}
-// This function is only used by the spellchecker for NextWord().
-// It doesn't handle LYX_ACCENTs and probably never will.
-WordLangTuple const LyXText::selectNextWordToSpellcheck(float & value)
-{
- if (the_locking_inset) {
- WordLangTuple word =
- the_locking_inset->selectNextWordToSpellcheck(bv(), value);
- if (!word.word().empty()) {
- value += float(cursor.y());
- value /= float(height);
- return word;
- }
- // we have to go on checking so move cursor to the next char
- if (cursor.pos() == cursorPar()->size()) {
- if (cursor.par() + 1 == int(ownerParagraphs().size()))
- return word;
- cursor.par(cursor.par() + 1);
- cursor.pos(0);
- } else {
- cursor.pos(cursor.pos() + 1);
- }
- }
- int const tmppar = cursor.par();
-
- // If this is not the very first word, skip rest of
- // current word because we are probably in the middle
- // of a word if there is text here.
- if (cursor.pos() || cursor.par() != 0) {
- while (cursor.pos() < cursorPar()->size()
- && cursorPar()->isLetter(cursor.pos()))
- cursor.pos(cursor.pos() + 1);
- }
-
- // Now, skip until we have real text (will jump paragraphs)
- while (true) {
- ParagraphList::iterator cpit = cursorPar();
- pos_type const cpos = cursor.pos();
-
- if (cpos == cpit->size()) {
- if (cursor.par() + 1 != int(ownerParagraphs().size())) {
- cursor.par(cursor.par() + 1);
- cursor.pos(0);
- continue;
- }
- break;
- }
-
- bool const is_good_inset = cpit->isInset(cpos)
- && cpit->getInset(cpos)->allowSpellcheck();
-
- if (!isDeletedText(*cpit, cpos)
- && (is_good_inset || cpit->isLetter(cpos)))
- break;
-
- cursor.pos(cpos + 1);
- }
-
- // now check if we hit an inset so it has to be a inset containing text!
- if (cursor.pos() < cursorPar()->size() &&
- cursorPar()->isInset(cursor.pos())) {
- // lock the inset!
- FuncRequest cmd(bv(), LFUN_INSET_EDIT, "left");
- cursorPar()->getInset(cursor.pos())->dispatch(cmd);
- // now call us again to do the above trick
- // but obviously we have to start from down below ;)
- return bv()->text->selectNextWordToSpellcheck(value);
- }
-
- // Update the value if we changed paragraphs
- if (cursor.par() != tmppar) {
- setCursor(cursor.par(), cursor.pos());
- value = float(cursor.y())/float(height);
- }
-
- // Start the selection from here
- selection.cursor = cursor;
-
- string lang_code = getFont(cursorPar(), cursor.pos()).language()->code();
- // and find the end of the word (insets like optional hyphens
- // and ligature break are part of a word)
- while (cursor.pos() < cursorPar()->size()
- && cursorPar()->isLetter(cursor.pos())
- && !isDeletedText(*cursorPar(), cursor.pos()))
- cursor.pos(cursor.pos() + 1);
-
- // Finally, we copy the word to a string and return it
- string str;
- if (selection.cursor.pos() < cursor.pos()) {
- for (pos_type i = selection.cursor.pos(); i < cursor.pos(); ++i) {
- if (!cursorPar()->isInset(i))
- str += cursorPar()->getChar(i);
- }
- }
- return WordLangTuple(str, lang_code);
-}
-
-
-// This one is also only for the spellchecker
-void LyXText::selectSelectedWord()
-{
- if (the_locking_inset) {
- the_locking_inset->selectSelectedWord(bv());
- return;
- }
- // move cursor to the beginning
- setCursor(selection.cursor.par(), selection.cursor.pos());
-
- // set the sel cursor
- selection.cursor = cursor;
-
- // now find the end of the word
- while (cursor.pos() < cursorPar()->size()
- && cursorPar()->isLetter(cursor.pos()))
- cursor.pos(cursor.pos() + 1);
-
- setCursor(cursorPar(), cursor.pos());
-
- // finally set the selection
- setSelection();
-}
-
-
// Delete from cursor up to the end of the current or next word.
void LyXText::deleteWordForward()
{