]> git.lyx.org Git - features.git/commitdiff
fix two lfuns
authorAlfredo Braunstein <abraunst@lyx.org>
Wed, 14 Jan 2004 09:33:14 +0000 (09:33 +0000)
committerAlfredo Braunstein <abraunst@lyx.org>
Wed, 14 Jan 2004 09:33:14 +0000 (09:33 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8341 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/lyxtext.h
src/text.C
src/text2.C
src/text3.C

index 94d2b8530180f8b40b01407dba2072368bffcfb9..2eebfe60009f85fc415739ec72c2e9df35a7c92a 100644 (file)
@@ -1,3 +1,7 @@
+2004-01-14  Alfredo Braunstein  <abraunst@lyx.org>
+
+       * text.C (getWord): fix getWord (and thus LFUN_WORDSEL)
+       * text3.C (dispatch): fix LFUN_WORD{RIGHT,LEFT}SEL
 
 2004-01-13  André Pönitz  <poenitz@gmx.net>
 
index 282a12e9b7d4866ab4b78a2bc1bbdc62033f5881..e652eb8efc6e7cc94a92eb034419115ee7b36ac5 100644 (file)
@@ -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);
index 82eb64ec91f6074fcb26b1a80c431bd7f9e36475..4ac22948e36c1adccafdadfae25a71e43949f0b5 100644 (file)
@@ -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())
index 1d5dc716a7803c395fadeb434934c122707968ef..811ca906eeac832a04a57a3a6c73af401d636851 100644 (file)
@@ -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();
index bfd7fe534151b15de216795faf4862da73739e6f..61fb2b28b20b2bb9de5fdb5328fcbd787d9e947b 100644 (file)
@@ -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;
        }