}
-// 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())
class Painter;
class TeXErrors;
class UpdatableInset;
-class WordLangTuple;
/**
* A buffer view encapsulates a view onto a particular
/// 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);
+
+2003-11-04 Alfredo Braunstein <abraunst@libero.it>
+
+ * BufferView.[Ch]:
+ * lyxtext.h:
+ * text.C: remove dead spellcheck code
+
2003-11-04 Lars Gullik Bjønnes <larsbj@gullik.net>
* dispatchresult.h: add a val setter
+
+2003-11-04 Alfredo Braunstein <abraunst@libero.it>
+
+ * inset.h:
+ * insetcollapsable.[Ch]:
+ * insetert.[Ch]:
+ * insettabular.[Ch]:
+ * insettext.[Ch]:
+ * updatableinset.[Ch]: remove dead spellcheck code
+
2003-11-04 Alfredo Braunstein <abraunst@libero.it>
* insettabular.C (lockInsetInInset): small fix
class Painter;
class Paragraph;
class UpdatableInset;
-class WordLangTuple;
namespace lyx {
namespace graphics {
/// 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; }
#include "funcrequest.h"
#include "metricsinfo.h"
#include "paragraph.h"
-#include "WordLangTuple.h"
#include "frontends/font_metrics.h"
#include "frontends/Painter.h"
}
-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);
void open(BufferView *);
///
void close(BufferView *) const;
- ///
- bool allowSpellcheck() const;
- ///
- WordLangTuple const
- selectNextWordToSpellcheck(BufferView *, float &) const;
- ///
- void selectSelectedWord(BufferView *);
void markErased();
}
-inline
-bool InsetCollapsable::allowSpellcheck() const
-{
- return inset.allowSpellcheck();
-}
-
-
-inline
-void InsetCollapsable::selectSelectedWord(BufferView * bv)
-{
- inset.selectSelectedWord(bv);
-}
-
-
inline
Box const & InsetCollapsable::buttonDim() const
{
#include "lyxlex.h"
#include "metricsinfo.h"
#include "paragraph.h"
-#include "WordLangTuple.h"
#include "frontends/Alert.h"
#include "frontends/LyXView.h"
}
-WordLangTuple const
-InsetERT::selectNextWordToSpellcheck(BufferView * bv, float &) const
-{
- bv->unlockInset(const_cast<InsetERT *>(this));
- return WordLangTuple();
-}
-
-
void InsetERT::getDrawFont(LyXFont & font) const
{
LyXFont f(LyXFont::ALL_INHERIT, latex_language);
///
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;
#include "paragraph_funcs.h"
#include "ParagraphParameters.h"
#include "undo.h"
-#include "WordLangTuple.h"
#include "frontends/Alert.h"
#include "frontends/font_metrics.h"
}
-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<InsetTabular *>(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<InsetTabular *>(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)
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
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);
//
#include "sgml.h"
#include "texrow.h"
#include "undo.h"
-#include "WordLangTuple.h"
#include "frontends/Alert.h"
#include "frontends/font_metrics.h"
}
-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<InsetText *>(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) {
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); };
#include "dispatchresult.h"
#include "funcrequest.h"
#include "lyxtext.h"
-#include "WordLangTuple.h"
#include "support/lstrings.h"
}
-WordLangTuple const
-UpdatableInset::selectNextWordToSpellcheck(BufferView *bv, float & value) const
-{
- // we have to unlock ourself in this function by default!
- bv->unlockInset(const_cast<UpdatableInset *>(this));
- value = 0;
- return WordLangTuple();
-}
-
-
bool UpdatableInset::nextChange(BufferView * bv, lyx::pos_type &)
{
// we have to unlock ourself in this function by default!
///
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
class Spacing;
class UpdatableInset;
class VSpace;
-class WordLangTuple;
/**
/// 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();
///
}
-// 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()
{