From bc596c4af7668cf1a3dcf424b8a2e22ba30d6150 Mon Sep 17 00:00:00 2001 From: Alfredo Braunstein Date: Wed, 14 Jan 2004 09:33:14 +0000 Subject: [PATCH] fix two lfuns git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8341 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 4 ++++ src/lyxtext.h | 6 +++++- src/text.C | 2 +- src/text2.C | 3 +-- src/text3.C | 11 +++++------ 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 94d2b85301..2eebfe6000 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2004-01-14 Alfredo Braunstein + + * text.C (getWord): fix getWord (and thus LFUN_WORDSEL) + * text3.C (dispatch): fix LFUN_WORD{RIGHT,LEFT}SEL 2004-01-13 André Pönitz diff --git a/src/lyxtext.h b/src/lyxtext.h index 282a12e9b7..e652eb8efc 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -178,7 +178,11 @@ public: lyx::pos_type getColumnNearX(ParagraphList::iterator pit, Row const & row, int & x, bool & boundary) const; - /// select the word we need depending on word_location + /** Find the word under \c from in the relative location + * defined by \c word_location. + * @param from return here the start of the word + * @param to return here the end of the word + */ void getWord(CursorSlice & from, CursorSlice & to, lyx::word_location const); /// just selects the word the cursor is in void selectWord(lyx::word_location loc); diff --git a/src/text.C b/src/text.C index 82eb64ec91..4ac22948e3 100644 --- a/src/text.C +++ b/src/text.C @@ -1710,7 +1710,6 @@ void LyXText::cursorRightOneWord(CursorSlice & cur) void LyXText::getWord(CursorSlice & from, CursorSlice & to, word_location const loc) { ParagraphList::iterator from_par = getPar(from); - ParagraphList::iterator to_par = getPar(to); switch (loc) { case lyx::WHOLE_WORD_STRICT: if (from.pos() == 0 || from.pos() == from_par->size() @@ -1744,6 +1743,7 @@ void LyXText::getWord(CursorSlice & from, CursorSlice & to, word_location const break; } to = from; + ParagraphList::iterator to_par = getPar(to); while (to.pos() < to_par->size() && !to_par->isSeparator(to.pos()) && !to_par->isKomma(to.pos()) diff --git a/src/text2.C b/src/text2.C index 1d5dc716a7..811ca906ee 100644 --- a/src/text2.C +++ b/src/text2.C @@ -1149,8 +1149,7 @@ void LyXText::setCursor(CursorSlice & cur, paroffset_type par, if (paragraphs().begin()->rows.empty()) return; - // get the cursor y position in text - + // now some strict checking ParagraphList::iterator pit = getPar(par); Row const & row = *pit->getRow(pos); pos_type const end = row.endpos(); diff --git a/src/text3.C b/src/text3.C index bfd7fe5341..61fb2b28b2 100644 --- a/src/text3.C +++ b/src/text3.C @@ -618,6 +618,8 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd) break; case LFUN_WORDRIGHTSEL: + if (!selection.set()) + bv->resetAnchor(); if (rtl()) cursorLeftOneWord(); else @@ -626,6 +628,8 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd) break; case LFUN_WORDLEFTSEL: + if (!selection.set()) + bv->resetAnchor(); if (rtl()) cursorRightOneWord(); else @@ -634,12 +638,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd) break; case LFUN_WORDSEL: { - CursorSlice cur1 = cursor(); - CursorSlice cur2; - getWord(cur1, cur2, lyx::WHOLE_WORD); - setCursor(cur1.par(), cur1.pos()); - clearSelection(); - setCursor(cur2.par(), cur2.pos()); + selectWord(lyx::WHOLE_WORD); finishChange(bv, true); break; } -- 2.39.2