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 docstring sel = 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 if (sel.find(from_ascii("\\newcommand")) == string::npos
166 && sel.find(from_ascii("\\def")) == string::npos)
168 InsetMathHull * formula = new InsetMathHull;
169 istringstream is(to_utf8(sel));
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(sel));
182 cur.message(from_utf8(N_("Math editor mode")));
191 string const freefont2string()
194 if (font2string(freefont, toggleall, data))
201 bool LyXText::cursorPrevious(LCursor & cur)
203 pos_type cpos = cur.pos();
204 pit_type cpar = cur.pit();
206 int x = cur.x_target();
208 bool updated = setCursorFromCoordinates(cur, x, 0);
211 updated |= cursorUp(cur);
213 if (cpar == cur.pit() && cpos == cur.pos()) {
214 // we have a row which is taller than the workarea. The
215 // simplest solution is to move to the previous row instead.
216 updated |= cursorUp(cur);
224 bool LyXText::cursorNext(LCursor & cur)
226 pos_type cpos = cur.pos();
227 pit_type cpar = cur.pit();
229 int x = cur.x_target();
230 bool updated = setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1);
233 updated |= cursorDown(cur);
235 if (cpar == cur.pit() && cpos == cur.pos()) {
236 // we have a row which is taller than the workarea. The
237 // simplest solution is to move to the next row instead.
238 updated |= cursorDown(cur);
248 void specialChar(LCursor & cur, InsetSpecialChar::Kind kind)
250 cap::replaceSelection(cur);
251 cur.insert(new InsetSpecialChar(kind));
256 bool doInsertInset(LCursor & cur, LyXText * text,
257 FuncRequest const & cmd, bool edit, bool pastesel)
259 InsetBase * inset = createInset(&cur.bv(), cmd);
265 if (cur.selection()) {
266 lyx::dispatch(FuncRequest(LFUN_CUT));
269 text->insertInset(cur, inset);
272 inset->edit(cur, true);
274 if (gotsel && pastesel) {
275 lyx::dispatch(FuncRequest(LFUN_PASTE));
276 // reset first par to default
277 if (cur.lastpit() != 0 || cur.lastpos() != 0) {
278 LyXLayout_ptr const layout =
279 cur.buffer().params().getLyXTextClass().defaultLayout();
280 cur.text()->paragraphs().begin()->layout(layout);
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_BUFFER_BEGIN:
399 case LFUN_BUFFER_BEGIN_SELECT:
400 needsUpdate |= cur.selHandle(cmd.action == LFUN_BUFFER_BEGIN_SELECT);
401 if (cur.depth() == 1) {
402 needsUpdate |= cursorTop(cur);
408 case LFUN_BUFFER_END:
409 case LFUN_BUFFER_END_SELECT:
410 needsUpdate |= cur.selHandle(cmd.action == LFUN_BUFFER_END_SELECT);
411 if (cur.depth() == 1) {
412 needsUpdate |= cursorBottom(cur);
418 case LFUN_CHAR_FORWARD:
419 case LFUN_CHAR_FORWARD_SELECT:
420 //lyxerr << BOOST_CURRENT_FUNCTION
421 // << " LFUN_CHAR_FORWARD[SEL]:\n" << cur << endl;
422 needsUpdate |= cur.selHandle(cmd.action == LFUN_CHAR_FORWARD_SELECT);
423 if (isRTL(cur.paragraph()))
424 needsUpdate |= cursorLeft(cur);
426 needsUpdate |= cursorRight(cur);
428 if (!needsUpdate && oldTopSlice == cur.top()
429 && cur.boundary() == oldBoundary) {
431 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
435 case LFUN_CHAR_BACKWARD:
436 case LFUN_CHAR_BACKWARD_SELECT:
437 //lyxerr << "handle LFUN_CHAR_BACKWARD[_SELECT]:\n" << cur << endl;
438 needsUpdate |= cur.selHandle(cmd.action == LFUN_CHAR_BACKWARD_SELECT);
439 if (isRTL(cur.paragraph()))
440 needsUpdate |= cursorRight(cur);
442 needsUpdate |= cursorLeft(cur);
444 if (!needsUpdate && oldTopSlice == cur.top()
445 && cur.boundary() == oldBoundary) {
447 cmd = FuncRequest(LFUN_FINISHED_LEFT);
453 //lyxerr << "handle LFUN_UP[SEL]:\n" << cur << endl;
454 needsUpdate |= cur.selHandle(cmd.action == LFUN_UP_SELECT);
456 needsUpdate |= cursorUp(cur);
458 if (!needsUpdate && oldTopSlice == cur.top()
459 && cur.boundary() == oldBoundary) {
461 cmd = FuncRequest(LFUN_FINISHED_UP);
466 case LFUN_DOWN_SELECT:
467 //lyxerr << "handle LFUN_DOWN[SEL]:\n" << cur << endl;
468 needsUpdate |= cur.selHandle(cmd.action == LFUN_DOWN_SELECT);
469 needsUpdate |= cursorDown(cur);
471 if (!needsUpdate && oldTopSlice == cur.top() &&
472 cur.boundary() == oldBoundary)
475 cmd = FuncRequest(LFUN_FINISHED_DOWN);
479 case LFUN_PARAGRAPH_UP:
480 case LFUN_PARAGRAPH_UP_SELECT:
481 needsUpdate |= cur.selHandle(cmd.action == LFUN_PARAGRAPH_UP_SELECT);
482 needsUpdate |= cursorUpParagraph(cur);
485 case LFUN_PARAGRAPH_DOWN:
486 case LFUN_PARAGRAPH_DOWN_SELECT:
487 needsUpdate |= cur.selHandle(cmd.action == LFUN_PARAGRAPH_DOWN_SELECT);
488 needsUpdate |= cursorDownParagraph(cur);
492 case LFUN_SCREEN_UP_SELECT:
493 needsUpdate |= cur.selHandle(cmd.action == LFUN_SCREEN_UP_SELECT);
494 if (cur.pit() == 0 && cur.textRow().pos() == 0) {
496 cmd = FuncRequest(LFUN_FINISHED_UP);
498 needsUpdate |= cursorPrevious(cur);
502 case LFUN_SCREEN_DOWN:
503 case LFUN_SCREEN_DOWN_SELECT:
504 needsUpdate |= cur.selHandle(cmd.action == LFUN_SCREEN_DOWN_SELECT);
505 if (cur.pit() == cur.lastpit()
506 && cur.textRow().endpos() == cur.lastpos()) {
508 cmd = FuncRequest(LFUN_FINISHED_DOWN);
510 needsUpdate |= cursorNext(cur);
514 case LFUN_LINE_BEGIN:
515 case LFUN_LINE_BEGIN_SELECT:
516 needsUpdate |= cur.selHandle(cmd.action == LFUN_LINE_BEGIN_SELECT);
517 needsUpdate |= cursorHome(cur);
521 case LFUN_LINE_END_SELECT:
522 needsUpdate |= cur.selHandle(cmd.action == LFUN_LINE_END_SELECT);
523 needsUpdate |= cursorEnd(cur);
526 case LFUN_WORD_FORWARD:
527 case LFUN_WORD_FORWARD_SELECT:
528 needsUpdate |= cur.selHandle(cmd.action == LFUN_WORD_FORWARD_SELECT);
529 if (isRTL(cur.paragraph()))
530 needsUpdate |= cursorLeftOneWord(cur);
532 needsUpdate |= cursorRightOneWord(cur);
535 case LFUN_WORD_BACKWARD:
536 case LFUN_WORD_BACKWARD_SELECT:
537 needsUpdate |= cur.selHandle(cmd.action == LFUN_WORD_BACKWARD_SELECT);
538 if (isRTL(cur.paragraph()))
539 needsUpdate |= cursorRightOneWord(cur);
541 needsUpdate |= cursorLeftOneWord(cur);
544 case LFUN_WORD_SELECT: {
545 selectWord(cur, WHOLE_WORD);
546 finishChange(cur, true);
550 case LFUN_BREAK_LINE: {
551 // Not allowed by LaTeX (labels or empty par)
552 if (cur.pos() > cur.paragraph().beginOfBody()) {
553 cap::replaceSelection(cur);
554 cur.insert(new InsetNewline);
556 moveCursor(cur, false);
561 case LFUN_CHAR_DELETE_FORWARD:
562 if (!cur.selection()) {
563 if (cur.pos() == cur.paragraph().size())
564 // Par boundary, force full-screen update
565 singleParUpdate = false;
566 needsUpdate |= erase(cur);
568 // It is possible to make it a lot faster still
569 // just comment out the line below...
571 cutSelection(cur, true, false);
572 singleParUpdate = false;
574 moveCursor(cur, false);
577 case LFUN_DELETE_FORWARD_SKIP:
578 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
579 if (!cur.selection()) {
580 if (cur.pos() == cur.lastpos()) {
587 cutSelection(cur, true, false);
592 case LFUN_CHAR_DELETE_BACKWARD:
593 if (!cur.selection()) {
594 if (bv->getIntl().getTransManager().backspace()) {
595 // Par boundary, full-screen update
597 singleParUpdate = false;
598 needsUpdate |= backspace(cur);
600 // It is possible to make it a lot faster still
601 // just comment out the line below...
604 cutSelection(cur, true, false);
605 singleParUpdate = false;
610 case LFUN_DELETE_BACKWARD_SKIP:
611 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
612 if (!cur.selection()) {
616 //CursorSlice cur = cursor();
620 cutSelection(cur, true, false);
624 case LFUN_BREAK_PARAGRAPH:
625 cap::replaceSelection(cur);
626 breakParagraph(cur, 0);
631 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
632 cap::replaceSelection(cur);
633 breakParagraph(cur, 1);
638 case LFUN_BREAK_PARAGRAPH_SKIP: {
639 // When at the beginning of a paragraph, remove
640 // indentation. Otherwise, do the same as LFUN_BREAK_PARAGRAPH.
641 cap::replaceSelection(cur);
643 cur.paragraph().params().labelWidthString(docstring());
645 breakParagraph(cur, 0);
651 case LFUN_PARAGRAPH_SPACING: {
652 Paragraph & par = cur.paragraph();
653 Spacing::Space cur_spacing = par.params().spacing().getSpace();
654 string cur_value = "1.0";
655 if (cur_spacing == Spacing::Other)
656 cur_value = par.params().spacing().getValueAsString();
658 istringstream is(to_utf8(cmd.argument()));
661 Spacing::Space new_spacing = cur_spacing;
662 string new_value = cur_value;
664 lyxerr << "Missing argument to `paragraph-spacing'"
666 } else if (tmp == "single") {
667 new_spacing = Spacing::Single;
668 } else if (tmp == "onehalf") {
669 new_spacing = Spacing::Onehalf;
670 } else if (tmp == "double") {
671 new_spacing = Spacing::Double;
672 } else if (tmp == "other") {
673 new_spacing = Spacing::Other;
674 string tmpval = "0.0";
676 lyxerr << "new_value = " << tmpval << endl;
679 } else if (tmp == "default") {
680 new_spacing = Spacing::Default;
682 lyxerr << to_utf8(_("Unknown spacing argument: "))
683 << to_utf8(cmd.argument()) << endl;
685 if (cur_spacing != new_spacing || cur_value != new_value)
686 par.params().spacing(Spacing(new_spacing, new_value));
690 case LFUN_INSET_INSERT: {
692 InsetBase * inset = createInset(bv, cmd);
694 insertInset(cur, inset);
700 case LFUN_INSET_DISSOLVE:
701 needsUpdate |= dissolveInset(cur);
704 case LFUN_INSET_SETTINGS:
705 cur.inset().showInsetDialog(bv);
708 case LFUN_SPACE_INSERT:
709 if (cur.paragraph().layout()->free_spacing)
710 insertChar(cur, ' ');
712 doInsertInset(cur, this, cmd, false, false);
715 moveCursor(cur, false);
718 case LFUN_HYPHENATION_POINT_INSERT:
719 specialChar(cur, InsetSpecialChar::HYPHENATION);
722 case LFUN_LIGATURE_BREAK_INSERT:
723 specialChar(cur, InsetSpecialChar::LIGATURE_BREAK);
726 case LFUN_DOTS_INSERT:
727 specialChar(cur, InsetSpecialChar::LDOTS);
730 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
731 specialChar(cur, InsetSpecialChar::END_OF_SENTENCE);
734 case LFUN_MENU_SEPARATOR_INSERT:
735 specialChar(cur, InsetSpecialChar::MENU_SEPARATOR);
738 case LFUN_WORD_UPCASE:
739 changeCase(cur, LyXText::text_uppercase);
742 case LFUN_WORD_LOWCASE:
743 changeCase(cur, LyXText::text_lowercase);
746 case LFUN_WORD_CAPITALIZE:
747 changeCase(cur, LyXText::text_capitalization);
750 case LFUN_CHARS_TRANSPOSE:
755 cur.message(_("Paste"));
756 cap::replaceSelection(cur);
757 if (isStrUnsignedInt(to_utf8(cmd.argument())))
758 pasteSelection(cur, bv->buffer()->errorList("Paste"),
759 convert<unsigned int>(to_utf8(cmd.argument())));
761 pasteSelection(cur, bv->buffer()->errorList("Paste"),
763 bv->buffer()->errors("Paste");
764 cur.clearSelection(); // bug 393
770 cutSelection(cur, true, true);
771 cur.message(_("Cut"));
776 cur.message(_("Copy"));
779 case LFUN_SERVER_GET_XY:
780 cur.message(from_utf8(
781 convert<string>(cursorX(cur.top(), cur.boundary())) + ' '
782 + convert<string>(cursorY(cur.top(), cur.boundary()))));
785 case LFUN_SERVER_SET_XY: {
788 istringstream is(to_utf8(cmd.argument()));
791 lyxerr << "SETXY: Could not parse coordinates in '"
792 << to_utf8(cmd.argument()) << std::endl;
794 setCursorFromCoordinates(cur, x, y);
798 case LFUN_SERVER_GET_FONT:
799 if (current_font.shape() == LyXFont::ITALIC_SHAPE)
800 cur.message(from_ascii("E"));
801 else if (current_font.shape() == LyXFont::SMALLCAPS_SHAPE)
802 cur.message(from_ascii("N"));
804 cur.message(from_ascii("0"));
807 case LFUN_SERVER_GET_LAYOUT:
808 cur.message(from_utf8(cur.paragraph().layout()->name()));
812 lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) "
813 << to_utf8(cmd.argument()) << endl;
815 // This is not the good solution to the empty argument
816 // problem, but it will hopefully suffice for 1.2.0.
817 // The correct solution would be to augument the
818 // function list/array with information about what
819 // functions needs arguments and their type.
820 if (cmd.argument().empty()) {
821 cur.errorMessage(_("LyX function 'layout' needs an argument."));
825 // Derive layout number from given argument (string)
826 // and current buffer's textclass (number)
827 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
828 bool hasLayout = tclass.hasLayout(to_utf8(cmd.argument()));
829 string layout = to_utf8(cmd.argument());
831 // If the entry is obsolete, use the new one instead.
833 string const & obs = tclass[layout]->obsoleted_by();
839 cur.errorMessage(from_utf8(N_("Layout ")) + cmd.argument() +
840 from_utf8(N_(" not known")));
844 bool change_layout = (current_layout != layout);
846 if (!change_layout && cur.selection() &&
847 cur.selBegin().pit() != cur.selEnd().pit())
849 pit_type spit = cur.selBegin().pit();
850 pit_type epit = cur.selEnd().pit() + 1;
851 while (spit != epit) {
852 if (pars_[spit].layout()->name() != current_layout) {
853 change_layout = true;
861 current_layout = layout;
862 setLayout(cur, layout);
863 // inform the GUI that the layout has changed.
864 bv->layoutChanged(layout);
870 case LFUN_CLIPBOARD_PASTE: {
871 cur.clearSelection();
872 docstring const clip = theClipboard().get();
875 if (cmd.argument() == "paragraph")
876 insertStringAsParagraphs(cur, clip);
878 insertStringAsLines(cur, clip);
883 case LFUN_PRIMARY_SELECTION_PASTE: {
884 cur.clearSelection();
885 docstring const clip = theSelection().get();
888 if (cmd.argument() == "paragraph")
889 insertStringAsParagraphs(cur, clip);
891 insertStringAsLines(cur, clip);
896 case LFUN_QUOTE_INSERT: {
897 cap::replaceSelection(cur);
898 Paragraph & par = cur.paragraph();
899 pos_type pos = cur.pos();
903 else if (cur.prevInset() && cur.prevInset()->isSpace())
906 c = par.getChar(pos - 1);
908 LyXLayout_ptr const & style = par.layout();
910 BufferParams const & bufparams = bv->buffer()->params();
911 if (!style->pass_thru
912 && par.getFontSettings(bufparams, pos).language()->lang() != "hebrew") {
913 string arg = to_utf8(cmd.argument());
915 cur.insert(new InsetQuotes(c,
916 bufparams.quotes_language,
917 InsetQuotes::SingleQ));
919 cur.insert(new InsetQuotes(c,
920 bufparams.quotes_language,
921 InsetQuotes::DoubleQ));
925 lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, "\""));
929 case LFUN_DATE_INSERT:
930 if (cmd.argument().empty())
931 lyx::dispatch(FuncRequest(LFUN_SELF_INSERT,
932 formatted_time(current_time())));
934 lyx::dispatch(FuncRequest(LFUN_SELF_INSERT,
935 formatted_time(current_time(), to_utf8(cmd.argument()))));
938 case LFUN_MOUSE_TRIPLE:
939 if (cmd.button() == mouse_button::button1) {
945 theSelection().haveSelection(cur.selection());
949 case LFUN_MOUSE_DOUBLE:
950 if (cmd.button() == mouse_button::button1) {
951 selectWord(cur, WHOLE_WORD_STRICT);
953 theSelection().haveSelection(cur.selection());
957 // Single-click on work area
958 case LFUN_MOUSE_PRESS: {
959 // Right click on a footnote flag opens float menu
960 if (cmd.button() == mouse_button::button3)
961 cur.clearSelection();
963 // Middle button press pastes if we have a selection
964 // We do this here as if the selection was inside an inset
965 // it could get cleared on the unlocking of the inset so
966 // we have to check this first
967 bool paste_internally = false;
968 if (cmd.button() == mouse_button::button2 && cur.selection()) {
969 lyx::dispatch(FuncRequest(LFUN_COPY));
970 paste_internally = true;
973 bv->mouseSetCursor(cur);
975 // Insert primary selection with middle mouse
976 // if there is a local selection in the current buffer,
978 if (cmd.button() == mouse_button::button2) {
979 if (paste_internally)
980 lyx::dispatch(FuncRequest(LFUN_PASTE));
982 lyx::dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph"));
988 case LFUN_MOUSE_MOTION: {
989 // Only use motion with button 1
990 //if (cmd.button() != mouse_button::button1)
993 // ignore motions deeper nested than the real anchor
994 LCursor & bvcur = cur.bv().cursor();
995 if (bvcur.anchor_.hasPart(cur)) {
996 CursorSlice old = bvcur.top();
998 int const wh = bv->workHeight();
999 int const y = std::max(0, std::min(wh - 1, cmd.y));
1001 setCursorFromCoordinates(cur, cmd.x, y);
1002 cur.x_target() = cmd.x;
1007 // This is to allow jumping over large insets
1008 if (cur.top() == old) {
1015 if (cur.top() == old)
1018 // don't set anchor_
1019 bvcur.setCursor(cur);
1020 bvcur.selection() = true;
1021 //lyxerr << "MOTION: " << bv->cursor() << endl;
1029 case LFUN_MOUSE_RELEASE: {
1030 if (cmd.button() == mouse_button::button2)
1034 if (cmd.button() == mouse_button::button1)
1035 theSelection().haveSelection(cur.selection());
1041 case LFUN_SELF_INSERT: {
1042 if (cmd.argument().empty())
1045 // Automatically delete the currently selected
1046 // text and replace it with what is being
1047 // typed in now. Depends on lyxrc settings
1048 // "auto_region_delete", which defaults to
1051 if (lyxrc.auto_region_delete) {
1052 if (cur.selection())
1053 cutSelection(cur, false, false);
1054 theSelection().haveSelection(false);
1057 cur.clearSelection();
1058 LyXFont const old_font = real_current_font;
1060 docstring::const_iterator cit = cmd.argument().begin();
1061 docstring::const_iterator end = cmd.argument().end();
1062 for (; cit != end; ++cit)
1064 bv->getIntl().getTransManager().
1065 translateAndInsert(*cit, this);
1067 insertChar(bv->cursor(), *cit);
1071 moveCursor(cur, false);
1075 case LFUN_URL_INSERT: {
1076 InsetCommandParams p("url");
1077 string const data = InsetCommandMailer::params2string("url", p);
1078 bv->showInsetDialog("url", data, 0);
1082 case LFUN_HTML_INSERT: {
1083 InsetCommandParams p("htmlurl");
1084 string const data = InsetCommandMailer::params2string("url", p);
1085 bv->showInsetDialog("url", data, 0);
1089 case LFUN_LABEL_INSERT: {
1090 InsetCommandParams p("label");
1091 // Try to generate a valid label
1092 p["name"] = (cmd.argument().empty()) ?
1094 from_utf8(cur.getPossibleLabel()) :
1096 string const data = InsetCommandMailer::params2string("label", p);
1098 if (cmd.argument().empty()) {
1099 bv->showInsetDialog("label", data, 0);
1101 FuncRequest fr(LFUN_INSET_INSERT, data);
1109 case LFUN_LIST_INSERT:
1110 case LFUN_THEOREM_INSERT:
1111 case LFUN_CAPTION_INSERT:
1113 case LFUN_NOTE_INSERT:
1114 case LFUN_CHARSTYLE_INSERT:
1115 case LFUN_BOX_INSERT:
1116 case LFUN_BRANCH_INSERT:
1117 case LFUN_BIBITEM_INSERT:
1118 case LFUN_ERT_INSERT:
1119 case LFUN_FOOTNOTE_INSERT:
1120 case LFUN_MARGINALNOTE_INSERT:
1121 case LFUN_OPTIONAL_INSERT:
1122 case LFUN_ENVIRONMENT_INSERT:
1123 // Open the inset, and move the current selection
1125 doInsertInset(cur, this, cmd, true, true);
1129 case LFUN_TABULAR_INSERT:
1130 // if there were no arguments, just open the dialog
1131 if (doInsertInset(cur, this, cmd, false, true))
1134 bv->showDialog("tabularcreate");
1138 case LFUN_FLOAT_INSERT:
1139 case LFUN_FLOAT_WIDE_INSERT:
1140 case LFUN_WRAP_INSERT:
1141 doInsertInset(cur, this, cmd, true, true);
1143 // FIXME: the "Caption" name should not be hardcoded,
1144 // but given by the float definition.
1145 cur.dispatch(FuncRequest(LFUN_LAYOUT, "Caption"));
1148 case LFUN_INDEX_INSERT: {
1149 InsetBase * inset = createInset(&cur.bv(), cmd);
1154 cur.clearSelection();
1155 insertInset(cur, inset);
1156 inset->edit(cur, true);
1161 case LFUN_INDEX_PRINT:
1162 case LFUN_TOC_INSERT:
1163 case LFUN_HFILL_INSERT:
1164 case LFUN_LINE_INSERT:
1165 case LFUN_PAGEBREAK_INSERT:
1167 doInsertInset(cur, this, cmd, false, false);
1171 case LFUN_DEPTH_DECREMENT:
1172 changeDepth(cur, DEC_DEPTH);
1175 case LFUN_DEPTH_INCREMENT:
1176 changeDepth(cur, INC_DEPTH);
1179 case LFUN_MATH_DISPLAY:
1180 mathDispatch(cur, cmd, true);
1183 case LFUN_MATH_IMPORT_SELECTION:
1184 case LFUN_MATH_MODE:
1185 if (cmd.argument() == "on")
1186 // don't pass "on" as argument
1187 mathDispatch(cur, FuncRequest(LFUN_MATH_MODE), false);
1189 mathDispatch(cur, cmd, false);
1192 case LFUN_MATH_MACRO:
1193 if (cmd.argument().empty())
1194 cur.errorMessage(from_utf8(N_("Missing argument")));
1196 string s = to_utf8(cmd.argument());
1197 string const s1 = token(s, ' ', 1);
1198 int const nargs = s1.empty() ? 0 : convert<int>(s1);
1199 string const s2 = token(s, ' ', 2);
1200 string const type = s2.empty() ? "newcommand" : s2;
1201 cur.insert(new MathMacroTemplate(from_utf8(token(s, ' ', 0)), nargs, from_utf8(type)));
1202 //cur.nextInset()->edit(cur, true);
1206 // passthrough hat and underscore outside mathed:
1207 case LFUN_MATH_SUBSCRIPT:
1208 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "_"), false);
1210 case LFUN_MATH_SUPERSCRIPT:
1211 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "^"), false);
1214 case LFUN_MATH_INSERT:
1215 case LFUN_MATH_MATRIX:
1216 case LFUN_MATH_DELIM:
1217 case LFUN_MATH_BIGDELIM: {
1218 cur.insert(new InsetMathHull(hullSimple));
1219 cur.dispatch(FuncRequest(LFUN_CHAR_FORWARD));
1224 case LFUN_FONT_EMPH: {
1225 LyXFont font(LyXFont::ALL_IGNORE);
1226 font.setEmph(LyXFont::TOGGLE);
1227 toggleAndShow(cur, this, font);
1231 case LFUN_FONT_BOLD: {
1232 LyXFont font(LyXFont::ALL_IGNORE);
1233 font.setSeries(LyXFont::BOLD_SERIES);
1234 toggleAndShow(cur, this, font);
1238 case LFUN_FONT_NOUN: {
1239 LyXFont font(LyXFont::ALL_IGNORE);
1240 font.setNoun(LyXFont::TOGGLE);
1241 toggleAndShow(cur, this, font);
1245 case LFUN_FONT_CODE: {
1246 LyXFont font(LyXFont::ALL_IGNORE);
1247 font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
1248 toggleAndShow(cur, this, font);
1252 case LFUN_FONT_SANS: {
1253 LyXFont font(LyXFont::ALL_IGNORE);
1254 font.setFamily(LyXFont::SANS_FAMILY);
1255 toggleAndShow(cur, this, font);
1259 case LFUN_FONT_ROMAN: {
1260 LyXFont font(LyXFont::ALL_IGNORE);
1261 font.setFamily(LyXFont::ROMAN_FAMILY);
1262 toggleAndShow(cur, this, font);
1266 case LFUN_FONT_DEFAULT: {
1267 LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
1268 toggleAndShow(cur, this, font);
1272 case LFUN_FONT_UNDERLINE: {
1273 LyXFont font(LyXFont::ALL_IGNORE);
1274 font.setUnderbar(LyXFont::TOGGLE);
1275 toggleAndShow(cur, this, font);
1279 case LFUN_FONT_SIZE: {
1280 LyXFont font(LyXFont::ALL_IGNORE);
1281 font.setLyXSize(to_utf8(cmd.argument()));
1282 toggleAndShow(cur, this, font);
1286 case LFUN_LANGUAGE: {
1287 Language const * lang = languages.getLanguage(to_utf8(cmd.argument()));
1290 LyXFont font(LyXFont::ALL_IGNORE);
1291 font.setLanguage(lang);
1292 toggleAndShow(cur, this, font);
1297 case LFUN_FONT_FREE_APPLY:
1298 toggleAndShow(cur, this, freefont, toggleall);
1299 cur.message(_("Character set"));
1302 // Set the freefont using the contents of \param data dispatched from
1303 // the frontends and apply it at the current cursor location.
1304 case LFUN_FONT_FREE_UPDATE: {
1307 if (bv_funcs::string2font(to_utf8(cmd.argument()), font, toggle)) {
1310 toggleAndShow(cur, this, freefont, toggleall);
1311 cur.message(_("Character set"));
1316 case LFUN_FINISHED_LEFT:
1317 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_LEFT:\n" << cur << endl;
1320 case LFUN_FINISHED_RIGHT:
1321 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_RIGHT:\n" << cur << endl;
1325 case LFUN_FINISHED_UP:
1326 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_UP:\n" << cur << endl;
1330 case LFUN_FINISHED_DOWN:
1331 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_DOWN:\n" << cur << endl;
1335 case LFUN_LAYOUT_PARAGRAPH: {
1337 params2string(cur.paragraph(), data);
1338 data = "show\n" + data;
1339 bv->showDialogWithData("paragraph", data);
1343 case LFUN_PARAGRAPH_UPDATE: {
1345 params2string(cur.paragraph(), data);
1347 // Will the paragraph accept changes from the dialog?
1348 bool const accept = !cur.inset().forceDefaultParagraphs(cur.idx());
1350 data = "update " + convert<string>(accept) + '\n' + data;
1351 bv->updateDialog("paragraph", data);
1355 case LFUN_ACCENT_UMLAUT:
1356 case LFUN_ACCENT_CIRCUMFLEX:
1357 case LFUN_ACCENT_GRAVE:
1358 case LFUN_ACCENT_ACUTE:
1359 case LFUN_ACCENT_TILDE:
1360 case LFUN_ACCENT_CEDILLA:
1361 case LFUN_ACCENT_MACRON:
1362 case LFUN_ACCENT_DOT:
1363 case LFUN_ACCENT_UNDERDOT:
1364 case LFUN_ACCENT_UNDERBAR:
1365 case LFUN_ACCENT_CARON:
1366 case LFUN_ACCENT_SPECIAL_CARON:
1367 case LFUN_ACCENT_BREVE:
1368 case LFUN_ACCENT_TIE:
1369 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1370 case LFUN_ACCENT_CIRCLE:
1371 case LFUN_ACCENT_OGONEK:
1372 theLyXFunc().handleKeyFunc(cmd.action);
1373 if (!cmd.argument().empty())
1374 // FIXME: Are all these characters encoded in one byte in utf8?
1375 bv->getIntl().getTransManager()
1376 .translateAndInsert(cmd.argument()[0], this);
1379 case LFUN_FLOAT_LIST: {
1380 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
1381 if (tclass.floats().typeExist(to_utf8(cmd.argument()))) {
1382 // not quite sure if we want this...
1384 cur.clearSelection();
1385 breakParagraph(cur);
1387 if (cur.lastpos() != 0) {
1389 breakParagraph(cur);
1392 setLayout(cur, tclass.defaultLayoutName());
1393 setParagraph(cur, Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
1394 insertInset(cur, new InsetFloatList(to_utf8(cmd.argument())));
1397 lyxerr << "Non-existent float type: "
1398 << to_utf8(cmd.argument()) << endl;
1403 case LFUN_CHANGE_ACCEPT: {
1408 case LFUN_CHANGE_REJECT: {
1413 case LFUN_THESAURUS_ENTRY: {
1414 docstring arg = cmd.argument();
1416 arg = cur.selectionAsString(false);
1418 if (arg.size() > 100 || arg.empty()) {
1419 // Get word or selection
1420 selectWordWhenUnderCursor(cur, WHOLE_WORD);
1421 arg = cur.selectionAsString(false);
1424 bv->showDialogWithData("thesaurus", to_utf8(arg));
1428 case LFUN_PARAGRAPH_PARAMS_APPLY: {
1429 // Given data, an encoding of the ParagraphParameters
1430 // generated in the Paragraph dialog, this function sets
1431 // the current paragraph appropriately.
1432 istringstream is(to_utf8(cmd.argument()));
1435 ParagraphParameters params;
1441 to_ascii(params.labelWidthString()),
1443 cur.message(_("Paragraph layout set"));
1448 if (cur.selection()) {
1449 cur.selection() = false;
1452 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
1457 lyxerr[Debug::ACTION]
1458 << BOOST_CURRENT_FUNCTION
1459 << ": Command " << cmd
1460 << " not DISPATCHED by LyXText" << endl;
1465 needsUpdate |= (cur.pos() != cur.lastpos()) && cur.selection();
1466 if (singleParUpdate)
1467 // Inserting characters does not change par height
1468 if (cur.bottom().paragraph().dim().height()
1469 == olddim.height()) {
1470 // if so, update _only_ this paragraph
1471 cur.updateFlags(Update::SinglePar |
1473 Update::MultiParSel);
1478 && &oldTopSlice.inset() == &cur.inset()
1479 && oldTopSlice.idx() == cur.idx()
1481 && !cur.selection())
1484 cur.updateFlags(Update::Force | Update::FitCursor);
1488 bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
1489 FuncStatus & flag) const
1491 BOOST_ASSERT(cur.text() == this);
1493 LyXFont const & font = real_current_font;
1495 InsetBase::Code code = InsetBase::NO_CODE;
1497 switch (cmd.action) {
1499 case LFUN_DEPTH_DECREMENT:
1500 enable = changeDepthAllowed(cur, DEC_DEPTH);
1503 case LFUN_DEPTH_INCREMENT:
1504 enable = changeDepthAllowed(cur, INC_DEPTH);
1508 flag.setOnOff(cur.paragraph().params().startOfAppendix());
1511 case LFUN_BIBITEM_INSERT:
1512 enable = (cur.paragraph().layout()->labeltype == LABEL_BIBLIO);
1515 case LFUN_DIALOG_SHOW_NEW_INSET:
1516 if (cmd.argument() == "bibitem")
1517 code = InsetBase::BIBITEM_CODE;
1518 else if (cmd.argument() == "bibtex")
1519 code = InsetBase::BIBTEX_CODE;
1520 else if (cmd.argument() == "box")
1521 code = InsetBase::BOX_CODE;
1522 else if (cmd.argument() == "branch")
1523 code = InsetBase::BRANCH_CODE;
1524 else if (cmd.argument() == "citation")
1525 code = InsetBase::CITE_CODE;
1526 else if (cmd.argument() == "ert")
1527 code = InsetBase::ERT_CODE;
1528 else if (cmd.argument() == "external")
1529 code = InsetBase::EXTERNAL_CODE;
1530 else if (cmd.argument() == "float")
1531 code = InsetBase::FLOAT_CODE;
1532 else if (cmd.argument() == "graphics")
1533 code = InsetBase::GRAPHICS_CODE;
1534 else if (cmd.argument() == "include")
1535 code = InsetBase::INCLUDE_CODE;
1536 else if (cmd.argument() == "index")
1537 code = InsetBase::INDEX_CODE;
1538 else if (cmd.argument() == "label")
1539 code = InsetBase::LABEL_CODE;
1540 else if (cmd.argument() == "note")
1541 code = InsetBase::NOTE_CODE;
1542 else if (cmd.argument() == "ref")
1543 code = InsetBase::REF_CODE;
1544 else if (cmd.argument() == "toc")
1545 code = InsetBase::TOC_CODE;
1546 else if (cmd.argument() == "url")
1547 code = InsetBase::URL_CODE;
1548 else if (cmd.argument() == "vspace")
1549 code = InsetBase::VSPACE_CODE;
1550 else if (cmd.argument() == "wrap")
1551 code = InsetBase::WRAP_CODE;
1554 case LFUN_ERT_INSERT:
1555 code = InsetBase::ERT_CODE;
1557 case LFUN_FOOTNOTE_INSERT:
1558 code = InsetBase::FOOT_CODE;
1560 case LFUN_TABULAR_INSERT:
1561 code = InsetBase::TABULAR_CODE;
1563 case LFUN_MARGINALNOTE_INSERT:
1564 code = InsetBase::MARGIN_CODE;
1566 case LFUN_FLOAT_INSERT:
1567 case LFUN_FLOAT_WIDE_INSERT:
1568 code = InsetBase::FLOAT_CODE;
1570 case LFUN_WRAP_INSERT:
1571 code = InsetBase::WRAP_CODE;
1573 case LFUN_FLOAT_LIST:
1574 code = InsetBase::FLOAT_LIST_CODE;
1577 case LFUN_LIST_INSERT:
1578 code = InsetBase::LIST_CODE;
1580 case LFUN_THEOREM_INSERT:
1581 code = InsetBase::THEOREM_CODE;
1584 case LFUN_CAPTION_INSERT:
1585 code = InsetBase::CAPTION_CODE;
1587 case LFUN_NOTE_INSERT:
1588 code = InsetBase::NOTE_CODE;
1590 case LFUN_CHARSTYLE_INSERT:
1591 code = InsetBase::CHARSTYLE_CODE;
1592 if (cur.buffer().params().getLyXTextClass().charstyles().empty())
1595 case LFUN_BOX_INSERT:
1596 code = InsetBase::BOX_CODE;
1598 case LFUN_BRANCH_INSERT:
1599 code = InsetBase::BRANCH_CODE;
1600 if (cur.buffer().getMasterBuffer()->params().branchlist().empty())
1603 case LFUN_LABEL_INSERT:
1604 code = InsetBase::LABEL_CODE;
1606 case LFUN_OPTIONAL_INSERT:
1607 code = InsetBase::OPTARG_CODE;
1608 enable = numberOfOptArgs(cur.paragraph())
1609 < cur.paragraph().layout()->optionalargs;
1611 case LFUN_ENVIRONMENT_INSERT:
1612 code = InsetBase::BOX_CODE;
1614 case LFUN_INDEX_INSERT:
1615 code = InsetBase::INDEX_CODE;
1617 case LFUN_INDEX_PRINT:
1618 code = InsetBase::INDEX_PRINT_CODE;
1620 case LFUN_TOC_INSERT:
1621 code = InsetBase::TOC_CODE;
1623 case LFUN_HTML_INSERT:
1624 case LFUN_URL_INSERT:
1625 code = InsetBase::URL_CODE;
1627 case LFUN_QUOTE_INSERT:
1628 // always allow this, since we will inset a raw quote
1629 // if an inset is not allowed.
1631 case LFUN_HYPHENATION_POINT_INSERT:
1632 case LFUN_LIGATURE_BREAK_INSERT:
1633 case LFUN_HFILL_INSERT:
1634 case LFUN_MENU_SEPARATOR_INSERT:
1635 case LFUN_DOTS_INSERT:
1636 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
1637 code = InsetBase::SPECIALCHAR_CODE;
1639 case LFUN_SPACE_INSERT:
1640 // slight hack: we know this is allowed in math mode
1642 code = InsetBase::SPACE_CODE;
1645 case LFUN_INSET_MODIFY:
1646 // We need to disable this, because we may get called for a
1648 // InsetTabular::getStatus() -> InsetText::getStatus()
1649 // and we don't handle LFUN_INSET_MODIFY.
1653 case LFUN_FONT_EMPH:
1654 flag.setOnOff(font.emph() == LyXFont::ON);
1657 case LFUN_FONT_NOUN:
1658 flag.setOnOff(font.noun() == LyXFont::ON);
1661 case LFUN_FONT_BOLD:
1662 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
1665 case LFUN_FONT_SANS:
1666 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
1669 case LFUN_FONT_ROMAN:
1670 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
1673 case LFUN_FONT_CODE:
1674 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
1679 enable = cur.selection();
1683 enable = cap::numberOfSelections() > 0;
1686 case LFUN_PARAGRAPH_MOVE_UP:
1687 enable = cur.pit() > 0 && !cur.selection();
1690 case LFUN_PARAGRAPH_MOVE_DOWN:
1691 enable = cur.pit() < cur.lastpit() && !cur.selection();
1694 case LFUN_INSET_DISSOLVE:
1695 enable = !isMainText() && cur.inset().nargs() == 1;
1698 case LFUN_CHANGE_ACCEPT:
1699 case LFUN_CHANGE_REJECT:
1700 enable = true; // FIXME: Change tracking (MG)
1703 case LFUN_WORD_DELETE_FORWARD:
1704 case LFUN_WORD_DELETE_BACKWARD:
1705 case LFUN_LINE_DELETE:
1706 case LFUN_WORD_FORWARD:
1707 case LFUN_WORD_BACKWARD:
1708 case LFUN_CHAR_FORWARD:
1709 case LFUN_CHAR_FORWARD_SELECT:
1710 case LFUN_CHAR_BACKWARD:
1711 case LFUN_CHAR_BACKWARD_SELECT:
1713 case LFUN_UP_SELECT:
1715 case LFUN_DOWN_SELECT:
1716 case LFUN_PARAGRAPH_UP_SELECT:
1717 case LFUN_PARAGRAPH_DOWN_SELECT:
1718 case LFUN_SCREEN_UP_SELECT:
1719 case LFUN_SCREEN_DOWN_SELECT:
1720 case LFUN_LINE_BEGIN_SELECT:
1721 case LFUN_LINE_END_SELECT:
1722 case LFUN_WORD_FORWARD_SELECT:
1723 case LFUN_WORD_BACKWARD_SELECT:
1724 case LFUN_WORD_SELECT:
1725 case LFUN_PARAGRAPH_UP:
1726 case LFUN_PARAGRAPH_DOWN:
1727 case LFUN_SCREEN_UP:
1728 case LFUN_SCREEN_DOWN:
1729 case LFUN_LINE_BEGIN:
1731 case LFUN_BREAK_LINE:
1732 case LFUN_CHAR_DELETE_FORWARD:
1733 case LFUN_DELETE_FORWARD_SKIP:
1734 case LFUN_CHAR_DELETE_BACKWARD:
1735 case LFUN_DELETE_BACKWARD_SKIP:
1736 case LFUN_BREAK_PARAGRAPH:
1737 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
1738 case LFUN_BREAK_PARAGRAPH_SKIP:
1739 case LFUN_PARAGRAPH_SPACING:
1740 case LFUN_INSET_INSERT:
1741 case LFUN_WORD_UPCASE:
1742 case LFUN_WORD_LOWCASE:
1743 case LFUN_WORD_CAPITALIZE:
1744 case LFUN_CHARS_TRANSPOSE:
1745 case LFUN_SERVER_GET_XY:
1746 case LFUN_SERVER_SET_XY:
1747 case LFUN_SERVER_GET_FONT:
1748 case LFUN_SERVER_GET_LAYOUT:
1750 case LFUN_CLIPBOARD_PASTE:
1751 case LFUN_PRIMARY_SELECTION_PASTE:
1752 case LFUN_DATE_INSERT:
1753 case LFUN_SELF_INSERT:
1754 case LFUN_LINE_INSERT:
1755 case LFUN_PAGEBREAK_INSERT:
1756 case LFUN_MATH_DISPLAY:
1757 case LFUN_MATH_IMPORT_SELECTION:
1758 case LFUN_MATH_MODE:
1759 case LFUN_MATH_MACRO:
1760 case LFUN_MATH_MATRIX:
1761 case LFUN_MATH_DELIM:
1762 case LFUN_MATH_BIGDELIM:
1763 case LFUN_MATH_SUBSCRIPT:
1764 case LFUN_MATH_SUPERSCRIPT:
1765 case LFUN_FONT_DEFAULT:
1766 case LFUN_FONT_UNDERLINE:
1767 case LFUN_FONT_SIZE:
1769 case LFUN_FONT_FREE_APPLY:
1770 case LFUN_FONT_FREE_UPDATE:
1771 case LFUN_LAYOUT_PARAGRAPH:
1772 case LFUN_PARAGRAPH_UPDATE:
1773 case LFUN_ACCENT_UMLAUT:
1774 case LFUN_ACCENT_CIRCUMFLEX:
1775 case LFUN_ACCENT_GRAVE:
1776 case LFUN_ACCENT_ACUTE:
1777 case LFUN_ACCENT_TILDE:
1778 case LFUN_ACCENT_CEDILLA:
1779 case LFUN_ACCENT_MACRON:
1780 case LFUN_ACCENT_DOT:
1781 case LFUN_ACCENT_UNDERDOT:
1782 case LFUN_ACCENT_UNDERBAR:
1783 case LFUN_ACCENT_CARON:
1784 case LFUN_ACCENT_SPECIAL_CARON:
1785 case LFUN_ACCENT_BREVE:
1786 case LFUN_ACCENT_TIE:
1787 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1788 case LFUN_ACCENT_CIRCLE:
1789 case LFUN_ACCENT_OGONEK:
1790 case LFUN_THESAURUS_ENTRY:
1791 case LFUN_PARAGRAPH_PARAMS_APPLY:
1793 case LFUN_BUFFER_END:
1794 case LFUN_BUFFER_BEGIN:
1795 case LFUN_BUFFER_BEGIN_SELECT:
1796 case LFUN_BUFFER_END_SELECT:
1797 // these are handled in our dispatch()
1805 if (code != InsetBase::NO_CODE
1806 && (cur.empty() || !cur.inset().insetAllowed(code)))
1809 flag.enabled(enable);