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/Clipboard.h"
51 #include "frontends/Selection.h"
53 #include "insets/insetcommand.h"
54 #include "insets/insetfloatlist.h"
55 #include "insets/insetnewline.h"
56 #include "insets/insetquotes.h"
57 #include "insets/insetspecialchar.h"
58 #include "insets/insettext.h"
60 #include "support/lstrings.h"
61 #include "support/lyxlib.h"
62 #include "support/convert.h"
63 #include "support/lyxtime.h"
65 #include "mathed/InsetMathHull.h"
66 #include "mathed/MathMacroTemplate.h"
68 #include <boost/current_function.hpp>
76 using cap::copySelection;
77 using cap::cutSelection;
78 using cap::pasteSelection;
79 using cap::replaceSelection;
81 using support::isStrUnsignedInt;
86 using std::istringstream;
87 using std::ostringstream;
90 extern string current_layout;
96 LyXFont freefont(LyXFont::ALL_IGNORE);
97 bool toggleall = false;
100 void toggleAndShow(LCursor & cur, LyXText * text,
101 LyXFont const & font, bool toggleall = true)
103 text->toggleFree(cur, font, toggleall);
105 if (font.language() != ignore_language ||
106 font.number() != LyXFont::IGNORE) {
107 Paragraph & par = cur.paragraph();
108 text->bidi.computeTables(par, cur.buffer(), cur.textRow());
109 if (cur.boundary() !=
110 text->bidi.isBoundary(cur.buffer(), par,
112 text->real_current_font))
113 text->setCursor(cur, cur.pit(), cur.pos(),
114 false, !cur.boundary());
119 void moveCursor(LCursor & cur, bool selecting)
121 if (selecting || cur.mark())
123 if (!cur.selection())
124 theSelection().haveSelection(false);
125 cur.bv().switchKeyMap();
129 void finishChange(LCursor & cur, bool selecting)
132 moveCursor(cur, selecting);
136 void mathDispatch(LCursor & cur, FuncRequest const & cmd, bool display)
139 string sel = to_utf8(cur.selectionAsString(false));
140 //lyxerr << "selection is: '" << sel << "'" << endl;
142 // It may happen that sel is empty but there is a selection
143 replaceSelection(cur);
146 const int old_pos = cur.pos();
147 cur.insert(new InsetMathHull(hullSimple));
148 BOOST_ASSERT(old_pos == cur.pos());
149 cur.nextInset()->edit(cur, true);
150 // don't do that also for LFUN_MATH_MODE
151 // unless you want end up with always changing
152 // to mathrm when opening an inlined inset --
153 // I really hate "LyXfunc overloading"...
155 cur.dispatch(FuncRequest(LFUN_MATH_DISPLAY));
156 // Avoid an unnecessary undo step if cmd.argument
158 if (!cmd.argument().empty())
159 cur.dispatch(FuncRequest(LFUN_MATH_INSERT,
162 // create a macro if we see "\\newcommand"
163 // somewhere, and an ordinary formula
165 istringstream is(sel);
166 if (sel.find("\\newcommand") == string::npos
167 && sel.find("\\def") == string::npos)
169 InsetMathHull * formula = new InsetMathHull;
172 formula->read(cur.buffer(), lex);
173 if (formula->getType() == hullNone)
174 // Don't create pseudo formulas if
175 // delimiters are left out
176 formula->mutate(hullSimple);
179 cur.insert(new MathMacroTemplate(is));
181 cur.message(from_utf8(N_("Math editor mode")));
190 string const freefont2string()
193 if (font2string(freefont, toggleall, data))
200 bool LyXText::cursorPrevious(LCursor & cur)
202 pos_type cpos = cur.pos();
203 pit_type cpar = cur.pit();
205 int x = cur.x_target();
207 bool updated = setCursorFromCoordinates(cur, x, 0);
210 updated |= cursorUp(cur);
212 if (cpar == cur.pit() && cpos == cur.pos()) {
213 // we have a row which is taller than the workarea. The
214 // simplest solution is to move to the previous row instead.
215 updated |= cursorUp(cur);
223 bool LyXText::cursorNext(LCursor & cur)
225 pos_type cpos = cur.pos();
226 pit_type cpar = cur.pit();
228 int x = cur.x_target();
229 bool updated = setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1);
232 updated |= cursorDown(cur);
234 if (cpar == cur.pit() && cpos == cur.pos()) {
235 // we have a row which is taller than the workarea. The
236 // simplest solution is to move to the next row instead.
237 updated |= cursorDown(cur);
247 void specialChar(LCursor & cur, InsetSpecialChar::Kind kind)
249 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 lyx::dispatch(FuncRequest(LFUN_CUT));
268 text->insertInset(cur, inset);
271 inset->edit(cur, true);
273 if (gotsel && pastesel) {
274 lyx::dispatch(FuncRequest(LFUN_PASTE));
275 // reset first par to default
276 if (cur.lastpit() != 0 || cur.lastpos() != 0) {
277 LyXLayout_ptr const layout =
278 cur.buffer().params().getLyXTextClass().defaultLayout();
279 cur.text()->paragraphs().begin()->layout(layout);
286 void update(LCursor & cur)
288 //we don't call update(true, false) directly to save a metrics call
289 if (cur.bv().fitCursor())
290 cur.bv().update(Update::Force);
297 void LyXText::number(LCursor & cur)
299 LyXFont font(LyXFont::ALL_IGNORE);
300 font.setNumber(LyXFont::TOGGLE);
301 toggleAndShow(cur, this, font);
305 bool LyXText::isRTL(Paragraph const & par) const
307 return par.isRightToLeftPar(bv()->buffer()->params());
311 void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
313 lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl;
315 BOOST_ASSERT(cur.text() == this);
316 BufferView * bv = &cur.bv();
317 CursorSlice oldTopSlice = cur.top();
318 bool oldBoundary = cur.boundary();
319 bool sel = cur.selection();
320 // Signals that, even if needsUpdate == false, an update of the
321 // cursor paragraph is required
322 bool singleParUpdate = lyxaction.funcHasFlag(cmd.action,
323 LyXAction::SingleParUpdate);
324 // Signals that a full-screen update is required
325 bool needsUpdate = !(lyxaction.funcHasFlag(cmd.action,
326 LyXAction::NoUpdate) || singleParUpdate);
327 // Remember the old paragraph metric (_outer_ paragraph!)
328 Dimension olddim = cur.bottom().paragraph().dim();
330 switch (cmd.action) {
332 case LFUN_PARAGRAPH_MOVE_DOWN: {
333 pit_type const pit = cur.pit();
334 recUndo(pit, pit + 1);
336 std::swap(pars_[pit], pars_[pit + 1]);
338 ParIterator begin(cur);
340 ParIterator end = boost::next(ParIterator(cur));
341 updateLabels(cur.buffer(), begin, end);
347 case LFUN_PARAGRAPH_MOVE_UP: {
348 pit_type const pit = cur.pit();
349 recUndo(pit - 1, pit);
351 std::swap(pars_[pit], pars_[pit - 1]);
353 ParIterator end = boost::next(ParIterator(cur));
355 ParIterator begin(cur);
356 updateLabels(cur.buffer(), begin, end);
362 case LFUN_APPENDIX: {
363 Paragraph & par = cur.paragraph();
364 bool start = !par.params().startOfAppendix();
367 #warning The code below only makes sense at top level.
368 // Should LFUN_APPENDIX be restricted to top-level paragraphs?
370 // ensure that we have only one start_of_appendix in this document
371 for (pit_type tmp = 0, end = pars_.size(); tmp != end; ++tmp) {
372 if (pars_[tmp].params().startOfAppendix()) {
374 pars_[tmp].params().startOfAppendix(false);
380 par.params().startOfAppendix(start);
382 // we can set the refreshing parameters now
383 updateLabels(cur.buffer());
387 case LFUN_WORD_DELETE_FORWARD:
388 cur.clearSelection();
389 deleteWordForward(cur);
390 finishChange(cur, false);
393 case LFUN_WORD_DELETE_BACKWARD:
394 cur.clearSelection();
395 deleteWordBackward(cur);
396 finishChange(cur, false);
399 case LFUN_LINE_DELETE:
400 cur.clearSelection();
401 deleteLineForward(cur);
402 finishChange(cur, false);
405 case LFUN_BUFFER_BEGIN:
406 case LFUN_BUFFER_BEGIN_SELECT:
407 cur.selHandle(cmd.action == LFUN_BUFFER_BEGIN_SELECT);
408 if (cur.depth() == 1) {
409 needsUpdate = cursorTop(cur);
415 case LFUN_BUFFER_END:
416 case LFUN_BUFFER_END_SELECT:
417 cur.selHandle(cmd.action == LFUN_BUFFER_END_SELECT);
418 if (cur.depth() == 1) {
419 needsUpdate = cursorBottom(cur);
425 case LFUN_CHAR_FORWARD:
426 case LFUN_CHAR_FORWARD_SELECT:
427 //lyxerr << BOOST_CURRENT_FUNCTION
428 // << " LFUN_CHAR_FORWARD[SEL]:\n" << cur << endl;
429 cur.selHandle(cmd.action == LFUN_CHAR_FORWARD_SELECT);
430 if (isRTL(cur.paragraph()))
431 needsUpdate = cursorLeft(cur);
433 needsUpdate = cursorRight(cur);
435 if (!needsUpdate && oldTopSlice == cur.top()
436 && cur.boundary() == oldBoundary) {
438 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
442 case LFUN_CHAR_BACKWARD:
443 case LFUN_CHAR_BACKWARD_SELECT:
444 //lyxerr << "handle LFUN_CHAR_BACKWARD[_SELECT]:\n" << cur << endl;
445 cur.selHandle(cmd.action == LFUN_CHAR_BACKWARD_SELECT);
446 if (isRTL(cur.paragraph()))
447 needsUpdate = cursorRight(cur);
449 needsUpdate = cursorLeft(cur);
451 if (!needsUpdate && oldTopSlice == cur.top()
452 && cur.boundary() == oldBoundary) {
454 cmd = FuncRequest(LFUN_FINISHED_LEFT);
461 //lyxerr << "handle LFUN_UP[SEL]:\n" << cur << endl;
462 cur.selHandle(cmd.action == LFUN_UP_SELECT);
464 needsUpdate = cursorUp(cur);
465 if (!needsUpdate && oldTopSlice == cur.top()
466 && cur.boundary() == oldBoundary) {
468 cmd = FuncRequest(LFUN_FINISHED_UP);
473 case LFUN_DOWN_SELECT:
475 //lyxerr << "handle LFUN_DOWN[SEL]:\n" << cur << endl;
476 cur.selHandle(cmd.action == LFUN_DOWN_SELECT);
477 needsUpdate = cursorDown(cur);
478 if (!needsUpdate && oldTopSlice == cur.top() &&
479 cur.boundary() == oldBoundary)
482 cmd = FuncRequest(LFUN_FINISHED_DOWN);
486 case LFUN_PARAGRAPH_UP:
487 case LFUN_PARAGRAPH_UP_SELECT:
488 cur.selHandle(cmd.action == LFUN_PARAGRAPH_UP_SELECT);
489 needsUpdate = cursorUpParagraph(cur);
492 case LFUN_PARAGRAPH_DOWN:
493 case LFUN_PARAGRAPH_DOWN_SELECT:
494 cur.selHandle(cmd.action == LFUN_PARAGRAPH_DOWN_SELECT);
495 needsUpdate = cursorDownParagraph(cur);
499 case LFUN_SCREEN_UP_SELECT:
501 cur.selHandle(cmd.action == LFUN_SCREEN_UP_SELECT);
502 if (cur.pit() == 0 && cur.textRow().pos() == 0) {
504 cmd = FuncRequest(LFUN_FINISHED_UP);
506 needsUpdate = cursorPrevious(cur);
510 case LFUN_SCREEN_DOWN:
511 case LFUN_SCREEN_DOWN_SELECT:
513 cur.selHandle(cmd.action == LFUN_SCREEN_DOWN_SELECT);
514 if (cur.pit() == cur.lastpit()
515 && cur.textRow().endpos() == cur.lastpos()) {
517 cmd = FuncRequest(LFUN_FINISHED_DOWN);
519 needsUpdate = cursorNext(cur);
523 case LFUN_LINE_BEGIN:
524 case LFUN_LINE_BEGIN_SELECT:
526 cur.selHandle(cmd.action == LFUN_LINE_BEGIN_SELECT);
527 needsUpdate = cursorHome(cur);
531 case LFUN_LINE_END_SELECT:
533 cur.selHandle(cmd.action == LFUN_LINE_END_SELECT);
534 needsUpdate = cursorEnd(cur);
537 case LFUN_WORD_FORWARD:
538 case LFUN_WORD_FORWARD_SELECT:
539 cur.selHandle(cmd.action == LFUN_WORD_FORWARD_SELECT);
540 if (isRTL(cur.paragraph()))
541 needsUpdate = cursorLeftOneWord(cur);
543 needsUpdate = cursorRightOneWord(cur);
546 case LFUN_WORD_BACKWARD:
547 case LFUN_WORD_BACKWARD_SELECT:
548 cur.selHandle(cmd.action == LFUN_WORD_BACKWARD_SELECT);
549 if (isRTL(cur.paragraph()))
550 needsUpdate = cursorRightOneWord(cur);
552 needsUpdate = cursorLeftOneWord(cur);
555 case LFUN_WORD_SELECT: {
556 selectWord(cur, WHOLE_WORD);
557 finishChange(cur, true);
561 case LFUN_BREAK_LINE: {
562 // Not allowed by LaTeX (labels or empty par)
563 if (cur.pos() > cur.paragraph().beginOfBody()) {
564 cap::replaceSelection(cur);
565 cur.insert(new InsetNewline);
567 moveCursor(cur, false);
572 case LFUN_CHAR_DELETE_FORWARD:
573 if (!cur.selection()) {
574 if (cur.pos() == cur.paragraph().size())
575 // Par boundary, force full-screen update
576 singleParUpdate = false;
577 needsUpdate = erase(cur);
579 // It is possible to make it a lot faster still
580 // just comment out the line below...
582 cutSelection(cur, true, false);
583 singleParUpdate = false;
585 moveCursor(cur, false);
588 case LFUN_DELETE_FORWARD_SKIP:
589 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
590 if (!cur.selection()) {
591 if (cur.pos() == cur.lastpos()) {
598 cutSelection(cur, true, false);
603 case LFUN_CHAR_DELETE_BACKWARD:
604 if (!cur.selection()) {
605 if (bv->getIntl().getTransManager().backspace()) {
606 // Par boundary, full-screen update
608 singleParUpdate = false;
609 needsUpdate = backspace(cur);
611 // It is possible to make it a lot faster still
612 // just comment out the line below...
615 cutSelection(cur, true, false);
616 singleParUpdate = false;
621 case LFUN_DELETE_BACKWARD_SKIP:
622 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
623 if (!cur.selection()) {
627 //CursorSlice cur = cursor();
631 cutSelection(cur, true, false);
635 case LFUN_BREAK_PARAGRAPH:
636 cap::replaceSelection(cur);
637 breakParagraph(cur, 0);
642 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
643 cap::replaceSelection(cur);
644 breakParagraph(cur, 1);
649 case LFUN_BREAK_PARAGRAPH_SKIP: {
650 // When at the beginning of a paragraph, remove
651 // indentation. Otherwise, do the same as LFUN_BREAK_PARAGRAPH.
652 cap::replaceSelection(cur);
654 cur.paragraph().params().labelWidthString(docstring());
656 breakParagraph(cur, 0);
662 case LFUN_PARAGRAPH_SPACING: {
663 Paragraph & par = cur.paragraph();
664 Spacing::Space cur_spacing = par.params().spacing().getSpace();
665 string cur_value = "1.0";
666 if (cur_spacing == Spacing::Other)
667 cur_value = par.params().spacing().getValueAsString();
669 istringstream is(to_utf8(cmd.argument()));
672 Spacing::Space new_spacing = cur_spacing;
673 string new_value = cur_value;
675 lyxerr << "Missing argument to `paragraph-spacing'"
677 } else if (tmp == "single") {
678 new_spacing = Spacing::Single;
679 } else if (tmp == "onehalf") {
680 new_spacing = Spacing::Onehalf;
681 } else if (tmp == "double") {
682 new_spacing = Spacing::Double;
683 } else if (tmp == "other") {
684 new_spacing = Spacing::Other;
685 string tmpval = "0.0";
687 lyxerr << "new_value = " << tmpval << endl;
690 } else if (tmp == "default") {
691 new_spacing = Spacing::Default;
693 lyxerr << to_utf8(_("Unknown spacing argument: "))
694 << to_utf8(cmd.argument()) << endl;
696 if (cur_spacing != new_spacing || cur_value != new_value)
697 par.params().spacing(Spacing(new_spacing, new_value));
701 case LFUN_INSET_INSERT: {
703 InsetBase * inset = createInset(bv, cmd);
705 insertInset(cur, inset);
711 case LFUN_INSET_DISSOLVE:
712 needsUpdate = dissolveInset(cur);
715 case LFUN_INSET_SETTINGS:
716 cur.inset().showInsetDialog(bv);
719 case LFUN_SPACE_INSERT:
720 if (cur.paragraph().layout()->free_spacing)
721 insertChar(cur, ' ');
723 doInsertInset(cur, this, cmd, false, false);
726 moveCursor(cur, false);
729 case LFUN_HYPHENATION_POINT_INSERT:
730 specialChar(cur, InsetSpecialChar::HYPHENATION);
733 case LFUN_LIGATURE_BREAK_INSERT:
734 specialChar(cur, InsetSpecialChar::LIGATURE_BREAK);
737 case LFUN_DOTS_INSERT:
738 specialChar(cur, InsetSpecialChar::LDOTS);
741 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
742 specialChar(cur, InsetSpecialChar::END_OF_SENTENCE);
745 case LFUN_MENU_SEPARATOR_INSERT:
746 specialChar(cur, InsetSpecialChar::MENU_SEPARATOR);
749 case LFUN_WORD_UPCASE:
750 changeCase(cur, LyXText::text_uppercase);
753 case LFUN_WORD_LOWCASE:
754 changeCase(cur, LyXText::text_lowercase);
757 case LFUN_WORD_CAPITALIZE:
758 changeCase(cur, LyXText::text_capitalization);
761 case LFUN_CHARS_TRANSPOSE:
766 cur.message(_("Paste"));
767 cap::replaceSelection(cur);
768 if (isStrUnsignedInt(to_utf8(cmd.argument())))
769 pasteSelection(cur, bv->buffer()->errorList("Paste"),
770 convert<unsigned int>(to_utf8(cmd.argument())));
772 pasteSelection(cur, bv->buffer()->errorList("Paste"),
774 bv->buffer()->errors("Paste");
775 cur.clearSelection(); // bug 393
781 cutSelection(cur, true, true);
782 cur.message(_("Cut"));
787 cur.message(_("Copy"));
790 case LFUN_SERVER_GET_XY:
791 cur.message(from_utf8(
792 convert<string>(cursorX(cur.top(), cur.boundary())) + ' '
793 + convert<string>(cursorY(cur.top(), cur.boundary()))));
796 case LFUN_SERVER_SET_XY: {
799 istringstream is(to_utf8(cmd.argument()));
802 lyxerr << "SETXY: Could not parse coordinates in '"
803 << to_utf8(cmd.argument()) << std::endl;
805 setCursorFromCoordinates(cur, x, y);
809 case LFUN_SERVER_GET_FONT:
810 if (current_font.shape() == LyXFont::ITALIC_SHAPE)
811 cur.message(from_ascii("E"));
812 else if (current_font.shape() == LyXFont::SMALLCAPS_SHAPE)
813 cur.message(from_ascii("N"));
815 cur.message(from_ascii("0"));
818 case LFUN_SERVER_GET_LAYOUT:
819 cur.message(from_utf8(cur.paragraph().layout()->name()));
823 lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) "
824 << to_utf8(cmd.argument()) << endl;
826 // This is not the good solution to the empty argument
827 // problem, but it will hopefully suffice for 1.2.0.
828 // The correct solution would be to augument the
829 // function list/array with information about what
830 // functions needs arguments and their type.
831 if (cmd.argument().empty()) {
832 cur.errorMessage(_("LyX function 'layout' needs an argument."));
836 // Derive layout number from given argument (string)
837 // and current buffer's textclass (number)
838 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
839 bool hasLayout = tclass.hasLayout(to_utf8(cmd.argument()));
840 string layout = to_utf8(cmd.argument());
842 // If the entry is obsolete, use the new one instead.
844 string const & obs = tclass[layout]->obsoleted_by();
850 cur.errorMessage(from_utf8(N_("Layout ")) + cmd.argument() +
851 from_utf8(N_(" not known")));
855 bool change_layout = (current_layout != layout);
857 if (!change_layout && cur.selection() &&
858 cur.selBegin().pit() != cur.selEnd().pit())
860 pit_type spit = cur.selBegin().pit();
861 pit_type epit = cur.selEnd().pit() + 1;
862 while (spit != epit) {
863 if (pars_[spit].layout()->name() != current_layout) {
864 change_layout = true;
872 current_layout = layout;
873 setLayout(cur, layout);
874 // inform the GUI that the layout has changed.
875 bv->layoutChanged(layout);
881 case LFUN_CLIPBOARD_PASTE: {
882 cur.clearSelection();
883 docstring const clip = theClipboard().get();
886 if (cmd.argument() == "paragraph")
887 insertStringAsParagraphs(cur, clip);
889 insertStringAsLines(cur, clip);
894 case LFUN_PRIMARY_SELECTION_PASTE: {
895 cur.clearSelection();
896 docstring const clip = theSelection().get();
899 if (cmd.argument() == "paragraph")
900 insertStringAsParagraphs(cur, clip);
902 insertStringAsLines(cur, clip);
907 case LFUN_QUOTE_INSERT: {
908 cap::replaceSelection(cur);
909 Paragraph & par = cur.paragraph();
910 pos_type pos = cur.pos();
914 else if (cur.prevInset() && cur.prevInset()->isSpace())
917 c = par.getChar(pos - 1);
919 LyXLayout_ptr const & style = par.layout();
921 BufferParams const & bufparams = bv->buffer()->params();
922 if (!style->pass_thru
923 && par.getFontSettings(bufparams, pos).language()->lang() != "hebrew") {
924 string arg = to_utf8(cmd.argument());
926 cur.insert(new InsetQuotes(c,
927 bufparams.quotes_language,
928 InsetQuotes::SingleQ));
930 cur.insert(new InsetQuotes(c,
931 bufparams.quotes_language,
932 InsetQuotes::DoubleQ));
936 lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, "\""));
940 case LFUN_DATE_INSERT:
941 if (cmd.argument().empty())
942 lyx::dispatch(FuncRequest(LFUN_SELF_INSERT,
943 formatted_time(current_time())));
945 lyx::dispatch(FuncRequest(LFUN_SELF_INSERT,
946 formatted_time(current_time(), to_utf8(cmd.argument()))));
949 case LFUN_MOUSE_TRIPLE:
950 if (cmd.button() == mouse_button::button1) {
956 theSelection().haveSelection(cur.selection());
960 case LFUN_MOUSE_DOUBLE:
961 if (cmd.button() == mouse_button::button1) {
962 selectWord(cur, WHOLE_WORD_STRICT);
964 theSelection().haveSelection(cur.selection());
968 // Single-click on work area
969 case LFUN_MOUSE_PRESS: {
970 // Right click on a footnote flag opens float menu
971 if (cmd.button() == mouse_button::button3)
972 cur.clearSelection();
974 // Middle button press pastes if we have a selection
975 // We do this here as if the selection was inside an inset
976 // it could get cleared on the unlocking of the inset so
977 // we have to check this first
978 bool paste_internally = false;
979 if (cmd.button() == mouse_button::button2 && cur.selection()) {
980 lyx::dispatch(FuncRequest(LFUN_COPY));
981 paste_internally = true;
984 bv->mouseSetCursor(cur);
986 // Insert primary selection with middle mouse
987 // if there is a local selection in the current buffer,
989 if (cmd.button() == mouse_button::button2) {
990 if (paste_internally)
991 lyx::dispatch(FuncRequest(LFUN_PASTE));
993 lyx::dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph"));
999 case LFUN_MOUSE_MOTION: {
1000 // Only use motion with button 1
1001 //if (cmd.button() != mouse_button::button1)
1004 // ignore motions deeper nested than the real anchor
1005 LCursor & bvcur = cur.bv().cursor();
1006 if (bvcur.anchor_.hasPart(cur)) {
1007 CursorSlice old = bvcur.top();
1009 int const wh = bv->workHeight();
1010 int const y = std::max(0, std::min(wh - 1, cmd.y));
1012 setCursorFromCoordinates(cur, cmd.x, y);
1013 cur.x_target() = cmd.x;
1018 // This is to allow jumping over large insets
1019 if (cur.top() == old) {
1026 if (cur.top() == old)
1029 // don't set anchor_
1030 bvcur.setCursor(cur);
1031 bvcur.selection() = true;
1032 //lyxerr << "MOTION: " << bv->cursor() << endl;
1040 case LFUN_MOUSE_RELEASE: {
1041 if (cmd.button() == mouse_button::button2)
1045 if (cmd.button() == mouse_button::button1)
1046 theSelection().haveSelection(cur.selection());
1052 case LFUN_SELF_INSERT: {
1053 if (cmd.argument().empty())
1056 // Automatically delete the currently selected
1057 // text and replace it with what is being
1058 // typed in now. Depends on lyxrc settings
1059 // "auto_region_delete", which defaults to
1062 if (lyxrc.auto_region_delete) {
1063 if (cur.selection())
1064 cutSelection(cur, false, false);
1065 theSelection().haveSelection(false);
1068 cur.clearSelection();
1069 LyXFont const old_font = real_current_font;
1071 docstring::const_iterator cit = cmd.argument().begin();
1072 docstring::const_iterator end = cmd.argument().end();
1073 for (; cit != end; ++cit)
1075 bv->getIntl().getTransManager().
1076 translateAndInsert(*cit, this);
1078 insertChar(bv->cursor(), *cit);
1082 moveCursor(cur, false);
1086 case LFUN_URL_INSERT: {
1087 InsetCommandParams p("url");
1088 string const data = InsetCommandMailer::params2string("url", p);
1089 bv->showInsetDialog("url", data, 0);
1093 case LFUN_HTML_INSERT: {
1094 InsetCommandParams p("htmlurl");
1095 string const data = InsetCommandMailer::params2string("url", p);
1096 bv->showInsetDialog("url", data, 0);
1100 case LFUN_LABEL_INSERT: {
1101 InsetCommandParams p("label");
1102 // Try to generate a valid label
1103 p["name"] = (cmd.argument().empty()) ?
1105 from_utf8(cur.getPossibleLabel()) :
1107 string const data = InsetCommandMailer::params2string("label", p);
1109 if (cmd.argument().empty()) {
1110 bv->showInsetDialog("label", data, 0);
1112 FuncRequest fr(LFUN_INSET_INSERT, data);
1120 case LFUN_LIST_INSERT:
1121 case LFUN_THEOREM_INSERT:
1122 case LFUN_CAPTION_INSERT:
1124 case LFUN_NOTE_INSERT:
1125 case LFUN_CHARSTYLE_INSERT:
1126 case LFUN_BOX_INSERT:
1127 case LFUN_BRANCH_INSERT:
1128 case LFUN_BIBITEM_INSERT:
1129 case LFUN_ERT_INSERT:
1130 case LFUN_FOOTNOTE_INSERT:
1131 case LFUN_MARGINALNOTE_INSERT:
1132 case LFUN_OPTIONAL_INSERT:
1133 case LFUN_ENVIRONMENT_INSERT:
1134 // Open the inset, and move the current selection
1136 doInsertInset(cur, this, cmd, true, true);
1140 case LFUN_TABULAR_INSERT:
1141 // if there were no arguments, just open the dialog
1142 if (doInsertInset(cur, this, cmd, false, true))
1145 bv->showDialog("tabularcreate");
1149 case LFUN_FLOAT_INSERT:
1150 case LFUN_FLOAT_WIDE_INSERT:
1151 case LFUN_WRAP_INSERT:
1152 doInsertInset(cur, this, cmd, true, true);
1154 // FIXME: the "Caption" name should not be hardcoded,
1155 // but given by the float definition.
1156 cur.dispatch(FuncRequest(LFUN_LAYOUT, "Caption"));
1159 case LFUN_INDEX_INSERT: {
1160 InsetBase * inset = createInset(&cur.bv(), cmd);
1165 cur.clearSelection();
1166 insertInset(cur, inset);
1167 inset->edit(cur, true);
1172 case LFUN_INDEX_PRINT:
1173 case LFUN_TOC_INSERT:
1174 case LFUN_HFILL_INSERT:
1175 case LFUN_LINE_INSERT:
1176 case LFUN_PAGEBREAK_INSERT:
1178 doInsertInset(cur, this, cmd, false, false);
1182 case LFUN_DEPTH_DECREMENT:
1183 changeDepth(cur, DEC_DEPTH);
1186 case LFUN_DEPTH_INCREMENT:
1187 changeDepth(cur, INC_DEPTH);
1190 case LFUN_MATH_DISPLAY:
1191 mathDispatch(cur, cmd, true);
1194 case LFUN_MATH_IMPORT_SELECTION:
1195 case LFUN_MATH_MODE:
1196 if (cmd.argument() == "on")
1197 // don't pass "on" as argument
1198 mathDispatch(cur, FuncRequest(LFUN_MATH_MODE), false);
1200 mathDispatch(cur, cmd, false);
1203 case LFUN_MATH_MACRO:
1204 if (cmd.argument().empty())
1205 cur.errorMessage(from_utf8(N_("Missing argument")));
1207 string s = to_utf8(cmd.argument());
1208 string const s1 = token(s, ' ', 1);
1209 int const nargs = s1.empty() ? 0 : convert<int>(s1);
1210 string const s2 = token(s, ' ', 2);
1211 string const type = s2.empty() ? "newcommand" : s2;
1212 cur.insert(new MathMacroTemplate(token(s, ' ', 0), nargs, type));
1213 //cur.nextInset()->edit(cur, true);
1217 // passthrough hat and underscore outside mathed:
1218 case LFUN_MATH_SUBSCRIPT:
1219 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "_"), false);
1221 case LFUN_MATH_SUPERSCRIPT:
1222 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "^"), false);
1225 case LFUN_MATH_INSERT:
1226 case LFUN_MATH_MATRIX:
1227 case LFUN_MATH_DELIM:
1228 case LFUN_MATH_BIGDELIM: {
1229 cur.insert(new InsetMathHull(hullSimple));
1230 cur.dispatch(FuncRequest(LFUN_CHAR_FORWARD));
1235 case LFUN_FONT_EMPH: {
1236 LyXFont font(LyXFont::ALL_IGNORE);
1237 font.setEmph(LyXFont::TOGGLE);
1238 toggleAndShow(cur, this, font);
1242 case LFUN_FONT_BOLD: {
1243 LyXFont font(LyXFont::ALL_IGNORE);
1244 font.setSeries(LyXFont::BOLD_SERIES);
1245 toggleAndShow(cur, this, font);
1249 case LFUN_FONT_NOUN: {
1250 LyXFont font(LyXFont::ALL_IGNORE);
1251 font.setNoun(LyXFont::TOGGLE);
1252 toggleAndShow(cur, this, font);
1256 case LFUN_FONT_CODE: {
1257 LyXFont font(LyXFont::ALL_IGNORE);
1258 font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
1259 toggleAndShow(cur, this, font);
1263 case LFUN_FONT_SANS: {
1264 LyXFont font(LyXFont::ALL_IGNORE);
1265 font.setFamily(LyXFont::SANS_FAMILY);
1266 toggleAndShow(cur, this, font);
1270 case LFUN_FONT_ROMAN: {
1271 LyXFont font(LyXFont::ALL_IGNORE);
1272 font.setFamily(LyXFont::ROMAN_FAMILY);
1273 toggleAndShow(cur, this, font);
1277 case LFUN_FONT_DEFAULT: {
1278 LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
1279 toggleAndShow(cur, this, font);
1283 case LFUN_FONT_UNDERLINE: {
1284 LyXFont font(LyXFont::ALL_IGNORE);
1285 font.setUnderbar(LyXFont::TOGGLE);
1286 toggleAndShow(cur, this, font);
1290 case LFUN_FONT_SIZE: {
1291 LyXFont font(LyXFont::ALL_IGNORE);
1292 font.setLyXSize(to_utf8(cmd.argument()));
1293 toggleAndShow(cur, this, font);
1297 case LFUN_LANGUAGE: {
1298 Language const * lang = languages.getLanguage(to_utf8(cmd.argument()));
1301 LyXFont font(LyXFont::ALL_IGNORE);
1302 font.setLanguage(lang);
1303 toggleAndShow(cur, this, font);
1308 case LFUN_FONT_FREE_APPLY:
1309 toggleAndShow(cur, this, freefont, toggleall);
1310 cur.message(_("Character set"));
1313 // Set the freefont using the contents of \param data dispatched from
1314 // the frontends and apply it at the current cursor location.
1315 case LFUN_FONT_FREE_UPDATE: {
1318 if (bv_funcs::string2font(to_utf8(cmd.argument()), font, toggle)) {
1321 toggleAndShow(cur, this, freefont, toggleall);
1322 cur.message(_("Character set"));
1327 case LFUN_FINISHED_LEFT:
1328 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_LEFT:\n" << cur << endl;
1331 case LFUN_FINISHED_RIGHT:
1332 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_RIGHT:\n" << cur << endl;
1336 case LFUN_FINISHED_UP:
1337 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_UP:\n" << cur << endl;
1341 case LFUN_FINISHED_DOWN:
1342 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_DOWN:\n" << cur << endl;
1346 case LFUN_LAYOUT_PARAGRAPH: {
1348 params2string(cur.paragraph(), data);
1349 data = "show\n" + data;
1350 bv->showDialogWithData("paragraph", data);
1354 case LFUN_PARAGRAPH_UPDATE: {
1356 params2string(cur.paragraph(), data);
1358 // Will the paragraph accept changes from the dialog?
1359 bool const accept = !cur.inset().forceDefaultParagraphs(cur.idx());
1361 data = "update " + convert<string>(accept) + '\n' + data;
1362 bv->updateDialog("paragraph", data);
1366 case LFUN_ACCENT_UMLAUT:
1367 case LFUN_ACCENT_CIRCUMFLEX:
1368 case LFUN_ACCENT_GRAVE:
1369 case LFUN_ACCENT_ACUTE:
1370 case LFUN_ACCENT_TILDE:
1371 case LFUN_ACCENT_CEDILLA:
1372 case LFUN_ACCENT_MACRON:
1373 case LFUN_ACCENT_DOT:
1374 case LFUN_ACCENT_UNDERDOT:
1375 case LFUN_ACCENT_UNDERBAR:
1376 case LFUN_ACCENT_CARON:
1377 case LFUN_ACCENT_SPECIAL_CARON:
1378 case LFUN_ACCENT_BREVE:
1379 case LFUN_ACCENT_TIE:
1380 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1381 case LFUN_ACCENT_CIRCLE:
1382 case LFUN_ACCENT_OGONEK:
1383 theLyXFunc().handleKeyFunc(cmd.action);
1384 if (!cmd.argument().empty())
1385 // FIXME: Are all these characters encoded in one byte in utf8?
1386 bv->getIntl().getTransManager()
1387 .translateAndInsert(cmd.argument()[0], this);
1390 case LFUN_FLOAT_LIST: {
1391 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
1392 if (tclass.floats().typeExist(to_utf8(cmd.argument()))) {
1393 // not quite sure if we want this...
1395 cur.clearSelection();
1396 breakParagraph(cur);
1398 if (cur.lastpos() != 0) {
1400 breakParagraph(cur);
1403 setLayout(cur, tclass.defaultLayoutName());
1404 setParagraph(cur, Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
1405 insertInset(cur, new InsetFloatList(to_utf8(cmd.argument())));
1408 lyxerr << "Non-existent float type: "
1409 << to_utf8(cmd.argument()) << endl;
1414 case LFUN_CHANGE_ACCEPT: {
1419 case LFUN_CHANGE_REJECT: {
1424 case LFUN_THESAURUS_ENTRY: {
1425 docstring arg = cmd.argument();
1427 arg = cur.selectionAsString(false);
1429 if (arg.size() > 100 || arg.empty()) {
1430 // Get word or selection
1431 selectWordWhenUnderCursor(cur, WHOLE_WORD);
1432 arg = cur.selectionAsString(false);
1435 bv->showDialogWithData("thesaurus", to_utf8(arg));
1439 case LFUN_PARAGRAPH_PARAMS_APPLY: {
1440 // Given data, an encoding of the ParagraphParameters
1441 // generated in the Paragraph dialog, this function sets
1442 // the current paragraph appropriately.
1443 istringstream is(to_utf8(cmd.argument()));
1446 ParagraphParameters params;
1452 to_ascii(params.labelWidthString()),
1454 cur.message(_("Paragraph layout set"));
1459 if (cur.selection()) {
1460 cur.selection() = false;
1463 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
1468 lyxerr[Debug::ACTION]
1469 << BOOST_CURRENT_FUNCTION
1470 << ": Command " << cmd
1471 << " not DISPATCHED by LyXText" << endl;
1476 if (singleParUpdate)
1477 // Inserting characters does not change par height
1478 if (cur.bottom().paragraph().dim().height()
1479 == olddim.height()) {
1480 // if so, update _only_ this paragraph
1481 cur.bv().update(Update::SinglePar |
1483 Update::MultiParSel);
1489 && &oldTopSlice.inset() == &cur.inset()
1490 && oldTopSlice.idx() == cur.idx()
1492 && !cur.selection())
1499 bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
1500 FuncStatus & flag) const
1502 BOOST_ASSERT(cur.text() == this);
1504 LyXFont const & font = real_current_font;
1506 InsetBase::Code code = InsetBase::NO_CODE;
1508 switch (cmd.action) {
1510 case LFUN_DEPTH_DECREMENT:
1511 enable = changeDepthAllowed(cur, DEC_DEPTH);
1514 case LFUN_DEPTH_INCREMENT:
1515 enable = changeDepthAllowed(cur, INC_DEPTH);
1519 flag.setOnOff(cur.paragraph().params().startOfAppendix());
1522 case LFUN_BIBITEM_INSERT:
1523 enable = (cur.paragraph().layout()->labeltype == LABEL_BIBLIO);
1526 case LFUN_DIALOG_SHOW_NEW_INSET:
1527 if (cmd.argument() == "bibitem")
1528 code = InsetBase::BIBITEM_CODE;
1529 else if (cmd.argument() == "bibtex")
1530 code = InsetBase::BIBTEX_CODE;
1531 else if (cmd.argument() == "box")
1532 code = InsetBase::BOX_CODE;
1533 else if (cmd.argument() == "branch")
1534 code = InsetBase::BRANCH_CODE;
1535 else if (cmd.argument() == "citation")
1536 code = InsetBase::CITE_CODE;
1537 else if (cmd.argument() == "ert")
1538 code = InsetBase::ERT_CODE;
1539 else if (cmd.argument() == "external")
1540 code = InsetBase::EXTERNAL_CODE;
1541 else if (cmd.argument() == "float")
1542 code = InsetBase::FLOAT_CODE;
1543 else if (cmd.argument() == "graphics")
1544 code = InsetBase::GRAPHICS_CODE;
1545 else if (cmd.argument() == "include")
1546 code = InsetBase::INCLUDE_CODE;
1547 else if (cmd.argument() == "index")
1548 code = InsetBase::INDEX_CODE;
1549 else if (cmd.argument() == "label")
1550 code = InsetBase::LABEL_CODE;
1551 else if (cmd.argument() == "note")
1552 code = InsetBase::NOTE_CODE;
1553 else if (cmd.argument() == "ref")
1554 code = InsetBase::REF_CODE;
1555 else if (cmd.argument() == "toc")
1556 code = InsetBase::TOC_CODE;
1557 else if (cmd.argument() == "url")
1558 code = InsetBase::URL_CODE;
1559 else if (cmd.argument() == "vspace")
1560 code = InsetBase::VSPACE_CODE;
1561 else if (cmd.argument() == "wrap")
1562 code = InsetBase::WRAP_CODE;
1565 case LFUN_ERT_INSERT:
1566 code = InsetBase::ERT_CODE;
1568 case LFUN_FOOTNOTE_INSERT:
1569 code = InsetBase::FOOT_CODE;
1571 case LFUN_TABULAR_INSERT:
1572 code = InsetBase::TABULAR_CODE;
1574 case LFUN_MARGINALNOTE_INSERT:
1575 code = InsetBase::MARGIN_CODE;
1577 case LFUN_FLOAT_INSERT:
1578 case LFUN_FLOAT_WIDE_INSERT:
1579 code = InsetBase::FLOAT_CODE;
1581 case LFUN_WRAP_INSERT:
1582 code = InsetBase::WRAP_CODE;
1584 case LFUN_FLOAT_LIST:
1585 code = InsetBase::FLOAT_LIST_CODE;
1588 case LFUN_LIST_INSERT:
1589 code = InsetBase::LIST_CODE;
1591 case LFUN_THEOREM_INSERT:
1592 code = InsetBase::THEOREM_CODE;
1595 case LFUN_CAPTION_INSERT:
1596 code = InsetBase::CAPTION_CODE;
1598 case LFUN_NOTE_INSERT:
1599 code = InsetBase::NOTE_CODE;
1601 case LFUN_CHARSTYLE_INSERT:
1602 code = InsetBase::CHARSTYLE_CODE;
1603 if (cur.buffer().params().getLyXTextClass().charstyles().empty())
1606 case LFUN_BOX_INSERT:
1607 code = InsetBase::BOX_CODE;
1609 case LFUN_BRANCH_INSERT:
1610 code = InsetBase::BRANCH_CODE;
1611 if (cur.buffer().getMasterBuffer()->params().branchlist().empty())
1614 case LFUN_LABEL_INSERT:
1615 code = InsetBase::LABEL_CODE;
1617 case LFUN_OPTIONAL_INSERT:
1618 code = InsetBase::OPTARG_CODE;
1619 enable = numberOfOptArgs(cur.paragraph())
1620 < cur.paragraph().layout()->optionalargs;
1622 case LFUN_ENVIRONMENT_INSERT:
1623 code = InsetBase::BOX_CODE;
1625 case LFUN_INDEX_INSERT:
1626 code = InsetBase::INDEX_CODE;
1628 case LFUN_INDEX_PRINT:
1629 code = InsetBase::INDEX_PRINT_CODE;
1631 case LFUN_TOC_INSERT:
1632 code = InsetBase::TOC_CODE;
1634 case LFUN_HTML_INSERT:
1635 case LFUN_URL_INSERT:
1636 code = InsetBase::URL_CODE;
1638 case LFUN_QUOTE_INSERT:
1639 // always allow this, since we will inset a raw quote
1640 // if an inset is not allowed.
1642 case LFUN_HYPHENATION_POINT_INSERT:
1643 case LFUN_LIGATURE_BREAK_INSERT:
1644 case LFUN_HFILL_INSERT:
1645 case LFUN_MENU_SEPARATOR_INSERT:
1646 case LFUN_DOTS_INSERT:
1647 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
1648 code = InsetBase::SPECIALCHAR_CODE;
1650 case LFUN_SPACE_INSERT:
1651 // slight hack: we know this is allowed in math mode
1653 code = InsetBase::SPACE_CODE;
1656 case LFUN_INSET_MODIFY:
1657 // We need to disable this, because we may get called for a
1659 // InsetTabular::getStatus() -> InsetText::getStatus()
1660 // and we don't handle LFUN_INSET_MODIFY.
1664 case LFUN_FONT_EMPH:
1665 flag.setOnOff(font.emph() == LyXFont::ON);
1668 case LFUN_FONT_NOUN:
1669 flag.setOnOff(font.noun() == LyXFont::ON);
1672 case LFUN_FONT_BOLD:
1673 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
1676 case LFUN_FONT_SANS:
1677 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
1680 case LFUN_FONT_ROMAN:
1681 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
1684 case LFUN_FONT_CODE:
1685 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
1690 enable = cur.selection();
1694 enable = cap::numberOfSelections() > 0;
1697 case LFUN_PARAGRAPH_MOVE_UP:
1698 enable = cur.pit() > 0 && !cur.selection();
1701 case LFUN_PARAGRAPH_MOVE_DOWN:
1702 enable = cur.pit() < cur.lastpit() && !cur.selection();
1705 case LFUN_INSET_DISSOLVE:
1706 enable = !isMainText() && cur.inset().nargs() == 1;
1709 case LFUN_CHANGE_ACCEPT:
1710 case LFUN_CHANGE_REJECT:
1711 enable = true; // FIXME: Change tracking (MG)
1714 case LFUN_WORD_DELETE_FORWARD:
1715 case LFUN_WORD_DELETE_BACKWARD:
1716 case LFUN_LINE_DELETE:
1717 case LFUN_WORD_FORWARD:
1718 case LFUN_WORD_BACKWARD:
1719 case LFUN_CHAR_FORWARD:
1720 case LFUN_CHAR_FORWARD_SELECT:
1721 case LFUN_CHAR_BACKWARD:
1722 case LFUN_CHAR_BACKWARD_SELECT:
1724 case LFUN_UP_SELECT:
1726 case LFUN_DOWN_SELECT:
1727 case LFUN_PARAGRAPH_UP_SELECT:
1728 case LFUN_PARAGRAPH_DOWN_SELECT:
1729 case LFUN_SCREEN_UP_SELECT:
1730 case LFUN_SCREEN_DOWN_SELECT:
1731 case LFUN_LINE_BEGIN_SELECT:
1732 case LFUN_LINE_END_SELECT:
1733 case LFUN_WORD_FORWARD_SELECT:
1734 case LFUN_WORD_BACKWARD_SELECT:
1735 case LFUN_WORD_SELECT:
1736 case LFUN_PARAGRAPH_UP:
1737 case LFUN_PARAGRAPH_DOWN:
1738 case LFUN_SCREEN_UP:
1739 case LFUN_SCREEN_DOWN:
1740 case LFUN_LINE_BEGIN:
1742 case LFUN_BREAK_LINE:
1743 case LFUN_CHAR_DELETE_FORWARD:
1744 case LFUN_DELETE_FORWARD_SKIP:
1745 case LFUN_CHAR_DELETE_BACKWARD:
1746 case LFUN_DELETE_BACKWARD_SKIP:
1747 case LFUN_BREAK_PARAGRAPH:
1748 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
1749 case LFUN_BREAK_PARAGRAPH_SKIP:
1750 case LFUN_PARAGRAPH_SPACING:
1751 case LFUN_INSET_INSERT:
1752 case LFUN_WORD_UPCASE:
1753 case LFUN_WORD_LOWCASE:
1754 case LFUN_WORD_CAPITALIZE:
1755 case LFUN_CHARS_TRANSPOSE:
1756 case LFUN_SERVER_GET_XY:
1757 case LFUN_SERVER_SET_XY:
1758 case LFUN_SERVER_GET_FONT:
1759 case LFUN_SERVER_GET_LAYOUT:
1761 case LFUN_CLIPBOARD_PASTE:
1762 case LFUN_PRIMARY_SELECTION_PASTE:
1763 case LFUN_DATE_INSERT:
1764 case LFUN_SELF_INSERT:
1765 case LFUN_LINE_INSERT:
1766 case LFUN_PAGEBREAK_INSERT:
1767 case LFUN_MATH_DISPLAY:
1768 case LFUN_MATH_IMPORT_SELECTION:
1769 case LFUN_MATH_MODE:
1770 case LFUN_MATH_MACRO:
1771 case LFUN_MATH_MATRIX:
1772 case LFUN_MATH_DELIM:
1773 case LFUN_MATH_BIGDELIM:
1774 case LFUN_MATH_SUBSCRIPT:
1775 case LFUN_MATH_SUPERSCRIPT:
1776 case LFUN_FONT_DEFAULT:
1777 case LFUN_FONT_UNDERLINE:
1778 case LFUN_FONT_SIZE:
1780 case LFUN_FONT_FREE_APPLY:
1781 case LFUN_FONT_FREE_UPDATE:
1782 case LFUN_LAYOUT_PARAGRAPH:
1783 case LFUN_PARAGRAPH_UPDATE:
1784 case LFUN_ACCENT_UMLAUT:
1785 case LFUN_ACCENT_CIRCUMFLEX:
1786 case LFUN_ACCENT_GRAVE:
1787 case LFUN_ACCENT_ACUTE:
1788 case LFUN_ACCENT_TILDE:
1789 case LFUN_ACCENT_CEDILLA:
1790 case LFUN_ACCENT_MACRON:
1791 case LFUN_ACCENT_DOT:
1792 case LFUN_ACCENT_UNDERDOT:
1793 case LFUN_ACCENT_UNDERBAR:
1794 case LFUN_ACCENT_CARON:
1795 case LFUN_ACCENT_SPECIAL_CARON:
1796 case LFUN_ACCENT_BREVE:
1797 case LFUN_ACCENT_TIE:
1798 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1799 case LFUN_ACCENT_CIRCLE:
1800 case LFUN_ACCENT_OGONEK:
1801 case LFUN_THESAURUS_ENTRY:
1802 case LFUN_PARAGRAPH_PARAMS_APPLY:
1804 case LFUN_BUFFER_END:
1805 case LFUN_BUFFER_BEGIN:
1806 case LFUN_BUFFER_BEGIN_SELECT:
1807 case LFUN_BUFFER_END_SELECT:
1808 // these are handled in our dispatch()
1816 if (code != InsetBase::NO_CODE
1817 && (cur.empty() || !cur.inset().insetAllowed(code)))
1820 flag.enabled(enable);