From: André Pönitz Date: Tue, 5 Aug 2003 10:54:19 +0000 (+0000) Subject: small stuff: X-Git-Tag: 1.6.10~16330 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=19f83569df43f11957287c378fbc3b40a003f17c;p=features.git 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 --- diff --git a/src/ChangeLog b/src/ChangeLog index ede4f47e31..fe2889bf9c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -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 * BufferView.[Ch]: diff --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index 2c7e2b013e..b989b6520a 100644 --- a/src/insets/insetlabel.C +++ b/src/insets/insetlabel.C @@ -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 & list) const dispatch_result InsetLabel::localDispatch(FuncRequest const & cmd) { - InsetOld::RESULT result = UNDISPATCHED; - switch (cmd.action) { case LFUN_INSET_EDIT: diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 3a3c51b5a6..ef47ea9f35 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -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); } diff --git a/src/insets/insettext.h b/src/insets/insettext.h index e5adc0a135..f567eba2ab 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -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, diff --git a/src/text2.C b/src/text2.C index 1678333bc4..8377ed5abc 100644 --- a/src/text2.C +++ b/src/text2.C @@ -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; } } diff --git a/src/text3.C b/src/text3.C index 26561b6422..fc2c2e6127 100644 --- a/src/text3.C +++ b/src/text3.C @@ -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: diff --git a/src/textcursor.C b/src/textcursor.C index ecb6584a8e..e5d1aede83 100644 --- a/src/textcursor.C +++ b/src/textcursor.C @@ -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; } diff --git a/src/textcursor.h b/src/textcursor.h index 5e1c982c70..a7187eb3d9 100644 --- a/src/textcursor.h +++ b/src/textcursor.h @@ -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