result = DispatchResult(true, true);
break;
- case LFUN_SELFINSERT:
- if (bv->buffer()->isReadonly()) {
- // setErrorMessage(N_("Document is read only"));
- break;
- }
- if (!cmd.argument.empty()) {
- /* Automatically delete the currently selected
- * text and replace it with what is being
- * typed in now. Depends on lyxrc settings
- * "auto_region_delete", which defaults to
- * true (on). */
-#if 0
- // This should not be needed here and is also WRONG!
- recordUndo(bv, Undo::INSERT, text_.cursorPar());
-#endif
- bv->switchKeyMap();
-
- if (lyxrc.auto_region_delete && text_.selection.set())
- text_.cutSelection(false, false);
- text_.clearSelection();
-
- for (string::size_type i = 0; i < cmd.argument.length(); ++i)
- bv->owner()->getIntl().getTransManager().
- TranslateAndInsert(cmd.argument[i], &text_);
- }
- text_.selection.cursor = text_.cursor;
- result.dispatched(true);
- result.update(true);
- break;
-
- case LFUN_RIGHT:
- result = text_.moveRight();
- finishUndo();
- break;
-
- case LFUN_LEFT:
- finishUndo();
- result = text_.moveLeft();
- break;
-
- case LFUN_DOWN:
- finishUndo();
- result = text_.moveDown();
- break;
-
- case LFUN_UP:
- finishUndo();
- result = text_.moveUp();
- break;
-
- case LFUN_PRIOR:
- if (crow() == text_.firstRow()) {
- result.val(FINISHED_UP);
- } else {
- text_.cursorPrevious();
- text_.clearSelection();
- result.dispatched(true);
- }
- break;
-
- case LFUN_NEXT:
- if (crow() == text_.lastRow()) {
- result.val(FINISHED_DOWN);
- } else {
- text_.cursorNext();
- text_.clearSelection();
- result.dispatched(true);
- }
- break;
-
- case LFUN_BACKSPACE:
- if (text_.selection.set())
- text_.cutSelection(true, false);
- else
- text_.backspace();
-#warning should be also set dispatched here?
- result.update(true);
- break;
-
- case LFUN_DELETE:
- if (text_.selection.set())
- text_.cutSelection(true, false);
- else
- text_.Delete();
-#warning should be also set dispatched here?
- result.update(true);
- break;
-
- case LFUN_BREAKPARAGRAPH:
- if (!autoBreakRows_) {
- result.dispatched(true);
- result.update(true);
- } else {
- replaceSelection(bv->getLyXText());
- text_.breakParagraph(paragraphs, 0);
-#warning should be also set dispatched here?
- result.update(true);
- }
- break;
-
- case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
- if (!autoBreakRows_) {
- result.dispatched(true);
- result.update(true);
- } else {
- replaceSelection(bv->getLyXText());
- text_.breakParagraph(paragraphs, 1);
-#warning should be also set dispatched here?
- result.update(true);
- }
- break;
-
- case LFUN_BREAKLINE: {
- if (!autoBreakRows_) {
- result.dispatched(true);
- result.update(true);
- } else {
- replaceSelection(bv->getLyXText());
- auto_ptr<InsetNewline> ins(new InsetNewline);
- text_.insertInset(ins.release());
-#warning should be also set dispatched here?
- result.update(true);
- }
- break;
- }
-
- case LFUN_LAYOUT:
- // do not set layouts on non breakable textinsets
- if (autoBreakRows_) {
- string cur_layout = cpar()->layout()->name();
-
- // Derive layout number from given argument (string)
- // and current buffer's textclass (number).
- LyXTextClass const & tclass =
- bv->buffer()->params().getLyXTextClass();
- string layout = cmd.argument;
- bool hasLayout = tclass.hasLayout(layout);
-
- // If the entry is obsolete, use the new one instead.
- if (hasLayout) {
- string const & obs = tclass[layout]->obsoleted_by();
- if (!obs.empty())
- layout = obs;
- }
-
- // see if we found the layout number:
- if (!hasLayout) {
- FuncRequest lf(LFUN_MESSAGE, N_("Layout ") + cmd.argument + N_(" not known"));
- bv->owner()->dispatch(lf);
- break;
- }
-
- if (cur_layout != layout) {
- cur_layout = layout;
- text_.setLayout(layout);
- bv->owner()->setLayout(cpar()->layout()->name());
-#warning should be also set dispatched here?
- result.update(true);
- }
- } else {
- // reset the layout box
- bv->owner()->setLayout(cpar()->layout()->name());
- }
- break;
-
default:
result = text_.dispatch(cmd);
break;
break;
}
- case LFUN_RIGHT: {
- bool is_rtl = rtl();
- if (!selection.mark())
- clearSelection();
- if (is_rtl)
- cursorLeft(false);
- if (cursor.pos() < cursorPar()->size()
- && cursorPar()->isInset(cursor.pos())
- && isHighlyEditableInset(cursorPar()->getInset(cursor.pos()))) {
- InsetOld * tmpinset = cursorPar()->getInset(cursor.pos());
- cmd.message(tmpinset->editMessage());
- tmpinset->edit(bv, !is_rtl);
- break;
- }
- if (!is_rtl)
- cursorRight(false);
+ case LFUN_RIGHT:
finishChange(bv);
- break;
- }
+ return moveRight();
- case LFUN_LEFT: {
- // This is soooo ugly. Isn't it possible to make
- // it simpler? (Lgb)
- bool const is_rtl = rtl();
- if (!selection.mark())
- clearSelection();
- LyXCursor const cur = cursor;
- if (!is_rtl)
- cursorLeft(false);
- if ((is_rtl || cur != cursor) && // only if really moved!
- cursor.pos() < cursorPar()->size() &&
- cursorPar()->isInset(cursor.pos()) &&
- isHighlyEditableInset(cursorPar()->getInset(cursor.pos()))) {
- InsetOld * tmpinset = cursorPar()->getInset(cursor.pos());
- cmd.message(tmpinset->editMessage());
- tmpinset->edit(bv, is_rtl);
- break;
- }
- if (is_rtl)
- cursorRight(false);
+ case LFUN_LEFT:
finishChange(bv);
- break;
- }
+ return moveLeft();
case LFUN_UP:
- if (!selection.mark())
- clearSelection();
- cursorUp(false);
finishChange(bv);
- break;
+ return moveUp();
case LFUN_DOWN:
- if (!selection.mark())
- clearSelection();
- cursorDown(false);
finishChange(bv);
- break;
+ return moveDown();
case LFUN_UP_PARAGRAPH:
if (!selection.mark())
case LFUN_PRIOR:
if (!selection.mark())
clearSelection();
- cursorPrevious();
finishChange(bv, false);
+ if (cursorRow() == firstRow())
+ return DispatchResult(false, FINISHED_UP);
+ cursorPrevious();
break;
case LFUN_NEXT:
if (!selection.mark())
clearSelection();
- cursorNext();
finishChange(bv, false);
+ if (cursorRow() == lastRow())
+ return DispatchResult(false, FINISHED_DOWN);
+ cursorNext();
break;
case LFUN_HOME: