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"
32 #include "errorlist.h"
34 #include "funcrequest.h"
38 #include "LyXAction.h"
43 #include "paragraph.h"
44 #include "paragraph_funcs.h"
45 #include "ParagraphParameters.h"
48 #include "pariterator.h"
50 #include "frontends/Dialogs.h"
51 #include "frontends/Gui.h"
52 #include "frontends/LyXView.h"
53 #include "frontends/Clipboard.h"
54 #include "frontends/Selection.h"
56 #include "insets/insetcommand.h"
57 #include "insets/insetfloatlist.h"
58 #include "insets/insetnewline.h"
59 #include "insets/insetquotes.h"
60 #include "insets/insetspecialchar.h"
61 #include "insets/insettext.h"
63 #include "support/lstrings.h"
64 #include "support/lyxlib.h"
65 #include "support/convert.h"
66 #include "support/lyxtime.h"
68 #include "mathed/math_hullinset.h"
69 #include "mathed/math_macrotemplate.h"
71 #include <boost/current_function.hpp>
78 using lyx::cap::copySelection;
79 using lyx::cap::cutSelection;
80 using lyx::cap::pasteSelection;
81 using lyx::cap::replaceSelection;
83 using lyx::support::isStrUnsignedInt;
84 using lyx::support::token;
86 using lyx::frontend::Gui;
87 using lyx::frontend::Clipboard;
91 using std::istringstream;
92 using std::ostringstream;
95 extern string current_layout;
101 LyXFont freefont(LyXFont::ALL_IGNORE);
102 bool toggleall = false;
105 void toggleAndShow(LCursor & cur, LyXText * text,
106 LyXFont const & font, bool toggleall = true)
108 text->toggleFree(cur, font, toggleall);
110 if (font.language() != ignore_language ||
111 font.number() != LyXFont::IGNORE) {
112 Paragraph & par = cur.paragraph();
113 text->bidi.computeTables(par, cur.buffer(), cur.textRow());
114 if (cur.boundary() !=
115 text->bidi.isBoundary(cur.buffer(), par,
117 text->real_current_font))
118 text->setCursor(cur, cur.pit(), cur.pos(),
119 false, !cur.boundary());
124 void moveCursor(LCursor & cur, bool selecting)
126 if (selecting || cur.mark())
128 if (!cur.selection())
129 cur.bv().owner()->gui().selection().haveSelection(false);
130 cur.bv().switchKeyMap();
134 void finishChange(LCursor & cur, bool selecting)
137 moveCursor(cur, selecting);
141 void mathDispatch(LCursor & cur, FuncRequest const & cmd, bool display)
144 string sel = cur.selectionAsString(false);
145 //lyxerr << "selection is: '" << sel << "'" << endl;
147 // It may happen that sel is empty but there is a selection
148 replaceSelection(cur);
151 const int old_pos = cur.pos();
152 cur.insert(new MathHullInset("simple"));
153 BOOST_ASSERT(old_pos == cur.pos());
154 cur.nextInset()->edit(cur, true);
155 // don't do that also for LFUN_MATH_MODE
156 // unless you want end up with always changing
157 // to mathrm when opening an inlined inset --
158 // I really hate "LyXfunc overloading"...
160 cur.dispatch(FuncRequest(LFUN_MATH_DISPLAY));
161 // Avoid an unnecessary undo step if cmd.argument
163 if (!cmd.argument.empty())
164 cur.dispatch(FuncRequest(LFUN_MATH_INSERT,
167 // create a macro if we see "\\newcommand"
168 // somewhere, and an ordinary formula
170 istringstream is(sel);
171 if (sel.find("\\newcommand") == string::npos
172 && sel.find("\\def") == string::npos)
174 MathHullInset * formula = new MathHullInset;
177 formula->read(cur.buffer(), lex);
178 if (formula->getType() == "none")
179 // Don't create pseudo formulas if
180 // delimiters are left out
181 formula->mutate("simple");
184 cur.insert(new MathMacroTemplate(is));
186 cur.message(N_("Math editor mode"));
195 string const freefont2string()
198 if (font2string(freefont, toggleall, data))
205 bool LyXText::cursorPrevious(LCursor & cur)
207 pos_type cpos = cur.pos();
208 lyx::pit_type cpar = cur.pit();
210 int x = cur.x_target();
212 bool updated = setCursorFromCoordinates(cur, x, 0);
215 updated |= cursorUp(cur);
217 if (cpar == cur.pit() && cpos == cur.pos()) {
218 // we have a row which is taller than the workarea. The
219 // simplest solution is to move to the previous row instead.
220 updated |= cursorUp(cur);
228 bool LyXText::cursorNext(LCursor & cur)
230 pos_type cpos = cur.pos();
231 lyx::pit_type cpar = cur.pit();
233 int x = cur.x_target();
234 bool updated = setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1);
237 updated |= cursorDown(cur);
239 if (cpar == cur.pit() && cpos == cur.pos()) {
240 // we have a row which is taller than the workarea. The
241 // simplest solution is to move to the next row instead.
242 updated |= cursorDown(cur);
252 void specialChar(LCursor & cur, InsetSpecialChar::Kind kind)
254 lyx::cap::replaceSelection(cur);
255 cur.insert(new InsetSpecialChar(kind));
260 bool doInsertInset(LCursor & cur, LyXText * text,
261 FuncRequest const & cmd, bool edit, bool pastesel)
263 InsetBase * inset = createInset(&cur.bv(), cmd);
269 if (cur.selection()) {
270 cur.bv().owner()->dispatch(FuncRequest(LFUN_CUT));
273 text->insertInset(cur, inset);
276 inset->edit(cur, true);
278 if (gotsel && pastesel)
279 cur.bv().owner()->dispatch(FuncRequest(LFUN_PASTE));
284 void update(LCursor & cur)
286 //we don't call update(true, false) directly to save a metrics call
287 if (cur.bv().fitCursor())
288 cur.bv().update(Update::Force);
295 void LyXText::number(LCursor & cur)
297 LyXFont font(LyXFont::ALL_IGNORE);
298 font.setNumber(LyXFont::TOGGLE);
299 toggleAndShow(cur, this, font);
303 bool LyXText::isRTL(Paragraph const & par) const
305 return par.isRightToLeftPar(bv()->buffer()->params());
309 void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
311 lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl;
313 BOOST_ASSERT(cur.text() == this);
314 BufferView * bv = &cur.bv();
315 CursorSlice oldTopSlice = cur.top();
316 bool oldBoundary = cur.boundary();
317 bool sel = cur.selection();
318 // Signals that, even if needsUpdate == false, an update of the
319 // cursor paragraph is required
320 bool singleParUpdate = lyxaction.funcHasFlag(cmd.action,
321 LyXAction::SingleParUpdate);
322 // Signals that a full-screen update is required
323 bool needsUpdate = !(lyxaction.funcHasFlag(cmd.action,
324 LyXAction::NoUpdate) || singleParUpdate);
325 // Remember the old paragraph metric (_outer_ paragraph!)
326 Dimension olddim = cur.bottom().paragraph().dim();
328 switch (cmd.action) {
330 case LFUN_PARAGRAPH_MOVE_DOWN: {
331 pit_type const pit = cur.pit();
332 recUndo(pit, pit + 1);
334 std::swap(pars_[pit], pars_[pit + 1]);
336 ParIterator begin(cur);
338 ParIterator end = boost::next(ParIterator(cur));
339 updateLabels(cur.buffer(), begin, end);
345 case LFUN_PARAGRAPH_MOVE_UP: {
346 pit_type const pit = cur.pit();
347 recUndo(pit - 1, pit);
349 std::swap(pars_[pit], pars_[pit - 1]);
351 ParIterator end = boost::next(ParIterator(cur));
353 ParIterator begin(cur);
354 updateLabels(cur.buffer(), begin, end);
360 case LFUN_APPENDIX: {
361 Paragraph & par = cur.paragraph();
362 bool start = !par.params().startOfAppendix();
365 #warning The code below only makes sense at top level.
366 // Should LFUN_APPENDIX be restricted to top-level paragraphs?
368 // ensure that we have only one start_of_appendix in this document
369 for (pit_type tmp = 0, end = pars_.size(); tmp != end; ++tmp) {
370 if (pars_[tmp].params().startOfAppendix()) {
372 pars_[tmp].params().startOfAppendix(false);
378 par.params().startOfAppendix(start);
380 // we can set the refreshing parameters now
381 updateLabels(cur.buffer());
385 case LFUN_WORD_DELETE_FORWARD:
386 cur.clearSelection();
387 deleteWordForward(cur);
388 finishChange(cur, false);
391 case LFUN_WORD_DELETE_BACKWARD:
392 cur.clearSelection();
393 deleteWordBackward(cur);
394 finishChange(cur, false);
397 case LFUN_LINE_DELETE:
398 cur.clearSelection();
399 deleteLineForward(cur);
400 finishChange(cur, false);
403 case LFUN_BUFFER_BEGIN:
404 case LFUN_BUFFER_BEGIN_SELECT:
405 cur.selHandle(cmd.action == LFUN_BUFFER_BEGIN_SELECT);
406 if (cur.depth() == 1) {
407 needsUpdate = cursorTop(cur);
413 case LFUN_BUFFER_END:
414 case LFUN_BUFFER_END_SELECT:
415 cur.selHandle(cmd.action == LFUN_BUFFER_END_SELECT);
416 if (cur.depth() == 1) {
417 needsUpdate = cursorBottom(cur);
423 case LFUN_CHAR_FORWARD:
424 case LFUN_CHAR_FORWARD_SELECT:
425 //lyxerr << BOOST_CURRENT_FUNCTION
426 // << " LFUN_CHAR_FORWARD[SEL]:\n" << cur << endl;
427 cur.selHandle(cmd.action == LFUN_CHAR_FORWARD_SELECT);
428 if (isRTL(cur.paragraph()))
429 needsUpdate = cursorLeft(cur);
431 needsUpdate = cursorRight(cur);
433 if (!needsUpdate && oldTopSlice == cur.top()
434 && cur.boundary() == oldBoundary) {
436 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
440 case LFUN_CHAR_BACKWARD:
441 case LFUN_CHAR_BACKWARD_SELECT:
442 //lyxerr << "handle LFUN_CHAR_BACKWARD[_SELECT]:\n" << cur << endl;
443 cur.selHandle(cmd.action == LFUN_CHAR_BACKWARD_SELECT);
444 if (isRTL(cur.paragraph()))
445 needsUpdate = cursorRight(cur);
447 needsUpdate = cursorLeft(cur);
449 if (!needsUpdate && oldTopSlice == cur.top()
450 && cur.boundary() == oldBoundary) {
452 cmd = FuncRequest(LFUN_FINISHED_LEFT);
459 //lyxerr << "handle LFUN_UP[SEL]:\n" << cur << endl;
460 cur.selHandle(cmd.action == LFUN_UP_SELECT);
462 needsUpdate = cursorUp(cur);
463 if (!needsUpdate && oldTopSlice == cur.top()
464 && cur.boundary() == oldBoundary) {
466 cmd = FuncRequest(LFUN_FINISHED_UP);
471 case LFUN_DOWN_SELECT:
473 //lyxerr << "handle LFUN_DOWN[SEL]:\n" << cur << endl;
474 cur.selHandle(cmd.action == LFUN_DOWN_SELECT);
475 needsUpdate = cursorDown(cur);
476 if (!needsUpdate && oldTopSlice == cur.top() &&
477 cur.boundary() == oldBoundary)
480 cmd = FuncRequest(LFUN_FINISHED_DOWN);
484 case LFUN_PARAGRAPH_UP:
485 case LFUN_PARAGRAPH_UP_SELECT:
486 cur.selHandle(cmd.action == LFUN_PARAGRAPH_UP_SELECT);
487 needsUpdate = cursorUpParagraph(cur);
490 case LFUN_PARAGRAPH_DOWN:
491 case LFUN_PARAGRAPH_DOWN_SELECT:
492 cur.selHandle(cmd.action == LFUN_PARAGRAPH_DOWN_SELECT);
493 needsUpdate = cursorDownParagraph(cur);
497 case LFUN_SCREEN_UP_SELECT:
499 cur.selHandle(cmd.action == LFUN_SCREEN_UP_SELECT);
500 if (cur.pit() == 0 && cur.textRow().pos() == 0) {
502 cmd = FuncRequest(LFUN_FINISHED_UP);
504 needsUpdate = cursorPrevious(cur);
508 case LFUN_SCREEN_DOWN:
509 case LFUN_SCREEN_DOWN_SELECT:
511 cur.selHandle(cmd.action == LFUN_SCREEN_DOWN_SELECT);
512 if (cur.pit() == cur.lastpit()
513 && cur.textRow().endpos() == cur.lastpos()) {
515 cmd = FuncRequest(LFUN_FINISHED_DOWN);
517 needsUpdate = cursorNext(cur);
521 case LFUN_LINE_BEGIN:
522 case LFUN_LINE_BEGIN_SELECT:
524 cur.selHandle(cmd.action == LFUN_LINE_BEGIN_SELECT);
525 needsUpdate = cursorHome(cur);
529 case LFUN_LINE_END_SELECT:
531 cur.selHandle(cmd.action == LFUN_LINE_END_SELECT);
532 needsUpdate = cursorEnd(cur);
535 case LFUN_WORD_FORWARD:
536 case LFUN_WORD_FORWARD_SELECT:
537 cur.selHandle(cmd.action == LFUN_WORD_FORWARD_SELECT);
538 if (isRTL(cur.paragraph()))
539 needsUpdate = cursorLeftOneWord(cur);
541 needsUpdate = cursorRightOneWord(cur);
544 case LFUN_WORD_BACKWARD:
545 case LFUN_WORD_BACKWARD_SELECT:
546 cur.selHandle(cmd.action == LFUN_WORD_BACKWARD_SELECT);
547 if (isRTL(cur.paragraph()))
548 needsUpdate = cursorRightOneWord(cur);
550 needsUpdate = cursorLeftOneWord(cur);
553 case LFUN_WORD_SELECT: {
554 selectWord(cur, lyx::WHOLE_WORD);
555 finishChange(cur, true);
559 case LFUN_BREAK_LINE: {
560 // Not allowed by LaTeX (labels or empty par)
561 if (cur.pos() > cur.paragraph().beginOfBody()) {
562 lyx::cap::replaceSelection(cur);
563 cur.insert(new InsetNewline);
565 moveCursor(cur, false);
570 case LFUN_CHAR_DELETE_FORWARD:
571 if (!cur.selection()) {
572 if (cur.pos() == cur.paragraph().size())
573 // Par boundary, force full-screen update
574 singleParUpdate = false;
575 needsUpdate = erase(cur);
577 // It is possible to make it a lot faster still
578 // just comment out the line below...
580 cutSelection(cur, true, false);
581 singleParUpdate = false;
583 moveCursor(cur, false);
586 case LFUN_DELETE_FORWARD_SKIP:
587 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
588 if (!cur.selection()) {
589 if (cur.pos() == cur.lastpos()) {
596 cutSelection(cur, true, false);
601 case LFUN_CHAR_DELETE_BACKWARD:
602 if (!cur.selection()) {
603 if (bv->owner()->getIntl().getTransManager().backspace()) {
604 // Par boundary, full-screen update
606 singleParUpdate = false;
607 needsUpdate = backspace(cur);
609 // It is possible to make it a lot faster still
610 // just comment out the line below...
613 cutSelection(cur, true, false);
614 singleParUpdate = false;
619 case LFUN_DELETE_BACKWARD_SKIP:
620 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
621 if (!cur.selection()) {
625 //CursorSlice cur = cursor();
629 cutSelection(cur, true, false);
633 case LFUN_BREAK_PARAGRAPH:
634 lyx::cap::replaceSelection(cur);
635 breakParagraph(cur, 0);
640 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
641 lyx::cap::replaceSelection(cur);
642 breakParagraph(cur, 1);
647 case LFUN_BREAK_PARAGRAPH_SKIP: {
648 // When at the beginning of a paragraph, remove
649 // indentation. Otherwise, do the same as LFUN_BREAK_PARAGRAPH.
650 lyx::cap::replaceSelection(cur);
652 cur.paragraph().params().labelWidthString(string());
654 breakParagraph(cur, 0);
660 case LFUN_PARAGRAPH_SPACING: {
661 Paragraph & par = cur.paragraph();
662 Spacing::Space cur_spacing = par.params().spacing().getSpace();
663 string cur_value = "1.0";
664 if (cur_spacing == Spacing::Other)
665 cur_value = par.params().spacing().getValueAsString();
667 istringstream is(cmd.argument);
670 Spacing::Space new_spacing = cur_spacing;
671 string new_value = cur_value;
673 lyxerr << "Missing argument to `paragraph-spacing'"
675 } else if (tmp == "single") {
676 new_spacing = Spacing::Single;
677 } else if (tmp == "onehalf") {
678 new_spacing = Spacing::Onehalf;
679 } else if (tmp == "double") {
680 new_spacing = Spacing::Double;
681 } else if (tmp == "other") {
682 new_spacing = Spacing::Other;
683 string tmpval = "0.0";
685 lyxerr << "new_value = " << tmpval << endl;
688 } else if (tmp == "default") {
689 new_spacing = Spacing::Default;
691 lyxerr << _("Unknown spacing argument: ")
692 << cmd.argument << endl;
694 if (cur_spacing != new_spacing || cur_value != new_value)
695 par.params().spacing(Spacing(new_spacing, new_value));
699 case LFUN_INSET_INSERT: {
701 InsetBase * inset = createInset(bv, cmd);
703 insertInset(cur, inset);
709 case LFUN_INSET_DISSOLVE: {
711 cur.selHandle(false);
713 lyx::pos_type spos = cur.pos();
714 lyx::pit_type spit = cur.pit();
715 bool content = false;
716 if (cur.lastpit() != 0 || cur.lastpos() != 0) {
717 setCursor(cur, 0, 0);
719 cur.pit() = cur.lastpit();
720 cur.pos() = cur.lastpos();
727 // store cursor offset
734 lyx::cap::replaceSelection(cur);
735 pasteSelection(cur, bv->buffer()->errorList("Paste"), 0);
736 cur.clearSelection();
738 cur.pit() = std::min(cur.lastpit(), spit);
739 cur.pos() = std::min(cur.lastpos(), spos);
742 cutSelection(cur, false, false);
747 case LFUN_INSET_SETTINGS:
748 cur.inset().showInsetDialog(bv);
751 case LFUN_SPACE_INSERT:
752 if (cur.paragraph().layout()->free_spacing)
753 insertChar(cur, ' ');
755 doInsertInset(cur, this, cmd, false, false);
758 moveCursor(cur, false);
761 case LFUN_HYPHENATION_POINT_INSERT:
762 specialChar(cur, InsetSpecialChar::HYPHENATION);
765 case LFUN_LIGATURE_BREAK_INSERT:
766 specialChar(cur, InsetSpecialChar::LIGATURE_BREAK);
769 case LFUN_DOTS_INSERT:
770 specialChar(cur, InsetSpecialChar::LDOTS);
773 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
774 specialChar(cur, InsetSpecialChar::END_OF_SENTENCE);
777 case LFUN_MENU_SEPARATOR_INSERT:
778 specialChar(cur, InsetSpecialChar::MENU_SEPARATOR);
781 case LFUN_WORD_UPCASE:
782 changeCase(cur, LyXText::text_uppercase);
785 case LFUN_WORD_LOWCASE:
786 changeCase(cur, LyXText::text_lowercase);
789 case LFUN_WORD_CAPITALIZE:
790 changeCase(cur, LyXText::text_capitalization);
793 case LFUN_CHARS_TRANSPOSE:
798 cur.message(_("Paste"));
799 lyx::cap::replaceSelection(cur);
800 if (isStrUnsignedInt(cmd.argument))
801 pasteSelection(cur, bv->buffer()->errorList("Paste"),
802 convert<unsigned int>(cmd.argument));
804 pasteSelection(cur, bv->buffer()->errorList("Paste"),
806 bv->buffer()->errors("Paste");
807 cur.clearSelection(); // bug 393
813 cutSelection(cur, true, true);
814 cur.message(_("Cut"));
819 cur.message(_("Copy"));
822 case LFUN_SERVER_GET_XY:
823 cur.message(convert<string>(cursorX(cur.top(), cur.boundary())) + ' '
824 + convert<string>(cursorY(cur.top(), cur.boundary())));
827 case LFUN_SERVER_SET_XY: {
830 istringstream is(cmd.argument);
833 lyxerr << "SETXY: Could not parse coordinates in '"
834 << cmd.argument << std::endl;
836 setCursorFromCoordinates(cur, x, y);
840 case LFUN_SERVER_GET_FONT:
841 if (current_font.shape() == LyXFont::ITALIC_SHAPE)
843 else if (current_font.shape() == LyXFont::SMALLCAPS_SHAPE)
849 case LFUN_SERVER_GET_LAYOUT:
850 cur.message(cur.paragraph().layout()->name());
854 lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) "
855 << cmd.argument << endl;
857 // This is not the good solution to the empty argument
858 // problem, but it will hopefully suffice for 1.2.0.
859 // The correct solution would be to augument the
860 // function list/array with information about what
861 // functions needs arguments and their type.
862 if (cmd.argument.empty()) {
863 cur.errorMessage(_("LyX function 'layout' needs an argument."));
867 // Derive layout number from given argument (string)
868 // and current buffer's textclass (number)
869 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
870 bool hasLayout = tclass.hasLayout(cmd.argument);
871 string layout = cmd.argument;
873 // If the entry is obsolete, use the new one instead.
875 string const & obs = tclass[layout]->obsoleted_by();
881 cur.errorMessage(string(N_("Layout ")) + cmd.argument +
886 bool change_layout = (current_layout != layout);
888 if (!change_layout && cur.selection() &&
889 cur.selBegin().pit() != cur.selEnd().pit())
891 pit_type spit = cur.selBegin().pit();
892 pit_type epit = cur.selEnd().pit() + 1;
893 while (spit != epit) {
894 if (pars_[spit].layout()->name() != current_layout) {
895 change_layout = true;
903 current_layout = layout;
904 setLayout(cur, layout);
905 bv->owner()->setLayout(layout);
911 case LFUN_CLIPBOARD_PASTE: {
912 cur.clearSelection();
913 string const clip = bv->owner()->gui().clipboard().get();
916 if (cmd.argument == "paragraph")
917 insertStringAsParagraphs(cur, clip);
919 insertStringAsLines(cur, clip);
924 case LFUN_PRIMARY_SELECTION_PASTE: {
925 cur.clearSelection();
926 string const clip = bv->owner()->gui().selection().get();
929 if (cmd.argument == "paragraph")
930 insertStringAsParagraphs(cur, clip);
932 insertStringAsLines(cur, clip);
937 case LFUN_QUOTE_INSERT: {
938 lyx::cap::replaceSelection(cur);
939 Paragraph & par = cur.paragraph();
940 lyx::pos_type pos = cur.pos();
944 else if (cur.prevInset() && cur.prevInset()->isSpace())
947 c = par.getChar(pos - 1);
949 LyXLayout_ptr const & style = par.layout();
951 BufferParams const & bufparams = bv->buffer()->params();
952 if (!style->pass_thru
953 && par.getFontSettings(bufparams, pos).language()->lang() != "hebrew") {
954 string arg = cmd.argument;
956 cur.insert(new InsetQuotes(c,
957 bufparams.quotes_language,
958 InsetQuotes::SingleQ));
960 cur.insert(new InsetQuotes(c,
961 bufparams.quotes_language,
962 InsetQuotes::DoubleQ));
966 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT, "\""));
970 case LFUN_DATE_INSERT:
971 if (cmd.argument.empty())
972 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT,
973 lyx::formatted_time(lyx::current_time())));
975 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT,
976 lyx::formatted_time(lyx::current_time(), cmd.argument)));
979 case LFUN_MOUSE_TRIPLE:
980 if (cmd.button() == mouse_button::button1) {
986 bv->owner()->gui().selection().haveSelection(cur.selection());
990 case LFUN_MOUSE_DOUBLE:
991 if (cmd.button() == mouse_button::button1) {
992 selectWord(cur, lyx::WHOLE_WORD_STRICT);
994 bv->owner()->gui().selection().haveSelection(cur.selection());
998 // Single-click on work area
999 case LFUN_MOUSE_PRESS: {
1000 // Right click on a footnote flag opens float menu
1001 if (cmd.button() == mouse_button::button3)
1002 cur.clearSelection();
1004 // Middle button press pastes if we have a selection
1005 // We do this here as if the selection was inside an inset
1006 // it could get cleared on the unlocking of the inset so
1007 // we have to check this first
1008 bool paste_internally = false;
1009 if (cmd.button() == mouse_button::button2 && cur.selection()) {
1010 bv->owner()->dispatch(FuncRequest(LFUN_COPY));
1011 paste_internally = true;
1014 bv->mouseSetCursor(cur);
1016 // Insert primary selection with middle mouse
1017 // if there is a local selection in the current buffer,
1019 if (cmd.button() == mouse_button::button2) {
1020 if (paste_internally)
1021 bv->owner()->dispatch(FuncRequest(LFUN_PASTE));
1023 bv->owner()->dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph"));
1029 case LFUN_MOUSE_MOTION: {
1030 // Only use motion with button 1
1031 //if (cmd.button() != mouse_button::button1)
1034 // ignore motions deeper nested than the real anchor
1035 LCursor & bvcur = cur.bv().cursor();
1036 if (bvcur.anchor_.hasPart(cur)) {
1037 CursorSlice old = bvcur.top();
1039 int const wh = bv->workHeight();
1040 int const y = std::max(0, std::min(wh - 1, cmd.y));
1042 setCursorFromCoordinates(cur, cmd.x, y);
1043 cur.x_target() = cmd.x;
1048 // This is to allow jumping over large insets
1049 if (cur.top() == old) {
1056 if (cur.top() == old)
1059 // don't set anchor_
1060 bvcur.setCursor(cur);
1061 bvcur.selection() = true;
1062 //lyxerr << "MOTION: " << bv->cursor() << endl;
1070 case LFUN_MOUSE_RELEASE: {
1071 if (cmd.button() == mouse_button::button2)
1075 if (cmd.button() == mouse_button::button1)
1076 bv->owner()->gui().selection().haveSelection(cur.selection());
1079 bv->owner()->updateMenubar();
1080 bv->owner()->updateToolbars();
1084 case LFUN_SELF_INSERT: {
1085 if (cmd.argument.empty())
1088 // Automatically delete the currently selected
1089 // text and replace it with what is being
1090 // typed in now. Depends on lyxrc settings
1091 // "auto_region_delete", which defaults to
1094 if (lyxrc.auto_region_delete) {
1095 if (cur.selection())
1096 cutSelection(cur, false, false);
1097 bv->owner()->gui().selection().haveSelection(false);
1100 cur.clearSelection();
1101 LyXFont const old_font = real_current_font;
1103 string::const_iterator cit = cmd.argument.begin();
1104 string::const_iterator end = cmd.argument.end();
1105 for (; cit != end; ++cit)
1106 bv->owner()->getIntl().getTransManager().
1107 translateAndInsert(*cit, this);
1110 moveCursor(cur, false);
1114 case LFUN_URL_INSERT: {
1115 InsetCommandParams p("url");
1116 string const data = InsetCommandMailer::params2string("url", p);
1117 bv->owner()->getDialogs().show("url", data, 0);
1121 case LFUN_HTML_INSERT: {
1122 InsetCommandParams p("htmlurl");
1123 string const data = InsetCommandMailer::params2string("url", p);
1124 bv->owner()->getDialogs().show("url", data, 0);
1128 case LFUN_LABEL_INSERT: {
1129 // Try to generate a valid label
1130 string const contents = cmd.argument.empty() ?
1131 cur.getPossibleLabel() : cmd.argument;
1133 InsetCommandParams p("label", contents);
1134 string const data = InsetCommandMailer::params2string("label", p);
1136 if (cmd.argument.empty()) {
1137 bv->owner()->getDialogs().show("label", data, 0);
1139 FuncRequest fr(LFUN_INSET_INSERT, data);
1147 case LFUN_LIST_INSERT:
1148 case LFUN_THEOREM_INSERT:
1149 case LFUN_CAPTION_INSERT:
1151 case LFUN_NOTE_INSERT:
1152 case LFUN_CHARSTYLE_INSERT:
1153 case LFUN_BOX_INSERT:
1154 case LFUN_BRANCH_INSERT:
1155 case LFUN_BIBITEM_INSERT:
1156 case LFUN_ERT_INSERT:
1157 case LFUN_FOOTNOTE_INSERT:
1158 case LFUN_MARGINALNOTE_INSERT:
1159 case LFUN_OPTIONAL_INSERT:
1160 case LFUN_ENVIRONMENT_INSERT:
1161 // Open the inset, and move the current selection
1163 doInsertInset(cur, this, cmd, true, true);
1167 case LFUN_TABULAR_INSERT:
1168 // if there were no arguments, just open the dialog
1169 if (doInsertInset(cur, this, cmd, false, true))
1172 bv->owner()->getDialogs().show("tabularcreate");
1176 case LFUN_FLOAT_INSERT:
1177 case LFUN_FLOAT_WIDE_INSERT:
1178 case LFUN_WRAP_INSERT:
1179 doInsertInset(cur, this, cmd, true, true);
1181 // FIXME: the "Caption" name should not be hardcoded,
1182 // but given by the float definition.
1183 cur.dispatch(FuncRequest(LFUN_LAYOUT, "Caption"));
1186 case LFUN_INDEX_INSERT: {
1187 InsetBase * inset = createInset(&cur.bv(), cmd);
1192 cur.clearSelection();
1193 insertInset(cur, inset);
1194 inset->edit(cur, true);
1199 case LFUN_INDEX_PRINT:
1200 case LFUN_TOC_INSERT:
1201 case LFUN_HFILL_INSERT:
1202 case LFUN_LINE_INSERT:
1203 case LFUN_PAGEBREAK_INSERT:
1205 doInsertInset(cur, this, cmd, false, false);
1209 case LFUN_DEPTH_DECREMENT:
1210 changeDepth(cur, DEC_DEPTH);
1213 case LFUN_DEPTH_INCREMENT:
1214 changeDepth(cur, INC_DEPTH);
1217 case LFUN_MATH_DISPLAY:
1218 mathDispatch(cur, cmd, true);
1221 case LFUN_MATH_IMPORT_SELECTION:
1222 case LFUN_MATH_MODE:
1223 if (cmd.argument == "on")
1224 // don't pass "on" as argument
1225 mathDispatch(cur, FuncRequest(LFUN_MATH_MODE), false);
1227 mathDispatch(cur, cmd, false);
1230 case LFUN_MATH_MACRO:
1231 if (cmd.argument.empty())
1232 cur.errorMessage(N_("Missing argument"));
1234 string s = cmd.argument;
1235 string const s1 = token(s, ' ', 1);
1236 int const nargs = s1.empty() ? 0 : convert<int>(s1);
1237 string const s2 = token(s, ' ', 2);
1238 string const type = s2.empty() ? "newcommand" : s2;
1239 cur.insert(new MathMacroTemplate(token(s, ' ', 0), nargs, type));
1240 //cur.nextInset()->edit(cur, true);
1244 // passthrough hat and underscore outside mathed:
1245 case LFUN_MATH_SUBSCRIPT:
1246 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "_"), false);
1248 case LFUN_MATH_SUPERSCRIPT:
1249 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "^"), false);
1252 case LFUN_MATH_INSERT:
1253 case LFUN_MATH_MATRIX:
1254 case LFUN_MATH_DELIM:
1255 case LFUN_MATH_BIGDELIM: {
1256 cur.insert(new MathHullInset("simple"));
1257 cur.dispatch(FuncRequest(LFUN_CHAR_FORWARD));
1262 case LFUN_FONT_EMPH: {
1263 LyXFont font(LyXFont::ALL_IGNORE);
1264 font.setEmph(LyXFont::TOGGLE);
1265 toggleAndShow(cur, this, font);
1269 case LFUN_FONT_BOLD: {
1270 LyXFont font(LyXFont::ALL_IGNORE);
1271 font.setSeries(LyXFont::BOLD_SERIES);
1272 toggleAndShow(cur, this, font);
1276 case LFUN_FONT_NOUN: {
1277 LyXFont font(LyXFont::ALL_IGNORE);
1278 font.setNoun(LyXFont::TOGGLE);
1279 toggleAndShow(cur, this, font);
1283 case LFUN_FONT_CODE: {
1284 LyXFont font(LyXFont::ALL_IGNORE);
1285 font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
1286 toggleAndShow(cur, this, font);
1290 case LFUN_FONT_SANS: {
1291 LyXFont font(LyXFont::ALL_IGNORE);
1292 font.setFamily(LyXFont::SANS_FAMILY);
1293 toggleAndShow(cur, this, font);
1297 case LFUN_FONT_ROMAN: {
1298 LyXFont font(LyXFont::ALL_IGNORE);
1299 font.setFamily(LyXFont::ROMAN_FAMILY);
1300 toggleAndShow(cur, this, font);
1304 case LFUN_FONT_DEFAULT: {
1305 LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
1306 toggleAndShow(cur, this, font);
1310 case LFUN_FONT_UNDERLINE: {
1311 LyXFont font(LyXFont::ALL_IGNORE);
1312 font.setUnderbar(LyXFont::TOGGLE);
1313 toggleAndShow(cur, this, font);
1317 case LFUN_FONT_SIZE: {
1318 LyXFont font(LyXFont::ALL_IGNORE);
1319 font.setLyXSize(cmd.argument);
1320 toggleAndShow(cur, this, font);
1324 case LFUN_LANGUAGE: {
1325 Language const * lang = languages.getLanguage(cmd.argument);
1328 LyXFont font(LyXFont::ALL_IGNORE);
1329 font.setLanguage(lang);
1330 toggleAndShow(cur, this, font);
1335 case LFUN_FONT_FREE_APPLY:
1336 toggleAndShow(cur, this, freefont, toggleall);
1337 cur.message(_("Character set"));
1340 // Set the freefont using the contents of \param data dispatched from
1341 // the frontends and apply it at the current cursor location.
1342 case LFUN_FONT_FREE_UPDATE: {
1345 if (bv_funcs::string2font(cmd.argument, font, toggle)) {
1348 toggleAndShow(cur, this, freefont, toggleall);
1349 cur.message(_("Character set"));
1354 case LFUN_FINISHED_LEFT:
1355 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_LEFT:\n" << cur << endl;
1358 case LFUN_FINISHED_RIGHT:
1359 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_RIGHT:\n" << cur << endl;
1363 case LFUN_FINISHED_UP:
1364 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_UP:\n" << cur << endl;
1368 case LFUN_FINISHED_DOWN:
1369 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_DOWN:\n" << cur << endl;
1373 case LFUN_LAYOUT_PARAGRAPH: {
1375 params2string(cur.paragraph(), data);
1376 data = "show\n" + data;
1377 bv->owner()->getDialogs().show("paragraph", data);
1381 case LFUN_PARAGRAPH_UPDATE: {
1382 if (!bv->owner()->getDialogs().visible("paragraph"))
1385 params2string(cur.paragraph(), data);
1387 // Will the paragraph accept changes from the dialog?
1388 bool const accept = !cur.inset().forceDefaultParagraphs(cur.idx());
1390 data = "update " + convert<string>(accept) + '\n' + data;
1391 bv->owner()->getDialogs().update("paragraph", data);
1395 case LFUN_ACCENT_UMLAUT:
1396 case LFUN_ACCENT_CIRCUMFLEX:
1397 case LFUN_ACCENT_GRAVE:
1398 case LFUN_ACCENT_ACUTE:
1399 case LFUN_ACCENT_TILDE:
1400 case LFUN_ACCENT_CEDILLA:
1401 case LFUN_ACCENT_MACRON:
1402 case LFUN_ACCENT_DOT:
1403 case LFUN_ACCENT_UNDERDOT:
1404 case LFUN_ACCENT_UNDERBAR:
1405 case LFUN_ACCENT_CARON:
1406 case LFUN_ACCENT_SPECIAL_CARON:
1407 case LFUN_ACCENT_BREVE:
1408 case LFUN_ACCENT_TIE:
1409 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1410 case LFUN_ACCENT_CIRCLE:
1411 case LFUN_ACCENT_OGONEK:
1412 bv->owner()->getLyXFunc().handleKeyFunc(cmd.action);
1413 if (!cmd.argument.empty())
1414 bv->owner()->getIntl().getTransManager()
1415 .translateAndInsert(cmd.argument[0], this);
1418 case LFUN_FLOAT_LIST: {
1419 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
1420 if (tclass.floats().typeExist(cmd.argument)) {
1421 // not quite sure if we want this...
1423 cur.clearSelection();
1424 breakParagraph(cur);
1426 if (cur.lastpos() != 0) {
1428 breakParagraph(cur);
1431 setLayout(cur, tclass.defaultLayoutName());
1432 setParagraph(cur, Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
1433 insertInset(cur, new InsetFloatList(cmd.argument));
1436 lyxerr << "Non-existent float type: "
1437 << cmd.argument << endl;
1442 case LFUN_CHANGE_ACCEPT: {
1447 case LFUN_CHANGE_REJECT: {
1452 case LFUN_THESAURUS_ENTRY: {
1453 string arg = cmd.argument;
1455 arg = cur.selectionAsString(false);
1457 if (arg.size() > 100 || arg.empty()) {
1458 // Get word or selection
1459 selectWordWhenUnderCursor(cur, lyx::WHOLE_WORD);
1460 arg = cur.selectionAsString(false);
1463 bv->owner()->getDialogs().show("thesaurus", arg);
1467 case LFUN_PARAGRAPH_PARAMS_APPLY: {
1468 // Given data, an encoding of the ParagraphParameters
1469 // generated in the Paragraph dialog, this function sets
1470 // the current paragraph appropriately.
1471 istringstream is(cmd.argument);
1474 ParagraphParameters params;
1479 params.labelWidthString(),
1481 cur.message(_("Paragraph layout set"));
1486 if (cur.selection()) {
1487 cur.selection() = false;
1490 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
1495 lyxerr[Debug::ACTION]
1496 << BOOST_CURRENT_FUNCTION
1497 << ": Command " << cmd
1498 << " not DISPATCHED by LyXText" << endl;
1503 if (singleParUpdate)
1504 // Inserting characters does not change par height
1505 if (cur.bottom().paragraph().dim().height()
1506 == olddim.height()) {
1507 // if so, update _only_ this paragraph
1508 cur.bv().update(Update::SinglePar |
1510 Update::MultiParSel);
1516 && &oldTopSlice.inset() == &cur.inset()
1517 && oldTopSlice.idx() == cur.idx()
1519 && !cur.selection())
1526 bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
1527 FuncStatus & flag) const
1529 BOOST_ASSERT(cur.text() == this);
1531 LyXFont const & font = real_current_font;
1533 InsetBase::Code code = InsetBase::NO_CODE;
1535 switch (cmd.action) {
1537 case LFUN_DEPTH_DECREMENT:
1538 enable = changeDepthAllowed(cur, DEC_DEPTH);
1541 case LFUN_DEPTH_INCREMENT:
1542 enable = changeDepthAllowed(cur, INC_DEPTH);
1546 flag.setOnOff(cur.paragraph().params().startOfAppendix());
1549 case LFUN_BIBITEM_INSERT:
1550 enable = (cur.paragraph().layout()->labeltype == LABEL_BIBLIO);
1553 case LFUN_DIALOG_SHOW_NEW_INSET:
1554 if (cmd.argument == "bibitem")
1555 code = InsetBase::BIBITEM_CODE;
1556 else if (cmd.argument == "bibtex")
1557 code = InsetBase::BIBTEX_CODE;
1558 else if (cmd.argument == "box")
1559 code = InsetBase::BOX_CODE;
1560 else if (cmd.argument == "branch")
1561 code = InsetBase::BRANCH_CODE;
1562 else if (cmd.argument == "citation")
1563 code = InsetBase::CITE_CODE;
1564 else if (cmd.argument == "ert")
1565 code = InsetBase::ERT_CODE;
1566 else if (cmd.argument == "external")
1567 code = InsetBase::EXTERNAL_CODE;
1568 else if (cmd.argument == "float")
1569 code = InsetBase::FLOAT_CODE;
1570 else if (cmd.argument == "graphics")
1571 code = InsetBase::GRAPHICS_CODE;
1572 else if (cmd.argument == "include")
1573 code = InsetBase::INCLUDE_CODE;
1574 else if (cmd.argument == "index")
1575 code = InsetBase::INDEX_CODE;
1576 else if (cmd.argument == "label")
1577 code = InsetBase::LABEL_CODE;
1578 else if (cmd.argument == "note")
1579 code = InsetBase::NOTE_CODE;
1580 else if (cmd.argument == "ref")
1581 code = InsetBase::REF_CODE;
1582 else if (cmd.argument == "toc")
1583 code = InsetBase::TOC_CODE;
1584 else if (cmd.argument == "url")
1585 code = InsetBase::URL_CODE;
1586 else if (cmd.argument == "vspace")
1587 code = InsetBase::VSPACE_CODE;
1588 else if (cmd.argument == "wrap")
1589 code = InsetBase::WRAP_CODE;
1592 case LFUN_ERT_INSERT:
1593 code = InsetBase::ERT_CODE;
1595 case LFUN_FOOTNOTE_INSERT:
1596 code = InsetBase::FOOT_CODE;
1598 case LFUN_TABULAR_INSERT:
1599 code = InsetBase::TABULAR_CODE;
1601 case LFUN_MARGINALNOTE_INSERT:
1602 code = InsetBase::MARGIN_CODE;
1604 case LFUN_FLOAT_INSERT:
1605 case LFUN_FLOAT_WIDE_INSERT:
1606 code = InsetBase::FLOAT_CODE;
1608 case LFUN_WRAP_INSERT:
1609 code = InsetBase::WRAP_CODE;
1611 case LFUN_FLOAT_LIST:
1612 code = InsetBase::FLOAT_LIST_CODE;
1615 case LFUN_LIST_INSERT:
1616 code = InsetBase::LIST_CODE;
1618 case LFUN_THEOREM_INSERT:
1619 code = InsetBase::THEOREM_CODE;
1622 case LFUN_CAPTION_INSERT:
1623 code = InsetBase::CAPTION_CODE;
1625 case LFUN_NOTE_INSERT:
1626 code = InsetBase::NOTE_CODE;
1628 case LFUN_CHARSTYLE_INSERT:
1629 code = InsetBase::CHARSTYLE_CODE;
1630 if (cur.buffer().params().getLyXTextClass().charstyles().empty())
1633 case LFUN_BOX_INSERT:
1634 code = InsetBase::BOX_CODE;
1636 case LFUN_BRANCH_INSERT:
1637 code = InsetBase::BRANCH_CODE;
1638 if (cur.buffer().getMasterBuffer()->params().branchlist().empty())
1641 case LFUN_LABEL_INSERT:
1642 code = InsetBase::LABEL_CODE;
1644 case LFUN_OPTIONAL_INSERT:
1645 code = InsetBase::OPTARG_CODE;
1646 enable = numberOfOptArgs(cur.paragraph())
1647 < cur.paragraph().layout()->optionalargs;
1649 case LFUN_ENVIRONMENT_INSERT:
1650 code = InsetBase::BOX_CODE;
1652 case LFUN_INDEX_INSERT:
1653 code = InsetBase::INDEX_CODE;
1655 case LFUN_INDEX_PRINT:
1656 code = InsetBase::INDEX_PRINT_CODE;
1658 case LFUN_TOC_INSERT:
1659 code = InsetBase::TOC_CODE;
1661 case LFUN_HTML_INSERT:
1662 case LFUN_URL_INSERT:
1663 code = InsetBase::URL_CODE;
1665 case LFUN_QUOTE_INSERT:
1666 // always allow this, since we will inset a raw quote
1667 // if an inset is not allowed.
1669 case LFUN_HYPHENATION_POINT_INSERT:
1670 case LFUN_LIGATURE_BREAK_INSERT:
1671 case LFUN_HFILL_INSERT:
1672 case LFUN_MENU_SEPARATOR_INSERT:
1673 case LFUN_DOTS_INSERT:
1674 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
1675 code = InsetBase::SPECIALCHAR_CODE;
1677 case LFUN_SPACE_INSERT:
1678 // slight hack: we know this is allowed in math mode
1680 code = InsetBase::SPACE_CODE;
1683 case LFUN_INSET_MODIFY:
1684 // We need to disable this, because we may get called for a
1686 // InsetTabular::getStatus() -> InsetText::getStatus()
1687 // and we don't handle LFUN_INSET_MODIFY.
1691 case LFUN_FONT_EMPH:
1692 flag.setOnOff(font.emph() == LyXFont::ON);
1695 case LFUN_FONT_NOUN:
1696 flag.setOnOff(font.noun() == LyXFont::ON);
1699 case LFUN_FONT_BOLD:
1700 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
1703 case LFUN_FONT_SANS:
1704 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
1707 case LFUN_FONT_ROMAN:
1708 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
1711 case LFUN_FONT_CODE:
1712 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
1717 enable = cur.selection();
1721 enable = lyx::cap::numberOfSelections() > 0;
1724 case LFUN_PARAGRAPH_MOVE_UP: {
1725 enable = cur.pit() > 0 && !cur.selection();
1729 case LFUN_PARAGRAPH_MOVE_DOWN: {
1730 enable = cur.pit() < cur.lastpit() && !cur.selection();
1734 case LFUN_INSET_DISSOLVE: {
1735 enable = &cur.inset() && cur.inTexted();
1739 case LFUN_WORD_DELETE_FORWARD:
1740 case LFUN_WORD_DELETE_BACKWARD:
1741 case LFUN_LINE_DELETE:
1742 case LFUN_WORD_FORWARD:
1743 case LFUN_WORD_BACKWARD:
1744 case LFUN_CHAR_FORWARD:
1745 case LFUN_CHAR_FORWARD_SELECT:
1746 case LFUN_CHAR_BACKWARD:
1747 case LFUN_CHAR_BACKWARD_SELECT:
1749 case LFUN_UP_SELECT:
1751 case LFUN_DOWN_SELECT:
1752 case LFUN_PARAGRAPH_UP_SELECT:
1753 case LFUN_PARAGRAPH_DOWN_SELECT:
1754 case LFUN_SCREEN_UP_SELECT:
1755 case LFUN_SCREEN_DOWN_SELECT:
1756 case LFUN_LINE_BEGIN_SELECT:
1757 case LFUN_LINE_END_SELECT:
1758 case LFUN_WORD_FORWARD_SELECT:
1759 case LFUN_WORD_BACKWARD_SELECT:
1760 case LFUN_WORD_SELECT:
1761 case LFUN_PARAGRAPH_UP:
1762 case LFUN_PARAGRAPH_DOWN:
1763 case LFUN_SCREEN_UP:
1764 case LFUN_SCREEN_DOWN:
1765 case LFUN_LINE_BEGIN:
1767 case LFUN_BREAK_LINE:
1768 case LFUN_CHAR_DELETE_FORWARD:
1769 case LFUN_DELETE_FORWARD_SKIP:
1770 case LFUN_CHAR_DELETE_BACKWARD:
1771 case LFUN_DELETE_BACKWARD_SKIP:
1772 case LFUN_BREAK_PARAGRAPH:
1773 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
1774 case LFUN_BREAK_PARAGRAPH_SKIP:
1775 case LFUN_PARAGRAPH_SPACING:
1776 case LFUN_INSET_INSERT:
1777 case LFUN_WORD_UPCASE:
1778 case LFUN_WORD_LOWCASE:
1779 case LFUN_WORD_CAPITALIZE:
1780 case LFUN_CHARS_TRANSPOSE:
1781 case LFUN_SERVER_GET_XY:
1782 case LFUN_SERVER_SET_XY:
1783 case LFUN_SERVER_GET_FONT:
1784 case LFUN_SERVER_GET_LAYOUT:
1786 case LFUN_CLIPBOARD_PASTE:
1787 case LFUN_PRIMARY_SELECTION_PASTE:
1788 case LFUN_DATE_INSERT:
1789 case LFUN_SELF_INSERT:
1790 case LFUN_LINE_INSERT:
1791 case LFUN_PAGEBREAK_INSERT:
1792 case LFUN_MATH_DISPLAY:
1793 case LFUN_MATH_IMPORT_SELECTION:
1794 case LFUN_MATH_MODE:
1795 case LFUN_MATH_MACRO:
1796 case LFUN_MATH_INSERT:
1797 case LFUN_MATH_MATRIX:
1798 case LFUN_MATH_DELIM:
1799 case LFUN_MATH_BIGDELIM:
1800 case LFUN_MATH_SUBSCRIPT:
1801 case LFUN_MATH_SUPERSCRIPT:
1802 case LFUN_FONT_DEFAULT:
1803 case LFUN_FONT_UNDERLINE:
1804 case LFUN_FONT_SIZE:
1806 case LFUN_FONT_FREE_APPLY:
1807 case LFUN_FONT_FREE_UPDATE:
1808 case LFUN_LAYOUT_PARAGRAPH:
1809 case LFUN_PARAGRAPH_UPDATE:
1810 case LFUN_ACCENT_UMLAUT:
1811 case LFUN_ACCENT_CIRCUMFLEX:
1812 case LFUN_ACCENT_GRAVE:
1813 case LFUN_ACCENT_ACUTE:
1814 case LFUN_ACCENT_TILDE:
1815 case LFUN_ACCENT_CEDILLA:
1816 case LFUN_ACCENT_MACRON:
1817 case LFUN_ACCENT_DOT:
1818 case LFUN_ACCENT_UNDERDOT:
1819 case LFUN_ACCENT_UNDERBAR:
1820 case LFUN_ACCENT_CARON:
1821 case LFUN_ACCENT_SPECIAL_CARON:
1822 case LFUN_ACCENT_BREVE:
1823 case LFUN_ACCENT_TIE:
1824 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1825 case LFUN_ACCENT_CIRCLE:
1826 case LFUN_ACCENT_OGONEK:
1827 case LFUN_CHANGE_ACCEPT:
1828 case LFUN_CHANGE_REJECT:
1829 case LFUN_THESAURUS_ENTRY:
1830 case LFUN_PARAGRAPH_PARAMS_APPLY:
1832 case LFUN_BUFFER_END:
1833 case LFUN_BUFFER_BEGIN:
1834 case LFUN_BUFFER_BEGIN_SELECT:
1835 case LFUN_BUFFER_END_SELECT:
1836 // these are handled in our dispatch()
1844 if (code != InsetBase::NO_CODE
1845 && (cur.empty() || !cur.inset().insetAllowed(code)))
1848 flag.enabled(enable);