3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Asger Alstrup
7 * \author Lars Gullik Bjønnes
8 * \author Alfredo Braunstein
9 * \author Angus Leeming
11 * \author André Pönitz
13 * Full author contact details are available in file CREDITS.
20 #include "BranchList.h"
21 #include "FloatList.h"
22 #include "FuncStatus.h"
24 #include "buffer_funcs.h"
25 #include "bufferparams.h"
26 #include "BufferView.h"
28 #include "coordcache.h"
29 #include "CutAndPaste.h"
31 #include "dispatchresult.h"
33 #include "funcrequest.h"
37 #include "LyXAction.h"
42 #include "paragraph.h"
43 #include "paragraph_funcs.h"
44 #include "ParagraphParameters.h"
47 #include "pariterator.h"
49 #include "frontends/Dialogs.h"
50 #include "frontends/LyXView.h"
52 #include "insets/insetcommand.h"
53 #include "insets/insetfloatlist.h"
54 #include "insets/insetnewline.h"
55 #include "insets/insetquotes.h"
56 #include "insets/insetspecialchar.h"
57 #include "insets/insettext.h"
59 #include "support/lstrings.h"
60 #include "support/lyxlib.h"
61 #include "support/convert.h"
62 #include "support/lyxtime.h"
64 #include "mathed/math_hullinset.h"
65 #include "mathed/math_macrotemplate.h"
67 #include <boost/current_function.hpp>
74 using lyx::cap::copySelection;
75 using lyx::cap::cutSelection;
76 using lyx::cap::pasteSelection;
77 using lyx::cap::replaceSelection;
79 using lyx::support::isStrUnsignedInt;
80 using lyx::support::token;
84 using std::istringstream;
85 using std::ostringstream;
88 extern string current_layout;
94 LyXFont freefont(LyXFont::ALL_IGNORE);
95 bool toggleall = false;
98 void toggleAndShow(LCursor & cur, LyXText * text,
99 LyXFont const & font, bool toggleall = true)
101 text->toggleFree(cur, font, toggleall);
103 if (font.language() != ignore_language ||
104 font.number() != LyXFont::IGNORE) {
105 Paragraph & par = cur.paragraph();
106 text->bidi.computeTables(par, cur.buffer(), cur.textRow());
107 if (cur.boundary() !=
108 text->bidi.isBoundary(cur.buffer(), par,
110 text->real_current_font))
111 text->setCursor(cur, cur.pit(), cur.pos(),
112 false, !cur.boundary());
117 void moveCursor(LCursor & cur, bool selecting)
119 if (selecting || cur.mark())
121 if (!cur.selection())
122 cur.bv().haveSelection(false);
123 cur.bv().switchKeyMap();
127 void finishChange(LCursor & cur, bool selecting)
130 moveCursor(cur, selecting);
134 void mathDispatch(LCursor & cur, FuncRequest const & cmd, bool display)
137 string sel = cur.selectionAsString(false);
138 //lyxerr << "selection is: '" << sel << "'" << endl;
140 // It may happen that sel is empty but there is a selection
141 replaceSelection(cur);
144 const int old_pos = cur.pos();
145 cur.insert(new MathHullInset("simple"));
146 BOOST_ASSERT(old_pos == cur.pos());
147 cur.nextInset()->edit(cur, true);
148 // don't do that also for LFUN_MATH_MODE
149 // unless you want end up with always changing
150 // to mathrm when opening an inlined inset --
151 // I really hate "LyXfunc overloading"...
153 cur.dispatch(FuncRequest(LFUN_MATH_DISPLAY));
154 // Avoid an unnecessary undo step if cmd.argument
156 if (!cmd.argument.empty())
157 cur.dispatch(FuncRequest(LFUN_MATH_INSERT,
160 // create a macro if we see "\\newcommand"
161 // somewhere, and an ordinary formula
163 istringstream is(sel);
164 if (sel.find("\\newcommand") == string::npos
165 && sel.find("\\def") == string::npos)
167 MathHullInset * formula = new MathHullInset;
170 formula->read(cur.buffer(), lex);
171 if (formula->getType() == "none")
172 // Don't create pseudo formulas if
173 // delimiters are left out
174 formula->mutate("simple");
177 cur.insert(new MathMacroTemplate(is));
179 cur.message(N_("Math editor mode"));
188 string const freefont2string()
191 if (font2string(freefont, toggleall, data))
198 bool LyXText::cursorPrevious(LCursor & cur)
200 pos_type cpos = cur.pos();
201 lyx::pit_type cpar = cur.pit();
203 int x = cur.x_target();
205 bool updated = setCursorFromCoordinates(cur, x, 0);
208 updated |= cursorUp(cur);
210 if (cpar == cur.pit() && cpos == cur.pos()) {
211 // we have a row which is taller than the workarea. The
212 // simplest solution is to move to the previous row instead.
213 updated |= cursorUp(cur);
216 cur.bv().updateScrollbar();
222 bool LyXText::cursorNext(LCursor & cur)
224 pos_type cpos = cur.pos();
225 lyx::pit_type cpar = cur.pit();
227 int x = cur.x_target();
228 bool updated = setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1);
231 updated |= cursorDown(cur);
233 if (cpar == cur.pit() && cpos == cur.pos()) {
234 // we have a row which is taller than the workarea. The
235 // simplest solution is to move to the next row instead.
236 updated |= cursorDown(cur);
239 cur.bv().updateScrollbar();
247 void specialChar(LCursor & cur, InsetSpecialChar::Kind kind)
249 lyx::cap::replaceSelection(cur);
250 cur.insert(new InsetSpecialChar(kind));
255 bool doInsertInset(LCursor & cur, LyXText * text,
256 FuncRequest const & cmd, bool edit, bool pastesel)
258 InsetBase * inset = createInset(&cur.bv(), cmd);
264 if (cur.selection()) {
265 cur.bv().owner()->dispatch(FuncRequest(LFUN_CUT));
268 text->insertInset(cur, inset);
271 inset->edit(cur, true);
273 if (gotsel && pastesel)
274 cur.bv().owner()->dispatch(FuncRequest(LFUN_PASTE));
279 void update(LCursor & cur)
281 //we don't call update(true, false) directly to save a metrics call
282 if (cur.bv().fitCursor())
283 cur.bv().update(Update::Force);
290 void LyXText::number(LCursor & cur)
292 LyXFont font(LyXFont::ALL_IGNORE);
293 font.setNumber(LyXFont::TOGGLE);
294 toggleAndShow(cur, this, font);
298 bool LyXText::isRTL(Paragraph const & par) const
300 return par.isRightToLeftPar(bv()->buffer()->params());
304 void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
306 lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl;
308 BOOST_ASSERT(cur.text() == this);
309 BufferView * bv = &cur.bv();
310 CursorSlice oldTopSlice = cur.top();
311 bool oldBoundary = cur.boundary();
312 bool sel = cur.selection();
313 // Signals that, even if needsUpdate == false, an update of the
314 // cursor paragraph is required
315 bool singleParUpdate = lyxaction.funcHasFlag(cmd.action,
316 LyXAction::SingleParUpdate);
317 // Signals that a full-screen update is required
318 bool needsUpdate = !(lyxaction.funcHasFlag(cmd.action,
319 LyXAction::NoUpdate) || singleParUpdate);
320 // Remember the old paragraph metric (_outer_ paragraph!)
321 Dimension olddim = cur.bottom().paragraph().dim();
323 switch (cmd.action) {
325 case LFUN_PARAGRAPH_MOVE_DOWN: {
326 pit_type const pit = cur.pit();
327 recUndo(pit, pit + 1);
329 std::swap(pars_[pit], pars_[pit + 1]);
331 ParIterator begin(cur);
333 ParIterator end = boost::next(ParIterator(cur));
334 updateLabels(cur.buffer(), begin, end);
340 case LFUN_PARAGRAPH_MOVE_UP: {
341 pit_type const pit = cur.pit();
342 recUndo(pit - 1, pit);
344 std::swap(pars_[pit], pars_[pit - 1]);
346 ParIterator end = boost::next(ParIterator(cur));
348 ParIterator begin(cur);
349 updateLabels(cur.buffer(), begin, end);
355 case LFUN_APPENDIX: {
356 Paragraph & par = cur.paragraph();
357 bool start = !par.params().startOfAppendix();
360 #warning The code below only makes sense at top level.
361 // Should LFUN_APPENDIX be restricted to top-level paragraphs?
363 // ensure that we have only one start_of_appendix in this document
364 for (pit_type tmp = 0, end = pars_.size(); tmp != end; ++tmp) {
365 if (pars_[tmp].params().startOfAppendix()) {
367 pars_[tmp].params().startOfAppendix(false);
373 par.params().startOfAppendix(start);
375 // we can set the refreshing parameters now
376 updateLabels(cur.buffer());
380 case LFUN_WORD_DELETE_FORWARD:
381 cur.clearSelection();
382 deleteWordForward(cur);
383 finishChange(cur, false);
386 case LFUN_WORD_DELETE_BACKWARD:
387 cur.clearSelection();
388 deleteWordBackward(cur);
389 finishChange(cur, false);
392 case LFUN_LINE_DELETE:
393 cur.clearSelection();
394 deleteLineForward(cur);
395 finishChange(cur, false);
398 case LFUN_WORD_FORWARD:
400 cur.clearSelection();
401 if (isRTL(cur.paragraph()))
402 needsUpdate = cursorLeftOneWord(cur);
404 needsUpdate = cursorRightOneWord(cur);
405 finishChange(cur, false);
408 case LFUN_WORD_BACKWARD:
410 cur.clearSelection();
411 if (isRTL(cur.paragraph()))
412 needsUpdate = cursorRightOneWord(cur);
414 needsUpdate = cursorLeftOneWord(cur);
415 finishChange(cur, false);
418 case LFUN_BUFFER_BEGIN:
419 if (cur.depth() == 1) {
421 cur.clearSelection();
422 needsUpdate = cursorTop(cur);
423 finishChange(cur, false);
429 case LFUN_BUFFER_BEGIN_SELECT:
430 if (cur.depth() == 1) {
431 if (!cur.selection())
433 needsUpdate = cursorTop(cur);
434 finishChange(cur, true);
440 case LFUN_BUFFER_END:
441 if (cur.depth() == 1) {
443 cur.clearSelection();
444 needsUpdate = cursorBottom(cur);
445 finishChange(cur, false);
451 case LFUN_BUFFER_END_SELECT:
452 if (cur.depth() == 1) {
453 if (!cur.selection())
455 needsUpdate = cursorBottom(cur);
456 finishChange(cur, true);
462 case LFUN_CHAR_FORWARD:
463 case LFUN_CHAR_FORWARD_SELECT:
464 //lyxerr << BOOST_CURRENT_FUNCTION
465 // << " LFUN_CHAR_FORWARD[SEL]:\n" << cur << endl;
466 cur.selHandle(cmd.action == LFUN_CHAR_FORWARD_SELECT);
467 if (isRTL(cur.paragraph()))
468 needsUpdate = cursorLeft(cur);
470 needsUpdate = cursorRight(cur);
472 if (!needsUpdate && oldTopSlice == cur.top()
473 && cur.boundary() == oldBoundary) {
475 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
479 case LFUN_CHAR_BACKWARD:
480 case LFUN_CHAR_BACKWARD_SELECT:
481 //lyxerr << "handle LFUN_CHAR_BACKWARD[_SELECT]:\n" << cur << endl;
482 cur.selHandle(cmd.action == LFUN_CHAR_BACKWARD_SELECT);
483 if (isRTL(cur.paragraph()))
484 needsUpdate = cursorRight(cur);
486 needsUpdate = cursorLeft(cur);
488 if (!needsUpdate && oldTopSlice == cur.top()
489 && cur.boundary() == oldBoundary) {
491 cmd = FuncRequest(LFUN_FINISHED_LEFT);
498 //lyxerr << "handle LFUN_UP[SEL]:\n" << cur << endl;
499 cur.selHandle(cmd.action == LFUN_UP_SELECT);
501 needsUpdate = cursorUp(cur);
502 if (!needsUpdate && oldTopSlice == cur.top()
503 && cur.boundary() == oldBoundary) {
505 cmd = FuncRequest(LFUN_FINISHED_UP);
510 case LFUN_DOWN_SELECT:
512 //lyxerr << "handle LFUN_DOWN[SEL]:\n" << cur << endl;
513 cur.selHandle(cmd.action == LFUN_DOWN_SELECT);
514 needsUpdate = cursorDown(cur);
515 if (!needsUpdate && oldTopSlice == cur.top() &&
516 cur.boundary() == oldBoundary)
519 cmd = FuncRequest(LFUN_FINISHED_DOWN);
523 case LFUN_PARAGRAPH_UP:
525 cur.clearSelection();
526 needsUpdate = cursorUpParagraph(cur);
527 finishChange(cur, false);
530 case LFUN_PARAGRAPH_UP_SELECT:
531 if (!cur.selection())
533 cursorUpParagraph(cur);
534 finishChange(cur, true);
537 case LFUN_PARAGRAPH_DOWN:
539 cur.clearSelection();
540 needsUpdate = cursorDownParagraph(cur);
541 finishChange(cur, false);
544 case LFUN_PARAGRAPH_DOWN_SELECT:
545 if (!cur.selection())
547 cursorDownParagraph(cur);
548 finishChange(cur, true);
551 case LFUN_SCREEN_UP_SELECT:
553 if (!cur.selection())
555 needsUpdate = cursorPrevious(cur);
556 finishChange(cur, true);
559 case LFUN_SCREEN_DOWN_SELECT:
561 if (!cur.selection())
563 needsUpdate = cursorNext(cur);
564 finishChange(cur, true);
567 case LFUN_LINE_BEGIN_SELECT:
569 if (!cur.selection())
571 needsUpdate = cursorHome(cur);
572 finishChange(cur, true);
575 case LFUN_LINE_END_SELECT:
577 if (!cur.selection())
579 needsUpdate = cursorEnd(cur);
580 finishChange(cur, true);
583 case LFUN_WORD_FORWARD_SELECT:
584 if (!cur.selection())
586 if (isRTL(cur.paragraph()))
587 cursorLeftOneWord(cur);
589 cursorRightOneWord(cur);
590 finishChange(cur, true);
593 case LFUN_WORD_BACKWARD_SELECT:
594 if (!cur.selection())
596 if (isRTL(cur.paragraph()))
597 cursorRightOneWord(cur);
599 cursorLeftOneWord(cur);
600 finishChange(cur, true);
603 case LFUN_WORD_SELECT: {
604 selectWord(cur, lyx::WHOLE_WORD);
605 finishChange(cur, true);
612 cur.clearSelection();
613 finishChange(cur, false);
614 if (cur.pit() == 0 && cur.textRow().pos() == 0) {
616 cmd = FuncRequest(LFUN_FINISHED_UP);
618 needsUpdate = cursorPrevious(cur);
622 case LFUN_SCREEN_DOWN:
625 cur.clearSelection();
626 finishChange(cur, false);
627 if (cur.pit() == cur.lastpit()
628 && cur.textRow().endpos() == cur.lastpos()) {
630 cmd = FuncRequest(LFUN_FINISHED_DOWN);
632 needsUpdate = cursorNext(cur);
636 case LFUN_LINE_BEGIN:
638 cur.clearSelection();
639 needsUpdate = cursorHome(cur);
640 finishChange(cur, false);
645 cur.clearSelection();
646 needsUpdate = cursorEnd(cur);
647 finishChange(cur, false);
650 case LFUN_BREAK_LINE: {
651 // Not allowed by LaTeX (labels or empty par)
652 if (cur.pos() > cur.paragraph().beginOfBody()) {
653 lyx::cap::replaceSelection(cur);
654 cur.insert(new InsetNewline);
656 moveCursor(cur, false);
661 case LFUN_CHAR_DELETE_FORWARD:
662 if (!cur.selection()) {
663 if (cur.pos() == cur.paragraph().size())
664 // Par boundary, force full-screen update
665 singleParUpdate = false;
666 needsUpdate = erase(cur);
668 // It is possible to make it a lot faster still
669 // just comment out the line below...
671 cutSelection(cur, true, false);
672 singleParUpdate = false;
674 moveCursor(cur, false);
677 case LFUN_DELETE_FORWARD_SKIP:
678 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
679 if (!cur.selection()) {
680 if (cur.pos() == cur.lastpos()) {
687 cutSelection(cur, true, false);
692 case LFUN_CHAR_DELETE_BACKWARD:
693 if (!cur.selection()) {
694 if (bv->owner()->getIntl().getTransManager().backspace()) {
695 // Par boundary, full-screen update
697 singleParUpdate = false;
698 needsUpdate = backspace(cur);
700 // It is possible to make it a lot faster still
701 // just comment out the line below...
704 cutSelection(cur, true, false);
705 singleParUpdate = false;
710 case LFUN_DELETE_BACKWARD_SKIP:
711 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
712 if (!cur.selection()) {
716 //CursorSlice cur = cursor();
720 cutSelection(cur, true, false);
724 case LFUN_BREAK_PARAGRAPH:
725 lyx::cap::replaceSelection(cur);
726 breakParagraph(cur, 0);
731 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
732 lyx::cap::replaceSelection(cur);
733 breakParagraph(cur, 1);
738 case LFUN_BREAK_PARAGRAPH_SKIP: {
739 // When at the beginning of a paragraph, remove
740 // indentation. Otherwise, do the same as LFUN_BREAK_PARAGRAPH.
741 lyx::cap::replaceSelection(cur);
743 cur.paragraph().params().labelWidthString(string());
745 breakParagraph(cur, 0);
751 case LFUN_PARAGRAPH_SPACING: {
752 Paragraph & par = cur.paragraph();
753 Spacing::Space cur_spacing = par.params().spacing().getSpace();
754 string cur_value = "1.0";
755 if (cur_spacing == Spacing::Other)
756 cur_value = par.params().spacing().getValueAsString();
758 istringstream is(cmd.argument);
761 Spacing::Space new_spacing = cur_spacing;
762 string new_value = cur_value;
764 lyxerr << "Missing argument to `paragraph-spacing'"
766 } else if (tmp == "single") {
767 new_spacing = Spacing::Single;
768 } else if (tmp == "onehalf") {
769 new_spacing = Spacing::Onehalf;
770 } else if (tmp == "double") {
771 new_spacing = Spacing::Double;
772 } else if (tmp == "other") {
773 new_spacing = Spacing::Other;
774 string tmpval = "0.0";
776 lyxerr << "new_value = " << tmpval << endl;
779 } else if (tmp == "default") {
780 new_spacing = Spacing::Default;
782 lyxerr << _("Unknown spacing argument: ")
783 << cmd.argument << endl;
785 if (cur_spacing != new_spacing || cur_value != new_value)
786 par.params().spacing(Spacing(new_spacing, new_value));
790 case LFUN_INSET_INSERT: {
792 InsetBase * inset = createInset(bv, cmd);
794 insertInset(cur, inset);
800 case LFUN_INSET_SETTINGS:
801 cur.inset().showInsetDialog(bv);
804 case LFUN_NEXT_INSET_TOGGLE: {
805 InsetBase * inset = cur.nextInset();
806 // this is the real function we want to invoke
807 cmd = FuncRequest(LFUN_INSET_TOGGLE);
809 // if there is an inset at cursor, see whether it
812 LCursor tmpcur = cur;
813 tmpcur.pushLeft(*inset);
814 inset->dispatch(tmpcur, cmd);
815 if (tmpcur.result().dispatched()) {
816 cur.clearSelection();
820 // if it did not work, try the underlying inset.
821 if (!cur.result().dispatched())
822 cur.inset().dispatch(cur, cmd);
826 case LFUN_SPACE_INSERT:
827 if (cur.paragraph().layout()->free_spacing)
828 insertChar(cur, ' ');
830 doInsertInset(cur, this, cmd, false, false);
833 moveCursor(cur, false);
836 case LFUN_HYPHENATION_POINT_INSERT:
837 specialChar(cur, InsetSpecialChar::HYPHENATION);
840 case LFUN_LIGATURE_BREAK_INSERT:
841 specialChar(cur, InsetSpecialChar::LIGATURE_BREAK);
844 case LFUN_DOTS_INSERT:
845 specialChar(cur, InsetSpecialChar::LDOTS);
848 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
849 specialChar(cur, InsetSpecialChar::END_OF_SENTENCE);
852 case LFUN_MENU_SEPARATOR_INSERT:
853 specialChar(cur, InsetSpecialChar::MENU_SEPARATOR);
856 case LFUN_WORD_UPCASE:
857 changeCase(cur, LyXText::text_uppercase);
860 case LFUN_WORD_LOWCASE:
861 changeCase(cur, LyXText::text_lowercase);
864 case LFUN_WORD_CAPITALIZE:
865 changeCase(cur, LyXText::text_capitalization);
868 case LFUN_CHARS_TRANSPOSE:
873 cur.message(_("Paste"));
874 lyx::cap::replaceSelection(cur);
875 if (isStrUnsignedInt(cmd.argument))
876 pasteSelection(cur, convert<unsigned int>(cmd.argument));
878 pasteSelection(cur, 0);
879 cur.clearSelection(); // bug 393
885 cutSelection(cur, true, true);
886 cur.message(_("Cut"));
891 cur.message(_("Copy"));
894 case LFUN_SERVER_GET_XY:
895 cur.message(convert<string>(cursorX(cur.top(), cur.boundary())) + ' '
896 + convert<string>(cursorY(cur.top(), cur.boundary())));
899 case LFUN_SERVER_SET_XY: {
902 istringstream is(cmd.argument);
905 lyxerr << "SETXY: Could not parse coordinates in '"
906 << cmd.argument << std::endl;
908 setCursorFromCoordinates(cur, x, y);
912 case LFUN_SERVER_GET_FONT:
913 if (current_font.shape() == LyXFont::ITALIC_SHAPE)
915 else if (current_font.shape() == LyXFont::SMALLCAPS_SHAPE)
921 case LFUN_SERVER_GET_LAYOUT:
922 cur.message(cur.paragraph().layout()->name());
926 lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) "
927 << cmd.argument << endl;
929 // This is not the good solution to the empty argument
930 // problem, but it will hopefully suffice for 1.2.0.
931 // The correct solution would be to augument the
932 // function list/array with information about what
933 // functions needs arguments and their type.
934 if (cmd.argument.empty()) {
935 cur.errorMessage(_("LyX function 'layout' needs an argument."));
939 // Derive layout number from given argument (string)
940 // and current buffer's textclass (number)
941 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
942 bool hasLayout = tclass.hasLayout(cmd.argument);
943 string layout = cmd.argument;
945 // If the entry is obsolete, use the new one instead.
947 string const & obs = tclass[layout]->obsoleted_by();
953 cur.errorMessage(string(N_("Layout ")) + cmd.argument +
958 bool change_layout = (current_layout != layout);
960 if (!change_layout && cur.selection() &&
961 cur.selBegin().pit() != cur.selEnd().pit())
963 pit_type spit = cur.selBegin().pit();
964 pit_type epit = cur.selEnd().pit() + 1;
965 while (spit != epit) {
966 if (pars_[spit].layout()->name() != current_layout) {
967 change_layout = true;
975 current_layout = layout;
976 setLayout(cur, layout);
977 bv->owner()->setLayout(layout);
983 case LFUN_PRIMARY_SELECTION_PASTE: {
984 cur.clearSelection();
985 string const clip = bv->getClipboard();
988 if (cmd.argument == "paragraph")
989 insertStringAsParagraphs(cur, clip);
991 insertStringAsLines(cur, clip);
996 case LFUN_QUOTE_INSERT: {
997 lyx::cap::replaceSelection(cur);
998 Paragraph & par = cur.paragraph();
999 lyx::pos_type pos = cur.pos();
1003 else if (cur.prevInset() && cur.prevInset()->isSpace())
1006 c = par.getChar(pos - 1);
1008 LyXLayout_ptr const & style = par.layout();
1010 BufferParams const & bufparams = bv->buffer()->params();
1011 if (!style->pass_thru
1012 && par.getFontSettings(bufparams, pos).language()->lang() != "hebrew") {
1013 string arg = cmd.argument;
1014 if (arg == "single")
1015 cur.insert(new InsetQuotes(c,
1016 bufparams.quotes_language,
1017 InsetQuotes::SingleQ));
1019 cur.insert(new InsetQuotes(c,
1020 bufparams.quotes_language,
1021 InsetQuotes::DoubleQ));
1025 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT, "\""));
1029 case LFUN_DATE_INSERT:
1030 if (cmd.argument.empty())
1031 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT,
1032 lyx::formatted_time(lyx::current_time())));
1034 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT,
1035 lyx::formatted_time(lyx::current_time(), cmd.argument)));
1038 case LFUN_MOUSE_TRIPLE:
1039 if (cmd.button() == mouse_button::button1) {
1045 bv->haveSelection(cur.selection());
1049 case LFUN_MOUSE_DOUBLE:
1050 if (cmd.button() == mouse_button::button1) {
1051 selectWord(cur, lyx::WHOLE_WORD_STRICT);
1053 bv->haveSelection(cur.selection());
1057 // Single-click on work area
1058 case LFUN_MOUSE_PRESS: {
1059 // Right click on a footnote flag opens float menu
1060 if (cmd.button() == mouse_button::button3)
1061 cur.clearSelection();
1063 // Middle button press pastes if we have a selection
1064 // We do this here as if the selection was inside an inset
1065 // it could get cleared on the unlocking of the inset so
1066 // we have to check this first
1067 bool paste_internally = false;
1068 if (cmd.button() == mouse_button::button2 && cur.selection()) {
1069 bv->owner()->dispatch(FuncRequest(LFUN_COPY));
1070 paste_internally = true;
1073 bv->mouseSetCursor(cur);
1075 // Insert primary selection with middle mouse
1076 // if there is a local selection in the current buffer,
1078 if (cmd.button() == mouse_button::button2) {
1079 if (paste_internally)
1080 bv->owner()->dispatch(FuncRequest(LFUN_PASTE));
1082 bv->owner()->dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph"));
1088 case LFUN_MOUSE_MOTION: {
1089 // Only use motion with button 1
1090 //if (cmd.button() != mouse_button::button1)
1093 // ignore motions deeper nested than the real anchor
1094 LCursor & bvcur = cur.bv().cursor();
1095 if (bvcur.anchor_.hasPart(cur)) {
1096 CursorSlice old = bvcur.top();
1098 int const wh = bv->workHeight();
1099 int const y = std::max(0, std::min(wh - 1, cmd.y));
1101 setCursorFromCoordinates(cur, cmd.x, y);
1102 cur.x_target() = cmd.x;
1107 // This is to allow jumping over large insets
1108 if (cur.top() == old) {
1115 if (cur.top() == old)
1118 // don't set anchor_
1119 bvcur.setCursor(cur);
1120 bvcur.selection() = true;
1121 //lyxerr << "MOTION: " << bv->cursor() << endl;
1129 case LFUN_MOUSE_RELEASE: {
1130 if (cmd.button() == mouse_button::button2)
1134 if (cmd.button() == mouse_button::button1)
1135 bv->haveSelection(cur.selection());
1138 bv->owner()->updateMenubar();
1139 bv->owner()->updateToolbars();
1143 case LFUN_SELF_INSERT: {
1144 if (cmd.argument.empty())
1147 // Automatically delete the currently selected
1148 // text and replace it with what is being
1149 // typed in now. Depends on lyxrc settings
1150 // "auto_region_delete", which defaults to
1153 if (lyxrc.auto_region_delete) {
1154 if (cur.selection())
1155 cutSelection(cur, false, false);
1156 bv->haveSelection(false);
1159 cur.clearSelection();
1160 LyXFont const old_font = real_current_font;
1162 string::const_iterator cit = cmd.argument.begin();
1163 string::const_iterator end = cmd.argument.end();
1164 for (; cit != end; ++cit)
1165 bv->owner()->getIntl().getTransManager().
1166 translateAndInsert(*cit, this);
1169 moveCursor(cur, false);
1170 bv->updateScrollbar();
1174 case LFUN_URL_INSERT: {
1175 InsetCommandParams p("url");
1176 string const data = InsetCommandMailer::params2string("url", p);
1177 bv->owner()->getDialogs().show("url", data, 0);
1181 case LFUN_HTML_INSERT: {
1182 InsetCommandParams p("htmlurl");
1183 string const data = InsetCommandMailer::params2string("url", p);
1184 bv->owner()->getDialogs().show("url", data, 0);
1188 case LFUN_LABEL_INSERT: {
1189 // Try to generate a valid label
1190 string const contents = cmd.argument.empty() ?
1191 cur.getPossibleLabel() : cmd.argument;
1193 InsetCommandParams p("label", contents);
1194 string const data = InsetCommandMailer::params2string("label", p);
1196 if (cmd.argument.empty()) {
1197 bv->owner()->getDialogs().show("label", data, 0);
1199 FuncRequest fr(LFUN_INSET_INSERT, data);
1207 case LFUN_LIST_INSERT:
1208 case LFUN_THEOREM_INSERT:
1209 case LFUN_CAPTION_INSERT:
1211 case LFUN_NOTE_INSERT:
1212 case LFUN_CHARSTYLE_INSERT:
1213 case LFUN_BOX_INSERT:
1214 case LFUN_BRANCH_INSERT:
1215 case LFUN_BIBITEM_INSERT:
1216 case LFUN_ERT_INSERT:
1217 case LFUN_FOOTNOTE_INSERT:
1218 case LFUN_MARGINALNOTE_INSERT:
1219 case LFUN_OPTIONAL_INSERT:
1220 case LFUN_ENVIRONMENT_INSERT:
1221 // Open the inset, and move the current selection
1223 doInsertInset(cur, this, cmd, true, true);
1227 case LFUN_TABULAR_INSERT:
1228 // if there were no arguments, just open the dialog
1229 if (doInsertInset(cur, this, cmd, false, true))
1232 bv->owner()->getDialogs().show("tabularcreate");
1236 case LFUN_FLOAT_INSERT:
1237 case LFUN_FLOAT_WIDE_INSERT:
1238 case LFUN_WRAP_INSERT:
1239 doInsertInset(cur, this, cmd, true, true);
1241 // FIXME: the "Caption" name should not be hardcoded,
1242 // but given by the float definition.
1243 cur.dispatch(FuncRequest(LFUN_LAYOUT, "Caption"));
1246 case LFUN_INDEX_INSERT: {
1247 InsetBase * inset = createInset(&cur.bv(), cmd);
1252 cur.clearSelection();
1253 insertInset(cur, inset);
1254 inset->edit(cur, true);
1259 case LFUN_INDEX_PRINT:
1260 case LFUN_TOC_INSERT:
1261 case LFUN_HFILL_INSERT:
1262 case LFUN_LINE_INSERT:
1263 case LFUN_PAGEBREAK_INSERT:
1265 doInsertInset(cur, this, cmd, false, false);
1269 case LFUN_DEPTH_DECREMENT:
1270 changeDepth(cur, DEC_DEPTH);
1273 case LFUN_DEPTH_INCREMENT:
1274 changeDepth(cur, INC_DEPTH);
1277 case LFUN_MATH_DISPLAY:
1278 mathDispatch(cur, cmd, true);
1281 case LFUN_MATH_IMPORT_SELECTION:
1282 case LFUN_MATH_MODE:
1283 if (cmd.argument == "on")
1284 // don't pass "on" as argument
1285 mathDispatch(cur, FuncRequest(LFUN_MATH_MODE), false);
1287 mathDispatch(cur, cmd, false);
1290 case LFUN_MATH_MACRO:
1291 if (cmd.argument.empty())
1292 cur.errorMessage(N_("Missing argument"));
1294 string s = cmd.argument;
1295 string const s1 = token(s, ' ', 1);
1296 int const nargs = s1.empty() ? 0 : convert<int>(s1);
1297 string const s2 = token(s, ' ', 2);
1298 string const type = s2.empty() ? "newcommand" : s2;
1299 cur.insert(new MathMacroTemplate(token(s, ' ', 0), nargs, type));
1300 //cur.nextInset()->edit(cur, true);
1304 // passthrough hat and underscore outside mathed:
1305 case LFUN_MATH_SUBSCRIPT:
1306 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "_"), false);
1308 case LFUN_MATH_SUPERSCRIPT:
1309 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "^"), false);
1312 case LFUN_MATH_INSERT:
1313 case LFUN_MATH_MATRIX:
1314 case LFUN_MATH_DELIM:
1315 case LFUN_MATH_BIGDELIM: {
1316 cur.insert(new MathHullInset("simple"));
1317 cur.dispatch(FuncRequest(LFUN_CHAR_FORWARD));
1322 case LFUN_FONT_EMPH: {
1323 LyXFont font(LyXFont::ALL_IGNORE);
1324 font.setEmph(LyXFont::TOGGLE);
1325 toggleAndShow(cur, this, font);
1329 case LFUN_FONT_BOLD: {
1330 LyXFont font(LyXFont::ALL_IGNORE);
1331 font.setSeries(LyXFont::BOLD_SERIES);
1332 toggleAndShow(cur, this, font);
1336 case LFUN_FONT_NOUN: {
1337 LyXFont font(LyXFont::ALL_IGNORE);
1338 font.setNoun(LyXFont::TOGGLE);
1339 toggleAndShow(cur, this, font);
1343 case LFUN_FONT_CODE: {
1344 LyXFont font(LyXFont::ALL_IGNORE);
1345 font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
1346 toggleAndShow(cur, this, font);
1350 case LFUN_FONT_SANS: {
1351 LyXFont font(LyXFont::ALL_IGNORE);
1352 font.setFamily(LyXFont::SANS_FAMILY);
1353 toggleAndShow(cur, this, font);
1357 case LFUN_FONT_ROMAN: {
1358 LyXFont font(LyXFont::ALL_IGNORE);
1359 font.setFamily(LyXFont::ROMAN_FAMILY);
1360 toggleAndShow(cur, this, font);
1364 case LFUN_FONT_DEFAULT: {
1365 LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
1366 toggleAndShow(cur, this, font);
1370 case LFUN_FONT_UNDERLINE: {
1371 LyXFont font(LyXFont::ALL_IGNORE);
1372 font.setUnderbar(LyXFont::TOGGLE);
1373 toggleAndShow(cur, this, font);
1377 case LFUN_FONT_SIZE: {
1378 LyXFont font(LyXFont::ALL_IGNORE);
1379 font.setLyXSize(cmd.argument);
1380 toggleAndShow(cur, this, font);
1384 case LFUN_LANGUAGE: {
1385 Language const * lang = languages.getLanguage(cmd.argument);
1388 LyXFont font(LyXFont::ALL_IGNORE);
1389 font.setLanguage(lang);
1390 toggleAndShow(cur, this, font);
1395 case LFUN_FONT_FREE_APPLY:
1396 toggleAndShow(cur, this, freefont, toggleall);
1397 cur.message(_("Character set"));
1400 // Set the freefont using the contents of \param data dispatched from
1401 // the frontends and apply it at the current cursor location.
1402 case LFUN_FONT_FREE_UPDATE: {
1405 if (bv_funcs::string2font(cmd.argument, font, toggle)) {
1408 toggleAndShow(cur, this, freefont, toggleall);
1409 cur.message(_("Character set"));
1414 case LFUN_FINISHED_LEFT:
1415 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_LEFT:\n" << cur << endl;
1418 case LFUN_FINISHED_RIGHT:
1419 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_RIGHT:\n" << cur << endl;
1423 case LFUN_FINISHED_UP:
1424 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_UP:\n" << cur << endl;
1428 case LFUN_FINISHED_DOWN:
1429 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_DOWN:\n" << cur << endl;
1433 case LFUN_LAYOUT_PARAGRAPH: {
1435 params2string(cur.paragraph(), data);
1436 data = "show\n" + data;
1437 bv->owner()->getDialogs().show("paragraph", data);
1441 case LFUN_PARAGRAPH_UPDATE: {
1442 if (!bv->owner()->getDialogs().visible("paragraph"))
1445 params2string(cur.paragraph(), data);
1447 // Will the paragraph accept changes from the dialog?
1448 bool const accept = !cur.inset().forceDefaultParagraphs(cur.idx());
1450 data = "update " + convert<string>(accept) + '\n' + data;
1451 bv->owner()->getDialogs().update("paragraph", data);
1455 case LFUN_ACCENT_UMLAUT:
1456 case LFUN_ACCENT_CIRCUMFLEX:
1457 case LFUN_ACCENT_GRAVE:
1458 case LFUN_ACCENT_ACUTE:
1459 case LFUN_ACCENT_TILDE:
1460 case LFUN_ACCENT_CEDILLA:
1461 case LFUN_ACCENT_MACRON:
1462 case LFUN_ACCENT_DOT:
1463 case LFUN_ACCENT_UNDERDOT:
1464 case LFUN_ACCENT_UNDERBAR:
1465 case LFUN_ACCENT_CARON:
1466 case LFUN_ACCENT_SPECIAL_CARON:
1467 case LFUN_ACCENT_BREVE:
1468 case LFUN_ACCENT_TIE:
1469 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1470 case LFUN_ACCENT_CIRCLE:
1471 case LFUN_ACCENT_OGONEK:
1472 bv->owner()->getLyXFunc().handleKeyFunc(cmd.action);
1473 if (!cmd.argument.empty())
1474 bv->owner()->getIntl().getTransManager()
1475 .translateAndInsert(cmd.argument[0], this);
1478 case LFUN_FLOAT_LIST: {
1479 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
1480 if (tclass.floats().typeExist(cmd.argument)) {
1481 // not quite sure if we want this...
1483 cur.clearSelection();
1484 breakParagraph(cur);
1486 if (cur.lastpos() != 0) {
1488 breakParagraph(cur);
1491 setLayout(cur, tclass.defaultLayoutName());
1492 setParagraph(cur, Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
1493 insertInset(cur, new InsetFloatList(cmd.argument));
1496 lyxerr << "Non-existent float type: "
1497 << cmd.argument << endl;
1502 case LFUN_CHANGE_ACCEPT: {
1507 case LFUN_CHANGE_REJECT: {
1512 case LFUN_THESAURUS_ENTRY: {
1513 string arg = cmd.argument;
1515 arg = cur.selectionAsString(false);
1517 if (arg.size() > 100 || arg.empty()) {
1518 // Get word or selection
1519 selectWordWhenUnderCursor(cur, lyx::WHOLE_WORD);
1520 arg = cur.selectionAsString(false);
1523 bv->owner()->getDialogs().show("thesaurus", arg);
1527 case LFUN_PARAGRAPH_PARAMS_APPLY: {
1528 // Given data, an encoding of the ParagraphParameters
1529 // generated in the Paragraph dialog, this function sets
1530 // the current paragraph appropriately.
1531 istringstream is(cmd.argument);
1534 ParagraphParameters params;
1539 params.labelWidthString(),
1541 cur.message(_("Paragraph layout set"));
1545 case LFUN_INSET_DIALOG_SHOW: {
1546 InsetBase * inset = cur.nextInset();
1548 FuncRequest fr(LFUN_INSET_DIALOG_SHOW);
1549 inset->dispatch(cur, fr);
1555 if (cur.selection()) {
1556 cur.selection() = false;
1559 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
1564 lyxerr[Debug::ACTION]
1565 << BOOST_CURRENT_FUNCTION
1566 << ": Command " << cmd
1567 << " not DISPATCHED by LyXText" << endl;
1572 if (singleParUpdate)
1573 // Inserting characters does not change par height
1574 if (cur.bottom().paragraph().dim().height()
1575 == olddim.height()) {
1576 // if so, update _only_ this paragraph
1577 cur.bv().update(Update::SinglePar |
1579 Update::MultiParSel);
1585 && &oldTopSlice.inset() == &cur.inset()
1586 && oldTopSlice.idx() == cur.idx()
1588 && !cur.selection())
1595 bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
1596 FuncStatus & flag) const
1598 BOOST_ASSERT(cur.text() == this);
1600 LyXFont const & font = real_current_font;
1602 InsetBase::Code code = InsetBase::NO_CODE;
1604 switch (cmd.action) {
1606 case LFUN_DEPTH_DECREMENT:
1607 enable = changeDepthAllowed(cur, DEC_DEPTH);
1610 case LFUN_DEPTH_INCREMENT:
1611 enable = changeDepthAllowed(cur, INC_DEPTH);
1615 flag.setOnOff(cur.paragraph().params().startOfAppendix());
1618 case LFUN_BIBITEM_INSERT:
1619 enable = (cur.paragraph().layout()->labeltype == LABEL_BIBLIO);
1622 case LFUN_DIALOG_SHOW_NEW_INSET:
1623 if (cmd.argument == "bibitem")
1624 code = InsetBase::BIBITEM_CODE;
1625 else if (cmd.argument == "bibtex")
1626 code = InsetBase::BIBTEX_CODE;
1627 else if (cmd.argument == "box")
1628 code = InsetBase::BOX_CODE;
1629 else if (cmd.argument == "branch")
1630 code = InsetBase::BRANCH_CODE;
1631 else if (cmd.argument == "citation")
1632 code = InsetBase::CITE_CODE;
1633 else if (cmd.argument == "ert")
1634 code = InsetBase::ERT_CODE;
1635 else if (cmd.argument == "external")
1636 code = InsetBase::EXTERNAL_CODE;
1637 else if (cmd.argument == "float")
1638 code = InsetBase::FLOAT_CODE;
1639 else if (cmd.argument == "graphics")
1640 code = InsetBase::GRAPHICS_CODE;
1641 else if (cmd.argument == "include")
1642 code = InsetBase::INCLUDE_CODE;
1643 else if (cmd.argument == "index")
1644 code = InsetBase::INDEX_CODE;
1645 else if (cmd.argument == "label")
1646 code = InsetBase::LABEL_CODE;
1647 else if (cmd.argument == "note")
1648 code = InsetBase::NOTE_CODE;
1649 else if (cmd.argument == "ref")
1650 code = InsetBase::REF_CODE;
1651 else if (cmd.argument == "toc")
1652 code = InsetBase::TOC_CODE;
1653 else if (cmd.argument == "url")
1654 code = InsetBase::URL_CODE;
1655 else if (cmd.argument == "vspace")
1656 code = InsetBase::VSPACE_CODE;
1657 else if (cmd.argument == "wrap")
1658 code = InsetBase::WRAP_CODE;
1661 case LFUN_ERT_INSERT:
1662 code = InsetBase::ERT_CODE;
1664 case LFUN_FOOTNOTE_INSERT:
1665 code = InsetBase::FOOT_CODE;
1667 case LFUN_TABULAR_INSERT:
1668 code = InsetBase::TABULAR_CODE;
1670 case LFUN_MARGINALNOTE_INSERT:
1671 code = InsetBase::MARGIN_CODE;
1673 case LFUN_FLOAT_INSERT:
1674 case LFUN_FLOAT_WIDE_INSERT:
1675 code = InsetBase::FLOAT_CODE;
1677 case LFUN_WRAP_INSERT:
1678 code = InsetBase::WRAP_CODE;
1680 case LFUN_FLOAT_LIST:
1681 code = InsetBase::FLOAT_LIST_CODE;
1684 case LFUN_LIST_INSERT:
1685 code = InsetBase::LIST_CODE;
1687 case LFUN_THEOREM_INSERT:
1688 code = InsetBase::THEOREM_CODE;
1691 case LFUN_CAPTION_INSERT:
1692 code = InsetBase::CAPTION_CODE;
1694 case LFUN_NOTE_INSERT:
1695 code = InsetBase::NOTE_CODE;
1697 case LFUN_CHARSTYLE_INSERT:
1698 code = InsetBase::CHARSTYLE_CODE;
1699 if (cur.buffer().params().getLyXTextClass().charstyles().empty())
1702 case LFUN_BOX_INSERT:
1703 code = InsetBase::BOX_CODE;
1705 case LFUN_BRANCH_INSERT:
1706 code = InsetBase::BRANCH_CODE;
1707 if (cur.buffer().getMasterBuffer()->params().branchlist().empty())
1710 case LFUN_LABEL_INSERT:
1711 code = InsetBase::LABEL_CODE;
1713 case LFUN_OPTIONAL_INSERT:
1714 code = InsetBase::OPTARG_CODE;
1715 enable = numberOfOptArgs(cur.paragraph())
1716 < cur.paragraph().layout()->optionalargs;
1718 case LFUN_ENVIRONMENT_INSERT:
1719 code = InsetBase::BOX_CODE;
1721 case LFUN_INDEX_INSERT:
1722 code = InsetBase::INDEX_CODE;
1724 case LFUN_INDEX_PRINT:
1725 code = InsetBase::INDEX_PRINT_CODE;
1727 case LFUN_TOC_INSERT:
1728 code = InsetBase::TOC_CODE;
1730 case LFUN_HTML_INSERT:
1731 case LFUN_URL_INSERT:
1732 code = InsetBase::URL_CODE;
1734 case LFUN_QUOTE_INSERT:
1735 // always allow this, since we will inset a raw quote
1736 // if an inset is not allowed.
1738 case LFUN_HYPHENATION_POINT_INSERT:
1739 case LFUN_LIGATURE_BREAK_INSERT:
1740 case LFUN_HFILL_INSERT:
1741 case LFUN_MENU_SEPARATOR_INSERT:
1742 case LFUN_DOTS_INSERT:
1743 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
1744 code = InsetBase::SPECIALCHAR_CODE;
1746 case LFUN_SPACE_INSERT:
1747 // slight hack: we know this is allowed in math mode
1749 code = InsetBase::SPACE_CODE;
1752 #ifdef WITH_WARNINGS
1753 #warning This LFUN is not used anymore and should be nuked (JMarc 29/10/2005)
1756 case LFUN_INSET_DIALOG_SHOW: {
1757 InsetBase * inset = cur.nextInset();
1760 code = inset->lyxCode();
1761 if (!(code == InsetBase::INCLUDE_CODE
1762 || code == InsetBase::BIBTEX_CODE
1763 || code == InsetBase::FLOAT_LIST_CODE
1764 || code == InsetBase::TOC_CODE))
1771 case LFUN_INSET_MODIFY:
1772 // We need to disable this, because we may get called for a
1774 // InsetTabular::getStatus() -> InsetText::getStatus()
1775 // and we don't handle LFUN_INSET_MODIFY.
1779 case LFUN_FONT_EMPH:
1780 flag.setOnOff(font.emph() == LyXFont::ON);
1783 case LFUN_FONT_NOUN:
1784 flag.setOnOff(font.noun() == LyXFont::ON);
1787 case LFUN_FONT_BOLD:
1788 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
1791 case LFUN_FONT_SANS:
1792 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
1795 case LFUN_FONT_ROMAN:
1796 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
1799 case LFUN_FONT_CODE:
1800 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
1805 enable = cur.selection();
1809 enable = lyx::cap::numberOfSelections() > 0;
1812 case LFUN_PARAGRAPH_MOVE_UP: {
1813 enable = cur.pit() > 0 && !cur.selection();
1817 case LFUN_PARAGRAPH_MOVE_DOWN: {
1818 enable = cur.pit() < cur.lastpit() && !cur.selection();
1822 case LFUN_WORD_DELETE_FORWARD:
1823 case LFUN_WORD_DELETE_BACKWARD:
1824 case LFUN_LINE_DELETE:
1825 case LFUN_WORD_FORWARD:
1826 case LFUN_WORD_BACKWARD:
1827 case LFUN_CHAR_FORWARD:
1828 case LFUN_CHAR_FORWARD_SELECT:
1829 case LFUN_CHAR_BACKWARD:
1830 case LFUN_CHAR_BACKWARD_SELECT:
1832 case LFUN_UP_SELECT:
1834 case LFUN_DOWN_SELECT:
1835 case LFUN_PARAGRAPH_UP_SELECT:
1836 case LFUN_PARAGRAPH_DOWN_SELECT:
1837 case LFUN_SCREEN_UP_SELECT:
1838 case LFUN_SCREEN_DOWN_SELECT:
1839 case LFUN_LINE_BEGIN_SELECT:
1840 case LFUN_LINE_END_SELECT:
1841 case LFUN_WORD_FORWARD_SELECT:
1842 case LFUN_WORD_BACKWARD_SELECT:
1843 case LFUN_WORD_SELECT:
1844 case LFUN_PARAGRAPH_UP:
1845 case LFUN_PARAGRAPH_DOWN:
1846 case LFUN_SCREEN_UP:
1847 case LFUN_SCREEN_DOWN:
1848 case LFUN_LINE_BEGIN:
1850 case LFUN_BREAK_LINE:
1851 case LFUN_CHAR_DELETE_FORWARD:
1852 case LFUN_DELETE_FORWARD_SKIP:
1853 case LFUN_CHAR_DELETE_BACKWARD:
1854 case LFUN_DELETE_BACKWARD_SKIP:
1855 case LFUN_BREAK_PARAGRAPH:
1856 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
1857 case LFUN_BREAK_PARAGRAPH_SKIP:
1858 case LFUN_PARAGRAPH_SPACING:
1859 case LFUN_INSET_INSERT:
1860 case LFUN_NEXT_INSET_TOGGLE:
1861 case LFUN_WORD_UPCASE:
1862 case LFUN_WORD_LOWCASE:
1863 case LFUN_WORD_CAPITALIZE:
1864 case LFUN_CHARS_TRANSPOSE:
1865 case LFUN_SERVER_GET_XY:
1866 case LFUN_SERVER_SET_XY:
1867 case LFUN_SERVER_GET_FONT:
1868 case LFUN_SERVER_GET_LAYOUT:
1870 case LFUN_PRIMARY_SELECTION_PASTE:
1871 case LFUN_DATE_INSERT:
1872 case LFUN_SELF_INSERT:
1873 case LFUN_LINE_INSERT:
1874 case LFUN_PAGEBREAK_INSERT:
1875 case LFUN_MATH_DISPLAY:
1876 case LFUN_MATH_IMPORT_SELECTION:
1877 case LFUN_MATH_MODE:
1878 case LFUN_MATH_MACRO:
1879 case LFUN_MATH_INSERT:
1880 case LFUN_MATH_MATRIX:
1881 case LFUN_MATH_DELIM:
1882 case LFUN_MATH_BIGDELIM:
1883 case LFUN_MATH_SUBSCRIPT:
1884 case LFUN_MATH_SUPERSCRIPT:
1885 case LFUN_FONT_DEFAULT:
1886 case LFUN_FONT_UNDERLINE:
1887 case LFUN_FONT_SIZE:
1889 case LFUN_FONT_FREE_APPLY:
1890 case LFUN_FONT_FREE_UPDATE:
1891 case LFUN_LAYOUT_PARAGRAPH:
1892 case LFUN_PARAGRAPH_UPDATE:
1893 case LFUN_ACCENT_UMLAUT:
1894 case LFUN_ACCENT_CIRCUMFLEX:
1895 case LFUN_ACCENT_GRAVE:
1896 case LFUN_ACCENT_ACUTE:
1897 case LFUN_ACCENT_TILDE:
1898 case LFUN_ACCENT_CEDILLA:
1899 case LFUN_ACCENT_MACRON:
1900 case LFUN_ACCENT_DOT:
1901 case LFUN_ACCENT_UNDERDOT:
1902 case LFUN_ACCENT_UNDERBAR:
1903 case LFUN_ACCENT_CARON:
1904 case LFUN_ACCENT_SPECIAL_CARON:
1905 case LFUN_ACCENT_BREVE:
1906 case LFUN_ACCENT_TIE:
1907 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1908 case LFUN_ACCENT_CIRCLE:
1909 case LFUN_ACCENT_OGONEK:
1910 case LFUN_CHANGE_ACCEPT:
1911 case LFUN_CHANGE_REJECT:
1912 case LFUN_THESAURUS_ENTRY:
1913 case LFUN_PARAGRAPH_PARAMS_APPLY:
1915 case LFUN_BUFFER_END:
1916 case LFUN_BUFFER_BEGIN:
1917 case LFUN_BUFFER_BEGIN_SELECT:
1918 case LFUN_BUFFER_END_SELECT:
1919 // these are handled in our dispatch()
1927 if (code != InsetBase::NO_CODE
1928 && (cur.empty() || !cur.inset().insetAllowed(code)))
1931 flag.enabled(enable);