3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Asger Alstrup
7 * \author Lars Gullik Bjønnes
8 * \author Alfredo Braunstein
9 * \author Angus Leeming
11 * \author André Pönitz
13 * Full author contact details are available in file CREDITS.
20 #include "BranchList.h"
21 #include "FloatList.h"
22 #include "FuncStatus.h"
24 #include "buffer_funcs.h"
25 #include "bufferparams.h"
26 #include "BufferView.h"
28 #include "coordcache.h"
29 #include "CutAndPaste.h"
31 #include "dispatchresult.h"
33 #include "funcrequest.h"
37 #include "LyXAction.h"
42 #include "paragraph.h"
43 #include "paragraph_funcs.h"
44 #include "ParagraphParameters.h"
47 #include "pariterator.h"
49 #include "frontends/Dialogs.h"
50 #include "frontends/Gui.h"
51 #include "frontends/LyXView.h"
52 #include "frontends/Clipboard.h"
54 #include "insets/insetcommand.h"
55 #include "insets/insetfloatlist.h"
56 #include "insets/insetnewline.h"
57 #include "insets/insetquotes.h"
58 #include "insets/insetspecialchar.h"
59 #include "insets/insettext.h"
61 #include "support/lstrings.h"
62 #include "support/lyxlib.h"
63 #include "support/convert.h"
64 #include "support/lyxtime.h"
66 #include "mathed/math_hullinset.h"
67 #include "mathed/math_macrotemplate.h"
69 #include <boost/current_function.hpp>
76 using lyx::cap::copySelection;
77 using lyx::cap::cutSelection;
78 using lyx::cap::pasteSelection;
79 using lyx::cap::replaceSelection;
81 using lyx::support::isStrUnsignedInt;
82 using lyx::support::token;
84 using lyx::frontend::Gui;
85 using lyx::frontend::Clipboard;
89 using std::istringstream;
90 using std::ostringstream;
93 extern string current_layout;
99 LyXFont freefont(LyXFont::ALL_IGNORE);
100 bool toggleall = false;
103 void toggleAndShow(LCursor & cur, LyXText * text,
104 LyXFont const & font, bool toggleall = true)
106 text->toggleFree(cur, font, toggleall);
108 if (font.language() != ignore_language ||
109 font.number() != LyXFont::IGNORE) {
110 Paragraph & par = cur.paragraph();
111 text->bidi.computeTables(par, cur.buffer(), cur.textRow());
112 if (cur.boundary() !=
113 text->bidi.isBoundary(cur.buffer(), par,
115 text->real_current_font))
116 text->setCursor(cur, cur.pit(), cur.pos(),
117 false, !cur.boundary());
122 void moveCursor(LCursor & cur, bool selecting)
124 if (selecting || cur.mark())
126 if (!cur.selection())
127 cur.bv().owner()->gui().clipboard().haveSelection(false);
128 cur.bv().switchKeyMap();
132 void finishChange(LCursor & cur, bool selecting)
135 moveCursor(cur, selecting);
139 void mathDispatch(LCursor & cur, FuncRequest const & cmd, bool display)
142 string sel = cur.selectionAsString(false);
143 //lyxerr << "selection is: '" << sel << "'" << endl;
145 // It may happen that sel is empty but there is a selection
146 replaceSelection(cur);
149 const int old_pos = cur.pos();
150 cur.insert(new MathHullInset("simple"));
151 BOOST_ASSERT(old_pos == cur.pos());
152 cur.nextInset()->edit(cur, true);
153 // don't do that also for LFUN_MATH_MODE
154 // unless you want end up with always changing
155 // to mathrm when opening an inlined inset --
156 // I really hate "LyXfunc overloading"...
158 cur.dispatch(FuncRequest(LFUN_MATH_DISPLAY));
159 // Avoid an unnecessary undo step if cmd.argument
161 if (!cmd.argument.empty())
162 cur.dispatch(FuncRequest(LFUN_MATH_INSERT,
165 // create a macro if we see "\\newcommand"
166 // somewhere, and an ordinary formula
168 istringstream is(sel);
169 if (sel.find("\\newcommand") == string::npos
170 && sel.find("\\def") == string::npos)
172 MathHullInset * formula = new MathHullInset;
175 formula->read(cur.buffer(), lex);
176 if (formula->getType() == "none")
177 // Don't create pseudo formulas if
178 // delimiters are left out
179 formula->mutate("simple");
182 cur.insert(new MathMacroTemplate(is));
184 cur.message(N_("Math editor mode"));
193 string const freefont2string()
196 if (font2string(freefont, toggleall, data))
203 bool LyXText::cursorPrevious(LCursor & cur)
205 pos_type cpos = cur.pos();
206 lyx::pit_type cpar = cur.pit();
208 int x = cur.x_target();
210 bool updated = setCursorFromCoordinates(cur, x, 0);
213 updated |= cursorUp(cur);
215 if (cpar == cur.pit() && cpos == cur.pos()) {
216 // we have a row which is taller than the workarea. The
217 // simplest solution is to move to the previous row instead.
218 updated |= cursorUp(cur);
226 bool LyXText::cursorNext(LCursor & cur)
228 pos_type cpos = cur.pos();
229 lyx::pit_type cpar = cur.pit();
231 int x = cur.x_target();
232 bool updated = setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1);
235 updated |= cursorDown(cur);
237 if (cpar == cur.pit() && cpos == cur.pos()) {
238 // we have a row which is taller than the workarea. The
239 // simplest solution is to move to the next row instead.
240 updated |= cursorDown(cur);
250 void specialChar(LCursor & cur, InsetSpecialChar::Kind kind)
252 lyx::cap::replaceSelection(cur);
253 cur.insert(new InsetSpecialChar(kind));
258 bool doInsertInset(LCursor & cur, LyXText * text,
259 FuncRequest const & cmd, bool edit, bool pastesel)
261 InsetBase * inset = createInset(&cur.bv(), cmd);
267 if (cur.selection()) {
268 cur.bv().owner()->dispatch(FuncRequest(LFUN_CUT));
271 text->insertInset(cur, inset);
274 inset->edit(cur, true);
276 if (gotsel && pastesel)
277 cur.bv().owner()->dispatch(FuncRequest(LFUN_PASTE));
282 void update(LCursor & cur)
284 //we don't call update(true, false) directly to save a metrics call
285 if (cur.bv().fitCursor())
286 cur.bv().update(Update::Force);
293 void LyXText::number(LCursor & cur)
295 LyXFont font(LyXFont::ALL_IGNORE);
296 font.setNumber(LyXFont::TOGGLE);
297 toggleAndShow(cur, this, font);
301 bool LyXText::isRTL(Paragraph const & par) const
303 return par.isRightToLeftPar(bv()->buffer()->params());
307 void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
309 lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl;
311 BOOST_ASSERT(cur.text() == this);
312 BufferView * bv = &cur.bv();
313 CursorSlice oldTopSlice = cur.top();
314 bool oldBoundary = cur.boundary();
315 bool sel = cur.selection();
316 // Signals that, even if needsUpdate == false, an update of the
317 // cursor paragraph is required
318 bool singleParUpdate = lyxaction.funcHasFlag(cmd.action,
319 LyXAction::SingleParUpdate);
320 // Signals that a full-screen update is required
321 bool needsUpdate = !(lyxaction.funcHasFlag(cmd.action,
322 LyXAction::NoUpdate) || singleParUpdate);
323 // Remember the old paragraph metric (_outer_ paragraph!)
324 Dimension olddim = cur.bottom().paragraph().dim();
326 switch (cmd.action) {
328 case LFUN_PARAGRAPH_MOVE_DOWN: {
329 pit_type const pit = cur.pit();
330 recUndo(pit, pit + 1);
332 std::swap(pars_[pit], pars_[pit + 1]);
334 ParIterator begin(cur);
336 ParIterator end = boost::next(ParIterator(cur));
337 updateLabels(cur.buffer(), begin, end);
343 case LFUN_PARAGRAPH_MOVE_UP: {
344 pit_type const pit = cur.pit();
345 recUndo(pit - 1, pit);
347 std::swap(pars_[pit], pars_[pit - 1]);
349 ParIterator end = boost::next(ParIterator(cur));
351 ParIterator begin(cur);
352 updateLabels(cur.buffer(), begin, end);
358 case LFUN_APPENDIX: {
359 Paragraph & par = cur.paragraph();
360 bool start = !par.params().startOfAppendix();
363 #warning The code below only makes sense at top level.
364 // Should LFUN_APPENDIX be restricted to top-level paragraphs?
366 // ensure that we have only one start_of_appendix in this document
367 for (pit_type tmp = 0, end = pars_.size(); tmp != end; ++tmp) {
368 if (pars_[tmp].params().startOfAppendix()) {
370 pars_[tmp].params().startOfAppendix(false);
376 par.params().startOfAppendix(start);
378 // we can set the refreshing parameters now
379 updateLabels(cur.buffer());
383 case LFUN_WORD_DELETE_FORWARD:
384 cur.clearSelection();
385 deleteWordForward(cur);
386 finishChange(cur, false);
389 case LFUN_WORD_DELETE_BACKWARD:
390 cur.clearSelection();
391 deleteWordBackward(cur);
392 finishChange(cur, false);
395 case LFUN_LINE_DELETE:
396 cur.clearSelection();
397 deleteLineForward(cur);
398 finishChange(cur, false);
401 case LFUN_WORD_FORWARD:
403 cur.clearSelection();
404 if (isRTL(cur.paragraph()))
405 needsUpdate = cursorLeftOneWord(cur);
407 needsUpdate = cursorRightOneWord(cur);
408 finishChange(cur, false);
411 case LFUN_WORD_BACKWARD:
413 cur.clearSelection();
414 if (isRTL(cur.paragraph()))
415 needsUpdate = cursorRightOneWord(cur);
417 needsUpdate = cursorLeftOneWord(cur);
418 finishChange(cur, false);
421 case LFUN_BUFFER_BEGIN:
422 if (cur.depth() == 1) {
424 cur.clearSelection();
425 needsUpdate = cursorTop(cur);
426 finishChange(cur, false);
432 case LFUN_BUFFER_BEGIN_SELECT:
433 if (cur.depth() == 1) {
434 if (!cur.selection())
436 needsUpdate = cursorTop(cur);
437 finishChange(cur, true);
443 case LFUN_BUFFER_END:
444 if (cur.depth() == 1) {
446 cur.clearSelection();
447 needsUpdate = cursorBottom(cur);
448 finishChange(cur, false);
454 case LFUN_BUFFER_END_SELECT:
455 if (cur.depth() == 1) {
456 if (!cur.selection())
458 needsUpdate = cursorBottom(cur);
459 finishChange(cur, true);
465 case LFUN_CHAR_FORWARD:
466 case LFUN_CHAR_FORWARD_SELECT:
467 //lyxerr << BOOST_CURRENT_FUNCTION
468 // << " LFUN_CHAR_FORWARD[SEL]:\n" << cur << endl;
469 cur.selHandle(cmd.action == LFUN_CHAR_FORWARD_SELECT);
470 if (isRTL(cur.paragraph()))
471 needsUpdate = cursorLeft(cur);
473 needsUpdate = cursorRight(cur);
475 if (!needsUpdate && oldTopSlice == cur.top()
476 && cur.boundary() == oldBoundary) {
478 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
482 case LFUN_CHAR_BACKWARD:
483 case LFUN_CHAR_BACKWARD_SELECT:
484 //lyxerr << "handle LFUN_CHAR_BACKWARD[_SELECT]:\n" << cur << endl;
485 cur.selHandle(cmd.action == LFUN_CHAR_BACKWARD_SELECT);
486 if (isRTL(cur.paragraph()))
487 needsUpdate = cursorRight(cur);
489 needsUpdate = cursorLeft(cur);
491 if (!needsUpdate && oldTopSlice == cur.top()
492 && cur.boundary() == oldBoundary) {
494 cmd = FuncRequest(LFUN_FINISHED_LEFT);
501 //lyxerr << "handle LFUN_UP[SEL]:\n" << cur << endl;
502 cur.selHandle(cmd.action == LFUN_UP_SELECT);
504 needsUpdate = cursorUp(cur);
505 if (!needsUpdate && oldTopSlice == cur.top()
506 && cur.boundary() == oldBoundary) {
508 cmd = FuncRequest(LFUN_FINISHED_UP);
513 case LFUN_DOWN_SELECT:
515 //lyxerr << "handle LFUN_DOWN[SEL]:\n" << cur << endl;
516 cur.selHandle(cmd.action == LFUN_DOWN_SELECT);
517 needsUpdate = cursorDown(cur);
518 if (!needsUpdate && oldTopSlice == cur.top() &&
519 cur.boundary() == oldBoundary)
522 cmd = FuncRequest(LFUN_FINISHED_DOWN);
526 case LFUN_PARAGRAPH_UP:
528 cur.clearSelection();
529 needsUpdate = cursorUpParagraph(cur);
530 finishChange(cur, false);
533 case LFUN_PARAGRAPH_UP_SELECT:
534 if (!cur.selection())
536 cursorUpParagraph(cur);
537 finishChange(cur, true);
540 case LFUN_PARAGRAPH_DOWN:
542 cur.clearSelection();
543 needsUpdate = cursorDownParagraph(cur);
544 finishChange(cur, false);
547 case LFUN_PARAGRAPH_DOWN_SELECT:
548 if (!cur.selection())
550 cursorDownParagraph(cur);
551 finishChange(cur, true);
554 case LFUN_SCREEN_UP_SELECT:
556 if (!cur.selection())
558 needsUpdate = cursorPrevious(cur);
559 finishChange(cur, true);
562 case LFUN_SCREEN_DOWN_SELECT:
564 if (!cur.selection())
566 needsUpdate = cursorNext(cur);
567 finishChange(cur, true);
570 case LFUN_LINE_BEGIN_SELECT:
572 if (!cur.selection())
574 needsUpdate = cursorHome(cur);
575 finishChange(cur, true);
578 case LFUN_LINE_END_SELECT:
580 if (!cur.selection())
582 needsUpdate = cursorEnd(cur);
583 finishChange(cur, true);
586 case LFUN_WORD_FORWARD_SELECT:
587 if (!cur.selection())
589 if (isRTL(cur.paragraph()))
590 cursorLeftOneWord(cur);
592 cursorRightOneWord(cur);
593 finishChange(cur, true);
596 case LFUN_WORD_BACKWARD_SELECT:
597 if (!cur.selection())
599 if (isRTL(cur.paragraph()))
600 cursorRightOneWord(cur);
602 cursorLeftOneWord(cur);
603 finishChange(cur, true);
606 case LFUN_WORD_SELECT: {
607 selectWord(cur, lyx::WHOLE_WORD);
608 finishChange(cur, true);
615 cur.clearSelection();
616 finishChange(cur, false);
617 if (cur.pit() == 0 && cur.textRow().pos() == 0) {
619 cmd = FuncRequest(LFUN_FINISHED_UP);
621 needsUpdate = cursorPrevious(cur);
625 case LFUN_SCREEN_DOWN:
628 cur.clearSelection();
629 finishChange(cur, false);
630 if (cur.pit() == cur.lastpit()
631 && cur.textRow().endpos() == cur.lastpos()) {
633 cmd = FuncRequest(LFUN_FINISHED_DOWN);
635 needsUpdate = cursorNext(cur);
639 case LFUN_LINE_BEGIN:
641 cur.clearSelection();
642 needsUpdate = cursorHome(cur);
643 finishChange(cur, false);
648 cur.clearSelection();
649 needsUpdate = cursorEnd(cur);
650 finishChange(cur, false);
653 case LFUN_BREAK_LINE: {
654 // Not allowed by LaTeX (labels or empty par)
655 if (cur.pos() > cur.paragraph().beginOfBody()) {
656 lyx::cap::replaceSelection(cur);
657 cur.insert(new InsetNewline);
659 moveCursor(cur, false);
664 case LFUN_CHAR_DELETE_FORWARD:
665 if (!cur.selection()) {
666 if (cur.pos() == cur.paragraph().size())
667 // Par boundary, force full-screen update
668 singleParUpdate = false;
669 needsUpdate = erase(cur);
671 // It is possible to make it a lot faster still
672 // just comment out the line below...
674 cutSelection(cur, true, false);
675 singleParUpdate = false;
677 moveCursor(cur, false);
680 case LFUN_DELETE_FORWARD_SKIP:
681 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
682 if (!cur.selection()) {
683 if (cur.pos() == cur.lastpos()) {
690 cutSelection(cur, true, false);
695 case LFUN_CHAR_DELETE_BACKWARD:
696 if (!cur.selection()) {
697 if (bv->owner()->getIntl().getTransManager().backspace()) {
698 // Par boundary, full-screen update
700 singleParUpdate = false;
701 needsUpdate = backspace(cur);
703 // It is possible to make it a lot faster still
704 // just comment out the line below...
707 cutSelection(cur, true, false);
708 singleParUpdate = false;
713 case LFUN_DELETE_BACKWARD_SKIP:
714 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
715 if (!cur.selection()) {
719 //CursorSlice cur = cursor();
723 cutSelection(cur, true, false);
727 case LFUN_BREAK_PARAGRAPH:
728 lyx::cap::replaceSelection(cur);
729 breakParagraph(cur, 0);
734 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
735 lyx::cap::replaceSelection(cur);
736 breakParagraph(cur, 1);
741 case LFUN_BREAK_PARAGRAPH_SKIP: {
742 // When at the beginning of a paragraph, remove
743 // indentation. Otherwise, do the same as LFUN_BREAK_PARAGRAPH.
744 lyx::cap::replaceSelection(cur);
746 cur.paragraph().params().labelWidthString(string());
748 breakParagraph(cur, 0);
754 case LFUN_PARAGRAPH_SPACING: {
755 Paragraph & par = cur.paragraph();
756 Spacing::Space cur_spacing = par.params().spacing().getSpace();
757 string cur_value = "1.0";
758 if (cur_spacing == Spacing::Other)
759 cur_value = par.params().spacing().getValueAsString();
761 istringstream is(cmd.argument);
764 Spacing::Space new_spacing = cur_spacing;
765 string new_value = cur_value;
767 lyxerr << "Missing argument to `paragraph-spacing'"
769 } else if (tmp == "single") {
770 new_spacing = Spacing::Single;
771 } else if (tmp == "onehalf") {
772 new_spacing = Spacing::Onehalf;
773 } else if (tmp == "double") {
774 new_spacing = Spacing::Double;
775 } else if (tmp == "other") {
776 new_spacing = Spacing::Other;
777 string tmpval = "0.0";
779 lyxerr << "new_value = " << tmpval << endl;
782 } else if (tmp == "default") {
783 new_spacing = Spacing::Default;
785 lyxerr << _("Unknown spacing argument: ")
786 << cmd.argument << endl;
788 if (cur_spacing != new_spacing || cur_value != new_value)
789 par.params().spacing(Spacing(new_spacing, new_value));
793 case LFUN_INSET_INSERT: {
795 InsetBase * inset = createInset(bv, cmd);
797 insertInset(cur, inset);
803 case LFUN_INSET_SETTINGS:
804 cur.inset().showInsetDialog(bv);
807 case LFUN_NEXT_INSET_TOGGLE: {
808 InsetBase * inset = cur.nextInset();
809 // this is the real function we want to invoke
810 cmd = FuncRequest(LFUN_INSET_TOGGLE);
812 // if there is an inset at cursor, see whether it
815 LCursor tmpcur = cur;
816 tmpcur.pushLeft(*inset);
817 inset->dispatch(tmpcur, cmd);
818 if (tmpcur.result().dispatched()) {
819 cur.clearSelection();
823 // if it did not work, try the underlying inset.
824 if (!cur.result().dispatched())
825 cur.inset().dispatch(cur, cmd);
829 case LFUN_SPACE_INSERT:
830 if (cur.paragraph().layout()->free_spacing)
831 insertChar(cur, ' ');
833 doInsertInset(cur, this, cmd, false, false);
836 moveCursor(cur, false);
839 case LFUN_HYPHENATION_POINT_INSERT:
840 specialChar(cur, InsetSpecialChar::HYPHENATION);
843 case LFUN_LIGATURE_BREAK_INSERT:
844 specialChar(cur, InsetSpecialChar::LIGATURE_BREAK);
847 case LFUN_DOTS_INSERT:
848 specialChar(cur, InsetSpecialChar::LDOTS);
851 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
852 specialChar(cur, InsetSpecialChar::END_OF_SENTENCE);
855 case LFUN_MENU_SEPARATOR_INSERT:
856 specialChar(cur, InsetSpecialChar::MENU_SEPARATOR);
859 case LFUN_WORD_UPCASE:
860 changeCase(cur, LyXText::text_uppercase);
863 case LFUN_WORD_LOWCASE:
864 changeCase(cur, LyXText::text_lowercase);
867 case LFUN_WORD_CAPITALIZE:
868 changeCase(cur, LyXText::text_capitalization);
871 case LFUN_CHARS_TRANSPOSE:
876 cur.message(_("Paste"));
877 lyx::cap::replaceSelection(cur);
878 if (isStrUnsignedInt(cmd.argument))
879 pasteSelection(cur, convert<unsigned int>(cmd.argument));
881 pasteSelection(cur, 0);
882 cur.clearSelection(); // bug 393
888 cutSelection(cur, true, true);
889 cur.message(_("Cut"));
894 cur.message(_("Copy"));
897 case LFUN_SERVER_GET_XY:
898 cur.message(convert<string>(cursorX(cur.top(), cur.boundary())) + ' '
899 + convert<string>(cursorY(cur.top(), cur.boundary())));
902 case LFUN_SERVER_SET_XY: {
905 istringstream is(cmd.argument);
908 lyxerr << "SETXY: Could not parse coordinates in '"
909 << cmd.argument << std::endl;
911 setCursorFromCoordinates(cur, x, y);
915 case LFUN_SERVER_GET_FONT:
916 if (current_font.shape() == LyXFont::ITALIC_SHAPE)
918 else if (current_font.shape() == LyXFont::SMALLCAPS_SHAPE)
924 case LFUN_SERVER_GET_LAYOUT:
925 cur.message(cur.paragraph().layout()->name());
929 lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) "
930 << cmd.argument << endl;
932 // This is not the good solution to the empty argument
933 // problem, but it will hopefully suffice for 1.2.0.
934 // The correct solution would be to augument the
935 // function list/array with information about what
936 // functions needs arguments and their type.
937 if (cmd.argument.empty()) {
938 cur.errorMessage(_("LyX function 'layout' needs an argument."));
942 // Derive layout number from given argument (string)
943 // and current buffer's textclass (number)
944 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
945 bool hasLayout = tclass.hasLayout(cmd.argument);
946 string layout = cmd.argument;
948 // If the entry is obsolete, use the new one instead.
950 string const & obs = tclass[layout]->obsoleted_by();
956 cur.errorMessage(string(N_("Layout ")) + cmd.argument +
961 bool change_layout = (current_layout != layout);
963 if (!change_layout && cur.selection() &&
964 cur.selBegin().pit() != cur.selEnd().pit())
966 pit_type spit = cur.selBegin().pit();
967 pit_type epit = cur.selEnd().pit() + 1;
968 while (spit != epit) {
969 if (pars_[spit].layout()->name() != current_layout) {
970 change_layout = true;
978 current_layout = layout;
979 setLayout(cur, layout);
980 bv->owner()->setLayout(layout);
986 case LFUN_PRIMARY_SELECTION_PASTE: {
987 cur.clearSelection();
988 string const clip = bv->owner()->gui().clipboard().get();
991 if (cmd.argument == "paragraph")
992 insertStringAsParagraphs(cur, clip);
994 insertStringAsLines(cur, clip);
999 case LFUN_QUOTE_INSERT: {
1000 lyx::cap::replaceSelection(cur);
1001 Paragraph & par = cur.paragraph();
1002 lyx::pos_type pos = cur.pos();
1006 else if (cur.prevInset() && cur.prevInset()->isSpace())
1009 c = par.getChar(pos - 1);
1011 LyXLayout_ptr const & style = par.layout();
1013 BufferParams const & bufparams = bv->buffer()->params();
1014 if (!style->pass_thru
1015 && par.getFontSettings(bufparams, pos).language()->lang() != "hebrew") {
1016 string arg = cmd.argument;
1017 if (arg == "single")
1018 cur.insert(new InsetQuotes(c,
1019 bufparams.quotes_language,
1020 InsetQuotes::SingleQ));
1022 cur.insert(new InsetQuotes(c,
1023 bufparams.quotes_language,
1024 InsetQuotes::DoubleQ));
1028 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT, "\""));
1032 case LFUN_DATE_INSERT:
1033 if (cmd.argument.empty())
1034 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT,
1035 lyx::formatted_time(lyx::current_time())));
1037 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT,
1038 lyx::formatted_time(lyx::current_time(), cmd.argument)));
1041 case LFUN_MOUSE_TRIPLE:
1042 if (cmd.button() == mouse_button::button1) {
1048 bv->owner()->gui().clipboard().haveSelection(cur.selection());
1052 case LFUN_MOUSE_DOUBLE:
1053 if (cmd.button() == mouse_button::button1) {
1054 selectWord(cur, lyx::WHOLE_WORD_STRICT);
1056 bv->owner()->gui().clipboard().haveSelection(cur.selection());
1060 // Single-click on work area
1061 case LFUN_MOUSE_PRESS: {
1062 // Right click on a footnote flag opens float menu
1063 if (cmd.button() == mouse_button::button3)
1064 cur.clearSelection();
1066 // Middle button press pastes if we have a selection
1067 // We do this here as if the selection was inside an inset
1068 // it could get cleared on the unlocking of the inset so
1069 // we have to check this first
1070 bool paste_internally = false;
1071 if (cmd.button() == mouse_button::button2 && cur.selection()) {
1072 bv->owner()->dispatch(FuncRequest(LFUN_COPY));
1073 paste_internally = true;
1076 bv->mouseSetCursor(cur);
1078 // Insert primary selection with middle mouse
1079 // if there is a local selection in the current buffer,
1081 if (cmd.button() == mouse_button::button2) {
1082 if (paste_internally)
1083 bv->owner()->dispatch(FuncRequest(LFUN_PASTE));
1085 bv->owner()->dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph"));
1091 case LFUN_MOUSE_MOTION: {
1092 // Only use motion with button 1
1093 //if (cmd.button() != mouse_button::button1)
1096 // ignore motions deeper nested than the real anchor
1097 LCursor & bvcur = cur.bv().cursor();
1098 if (bvcur.anchor_.hasPart(cur)) {
1099 CursorSlice old = bvcur.top();
1101 int const wh = bv->workHeight();
1102 int const y = std::max(0, std::min(wh - 1, cmd.y));
1104 setCursorFromCoordinates(cur, cmd.x, y);
1105 cur.x_target() = cmd.x;
1110 // This is to allow jumping over large insets
1111 if (cur.top() == old) {
1118 if (cur.top() == old)
1121 // don't set anchor_
1122 bvcur.setCursor(cur);
1123 bvcur.selection() = true;
1124 //lyxerr << "MOTION: " << bv->cursor() << endl;
1132 case LFUN_MOUSE_RELEASE: {
1133 if (cmd.button() == mouse_button::button2)
1137 if (cmd.button() == mouse_button::button1)
1138 bv->owner()->gui().clipboard().haveSelection(cur.selection());
1141 bv->owner()->updateMenubar();
1142 bv->owner()->updateToolbars();
1146 case LFUN_SELF_INSERT: {
1147 if (cmd.argument.empty())
1150 // Automatically delete the currently selected
1151 // text and replace it with what is being
1152 // typed in now. Depends on lyxrc settings
1153 // "auto_region_delete", which defaults to
1156 if (lyxrc.auto_region_delete) {
1157 if (cur.selection())
1158 cutSelection(cur, false, false);
1159 bv->owner()->gui().clipboard().haveSelection(false);
1162 cur.clearSelection();
1163 LyXFont const old_font = real_current_font;
1165 string::const_iterator cit = cmd.argument.begin();
1166 string::const_iterator end = cmd.argument.end();
1167 for (; cit != end; ++cit)
1168 bv->owner()->getIntl().getTransManager().
1169 translateAndInsert(*cit, this);
1172 moveCursor(cur, false);
1176 case LFUN_URL_INSERT: {
1177 InsetCommandParams p("url");
1178 string const data = InsetCommandMailer::params2string("url", p);
1179 bv->owner()->getDialogs().show("url", data, 0);
1183 case LFUN_HTML_INSERT: {
1184 InsetCommandParams p("htmlurl");
1185 string const data = InsetCommandMailer::params2string("url", p);
1186 bv->owner()->getDialogs().show("url", data, 0);
1190 case LFUN_LABEL_INSERT: {
1191 // Try to generate a valid label
1192 string const contents = cmd.argument.empty() ?
1193 cur.getPossibleLabel() : cmd.argument;
1195 InsetCommandParams p("label", contents);
1196 string const data = InsetCommandMailer::params2string("label", p);
1198 if (cmd.argument.empty()) {
1199 bv->owner()->getDialogs().show("label", data, 0);
1201 FuncRequest fr(LFUN_INSET_INSERT, data);
1209 case LFUN_LIST_INSERT:
1210 case LFUN_THEOREM_INSERT:
1211 case LFUN_CAPTION_INSERT:
1213 case LFUN_NOTE_INSERT:
1214 case LFUN_CHARSTYLE_INSERT:
1215 case LFUN_BOX_INSERT:
1216 case LFUN_BRANCH_INSERT:
1217 case LFUN_BIBITEM_INSERT:
1218 case LFUN_ERT_INSERT:
1219 case LFUN_FOOTNOTE_INSERT:
1220 case LFUN_MARGINALNOTE_INSERT:
1221 case LFUN_OPTIONAL_INSERT:
1222 case LFUN_ENVIRONMENT_INSERT:
1223 // Open the inset, and move the current selection
1225 doInsertInset(cur, this, cmd, true, true);
1229 case LFUN_TABULAR_INSERT:
1230 // if there were no arguments, just open the dialog
1231 if (doInsertInset(cur, this, cmd, false, true))
1234 bv->owner()->getDialogs().show("tabularcreate");
1238 case LFUN_FLOAT_INSERT:
1239 case LFUN_FLOAT_WIDE_INSERT:
1240 case LFUN_WRAP_INSERT:
1241 doInsertInset(cur, this, cmd, true, true);
1243 // FIXME: the "Caption" name should not be hardcoded,
1244 // but given by the float definition.
1245 cur.dispatch(FuncRequest(LFUN_LAYOUT, "Caption"));
1248 case LFUN_INDEX_INSERT: {
1249 InsetBase * inset = createInset(&cur.bv(), cmd);
1254 cur.clearSelection();
1255 insertInset(cur, inset);
1256 inset->edit(cur, true);
1261 case LFUN_INDEX_PRINT:
1262 case LFUN_TOC_INSERT:
1263 case LFUN_HFILL_INSERT:
1264 case LFUN_LINE_INSERT:
1265 case LFUN_PAGEBREAK_INSERT:
1267 doInsertInset(cur, this, cmd, false, false);
1271 case LFUN_DEPTH_DECREMENT:
1272 changeDepth(cur, DEC_DEPTH);
1275 case LFUN_DEPTH_INCREMENT:
1276 changeDepth(cur, INC_DEPTH);
1279 case LFUN_MATH_DISPLAY:
1280 mathDispatch(cur, cmd, true);
1283 case LFUN_MATH_IMPORT_SELECTION:
1284 case LFUN_MATH_MODE:
1285 if (cmd.argument == "on")
1286 // don't pass "on" as argument
1287 mathDispatch(cur, FuncRequest(LFUN_MATH_MODE), false);
1289 mathDispatch(cur, cmd, false);
1292 case LFUN_MATH_MACRO:
1293 if (cmd.argument.empty())
1294 cur.errorMessage(N_("Missing argument"));
1296 string s = cmd.argument;
1297 string const s1 = token(s, ' ', 1);
1298 int const nargs = s1.empty() ? 0 : convert<int>(s1);
1299 string const s2 = token(s, ' ', 2);
1300 string const type = s2.empty() ? "newcommand" : s2;
1301 cur.insert(new MathMacroTemplate(token(s, ' ', 0), nargs, type));
1302 //cur.nextInset()->edit(cur, true);
1306 // passthrough hat and underscore outside mathed:
1307 case LFUN_MATH_SUBSCRIPT:
1308 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "_"), false);
1310 case LFUN_MATH_SUPERSCRIPT:
1311 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "^"), false);
1314 case LFUN_MATH_INSERT:
1315 case LFUN_MATH_MATRIX:
1316 case LFUN_MATH_DELIM:
1317 case LFUN_MATH_BIGDELIM: {
1318 cur.insert(new MathHullInset("simple"));
1319 cur.dispatch(FuncRequest(LFUN_CHAR_FORWARD));
1324 case LFUN_FONT_EMPH: {
1325 LyXFont font(LyXFont::ALL_IGNORE);
1326 font.setEmph(LyXFont::TOGGLE);
1327 toggleAndShow(cur, this, font);
1331 case LFUN_FONT_BOLD: {
1332 LyXFont font(LyXFont::ALL_IGNORE);
1333 font.setSeries(LyXFont::BOLD_SERIES);
1334 toggleAndShow(cur, this, font);
1338 case LFUN_FONT_NOUN: {
1339 LyXFont font(LyXFont::ALL_IGNORE);
1340 font.setNoun(LyXFont::TOGGLE);
1341 toggleAndShow(cur, this, font);
1345 case LFUN_FONT_CODE: {
1346 LyXFont font(LyXFont::ALL_IGNORE);
1347 font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
1348 toggleAndShow(cur, this, font);
1352 case LFUN_FONT_SANS: {
1353 LyXFont font(LyXFont::ALL_IGNORE);
1354 font.setFamily(LyXFont::SANS_FAMILY);
1355 toggleAndShow(cur, this, font);
1359 case LFUN_FONT_ROMAN: {
1360 LyXFont font(LyXFont::ALL_IGNORE);
1361 font.setFamily(LyXFont::ROMAN_FAMILY);
1362 toggleAndShow(cur, this, font);
1366 case LFUN_FONT_DEFAULT: {
1367 LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
1368 toggleAndShow(cur, this, font);
1372 case LFUN_FONT_UNDERLINE: {
1373 LyXFont font(LyXFont::ALL_IGNORE);
1374 font.setUnderbar(LyXFont::TOGGLE);
1375 toggleAndShow(cur, this, font);
1379 case LFUN_FONT_SIZE: {
1380 LyXFont font(LyXFont::ALL_IGNORE);
1381 font.setLyXSize(cmd.argument);
1382 toggleAndShow(cur, this, font);
1386 case LFUN_LANGUAGE: {
1387 Language const * lang = languages.getLanguage(cmd.argument);
1390 LyXFont font(LyXFont::ALL_IGNORE);
1391 font.setLanguage(lang);
1392 toggleAndShow(cur, this, font);
1397 case LFUN_FONT_FREE_APPLY:
1398 toggleAndShow(cur, this, freefont, toggleall);
1399 cur.message(_("Character set"));
1402 // Set the freefont using the contents of \param data dispatched from
1403 // the frontends and apply it at the current cursor location.
1404 case LFUN_FONT_FREE_UPDATE: {
1407 if (bv_funcs::string2font(cmd.argument, font, toggle)) {
1410 toggleAndShow(cur, this, freefont, toggleall);
1411 cur.message(_("Character set"));
1416 case LFUN_FINISHED_LEFT:
1417 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_LEFT:\n" << cur << endl;
1420 case LFUN_FINISHED_RIGHT:
1421 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_RIGHT:\n" << cur << endl;
1425 case LFUN_FINISHED_UP:
1426 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_UP:\n" << cur << endl;
1430 case LFUN_FINISHED_DOWN:
1431 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_DOWN:\n" << cur << endl;
1435 case LFUN_LAYOUT_PARAGRAPH: {
1437 params2string(cur.paragraph(), data);
1438 data = "show\n" + data;
1439 bv->owner()->getDialogs().show("paragraph", data);
1443 case LFUN_PARAGRAPH_UPDATE: {
1444 if (!bv->owner()->getDialogs().visible("paragraph"))
1447 params2string(cur.paragraph(), data);
1449 // Will the paragraph accept changes from the dialog?
1450 bool const accept = !cur.inset().forceDefaultParagraphs(cur.idx());
1452 data = "update " + convert<string>(accept) + '\n' + data;
1453 bv->owner()->getDialogs().update("paragraph", data);
1457 case LFUN_ACCENT_UMLAUT:
1458 case LFUN_ACCENT_CIRCUMFLEX:
1459 case LFUN_ACCENT_GRAVE:
1460 case LFUN_ACCENT_ACUTE:
1461 case LFUN_ACCENT_TILDE:
1462 case LFUN_ACCENT_CEDILLA:
1463 case LFUN_ACCENT_MACRON:
1464 case LFUN_ACCENT_DOT:
1465 case LFUN_ACCENT_UNDERDOT:
1466 case LFUN_ACCENT_UNDERBAR:
1467 case LFUN_ACCENT_CARON:
1468 case LFUN_ACCENT_SPECIAL_CARON:
1469 case LFUN_ACCENT_BREVE:
1470 case LFUN_ACCENT_TIE:
1471 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1472 case LFUN_ACCENT_CIRCLE:
1473 case LFUN_ACCENT_OGONEK:
1474 bv->owner()->getLyXFunc().handleKeyFunc(cmd.action);
1475 if (!cmd.argument.empty())
1476 bv->owner()->getIntl().getTransManager()
1477 .translateAndInsert(cmd.argument[0], this);
1480 case LFUN_FLOAT_LIST: {
1481 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
1482 if (tclass.floats().typeExist(cmd.argument)) {
1483 // not quite sure if we want this...
1485 cur.clearSelection();
1486 breakParagraph(cur);
1488 if (cur.lastpos() != 0) {
1490 breakParagraph(cur);
1493 setLayout(cur, tclass.defaultLayoutName());
1494 setParagraph(cur, Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
1495 insertInset(cur, new InsetFloatList(cmd.argument));
1498 lyxerr << "Non-existent float type: "
1499 << cmd.argument << endl;
1504 case LFUN_CHANGE_ACCEPT: {
1509 case LFUN_CHANGE_REJECT: {
1514 case LFUN_THESAURUS_ENTRY: {
1515 string arg = cmd.argument;
1517 arg = cur.selectionAsString(false);
1519 if (arg.size() > 100 || arg.empty()) {
1520 // Get word or selection
1521 selectWordWhenUnderCursor(cur, lyx::WHOLE_WORD);
1522 arg = cur.selectionAsString(false);
1525 bv->owner()->getDialogs().show("thesaurus", arg);
1529 case LFUN_PARAGRAPH_PARAMS_APPLY: {
1530 // Given data, an encoding of the ParagraphParameters
1531 // generated in the Paragraph dialog, this function sets
1532 // the current paragraph appropriately.
1533 istringstream is(cmd.argument);
1536 ParagraphParameters params;
1541 params.labelWidthString(),
1543 cur.message(_("Paragraph layout set"));
1547 case LFUN_INSET_DIALOG_SHOW: {
1548 InsetBase * inset = cur.nextInset();
1550 FuncRequest fr(LFUN_INSET_DIALOG_SHOW);
1551 inset->dispatch(cur, fr);
1557 if (cur.selection()) {
1558 cur.selection() = false;
1561 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
1566 lyxerr[Debug::ACTION]
1567 << BOOST_CURRENT_FUNCTION
1568 << ": Command " << cmd
1569 << " not DISPATCHED by LyXText" << endl;
1574 if (singleParUpdate)
1575 // Inserting characters does not change par height
1576 if (cur.bottom().paragraph().dim().height()
1577 == olddim.height()) {
1578 // if so, update _only_ this paragraph
1579 cur.bv().update(Update::SinglePar |
1581 Update::MultiParSel);
1587 && &oldTopSlice.inset() == &cur.inset()
1588 && oldTopSlice.idx() == cur.idx()
1590 && !cur.selection())
1597 bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
1598 FuncStatus & flag) const
1600 BOOST_ASSERT(cur.text() == this);
1602 LyXFont const & font = real_current_font;
1604 InsetBase::Code code = InsetBase::NO_CODE;
1606 switch (cmd.action) {
1608 case LFUN_DEPTH_DECREMENT:
1609 enable = changeDepthAllowed(cur, DEC_DEPTH);
1612 case LFUN_DEPTH_INCREMENT:
1613 enable = changeDepthAllowed(cur, INC_DEPTH);
1617 flag.setOnOff(cur.paragraph().params().startOfAppendix());
1620 case LFUN_BIBITEM_INSERT:
1621 enable = (cur.paragraph().layout()->labeltype == LABEL_BIBLIO);
1624 case LFUN_DIALOG_SHOW_NEW_INSET:
1625 if (cmd.argument == "bibitem")
1626 code = InsetBase::BIBITEM_CODE;
1627 else if (cmd.argument == "bibtex")
1628 code = InsetBase::BIBTEX_CODE;
1629 else if (cmd.argument == "box")
1630 code = InsetBase::BOX_CODE;
1631 else if (cmd.argument == "branch")
1632 code = InsetBase::BRANCH_CODE;
1633 else if (cmd.argument == "citation")
1634 code = InsetBase::CITE_CODE;
1635 else if (cmd.argument == "ert")
1636 code = InsetBase::ERT_CODE;
1637 else if (cmd.argument == "external")
1638 code = InsetBase::EXTERNAL_CODE;
1639 else if (cmd.argument == "float")
1640 code = InsetBase::FLOAT_CODE;
1641 else if (cmd.argument == "graphics")
1642 code = InsetBase::GRAPHICS_CODE;
1643 else if (cmd.argument == "include")
1644 code = InsetBase::INCLUDE_CODE;
1645 else if (cmd.argument == "index")
1646 code = InsetBase::INDEX_CODE;
1647 else if (cmd.argument == "label")
1648 code = InsetBase::LABEL_CODE;
1649 else if (cmd.argument == "note")
1650 code = InsetBase::NOTE_CODE;
1651 else if (cmd.argument == "ref")
1652 code = InsetBase::REF_CODE;
1653 else if (cmd.argument == "toc")
1654 code = InsetBase::TOC_CODE;
1655 else if (cmd.argument == "url")
1656 code = InsetBase::URL_CODE;
1657 else if (cmd.argument == "vspace")
1658 code = InsetBase::VSPACE_CODE;
1659 else if (cmd.argument == "wrap")
1660 code = InsetBase::WRAP_CODE;
1663 case LFUN_ERT_INSERT:
1664 code = InsetBase::ERT_CODE;
1666 case LFUN_FOOTNOTE_INSERT:
1667 code = InsetBase::FOOT_CODE;
1669 case LFUN_TABULAR_INSERT:
1670 code = InsetBase::TABULAR_CODE;
1672 case LFUN_MARGINALNOTE_INSERT:
1673 code = InsetBase::MARGIN_CODE;
1675 case LFUN_FLOAT_INSERT:
1676 case LFUN_FLOAT_WIDE_INSERT:
1677 code = InsetBase::FLOAT_CODE;
1679 case LFUN_WRAP_INSERT:
1680 code = InsetBase::WRAP_CODE;
1682 case LFUN_FLOAT_LIST:
1683 code = InsetBase::FLOAT_LIST_CODE;
1686 case LFUN_LIST_INSERT:
1687 code = InsetBase::LIST_CODE;
1689 case LFUN_THEOREM_INSERT:
1690 code = InsetBase::THEOREM_CODE;
1693 case LFUN_CAPTION_INSERT:
1694 code = InsetBase::CAPTION_CODE;
1696 case LFUN_NOTE_INSERT:
1697 code = InsetBase::NOTE_CODE;
1699 case LFUN_CHARSTYLE_INSERT:
1700 code = InsetBase::CHARSTYLE_CODE;
1701 if (cur.buffer().params().getLyXTextClass().charstyles().empty())
1704 case LFUN_BOX_INSERT:
1705 code = InsetBase::BOX_CODE;
1707 case LFUN_BRANCH_INSERT:
1708 code = InsetBase::BRANCH_CODE;
1709 if (cur.buffer().getMasterBuffer()->params().branchlist().empty())
1712 case LFUN_LABEL_INSERT:
1713 code = InsetBase::LABEL_CODE;
1715 case LFUN_OPTIONAL_INSERT:
1716 code = InsetBase::OPTARG_CODE;
1717 enable = numberOfOptArgs(cur.paragraph())
1718 < cur.paragraph().layout()->optionalargs;
1720 case LFUN_ENVIRONMENT_INSERT:
1721 code = InsetBase::BOX_CODE;
1723 case LFUN_INDEX_INSERT:
1724 code = InsetBase::INDEX_CODE;
1726 case LFUN_INDEX_PRINT:
1727 code = InsetBase::INDEX_PRINT_CODE;
1729 case LFUN_TOC_INSERT:
1730 code = InsetBase::TOC_CODE;
1732 case LFUN_HTML_INSERT:
1733 case LFUN_URL_INSERT:
1734 code = InsetBase::URL_CODE;
1736 case LFUN_QUOTE_INSERT:
1737 // always allow this, since we will inset a raw quote
1738 // if an inset is not allowed.
1740 case LFUN_HYPHENATION_POINT_INSERT:
1741 case LFUN_LIGATURE_BREAK_INSERT:
1742 case LFUN_HFILL_INSERT:
1743 case LFUN_MENU_SEPARATOR_INSERT:
1744 case LFUN_DOTS_INSERT:
1745 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
1746 code = InsetBase::SPECIALCHAR_CODE;
1748 case LFUN_SPACE_INSERT:
1749 // slight hack: we know this is allowed in math mode
1751 code = InsetBase::SPACE_CODE;
1754 #ifdef WITH_WARNINGS
1755 #warning This LFUN is not used anymore and should be nuked (JMarc 29/10/2005)
1758 case LFUN_INSET_DIALOG_SHOW: {
1759 InsetBase * inset = cur.nextInset();
1762 code = inset->lyxCode();
1763 if (!(code == InsetBase::INCLUDE_CODE
1764 || code == InsetBase::BIBTEX_CODE
1765 || code == InsetBase::FLOAT_LIST_CODE
1766 || code == InsetBase::TOC_CODE))
1773 case LFUN_INSET_MODIFY:
1774 // We need to disable this, because we may get called for a
1776 // InsetTabular::getStatus() -> InsetText::getStatus()
1777 // and we don't handle LFUN_INSET_MODIFY.
1781 case LFUN_FONT_EMPH:
1782 flag.setOnOff(font.emph() == LyXFont::ON);
1785 case LFUN_FONT_NOUN:
1786 flag.setOnOff(font.noun() == LyXFont::ON);
1789 case LFUN_FONT_BOLD:
1790 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
1793 case LFUN_FONT_SANS:
1794 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
1797 case LFUN_FONT_ROMAN:
1798 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
1801 case LFUN_FONT_CODE:
1802 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
1807 enable = cur.selection();
1811 enable = lyx::cap::numberOfSelections() > 0;
1814 case LFUN_PARAGRAPH_MOVE_UP: {
1815 enable = cur.pit() > 0 && !cur.selection();
1819 case LFUN_PARAGRAPH_MOVE_DOWN: {
1820 enable = cur.pit() < cur.lastpit() && !cur.selection();
1824 case LFUN_WORD_DELETE_FORWARD:
1825 case LFUN_WORD_DELETE_BACKWARD:
1826 case LFUN_LINE_DELETE:
1827 case LFUN_WORD_FORWARD:
1828 case LFUN_WORD_BACKWARD:
1829 case LFUN_CHAR_FORWARD:
1830 case LFUN_CHAR_FORWARD_SELECT:
1831 case LFUN_CHAR_BACKWARD:
1832 case LFUN_CHAR_BACKWARD_SELECT:
1834 case LFUN_UP_SELECT:
1836 case LFUN_DOWN_SELECT:
1837 case LFUN_PARAGRAPH_UP_SELECT:
1838 case LFUN_PARAGRAPH_DOWN_SELECT:
1839 case LFUN_SCREEN_UP_SELECT:
1840 case LFUN_SCREEN_DOWN_SELECT:
1841 case LFUN_LINE_BEGIN_SELECT:
1842 case LFUN_LINE_END_SELECT:
1843 case LFUN_WORD_FORWARD_SELECT:
1844 case LFUN_WORD_BACKWARD_SELECT:
1845 case LFUN_WORD_SELECT:
1846 case LFUN_PARAGRAPH_UP:
1847 case LFUN_PARAGRAPH_DOWN:
1848 case LFUN_SCREEN_UP:
1849 case LFUN_SCREEN_DOWN:
1850 case LFUN_LINE_BEGIN:
1852 case LFUN_BREAK_LINE:
1853 case LFUN_CHAR_DELETE_FORWARD:
1854 case LFUN_DELETE_FORWARD_SKIP:
1855 case LFUN_CHAR_DELETE_BACKWARD:
1856 case LFUN_DELETE_BACKWARD_SKIP:
1857 case LFUN_BREAK_PARAGRAPH:
1858 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
1859 case LFUN_BREAK_PARAGRAPH_SKIP:
1860 case LFUN_PARAGRAPH_SPACING:
1861 case LFUN_INSET_INSERT:
1862 case LFUN_NEXT_INSET_TOGGLE:
1863 case LFUN_WORD_UPCASE:
1864 case LFUN_WORD_LOWCASE:
1865 case LFUN_WORD_CAPITALIZE:
1866 case LFUN_CHARS_TRANSPOSE:
1867 case LFUN_SERVER_GET_XY:
1868 case LFUN_SERVER_SET_XY:
1869 case LFUN_SERVER_GET_FONT:
1870 case LFUN_SERVER_GET_LAYOUT:
1872 case LFUN_PRIMARY_SELECTION_PASTE:
1873 case LFUN_DATE_INSERT:
1874 case LFUN_SELF_INSERT:
1875 case LFUN_LINE_INSERT:
1876 case LFUN_PAGEBREAK_INSERT:
1877 case LFUN_MATH_DISPLAY:
1878 case LFUN_MATH_IMPORT_SELECTION:
1879 case LFUN_MATH_MODE:
1880 case LFUN_MATH_MACRO:
1881 case LFUN_MATH_INSERT:
1882 case LFUN_MATH_MATRIX:
1883 case LFUN_MATH_DELIM:
1884 case LFUN_MATH_BIGDELIM:
1885 case LFUN_MATH_SUBSCRIPT:
1886 case LFUN_MATH_SUPERSCRIPT:
1887 case LFUN_FONT_DEFAULT:
1888 case LFUN_FONT_UNDERLINE:
1889 case LFUN_FONT_SIZE:
1891 case LFUN_FONT_FREE_APPLY:
1892 case LFUN_FONT_FREE_UPDATE:
1893 case LFUN_LAYOUT_PARAGRAPH:
1894 case LFUN_PARAGRAPH_UPDATE:
1895 case LFUN_ACCENT_UMLAUT:
1896 case LFUN_ACCENT_CIRCUMFLEX:
1897 case LFUN_ACCENT_GRAVE:
1898 case LFUN_ACCENT_ACUTE:
1899 case LFUN_ACCENT_TILDE:
1900 case LFUN_ACCENT_CEDILLA:
1901 case LFUN_ACCENT_MACRON:
1902 case LFUN_ACCENT_DOT:
1903 case LFUN_ACCENT_UNDERDOT:
1904 case LFUN_ACCENT_UNDERBAR:
1905 case LFUN_ACCENT_CARON:
1906 case LFUN_ACCENT_SPECIAL_CARON:
1907 case LFUN_ACCENT_BREVE:
1908 case LFUN_ACCENT_TIE:
1909 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1910 case LFUN_ACCENT_CIRCLE:
1911 case LFUN_ACCENT_OGONEK:
1912 case LFUN_CHANGE_ACCEPT:
1913 case LFUN_CHANGE_REJECT:
1914 case LFUN_THESAURUS_ENTRY:
1915 case LFUN_PARAGRAPH_PARAMS_APPLY:
1917 case LFUN_BUFFER_END:
1918 case LFUN_BUFFER_BEGIN:
1919 case LFUN_BUFFER_BEGIN_SELECT:
1920 case LFUN_BUFFER_END_SELECT:
1921 // these are handled in our dispatch()
1929 if (code != InsetBase::NO_CODE
1930 && (cur.empty() || !cur.inset().insetAllowed(code)))
1933 flag.enabled(enable);