fix LyXText::getWord (bug 1609)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8828 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2004-06-29 15:43:25 +00:00
parent 228ecfce96
commit dc5326c28f
3 changed files with 22 additions and 22 deletions

View File

@ -1,3 +1,11 @@
2004-06-29 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* paragraph.C (isWord): return true on insets that report
isLetter().
* text.C (getWord): use Paragraph::isWord to decide what is in a
word and what is not; fix bug 1609.
2004-06-27 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* tex-strings.C: add "none" to string_paperpackages[], fixes

View File

@ -1524,7 +1524,9 @@ bool Paragraph::isLetter(pos_type pos) const
bool Paragraph::isWord(pos_type pos) const
{
unsigned char const c = getChar(pos);
if (isInset(pos))
return getInset(pos)->isLetter();
value_type const c = getChar(pos);
return !(IsSeparatorChar(c)
|| IsKommaChar(c)
|| IsInsetChar(c));

View File

@ -1842,46 +1842,36 @@ void LyXText::getWord(CursorSlice & from, CursorSlice & to,
switch (loc) {
case lyx::WHOLE_WORD_STRICT:
if (from.pos() == 0 || from.pos() == from_par.size()
|| from_par.isSeparator(from.pos())
|| from_par.isKomma(from.pos())
|| from_par.isNewline(from.pos())
|| from_par.isSeparator(from.pos() - 1)
|| from_par.isKomma(from.pos() - 1)
|| from_par.isNewline(from.pos() - 1)) {
|| !from_par.isWord(from.pos())
|| !from_par.isWord(from.pos() - 1)) {
to = from;
return;
}
// no break here, we go to the next
case lyx::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)
|| from_par.isNewline(from.pos() - 1)))
cursorLeftOneWord(bv()->cursor());
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 lyx::PREVIOUS_WORD:
// always move the cursor to the beginning of previous word
cursorLeftOneWord(bv()->cursor());
while (from.pos() && from_par.isWord(from.pos() - 1))
--from.pos();
break;
case lyx::NEXT_WORD:
lyxerr << "LyXText::getWord: NEXT_WORD not implemented yet"
<< endl;
break;
case lyx::PARTIAL_WORD:
// no need to move the 'from' cursor
break;
}
to = from;
Paragraph & to_par = pars_[to.par()];
while (to.pos() < to_par.size()
&& !to_par.isSeparator(to.pos())
&& !to_par.isKomma(to.pos())
&& !to_par.isNewline(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();
}
}