-void BufferView::undo()
-{
- if (!available())
- return;
-
- owner()->message(_("Undo"));
- beforeChange(text);
- if (!textUndo(this))
- owner()->message(_("No further undo information"));
- update();
- switchKeyMap();
-}
-
-
-void BufferView::redo()
-{
- if (!available())
- return;
-
- owner()->message(_("Redo"));
- beforeChange(text);
- if (!textRedo(this))
- owner()->message(_("No further redo information"));
- update();
- switchKeyMap();
-}
-
-
-// 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())
- return;
-
- LyXText * text = getLyXText();
-
- text->replaceSelectionWithString(replacestring);
- text->setSelectionRange(replacestring.length());
-
- // Go back so that replacement string is also spellchecked
- for (string::size_type i = 0; i < replacestring.length() + 1; ++i)
- text->cursorLeft(this);
-
- // FIXME: should be done through LFUN
- buffer()->markDirty();
- update();
-}
-
-
-bool BufferView::lockInset(UpdatableInset * inset)
-{
- if (!inset)
- return false;
-
- // don't relock if we're already locked
- if (theLockingInset() == inset)
- return true;
-
- if (theLockingInset())
- return theLockingInset()->lockInsetInInset(this, inset);
-
- // first check if it's the inset under the cursor we want lock
- // should be most of the time
- if (text->cursor.pos() < text->cursorPar()->size()
- && text->cursorPar()->getChar(text->cursor.pos()) ==
- Paragraph::META_INSET) {
- if (inset == text->cursorPar()->getInset(text->cursor.pos())) {
- theLockingInset(inset);
- return true;
- }
- }
-
- // then do a deep look at the inset and lock the right one
- ParagraphList::iterator pit = buffer()->paragraphs().begin();
- ParagraphList::iterator pend = buffer()->paragraphs().end();
- for (int par = 0; pit != pend; ++pit, ++par) {
- InsetList::iterator it = pit->insetlist.begin();
- InsetList::iterator end = pit->insetlist.end();
- for (; it != end; ++it) {
- if (it->inset == inset) {
- text->setCursorIntern(par, it->pos);
- theLockingInset(inset);
- return true;
- }
- }
- }
- return false;
-}
-
-
-bool BufferView::fitLockedInsetCursor(int x, int y, int asc, int desc)
-{
- if (theLockingInset() && available()) {
- y += text->cursor.y() + theLockingInset()->insetInInsetY();
- if (screen().fitManualCursor(this, text, x, y, asc, desc)) {
- updateScrollbar();
- return true;
- }
- }
- return false;
-}
-
-