small stuff:

- fix yesterday's selection regression
- remove a few update() calls
- remove unused  Selection::last_sel_cursor member
- ...


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7504 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-08-05 10:54:19 +00:00
parent 60f18824f7
commit 19f83569df
8 changed files with 52 additions and 86 deletions

View File

@ -7,6 +7,8 @@
* text2.C:
* text3.C: rip out "deep update"
* textcursor.[Ch] (last_sel_cursor): remove unused member
2003-08-04 André Pönitz <poenitz@gmx.net>
* BufferView.[Ch]:

View File

@ -34,11 +34,6 @@ InsetLabel::InsetLabel(InsetCommandParams const & p)
{}
// InsetLabel::InsetLabel(InsetCommandParams const & p, bool)
// : InsetCommand(p, false)
// {}
InsetLabel::~InsetLabel()
{
InsetCommandMailer("label", *this).hideDialog();
@ -53,8 +48,6 @@ void InsetLabel::getLabelList(std::vector<string> & list) const
dispatch_result InsetLabel::localDispatch(FuncRequest const & cmd)
{
InsetOld::RESULT result = UNDISPATCHED;
switch (cmd.action) {
case LFUN_INSET_EDIT:

View File

@ -1373,23 +1373,21 @@ void InsetText::fitInsetCursor(BufferView * bv) const
}
InsetOld::RESULT
InsetText::moveRight(BufferView * bv, bool activate_inset, bool selecting)
InsetOld::RESULT InsetText::moveRight(BufferView * bv)
{
if (text_.cursor.par()->isRightToLeftPar(bv->buffer()->params))
return moveLeftIntern(bv, false, activate_inset, selecting);
return moveLeftIntern(bv, false, true, false);
else
return moveRightIntern(bv, true, activate_inset, selecting);
return moveRightIntern(bv, true, true, false);
}
InsetOld::RESULT
InsetText::moveLeft(BufferView * bv, bool activate_inset, bool selecting)
InsetOld::RESULT InsetText::moveLeft(BufferView * bv)
{
if (text_.cursor.par()->isRightToLeftPar(bv->buffer()->params))
return moveRightIntern(bv, true, activate_inset, selecting);
return moveRightIntern(bv, true, true, false);
else
return moveLeftIntern(bv, false, activate_inset, selecting);
return moveLeftIntern(bv, false, true, false);
}

View File

@ -235,13 +235,9 @@ private:
void lfunMouseMotion(FuncRequest const &);
///
RESULT moveRight(BufferView *,
bool activate_inset = true,
bool selecting = false);
RESULT moveRight(BufferView *);
///
RESULT moveLeft(BufferView *,
bool activate_inset = true,
bool selecting = false);
RESULT moveLeft(BufferView *);
///
RESULT moveRightIntern(BufferView *, bool front,
bool activate_inset = true,

View File

@ -2079,7 +2079,6 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
fixCursorAfterDelete(selection.cursor, old_cursor);
fixCursorAfterDelete(selection.start, old_cursor);
fixCursorAfterDelete(selection.end, old_cursor);
fixCursorAfterDelete(last_sel_cursor, old_cursor);
return false;
}
}

View File

@ -67,16 +67,16 @@ namespace {
{
LyXText * lt = bv->getLyXText();
if (selecting || lt->selection.mark()) {
//if (!lt->selection.set())
// lt->selection.cursor = lt->cursor;
if (selecting || lt->selection.mark())
lt->setSelection();
if (lt->isInInset())
bv->updateInset();
}
bv->update();
if (!lt->selection.set())
bv->haveSelection(false);
bv->update();
bv->switchKeyMap();
}
@ -91,7 +91,7 @@ namespace {
// check if the given co-ordinates are inside an inset at the
// given cursor, if one exists. If so, the inset is returned,
// and the co-ordinates are made relative. Otherwise, 0 is returned.
InsetOld * checkInset(BufferView * /*bv*/, LyXText & text,
InsetOld * checkInset(BufferView * /*bv*/, LyXText & text,
LyXCursor const & cur, int & x, int & y)
{
lyx::pos_type const pos = cur.pos();
@ -471,14 +471,12 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
cursorRightOneWord();
else
cursorLeftOneWord();
update();
finishChange(bv);
break;
case LFUN_BEGINNINGBUF:
if (!selection.mark())
bv->beforeChange(this);
update();
cursorTop();
finishChange(bv);
break;
@ -486,13 +484,13 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
case LFUN_ENDBUF:
if (selection.mark())
bv->beforeChange(this);
update();
cursorBottom();
finishChange(bv);
break;
case LFUN_RIGHTSEL:
update();
if (!selection.set())
selection.cursor = cursor;
if (cursor.par()->isRightToLeftPar(bv->buffer()->params))
cursorLeft(bv);
else
@ -501,7 +499,8 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
break;
case LFUN_LEFTSEL:
update();
if (!selection.set())
selection.cursor = cursor;
if (cursor.par()->isRightToLeftPar(bv->buffer()->params))
cursorRight(bv);
else
@ -510,55 +509,62 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
break;
case LFUN_UPSEL:
update();
if (!selection.set())
selection.cursor = cursor;
cursorUp(true);
finishChange(bv, true);
break;
case LFUN_DOWNSEL:
update();
if (!selection.set())
selection.cursor = cursor;
cursorDown(true);
finishChange(bv, true);
break;
case LFUN_UP_PARAGRAPHSEL:
update();
if (!selection.set())
selection.cursor = cursor;
cursorUpParagraph();
finishChange(bv, true);
break;
case LFUN_DOWN_PARAGRAPHSEL:
update();
if (!selection.set())
selection.cursor = cursor;
cursorDownParagraph();
finishChange(bv, true);
break;
case LFUN_PRIORSEL:
update();
if (!selection.set())
selection.cursor = cursor;
cursorPrevious();
finishChange(bv, true);
break;
case LFUN_NEXTSEL:
update();
if (!selection.set())
selection.cursor = cursor;
cursorNext();
finishChange(bv, true);
break;
case LFUN_HOMESEL:
update();
if (!selection.set())
selection.cursor = cursor;
cursorHome();
finishChange(bv, true);
break;
case LFUN_ENDSEL:
update();
if (!selection.set())
selection.cursor = cursor;
cursorEnd();
finishChange(bv, true);
break;
case LFUN_WORDRIGHTSEL:
update();
if (cursor.par()->isRightToLeftPar(bv->buffer()->params))
cursorLeftOneWord();
else
@ -567,7 +573,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
break;
case LFUN_WORDLEFTSEL:
update();
if (cursor.par()->isRightToLeftPar(bv->buffer()->params))
cursorRightOneWord();
else
@ -576,7 +581,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
break;
case LFUN_WORDSEL: {
update();
LyXCursor cur1 = cursor;
LyXCursor cur2;
::getWord(cur1, cur2, lyx::WHOLE_WORD, ownerParagraphs());
@ -591,7 +595,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
bool is_rtl = cursor.par()->isRightToLeftPar(bv->buffer()->params);
if (!selection.mark())
bv->beforeChange(this);
update();
if (is_rtl)
cursorLeft(false);
if (cursor.pos() < cursor.par()->size()
@ -615,7 +618,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
bool const is_rtl = cursor.par()->isRightToLeftPar(bv->buffer()->params);
if (!selection.mark())
bv->beforeChange(this);
update();
LyXCursor const cur = cursor;
if (!is_rtl)
cursorLeft(false);
@ -638,7 +640,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
case LFUN_UP:
if (!selection.mark())
bv->beforeChange(this);
bv->update();
cursorUp(false);
finishChange(bv);
break;
@ -646,7 +647,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
case LFUN_DOWN:
if (!selection.mark())
bv->beforeChange(this);
bv->update();
cursorDown(false);
finishChange(bv);
break;
@ -654,7 +654,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
case LFUN_UP_PARAGRAPH:
if (!selection.mark())
bv->beforeChange(this);
bv->update();
cursorUpParagraph();
finishChange(bv);
break;
@ -662,7 +661,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
case LFUN_DOWN_PARAGRAPH:
if (!selection.mark())
bv->beforeChange(this);
bv->update();
cursorDownParagraph();
finishChange(bv, false);
break;
@ -670,7 +668,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
case LFUN_PRIOR:
if (!selection.mark())
bv->beforeChange(this);
bv->update();
cursorPrevious();
finishChange(bv, false);
break;
@ -678,7 +675,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
case LFUN_NEXT:
if (!selection.mark())
bv->beforeChange(this);
bv->update();
cursorNext();
finishChange(bv, false);
break;
@ -686,7 +682,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
case LFUN_HOME:
if (!selection.mark())
bv->beforeChange(this);
update();
cursorHome();
finishChange(bv, false);
break;
@ -694,7 +689,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
case LFUN_END:
if (!selection.mark())
bv->beforeChange(this);
update();
cursorEnd();
finishChange(bv, false);
break;
@ -708,7 +702,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
replaceSelection(bv->getLyXText());
insertInset(new InsetNewline);
update();
setCursor(cursor.par(), cursor.pos());
moveCursorUpdate(bv, false);
break;
@ -718,12 +711,10 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
if (!selection.set()) {
Delete();
selection.cursor = cursor;
update();
// It is possible to make it a lot faster still
// just comment out the line below...
} else {
cutSelection(true, false);
update();
}
moveCursorUpdate(bv, false);
bv->owner()->view_state_changed();
@ -772,16 +763,15 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
if (bv->owner()->getIntl().getTransManager().backspace()) {
backspace();
selection.cursor = cursor;
update();
// It is possible to make it a lot faster still
// just comment out the line below...
}
} else {
cutSelection(true, false);
update();
}
bv->owner()->view_state_changed();
bv->switchKeyMap();
update();
break;
case LFUN_BACKSPACE_SKIP:
@ -789,14 +779,14 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
if (!selection.set()) {
LyXCursor cur = cursor;
if (cur.pos() == 0
&& !(cur.par()->params().spaceTop()
== VSpace (VSpace::NONE))) {
&& !(cur.par()->params().spaceTop() == VSpace(VSpace::NONE))) {
setParagraph(
cur.par()->params().lineTop(),
cur.par()->params().lineBottom(),
cur.par()->params().pagebreakTop(),
cur.par()->params().pagebreakBottom(),
VSpace(VSpace::NONE), cur.par()->params().spaceBottom(),
VSpace(VSpace::NONE),
cur.par()->params().spaceBottom(),
cur.par()->params().spacing(),
cur.par()->params().align(),
cur.par()->params().labelWidthString(), 0);
@ -961,14 +951,13 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
case LFUN_SETMARK:
bv->beforeChange(this);
if (selection.mark()) {
update();
cmd.message(N_("Mark removed"));
} else {
selection.mark(true);
update();
cmd.message(N_("Mark set"));
}
selection.cursor = cursor;
update();
break;
case LFUN_UPCASE_WORD:
@ -980,7 +969,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
break;
case LFUN_LOWCASE_WORD:
update();
changeCase(LyXText::text_lowercase);
if (inset_owner)
bv->updateInset();
@ -988,7 +976,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
break;
case LFUN_CAPITALIZE_WORD:
update();
changeCase(LyXText::text_capitalization);
if (inset_owner)
bv->updateInset();
@ -996,7 +983,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
break;
case LFUN_TRANSPOSE_CHARS:
update();
recordUndo(bv, Undo::ATOMIC, cursor.par());
if (transposeChars(cursor))
checkParagraph(cursor.par(), cursor.pos());
@ -1023,10 +1009,9 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
}
case LFUN_CUT:
update();
cutSelection(true, true);
update();
cmd.message(_("Cut"));
update();
break;
case LFUN_COPY:
@ -1037,17 +1022,17 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
case LFUN_BEGINNINGBUFSEL:
if (inset_owner)
return UNDISPATCHED;
update();
cursorTop();
finishChange(bv, true);
update();
break;
case LFUN_ENDBUFSEL:
if (inset_owner)
return UNDISPATCHED;
update();
cursorBottom();
finishChange(bv, true);
update();
break;
case LFUN_GETXY:

View File

@ -2,22 +2,16 @@
#include "textcursor.h"
bool TextCursor::setSelection()
void TextCursor::setSelection()
{
bool const lsel = selection.set();
if (!selection.set()) {
last_sel_cursor = selection.cursor;
selection.start = selection.cursor;
selection.end = selection.cursor;
}
selection.set(true);
last_sel_cursor = cursor;
// and now the whole selection
if (selection.cursor.par() == cursor.par())
if (selection.cursor.pos() < cursor.pos()) {
selection.end = cursor;
@ -40,9 +34,9 @@ bool TextCursor::setSelection()
// a selection with no contents is not a selection
if (selection.start.par() == selection.end.par() &&
selection.start.pos() == selection.end.pos())
{
selection.set(false);
return lsel;
}
}
@ -50,7 +44,9 @@ void TextCursor::clearSelection()
{
selection.set(false);
selection.mark(false);
last_sel_cursor = selection.end = selection.start = selection.cursor = cursor;
selection.end = cursor;
selection.start = cursor;
selection.cursor = cursor;
}

View File

@ -59,8 +59,8 @@ private:
};
struct TextCursor {
/// returns true if selection was set previously
bool setSelection();
///
void setSelection();
///
void clearSelection();
///
@ -72,9 +72,6 @@ struct TextCursor {
Selection selection;
// this is used to handle XSelection events in the right manner
Selection xsel_cache;
/// needed for the toggling (cursor position on last selection made)
LyXCursor last_sel_cursor;
};
#endif