From 4ad989550c6357eef644b2c7124c16bba2af89b4 Mon Sep 17 00:00:00 2001 From: Alfredo Braunstein Date: Tue, 4 Nov 2003 11:36:28 +0000 Subject: [PATCH] remove dead spellcheck code git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8032 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.C | 36 ---------- src/BufferView.h | 7 -- src/ChangeLog | 7 ++ src/insets/ChangeLog | 10 +++ src/insets/inset.h | 5 -- src/insets/insetcollapsable.C | 12 ---- src/insets/insetcollapsable.h | 21 ------ src/insets/insetert.C | 9 --- src/insets/insetert.h | 5 -- src/insets/insettabular.C | 55 --------------- src/insets/insettabular.h | 10 +-- src/insets/insettext.C | 34 ---------- src/insets/insettext.h | 7 -- src/insets/updatableinset.C | 11 --- src/insets/updatableinset.h | 9 --- src/lyxtext.h | 9 --- src/text.C | 122 ---------------------------------- 17 files changed, 18 insertions(+), 351 deletions(-) diff --git a/src/BufferView.C b/src/BufferView.C index 1cdbf0c75e..3224536433 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -362,42 +362,6 @@ void BufferView::redo() } -// these functions are for the spellchecker -WordLangTuple const BufferView::nextWord(float & value) -{ - if (!available()) { - value = 1; - return WordLangTuple(); - } - - return text->selectNextWordToSpellcheck(value); -} - - -void BufferView::selectLastWord() -{ - if (!available()) - return; - - LyXCursor cur = text->selection.cursor; - beforeChange(text); - text->selection.cursor = cur; - text->selectSelectedWord(); - update(); -} - - -void BufferView::endOfSpellCheck() -{ - if (!available()) return; - - beforeChange(text); - text->selectSelectedWord(); - text->clearSelection(); - update(); -} - - void BufferView::replaceWord(string const & replacestring) { if (!available()) diff --git a/src/BufferView.h b/src/BufferView.h index f05a62fd68..34b9b25cba 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -33,7 +33,6 @@ class LyXView; class Painter; class TeXErrors; class UpdatableInset; -class WordLangTuple; /** * A buffer view encapsulates a view onto a particular @@ -135,14 +134,8 @@ public: /// return the parent language of the given inset Language const * getParentLanguage(InsetOld * inset) const; - /// Select the "current" word - void selectLastWord(); /// replace the currently selected word void replaceWord(std::string const & replacestring); - /// Update after spellcheck finishes - void endOfSpellCheck(); - /// return the next word - WordLangTuple const nextWord(float & value); /// move cursor to the named label void gotoLabel(std::string const & label); diff --git a/src/ChangeLog b/src/ChangeLog index 382ce9c62b..e879aa8c1e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ + +2003-11-04 Alfredo Braunstein + + * BufferView.[Ch]: + * lyxtext.h: + * text.C: remove dead spellcheck code + 2003-11-04 Lars Gullik Bjønnes * dispatchresult.h: add a val setter diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index da46b017e9..907802f427 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,13 @@ + +2003-11-04 Alfredo Braunstein + + * inset.h: + * insetcollapsable.[Ch]: + * insetert.[Ch]: + * insettabular.[Ch]: + * insettext.[Ch]: + * updatableinset.[Ch]: remove dead spellcheck code + 2003-11-04 Alfredo Braunstein * insettabular.C (lockInsetInInset): small fix diff --git a/src/insets/inset.h b/src/insets/inset.h index 50616a2b9a..45cde09eee 100644 --- a/src/insets/inset.h +++ b/src/insets/inset.h @@ -31,7 +31,6 @@ class LyXText; class Painter; class Paragraph; class UpdatableInset; -class WordLangTuple; namespace lyx { namespace graphics { @@ -257,10 +256,6 @@ public: /// we need this here because collapsed insets are only EDITABLE virtual void setFont(BufferView *, LyXFont const &, bool toggleall = false, bool selectall = false); - /// - // needed for spellchecking text - /// - virtual bool allowSpellcheck() const { return false; } // should this inset be handled like a normal charater virtual bool isChar() const { return false; } diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index c5587cb3e0..e3a889d80f 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -23,7 +23,6 @@ #include "funcrequest.h" #include "metricsinfo.h" #include "paragraph.h" -#include "WordLangTuple.h" #include "frontends/font_metrics.h" #include "frontends/Painter.h" @@ -564,17 +563,6 @@ bool InsetCollapsable::searchBackward(BufferView * bv, string const & str, } -WordLangTuple const -InsetCollapsable::selectNextWordToSpellcheck(BufferView * bv, float & value) const -{ - WordLangTuple word = inset.selectNextWordToSpellcheck(bv, value); - if (first_after_edit && word.word().empty()) - close(bv); - first_after_edit = false; - return word; -} - - void InsetCollapsable::addPreview(PreviewLoader & loader) const { inset.addPreview(loader); diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index da1723bda0..9a85975d83 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -130,13 +130,6 @@ public: void open(BufferView *); /// void close(BufferView *) const; - /// - bool allowSpellcheck() const; - /// - WordLangTuple const - selectNextWordToSpellcheck(BufferView *, float &) const; - /// - void selectSelectedWord(BufferView *); void markErased(); @@ -259,20 +252,6 @@ bool InsetCollapsable::isOpen() const } -inline -bool InsetCollapsable::allowSpellcheck() const -{ - return inset.allowSpellcheck(); -} - - -inline -void InsetCollapsable::selectSelectedWord(BufferView * bv) -{ - inset.selectSelectedWord(bv); -} - - inline Box const & InsetCollapsable::buttonDim() const { diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 77814f47e9..0dfa14f46d 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -24,7 +24,6 @@ #include "lyxlex.h" #include "metricsinfo.h" #include "paragraph.h" -#include "WordLangTuple.h" #include "frontends/Alert.h" #include "frontends/LyXView.h" @@ -644,14 +643,6 @@ void InsetERT::close(BufferView * bv) const } -WordLangTuple const -InsetERT::selectNextWordToSpellcheck(BufferView * bv, float &) const -{ - bv->unlockInset(const_cast(this)); - return WordLangTuple(); -} - - void InsetERT::getDrawFont(LyXFont & font) const { LyXFont f(LyXFont::ALL_INHERIT, latex_language); diff --git a/src/insets/insetert.h b/src/insets/insetert.h index 5617d6839c..2999f73397 100644 --- a/src/insets/insetert.h +++ b/src/insets/insetert.h @@ -92,11 +92,6 @@ public: /// void close(BufferView *) const; /// - bool allowSpellcheck() const { return false; } - - WordLangTuple const - selectNextWordToSpellcheck(BufferView *, float &) const; - /// void metrics(MetricsInfo &, Dimension &) const; /// void draw(PainterInfo & pi, int x, int y) const; diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 974e709145..38f0eb8296 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -30,7 +30,6 @@ #include "paragraph_funcs.h" #include "ParagraphParameters.h" #include "undo.h" -#include "WordLangTuple.h" #include "frontends/Alert.h" #include "frontends/font_metrics.h" @@ -2419,60 +2418,6 @@ LyXCursor const & InsetTabular::cursor(BufferView * bv) const } -WordLangTuple const -InsetTabular::selectNextWordToSpellcheck(BufferView * bv, float & value) const -{ - if (the_locking_inset) { - WordLangTuple word = - the_locking_inset->selectNextWordToSpellcheck(bv, value); - if (!word.word().empty()) - return word; - if (tabular.isLastCell(actcell)) { - bv->unlockInset(const_cast(this)); - return WordLangTuple(); - } - ++actcell; - } - // otherwise we have to lock the next inset and ask for it's selecttion - tabular.getCellInset(actcell) - .dispatch(FuncRequest(bv, LFUN_INSET_EDIT)); - WordLangTuple word = selectNextWordInt(bv, value); - if (!word.word().empty()) - resetPos(bv); - return word; -} - - -WordLangTuple InsetTabular::selectNextWordInt(BufferView * bv, float & value) const -{ - // when entering this function the inset should be ALWAYS locked! - BOOST_ASSERT(the_locking_inset); - - WordLangTuple word = - the_locking_inset->selectNextWordToSpellcheck(bv, value); - if (!word.word().empty()) - return word; - - if (tabular.isLastCell(actcell)) { - bv->unlockInset(const_cast(this)); - return WordLangTuple(); - } - - // otherwise we have to lock the next inset and ask for it's selecttion - ++actcell; - tabular.getCellInset(actcell) - .dispatch(FuncRequest(bv, LFUN_INSET_EDIT)); - return selectNextWordInt(bv, value); -} - - -void InsetTabular::selectSelectedWord(BufferView * bv) -{ - if (the_locking_inset) - the_locking_inset->selectSelectedWord(bv); -} - - void InsetTabular::markErased() { for (int cell = 0; cell < tabular.getNumberOfCells(); ++cell) diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index 52186a4ebf..145bd1ee64 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -165,14 +165,8 @@ public: LyXText * getText(int) const; /// LyXCursor const & cursor(BufferView *) const; - /// - bool allowSpellcheck() const { return true; } - /// - WordLangTuple const - selectNextWordToSpellcheck(BufferView *, float & value) const; - /// - void selectSelectedWord(BufferView *); + /// void markErased(); /// find next change @@ -285,8 +279,6 @@ private: void getSelection(int & scol, int & ecol, int & srow, int & erow) const; /// - WordLangTuple selectNextWordInt(BufferView *, float & value) const; - /// bool insertAsciiString(BufferView *, std::string const & buf, bool usePaste); // diff --git a/src/insets/insettext.C b/src/insets/insettext.C index ad28fc028c..150193edc1 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -35,7 +35,6 @@ #include "sgml.h" #include "texrow.h" #include "undo.h" -#include "WordLangTuple.h" #include "frontends/Alert.h" #include "frontends/font_metrics.h" @@ -1456,39 +1455,6 @@ LyXCursor const & InsetText::cursor(BufferView * bv) const } -WordLangTuple const -InsetText::selectNextWordToSpellcheck(BufferView * bv, float & value) const -{ - WordLangTuple word; - if (the_locking_inset) { - word = the_locking_inset->selectNextWordToSpellcheck(bv, value); - if (!word.word().empty()) { - value += cy(); - return word; - } - // we have to go on checking so move cursor to the next char - text_.cursor.pos(text_.cursor.pos() + 1); - } - word = text_.selectNextWordToSpellcheck(value); - if (word.word().empty()) - bv->unlockInset(const_cast(this)); - else - value = cy(); - return word; -} - - -void InsetText::selectSelectedWord(BufferView * bv) -{ - if (the_locking_inset) { - the_locking_inset->selectSelectedWord(bv); - return; - } - getLyXText(bv)->selectSelectedWord(); - updateLocal(bv, false); -} - - bool InsetText::nextChange(BufferView * bv, lyx::pos_type & length) { if (the_locking_inset) { diff --git a/src/insets/insettext.h b/src/insets/insettext.h index bb5d1b980b..b9de092828 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -157,13 +157,6 @@ public: LyXText * getText(int) const; /// LyXCursor const & cursor(BufferView *) const; - /// - bool allowSpellcheck() const { return true; } - /// - WordLangTuple const - selectNextWordToSpellcheck(BufferView *, float & value) const; - /// - void selectSelectedWord(BufferView *); /// mark as erased for change tracking void markErased() { clear(true); }; diff --git a/src/insets/updatableinset.C b/src/insets/updatableinset.C index 6e1e725405..a62fbc0be7 100644 --- a/src/insets/updatableinset.C +++ b/src/insets/updatableinset.C @@ -20,7 +20,6 @@ #include "dispatchresult.h" #include "funcrequest.h" #include "lyxtext.h" -#include "WordLangTuple.h" #include "support/lstrings.h" @@ -139,16 +138,6 @@ LyXCursor const & InsetOld::cursor(BufferView * bv) const } -WordLangTuple const -UpdatableInset::selectNextWordToSpellcheck(BufferView *bv, float & value) const -{ - // we have to unlock ourself in this function by default! - bv->unlockInset(const_cast(this)); - value = 0; - return WordLangTuple(); -} - - bool UpdatableInset::nextChange(BufferView * bv, lyx::pos_type &) { // we have to unlock ourself in this function by default! diff --git a/src/insets/updatableinset.h b/src/insets/updatableinset.h index d791ecfdaa..bdb503bced 100644 --- a/src/insets/updatableinset.h +++ b/src/insets/updatableinset.h @@ -87,15 +87,6 @@ public: /// virtual bool showInsetDialog(BufferView *) const { return false; } /// - // needed for spellchecking text - /// - virtual bool allowSpellcheck() const { return false; } - /// - virtual WordLangTuple const - selectNextWordToSpellcheck(BufferView *, float & value) const; - /// - virtual void selectSelectedWord(BufferView *) {} - /// virtual void toggleSelection(BufferView *, bool /*kill_selection*/) {} /// find the next change in the inset diff --git a/src/lyxtext.h b/src/lyxtext.h index 5ed7f5f72a..c19d8b440c 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -37,7 +37,6 @@ class Row; class Spacing; class UpdatableInset; class VSpace; -class WordLangTuple; /** @@ -204,14 +203,6 @@ public: /// reject selected change void rejectChange(); - /** 'selects" the next word, where the cursor is not in - and returns this word as string. THe cursor will be moved - to the beginning of this word. - With SelectSelectedWord can this be highlighted really - */ - WordLangTuple const selectNextWordToSpellcheck(float & value); - /// - void selectSelectedWord(); /// re-computes the cached coordinates in the cursor void redoCursor(); /// diff --git a/src/text.C b/src/text.C index c2e51021cf..3c2bb6e871 100644 --- a/src/text.C +++ b/src/text.C @@ -1242,128 +1242,6 @@ void LyXText::rejectChange() } -// 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() { -- 2.39.2