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::pasteParagraphList;
83 using lyx::cap::pasteSelection;
84 using lyx::cap::replaceSelection;
86 using lyx::support::isStrUnsignedInt;
87 using lyx::support::token;
89 using lyx::frontend::Gui;
90 using lyx::frontend::Clipboard;
94 using std::istringstream;
95 using std::ostringstream;
98 extern string current_layout;
104 LyXFont freefont(LyXFont::ALL_IGNORE);
105 bool toggleall = false;
108 void toggleAndShow(LCursor & cur, LyXText * text,
109 LyXFont const & font, bool toggleall = true)
111 text->toggleFree(cur, font, toggleall);
113 if (font.language() != ignore_language ||
114 font.number() != LyXFont::IGNORE) {
115 Paragraph & par = cur.paragraph();
116 text->bidi.computeTables(par, cur.buffer(), cur.textRow());
117 if (cur.boundary() !=
118 text->bidi.isBoundary(cur.buffer(), par,
120 text->real_current_font))
121 text->setCursor(cur, cur.pit(), cur.pos(),
122 false, !cur.boundary());
127 void moveCursor(LCursor & cur, bool selecting)
129 if (selecting || cur.mark())
131 if (!cur.selection())
132 cur.bv().owner()->gui().selection().haveSelection(false);
133 cur.bv().switchKeyMap();
137 void finishChange(LCursor & cur, bool selecting)
140 moveCursor(cur, selecting);
144 void mathDispatch(LCursor & cur, FuncRequest const & cmd, bool display)
147 string sel = lyx::to_utf8(cur.selectionAsString(false));
148 //lyxerr << "selection is: '" << sel << "'" << endl;
150 // It may happen that sel is empty but there is a selection
151 replaceSelection(cur);
154 const int old_pos = cur.pos();
155 cur.insert(new MathHullInset("simple"));
156 BOOST_ASSERT(old_pos == cur.pos());
157 cur.nextInset()->edit(cur, true);
158 // don't do that also for LFUN_MATH_MODE
159 // unless you want end up with always changing
160 // to mathrm when opening an inlined inset --
161 // I really hate "LyXfunc overloading"...
163 cur.dispatch(FuncRequest(LFUN_MATH_DISPLAY));
164 // Avoid an unnecessary undo step if cmd.argument
166 if (!cmd.argument().empty())
167 cur.dispatch(FuncRequest(LFUN_MATH_INSERT,
170 // create a macro if we see "\\newcommand"
171 // somewhere, and an ordinary formula
173 istringstream is(sel);
174 if (sel.find("\\newcommand") == string::npos
175 && sel.find("\\def") == string::npos)
177 MathHullInset * formula = new MathHullInset;
180 formula->read(cur.buffer(), lex);
181 if (formula->getType() == "none")
182 // Don't create pseudo formulas if
183 // delimiters are left out
184 formula->mutate("simple");
187 cur.insert(new MathMacroTemplate(is));
189 cur.message(N_("Math editor mode"));
198 string const freefont2string()
201 if (font2string(freefont, toggleall, data))
208 bool LyXText::cursorPrevious(LCursor & cur)
210 pos_type cpos = cur.pos();
211 lyx::pit_type cpar = cur.pit();
213 int x = cur.x_target();
215 bool updated = setCursorFromCoordinates(cur, x, 0);
218 updated |= cursorUp(cur);
220 if (cpar == cur.pit() && cpos == cur.pos()) {
221 // we have a row which is taller than the workarea. The
222 // simplest solution is to move to the previous row instead.
223 updated |= cursorUp(cur);
231 bool LyXText::cursorNext(LCursor & cur)
233 pos_type cpos = cur.pos();
234 lyx::pit_type cpar = cur.pit();
236 int x = cur.x_target();
237 bool updated = setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1);
240 updated |= cursorDown(cur);
242 if (cpar == cur.pit() && cpos == cur.pos()) {
243 // we have a row which is taller than the workarea. The
244 // simplest solution is to move to the next row instead.
245 updated |= cursorDown(cur);
255 void specialChar(LCursor & cur, InsetSpecialChar::Kind kind)
257 lyx::cap::replaceSelection(cur);
258 cur.insert(new InsetSpecialChar(kind));
263 bool doInsertInset(LCursor & cur, LyXText * text,
264 FuncRequest const & cmd, bool edit, bool pastesel)
266 InsetBase * inset = createInset(&cur.bv(), cmd);
272 if (cur.selection()) {
273 cur.bv().owner()->dispatch(FuncRequest(LFUN_CUT));
276 text->insertInset(cur, inset);
279 inset->edit(cur, true);
281 if (gotsel && pastesel)
282 cur.bv().owner()->dispatch(FuncRequest(LFUN_PASTE));
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->owner()->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(string());
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 << _("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 recordUndoInset(cur);
714 cur.selHandle(false);
716 lyx::pos_type spos = cur.pos();
717 lyx::pit_type spit = cur.pit();
719 if (cur.lastpit() != 0 || cur.lastpos() != 0)
720 plist = paragraphs();
722 // store cursor offset
726 cur.paragraph().erase(cur.pos());
727 if (!plist.empty()) {
728 Buffer * b = bv->buffer();
729 pasteParagraphList(cur, plist, b->params().textclass,
730 b->errorList("Paste"));
732 cur.pit() = std::min(cur.lastpit(), spit);
733 cur.pos() = std::min(cur.lastpos(), spos);
735 cur.clearSelection();
741 case LFUN_INSET_SETTINGS:
742 cur.inset().showInsetDialog(bv);
745 case LFUN_SPACE_INSERT:
746 if (cur.paragraph().layout()->free_spacing)
747 insertChar(cur, ' ');
749 doInsertInset(cur, this, cmd, false, false);
752 moveCursor(cur, false);
755 case LFUN_HYPHENATION_POINT_INSERT:
756 specialChar(cur, InsetSpecialChar::HYPHENATION);
759 case LFUN_LIGATURE_BREAK_INSERT:
760 specialChar(cur, InsetSpecialChar::LIGATURE_BREAK);
763 case LFUN_DOTS_INSERT:
764 specialChar(cur, InsetSpecialChar::LDOTS);
767 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
768 specialChar(cur, InsetSpecialChar::END_OF_SENTENCE);
771 case LFUN_MENU_SEPARATOR_INSERT:
772 specialChar(cur, InsetSpecialChar::MENU_SEPARATOR);
775 case LFUN_WORD_UPCASE:
776 changeCase(cur, LyXText::text_uppercase);
779 case LFUN_WORD_LOWCASE:
780 changeCase(cur, LyXText::text_lowercase);
783 case LFUN_WORD_CAPITALIZE:
784 changeCase(cur, LyXText::text_capitalization);
787 case LFUN_CHARS_TRANSPOSE:
792 cur.message(_("Paste"));
793 lyx::cap::replaceSelection(cur);
794 if (isStrUnsignedInt(lyx::to_utf8(cmd.argument())))
795 pasteSelection(cur, bv->buffer()->errorList("Paste"),
796 convert<unsigned int>(lyx::to_utf8(cmd.argument())));
798 pasteSelection(cur, bv->buffer()->errorList("Paste"),
800 bv->buffer()->errors("Paste");
801 cur.clearSelection(); // bug 393
807 cutSelection(cur, true, true);
808 cur.message(_("Cut"));
813 cur.message(_("Copy"));
816 case LFUN_SERVER_GET_XY:
817 cur.message(convert<string>(cursorX(cur.top(), cur.boundary())) + ' '
818 + convert<string>(cursorY(cur.top(), cur.boundary())));
821 case LFUN_SERVER_SET_XY: {
824 istringstream is(lyx::to_utf8(cmd.argument()));
827 lyxerr << "SETXY: Could not parse coordinates in '"
828 << lyx::to_utf8(cmd.argument()) << std::endl;
830 setCursorFromCoordinates(cur, x, y);
834 case LFUN_SERVER_GET_FONT:
835 if (current_font.shape() == LyXFont::ITALIC_SHAPE)
837 else if (current_font.shape() == LyXFont::SMALLCAPS_SHAPE)
843 case LFUN_SERVER_GET_LAYOUT:
844 cur.message(cur.paragraph().layout()->name());
848 lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) "
849 << lyx::to_utf8(cmd.argument()) << endl;
851 // This is not the good solution to the empty argument
852 // problem, but it will hopefully suffice for 1.2.0.
853 // The correct solution would be to augument the
854 // function list/array with information about what
855 // functions needs arguments and their type.
856 if (cmd.argument().empty()) {
857 cur.errorMessage(_("LyX function 'layout' needs an argument."));
861 // Derive layout number from given argument (string)
862 // and current buffer's textclass (number)
863 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
864 bool hasLayout = tclass.hasLayout(lyx::to_utf8(cmd.argument()));
865 string layout = lyx::to_utf8(cmd.argument());
867 // If the entry is obsolete, use the new one instead.
869 string const & obs = tclass[layout]->obsoleted_by();
875 cur.errorMessage(string(N_("Layout ")) + lyx::to_utf8(cmd.argument()) +
880 bool change_layout = (current_layout != layout);
882 if (!change_layout && cur.selection() &&
883 cur.selBegin().pit() != cur.selEnd().pit())
885 pit_type spit = cur.selBegin().pit();
886 pit_type epit = cur.selEnd().pit() + 1;
887 while (spit != epit) {
888 if (pars_[spit].layout()->name() != current_layout) {
889 change_layout = true;
897 current_layout = layout;
898 setLayout(cur, layout);
899 bv->owner()->setLayout(layout);
905 case LFUN_CLIPBOARD_PASTE: {
906 cur.clearSelection();
907 docstring const clip = bv->owner()->gui().clipboard().get();
910 if (cmd.argument() == "paragraph")
911 insertStringAsParagraphs(cur, clip);
913 insertStringAsLines(cur, clip);
918 case LFUN_PRIMARY_SELECTION_PASTE: {
919 cur.clearSelection();
920 docstring const clip = bv->owner()->gui().selection().get();
923 if (cmd.argument() == "paragraph")
924 insertStringAsParagraphs(cur, clip);
926 insertStringAsLines(cur, clip);
931 case LFUN_QUOTE_INSERT: {
932 lyx::cap::replaceSelection(cur);
933 Paragraph & par = cur.paragraph();
934 lyx::pos_type pos = cur.pos();
938 else if (cur.prevInset() && cur.prevInset()->isSpace())
941 c = par.getChar(pos - 1);
943 LyXLayout_ptr const & style = par.layout();
945 BufferParams const & bufparams = bv->buffer()->params();
946 if (!style->pass_thru
947 && par.getFontSettings(bufparams, pos).language()->lang() != "hebrew") {
948 string arg = lyx::to_utf8(cmd.argument());
950 cur.insert(new InsetQuotes(c,
951 bufparams.quotes_language,
952 InsetQuotes::SingleQ));
954 cur.insert(new InsetQuotes(c,
955 bufparams.quotes_language,
956 InsetQuotes::DoubleQ));
960 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT, "\""));
964 case LFUN_DATE_INSERT:
965 if (cmd.argument().empty())
966 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT,
967 lyx::formatted_time(lyx::current_time())));
969 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT,
970 lyx::formatted_time(lyx::current_time(), lyx::to_utf8(cmd.argument()))));
973 case LFUN_MOUSE_TRIPLE:
974 if (cmd.button() == mouse_button::button1) {
980 bv->owner()->gui().selection().haveSelection(cur.selection());
984 case LFUN_MOUSE_DOUBLE:
985 if (cmd.button() == mouse_button::button1) {
986 selectWord(cur, lyx::WHOLE_WORD_STRICT);
988 bv->owner()->gui().selection().haveSelection(cur.selection());
992 // Single-click on work area
993 case LFUN_MOUSE_PRESS: {
994 // Right click on a footnote flag opens float menu
995 if (cmd.button() == mouse_button::button3)
996 cur.clearSelection();
998 // Middle button press pastes if we have a selection
999 // We do this here as if the selection was inside an inset
1000 // it could get cleared on the unlocking of the inset so
1001 // we have to check this first
1002 bool paste_internally = false;
1003 if (cmd.button() == mouse_button::button2 && cur.selection()) {
1004 bv->owner()->dispatch(FuncRequest(LFUN_COPY));
1005 paste_internally = true;
1008 bv->mouseSetCursor(cur);
1010 // Insert primary selection with middle mouse
1011 // if there is a local selection in the current buffer,
1013 if (cmd.button() == mouse_button::button2) {
1014 if (paste_internally)
1015 bv->owner()->dispatch(FuncRequest(LFUN_PASTE));
1017 bv->owner()->dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph"));
1023 case LFUN_MOUSE_MOTION: {
1024 // Only use motion with button 1
1025 //if (cmd.button() != mouse_button::button1)
1028 // ignore motions deeper nested than the real anchor
1029 LCursor & bvcur = cur.bv().cursor();
1030 if (bvcur.anchor_.hasPart(cur)) {
1031 CursorSlice old = bvcur.top();
1033 int const wh = bv->workHeight();
1034 int const y = std::max(0, std::min(wh - 1, cmd.y));
1036 setCursorFromCoordinates(cur, cmd.x, y);
1037 cur.x_target() = cmd.x;
1042 // This is to allow jumping over large insets
1043 if (cur.top() == old) {
1050 if (cur.top() == old)
1053 // don't set anchor_
1054 bvcur.setCursor(cur);
1055 bvcur.selection() = true;
1056 //lyxerr << "MOTION: " << bv->cursor() << endl;
1064 case LFUN_MOUSE_RELEASE: {
1065 if (cmd.button() == mouse_button::button2)
1069 if (cmd.button() == mouse_button::button1)
1070 bv->owner()->gui().selection().haveSelection(cur.selection());
1073 bv->owner()->updateMenubar();
1074 bv->owner()->updateToolbars();
1078 case LFUN_SELF_INSERT: {
1079 if (cmd.argument().empty())
1082 // Automatically delete the currently selected
1083 // text and replace it with what is being
1084 // typed in now. Depends on lyxrc settings
1085 // "auto_region_delete", which defaults to
1088 if (lyxrc.auto_region_delete) {
1089 if (cur.selection())
1090 cutSelection(cur, false, false);
1091 bv->owner()->gui().selection().haveSelection(false);
1094 cur.clearSelection();
1095 LyXFont const old_font = real_current_font;
1097 docstring::const_iterator cit = cmd.argument().begin();
1098 docstring::const_iterator end = cmd.argument().end();
1099 for (; cit != end; ++cit)
1101 bv->owner()->getIntl().getTransManager().
1102 translateAndInsert(*cit, this);
1104 insertChar(bv->cursor(), *cit);
1108 moveCursor(cur, false);
1112 case LFUN_URL_INSERT: {
1113 InsetCommandParams p("url");
1114 string const data = InsetCommandMailer::params2string("url", p);
1115 bv->owner()->getDialogs().show("url", data, 0);
1119 case LFUN_HTML_INSERT: {
1120 InsetCommandParams p("htmlurl");
1121 string const data = InsetCommandMailer::params2string("url", p);
1122 bv->owner()->getDialogs().show("url", data, 0);
1126 case LFUN_LABEL_INSERT: {
1127 // Try to generate a valid label
1128 string const contents = cmd.argument().empty() ?
1129 cur.getPossibleLabel() : lyx::to_utf8(cmd.argument());
1131 InsetCommandParams p("label", contents);
1132 string const data = InsetCommandMailer::params2string("label", p);
1134 if (cmd.argument().empty()) {
1135 bv->owner()->getDialogs().show("label", data, 0);
1137 FuncRequest fr(LFUN_INSET_INSERT, data);
1145 case LFUN_LIST_INSERT:
1146 case LFUN_THEOREM_INSERT:
1147 case LFUN_CAPTION_INSERT:
1149 case LFUN_NOTE_INSERT:
1150 case LFUN_CHARSTYLE_INSERT:
1151 case LFUN_BOX_INSERT:
1152 case LFUN_BRANCH_INSERT:
1153 case LFUN_BIBITEM_INSERT:
1154 case LFUN_ERT_INSERT:
1155 case LFUN_FOOTNOTE_INSERT:
1156 case LFUN_MARGINALNOTE_INSERT:
1157 case LFUN_OPTIONAL_INSERT:
1158 case LFUN_ENVIRONMENT_INSERT:
1159 // Open the inset, and move the current selection
1161 doInsertInset(cur, this, cmd, true, true);
1165 case LFUN_TABULAR_INSERT:
1166 // if there were no arguments, just open the dialog
1167 if (doInsertInset(cur, this, cmd, false, true))
1170 bv->owner()->getDialogs().show("tabularcreate");
1174 case LFUN_FLOAT_INSERT:
1175 case LFUN_FLOAT_WIDE_INSERT:
1176 case LFUN_WRAP_INSERT:
1177 doInsertInset(cur, this, cmd, true, true);
1179 // FIXME: the "Caption" name should not be hardcoded,
1180 // but given by the float definition.
1181 cur.dispatch(FuncRequest(LFUN_LAYOUT, "Caption"));
1184 case LFUN_INDEX_INSERT: {
1185 InsetBase * inset = createInset(&cur.bv(), cmd);
1190 cur.clearSelection();
1191 insertInset(cur, inset);
1192 inset->edit(cur, true);
1197 case LFUN_INDEX_PRINT:
1198 case LFUN_TOC_INSERT:
1199 case LFUN_HFILL_INSERT:
1200 case LFUN_LINE_INSERT:
1201 case LFUN_PAGEBREAK_INSERT:
1203 doInsertInset(cur, this, cmd, false, false);
1207 case LFUN_DEPTH_DECREMENT:
1208 changeDepth(cur, DEC_DEPTH);
1211 case LFUN_DEPTH_INCREMENT:
1212 changeDepth(cur, INC_DEPTH);
1215 case LFUN_MATH_DISPLAY:
1216 mathDispatch(cur, cmd, true);
1219 case LFUN_MATH_IMPORT_SELECTION:
1220 case LFUN_MATH_MODE:
1221 if (cmd.argument() == "on")
1222 // don't pass "on" as argument
1223 mathDispatch(cur, FuncRequest(LFUN_MATH_MODE), false);
1225 mathDispatch(cur, cmd, false);
1228 case LFUN_MATH_MACRO:
1229 if (cmd.argument().empty())
1230 cur.errorMessage(N_("Missing argument"));
1232 string s = lyx::to_utf8(cmd.argument());
1233 string const s1 = token(s, ' ', 1);
1234 int const nargs = s1.empty() ? 0 : convert<int>(s1);
1235 string const s2 = token(s, ' ', 2);
1236 string const type = s2.empty() ? "newcommand" : s2;
1237 cur.insert(new MathMacroTemplate(token(s, ' ', 0), nargs, type));
1238 //cur.nextInset()->edit(cur, true);
1242 // passthrough hat and underscore outside mathed:
1243 case LFUN_MATH_SUBSCRIPT:
1244 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "_"), false);
1246 case LFUN_MATH_SUPERSCRIPT:
1247 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "^"), false);
1250 case LFUN_MATH_INSERT:
1251 case LFUN_MATH_MATRIX:
1252 case LFUN_MATH_DELIM:
1253 case LFUN_MATH_BIGDELIM: {
1254 cur.insert(new MathHullInset("simple"));
1255 cur.dispatch(FuncRequest(LFUN_CHAR_FORWARD));
1260 case LFUN_FONT_EMPH: {
1261 LyXFont font(LyXFont::ALL_IGNORE);
1262 font.setEmph(LyXFont::TOGGLE);
1263 toggleAndShow(cur, this, font);
1267 case LFUN_FONT_BOLD: {
1268 LyXFont font(LyXFont::ALL_IGNORE);
1269 font.setSeries(LyXFont::BOLD_SERIES);
1270 toggleAndShow(cur, this, font);
1274 case LFUN_FONT_NOUN: {
1275 LyXFont font(LyXFont::ALL_IGNORE);
1276 font.setNoun(LyXFont::TOGGLE);
1277 toggleAndShow(cur, this, font);
1281 case LFUN_FONT_CODE: {
1282 LyXFont font(LyXFont::ALL_IGNORE);
1283 font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
1284 toggleAndShow(cur, this, font);
1288 case LFUN_FONT_SANS: {
1289 LyXFont font(LyXFont::ALL_IGNORE);
1290 font.setFamily(LyXFont::SANS_FAMILY);
1291 toggleAndShow(cur, this, font);
1295 case LFUN_FONT_ROMAN: {
1296 LyXFont font(LyXFont::ALL_IGNORE);
1297 font.setFamily(LyXFont::ROMAN_FAMILY);
1298 toggleAndShow(cur, this, font);
1302 case LFUN_FONT_DEFAULT: {
1303 LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
1304 toggleAndShow(cur, this, font);
1308 case LFUN_FONT_UNDERLINE: {
1309 LyXFont font(LyXFont::ALL_IGNORE);
1310 font.setUnderbar(LyXFont::TOGGLE);
1311 toggleAndShow(cur, this, font);
1315 case LFUN_FONT_SIZE: {
1316 LyXFont font(LyXFont::ALL_IGNORE);
1317 font.setLyXSize(lyx::to_utf8(cmd.argument()));
1318 toggleAndShow(cur, this, font);
1322 case LFUN_LANGUAGE: {
1323 Language const * lang = languages.getLanguage(lyx::to_utf8(cmd.argument()));
1326 LyXFont font(LyXFont::ALL_IGNORE);
1327 font.setLanguage(lang);
1328 toggleAndShow(cur, this, font);
1333 case LFUN_FONT_FREE_APPLY:
1334 toggleAndShow(cur, this, freefont, toggleall);
1335 cur.message(_("Character set"));
1338 // Set the freefont using the contents of \param data dispatched from
1339 // the frontends and apply it at the current cursor location.
1340 case LFUN_FONT_FREE_UPDATE: {
1343 if (bv_funcs::string2font(lyx::to_utf8(cmd.argument()), font, toggle)) {
1346 toggleAndShow(cur, this, freefont, toggleall);
1347 cur.message(_("Character set"));
1352 case LFUN_FINISHED_LEFT:
1353 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_LEFT:\n" << cur << endl;
1356 case LFUN_FINISHED_RIGHT:
1357 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_RIGHT:\n" << cur << endl;
1361 case LFUN_FINISHED_UP:
1362 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_UP:\n" << cur << endl;
1366 case LFUN_FINISHED_DOWN:
1367 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_DOWN:\n" << cur << endl;
1371 case LFUN_LAYOUT_PARAGRAPH: {
1373 params2string(cur.paragraph(), data);
1374 data = "show\n" + data;
1375 bv->owner()->getDialogs().show("paragraph", data);
1379 case LFUN_PARAGRAPH_UPDATE: {
1380 if (!bv->owner()->getDialogs().visible("paragraph"))
1383 params2string(cur.paragraph(), data);
1385 // Will the paragraph accept changes from the dialog?
1386 bool const accept = !cur.inset().forceDefaultParagraphs(cur.idx());
1388 data = "update " + convert<string>(accept) + '\n' + data;
1389 bv->owner()->getDialogs().update("paragraph", data);
1393 case LFUN_ACCENT_UMLAUT:
1394 case LFUN_ACCENT_CIRCUMFLEX:
1395 case LFUN_ACCENT_GRAVE:
1396 case LFUN_ACCENT_ACUTE:
1397 case LFUN_ACCENT_TILDE:
1398 case LFUN_ACCENT_CEDILLA:
1399 case LFUN_ACCENT_MACRON:
1400 case LFUN_ACCENT_DOT:
1401 case LFUN_ACCENT_UNDERDOT:
1402 case LFUN_ACCENT_UNDERBAR:
1403 case LFUN_ACCENT_CARON:
1404 case LFUN_ACCENT_SPECIAL_CARON:
1405 case LFUN_ACCENT_BREVE:
1406 case LFUN_ACCENT_TIE:
1407 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1408 case LFUN_ACCENT_CIRCLE:
1409 case LFUN_ACCENT_OGONEK:
1410 bv->owner()->getLyXFunc().handleKeyFunc(cmd.action);
1411 if (!cmd.argument().empty())
1412 // FIXME: Are all these characters encoded in one byte in utf8?
1413 bv->owner()->getIntl().getTransManager()
1414 .translateAndInsert(cmd.argument()[0], this);
1417 case LFUN_FLOAT_LIST: {
1418 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
1419 if (tclass.floats().typeExist(lyx::to_utf8(cmd.argument()))) {
1420 // not quite sure if we want this...
1422 cur.clearSelection();
1423 breakParagraph(cur);
1425 if (cur.lastpos() != 0) {
1427 breakParagraph(cur);
1430 setLayout(cur, tclass.defaultLayoutName());
1431 setParagraph(cur, Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
1432 insertInset(cur, new InsetFloatList(lyx::to_utf8(cmd.argument())));
1435 lyxerr << "Non-existent float type: "
1436 << lyx::to_utf8(cmd.argument()) << endl;
1441 case LFUN_CHANGE_ACCEPT: {
1446 case LFUN_CHANGE_REJECT: {
1451 case LFUN_THESAURUS_ENTRY: {
1452 docstring arg = cmd.argument();
1454 arg = cur.selectionAsString(false);
1456 if (arg.size() > 100 || arg.empty()) {
1457 // Get word or selection
1458 selectWordWhenUnderCursor(cur, lyx::WHOLE_WORD);
1459 arg = cur.selectionAsString(false);
1462 bv->owner()->getDialogs().show("thesaurus", lyx::to_utf8(arg));
1466 case LFUN_PARAGRAPH_PARAMS_APPLY: {
1467 // Given data, an encoding of the ParagraphParameters
1468 // generated in the Paragraph dialog, this function sets
1469 // the current paragraph appropriately.
1470 istringstream is(lyx::to_utf8(cmd.argument()));
1473 ParagraphParameters params;
1478 params.labelWidthString(),
1480 cur.message(_("Paragraph layout set"));
1485 if (cur.selection()) {
1486 cur.selection() = false;
1489 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
1494 lyxerr[Debug::ACTION]
1495 << BOOST_CURRENT_FUNCTION
1496 << ": Command " << cmd
1497 << " not DISPATCHED by LyXText" << endl;
1502 if (singleParUpdate)
1503 // Inserting characters does not change par height
1504 if (cur.bottom().paragraph().dim().height()
1505 == olddim.height()) {
1506 // if so, update _only_ this paragraph
1507 cur.bv().update(Update::SinglePar |
1509 Update::MultiParSel);
1515 && &oldTopSlice.inset() == &cur.inset()
1516 && oldTopSlice.idx() == cur.idx()
1518 && !cur.selection())
1525 bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
1526 FuncStatus & flag) const
1528 BOOST_ASSERT(cur.text() == this);
1530 LyXFont const & font = real_current_font;
1532 InsetBase::Code code = InsetBase::NO_CODE;
1534 switch (cmd.action) {
1536 case LFUN_DEPTH_DECREMENT:
1537 enable = changeDepthAllowed(cur, DEC_DEPTH);
1540 case LFUN_DEPTH_INCREMENT:
1541 enable = changeDepthAllowed(cur, INC_DEPTH);
1545 flag.setOnOff(cur.paragraph().params().startOfAppendix());
1548 case LFUN_BIBITEM_INSERT:
1549 enable = (cur.paragraph().layout()->labeltype == LABEL_BIBLIO);
1552 case LFUN_DIALOG_SHOW_NEW_INSET:
1553 if (cmd.argument() == "bibitem")
1554 code = InsetBase::BIBITEM_CODE;
1555 else if (cmd.argument() == "bibtex")
1556 code = InsetBase::BIBTEX_CODE;
1557 else if (cmd.argument() == "box")
1558 code = InsetBase::BOX_CODE;
1559 else if (cmd.argument() == "branch")
1560 code = InsetBase::BRANCH_CODE;
1561 else if (cmd.argument() == "citation")
1562 code = InsetBase::CITE_CODE;
1563 else if (cmd.argument() == "ert")
1564 code = InsetBase::ERT_CODE;
1565 else if (cmd.argument() == "external")
1566 code = InsetBase::EXTERNAL_CODE;
1567 else if (cmd.argument() == "float")
1568 code = InsetBase::FLOAT_CODE;
1569 else if (cmd.argument() == "graphics")
1570 code = InsetBase::GRAPHICS_CODE;
1571 else if (cmd.argument() == "include")
1572 code = InsetBase::INCLUDE_CODE;
1573 else if (cmd.argument() == "index")
1574 code = InsetBase::INDEX_CODE;
1575 else if (cmd.argument() == "label")
1576 code = InsetBase::LABEL_CODE;
1577 else if (cmd.argument() == "note")
1578 code = InsetBase::NOTE_CODE;
1579 else if (cmd.argument() == "ref")
1580 code = InsetBase::REF_CODE;
1581 else if (cmd.argument() == "toc")
1582 code = InsetBase::TOC_CODE;
1583 else if (cmd.argument() == "url")
1584 code = InsetBase::URL_CODE;
1585 else if (cmd.argument() == "vspace")
1586 code = InsetBase::VSPACE_CODE;
1587 else if (cmd.argument() == "wrap")
1588 code = InsetBase::WRAP_CODE;
1591 case LFUN_ERT_INSERT:
1592 code = InsetBase::ERT_CODE;
1594 case LFUN_FOOTNOTE_INSERT:
1595 code = InsetBase::FOOT_CODE;
1597 case LFUN_TABULAR_INSERT:
1598 code = InsetBase::TABULAR_CODE;
1600 case LFUN_MARGINALNOTE_INSERT:
1601 code = InsetBase::MARGIN_CODE;
1603 case LFUN_FLOAT_INSERT:
1604 case LFUN_FLOAT_WIDE_INSERT:
1605 code = InsetBase::FLOAT_CODE;
1607 case LFUN_WRAP_INSERT:
1608 code = InsetBase::WRAP_CODE;
1610 case LFUN_FLOAT_LIST:
1611 code = InsetBase::FLOAT_LIST_CODE;
1614 case LFUN_LIST_INSERT:
1615 code = InsetBase::LIST_CODE;
1617 case LFUN_THEOREM_INSERT:
1618 code = InsetBase::THEOREM_CODE;
1621 case LFUN_CAPTION_INSERT:
1622 code = InsetBase::CAPTION_CODE;
1624 case LFUN_NOTE_INSERT:
1625 code = InsetBase::NOTE_CODE;
1627 case LFUN_CHARSTYLE_INSERT:
1628 code = InsetBase::CHARSTYLE_CODE;
1629 if (cur.buffer().params().getLyXTextClass().charstyles().empty())
1632 case LFUN_BOX_INSERT:
1633 code = InsetBase::BOX_CODE;
1635 case LFUN_BRANCH_INSERT:
1636 code = InsetBase::BRANCH_CODE;
1637 if (cur.buffer().getMasterBuffer()->params().branchlist().empty())
1640 case LFUN_LABEL_INSERT:
1641 code = InsetBase::LABEL_CODE;
1643 case LFUN_OPTIONAL_INSERT:
1644 code = InsetBase::OPTARG_CODE;
1645 enable = numberOfOptArgs(cur.paragraph())
1646 < cur.paragraph().layout()->optionalargs;
1648 case LFUN_ENVIRONMENT_INSERT:
1649 code = InsetBase::BOX_CODE;
1651 case LFUN_INDEX_INSERT:
1652 code = InsetBase::INDEX_CODE;
1654 case LFUN_INDEX_PRINT:
1655 code = InsetBase::INDEX_PRINT_CODE;
1657 case LFUN_TOC_INSERT:
1658 code = InsetBase::TOC_CODE;
1660 case LFUN_HTML_INSERT:
1661 case LFUN_URL_INSERT:
1662 code = InsetBase::URL_CODE;
1664 case LFUN_QUOTE_INSERT:
1665 // always allow this, since we will inset a raw quote
1666 // if an inset is not allowed.
1668 case LFUN_HYPHENATION_POINT_INSERT:
1669 case LFUN_LIGATURE_BREAK_INSERT:
1670 case LFUN_HFILL_INSERT:
1671 case LFUN_MENU_SEPARATOR_INSERT:
1672 case LFUN_DOTS_INSERT:
1673 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
1674 code = InsetBase::SPECIALCHAR_CODE;
1676 case LFUN_SPACE_INSERT:
1677 // slight hack: we know this is allowed in math mode
1679 code = InsetBase::SPACE_CODE;
1682 case LFUN_INSET_MODIFY:
1683 // We need to disable this, because we may get called for a
1685 // InsetTabular::getStatus() -> InsetText::getStatus()
1686 // and we don't handle LFUN_INSET_MODIFY.
1690 case LFUN_FONT_EMPH:
1691 flag.setOnOff(font.emph() == LyXFont::ON);
1694 case LFUN_FONT_NOUN:
1695 flag.setOnOff(font.noun() == LyXFont::ON);
1698 case LFUN_FONT_BOLD:
1699 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
1702 case LFUN_FONT_SANS:
1703 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
1706 case LFUN_FONT_ROMAN:
1707 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
1710 case LFUN_FONT_CODE:
1711 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
1716 enable = cur.selection();
1720 enable = lyx::cap::numberOfSelections() > 0;
1723 case LFUN_PARAGRAPH_MOVE_UP: {
1724 enable = cur.pit() > 0 && !cur.selection();
1728 case LFUN_PARAGRAPH_MOVE_DOWN: {
1729 enable = cur.pit() < cur.lastpit() && !cur.selection();
1733 case LFUN_INSET_DISSOLVE: {
1734 enable = &cur.inset() && cur.inTexted();
1738 case LFUN_WORD_DELETE_FORWARD:
1739 case LFUN_WORD_DELETE_BACKWARD:
1740 case LFUN_LINE_DELETE:
1741 case LFUN_WORD_FORWARD:
1742 case LFUN_WORD_BACKWARD:
1743 case LFUN_CHAR_FORWARD:
1744 case LFUN_CHAR_FORWARD_SELECT:
1745 case LFUN_CHAR_BACKWARD:
1746 case LFUN_CHAR_BACKWARD_SELECT:
1748 case LFUN_UP_SELECT:
1750 case LFUN_DOWN_SELECT:
1751 case LFUN_PARAGRAPH_UP_SELECT:
1752 case LFUN_PARAGRAPH_DOWN_SELECT:
1753 case LFUN_SCREEN_UP_SELECT:
1754 case LFUN_SCREEN_DOWN_SELECT:
1755 case LFUN_LINE_BEGIN_SELECT:
1756 case LFUN_LINE_END_SELECT:
1757 case LFUN_WORD_FORWARD_SELECT:
1758 case LFUN_WORD_BACKWARD_SELECT:
1759 case LFUN_WORD_SELECT:
1760 case LFUN_PARAGRAPH_UP:
1761 case LFUN_PARAGRAPH_DOWN:
1762 case LFUN_SCREEN_UP:
1763 case LFUN_SCREEN_DOWN:
1764 case LFUN_LINE_BEGIN:
1766 case LFUN_BREAK_LINE:
1767 case LFUN_CHAR_DELETE_FORWARD:
1768 case LFUN_DELETE_FORWARD_SKIP:
1769 case LFUN_CHAR_DELETE_BACKWARD:
1770 case LFUN_DELETE_BACKWARD_SKIP:
1771 case LFUN_BREAK_PARAGRAPH:
1772 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
1773 case LFUN_BREAK_PARAGRAPH_SKIP:
1774 case LFUN_PARAGRAPH_SPACING:
1775 case LFUN_INSET_INSERT:
1776 case LFUN_WORD_UPCASE:
1777 case LFUN_WORD_LOWCASE:
1778 case LFUN_WORD_CAPITALIZE:
1779 case LFUN_CHARS_TRANSPOSE:
1780 case LFUN_SERVER_GET_XY:
1781 case LFUN_SERVER_SET_XY:
1782 case LFUN_SERVER_GET_FONT:
1783 case LFUN_SERVER_GET_LAYOUT:
1785 case LFUN_CLIPBOARD_PASTE:
1786 case LFUN_PRIMARY_SELECTION_PASTE:
1787 case LFUN_DATE_INSERT:
1788 case LFUN_SELF_INSERT:
1789 case LFUN_LINE_INSERT:
1790 case LFUN_PAGEBREAK_INSERT:
1791 case LFUN_MATH_DISPLAY:
1792 case LFUN_MATH_IMPORT_SELECTION:
1793 case LFUN_MATH_MODE:
1794 case LFUN_MATH_MACRO:
1795 case LFUN_MATH_INSERT:
1796 case LFUN_MATH_MATRIX:
1797 case LFUN_MATH_DELIM:
1798 case LFUN_MATH_BIGDELIM:
1799 case LFUN_MATH_SUBSCRIPT:
1800 case LFUN_MATH_SUPERSCRIPT:
1801 case LFUN_FONT_DEFAULT:
1802 case LFUN_FONT_UNDERLINE:
1803 case LFUN_FONT_SIZE:
1805 case LFUN_FONT_FREE_APPLY:
1806 case LFUN_FONT_FREE_UPDATE:
1807 case LFUN_LAYOUT_PARAGRAPH:
1808 case LFUN_PARAGRAPH_UPDATE:
1809 case LFUN_ACCENT_UMLAUT:
1810 case LFUN_ACCENT_CIRCUMFLEX:
1811 case LFUN_ACCENT_GRAVE:
1812 case LFUN_ACCENT_ACUTE:
1813 case LFUN_ACCENT_TILDE:
1814 case LFUN_ACCENT_CEDILLA:
1815 case LFUN_ACCENT_MACRON:
1816 case LFUN_ACCENT_DOT:
1817 case LFUN_ACCENT_UNDERDOT:
1818 case LFUN_ACCENT_UNDERBAR:
1819 case LFUN_ACCENT_CARON:
1820 case LFUN_ACCENT_SPECIAL_CARON:
1821 case LFUN_ACCENT_BREVE:
1822 case LFUN_ACCENT_TIE:
1823 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1824 case LFUN_ACCENT_CIRCLE:
1825 case LFUN_ACCENT_OGONEK:
1826 case LFUN_CHANGE_ACCEPT:
1827 case LFUN_CHANGE_REJECT:
1828 case LFUN_THESAURUS_ENTRY:
1829 case LFUN_PARAGRAPH_PARAMS_APPLY:
1831 case LFUN_BUFFER_END:
1832 case LFUN_BUFFER_BEGIN:
1833 case LFUN_BUFFER_BEGIN_SELECT:
1834 case LFUN_BUFFER_END_SELECT:
1835 // these are handled in our dispatch()
1843 if (code != InsetBase::NO_CODE
1844 && (cur.empty() || !cur.inset().insetAllowed(code)))
1847 flag.enabled(enable);