>>>>> "Jean-Marc" == Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes:
Jean-Marc> This patch makes sure that insetlatexaccents are considered Jean-Marc> as normal letters by the code that handles words Jean-Marc> (word-backward/forward, word-select). This is a version of the same thing for 1.3.X, which also contains some bug fixes already present in 1.4.0cvs. Comments? JMarc
Index: src/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v retrieving revision 1.1021.2.46 diff -u -r1.1021.2.46 ChangeLog --- src/ChangeLog 12 Nov 2004 14:47:37 -0000 1.1021.2.46 +++ src/ChangeLog 12 Nov 2004 15:07:55 -0000 @@ -1,5 +1,10 @@ 2004-11-12 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + * text.C (cursorLeftOneWord): + (getWord): simplify by using Paragraph::isWord + + * paragraph.C (isWord): invoke Inset::isLetter on insets + * lengthcommon.C (unitFromString): revert fix, which is is not needed (and indeed wrong) for 1.3.X Index: src/paragraph.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.C,v retrieving revision 1.235.2.3 diff -u -r1.235.2.3 paragraph.C --- src/paragraph.C 27 Sep 2004 10:55:57 -0000 1.235.2.3 +++ src/paragraph.C 12 Nov 2004 15:08:00 -0000 @@ -1681,7 +1681,10 @@ bool Paragraph::isWord(pos_type pos) const { - return IsWordChar(getChar(pos)) ; + if (isInset(pos)) + return getInset(pos)->isLetter(); + else + return IsWordChar(getChar(pos)) ; } Index: src/text.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v retrieving revision 1.283.2.2 diff -u -r1.283.2.2 text.C --- src/text.C 14 Feb 2003 21:37:49 -0000 1.283.2.2 +++ src/text.C 12 Nov 2004 15:08:07 -0000 @@ -2287,25 +2287,16 @@ { // treat HFills, floats and Insets as words cur = cursor; - while (cur.pos() - && (cur.par()->isSeparator(cur.pos() - 1) - || cur.par()->isKomma(cur.pos() - 1)) - && !(cur.par()->isHfill(cur.pos() - 1) - || cur.par()->isInset(cur.pos() - 1))) + while (cur.pos() && !cur.par()->isWord(cur.pos() - 1)) cur.pos(cur.pos() - 1); - if (cur.pos() - && (cur.par()->isInset(cur.pos() - 1) - || cur.par()->isHfill(cur.pos() - 1))) { - cur.pos(cur.pos() - 1); - } else if (!cur.pos()) { + if (!cur.pos()) { if (cur.par()->previous()) { cur.par(cur.par()->previous()); cur.pos(cur.par()->size()); } } else { // Here, cur != 0 - while (cur.pos() > 0 && - cur.par()->isWord(cur.pos() - 1)) + while (cur.pos() > 0 && cur.par()->isWord(cur.pos() - 1)) cur.pos(cur.pos() - 1); } } @@ -2316,45 +2307,39 @@ void LyXText::getWord(LyXCursor & from, LyXCursor & to, word_location const loc) const { - // first put the cursor where we wana start to select the word + // first put the cursor where we wanna start to select the word from = cursor; switch (loc) { case WHOLE_WORD_STRICT: if (cursor.pos() == 0 || cursor.pos() == cursor.par()->size() - || cursor.par()->isSeparator(cursor.pos()) - || cursor.par()->isKomma(cursor.pos()) - || cursor.par()->isSeparator(cursor.pos() - 1) - || cursor.par()->isKomma(cursor.pos() - 1)) { + || !cursor.par()->isWord(cursor.pos()) + || !cursor.par()->isWord(cursor.pos() - 1)) { to = from; return; } // no break here, we go to the next case WHOLE_WORD: - // Move cursor to the beginning, when not already there. - if (from.pos() && !from.par()->isSeparator(from.pos() - 1) - && !from.par()->isKomma(from.pos() - 1)) - cursorLeftOneWord(from); - break; + // If we are already at the beginning of a word, do nothing + if (!from.pos() || !from.par()->isWord(from.pos() - 1)) + break; + // no break here, we go to the next + case PREVIOUS_WORD: // always move the cursor to the beginning of previous word - cursorLeftOneWord(from); + while (from.pos() && from.par()->isWord(from.pos() - 1)) + from.pos(from.pos() - 1); break; case NEXT_WORD: lyxerr << "LyXText::getWord: NEXT_WORD not implemented yet\n"; break; case PARTIAL_WORD: + // no need to move the 'from' cursor break; } to = from; - while (to.pos() < to.par()->size() - && !to.par()->isSeparator(to.pos()) - && !to.par()->isKomma(to.pos()) - && !to.par()->isHfill(to.pos()) - && !to.par()->isInset(to.pos())) - { + while (to.pos() < to.par()->size() && to.par()->isWord(to.pos())) to.pos(to.pos() + 1); - } } Index: src/insets/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v retrieving revision 1.552.2.14 diff -u -r1.552.2.14 ChangeLog --- src/insets/ChangeLog 25 Oct 2004 08:51:39 -0000 1.552.2.14 +++ src/insets/ChangeLog 12 Nov 2004 15:08:21 -0000 @@ -1,3 +1,7 @@ +2004-11-12 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * insetlatexaccent.h (isLetter): implement + 2004-10-25 Jürgen Spitzmüller <[EMAIL PROTECTED]> * insetfoot.C (latex): use \thanks instead of \footnote on titlepage Index: src/insets/insetlatexaccent.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetlatexaccent.h,v retrieving revision 1.40 diff -u -r1.40 insetlatexaccent.h --- src/insets/insetlatexaccent.h 25 Sep 2002 14:26:11 -0000 1.40 +++ src/insets/insetlatexaccent.h 12 Nov 2004 15:08:21 -0000 @@ -76,6 +76,8 @@ inline bool canDisplay(); // should this inset be handled like a normal charater bool isChar() const { return true; } + /// is this equivalent to a letter? + bool isLetter() const { return candisp; } /// all the accent types enum ACCENT_TYPES{