From 221f1be82d3a79dfc76a413ef50330578f6ba662 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Fri, 15 Aug 2003 10:24:39 +0000 Subject: [PATCH] remove toggleSelection git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7552 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.C | 13 -------- src/BufferView.h | 2 -- src/BufferView_pimpl.C | 14 ++------ src/BufferView_pimpl.h | 2 -- src/ChangeLog | 6 ++++ src/frontends/ChangeLog | 5 +++ src/frontends/controllers/ChangeLog | 6 ++++ src/frontends/controllers/ControlErrorList.C | 2 -- .../controllers/ControlSpellchecker.C | 1 - src/frontends/screen.C | 32 ------------------- src/frontends/screen.h | 4 --- src/lyxfind.C | 7 ---- src/lyxtext.h | 5 ++- src/text3.C | 13 +------- 14 files changed, 25 insertions(+), 87 deletions(-) diff --git a/src/BufferView.C b/src/BufferView.C index dfeefc02c5..6850a52d6a 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -214,12 +214,6 @@ int BufferView::workWidth() const } -void BufferView::toggleSelection(bool b) -{ - pimpl_->toggleSelection(b); -} - - void BufferView::center() { pimpl_->center(); @@ -419,7 +413,6 @@ void BufferView::selectLastWord() beforeChange(text); text->selection.cursor = cur; text->selectSelectedWord(); - toggleSelection(false); update(); } @@ -442,13 +435,7 @@ void BufferView::replaceWord(string const & replacestring) LyXText * tt = getLyXText(); - // clear the selection (if there is any) - toggleSelection(false); - - // clear the selection (if there is any) - toggleSelection(false); tt->replaceSelectionWithString(replacestring); - tt->setSelectionRange(replacestring.length()); // Go back so that replacement string is also spellchecked diff --git a/src/BufferView.h b/src/BufferView.h index af356db3d2..6b3baae85a 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -155,8 +155,6 @@ public: /// FIXME bool fitLockedInsetCursor(int x, int y, int asc, int desc); - /// FIXME - void toggleSelection(bool = true); /// hide the cursor if it is visible void hideCursor(); diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 74090137c6..6e1e8ba482 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -577,7 +577,6 @@ void BufferView::Pimpl::selectionLost() { if (available()) { screen().hideCursor(); - toggleSelection(); bv_->getLyXText()->clearSelection(); bv_->text->xsel_cache.set(false); } @@ -662,19 +661,18 @@ Change const BufferView::Pimpl::getCurrentChange() if (!bv_->buffer()->params.tracking_changes) return Change(Change::UNCHANGED); - LyXText * t(bv_->getLyXText()); + LyXText * text = bv_->getLyXText(); - if (!t->selection.set()) + if (!text->selection.set()) return Change(Change::UNCHANGED); - LyXCursor const & cur(t->selection.start); + LyXCursor const & cur = text->selection.start; return cur.par()->lookupChangeFull(cur.pos()); } void BufferView::Pimpl::beforeChange(LyXText * text) { - toggleSelection(); text->clearSelection(); } @@ -763,12 +761,6 @@ void BufferView::Pimpl::insetUnlock() } -void BufferView::Pimpl::toggleSelection(bool b) -{ - screen().toggleSelection(bv_->text, bv_, b); -} - - void BufferView::Pimpl::center() { LyXText * t = bv_->text; diff --git a/src/BufferView_pimpl.h b/src/BufferView_pimpl.h index 1371bcd2f8..552a954aa1 100644 --- a/src/BufferView_pimpl.h +++ b/src/BufferView_pimpl.h @@ -89,8 +89,6 @@ struct BufferView::Pimpl : public boost::signals::trackable { /// void insetUnlock(); /// - void toggleSelection(bool = true); - /// void center(); /// bool insertInset(InsetOld * inset, string const & lout = string()); diff --git a/src/ChangeLog b/src/ChangeLog index 496dffa9d9..5ecc733f51 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -12,6 +12,12 @@ * text_funcs.C: split LyXText::rowlist_ into individual Paragraph::rows_ chunks + * BufferView.[Ch]: + * BufferView_pimpl.[Ch]: + * lyxfind.C: + * lyxtext.h: + * text3.C: remove toggleSelection() + 2003-08-12 Michael Schmitt * bufferlist.C: beautify two alerts (shorter text of buttons) diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index a62ca4de40..020cb74acf 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,8 @@ + +2003-08-15 André Pönitz + + * screen.[Ch]: remove toggle selection + 2003-08-02 Jean-Marc Lasgouttes * Makefile.am (SUBDIRS): use FRONTENDS_SUBDIRS diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index a58c70605d..08157861f4 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,9 @@ + +2003-08-15 André Pönitz + + * ControlErrorList.C: + * ControlSpellchecker.C: remove toggleSelection + 2003-08-12 Michael Schmitt * ControlGraphics.C: rename "XXX baseline" to "Baseline XXX" diff --git a/src/frontends/controllers/ControlErrorList.C b/src/frontends/controllers/ControlErrorList.C index 174a9974a8..594cab8f7a 100644 --- a/src/frontends/controllers/ControlErrorList.C +++ b/src/frontends/controllers/ControlErrorList.C @@ -75,11 +75,9 @@ void ControlErrorList::goTo(int item) // Now make the selection. BufferView * const bv = kernel().bufferview(); bv->insetUnlock(); - bv->toggleSelection(); bv->text->clearSelection(); bv->text->setCursor(pit.pit(), err.pos_start); bv->text->setSelectionRange(range); - bv->toggleSelection(false); bv->fitCursor(); bv->update(); } diff --git a/src/frontends/controllers/ControlSpellchecker.C b/src/frontends/controllers/ControlSpellchecker.C index de9c7ff3e3..95a9f6f1e8 100644 --- a/src/frontends/controllers/ControlSpellchecker.C +++ b/src/frontends/controllers/ControlSpellchecker.C @@ -149,7 +149,6 @@ void ControlSpellchecker::check() // clear any old selection LyXText * text = bufferview()->getLyXText(); - bufferview()->toggleSelection(true); bufferview()->update(); while (res == SpellBase::OK || res == SpellBase::IGNORE) { diff --git a/src/frontends/screen.C b/src/frontends/screen.C index 799c275c6e..33b3302b25 100644 --- a/src/frontends/screen.C +++ b/src/frontends/screen.C @@ -297,38 +297,6 @@ bool LyXScreen::fitCursor(LyXText * text, BufferView * bv) } -void LyXScreen::toggleSelection(LyXText * text, BufferView * bv, - bool kill_selection, - int yo, int xo) -{ - // only if there is a selection - if (!text->selection.set()) - return; - - int const bottom = min( - max(int(text->selection.end.y() - - text->getRow(text->selection.end)->baseline() - + text->getRow(text->selection.end)->height()), - text->top_y()), - int(text->top_y() + workarea().workHeight())); - int const top = min( - max(int(text->selection.start.y() - - text->getRow(text->selection.start)->baseline()), - text->top_y()), - int(text->top_y() + workarea().workHeight())); - - if (kill_selection) - text->selection.set(false); - - workarea().getPainter().start(); - - drawFromTo(text, bv, top - text->top_y(), bottom - text->top_y(), yo, xo); - expose(0, top - text->top_y(), workarea().workWidth(), bottom - top); - - workarea().getPainter().end(); -} - - void LyXScreen::redraw(BufferView & bv) { greyed_out_ = !bv.text; diff --git a/src/frontends/screen.h b/src/frontends/screen.h index f500017402..434611a554 100644 --- a/src/frontends/screen.h +++ b/src/frontends/screen.h @@ -92,10 +92,6 @@ public: /// toggle the cursor's visibility void toggleCursor(BufferView & bv); - /// FIXME - virtual void toggleSelection(LyXText *, BufferView *, bool = true, - int y_offset = 0, int x_offset = 0); - protected: /// cause the display of the given area of the work area virtual void expose(int x, int y, int w, int h) = 0; diff --git a/src/lyxfind.C b/src/lyxfind.C index 51367a2455..afc50357e8 100644 --- a/src/lyxfind.C +++ b/src/lyxfind.C @@ -198,7 +198,6 @@ int replace(BufferView * bv, if (!bv->theLockingInset() || ((text != bv->text) && (text->inset_owner == text->inset_owner->getLockingInset()))) { - bv->toggleSelection(false); text->replaceSelectionWithString(replacestr); text->setSelectionRange(replacestr.length()); ++replace_count; @@ -247,7 +246,6 @@ bool find(BufferView * bv, text->cursor = forward ? text->selection.end : text->selection.start; - bv->toggleSelection(); text->clearSelection(); SearchResult result = forward ? @@ -261,7 +259,6 @@ bool find(BufferView * bv, if (result == SR_FOUND) { bv->unlockInset(bv->theLockingInset()); text->setSelectionRange(searchstr.length()); - bv->toggleSelection(false); } else if (result == SR_NOT_FOUND) { bv->unlockInset(bv->theLockingInset()); found = false; @@ -281,7 +278,6 @@ SearchResult find(BufferView * bv, LyXText * text, text->cursor = forward ? text->selection.end : text->selection.start; - bv->toggleSelection(); text->clearSelection(); SearchResult result = forward ? @@ -351,7 +347,6 @@ SearchResult findNextChange(BufferView * bv, LyXText * text, pos_type & length) if (text->selection.set()) text->cursor = text->selection.end; - bv->toggleSelection(); text->clearSelection(); return nextChange(bv, text, length); @@ -385,7 +380,6 @@ bool findNextChange(BufferView * bv) if (text->selection.set()) text->cursor = text->selection.end; - bv->toggleSelection(); text->clearSelection(); SearchResult result = nextChange(bv, text, length); @@ -398,7 +392,6 @@ bool findNextChange(BufferView * bv) if (result == SR_FOUND) { bv->unlockInset(bv->theLockingInset()); text->setSelectionRange(length); - bv->toggleSelection(false); } else if (result == SR_NOT_FOUND) { bv->unlockInset(bv->theLockingInset()); found = false; diff --git a/src/lyxtext.h b/src/lyxtext.h index d393cc76fc..59140c7f89 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -39,7 +39,10 @@ class Dimension; /** - This class holds the mapping between buffer paragraphs and screen rows. + This class used to hold the mapping between buffer paragraphs and + screen rows. Nowadays, the Paragraphs take care of their rows + themselves and this contains just most of the code for manipulating + them and interaction with the Cursor. */ // The inheritance from TextCursor should go. It's just there to ease diff --git a/src/text3.C b/src/text3.C index 1b3d0b1875..ca471a16f7 100644 --- a/src/text3.C +++ b/src/text3.C @@ -1172,14 +1172,10 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd) if (!isInInset() && bv->theLockingInset()) break; if (cmd.button() == mouse_button::button1) { - if (!isInInset()) - bv->screen().toggleSelection(this, bv); cursorHome(); selection.cursor = cursor; cursorEnd(); setSelection(); - if (!isInInset()) - bv->screen().toggleSelection(this, bv, false); bv->update(); bv->haveSelection(selection.set()); } @@ -1191,13 +1187,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd) if (!isInInset() && bv->theLockingInset()) break; if (cmd.button() == mouse_button::button1) { - if (!isInInset()) { - bv->screen().toggleSelection(this, bv); - selectWord(lyx::WHOLE_WORD_STRICT); - bv->screen().toggleSelection(this, bv, false); - } else { - selectWord(lyx::WHOLE_WORD_STRICT); - } + selectWord(lyx::WHOLE_WORD_STRICT); bv->update(); bv->haveSelection(selection.set()); } @@ -1314,7 +1304,6 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd) selection_possible = true; // Clear the selection - bv->screen().toggleSelection(bv->text, bv); bv->text->clearSelection(); bv->update(); bv->updateScrollbar(); -- 2.39.5