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>
77 using lyx::cap::copySelection;
78 using lyx::cap::cutSelection;
79 using lyx::cap::pasteSelection;
80 using lyx::cap::replaceSelection;
82 using lyx::support::isStrUnsignedInt;
83 using lyx::support::token;
87 using std::istringstream;
88 using std::ostringstream;
91 extern string current_layout;
97 LyXFont freefont(LyXFont::ALL_IGNORE);
98 bool toggleall = false;
101 void toggleAndShow(LCursor & cur, LyXText * text,
102 LyXFont const & font, bool toggleall = true)
104 text->toggleFree(cur, font, toggleall);
106 if (font.language() != ignore_language ||
107 font.number() != LyXFont::IGNORE) {
108 Paragraph & par = cur.paragraph();
109 text->bidi.computeTables(par, cur.buffer(), cur.textRow());
110 if (cur.boundary() !=
111 text->bidi.isBoundary(cur.buffer(), par,
113 text->real_current_font))
114 text->setCursor(cur, cur.pit(), cur.pos(),
115 false, !cur.boundary());
120 void moveCursor(LCursor & cur, bool selecting)
122 if (selecting || cur.mark())
124 if (!cur.selection())
125 theSelection().haveSelection(false);
126 cur.bv().switchKeyMap();
130 void finishChange(LCursor & cur, bool selecting)
133 moveCursor(cur, selecting);
137 void mathDispatch(LCursor & cur, FuncRequest const & cmd, bool display)
140 string sel = lyx::to_utf8(cur.selectionAsString(false));
141 //lyxerr << "selection is: '" << sel << "'" << endl;
143 // It may happen that sel is empty but there is a selection
144 replaceSelection(cur);
147 const int old_pos = cur.pos();
148 cur.insert(new InsetMathHull(hullSimple));
149 BOOST_ASSERT(old_pos == cur.pos());
150 cur.nextInset()->edit(cur, true);
151 // don't do that also for LFUN_MATH_MODE
152 // unless you want end up with always changing
153 // to mathrm when opening an inlined inset --
154 // I really hate "LyXfunc overloading"...
156 cur.dispatch(FuncRequest(LFUN_MATH_DISPLAY));
157 // Avoid an unnecessary undo step if cmd.argument
159 if (!cmd.argument().empty())
160 cur.dispatch(FuncRequest(LFUN_MATH_INSERT,
163 // create a macro if we see "\\newcommand"
164 // somewhere, and an ordinary formula
166 istringstream is(sel);
167 if (sel.find("\\newcommand") == string::npos
168 && sel.find("\\def") == string::npos)
170 InsetMathHull * formula = new InsetMathHull;
173 formula->read(cur.buffer(), lex);
174 if (formula->getType() == hullNone)
175 // Don't create pseudo formulas if
176 // delimiters are left out
177 formula->mutate(hullSimple);
180 cur.insert(new MathMacroTemplate(is));
182 cur.message(lyx::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 lyx::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 lyx::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 lyx::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);
287 void update(LCursor & cur)
289 //we don't call update(true, false) directly to save a metrics call
290 if (cur.bv().fitCursor())
291 cur.bv().update(Update::Force);
298 void LyXText::number(LCursor & cur)
300 LyXFont font(LyXFont::ALL_IGNORE);
301 font.setNumber(LyXFont::TOGGLE);
302 toggleAndShow(cur, this, font);
306 bool LyXText::isRTL(Paragraph const & par) const
308 return par.isRightToLeftPar(bv()->buffer()->params());
312 void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
314 lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl;
316 BOOST_ASSERT(cur.text() == this);
317 BufferView * bv = &cur.bv();
318 CursorSlice oldTopSlice = cur.top();
319 bool oldBoundary = cur.boundary();
320 bool sel = cur.selection();
321 // Signals that, even if needsUpdate == false, an update of the
322 // cursor paragraph is required
323 bool singleParUpdate = lyxaction.funcHasFlag(cmd.action,
324 LyXAction::SingleParUpdate);
325 // Signals that a full-screen update is required
326 bool needsUpdate = !(lyxaction.funcHasFlag(cmd.action,
327 LyXAction::NoUpdate) || singleParUpdate);
328 // Remember the old paragraph metric (_outer_ paragraph!)
329 Dimension olddim = cur.bottom().paragraph().dim();
331 switch (cmd.action) {
333 case LFUN_PARAGRAPH_MOVE_DOWN: {
334 pit_type const pit = cur.pit();
335 recUndo(pit, pit + 1);
337 std::swap(pars_[pit], pars_[pit + 1]);
339 ParIterator begin(cur);
341 ParIterator end = boost::next(ParIterator(cur));
342 updateLabels(cur.buffer(), begin, end);
348 case LFUN_PARAGRAPH_MOVE_UP: {
349 pit_type const pit = cur.pit();
350 recUndo(pit - 1, pit);
352 std::swap(pars_[pit], pars_[pit - 1]);
354 ParIterator end = boost::next(ParIterator(cur));
356 ParIterator begin(cur);
357 updateLabels(cur.buffer(), begin, end);
363 case LFUN_APPENDIX: {
364 Paragraph & par = cur.paragraph();
365 bool start = !par.params().startOfAppendix();
368 #warning The code below only makes sense at top level.
369 // Should LFUN_APPENDIX be restricted to top-level paragraphs?
371 // ensure that we have only one start_of_appendix in this document
372 for (pit_type tmp = 0, end = pars_.size(); tmp != end; ++tmp) {
373 if (pars_[tmp].params().startOfAppendix()) {
375 pars_[tmp].params().startOfAppendix(false);
381 par.params().startOfAppendix(start);
383 // we can set the refreshing parameters now
384 updateLabels(cur.buffer());
388 case LFUN_WORD_DELETE_FORWARD:
389 cur.clearSelection();
390 deleteWordForward(cur);
391 finishChange(cur, false);
394 case LFUN_WORD_DELETE_BACKWARD:
395 cur.clearSelection();
396 deleteWordBackward(cur);
397 finishChange(cur, false);
400 case LFUN_LINE_DELETE:
401 cur.clearSelection();
402 deleteLineForward(cur);
403 finishChange(cur, false);
406 case LFUN_BUFFER_BEGIN:
407 case LFUN_BUFFER_BEGIN_SELECT:
408 cur.selHandle(cmd.action == LFUN_BUFFER_BEGIN_SELECT);
409 if (cur.depth() == 1) {
410 needsUpdate = cursorTop(cur);
416 case LFUN_BUFFER_END:
417 case LFUN_BUFFER_END_SELECT:
418 cur.selHandle(cmd.action == LFUN_BUFFER_END_SELECT);
419 if (cur.depth() == 1) {
420 needsUpdate = cursorBottom(cur);
426 case LFUN_CHAR_FORWARD:
427 case LFUN_CHAR_FORWARD_SELECT:
428 //lyxerr << BOOST_CURRENT_FUNCTION
429 // << " LFUN_CHAR_FORWARD[SEL]:\n" << cur << endl;
430 cur.selHandle(cmd.action == LFUN_CHAR_FORWARD_SELECT);
431 if (isRTL(cur.paragraph()))
432 needsUpdate = cursorLeft(cur);
434 needsUpdate = cursorRight(cur);
436 if (!needsUpdate && oldTopSlice == cur.top()
437 && cur.boundary() == oldBoundary) {
439 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
443 case LFUN_CHAR_BACKWARD:
444 case LFUN_CHAR_BACKWARD_SELECT:
445 //lyxerr << "handle LFUN_CHAR_BACKWARD[_SELECT]:\n" << cur << endl;
446 cur.selHandle(cmd.action == LFUN_CHAR_BACKWARD_SELECT);
447 if (isRTL(cur.paragraph()))
448 needsUpdate = cursorRight(cur);
450 needsUpdate = cursorLeft(cur);
452 if (!needsUpdate && oldTopSlice == cur.top()
453 && cur.boundary() == oldBoundary) {
455 cmd = FuncRequest(LFUN_FINISHED_LEFT);
462 //lyxerr << "handle LFUN_UP[SEL]:\n" << cur << endl;
463 cur.selHandle(cmd.action == LFUN_UP_SELECT);
465 needsUpdate = cursorUp(cur);
466 if (!needsUpdate && oldTopSlice == cur.top()
467 && cur.boundary() == oldBoundary) {
469 cmd = FuncRequest(LFUN_FINISHED_UP);
474 case LFUN_DOWN_SELECT:
476 //lyxerr << "handle LFUN_DOWN[SEL]:\n" << cur << endl;
477 cur.selHandle(cmd.action == LFUN_DOWN_SELECT);
478 needsUpdate = cursorDown(cur);
479 if (!needsUpdate && oldTopSlice == cur.top() &&
480 cur.boundary() == oldBoundary)
483 cmd = FuncRequest(LFUN_FINISHED_DOWN);
487 case LFUN_PARAGRAPH_UP:
488 case LFUN_PARAGRAPH_UP_SELECT:
489 cur.selHandle(cmd.action == LFUN_PARAGRAPH_UP_SELECT);
490 needsUpdate = cursorUpParagraph(cur);
493 case LFUN_PARAGRAPH_DOWN:
494 case LFUN_PARAGRAPH_DOWN_SELECT:
495 cur.selHandle(cmd.action == LFUN_PARAGRAPH_DOWN_SELECT);
496 needsUpdate = cursorDownParagraph(cur);
500 case LFUN_SCREEN_UP_SELECT:
502 cur.selHandle(cmd.action == LFUN_SCREEN_UP_SELECT);
503 if (cur.pit() == 0 && cur.textRow().pos() == 0) {
505 cmd = FuncRequest(LFUN_FINISHED_UP);
507 needsUpdate = cursorPrevious(cur);
511 case LFUN_SCREEN_DOWN:
512 case LFUN_SCREEN_DOWN_SELECT:
514 cur.selHandle(cmd.action == LFUN_SCREEN_DOWN_SELECT);
515 if (cur.pit() == cur.lastpit()
516 && cur.textRow().endpos() == cur.lastpos()) {
518 cmd = FuncRequest(LFUN_FINISHED_DOWN);
520 needsUpdate = cursorNext(cur);
524 case LFUN_LINE_BEGIN:
525 case LFUN_LINE_BEGIN_SELECT:
527 cur.selHandle(cmd.action == LFUN_LINE_BEGIN_SELECT);
528 needsUpdate = cursorHome(cur);
532 case LFUN_LINE_END_SELECT:
534 cur.selHandle(cmd.action == LFUN_LINE_END_SELECT);
535 needsUpdate = cursorEnd(cur);
538 case LFUN_WORD_FORWARD:
539 case LFUN_WORD_FORWARD_SELECT:
540 cur.selHandle(cmd.action == LFUN_WORD_FORWARD_SELECT);
541 if (isRTL(cur.paragraph()))
542 needsUpdate = cursorLeftOneWord(cur);
544 needsUpdate = cursorRightOneWord(cur);
547 case LFUN_WORD_BACKWARD:
548 case LFUN_WORD_BACKWARD_SELECT:
549 cur.selHandle(cmd.action == LFUN_WORD_BACKWARD_SELECT);
550 if (isRTL(cur.paragraph()))
551 needsUpdate = cursorRightOneWord(cur);
553 needsUpdate = cursorLeftOneWord(cur);
556 case LFUN_WORD_SELECT: {
557 selectWord(cur, lyx::WHOLE_WORD);
558 finishChange(cur, true);
562 case LFUN_BREAK_LINE: {
563 // Not allowed by LaTeX (labels or empty par)
564 if (cur.pos() > cur.paragraph().beginOfBody()) {
565 lyx::cap::replaceSelection(cur);
566 cur.insert(new InsetNewline);
568 moveCursor(cur, false);
573 case LFUN_CHAR_DELETE_FORWARD:
574 if (!cur.selection()) {
575 if (cur.pos() == cur.paragraph().size())
576 // Par boundary, force full-screen update
577 singleParUpdate = false;
578 needsUpdate = erase(cur);
580 // It is possible to make it a lot faster still
581 // just comment out the line below...
583 cutSelection(cur, true, false);
584 singleParUpdate = false;
586 moveCursor(cur, false);
589 case LFUN_DELETE_FORWARD_SKIP:
590 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
591 if (!cur.selection()) {
592 if (cur.pos() == cur.lastpos()) {
599 cutSelection(cur, true, false);
604 case LFUN_CHAR_DELETE_BACKWARD:
605 if (!cur.selection()) {
606 if (bv->getIntl().getTransManager().backspace()) {
607 // Par boundary, full-screen update
609 singleParUpdate = false;
610 needsUpdate = backspace(cur);
612 // It is possible to make it a lot faster still
613 // just comment out the line below...
616 cutSelection(cur, true, false);
617 singleParUpdate = false;
622 case LFUN_DELETE_BACKWARD_SKIP:
623 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
624 if (!cur.selection()) {
628 //CursorSlice cur = cursor();
632 cutSelection(cur, true, false);
636 case LFUN_BREAK_PARAGRAPH:
637 lyx::cap::replaceSelection(cur);
638 breakParagraph(cur, 0);
643 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
644 lyx::cap::replaceSelection(cur);
645 breakParagraph(cur, 1);
650 case LFUN_BREAK_PARAGRAPH_SKIP: {
651 // When at the beginning of a paragraph, remove
652 // indentation. Otherwise, do the same as LFUN_BREAK_PARAGRAPH.
653 lyx::cap::replaceSelection(cur);
655 cur.paragraph().params().labelWidthString(docstring());
657 breakParagraph(cur, 0);
663 case LFUN_PARAGRAPH_SPACING: {
664 Paragraph & par = cur.paragraph();
665 Spacing::Space cur_spacing = par.params().spacing().getSpace();
666 string cur_value = "1.0";
667 if (cur_spacing == Spacing::Other)
668 cur_value = par.params().spacing().getValueAsString();
670 istringstream is(lyx::to_utf8(cmd.argument()));
673 Spacing::Space new_spacing = cur_spacing;
674 string new_value = cur_value;
676 lyxerr << "Missing argument to `paragraph-spacing'"
678 } else if (tmp == "single") {
679 new_spacing = Spacing::Single;
680 } else if (tmp == "onehalf") {
681 new_spacing = Spacing::Onehalf;
682 } else if (tmp == "double") {
683 new_spacing = Spacing::Double;
684 } else if (tmp == "other") {
685 new_spacing = Spacing::Other;
686 string tmpval = "0.0";
688 lyxerr << "new_value = " << tmpval << endl;
691 } else if (tmp == "default") {
692 new_spacing = Spacing::Default;
694 lyxerr << lyx::to_utf8(_("Unknown spacing argument: "))
695 << lyx::to_utf8(cmd.argument()) << endl;
697 if (cur_spacing != new_spacing || cur_value != new_value)
698 par.params().spacing(Spacing(new_spacing, new_value));
702 case LFUN_INSET_INSERT: {
704 InsetBase * inset = createInset(bv, cmd);
706 insertInset(cur, inset);
712 case LFUN_INSET_DISSOLVE:
713 needsUpdate = dissolveInset(cur);
716 case LFUN_INSET_SETTINGS:
717 cur.inset().showInsetDialog(bv);
720 case LFUN_SPACE_INSERT:
721 if (cur.paragraph().layout()->free_spacing)
722 insertChar(cur, ' ');
724 doInsertInset(cur, this, cmd, false, false);
727 moveCursor(cur, false);
730 case LFUN_HYPHENATION_POINT_INSERT:
731 specialChar(cur, InsetSpecialChar::HYPHENATION);
734 case LFUN_LIGATURE_BREAK_INSERT:
735 specialChar(cur, InsetSpecialChar::LIGATURE_BREAK);
738 case LFUN_DOTS_INSERT:
739 specialChar(cur, InsetSpecialChar::LDOTS);
742 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
743 specialChar(cur, InsetSpecialChar::END_OF_SENTENCE);
746 case LFUN_MENU_SEPARATOR_INSERT:
747 specialChar(cur, InsetSpecialChar::MENU_SEPARATOR);
750 case LFUN_WORD_UPCASE:
751 changeCase(cur, LyXText::text_uppercase);
754 case LFUN_WORD_LOWCASE:
755 changeCase(cur, LyXText::text_lowercase);
758 case LFUN_WORD_CAPITALIZE:
759 changeCase(cur, LyXText::text_capitalization);
762 case LFUN_CHARS_TRANSPOSE:
767 cur.message(_("Paste"));
768 lyx::cap::replaceSelection(cur);
769 if (isStrUnsignedInt(lyx::to_utf8(cmd.argument())))
770 pasteSelection(cur, bv->buffer()->errorList("Paste"),
771 convert<unsigned int>(lyx::to_utf8(cmd.argument())));
773 pasteSelection(cur, bv->buffer()->errorList("Paste"),
775 bv->buffer()->errors("Paste");
776 cur.clearSelection(); // bug 393
782 cutSelection(cur, true, true);
783 cur.message(_("Cut"));
788 cur.message(_("Copy"));
791 case LFUN_SERVER_GET_XY:
792 cur.message(lyx::from_utf8(
793 convert<string>(cursorX(cur.top(), cur.boundary())) + ' '
794 + convert<string>(cursorY(cur.top(), cur.boundary()))));
797 case LFUN_SERVER_SET_XY: {
800 istringstream is(lyx::to_utf8(cmd.argument()));
803 lyxerr << "SETXY: Could not parse coordinates in '"
804 << lyx::to_utf8(cmd.argument()) << std::endl;
806 setCursorFromCoordinates(cur, x, y);
810 case LFUN_SERVER_GET_FONT:
811 if (current_font.shape() == LyXFont::ITALIC_SHAPE)
812 cur.message(lyx::from_ascii("E"));
813 else if (current_font.shape() == LyXFont::SMALLCAPS_SHAPE)
814 cur.message(lyx::from_ascii("N"));
816 cur.message(lyx::from_ascii("0"));
819 case LFUN_SERVER_GET_LAYOUT:
820 cur.message(lyx::from_utf8(cur.paragraph().layout()->name()));
824 lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) "
825 << lyx::to_utf8(cmd.argument()) << endl;
827 // This is not the good solution to the empty argument
828 // problem, but it will hopefully suffice for 1.2.0.
829 // The correct solution would be to augument the
830 // function list/array with information about what
831 // functions needs arguments and their type.
832 if (cmd.argument().empty()) {
833 cur.errorMessage(_("LyX function 'layout' needs an argument."));
837 // Derive layout number from given argument (string)
838 // and current buffer's textclass (number)
839 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
840 bool hasLayout = tclass.hasLayout(lyx::to_utf8(cmd.argument()));
841 string layout = lyx::to_utf8(cmd.argument());
843 // If the entry is obsolete, use the new one instead.
845 string const & obs = tclass[layout]->obsoleted_by();
851 cur.errorMessage(lyx::from_utf8(N_("Layout ")) + cmd.argument() +
852 lyx::from_utf8(N_(" not known")));
856 bool change_layout = (current_layout != layout);
858 if (!change_layout && cur.selection() &&
859 cur.selBegin().pit() != cur.selEnd().pit())
861 pit_type spit = cur.selBegin().pit();
862 pit_type epit = cur.selEnd().pit() + 1;
863 while (spit != epit) {
864 if (pars_[spit].layout()->name() != current_layout) {
865 change_layout = true;
873 current_layout = layout;
874 setLayout(cur, layout);
875 // inform the GUI that the layout has changed.
876 bv->layoutChanged(layout);
882 case LFUN_CLIPBOARD_PASTE: {
883 cur.clearSelection();
884 docstring const clip = theClipboard().get();
887 if (cmd.argument() == "paragraph")
888 insertStringAsParagraphs(cur, clip);
890 insertStringAsLines(cur, clip);
895 case LFUN_PRIMARY_SELECTION_PASTE: {
896 cur.clearSelection();
897 docstring const clip = theSelection().get();
900 if (cmd.argument() == "paragraph")
901 insertStringAsParagraphs(cur, clip);
903 insertStringAsLines(cur, clip);
908 case LFUN_QUOTE_INSERT: {
909 lyx::cap::replaceSelection(cur);
910 Paragraph & par = cur.paragraph();
911 lyx::pos_type pos = cur.pos();
915 else if (cur.prevInset() && cur.prevInset()->isSpace())
918 c = par.getChar(pos - 1);
920 LyXLayout_ptr const & style = par.layout();
922 BufferParams const & bufparams = bv->buffer()->params();
923 if (!style->pass_thru
924 && par.getFontSettings(bufparams, pos).language()->lang() != "hebrew") {
925 string arg = lyx::to_utf8(cmd.argument());
927 cur.insert(new InsetQuotes(c,
928 bufparams.quotes_language,
929 InsetQuotes::SingleQ));
931 cur.insert(new InsetQuotes(c,
932 bufparams.quotes_language,
933 InsetQuotes::DoubleQ));
937 lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, "\""));
941 case LFUN_DATE_INSERT:
942 if (cmd.argument().empty())
943 lyx::dispatch(FuncRequest(LFUN_SELF_INSERT,
944 lyx::formatted_time(lyx::current_time())));
946 lyx::dispatch(FuncRequest(LFUN_SELF_INSERT,
947 lyx::formatted_time(lyx::current_time(), lyx::to_utf8(cmd.argument()))));
950 case LFUN_MOUSE_TRIPLE:
951 if (cmd.button() == mouse_button::button1) {
957 theSelection().haveSelection(cur.selection());
961 case LFUN_MOUSE_DOUBLE:
962 if (cmd.button() == mouse_button::button1) {
963 selectWord(cur, lyx::WHOLE_WORD_STRICT);
965 theSelection().haveSelection(cur.selection());
969 // Single-click on work area
970 case LFUN_MOUSE_PRESS: {
971 // Right click on a footnote flag opens float menu
972 if (cmd.button() == mouse_button::button3)
973 cur.clearSelection();
975 // Middle button press pastes if we have a selection
976 // We do this here as if the selection was inside an inset
977 // it could get cleared on the unlocking of the inset so
978 // we have to check this first
979 bool paste_internally = false;
980 if (cmd.button() == mouse_button::button2 && cur.selection()) {
981 lyx::dispatch(FuncRequest(LFUN_COPY));
982 paste_internally = true;
985 bv->mouseSetCursor(cur);
987 // Insert primary selection with middle mouse
988 // if there is a local selection in the current buffer,
990 if (cmd.button() == mouse_button::button2) {
991 if (paste_internally)
992 lyx::dispatch(FuncRequest(LFUN_PASTE));
994 lyx::dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph"));
1000 case LFUN_MOUSE_MOTION: {
1001 // Only use motion with button 1
1002 //if (cmd.button() != mouse_button::button1)
1005 // ignore motions deeper nested than the real anchor
1006 LCursor & bvcur = cur.bv().cursor();
1007 if (bvcur.anchor_.hasPart(cur)) {
1008 CursorSlice old = bvcur.top();
1010 int const wh = bv->workHeight();
1011 int const y = std::max(0, std::min(wh - 1, cmd.y));
1013 setCursorFromCoordinates(cur, cmd.x, y);
1014 cur.x_target() = cmd.x;
1019 // This is to allow jumping over large insets
1020 if (cur.top() == old) {
1027 if (cur.top() == old)
1030 // don't set anchor_
1031 bvcur.setCursor(cur);
1032 bvcur.selection() = true;
1033 //lyxerr << "MOTION: " << bv->cursor() << endl;
1041 case LFUN_MOUSE_RELEASE: {
1042 if (cmd.button() == mouse_button::button2)
1046 if (cmd.button() == mouse_button::button1)
1047 theSelection().haveSelection(cur.selection());
1053 case LFUN_SELF_INSERT: {
1054 if (cmd.argument().empty())
1057 // Automatically delete the currently selected
1058 // text and replace it with what is being
1059 // typed in now. Depends on lyxrc settings
1060 // "auto_region_delete", which defaults to
1063 if (lyxrc.auto_region_delete) {
1064 if (cur.selection())
1065 cutSelection(cur, false, false);
1066 theSelection().haveSelection(false);
1069 cur.clearSelection();
1070 LyXFont const old_font = real_current_font;
1072 docstring::const_iterator cit = cmd.argument().begin();
1073 docstring::const_iterator end = cmd.argument().end();
1074 for (; cit != end; ++cit)
1076 bv->getIntl().getTransManager().
1077 translateAndInsert(*cit, this);
1079 insertChar(bv->cursor(), *cit);
1083 moveCursor(cur, false);
1087 case LFUN_URL_INSERT: {
1088 InsetCommandParams p("url");
1089 string const data = InsetCommandMailer::params2string("url", p);
1090 bv->showInsetDialog("url", data, 0);
1094 case LFUN_HTML_INSERT: {
1095 InsetCommandParams p("htmlurl");
1096 string const data = InsetCommandMailer::params2string("url", p);
1097 bv->showInsetDialog("url", data, 0);
1101 case LFUN_LABEL_INSERT: {
1102 InsetCommandParams p("label");
1103 // Try to generate a valid label
1104 p["name"] = (cmd.argument().empty()) ?
1106 lyx::from_utf8(cur.getPossibleLabel()) :
1108 string const data = InsetCommandMailer::params2string("label", p);
1110 if (cmd.argument().empty()) {
1111 bv->showInsetDialog("label", data, 0);
1113 FuncRequest fr(LFUN_INSET_INSERT, data);
1121 case LFUN_LIST_INSERT:
1122 case LFUN_THEOREM_INSERT:
1123 case LFUN_CAPTION_INSERT:
1125 case LFUN_NOTE_INSERT:
1126 case LFUN_CHARSTYLE_INSERT:
1127 case LFUN_BOX_INSERT:
1128 case LFUN_BRANCH_INSERT:
1129 case LFUN_BIBITEM_INSERT:
1130 case LFUN_ERT_INSERT:
1131 case LFUN_FOOTNOTE_INSERT:
1132 case LFUN_MARGINALNOTE_INSERT:
1133 case LFUN_OPTIONAL_INSERT:
1134 case LFUN_ENVIRONMENT_INSERT:
1135 // Open the inset, and move the current selection
1137 doInsertInset(cur, this, cmd, true, true);
1141 case LFUN_TABULAR_INSERT:
1142 // if there were no arguments, just open the dialog
1143 if (doInsertInset(cur, this, cmd, false, true))
1146 bv->showDialog("tabularcreate");
1150 case LFUN_FLOAT_INSERT:
1151 case LFUN_FLOAT_WIDE_INSERT:
1152 case LFUN_WRAP_INSERT:
1153 doInsertInset(cur, this, cmd, true, true);
1155 // FIXME: the "Caption" name should not be hardcoded,
1156 // but given by the float definition.
1157 cur.dispatch(FuncRequest(LFUN_LAYOUT, "Caption"));
1160 case LFUN_INDEX_INSERT: {
1161 InsetBase * inset = createInset(&cur.bv(), cmd);
1166 cur.clearSelection();
1167 insertInset(cur, inset);
1168 inset->edit(cur, true);
1173 case LFUN_INDEX_PRINT:
1174 case LFUN_TOC_INSERT:
1175 case LFUN_HFILL_INSERT:
1176 case LFUN_LINE_INSERT:
1177 case LFUN_PAGEBREAK_INSERT:
1179 doInsertInset(cur, this, cmd, false, false);
1183 case LFUN_DEPTH_DECREMENT:
1184 changeDepth(cur, DEC_DEPTH);
1187 case LFUN_DEPTH_INCREMENT:
1188 changeDepth(cur, INC_DEPTH);
1191 case LFUN_MATH_DISPLAY:
1192 mathDispatch(cur, cmd, true);
1195 case LFUN_MATH_IMPORT_SELECTION:
1196 case LFUN_MATH_MODE:
1197 if (cmd.argument() == "on")
1198 // don't pass "on" as argument
1199 mathDispatch(cur, FuncRequest(LFUN_MATH_MODE), false);
1201 mathDispatch(cur, cmd, false);
1204 case LFUN_MATH_MACRO:
1205 if (cmd.argument().empty())
1206 cur.errorMessage(lyx::from_utf8(N_("Missing argument")));
1208 string s = lyx::to_utf8(cmd.argument());
1209 string const s1 = token(s, ' ', 1);
1210 int const nargs = s1.empty() ? 0 : convert<int>(s1);
1211 string const s2 = token(s, ' ', 2);
1212 string const type = s2.empty() ? "newcommand" : s2;
1213 cur.insert(new MathMacroTemplate(token(s, ' ', 0), nargs, type));
1214 //cur.nextInset()->edit(cur, true);
1218 // passthrough hat and underscore outside mathed:
1219 case LFUN_MATH_SUBSCRIPT:
1220 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "_"), false);
1222 case LFUN_MATH_SUPERSCRIPT:
1223 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "^"), false);
1226 case LFUN_MATH_INSERT:
1227 case LFUN_MATH_MATRIX:
1228 case LFUN_MATH_DELIM:
1229 case LFUN_MATH_BIGDELIM: {
1230 cur.insert(new InsetMathHull(hullSimple));
1231 cur.dispatch(FuncRequest(LFUN_CHAR_FORWARD));
1236 case LFUN_FONT_EMPH: {
1237 LyXFont font(LyXFont::ALL_IGNORE);
1238 font.setEmph(LyXFont::TOGGLE);
1239 toggleAndShow(cur, this, font);
1243 case LFUN_FONT_BOLD: {
1244 LyXFont font(LyXFont::ALL_IGNORE);
1245 font.setSeries(LyXFont::BOLD_SERIES);
1246 toggleAndShow(cur, this, font);
1250 case LFUN_FONT_NOUN: {
1251 LyXFont font(LyXFont::ALL_IGNORE);
1252 font.setNoun(LyXFont::TOGGLE);
1253 toggleAndShow(cur, this, font);
1257 case LFUN_FONT_CODE: {
1258 LyXFont font(LyXFont::ALL_IGNORE);
1259 font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
1260 toggleAndShow(cur, this, font);
1264 case LFUN_FONT_SANS: {
1265 LyXFont font(LyXFont::ALL_IGNORE);
1266 font.setFamily(LyXFont::SANS_FAMILY);
1267 toggleAndShow(cur, this, font);
1271 case LFUN_FONT_ROMAN: {
1272 LyXFont font(LyXFont::ALL_IGNORE);
1273 font.setFamily(LyXFont::ROMAN_FAMILY);
1274 toggleAndShow(cur, this, font);
1278 case LFUN_FONT_DEFAULT: {
1279 LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
1280 toggleAndShow(cur, this, font);
1284 case LFUN_FONT_UNDERLINE: {
1285 LyXFont font(LyXFont::ALL_IGNORE);
1286 font.setUnderbar(LyXFont::TOGGLE);
1287 toggleAndShow(cur, this, font);
1291 case LFUN_FONT_SIZE: {
1292 LyXFont font(LyXFont::ALL_IGNORE);
1293 font.setLyXSize(lyx::to_utf8(cmd.argument()));
1294 toggleAndShow(cur, this, font);
1298 case LFUN_LANGUAGE: {
1299 Language const * lang = languages.getLanguage(lyx::to_utf8(cmd.argument()));
1302 LyXFont font(LyXFont::ALL_IGNORE);
1303 font.setLanguage(lang);
1304 toggleAndShow(cur, this, font);
1309 case LFUN_FONT_FREE_APPLY:
1310 toggleAndShow(cur, this, freefont, toggleall);
1311 cur.message(_("Character set"));
1314 // Set the freefont using the contents of \param data dispatched from
1315 // the frontends and apply it at the current cursor location.
1316 case LFUN_FONT_FREE_UPDATE: {
1319 if (bv_funcs::string2font(lyx::to_utf8(cmd.argument()), font, toggle)) {
1322 toggleAndShow(cur, this, freefont, toggleall);
1323 cur.message(_("Character set"));
1328 case LFUN_FINISHED_LEFT:
1329 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_LEFT:\n" << cur << endl;
1332 case LFUN_FINISHED_RIGHT:
1333 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_RIGHT:\n" << cur << endl;
1337 case LFUN_FINISHED_UP:
1338 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_UP:\n" << cur << endl;
1342 case LFUN_FINISHED_DOWN:
1343 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_DOWN:\n" << cur << endl;
1347 case LFUN_LAYOUT_PARAGRAPH: {
1349 params2string(cur.paragraph(), data);
1350 data = "show\n" + data;
1351 bv->showDialogWithData("paragraph", data);
1355 case LFUN_PARAGRAPH_UPDATE: {
1357 params2string(cur.paragraph(), data);
1359 // Will the paragraph accept changes from the dialog?
1360 bool const accept = !cur.inset().forceDefaultParagraphs(cur.idx());
1362 data = "update " + convert<string>(accept) + '\n' + data;
1363 bv->updateDialog("paragraph", data);
1367 case LFUN_ACCENT_UMLAUT:
1368 case LFUN_ACCENT_CIRCUMFLEX:
1369 case LFUN_ACCENT_GRAVE:
1370 case LFUN_ACCENT_ACUTE:
1371 case LFUN_ACCENT_TILDE:
1372 case LFUN_ACCENT_CEDILLA:
1373 case LFUN_ACCENT_MACRON:
1374 case LFUN_ACCENT_DOT:
1375 case LFUN_ACCENT_UNDERDOT:
1376 case LFUN_ACCENT_UNDERBAR:
1377 case LFUN_ACCENT_CARON:
1378 case LFUN_ACCENT_SPECIAL_CARON:
1379 case LFUN_ACCENT_BREVE:
1380 case LFUN_ACCENT_TIE:
1381 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1382 case LFUN_ACCENT_CIRCLE:
1383 case LFUN_ACCENT_OGONEK:
1384 theLyXFunc().handleKeyFunc(cmd.action);
1385 if (!cmd.argument().empty())
1386 // FIXME: Are all these characters encoded in one byte in utf8?
1387 bv->getIntl().getTransManager()
1388 .translateAndInsert(cmd.argument()[0], this);
1391 case LFUN_FLOAT_LIST: {
1392 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
1393 if (tclass.floats().typeExist(lyx::to_utf8(cmd.argument()))) {
1394 // not quite sure if we want this...
1396 cur.clearSelection();
1397 breakParagraph(cur);
1399 if (cur.lastpos() != 0) {
1401 breakParagraph(cur);
1404 setLayout(cur, tclass.defaultLayoutName());
1405 setParagraph(cur, Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
1406 insertInset(cur, new InsetFloatList(lyx::to_utf8(cmd.argument())));
1409 lyxerr << "Non-existent float type: "
1410 << lyx::to_utf8(cmd.argument()) << endl;
1415 case LFUN_CHANGE_ACCEPT: {
1420 case LFUN_CHANGE_REJECT: {
1425 case LFUN_THESAURUS_ENTRY: {
1426 docstring arg = cmd.argument();
1428 arg = cur.selectionAsString(false);
1430 if (arg.size() > 100 || arg.empty()) {
1431 // Get word or selection
1432 selectWordWhenUnderCursor(cur, lyx::WHOLE_WORD);
1433 arg = cur.selectionAsString(false);
1436 bv->showDialogWithData("thesaurus", lyx::to_utf8(arg));
1440 case LFUN_PARAGRAPH_PARAMS_APPLY: {
1441 // Given data, an encoding of the ParagraphParameters
1442 // generated in the Paragraph dialog, this function sets
1443 // the current paragraph appropriately.
1444 istringstream is(lyx::to_utf8(cmd.argument()));
1447 ParagraphParameters params;
1453 lyx::to_ascii(params.labelWidthString()),
1455 cur.message(_("Paragraph layout set"));
1460 if (cur.selection()) {
1461 cur.selection() = false;
1464 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
1469 lyxerr[Debug::ACTION]
1470 << BOOST_CURRENT_FUNCTION
1471 << ": Command " << cmd
1472 << " not DISPATCHED by LyXText" << endl;
1477 if (singleParUpdate)
1478 // Inserting characters does not change par height
1479 if (cur.bottom().paragraph().dim().height()
1480 == olddim.height()) {
1481 // if so, update _only_ this paragraph
1482 cur.bv().update(Update::SinglePar |
1484 Update::MultiParSel);
1490 && &oldTopSlice.inset() == &cur.inset()
1491 && oldTopSlice.idx() == cur.idx()
1493 && !cur.selection())
1500 bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
1501 FuncStatus & flag) const
1503 BOOST_ASSERT(cur.text() == this);
1505 LyXFont const & font = real_current_font;
1507 InsetBase::Code code = InsetBase::NO_CODE;
1509 switch (cmd.action) {
1511 case LFUN_DEPTH_DECREMENT:
1512 enable = changeDepthAllowed(cur, DEC_DEPTH);
1515 case LFUN_DEPTH_INCREMENT:
1516 enable = changeDepthAllowed(cur, INC_DEPTH);
1520 flag.setOnOff(cur.paragraph().params().startOfAppendix());
1523 case LFUN_BIBITEM_INSERT:
1524 enable = (cur.paragraph().layout()->labeltype == LABEL_BIBLIO);
1527 case LFUN_DIALOG_SHOW_NEW_INSET:
1528 if (cmd.argument() == "bibitem")
1529 code = InsetBase::BIBITEM_CODE;
1530 else if (cmd.argument() == "bibtex")
1531 code = InsetBase::BIBTEX_CODE;
1532 else if (cmd.argument() == "box")
1533 code = InsetBase::BOX_CODE;
1534 else if (cmd.argument() == "branch")
1535 code = InsetBase::BRANCH_CODE;
1536 else if (cmd.argument() == "citation")
1537 code = InsetBase::CITE_CODE;
1538 else if (cmd.argument() == "ert")
1539 code = InsetBase::ERT_CODE;
1540 else if (cmd.argument() == "external")
1541 code = InsetBase::EXTERNAL_CODE;
1542 else if (cmd.argument() == "float")
1543 code = InsetBase::FLOAT_CODE;
1544 else if (cmd.argument() == "graphics")
1545 code = InsetBase::GRAPHICS_CODE;
1546 else if (cmd.argument() == "include")
1547 code = InsetBase::INCLUDE_CODE;
1548 else if (cmd.argument() == "index")
1549 code = InsetBase::INDEX_CODE;
1550 else if (cmd.argument() == "label")
1551 code = InsetBase::LABEL_CODE;
1552 else if (cmd.argument() == "note")
1553 code = InsetBase::NOTE_CODE;
1554 else if (cmd.argument() == "ref")
1555 code = InsetBase::REF_CODE;
1556 else if (cmd.argument() == "toc")
1557 code = InsetBase::TOC_CODE;
1558 else if (cmd.argument() == "url")
1559 code = InsetBase::URL_CODE;
1560 else if (cmd.argument() == "vspace")
1561 code = InsetBase::VSPACE_CODE;
1562 else if (cmd.argument() == "wrap")
1563 code = InsetBase::WRAP_CODE;
1566 case LFUN_ERT_INSERT:
1567 code = InsetBase::ERT_CODE;
1569 case LFUN_FOOTNOTE_INSERT:
1570 code = InsetBase::FOOT_CODE;
1572 case LFUN_TABULAR_INSERT:
1573 code = InsetBase::TABULAR_CODE;
1575 case LFUN_MARGINALNOTE_INSERT:
1576 code = InsetBase::MARGIN_CODE;
1578 case LFUN_FLOAT_INSERT:
1579 case LFUN_FLOAT_WIDE_INSERT:
1580 code = InsetBase::FLOAT_CODE;
1582 case LFUN_WRAP_INSERT:
1583 code = InsetBase::WRAP_CODE;
1585 case LFUN_FLOAT_LIST:
1586 code = InsetBase::FLOAT_LIST_CODE;
1589 case LFUN_LIST_INSERT:
1590 code = InsetBase::LIST_CODE;
1592 case LFUN_THEOREM_INSERT:
1593 code = InsetBase::THEOREM_CODE;
1596 case LFUN_CAPTION_INSERT:
1597 code = InsetBase::CAPTION_CODE;
1599 case LFUN_NOTE_INSERT:
1600 code = InsetBase::NOTE_CODE;
1602 case LFUN_CHARSTYLE_INSERT:
1603 code = InsetBase::CHARSTYLE_CODE;
1604 if (cur.buffer().params().getLyXTextClass().charstyles().empty())
1607 case LFUN_BOX_INSERT:
1608 code = InsetBase::BOX_CODE;
1610 case LFUN_BRANCH_INSERT:
1611 code = InsetBase::BRANCH_CODE;
1612 if (cur.buffer().getMasterBuffer()->params().branchlist().empty())
1615 case LFUN_LABEL_INSERT:
1616 code = InsetBase::LABEL_CODE;
1618 case LFUN_OPTIONAL_INSERT:
1619 code = InsetBase::OPTARG_CODE;
1620 enable = numberOfOptArgs(cur.paragraph())
1621 < cur.paragraph().layout()->optionalargs;
1623 case LFUN_ENVIRONMENT_INSERT:
1624 code = InsetBase::BOX_CODE;
1626 case LFUN_INDEX_INSERT:
1627 code = InsetBase::INDEX_CODE;
1629 case LFUN_INDEX_PRINT:
1630 code = InsetBase::INDEX_PRINT_CODE;
1632 case LFUN_TOC_INSERT:
1633 code = InsetBase::TOC_CODE;
1635 case LFUN_HTML_INSERT:
1636 case LFUN_URL_INSERT:
1637 code = InsetBase::URL_CODE;
1639 case LFUN_QUOTE_INSERT:
1640 // always allow this, since we will inset a raw quote
1641 // if an inset is not allowed.
1643 case LFUN_HYPHENATION_POINT_INSERT:
1644 case LFUN_LIGATURE_BREAK_INSERT:
1645 case LFUN_HFILL_INSERT:
1646 case LFUN_MENU_SEPARATOR_INSERT:
1647 case LFUN_DOTS_INSERT:
1648 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
1649 code = InsetBase::SPECIALCHAR_CODE;
1651 case LFUN_SPACE_INSERT:
1652 // slight hack: we know this is allowed in math mode
1654 code = InsetBase::SPACE_CODE;
1657 case LFUN_INSET_MODIFY:
1658 // We need to disable this, because we may get called for a
1660 // InsetTabular::getStatus() -> InsetText::getStatus()
1661 // and we don't handle LFUN_INSET_MODIFY.
1665 case LFUN_FONT_EMPH:
1666 flag.setOnOff(font.emph() == LyXFont::ON);
1669 case LFUN_FONT_NOUN:
1670 flag.setOnOff(font.noun() == LyXFont::ON);
1673 case LFUN_FONT_BOLD:
1674 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
1677 case LFUN_FONT_SANS:
1678 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
1681 case LFUN_FONT_ROMAN:
1682 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
1685 case LFUN_FONT_CODE:
1686 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
1691 enable = cur.selection();
1695 enable = lyx::cap::numberOfSelections() > 0;
1698 case LFUN_PARAGRAPH_MOVE_UP:
1699 enable = cur.pit() > 0 && !cur.selection();
1702 case LFUN_PARAGRAPH_MOVE_DOWN:
1703 enable = cur.pit() < cur.lastpit() && !cur.selection();
1706 case LFUN_INSET_DISSOLVE:
1707 enable = !isMainText() && cur.inset().nargs() == 1;
1710 case LFUN_CHANGE_ACCEPT:
1711 case LFUN_CHANGE_REJECT:
1712 enable = true; // FIXME: Change tracking (MG)
1715 case LFUN_WORD_DELETE_FORWARD:
1716 case LFUN_WORD_DELETE_BACKWARD:
1717 case LFUN_LINE_DELETE:
1718 case LFUN_WORD_FORWARD:
1719 case LFUN_WORD_BACKWARD:
1720 case LFUN_CHAR_FORWARD:
1721 case LFUN_CHAR_FORWARD_SELECT:
1722 case LFUN_CHAR_BACKWARD:
1723 case LFUN_CHAR_BACKWARD_SELECT:
1725 case LFUN_UP_SELECT:
1727 case LFUN_DOWN_SELECT:
1728 case LFUN_PARAGRAPH_UP_SELECT:
1729 case LFUN_PARAGRAPH_DOWN_SELECT:
1730 case LFUN_SCREEN_UP_SELECT:
1731 case LFUN_SCREEN_DOWN_SELECT:
1732 case LFUN_LINE_BEGIN_SELECT:
1733 case LFUN_LINE_END_SELECT:
1734 case LFUN_WORD_FORWARD_SELECT:
1735 case LFUN_WORD_BACKWARD_SELECT:
1736 case LFUN_WORD_SELECT:
1737 case LFUN_PARAGRAPH_UP:
1738 case LFUN_PARAGRAPH_DOWN:
1739 case LFUN_SCREEN_UP:
1740 case LFUN_SCREEN_DOWN:
1741 case LFUN_LINE_BEGIN:
1743 case LFUN_BREAK_LINE:
1744 case LFUN_CHAR_DELETE_FORWARD:
1745 case LFUN_DELETE_FORWARD_SKIP:
1746 case LFUN_CHAR_DELETE_BACKWARD:
1747 case LFUN_DELETE_BACKWARD_SKIP:
1748 case LFUN_BREAK_PARAGRAPH:
1749 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
1750 case LFUN_BREAK_PARAGRAPH_SKIP:
1751 case LFUN_PARAGRAPH_SPACING:
1752 case LFUN_INSET_INSERT:
1753 case LFUN_WORD_UPCASE:
1754 case LFUN_WORD_LOWCASE:
1755 case LFUN_WORD_CAPITALIZE:
1756 case LFUN_CHARS_TRANSPOSE:
1757 case LFUN_SERVER_GET_XY:
1758 case LFUN_SERVER_SET_XY:
1759 case LFUN_SERVER_GET_FONT:
1760 case LFUN_SERVER_GET_LAYOUT:
1762 case LFUN_CLIPBOARD_PASTE:
1763 case LFUN_PRIMARY_SELECTION_PASTE:
1764 case LFUN_DATE_INSERT:
1765 case LFUN_SELF_INSERT:
1766 case LFUN_LINE_INSERT:
1767 case LFUN_PAGEBREAK_INSERT:
1768 case LFUN_MATH_DISPLAY:
1769 case LFUN_MATH_IMPORT_SELECTION:
1770 case LFUN_MATH_MODE:
1771 case LFUN_MATH_MACRO:
1772 case LFUN_MATH_MATRIX:
1773 case LFUN_MATH_DELIM:
1774 case LFUN_MATH_BIGDELIM:
1775 case LFUN_MATH_SUBSCRIPT:
1776 case LFUN_MATH_SUPERSCRIPT:
1777 case LFUN_FONT_DEFAULT:
1778 case LFUN_FONT_UNDERLINE:
1779 case LFUN_FONT_SIZE:
1781 case LFUN_FONT_FREE_APPLY:
1782 case LFUN_FONT_FREE_UPDATE:
1783 case LFUN_LAYOUT_PARAGRAPH:
1784 case LFUN_PARAGRAPH_UPDATE:
1785 case LFUN_ACCENT_UMLAUT:
1786 case LFUN_ACCENT_CIRCUMFLEX:
1787 case LFUN_ACCENT_GRAVE:
1788 case LFUN_ACCENT_ACUTE:
1789 case LFUN_ACCENT_TILDE:
1790 case LFUN_ACCENT_CEDILLA:
1791 case LFUN_ACCENT_MACRON:
1792 case LFUN_ACCENT_DOT:
1793 case LFUN_ACCENT_UNDERDOT:
1794 case LFUN_ACCENT_UNDERBAR:
1795 case LFUN_ACCENT_CARON:
1796 case LFUN_ACCENT_SPECIAL_CARON:
1797 case LFUN_ACCENT_BREVE:
1798 case LFUN_ACCENT_TIE:
1799 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1800 case LFUN_ACCENT_CIRCLE:
1801 case LFUN_ACCENT_OGONEK:
1802 case LFUN_THESAURUS_ENTRY:
1803 case LFUN_PARAGRAPH_PARAMS_APPLY:
1805 case LFUN_BUFFER_END:
1806 case LFUN_BUFFER_BEGIN:
1807 case LFUN_BUFFER_BEGIN_SELECT:
1808 case LFUN_BUFFER_END_SELECT:
1809 // these are handled in our dispatch()
1817 if (code != InsetBase::NO_CODE
1818 && (cur.empty() || !cur.inset().insetAllowed(code)))
1821 flag.enabled(enable);