+2004-11-16 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
+
+ * paragraph.C (isLetter): remove special spellchecker-related
+ code; return true also for digits
+ (isWord, isKomma): remove
+
+ * text.C (cursorRightOneWord, cursorLeftOneWord, getWord):
+ * lyxfind.C (MatchString()): use isLetter instead of isWord
+
2004-11-17 Lars Gullik Bjonnes <larsbj@gullik.net>
* pariterator.h (operatir=): comment out un-implemented member
function.
- * paragraph.h: resolv ambiguity found by gcc 4.0 with the use of a
+ * paragraph.h: resolve ambiguity found by gcc 4.0 with the use of a
static cast.
2004-11-17 Lars Gullik Bjonnes <larsbj@gullik.net>
+2004-11-18 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
+
+ * ControlSpellchecker.C (nextWord): rewrite to skip words
+ containing digits.
+ (isLetter): honor lyxrc.isp_esc_chars
+
2004-11-18 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* ControlTabular.C (initialiseParams): Compute the active cell
#endif
#endif
+#include "support/textutils.h"
#include "support/tostr.h"
#include "frontends/Alert.h"
namespace lyx {
using support::bformat;
+using support::contains;
namespace frontend {
return cur.inTexted()
&& cur.inset().allowSpellCheck()
&& cur.pos() != cur.lastpos()
- && cur.paragraph().isLetter(cur.pos())
+ && (cur.paragraph().isLetter(cur.pos())
+ // We want to pass the ' and escape chars to ispell
+ || contains(lyxrc.isp_esc_chars + '\'',
+ cur.paragraph().getChar(cur.pos())))
&& !isDeletedText(cur.paragraph(), cur.pos());
}
WordLangTuple nextWord(DocIterator & cur, ptrdiff_t & progress,
BufferParams & bp)
{
- // skip until we have real text (will jump paragraphs)
- for (; cur.size() && !isLetter(cur); cur.forwardPos());
+ bool inword = false;
+ bool ignoreword = false;
+ string word, lang_code;
+
+ while(cur.size()) {
+ if (isLetter(cur)) {
+ if (!inword) {
+ inword = true;
+ ignoreword = false;
+ word.clear();
+ lang_code = cur.paragraph().getFontSettings(bp, cur.pos()).language()->code();
+ }
+ // Insets like optional hyphens and ligature
+ // break are part of a word.
+ if (!cur.paragraph().isInset(cur.pos())) {
+ Paragraph::value_type const c =
+ cur.paragraph().getChar(cur.pos());
+ word += c;
+ if (IsDigit(c))
+ ignoreword = true;
+ }
+ } else { // !isLetter(cur)
+ if (inword)
+ if (!ignoreword)
+ return WordLangTuple(word, lang_code);
+ else
+ inword = false;
+ }
+
+ cur.forwardPos();
++progress;
-
- // hit end
- if (cur.empty())
- return WordLangTuple(string(), string());
-
- string lang_code = cur.paragraph().
- getFontSettings(bp, cur.pos()).language()->code();
- string str;
- // and find the end of the word (insets like optional hyphens
- // and ligature break are part of a word)
- for (; cur && isLetter(cur); cur.forwardPos(), ++progress) {
- if (!cur.paragraph().isInset(cur.pos()))
- str += cur.paragraph().getChar(cur.pos());
}
- return WordLangTuple(str, lang_code);
+ return WordLangTuple(string(), string());
}
} // namespace anon
// if necessary, check whether string matches word
if (mw) {
- if (pos > 0 && par.isWord(pos - 1))
+ if (pos > 0 && par.isLetter(pos - 1))
return false;
if (pos + lyx::pos_type(size) < parsize
- && par.isWord(pos + size));
+ && par.isLetter(pos + size));
return false;
}
using lyx::pos_type;
-using lyx::support::contains;
using lyx::support::subst;
using std::distance;
}
-bool Paragraph::isKomma(pos_type pos) const
-{
- return IsKommaChar(getChar(pos));
-}
-
-
/// Used by the spellchecker
bool Paragraph::isLetter(pos_type pos) const
-{
- value_type const c = getChar(pos);
- if (IsLetterChar(c))
- return true;
- if (isInset(pos))
- return getInset(pos)->isLetter();
- // We want to pass the ' and escape chars to ispell
- string const extra = lyxrc.isp_esc_chars + '\'';
- return contains(extra, c);
-}
-
-
-bool Paragraph::isWord(pos_type pos) const
{
if (isInset(pos))
return getInset(pos)->isLetter();
- value_type const c = getChar(pos);
- return !(IsSeparatorChar(c)
- || IsKommaChar(c)
- || IsInsetChar(c));
+ else {
+ value_type const c = getChar(pos);
+ return IsLetterChar(c) || IsDigit(c);
+ }
}
bool isSeparator(lyx::pos_type pos) const;
///
bool isLineSeparator(lyx::pos_type pos) const;
- ///
- bool isKomma(lyx::pos_type pos) const;
- /// Used by the spellchecker
+ /// True if the character/inset at this point can be part of a word
+ // Note that digits in particular are considered as letters
bool isLetter(lyx::pos_type pos) const;
- ///
- bool isWord(lyx::pos_type pos) const;
/// returns -1 if inset not found
int getPositionOfInset(InsetBase const * inset) const;
+2004-11-16 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
+
+ * textutils.h (isKommaChar): remove
+
2004-11-16 Lars Gullik Bjonnes <larsbj@gullik.net>
* forkedcontr.C (find_pid): simplify and also make pass concept
2004-11-07 Lars Gullik Bjonnes <larsbj@gullik.net>
- * Make it clearer where include files are comming from.
+ * Make it clearer where include files are coming from.
2004-11-06 Lars Gullik Bjonnes <larsbj@gullik.net>
}
-/// return true if the char is "punctuation"
-inline
-bool IsKommaChar(char c)
-{
- return c == ','
- || c == '('
- || c == ')'
- || c == '['
- || c == ']'
- || c == '{'
- || c == '}'
- || c == ';'
- || c == '.'
- || c == ':'
- || c == '-'
- || c == '?'
- || c == '!'
- || c == '&'
- || c == '@'
- || c == '+'
- || c == '-'
- || c == '~'
- || c == '#'
- || c == '%'
- || c == '^'
- || c == '/'
- || c == '\\';
-}
-
-
/// return true if a char is alphabetical (including accented chars)
inline
bool IsLetterChar(unsigned char c)
} else {
// Skip through initial nonword stuff.
// Treat floats and insets as words.
- while (cur.pos() != cur.lastpos() && !cur.paragraph().isWord(cur.pos()))
+ while (cur.pos() != cur.lastpos() && !cur.paragraph().isLetter(cur.pos()))
++cur.pos();
// Advance through word.
- while (cur.pos() != cur.lastpos() && cur.paragraph().isWord(cur.pos()))
+ while (cur.pos() != cur.lastpos() && cur.paragraph().isLetter(cur.pos()))
++cur.pos();
}
setCursor(cur, cur.par(), cur.pos());
} else {
// Skip through initial nonword stuff.
// Treat floats and insets as words.
- while (cur.pos() != 0 && !cur.paragraph().isWord(cur.pos() - 1))
+ while (cur.pos() != 0 && !cur.paragraph().isLetter(cur.pos() - 1))
--cur.pos();
// Advance through word.
- while (cur.pos() != 0 && cur.paragraph().isWord(cur.pos() - 1))
+ while (cur.pos() != 0 && cur.paragraph().isLetter(cur.pos() - 1))
--cur.pos();
}
setCursor(cur, cur.par(), cur.pos());
switch (loc) {
case lyx::WHOLE_WORD_STRICT:
if (from.pos() == 0 || from.pos() == from_par.size()
- || !from_par.isWord(from.pos())
- || !from_par.isWord(from.pos() - 1)) {
+ || !from_par.isLetter(from.pos())
+ || !from_par.isLetter(from.pos() - 1)) {
to = from;
return;
}
case lyx::WHOLE_WORD:
// If we are already at the beginning of a word, do nothing
- if (!from.pos() || !from_par.isWord(from.pos() - 1))
+ if (!from.pos() || !from_par.isLetter(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
- while (from.pos() && from_par.isWord(from.pos() - 1))
+ while (from.pos() && from_par.isLetter(from.pos() - 1))
--from.pos();
break;
case lyx::NEXT_WORD:
}
to = from;
Paragraph & to_par = pars_[to.par()];
- while (to.pos() < to_par.size() && to_par.isWord(to.pos()))
+ while (to.pos() < to_par.size() && to_par.isLetter(to.pos()))
++to.pos();
}