3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Asger Alstrup
7 * \author Lars Gullik Bjønnes
8 * \author Alfredo Braunstein
9 * \author Angus Leeming
11 * \author André Pönitz
13 * Full author contact details are available in file CREDITS.
20 #include "BranchList.h"
21 #include "FloatList.h"
22 #include "FuncStatus.h"
24 #include "buffer_funcs.h"
25 #include "bufferparams.h"
26 #include "BufferView.h"
28 #include "coordcache.h"
29 #include "CutAndPaste.h"
31 #include "dispatchresult.h"
32 #include "errorlist.h"
34 #include "funcrequest.h"
38 #include "LyXAction.h"
43 #include "paragraph.h"
44 #include "paragraph_funcs.h"
45 #include "ParagraphParameters.h"
48 #include "pariterator.h"
50 #include "frontends/Dialogs.h"
51 #include "frontends/Gui.h"
52 #include "frontends/LyXView.h"
53 #include "frontends/Clipboard.h"
54 #include "frontends/Selection.h"
56 #include "insets/insetcommand.h"
57 #include "insets/insetfloatlist.h"
58 #include "insets/insetnewline.h"
59 #include "insets/insetquotes.h"
60 #include "insets/insetspecialchar.h"
61 #include "insets/insettext.h"
63 #include "support/lstrings.h"
64 #include "support/lyxlib.h"
65 #include "support/convert.h"
66 #include "support/lyxtime.h"
68 #include "mathed/math_hullinset.h"
69 #include "mathed/math_macrotemplate.h"
71 #include <boost/current_function.hpp>
80 using lyx::cap::copySelection;
81 using lyx::cap::cutSelection;
82 using lyx::cap::pasteSelection;
83 using lyx::cap::replaceSelection;
85 using lyx::support::isStrUnsignedInt;
86 using lyx::support::token;
90 using std::istringstream;
91 using std::ostringstream;
94 extern string current_layout;
100 LyXFont freefont(LyXFont::ALL_IGNORE);
101 bool toggleall = false;
104 void toggleAndShow(LCursor & cur, LyXText * text,
105 LyXFont const & font, bool toggleall = true)
107 text->toggleFree(cur, font, toggleall);
109 if (font.language() != ignore_language ||
110 font.number() != LyXFont::IGNORE) {
111 Paragraph & par = cur.paragraph();
112 text->bidi.computeTables(par, cur.buffer(), cur.textRow());
113 if (cur.boundary() !=
114 text->bidi.isBoundary(cur.buffer(), par,
116 text->real_current_font))
117 text->setCursor(cur, cur.pit(), cur.pos(),
118 false, !cur.boundary());
123 void moveCursor(LCursor & cur, bool selecting)
125 if (selecting || cur.mark())
127 if (!cur.selection())
128 cur.bv().owner()->gui().selection().haveSelection(false);
129 cur.bv().switchKeyMap();
133 void finishChange(LCursor & cur, bool selecting)
136 moveCursor(cur, selecting);
140 void mathDispatch(LCursor & cur, FuncRequest const & cmd, bool display)
143 string sel = lyx::to_utf8(cur.selectionAsString(false));
144 //lyxerr << "selection is: '" << sel << "'" << endl;
146 // It may happen that sel is empty but there is a selection
147 replaceSelection(cur);
150 const int old_pos = cur.pos();
151 cur.insert(new MathHullInset(hullSimple));
152 BOOST_ASSERT(old_pos == cur.pos());
153 cur.nextInset()->edit(cur, true);
154 // don't do that also for LFUN_MATH_MODE
155 // unless you want end up with always changing
156 // to mathrm when opening an inlined inset --
157 // I really hate "LyXfunc overloading"...
159 cur.dispatch(FuncRequest(LFUN_MATH_DISPLAY));
160 // Avoid an unnecessary undo step if cmd.argument
162 if (!cmd.argument().empty())
163 cur.dispatch(FuncRequest(LFUN_MATH_INSERT,
166 // create a macro if we see "\\newcommand"
167 // somewhere, and an ordinary formula
169 istringstream is(sel);
170 if (sel.find("\\newcommand") == string::npos
171 && sel.find("\\def") == string::npos)
173 MathHullInset * formula = new MathHullInset;
176 formula->read(cur.buffer(), lex);
177 if (formula->getType() == hullNone)
178 // Don't create pseudo formulas if
179 // delimiters are left out
180 formula->mutate(hullSimple);
183 cur.insert(new MathMacroTemplate(is));
185 cur.message(lyx::from_utf8(N_("Math editor mode")));
194 string const freefont2string()
197 if (font2string(freefont, toggleall, data))
204 bool LyXText::cursorPrevious(LCursor & cur)
206 pos_type cpos = cur.pos();
207 lyx::pit_type cpar = cur.pit();
209 int x = cur.x_target();
211 bool updated = setCursorFromCoordinates(cur, x, 0);
214 updated |= cursorUp(cur);
216 if (cpar == cur.pit() && cpos == cur.pos()) {
217 // we have a row which is taller than the workarea. The
218 // simplest solution is to move to the previous row instead.
219 updated |= cursorUp(cur);
227 bool LyXText::cursorNext(LCursor & cur)
229 pos_type cpos = cur.pos();
230 lyx::pit_type cpar = cur.pit();
232 int x = cur.x_target();
233 bool updated = setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1);
236 updated |= cursorDown(cur);
238 if (cpar == cur.pit() && cpos == cur.pos()) {
239 // we have a row which is taller than the workarea. The
240 // simplest solution is to move to the next row instead.
241 updated |= cursorDown(cur);
251 void specialChar(LCursor & cur, InsetSpecialChar::Kind kind)
253 lyx::cap::replaceSelection(cur);
254 cur.insert(new InsetSpecialChar(kind));
259 bool doInsertInset(LCursor & cur, LyXText * text,
260 FuncRequest const & cmd, bool edit, bool pastesel)
262 InsetBase * inset = createInset(&cur.bv(), cmd);
268 if (cur.selection()) {
269 cur.bv().owner()->dispatch(FuncRequest(LFUN_CUT));
272 text->insertInset(cur, inset);
275 inset->edit(cur, true);
277 if (gotsel && pastesel)
278 cur.bv().owner()->dispatch(FuncRequest(LFUN_PASTE));
283 void update(LCursor & cur)
285 //we don't call update(true, false) directly to save a metrics call
286 if (cur.bv().fitCursor())
287 cur.bv().update(Update::Force);
294 void LyXText::number(LCursor & cur)
296 LyXFont font(LyXFont::ALL_IGNORE);
297 font.setNumber(LyXFont::TOGGLE);
298 toggleAndShow(cur, this, font);
302 bool LyXText::isRTL(Paragraph const & par) const
304 return par.isRightToLeftPar(bv()->buffer()->params());
308 void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
310 lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl;
312 BOOST_ASSERT(cur.text() == this);
313 BufferView * bv = &cur.bv();
314 CursorSlice oldTopSlice = cur.top();
315 bool oldBoundary = cur.boundary();
316 bool sel = cur.selection();
317 // Signals that, even if needsUpdate == false, an update of the
318 // cursor paragraph is required
319 bool singleParUpdate = lyxaction.funcHasFlag(cmd.action,
320 LyXAction::SingleParUpdate);
321 // Signals that a full-screen update is required
322 bool needsUpdate = !(lyxaction.funcHasFlag(cmd.action,
323 LyXAction::NoUpdate) || singleParUpdate);
324 // Remember the old paragraph metric (_outer_ paragraph!)
325 Dimension olddim = cur.bottom().paragraph().dim();
327 switch (cmd.action) {
329 case LFUN_PARAGRAPH_MOVE_DOWN: {
330 pit_type const pit = cur.pit();
331 recUndo(pit, pit + 1);
333 std::swap(pars_[pit], pars_[pit + 1]);
335 ParIterator begin(cur);
337 ParIterator end = boost::next(ParIterator(cur));
338 updateLabels(cur.buffer(), begin, end);
344 case LFUN_PARAGRAPH_MOVE_UP: {
345 pit_type const pit = cur.pit();
346 recUndo(pit - 1, pit);
348 std::swap(pars_[pit], pars_[pit - 1]);
350 ParIterator end = boost::next(ParIterator(cur));
352 ParIterator begin(cur);
353 updateLabels(cur.buffer(), begin, end);
359 case LFUN_APPENDIX: {
360 Paragraph & par = cur.paragraph();
361 bool start = !par.params().startOfAppendix();
364 #warning The code below only makes sense at top level.
365 // Should LFUN_APPENDIX be restricted to top-level paragraphs?
367 // ensure that we have only one start_of_appendix in this document
368 for (pit_type tmp = 0, end = pars_.size(); tmp != end; ++tmp) {
369 if (pars_[tmp].params().startOfAppendix()) {
371 pars_[tmp].params().startOfAppendix(false);
377 par.params().startOfAppendix(start);
379 // we can set the refreshing parameters now
380 updateLabels(cur.buffer());
384 case LFUN_WORD_DELETE_FORWARD:
385 cur.clearSelection();
386 deleteWordForward(cur);
387 finishChange(cur, false);
390 case LFUN_WORD_DELETE_BACKWARD:
391 cur.clearSelection();
392 deleteWordBackward(cur);
393 finishChange(cur, false);
396 case LFUN_LINE_DELETE:
397 cur.clearSelection();
398 deleteLineForward(cur);
399 finishChange(cur, false);
402 case LFUN_BUFFER_BEGIN:
403 case LFUN_BUFFER_BEGIN_SELECT:
404 cur.selHandle(cmd.action == LFUN_BUFFER_BEGIN_SELECT);
405 if (cur.depth() == 1) {
406 needsUpdate = cursorTop(cur);
412 case LFUN_BUFFER_END:
413 case LFUN_BUFFER_END_SELECT:
414 cur.selHandle(cmd.action == LFUN_BUFFER_END_SELECT);
415 if (cur.depth() == 1) {
416 needsUpdate = cursorBottom(cur);
422 case LFUN_CHAR_FORWARD:
423 case LFUN_CHAR_FORWARD_SELECT:
424 //lyxerr << BOOST_CURRENT_FUNCTION
425 // << " LFUN_CHAR_FORWARD[SEL]:\n" << cur << endl;
426 cur.selHandle(cmd.action == LFUN_CHAR_FORWARD_SELECT);
427 if (isRTL(cur.paragraph()))
428 needsUpdate = cursorLeft(cur);
430 needsUpdate = cursorRight(cur);
432 if (!needsUpdate && oldTopSlice == cur.top()
433 && cur.boundary() == oldBoundary) {
435 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
439 case LFUN_CHAR_BACKWARD:
440 case LFUN_CHAR_BACKWARD_SELECT:
441 //lyxerr << "handle LFUN_CHAR_BACKWARD[_SELECT]:\n" << cur << endl;
442 cur.selHandle(cmd.action == LFUN_CHAR_BACKWARD_SELECT);
443 if (isRTL(cur.paragraph()))
444 needsUpdate = cursorRight(cur);
446 needsUpdate = cursorLeft(cur);
448 if (!needsUpdate && oldTopSlice == cur.top()
449 && cur.boundary() == oldBoundary) {
451 cmd = FuncRequest(LFUN_FINISHED_LEFT);
458 //lyxerr << "handle LFUN_UP[SEL]:\n" << cur << endl;
459 cur.selHandle(cmd.action == LFUN_UP_SELECT);
461 needsUpdate = cursorUp(cur);
462 if (!needsUpdate && oldTopSlice == cur.top()
463 && cur.boundary() == oldBoundary) {
465 cmd = FuncRequest(LFUN_FINISHED_UP);
470 case LFUN_DOWN_SELECT:
472 //lyxerr << "handle LFUN_DOWN[SEL]:\n" << cur << endl;
473 cur.selHandle(cmd.action == LFUN_DOWN_SELECT);
474 needsUpdate = cursorDown(cur);
475 if (!needsUpdate && oldTopSlice == cur.top() &&
476 cur.boundary() == oldBoundary)
479 cmd = FuncRequest(LFUN_FINISHED_DOWN);
483 case LFUN_PARAGRAPH_UP:
484 case LFUN_PARAGRAPH_UP_SELECT:
485 cur.selHandle(cmd.action == LFUN_PARAGRAPH_UP_SELECT);
486 needsUpdate = cursorUpParagraph(cur);
489 case LFUN_PARAGRAPH_DOWN:
490 case LFUN_PARAGRAPH_DOWN_SELECT:
491 cur.selHandle(cmd.action == LFUN_PARAGRAPH_DOWN_SELECT);
492 needsUpdate = cursorDownParagraph(cur);
496 case LFUN_SCREEN_UP_SELECT:
498 cur.selHandle(cmd.action == LFUN_SCREEN_UP_SELECT);
499 if (cur.pit() == 0 && cur.textRow().pos() == 0) {
501 cmd = FuncRequest(LFUN_FINISHED_UP);
503 needsUpdate = cursorPrevious(cur);
507 case LFUN_SCREEN_DOWN:
508 case LFUN_SCREEN_DOWN_SELECT:
510 cur.selHandle(cmd.action == LFUN_SCREEN_DOWN_SELECT);
511 if (cur.pit() == cur.lastpit()
512 && cur.textRow().endpos() == cur.lastpos()) {
514 cmd = FuncRequest(LFUN_FINISHED_DOWN);
516 needsUpdate = cursorNext(cur);
520 case LFUN_LINE_BEGIN:
521 case LFUN_LINE_BEGIN_SELECT:
523 cur.selHandle(cmd.action == LFUN_LINE_BEGIN_SELECT);
524 needsUpdate = cursorHome(cur);
528 case LFUN_LINE_END_SELECT:
530 cur.selHandle(cmd.action == LFUN_LINE_END_SELECT);
531 needsUpdate = cursorEnd(cur);
534 case LFUN_WORD_FORWARD:
535 case LFUN_WORD_FORWARD_SELECT:
536 cur.selHandle(cmd.action == LFUN_WORD_FORWARD_SELECT);
537 if (isRTL(cur.paragraph()))
538 needsUpdate = cursorLeftOneWord(cur);
540 needsUpdate = cursorRightOneWord(cur);
543 case LFUN_WORD_BACKWARD:
544 case LFUN_WORD_BACKWARD_SELECT:
545 cur.selHandle(cmd.action == LFUN_WORD_BACKWARD_SELECT);
546 if (isRTL(cur.paragraph()))
547 needsUpdate = cursorRightOneWord(cur);
549 needsUpdate = cursorLeftOneWord(cur);
552 case LFUN_WORD_SELECT: {
553 selectWord(cur, lyx::WHOLE_WORD);
554 finishChange(cur, true);
558 case LFUN_BREAK_LINE: {
559 // Not allowed by LaTeX (labels or empty par)
560 if (cur.pos() > cur.paragraph().beginOfBody()) {
561 lyx::cap::replaceSelection(cur);
562 cur.insert(new InsetNewline);
564 moveCursor(cur, false);
569 case LFUN_CHAR_DELETE_FORWARD:
570 if (!cur.selection()) {
571 if (cur.pos() == cur.paragraph().size())
572 // Par boundary, force full-screen update
573 singleParUpdate = false;
574 needsUpdate = erase(cur);
576 // It is possible to make it a lot faster still
577 // just comment out the line below...
579 cutSelection(cur, true, false);
580 singleParUpdate = false;
582 moveCursor(cur, false);
585 case LFUN_DELETE_FORWARD_SKIP:
586 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
587 if (!cur.selection()) {
588 if (cur.pos() == cur.lastpos()) {
595 cutSelection(cur, true, false);
600 case LFUN_CHAR_DELETE_BACKWARD:
601 if (!cur.selection()) {
602 if (bv->owner()->getIntl().getTransManager().backspace()) {
603 // Par boundary, full-screen update
605 singleParUpdate = false;
606 needsUpdate = backspace(cur);
608 // It is possible to make it a lot faster still
609 // just comment out the line below...
612 cutSelection(cur, true, false);
613 singleParUpdate = false;
618 case LFUN_DELETE_BACKWARD_SKIP:
619 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
620 if (!cur.selection()) {
624 //CursorSlice cur = cursor();
628 cutSelection(cur, true, false);
632 case LFUN_BREAK_PARAGRAPH:
633 lyx::cap::replaceSelection(cur);
634 breakParagraph(cur, 0);
639 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
640 lyx::cap::replaceSelection(cur);
641 breakParagraph(cur, 1);
646 case LFUN_BREAK_PARAGRAPH_SKIP: {
647 // When at the beginning of a paragraph, remove
648 // indentation. Otherwise, do the same as LFUN_BREAK_PARAGRAPH.
649 lyx::cap::replaceSelection(cur);
651 cur.paragraph().params().labelWidthString(string());
653 breakParagraph(cur, 0);
659 case LFUN_PARAGRAPH_SPACING: {
660 Paragraph & par = cur.paragraph();
661 Spacing::Space cur_spacing = par.params().spacing().getSpace();
662 string cur_value = "1.0";
663 if (cur_spacing == Spacing::Other)
664 cur_value = par.params().spacing().getValueAsString();
666 istringstream is(lyx::to_utf8(cmd.argument()));
669 Spacing::Space new_spacing = cur_spacing;
670 string new_value = cur_value;
672 lyxerr << "Missing argument to `paragraph-spacing'"
674 } else if (tmp == "single") {
675 new_spacing = Spacing::Single;
676 } else if (tmp == "onehalf") {
677 new_spacing = Spacing::Onehalf;
678 } else if (tmp == "double") {
679 new_spacing = Spacing::Double;
680 } else if (tmp == "other") {
681 new_spacing = Spacing::Other;
682 string tmpval = "0.0";
684 lyxerr << "new_value = " << tmpval << endl;
687 } else if (tmp == "default") {
688 new_spacing = Spacing::Default;
690 lyxerr << lyx::to_utf8(_("Unknown spacing argument: "))
691 << lyx::to_utf8(cmd.argument()) << endl;
693 if (cur_spacing != new_spacing || cur_value != new_value)
694 par.params().spacing(Spacing(new_spacing, new_value));
698 case LFUN_INSET_INSERT: {
700 InsetBase * inset = createInset(bv, cmd);
702 insertInset(cur, inset);
708 case LFUN_INSET_DISSOLVE:
709 needsUpdate = dissolveInset(cur);
712 case LFUN_INSET_SETTINGS:
713 cur.inset().showInsetDialog(bv);
716 case LFUN_SPACE_INSERT:
717 if (cur.paragraph().layout()->free_spacing)
718 insertChar(cur, ' ');
720 doInsertInset(cur, this, cmd, false, false);
723 moveCursor(cur, false);
726 case LFUN_HYPHENATION_POINT_INSERT:
727 specialChar(cur, InsetSpecialChar::HYPHENATION);
730 case LFUN_LIGATURE_BREAK_INSERT:
731 specialChar(cur, InsetSpecialChar::LIGATURE_BREAK);
734 case LFUN_DOTS_INSERT:
735 specialChar(cur, InsetSpecialChar::LDOTS);
738 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
739 specialChar(cur, InsetSpecialChar::END_OF_SENTENCE);
742 case LFUN_MENU_SEPARATOR_INSERT:
743 specialChar(cur, InsetSpecialChar::MENU_SEPARATOR);
746 case LFUN_WORD_UPCASE:
747 changeCase(cur, LyXText::text_uppercase);
750 case LFUN_WORD_LOWCASE:
751 changeCase(cur, LyXText::text_lowercase);
754 case LFUN_WORD_CAPITALIZE:
755 changeCase(cur, LyXText::text_capitalization);
758 case LFUN_CHARS_TRANSPOSE:
763 cur.message(_("Paste"));
764 lyx::cap::replaceSelection(cur);
765 if (isStrUnsignedInt(lyx::to_utf8(cmd.argument())))
766 pasteSelection(cur, bv->buffer()->errorList("Paste"),
767 convert<unsigned int>(lyx::to_utf8(cmd.argument())));
769 pasteSelection(cur, bv->buffer()->errorList("Paste"),
771 bv->buffer()->errors("Paste");
772 cur.clearSelection(); // bug 393
778 cutSelection(cur, true, true);
779 cur.message(_("Cut"));
784 cur.message(_("Copy"));
787 case LFUN_SERVER_GET_XY:
788 cur.message(lyx::from_utf8(
789 convert<string>(cursorX(cur.top(), cur.boundary())) + ' '
790 + convert<string>(cursorY(cur.top(), cur.boundary()))));
793 case LFUN_SERVER_SET_XY: {
796 istringstream is(lyx::to_utf8(cmd.argument()));
799 lyxerr << "SETXY: Could not parse coordinates in '"
800 << lyx::to_utf8(cmd.argument()) << std::endl;
802 setCursorFromCoordinates(cur, x, y);
806 case LFUN_SERVER_GET_FONT:
807 if (current_font.shape() == LyXFont::ITALIC_SHAPE)
808 cur.message(lyx::from_utf8("E"));
809 else if (current_font.shape() == LyXFont::SMALLCAPS_SHAPE)
810 cur.message(lyx::from_utf8("N"));
812 cur.message(lyx::from_utf8("0"));
815 case LFUN_SERVER_GET_LAYOUT:
816 cur.message(lyx::from_utf8(cur.paragraph().layout()->name()));
820 lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) "
821 << lyx::to_utf8(cmd.argument()) << endl;
823 // This is not the good solution to the empty argument
824 // problem, but it will hopefully suffice for 1.2.0.
825 // The correct solution would be to augument the
826 // function list/array with information about what
827 // functions needs arguments and their type.
828 if (cmd.argument().empty()) {
829 cur.errorMessage(_("LyX function 'layout' needs an argument."));
833 // Derive layout number from given argument (string)
834 // and current buffer's textclass (number)
835 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
836 bool hasLayout = tclass.hasLayout(lyx::to_utf8(cmd.argument()));
837 string layout = lyx::to_utf8(cmd.argument());
839 // If the entry is obsolete, use the new one instead.
841 string const & obs = tclass[layout]->obsoleted_by();
847 cur.errorMessage(lyx::from_utf8(N_("Layout ")) + cmd.argument() +
848 lyx::from_utf8(N_(" not known")));
852 bool change_layout = (current_layout != layout);
854 if (!change_layout && cur.selection() &&
855 cur.selBegin().pit() != cur.selEnd().pit())
857 pit_type spit = cur.selBegin().pit();
858 pit_type epit = cur.selEnd().pit() + 1;
859 while (spit != epit) {
860 if (pars_[spit].layout()->name() != current_layout) {
861 change_layout = true;
869 current_layout = layout;
870 setLayout(cur, layout);
871 bv->owner()->setLayout(layout);
877 case LFUN_CLIPBOARD_PASTE: {
878 cur.clearSelection();
879 docstring const clip = bv->owner()->gui().clipboard().get();
882 if (cmd.argument() == "paragraph")
883 insertStringAsParagraphs(cur, clip);
885 insertStringAsLines(cur, clip);
890 case LFUN_PRIMARY_SELECTION_PASTE: {
891 cur.clearSelection();
892 docstring const clip = bv->owner()->gui().selection().get();
895 if (cmd.argument() == "paragraph")
896 insertStringAsParagraphs(cur, clip);
898 insertStringAsLines(cur, clip);
903 case LFUN_QUOTE_INSERT: {
904 lyx::cap::replaceSelection(cur);
905 Paragraph & par = cur.paragraph();
906 lyx::pos_type pos = cur.pos();
910 else if (cur.prevInset() && cur.prevInset()->isSpace())
913 c = par.getChar(pos - 1);
915 LyXLayout_ptr const & style = par.layout();
917 BufferParams const & bufparams = bv->buffer()->params();
918 if (!style->pass_thru
919 && par.getFontSettings(bufparams, pos).language()->lang() != "hebrew") {
920 string arg = lyx::to_utf8(cmd.argument());
922 cur.insert(new InsetQuotes(c,
923 bufparams.quotes_language,
924 InsetQuotes::SingleQ));
926 cur.insert(new InsetQuotes(c,
927 bufparams.quotes_language,
928 InsetQuotes::DoubleQ));
932 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT, "\""));
936 case LFUN_DATE_INSERT:
937 if (cmd.argument().empty())
938 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT,
939 lyx::formatted_time(lyx::current_time())));
941 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT,
942 lyx::formatted_time(lyx::current_time(), lyx::to_utf8(cmd.argument()))));
945 case LFUN_MOUSE_TRIPLE:
946 if (cmd.button() == mouse_button::button1) {
952 bv->owner()->gui().selection().haveSelection(cur.selection());
956 case LFUN_MOUSE_DOUBLE:
957 if (cmd.button() == mouse_button::button1) {
958 selectWord(cur, lyx::WHOLE_WORD_STRICT);
960 bv->owner()->gui().selection().haveSelection(cur.selection());
964 // Single-click on work area
965 case LFUN_MOUSE_PRESS: {
966 // Right click on a footnote flag opens float menu
967 if (cmd.button() == mouse_button::button3)
968 cur.clearSelection();
970 // Middle button press pastes if we have a selection
971 // We do this here as if the selection was inside an inset
972 // it could get cleared on the unlocking of the inset so
973 // we have to check this first
974 bool paste_internally = false;
975 if (cmd.button() == mouse_button::button2 && cur.selection()) {
976 bv->owner()->dispatch(FuncRequest(LFUN_COPY));
977 paste_internally = true;
980 bv->mouseSetCursor(cur);
982 // Insert primary selection with middle mouse
983 // if there is a local selection in the current buffer,
985 if (cmd.button() == mouse_button::button2) {
986 if (paste_internally)
987 bv->owner()->dispatch(FuncRequest(LFUN_PASTE));
989 bv->owner()->dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph"));
995 case LFUN_MOUSE_MOTION: {
996 // Only use motion with button 1
997 //if (cmd.button() != mouse_button::button1)
1000 // ignore motions deeper nested than the real anchor
1001 LCursor & bvcur = cur.bv().cursor();
1002 if (bvcur.anchor_.hasPart(cur)) {
1003 CursorSlice old = bvcur.top();
1005 int const wh = bv->workHeight();
1006 int const y = std::max(0, std::min(wh - 1, cmd.y));
1008 setCursorFromCoordinates(cur, cmd.x, y);
1009 cur.x_target() = cmd.x;
1014 // This is to allow jumping over large insets
1015 if (cur.top() == old) {
1022 if (cur.top() == old)
1025 // don't set anchor_
1026 bvcur.setCursor(cur);
1027 bvcur.selection() = true;
1028 //lyxerr << "MOTION: " << bv->cursor() << endl;
1036 case LFUN_MOUSE_RELEASE: {
1037 if (cmd.button() == mouse_button::button2)
1041 if (cmd.button() == mouse_button::button1)
1042 bv->owner()->gui().selection().haveSelection(cur.selection());
1045 bv->owner()->updateMenubar();
1046 bv->owner()->updateToolbars();
1050 case LFUN_SELF_INSERT: {
1051 if (cmd.argument().empty())
1054 // Automatically delete the currently selected
1055 // text and replace it with what is being
1056 // typed in now. Depends on lyxrc settings
1057 // "auto_region_delete", which defaults to
1060 if (lyxrc.auto_region_delete) {
1061 if (cur.selection())
1062 cutSelection(cur, false, false);
1063 bv->owner()->gui().selection().haveSelection(false);
1066 cur.clearSelection();
1067 LyXFont const old_font = real_current_font;
1069 docstring::const_iterator cit = cmd.argument().begin();
1070 docstring::const_iterator end = cmd.argument().end();
1071 for (; cit != end; ++cit)
1073 bv->owner()->getIntl().getTransManager().
1074 translateAndInsert(*cit, this);
1076 insertChar(bv->cursor(), *cit);
1080 moveCursor(cur, false);
1084 case LFUN_URL_INSERT: {
1085 InsetCommandParams p("url");
1086 string const data = InsetCommandMailer::params2string("url", p);
1087 bv->owner()->getDialogs().show("url", data, 0);
1091 case LFUN_HTML_INSERT: {
1092 InsetCommandParams p("htmlurl");
1093 string const data = InsetCommandMailer::params2string("url", p);
1094 bv->owner()->getDialogs().show("url", data, 0);
1098 case LFUN_LABEL_INSERT: {
1099 // Try to generate a valid label
1100 string const contents = cmd.argument().empty() ?
1101 cur.getPossibleLabel() : lyx::to_utf8(cmd.argument());
1103 InsetCommandParams p("label", contents);
1104 string const data = InsetCommandMailer::params2string("label", p);
1106 if (cmd.argument().empty()) {
1107 bv->owner()->getDialogs().show("label", data, 0);
1109 FuncRequest fr(LFUN_INSET_INSERT, data);
1117 case LFUN_LIST_INSERT:
1118 case LFUN_THEOREM_INSERT:
1119 case LFUN_CAPTION_INSERT:
1121 case LFUN_NOTE_INSERT:
1122 case LFUN_CHARSTYLE_INSERT:
1123 case LFUN_BOX_INSERT:
1124 case LFUN_BRANCH_INSERT:
1125 case LFUN_BIBITEM_INSERT:
1126 case LFUN_ERT_INSERT:
1127 case LFUN_FOOTNOTE_INSERT:
1128 case LFUN_MARGINALNOTE_INSERT:
1129 case LFUN_OPTIONAL_INSERT:
1130 case LFUN_ENVIRONMENT_INSERT:
1131 // Open the inset, and move the current selection
1133 doInsertInset(cur, this, cmd, true, true);
1137 case LFUN_TABULAR_INSERT:
1138 // if there were no arguments, just open the dialog
1139 if (doInsertInset(cur, this, cmd, false, true))
1142 bv->owner()->getDialogs().show("tabularcreate");
1146 case LFUN_FLOAT_INSERT:
1147 case LFUN_FLOAT_WIDE_INSERT:
1148 case LFUN_WRAP_INSERT:
1149 doInsertInset(cur, this, cmd, true, true);
1151 // FIXME: the "Caption" name should not be hardcoded,
1152 // but given by the float definition.
1153 cur.dispatch(FuncRequest(LFUN_LAYOUT, "Caption"));
1156 case LFUN_INDEX_INSERT: {
1157 InsetBase * inset = createInset(&cur.bv(), cmd);
1162 cur.clearSelection();
1163 insertInset(cur, inset);
1164 inset->edit(cur, true);
1169 case LFUN_INDEX_PRINT:
1170 case LFUN_TOC_INSERT:
1171 case LFUN_HFILL_INSERT:
1172 case LFUN_LINE_INSERT:
1173 case LFUN_PAGEBREAK_INSERT:
1175 doInsertInset(cur, this, cmd, false, false);
1179 case LFUN_DEPTH_DECREMENT:
1180 changeDepth(cur, DEC_DEPTH);
1183 case LFUN_DEPTH_INCREMENT:
1184 changeDepth(cur, INC_DEPTH);
1187 case LFUN_MATH_DISPLAY:
1188 mathDispatch(cur, cmd, true);
1191 case LFUN_MATH_IMPORT_SELECTION:
1192 case LFUN_MATH_MODE:
1193 if (cmd.argument() == "on")
1194 // don't pass "on" as argument
1195 mathDispatch(cur, FuncRequest(LFUN_MATH_MODE), false);
1197 mathDispatch(cur, cmd, false);
1200 case LFUN_MATH_MACRO:
1201 if (cmd.argument().empty())
1202 cur.errorMessage(lyx::from_utf8(N_("Missing argument")));
1204 string s = lyx::to_utf8(cmd.argument());
1205 string const s1 = token(s, ' ', 1);
1206 int const nargs = s1.empty() ? 0 : convert<int>(s1);
1207 string const s2 = token(s, ' ', 2);
1208 string const type = s2.empty() ? "newcommand" : s2;
1209 cur.insert(new MathMacroTemplate(token(s, ' ', 0), nargs, type));
1210 //cur.nextInset()->edit(cur, true);
1214 // passthrough hat and underscore outside mathed:
1215 case LFUN_MATH_SUBSCRIPT:
1216 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "_"), false);
1218 case LFUN_MATH_SUPERSCRIPT:
1219 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "^"), false);
1222 case LFUN_MATH_INSERT:
1223 case LFUN_MATH_MATRIX:
1224 case LFUN_MATH_DELIM:
1225 case LFUN_MATH_BIGDELIM: {
1226 cur.insert(new MathHullInset(hullSimple));
1227 cur.dispatch(FuncRequest(LFUN_CHAR_FORWARD));
1232 case LFUN_FONT_EMPH: {
1233 LyXFont font(LyXFont::ALL_IGNORE);
1234 font.setEmph(LyXFont::TOGGLE);
1235 toggleAndShow(cur, this, font);
1239 case LFUN_FONT_BOLD: {
1240 LyXFont font(LyXFont::ALL_IGNORE);
1241 font.setSeries(LyXFont::BOLD_SERIES);
1242 toggleAndShow(cur, this, font);
1246 case LFUN_FONT_NOUN: {
1247 LyXFont font(LyXFont::ALL_IGNORE);
1248 font.setNoun(LyXFont::TOGGLE);
1249 toggleAndShow(cur, this, font);
1253 case LFUN_FONT_CODE: {
1254 LyXFont font(LyXFont::ALL_IGNORE);
1255 font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
1256 toggleAndShow(cur, this, font);
1260 case LFUN_FONT_SANS: {
1261 LyXFont font(LyXFont::ALL_IGNORE);
1262 font.setFamily(LyXFont::SANS_FAMILY);
1263 toggleAndShow(cur, this, font);
1267 case LFUN_FONT_ROMAN: {
1268 LyXFont font(LyXFont::ALL_IGNORE);
1269 font.setFamily(LyXFont::ROMAN_FAMILY);
1270 toggleAndShow(cur, this, font);
1274 case LFUN_FONT_DEFAULT: {
1275 LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
1276 toggleAndShow(cur, this, font);
1280 case LFUN_FONT_UNDERLINE: {
1281 LyXFont font(LyXFont::ALL_IGNORE);
1282 font.setUnderbar(LyXFont::TOGGLE);
1283 toggleAndShow(cur, this, font);
1287 case LFUN_FONT_SIZE: {
1288 LyXFont font(LyXFont::ALL_IGNORE);
1289 font.setLyXSize(lyx::to_utf8(cmd.argument()));
1290 toggleAndShow(cur, this, font);
1294 case LFUN_LANGUAGE: {
1295 Language const * lang = languages.getLanguage(lyx::to_utf8(cmd.argument()));
1298 LyXFont font(LyXFont::ALL_IGNORE);
1299 font.setLanguage(lang);
1300 toggleAndShow(cur, this, font);
1305 case LFUN_FONT_FREE_APPLY:
1306 toggleAndShow(cur, this, freefont, toggleall);
1307 cur.message(_("Character set"));
1310 // Set the freefont using the contents of \param data dispatched from
1311 // the frontends and apply it at the current cursor location.
1312 case LFUN_FONT_FREE_UPDATE: {
1315 if (bv_funcs::string2font(lyx::to_utf8(cmd.argument()), font, toggle)) {
1318 toggleAndShow(cur, this, freefont, toggleall);
1319 cur.message(_("Character set"));
1324 case LFUN_FINISHED_LEFT:
1325 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_LEFT:\n" << cur << endl;
1328 case LFUN_FINISHED_RIGHT:
1329 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_RIGHT:\n" << cur << endl;
1333 case LFUN_FINISHED_UP:
1334 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_UP:\n" << cur << endl;
1338 case LFUN_FINISHED_DOWN:
1339 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_DOWN:\n" << cur << endl;
1343 case LFUN_LAYOUT_PARAGRAPH: {
1345 params2string(cur.paragraph(), data);
1346 data = "show\n" + data;
1347 bv->owner()->getDialogs().show("paragraph", data);
1351 case LFUN_PARAGRAPH_UPDATE: {
1352 if (!bv->owner()->getDialogs().visible("paragraph"))
1355 params2string(cur.paragraph(), data);
1357 // Will the paragraph accept changes from the dialog?
1358 bool const accept = !cur.inset().forceDefaultParagraphs(cur.idx());
1360 data = "update " + convert<string>(accept) + '\n' + data;
1361 bv->owner()->getDialogs().update("paragraph", data);
1365 case LFUN_ACCENT_UMLAUT:
1366 case LFUN_ACCENT_CIRCUMFLEX:
1367 case LFUN_ACCENT_GRAVE:
1368 case LFUN_ACCENT_ACUTE:
1369 case LFUN_ACCENT_TILDE:
1370 case LFUN_ACCENT_CEDILLA:
1371 case LFUN_ACCENT_MACRON:
1372 case LFUN_ACCENT_DOT:
1373 case LFUN_ACCENT_UNDERDOT:
1374 case LFUN_ACCENT_UNDERBAR:
1375 case LFUN_ACCENT_CARON:
1376 case LFUN_ACCENT_SPECIAL_CARON:
1377 case LFUN_ACCENT_BREVE:
1378 case LFUN_ACCENT_TIE:
1379 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1380 case LFUN_ACCENT_CIRCLE:
1381 case LFUN_ACCENT_OGONEK:
1382 bv->owner()->getLyXFunc().handleKeyFunc(cmd.action);
1383 if (!cmd.argument().empty())
1384 // FIXME: Are all these characters encoded in one byte in utf8?
1385 bv->owner()->getIntl().getTransManager()
1386 .translateAndInsert(cmd.argument()[0], this);
1389 case LFUN_FLOAT_LIST: {
1390 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
1391 if (tclass.floats().typeExist(lyx::to_utf8(cmd.argument()))) {
1392 // not quite sure if we want this...
1394 cur.clearSelection();
1395 breakParagraph(cur);
1397 if (cur.lastpos() != 0) {
1399 breakParagraph(cur);
1402 setLayout(cur, tclass.defaultLayoutName());
1403 setParagraph(cur, Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
1404 insertInset(cur, new InsetFloatList(lyx::to_utf8(cmd.argument())));
1407 lyxerr << "Non-existent float type: "
1408 << lyx::to_utf8(cmd.argument()) << endl;
1413 case LFUN_CHANGE_ACCEPT: {
1418 case LFUN_CHANGE_REJECT: {
1423 case LFUN_THESAURUS_ENTRY: {
1424 docstring arg = cmd.argument();
1426 arg = cur.selectionAsString(false);
1428 if (arg.size() > 100 || arg.empty()) {
1429 // Get word or selection
1430 selectWordWhenUnderCursor(cur, lyx::WHOLE_WORD);
1431 arg = cur.selectionAsString(false);
1434 bv->owner()->getDialogs().show("thesaurus", lyx::to_utf8(arg));
1438 case LFUN_PARAGRAPH_PARAMS_APPLY: {
1439 // Given data, an encoding of the ParagraphParameters
1440 // generated in the Paragraph dialog, this function sets
1441 // the current paragraph appropriately.
1442 istringstream is(lyx::to_utf8(cmd.argument()));
1445 ParagraphParameters params;
1450 params.labelWidthString(),
1452 cur.message(_("Paragraph layout set"));
1457 if (cur.selection()) {
1458 cur.selection() = false;
1461 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
1466 lyxerr[Debug::ACTION]
1467 << BOOST_CURRENT_FUNCTION
1468 << ": Command " << cmd
1469 << " not DISPATCHED by LyXText" << endl;
1474 if (singleParUpdate)
1475 // Inserting characters does not change par height
1476 if (cur.bottom().paragraph().dim().height()
1477 == olddim.height()) {
1478 // if so, update _only_ this paragraph
1479 cur.bv().update(Update::SinglePar |
1481 Update::MultiParSel);
1487 && &oldTopSlice.inset() == &cur.inset()
1488 && oldTopSlice.idx() == cur.idx()
1490 && !cur.selection())
1497 bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
1498 FuncStatus & flag) const
1500 BOOST_ASSERT(cur.text() == this);
1502 LyXFont const & font = real_current_font;
1504 InsetBase::Code code = InsetBase::NO_CODE;
1506 switch (cmd.action) {
1508 case LFUN_DEPTH_DECREMENT:
1509 enable = changeDepthAllowed(cur, DEC_DEPTH);
1512 case LFUN_DEPTH_INCREMENT:
1513 enable = changeDepthAllowed(cur, INC_DEPTH);
1517 flag.setOnOff(cur.paragraph().params().startOfAppendix());
1520 case LFUN_BIBITEM_INSERT:
1521 enable = (cur.paragraph().layout()->labeltype == LABEL_BIBLIO);
1524 case LFUN_DIALOG_SHOW_NEW_INSET:
1525 if (cmd.argument() == "bibitem")
1526 code = InsetBase::BIBITEM_CODE;
1527 else if (cmd.argument() == "bibtex")
1528 code = InsetBase::BIBTEX_CODE;
1529 else if (cmd.argument() == "box")
1530 code = InsetBase::BOX_CODE;
1531 else if (cmd.argument() == "branch")
1532 code = InsetBase::BRANCH_CODE;
1533 else if (cmd.argument() == "citation")
1534 code = InsetBase::CITE_CODE;
1535 else if (cmd.argument() == "ert")
1536 code = InsetBase::ERT_CODE;
1537 else if (cmd.argument() == "external")
1538 code = InsetBase::EXTERNAL_CODE;
1539 else if (cmd.argument() == "float")
1540 code = InsetBase::FLOAT_CODE;
1541 else if (cmd.argument() == "graphics")
1542 code = InsetBase::GRAPHICS_CODE;
1543 else if (cmd.argument() == "include")
1544 code = InsetBase::INCLUDE_CODE;
1545 else if (cmd.argument() == "index")
1546 code = InsetBase::INDEX_CODE;
1547 else if (cmd.argument() == "label")
1548 code = InsetBase::LABEL_CODE;
1549 else if (cmd.argument() == "note")
1550 code = InsetBase::NOTE_CODE;
1551 else if (cmd.argument() == "ref")
1552 code = InsetBase::REF_CODE;
1553 else if (cmd.argument() == "toc")
1554 code = InsetBase::TOC_CODE;
1555 else if (cmd.argument() == "url")
1556 code = InsetBase::URL_CODE;
1557 else if (cmd.argument() == "vspace")
1558 code = InsetBase::VSPACE_CODE;
1559 else if (cmd.argument() == "wrap")
1560 code = InsetBase::WRAP_CODE;
1563 case LFUN_ERT_INSERT:
1564 code = InsetBase::ERT_CODE;
1566 case LFUN_FOOTNOTE_INSERT:
1567 code = InsetBase::FOOT_CODE;
1569 case LFUN_TABULAR_INSERT:
1570 code = InsetBase::TABULAR_CODE;
1572 case LFUN_MARGINALNOTE_INSERT:
1573 code = InsetBase::MARGIN_CODE;
1575 case LFUN_FLOAT_INSERT:
1576 case LFUN_FLOAT_WIDE_INSERT:
1577 code = InsetBase::FLOAT_CODE;
1579 case LFUN_WRAP_INSERT:
1580 code = InsetBase::WRAP_CODE;
1582 case LFUN_FLOAT_LIST:
1583 code = InsetBase::FLOAT_LIST_CODE;
1586 case LFUN_LIST_INSERT:
1587 code = InsetBase::LIST_CODE;
1589 case LFUN_THEOREM_INSERT:
1590 code = InsetBase::THEOREM_CODE;
1593 case LFUN_CAPTION_INSERT:
1594 code = InsetBase::CAPTION_CODE;
1596 case LFUN_NOTE_INSERT:
1597 code = InsetBase::NOTE_CODE;
1599 case LFUN_CHARSTYLE_INSERT:
1600 code = InsetBase::CHARSTYLE_CODE;
1601 if (cur.buffer().params().getLyXTextClass().charstyles().empty())
1604 case LFUN_BOX_INSERT:
1605 code = InsetBase::BOX_CODE;
1607 case LFUN_BRANCH_INSERT:
1608 code = InsetBase::BRANCH_CODE;
1609 if (cur.buffer().getMasterBuffer()->params().branchlist().empty())
1612 case LFUN_LABEL_INSERT:
1613 code = InsetBase::LABEL_CODE;
1615 case LFUN_OPTIONAL_INSERT:
1616 code = InsetBase::OPTARG_CODE;
1617 enable = numberOfOptArgs(cur.paragraph())
1618 < cur.paragraph().layout()->optionalargs;
1620 case LFUN_ENVIRONMENT_INSERT:
1621 code = InsetBase::BOX_CODE;
1623 case LFUN_INDEX_INSERT:
1624 code = InsetBase::INDEX_CODE;
1626 case LFUN_INDEX_PRINT:
1627 code = InsetBase::INDEX_PRINT_CODE;
1629 case LFUN_TOC_INSERT:
1630 code = InsetBase::TOC_CODE;
1632 case LFUN_HTML_INSERT:
1633 case LFUN_URL_INSERT:
1634 code = InsetBase::URL_CODE;
1636 case LFUN_QUOTE_INSERT:
1637 // always allow this, since we will inset a raw quote
1638 // if an inset is not allowed.
1640 case LFUN_HYPHENATION_POINT_INSERT:
1641 case LFUN_LIGATURE_BREAK_INSERT:
1642 case LFUN_HFILL_INSERT:
1643 case LFUN_MENU_SEPARATOR_INSERT:
1644 case LFUN_DOTS_INSERT:
1645 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
1646 code = InsetBase::SPECIALCHAR_CODE;
1648 case LFUN_SPACE_INSERT:
1649 // slight hack: we know this is allowed in math mode
1651 code = InsetBase::SPACE_CODE;
1654 case LFUN_INSET_MODIFY:
1655 // We need to disable this, because we may get called for a
1657 // InsetTabular::getStatus() -> InsetText::getStatus()
1658 // and we don't handle LFUN_INSET_MODIFY.
1662 case LFUN_FONT_EMPH:
1663 flag.setOnOff(font.emph() == LyXFont::ON);
1666 case LFUN_FONT_NOUN:
1667 flag.setOnOff(font.noun() == LyXFont::ON);
1670 case LFUN_FONT_BOLD:
1671 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
1674 case LFUN_FONT_SANS:
1675 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
1678 case LFUN_FONT_ROMAN:
1679 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
1682 case LFUN_FONT_CODE:
1683 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
1688 enable = cur.selection();
1692 enable = lyx::cap::numberOfSelections() > 0;
1695 case LFUN_PARAGRAPH_MOVE_UP:
1696 enable = cur.pit() > 0 && !cur.selection();
1699 case LFUN_PARAGRAPH_MOVE_DOWN:
1700 enable = cur.pit() < cur.lastpit() && !cur.selection();
1703 case LFUN_INSET_DISSOLVE:
1704 enable = !isMainText() && cur.inset().nargs() == 1;
1707 case LFUN_WORD_DELETE_FORWARD:
1708 case LFUN_WORD_DELETE_BACKWARD:
1709 case LFUN_LINE_DELETE:
1710 case LFUN_WORD_FORWARD:
1711 case LFUN_WORD_BACKWARD:
1712 case LFUN_CHAR_FORWARD:
1713 case LFUN_CHAR_FORWARD_SELECT:
1714 case LFUN_CHAR_BACKWARD:
1715 case LFUN_CHAR_BACKWARD_SELECT:
1717 case LFUN_UP_SELECT:
1719 case LFUN_DOWN_SELECT:
1720 case LFUN_PARAGRAPH_UP_SELECT:
1721 case LFUN_PARAGRAPH_DOWN_SELECT:
1722 case LFUN_SCREEN_UP_SELECT:
1723 case LFUN_SCREEN_DOWN_SELECT:
1724 case LFUN_LINE_BEGIN_SELECT:
1725 case LFUN_LINE_END_SELECT:
1726 case LFUN_WORD_FORWARD_SELECT:
1727 case LFUN_WORD_BACKWARD_SELECT:
1728 case LFUN_WORD_SELECT:
1729 case LFUN_PARAGRAPH_UP:
1730 case LFUN_PARAGRAPH_DOWN:
1731 case LFUN_SCREEN_UP:
1732 case LFUN_SCREEN_DOWN:
1733 case LFUN_LINE_BEGIN:
1735 case LFUN_BREAK_LINE:
1736 case LFUN_CHAR_DELETE_FORWARD:
1737 case LFUN_DELETE_FORWARD_SKIP:
1738 case LFUN_CHAR_DELETE_BACKWARD:
1739 case LFUN_DELETE_BACKWARD_SKIP:
1740 case LFUN_BREAK_PARAGRAPH:
1741 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
1742 case LFUN_BREAK_PARAGRAPH_SKIP:
1743 case LFUN_PARAGRAPH_SPACING:
1744 case LFUN_INSET_INSERT:
1745 case LFUN_WORD_UPCASE:
1746 case LFUN_WORD_LOWCASE:
1747 case LFUN_WORD_CAPITALIZE:
1748 case LFUN_CHARS_TRANSPOSE:
1749 case LFUN_SERVER_GET_XY:
1750 case LFUN_SERVER_SET_XY:
1751 case LFUN_SERVER_GET_FONT:
1752 case LFUN_SERVER_GET_LAYOUT:
1754 case LFUN_CLIPBOARD_PASTE:
1755 case LFUN_PRIMARY_SELECTION_PASTE:
1756 case LFUN_DATE_INSERT:
1757 case LFUN_SELF_INSERT:
1758 case LFUN_LINE_INSERT:
1759 case LFUN_PAGEBREAK_INSERT:
1760 case LFUN_MATH_DISPLAY:
1761 case LFUN_MATH_IMPORT_SELECTION:
1762 case LFUN_MATH_MODE:
1763 case LFUN_MATH_MACRO:
1764 case LFUN_MATH_INSERT:
1765 case LFUN_MATH_MATRIX:
1766 case LFUN_MATH_DELIM:
1767 case LFUN_MATH_BIGDELIM:
1768 case LFUN_MATH_SUBSCRIPT:
1769 case LFUN_MATH_SUPERSCRIPT:
1770 case LFUN_FONT_DEFAULT:
1771 case LFUN_FONT_UNDERLINE:
1772 case LFUN_FONT_SIZE:
1774 case LFUN_FONT_FREE_APPLY:
1775 case LFUN_FONT_FREE_UPDATE:
1776 case LFUN_LAYOUT_PARAGRAPH:
1777 case LFUN_PARAGRAPH_UPDATE:
1778 case LFUN_ACCENT_UMLAUT:
1779 case LFUN_ACCENT_CIRCUMFLEX:
1780 case LFUN_ACCENT_GRAVE:
1781 case LFUN_ACCENT_ACUTE:
1782 case LFUN_ACCENT_TILDE:
1783 case LFUN_ACCENT_CEDILLA:
1784 case LFUN_ACCENT_MACRON:
1785 case LFUN_ACCENT_DOT:
1786 case LFUN_ACCENT_UNDERDOT:
1787 case LFUN_ACCENT_UNDERBAR:
1788 case LFUN_ACCENT_CARON:
1789 case LFUN_ACCENT_SPECIAL_CARON:
1790 case LFUN_ACCENT_BREVE:
1791 case LFUN_ACCENT_TIE:
1792 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1793 case LFUN_ACCENT_CIRCLE:
1794 case LFUN_ACCENT_OGONEK:
1795 case LFUN_CHANGE_ACCEPT:
1796 case LFUN_CHANGE_REJECT:
1797 case LFUN_THESAURUS_ENTRY:
1798 case LFUN_PARAGRAPH_PARAMS_APPLY:
1800 case LFUN_BUFFER_END:
1801 case LFUN_BUFFER_BEGIN:
1802 case LFUN_BUFFER_BEGIN_SELECT:
1803 case LFUN_BUFFER_END_SELECT:
1804 // these are handled in our dispatch()
1812 if (code != InsetBase::NO_CODE
1813 && (cur.empty() || !cur.inset().insetAllowed(code)))
1816 flag.enabled(enable);