3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Asger Alstrup
7 * \author Lars Gullik Bjønnes
8 * \author Alfredo Braunstein
9 * \author Angus Leeming
11 * \author André Pönitz
13 * Full author contact details are available in file CREDITS.
20 #include "BranchList.h"
21 #include "FloatList.h"
22 #include "FuncStatus.h"
24 #include "buffer_funcs.h"
25 #include "bufferparams.h"
26 #include "BufferView.h"
28 #include "coordcache.h"
29 #include "CutAndPaste.h"
31 #include "dispatchresult.h"
33 #include "funcrequest.h"
37 #include "LyXAction.h"
42 #include "paragraph.h"
43 #include "paragraph_funcs.h"
44 #include "ParagraphParameters.h"
47 #include "pariterator.h"
49 #include "frontends/Dialogs.h"
50 #include "frontends/LyXView.h"
52 #include "insets/insetcommand.h"
53 #include "insets/insetfloatlist.h"
54 #include "insets/insetnewline.h"
55 #include "insets/insetquotes.h"
56 #include "insets/insetspecialchar.h"
57 #include "insets/insettext.h"
59 #include "support/lstrings.h"
60 #include "support/lyxlib.h"
61 #include "support/convert.h"
62 #include "support/lyxtime.h"
64 #include "mathed/math_hullinset.h"
65 #include "mathed/math_macrotemplate.h"
67 #include <boost/current_function.hpp>
74 using lyx::cap::copySelection;
75 using lyx::cap::cutSelection;
76 using lyx::cap::pasteSelection;
77 using lyx::cap::replaceSelection;
79 using lyx::support::isStrUnsignedInt;
80 using lyx::support::token;
84 using std::istringstream;
85 using std::ostringstream;
88 extern string current_layout;
94 LyXFont freefont(LyXFont::ALL_IGNORE);
95 bool toggleall = false;
98 void toggleAndShow(LCursor & cur, LyXText * text,
99 LyXFont const & font, bool toggleall = true)
101 text->toggleFree(cur, font, toggleall);
103 if (font.language() != ignore_language ||
104 font.number() != LyXFont::IGNORE) {
105 Paragraph & par = cur.paragraph();
106 text->bidi.computeTables(par, cur.buffer(), cur.textRow());
107 if (cur.boundary() !=
108 text->bidi.isBoundary(cur.buffer(), par,
110 text->real_current_font))
111 text->setCursor(cur, cur.pit(), cur.pos(),
112 false, !cur.boundary());
117 void moveCursor(LCursor & cur, bool selecting)
119 if (selecting || cur.mark())
121 if (!cur.selection())
122 cur.bv().haveSelection(false);
123 cur.bv().switchKeyMap();
127 void finishChange(LCursor & cur, bool selecting)
130 moveCursor(cur, selecting);
134 void mathDispatch(LCursor & cur, FuncRequest const & cmd, bool display)
137 string sel = cur.selectionAsString(false);
138 //lyxerr << "selection is: '" << sel << "'" << endl;
140 // It may happen that sel is empty but there is a selection
141 replaceSelection(cur);
144 const int old_pos = cur.pos();
145 cur.insert(new MathHullInset("simple"));
146 BOOST_ASSERT(old_pos == cur.pos());
147 cur.nextInset()->edit(cur, true);
148 // don't do that also for LFUN_MATH_MODE
149 // unless you want end up with always changing
150 // to mathrm when opening an inlined inset --
151 // I really hate "LyXfunc overloading"...
153 cur.dispatch(FuncRequest(LFUN_MATH_DISPLAY));
154 // Avoid an unnecessary undo step if cmd.argument
156 if (!cmd.argument.empty())
157 cur.dispatch(FuncRequest(LFUN_MATH_INSERT,
160 // create a macro if we see "\\newcommand"
161 // somewhere, and an ordinary formula
163 istringstream is(sel);
164 if (sel.find("\\newcommand") == string::npos
165 && sel.find("\\def") == string::npos)
167 MathHullInset * formula = new MathHullInset;
170 formula->read(cur.buffer(), lex);
171 if (formula->getType() == "none")
172 // Don't create pseudo formulas if
173 // delimiters are left out
174 formula->mutate("simple");
177 cur.insert(new MathMacroTemplate(is));
179 cur.message(N_("Math editor mode"));
188 string const freefont2string()
191 if (font2string(freefont, toggleall, data))
198 bool LyXText::cursorPrevious(LCursor & cur)
200 pos_type cpos = cur.pos();
201 lyx::pit_type cpar = cur.pit();
203 int x = cur.x_target();
205 bool updated = setCursorFromCoordinates(cur, x, 0);
208 updated |= cursorUp(cur);
210 if (cpar == cur.pit() && cpos == cur.pos()) {
211 // we have a row which is taller than the workarea. The
212 // simplest solution is to move to the previous row instead.
213 updated |= cursorUp(cur);
221 bool LyXText::cursorNext(LCursor & cur)
223 pos_type cpos = cur.pos();
224 lyx::pit_type cpar = cur.pit();
226 int x = cur.x_target();
227 bool updated = setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1);
230 updated |= cursorDown(cur);
232 if (cpar == cur.pit() && cpos == cur.pos()) {
233 // we have a row which is taller than the workarea. The
234 // simplest solution is to move to the next row instead.
235 updated |= cursorDown(cur);
245 void specialChar(LCursor & cur, InsetSpecialChar::Kind kind)
247 lyx::cap::replaceSelection(cur);
248 cur.insert(new InsetSpecialChar(kind));
253 bool doInsertInset(LCursor & cur, LyXText * text,
254 FuncRequest const & cmd, bool edit, bool pastesel)
256 InsetBase * inset = createInset(&cur.bv(), cmd);
262 if (cur.selection()) {
263 cur.bv().owner()->dispatch(FuncRequest(LFUN_CUT));
266 text->insertInset(cur, inset);
269 inset->edit(cur, true);
271 if (gotsel && pastesel)
272 cur.bv().owner()->dispatch(FuncRequest(LFUN_PASTE));
277 void update(LCursor & cur)
279 //we don't call update(true, false) directly to save a metrics call
280 if (cur.bv().fitCursor())
281 cur.bv().update(Update::Force);
288 void LyXText::number(LCursor & cur)
290 LyXFont font(LyXFont::ALL_IGNORE);
291 font.setNumber(LyXFont::TOGGLE);
292 toggleAndShow(cur, this, font);
296 bool LyXText::isRTL(Paragraph const & par) const
298 return par.isRightToLeftPar(bv()->buffer()->params());
302 void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
304 lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl;
306 BOOST_ASSERT(cur.text() == this);
307 BufferView * bv = &cur.bv();
308 CursorSlice oldTopSlice = cur.top();
309 bool oldBoundary = cur.boundary();
310 bool sel = cur.selection();
311 // Signals that, even if needsUpdate == false, an update of the
312 // cursor paragraph is required
313 bool singleParUpdate = lyxaction.funcHasFlag(cmd.action,
314 LyXAction::SingleParUpdate);
315 // Signals that a full-screen update is required
316 bool needsUpdate = !(lyxaction.funcHasFlag(cmd.action,
317 LyXAction::NoUpdate) || singleParUpdate);
318 // Remember the old paragraph metric (_outer_ paragraph!)
319 Dimension olddim = cur.bottom().paragraph().dim();
321 switch (cmd.action) {
323 case LFUN_PARAGRAPH_MOVE_DOWN: {
324 pit_type const pit = cur.pit();
325 recUndo(pit, pit + 1);
327 std::swap(pars_[pit], pars_[pit + 1]);
329 ParIterator begin(cur);
331 ParIterator end = boost::next(ParIterator(cur));
332 updateLabels(cur.buffer(), begin, end);
338 case LFUN_PARAGRAPH_MOVE_UP: {
339 pit_type const pit = cur.pit();
340 recUndo(pit - 1, pit);
342 std::swap(pars_[pit], pars_[pit - 1]);
344 ParIterator end = boost::next(ParIterator(cur));
346 ParIterator begin(cur);
347 updateLabels(cur.buffer(), begin, end);
353 case LFUN_APPENDIX: {
354 Paragraph & par = cur.paragraph();
355 bool start = !par.params().startOfAppendix();
358 #warning The code below only makes sense at top level.
359 // Should LFUN_APPENDIX be restricted to top-level paragraphs?
361 // ensure that we have only one start_of_appendix in this document
362 for (pit_type tmp = 0, end = pars_.size(); tmp != end; ++tmp) {
363 if (pars_[tmp].params().startOfAppendix()) {
365 pars_[tmp].params().startOfAppendix(false);
371 par.params().startOfAppendix(start);
373 // we can set the refreshing parameters now
374 updateLabels(cur.buffer());
378 case LFUN_WORD_DELETE_FORWARD:
379 cur.clearSelection();
380 deleteWordForward(cur);
381 finishChange(cur, false);
384 case LFUN_WORD_DELETE_BACKWARD:
385 cur.clearSelection();
386 deleteWordBackward(cur);
387 finishChange(cur, false);
390 case LFUN_LINE_DELETE:
391 cur.clearSelection();
392 deleteLineForward(cur);
393 finishChange(cur, false);
396 case LFUN_WORD_FORWARD:
398 cur.clearSelection();
399 if (isRTL(cur.paragraph()))
400 needsUpdate = cursorLeftOneWord(cur);
402 needsUpdate = cursorRightOneWord(cur);
403 finishChange(cur, false);
406 case LFUN_WORD_BACKWARD:
408 cur.clearSelection();
409 if (isRTL(cur.paragraph()))
410 needsUpdate = cursorRightOneWord(cur);
412 needsUpdate = cursorLeftOneWord(cur);
413 finishChange(cur, false);
416 case LFUN_BUFFER_BEGIN:
417 if (cur.depth() == 1) {
419 cur.clearSelection();
420 needsUpdate = cursorTop(cur);
421 finishChange(cur, false);
427 case LFUN_BUFFER_BEGIN_SELECT:
428 if (cur.depth() == 1) {
429 if (!cur.selection())
431 needsUpdate = cursorTop(cur);
432 finishChange(cur, true);
438 case LFUN_BUFFER_END:
439 if (cur.depth() == 1) {
441 cur.clearSelection();
442 needsUpdate = cursorBottom(cur);
443 finishChange(cur, false);
449 case LFUN_BUFFER_END_SELECT:
450 if (cur.depth() == 1) {
451 if (!cur.selection())
453 needsUpdate = cursorBottom(cur);
454 finishChange(cur, true);
460 case LFUN_CHAR_FORWARD:
461 case LFUN_CHAR_FORWARD_SELECT:
462 //lyxerr << BOOST_CURRENT_FUNCTION
463 // << " LFUN_CHAR_FORWARD[SEL]:\n" << cur << endl;
464 cur.selHandle(cmd.action == LFUN_CHAR_FORWARD_SELECT);
465 if (isRTL(cur.paragraph()))
466 needsUpdate = cursorLeft(cur);
468 needsUpdate = cursorRight(cur);
470 if (!needsUpdate && oldTopSlice == cur.top()
471 && cur.boundary() == oldBoundary) {
473 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
477 case LFUN_CHAR_BACKWARD:
478 case LFUN_CHAR_BACKWARD_SELECT:
479 //lyxerr << "handle LFUN_CHAR_BACKWARD[_SELECT]:\n" << cur << endl;
480 cur.selHandle(cmd.action == LFUN_CHAR_BACKWARD_SELECT);
481 if (isRTL(cur.paragraph()))
482 needsUpdate = cursorRight(cur);
484 needsUpdate = cursorLeft(cur);
486 if (!needsUpdate && oldTopSlice == cur.top()
487 && cur.boundary() == oldBoundary) {
489 cmd = FuncRequest(LFUN_FINISHED_LEFT);
496 //lyxerr << "handle LFUN_UP[SEL]:\n" << cur << endl;
497 cur.selHandle(cmd.action == LFUN_UP_SELECT);
499 needsUpdate = cursorUp(cur);
500 if (!needsUpdate && oldTopSlice == cur.top()
501 && cur.boundary() == oldBoundary) {
503 cmd = FuncRequest(LFUN_FINISHED_UP);
508 case LFUN_DOWN_SELECT:
510 //lyxerr << "handle LFUN_DOWN[SEL]:\n" << cur << endl;
511 cur.selHandle(cmd.action == LFUN_DOWN_SELECT);
512 needsUpdate = cursorDown(cur);
513 if (!needsUpdate && oldTopSlice == cur.top() &&
514 cur.boundary() == oldBoundary)
517 cmd = FuncRequest(LFUN_FINISHED_DOWN);
521 case LFUN_PARAGRAPH_UP:
523 cur.clearSelection();
524 needsUpdate = cursorUpParagraph(cur);
525 finishChange(cur, false);
528 case LFUN_PARAGRAPH_UP_SELECT:
529 if (!cur.selection())
531 cursorUpParagraph(cur);
532 finishChange(cur, true);
535 case LFUN_PARAGRAPH_DOWN:
537 cur.clearSelection();
538 needsUpdate = cursorDownParagraph(cur);
539 finishChange(cur, false);
542 case LFUN_PARAGRAPH_DOWN_SELECT:
543 if (!cur.selection())
545 cursorDownParagraph(cur);
546 finishChange(cur, true);
549 case LFUN_SCREEN_UP_SELECT:
551 if (!cur.selection())
553 needsUpdate = cursorPrevious(cur);
554 finishChange(cur, true);
557 case LFUN_SCREEN_DOWN_SELECT:
559 if (!cur.selection())
561 needsUpdate = cursorNext(cur);
562 finishChange(cur, true);
565 case LFUN_LINE_BEGIN_SELECT:
567 if (!cur.selection())
569 needsUpdate = cursorHome(cur);
570 finishChange(cur, true);
573 case LFUN_LINE_END_SELECT:
575 if (!cur.selection())
577 needsUpdate = cursorEnd(cur);
578 finishChange(cur, true);
581 case LFUN_WORD_FORWARD_SELECT:
582 if (!cur.selection())
584 if (isRTL(cur.paragraph()))
585 cursorLeftOneWord(cur);
587 cursorRightOneWord(cur);
588 finishChange(cur, true);
591 case LFUN_WORD_BACKWARD_SELECT:
592 if (!cur.selection())
594 if (isRTL(cur.paragraph()))
595 cursorRightOneWord(cur);
597 cursorLeftOneWord(cur);
598 finishChange(cur, true);
601 case LFUN_WORD_SELECT: {
602 selectWord(cur, lyx::WHOLE_WORD);
603 finishChange(cur, true);
610 cur.clearSelection();
611 finishChange(cur, false);
612 if (cur.pit() == 0 && cur.textRow().pos() == 0) {
614 cmd = FuncRequest(LFUN_FINISHED_UP);
616 needsUpdate = cursorPrevious(cur);
620 case LFUN_SCREEN_DOWN:
623 cur.clearSelection();
624 finishChange(cur, false);
625 if (cur.pit() == cur.lastpit()
626 && cur.textRow().endpos() == cur.lastpos()) {
628 cmd = FuncRequest(LFUN_FINISHED_DOWN);
630 needsUpdate = cursorNext(cur);
634 case LFUN_LINE_BEGIN:
636 cur.clearSelection();
637 needsUpdate = cursorHome(cur);
638 finishChange(cur, false);
643 cur.clearSelection();
644 needsUpdate = cursorEnd(cur);
645 finishChange(cur, false);
648 case LFUN_BREAK_LINE: {
649 // Not allowed by LaTeX (labels or empty par)
650 if (cur.pos() > cur.paragraph().beginOfBody()) {
651 lyx::cap::replaceSelection(cur);
652 cur.insert(new InsetNewline);
654 moveCursor(cur, false);
659 case LFUN_CHAR_DELETE_FORWARD:
660 if (!cur.selection()) {
661 if (cur.pos() == cur.paragraph().size())
662 // Par boundary, force full-screen update
663 singleParUpdate = false;
664 needsUpdate = erase(cur);
666 // It is possible to make it a lot faster still
667 // just comment out the line below...
669 cutSelection(cur, true, false);
670 singleParUpdate = false;
672 moveCursor(cur, false);
675 case LFUN_DELETE_FORWARD_SKIP:
676 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
677 if (!cur.selection()) {
678 if (cur.pos() == cur.lastpos()) {
685 cutSelection(cur, true, false);
690 case LFUN_CHAR_DELETE_BACKWARD:
691 if (!cur.selection()) {
692 if (bv->owner()->getIntl().getTransManager().backspace()) {
693 // Par boundary, full-screen update
695 singleParUpdate = false;
696 needsUpdate = backspace(cur);
698 // It is possible to make it a lot faster still
699 // just comment out the line below...
702 cutSelection(cur, true, false);
703 singleParUpdate = false;
708 case LFUN_DELETE_BACKWARD_SKIP:
709 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
710 if (!cur.selection()) {
714 //CursorSlice cur = cursor();
718 cutSelection(cur, true, false);
722 case LFUN_BREAK_PARAGRAPH:
723 lyx::cap::replaceSelection(cur);
724 breakParagraph(cur, 0);
729 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
730 lyx::cap::replaceSelection(cur);
731 breakParagraph(cur, 1);
736 case LFUN_BREAK_PARAGRAPH_SKIP: {
737 // When at the beginning of a paragraph, remove
738 // indentation. Otherwise, do the same as LFUN_BREAK_PARAGRAPH.
739 lyx::cap::replaceSelection(cur);
741 cur.paragraph().params().labelWidthString(string());
743 breakParagraph(cur, 0);
749 case LFUN_PARAGRAPH_SPACING: {
750 Paragraph & par = cur.paragraph();
751 Spacing::Space cur_spacing = par.params().spacing().getSpace();
752 string cur_value = "1.0";
753 if (cur_spacing == Spacing::Other)
754 cur_value = par.params().spacing().getValueAsString();
756 istringstream is(cmd.argument);
759 Spacing::Space new_spacing = cur_spacing;
760 string new_value = cur_value;
762 lyxerr << "Missing argument to `paragraph-spacing'"
764 } else if (tmp == "single") {
765 new_spacing = Spacing::Single;
766 } else if (tmp == "onehalf") {
767 new_spacing = Spacing::Onehalf;
768 } else if (tmp == "double") {
769 new_spacing = Spacing::Double;
770 } else if (tmp == "other") {
771 new_spacing = Spacing::Other;
772 string tmpval = "0.0";
774 lyxerr << "new_value = " << tmpval << endl;
777 } else if (tmp == "default") {
778 new_spacing = Spacing::Default;
780 lyxerr << _("Unknown spacing argument: ")
781 << cmd.argument << endl;
783 if (cur_spacing != new_spacing || cur_value != new_value)
784 par.params().spacing(Spacing(new_spacing, new_value));
788 case LFUN_INSET_INSERT: {
790 InsetBase * inset = createInset(bv, cmd);
792 insertInset(cur, inset);
798 case LFUN_INSET_SETTINGS:
799 cur.inset().showInsetDialog(bv);
802 case LFUN_NEXT_INSET_TOGGLE: {
803 InsetBase * inset = cur.nextInset();
804 // this is the real function we want to invoke
805 cmd = FuncRequest(LFUN_INSET_TOGGLE);
807 // if there is an inset at cursor, see whether it
810 LCursor tmpcur = cur;
811 tmpcur.pushLeft(*inset);
812 inset->dispatch(tmpcur, cmd);
813 if (tmpcur.result().dispatched()) {
814 cur.clearSelection();
818 // if it did not work, try the underlying inset.
819 if (!cur.result().dispatched())
820 cur.inset().dispatch(cur, cmd);
824 case LFUN_SPACE_INSERT:
825 if (cur.paragraph().layout()->free_spacing)
826 insertChar(cur, ' ');
828 doInsertInset(cur, this, cmd, false, false);
831 moveCursor(cur, false);
834 case LFUN_HYPHENATION_POINT_INSERT:
835 specialChar(cur, InsetSpecialChar::HYPHENATION);
838 case LFUN_LIGATURE_BREAK_INSERT:
839 specialChar(cur, InsetSpecialChar::LIGATURE_BREAK);
842 case LFUN_DOTS_INSERT:
843 specialChar(cur, InsetSpecialChar::LDOTS);
846 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
847 specialChar(cur, InsetSpecialChar::END_OF_SENTENCE);
850 case LFUN_MENU_SEPARATOR_INSERT:
851 specialChar(cur, InsetSpecialChar::MENU_SEPARATOR);
854 case LFUN_WORD_UPCASE:
855 changeCase(cur, LyXText::text_uppercase);
858 case LFUN_WORD_LOWCASE:
859 changeCase(cur, LyXText::text_lowercase);
862 case LFUN_WORD_CAPITALIZE:
863 changeCase(cur, LyXText::text_capitalization);
866 case LFUN_CHARS_TRANSPOSE:
871 cur.message(_("Paste"));
872 lyx::cap::replaceSelection(cur);
873 if (isStrUnsignedInt(cmd.argument))
874 pasteSelection(cur, convert<unsigned int>(cmd.argument));
876 pasteSelection(cur, 0);
877 cur.clearSelection(); // bug 393
883 cutSelection(cur, true, true);
884 cur.message(_("Cut"));
889 cur.message(_("Copy"));
892 case LFUN_SERVER_GET_XY:
893 cur.message(convert<string>(cursorX(cur.top(), cur.boundary())) + ' '
894 + convert<string>(cursorY(cur.top(), cur.boundary())));
897 case LFUN_SERVER_SET_XY: {
900 istringstream is(cmd.argument);
903 lyxerr << "SETXY: Could not parse coordinates in '"
904 << cmd.argument << std::endl;
906 setCursorFromCoordinates(cur, x, y);
910 case LFUN_SERVER_GET_FONT:
911 if (current_font.shape() == LyXFont::ITALIC_SHAPE)
913 else if (current_font.shape() == LyXFont::SMALLCAPS_SHAPE)
919 case LFUN_SERVER_GET_LAYOUT:
920 cur.message(cur.paragraph().layout()->name());
924 lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) "
925 << cmd.argument << endl;
927 // This is not the good solution to the empty argument
928 // problem, but it will hopefully suffice for 1.2.0.
929 // The correct solution would be to augument the
930 // function list/array with information about what
931 // functions needs arguments and their type.
932 if (cmd.argument.empty()) {
933 cur.errorMessage(_("LyX function 'layout' needs an argument."));
937 // Derive layout number from given argument (string)
938 // and current buffer's textclass (number)
939 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
940 bool hasLayout = tclass.hasLayout(cmd.argument);
941 string layout = cmd.argument;
943 // If the entry is obsolete, use the new one instead.
945 string const & obs = tclass[layout]->obsoleted_by();
951 cur.errorMessage(string(N_("Layout ")) + cmd.argument +
956 bool change_layout = (current_layout != layout);
958 if (!change_layout && cur.selection() &&
959 cur.selBegin().pit() != cur.selEnd().pit())
961 pit_type spit = cur.selBegin().pit();
962 pit_type epit = cur.selEnd().pit() + 1;
963 while (spit != epit) {
964 if (pars_[spit].layout()->name() != current_layout) {
965 change_layout = true;
973 current_layout = layout;
974 setLayout(cur, layout);
975 bv->owner()->setLayout(layout);
981 case LFUN_PRIMARY_SELECTION_PASTE: {
982 cur.clearSelection();
983 string const clip = bv->getClipboard();
986 if (cmd.argument == "paragraph")
987 insertStringAsParagraphs(cur, clip);
989 insertStringAsLines(cur, clip);
994 case LFUN_QUOTE_INSERT: {
995 lyx::cap::replaceSelection(cur);
996 Paragraph & par = cur.paragraph();
997 lyx::pos_type pos = cur.pos();
1001 else if (cur.prevInset() && cur.prevInset()->isSpace())
1004 c = par.getChar(pos - 1);
1006 LyXLayout_ptr const & style = par.layout();
1008 BufferParams const & bufparams = bv->buffer()->params();
1009 if (!style->pass_thru
1010 && par.getFontSettings(bufparams, pos).language()->lang() != "hebrew") {
1011 string arg = cmd.argument;
1012 if (arg == "single")
1013 cur.insert(new InsetQuotes(c,
1014 bufparams.quotes_language,
1015 InsetQuotes::SingleQ));
1017 cur.insert(new InsetQuotes(c,
1018 bufparams.quotes_language,
1019 InsetQuotes::DoubleQ));
1023 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT, "\""));
1027 case LFUN_DATE_INSERT:
1028 if (cmd.argument.empty())
1029 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT,
1030 lyx::formatted_time(lyx::current_time())));
1032 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT,
1033 lyx::formatted_time(lyx::current_time(), cmd.argument)));
1036 case LFUN_MOUSE_TRIPLE:
1037 if (cmd.button() == mouse_button::button1) {
1043 bv->haveSelection(cur.selection());
1047 case LFUN_MOUSE_DOUBLE:
1048 if (cmd.button() == mouse_button::button1) {
1049 selectWord(cur, lyx::WHOLE_WORD_STRICT);
1051 bv->haveSelection(cur.selection());
1055 // Single-click on work area
1056 case LFUN_MOUSE_PRESS: {
1057 // Right click on a footnote flag opens float menu
1058 if (cmd.button() == mouse_button::button3)
1059 cur.clearSelection();
1061 // Middle button press pastes if we have a selection
1062 // We do this here as if the selection was inside an inset
1063 // it could get cleared on the unlocking of the inset so
1064 // we have to check this first
1065 bool paste_internally = false;
1066 if (cmd.button() == mouse_button::button2 && cur.selection()) {
1067 bv->owner()->dispatch(FuncRequest(LFUN_COPY));
1068 paste_internally = true;
1071 bv->mouseSetCursor(cur);
1073 // Insert primary selection with middle mouse
1074 // if there is a local selection in the current buffer,
1076 if (cmd.button() == mouse_button::button2) {
1077 if (paste_internally)
1078 bv->owner()->dispatch(FuncRequest(LFUN_PASTE));
1080 bv->owner()->dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph"));
1086 case LFUN_MOUSE_MOTION: {
1087 // Only use motion with button 1
1088 //if (cmd.button() != mouse_button::button1)
1091 // ignore motions deeper nested than the real anchor
1092 LCursor & bvcur = cur.bv().cursor();
1093 if (bvcur.anchor_.hasPart(cur)) {
1094 CursorSlice old = bvcur.top();
1096 int const wh = bv->workHeight();
1097 int const y = std::max(0, std::min(wh - 1, cmd.y));
1099 setCursorFromCoordinates(cur, cmd.x, y);
1100 cur.x_target() = cmd.x;
1105 // This is to allow jumping over large insets
1106 if (cur.top() == old) {
1113 if (cur.top() == old)
1116 // don't set anchor_
1117 bvcur.setCursor(cur);
1118 bvcur.selection() = true;
1119 //lyxerr << "MOTION: " << bv->cursor() << endl;
1127 case LFUN_MOUSE_RELEASE: {
1128 if (cmd.button() == mouse_button::button2)
1132 if (cmd.button() == mouse_button::button1)
1133 bv->haveSelection(cur.selection());
1136 bv->owner()->updateMenubar();
1137 bv->owner()->updateToolbars();
1141 case LFUN_SELF_INSERT: {
1142 if (cmd.argument.empty())
1145 // Automatically delete the currently selected
1146 // text and replace it with what is being
1147 // typed in now. Depends on lyxrc settings
1148 // "auto_region_delete", which defaults to
1151 if (lyxrc.auto_region_delete) {
1152 if (cur.selection())
1153 cutSelection(cur, false, false);
1154 bv->haveSelection(false);
1157 cur.clearSelection();
1158 LyXFont const old_font = real_current_font;
1160 string::const_iterator cit = cmd.argument.begin();
1161 string::const_iterator end = cmd.argument.end();
1162 for (; cit != end; ++cit)
1163 bv->owner()->getIntl().getTransManager().
1164 translateAndInsert(*cit, this);
1167 moveCursor(cur, false);
1171 case LFUN_URL_INSERT: {
1172 InsetCommandParams p("url");
1173 string const data = InsetCommandMailer::params2string("url", p);
1174 bv->owner()->getDialogs().show("url", data, 0);
1178 case LFUN_HTML_INSERT: {
1179 InsetCommandParams p("htmlurl");
1180 string const data = InsetCommandMailer::params2string("url", p);
1181 bv->owner()->getDialogs().show("url", data, 0);
1185 case LFUN_LABEL_INSERT: {
1186 // Try to generate a valid label
1187 string const contents = cmd.argument.empty() ?
1188 cur.getPossibleLabel() : cmd.argument;
1190 InsetCommandParams p("label", contents);
1191 string const data = InsetCommandMailer::params2string("label", p);
1193 if (cmd.argument.empty()) {
1194 bv->owner()->getDialogs().show("label", data, 0);
1196 FuncRequest fr(LFUN_INSET_INSERT, data);
1204 case LFUN_LIST_INSERT:
1205 case LFUN_THEOREM_INSERT:
1206 case LFUN_CAPTION_INSERT:
1208 case LFUN_NOTE_INSERT:
1209 case LFUN_CHARSTYLE_INSERT:
1210 case LFUN_BOX_INSERT:
1211 case LFUN_BRANCH_INSERT:
1212 case LFUN_BIBITEM_INSERT:
1213 case LFUN_ERT_INSERT:
1214 case LFUN_FOOTNOTE_INSERT:
1215 case LFUN_MARGINALNOTE_INSERT:
1216 case LFUN_OPTIONAL_INSERT:
1217 case LFUN_ENVIRONMENT_INSERT:
1218 // Open the inset, and move the current selection
1220 doInsertInset(cur, this, cmd, true, true);
1224 case LFUN_TABULAR_INSERT:
1225 // if there were no arguments, just open the dialog
1226 if (doInsertInset(cur, this, cmd, false, true))
1229 bv->owner()->getDialogs().show("tabularcreate");
1233 case LFUN_FLOAT_INSERT:
1234 case LFUN_FLOAT_WIDE_INSERT:
1235 case LFUN_WRAP_INSERT:
1236 doInsertInset(cur, this, cmd, true, true);
1238 // FIXME: the "Caption" name should not be hardcoded,
1239 // but given by the float definition.
1240 cur.dispatch(FuncRequest(LFUN_LAYOUT, "Caption"));
1243 case LFUN_INDEX_INSERT: {
1244 InsetBase * inset = createInset(&cur.bv(), cmd);
1249 cur.clearSelection();
1250 insertInset(cur, inset);
1251 inset->edit(cur, true);
1256 case LFUN_INDEX_PRINT:
1257 case LFUN_TOC_INSERT:
1258 case LFUN_HFILL_INSERT:
1259 case LFUN_LINE_INSERT:
1260 case LFUN_PAGEBREAK_INSERT:
1262 doInsertInset(cur, this, cmd, false, false);
1266 case LFUN_DEPTH_DECREMENT:
1267 changeDepth(cur, DEC_DEPTH);
1270 case LFUN_DEPTH_INCREMENT:
1271 changeDepth(cur, INC_DEPTH);
1274 case LFUN_MATH_DISPLAY:
1275 mathDispatch(cur, cmd, true);
1278 case LFUN_MATH_IMPORT_SELECTION:
1279 case LFUN_MATH_MODE:
1280 if (cmd.argument == "on")
1281 // don't pass "on" as argument
1282 mathDispatch(cur, FuncRequest(LFUN_MATH_MODE), false);
1284 mathDispatch(cur, cmd, false);
1287 case LFUN_MATH_MACRO:
1288 if (cmd.argument.empty())
1289 cur.errorMessage(N_("Missing argument"));
1291 string s = cmd.argument;
1292 string const s1 = token(s, ' ', 1);
1293 int const nargs = s1.empty() ? 0 : convert<int>(s1);
1294 string const s2 = token(s, ' ', 2);
1295 string const type = s2.empty() ? "newcommand" : s2;
1296 cur.insert(new MathMacroTemplate(token(s, ' ', 0), nargs, type));
1297 //cur.nextInset()->edit(cur, true);
1301 // passthrough hat and underscore outside mathed:
1302 case LFUN_MATH_SUBSCRIPT:
1303 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "_"), false);
1305 case LFUN_MATH_SUPERSCRIPT:
1306 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "^"), false);
1309 case LFUN_MATH_INSERT:
1310 case LFUN_MATH_MATRIX:
1311 case LFUN_MATH_DELIM:
1312 case LFUN_MATH_BIGDELIM: {
1313 cur.insert(new MathHullInset("simple"));
1314 cur.dispatch(FuncRequest(LFUN_CHAR_FORWARD));
1319 case LFUN_FONT_EMPH: {
1320 LyXFont font(LyXFont::ALL_IGNORE);
1321 font.setEmph(LyXFont::TOGGLE);
1322 toggleAndShow(cur, this, font);
1326 case LFUN_FONT_BOLD: {
1327 LyXFont font(LyXFont::ALL_IGNORE);
1328 font.setSeries(LyXFont::BOLD_SERIES);
1329 toggleAndShow(cur, this, font);
1333 case LFUN_FONT_NOUN: {
1334 LyXFont font(LyXFont::ALL_IGNORE);
1335 font.setNoun(LyXFont::TOGGLE);
1336 toggleAndShow(cur, this, font);
1340 case LFUN_FONT_CODE: {
1341 LyXFont font(LyXFont::ALL_IGNORE);
1342 font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
1343 toggleAndShow(cur, this, font);
1347 case LFUN_FONT_SANS: {
1348 LyXFont font(LyXFont::ALL_IGNORE);
1349 font.setFamily(LyXFont::SANS_FAMILY);
1350 toggleAndShow(cur, this, font);
1354 case LFUN_FONT_ROMAN: {
1355 LyXFont font(LyXFont::ALL_IGNORE);
1356 font.setFamily(LyXFont::ROMAN_FAMILY);
1357 toggleAndShow(cur, this, font);
1361 case LFUN_FONT_DEFAULT: {
1362 LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
1363 toggleAndShow(cur, this, font);
1367 case LFUN_FONT_UNDERLINE: {
1368 LyXFont font(LyXFont::ALL_IGNORE);
1369 font.setUnderbar(LyXFont::TOGGLE);
1370 toggleAndShow(cur, this, font);
1374 case LFUN_FONT_SIZE: {
1375 LyXFont font(LyXFont::ALL_IGNORE);
1376 font.setLyXSize(cmd.argument);
1377 toggleAndShow(cur, this, font);
1381 case LFUN_LANGUAGE: {
1382 Language const * lang = languages.getLanguage(cmd.argument);
1385 LyXFont font(LyXFont::ALL_IGNORE);
1386 font.setLanguage(lang);
1387 toggleAndShow(cur, this, font);
1392 case LFUN_FONT_FREE_APPLY:
1393 toggleAndShow(cur, this, freefont, toggleall);
1394 cur.message(_("Character set"));
1397 // Set the freefont using the contents of \param data dispatched from
1398 // the frontends and apply it at the current cursor location.
1399 case LFUN_FONT_FREE_UPDATE: {
1402 if (bv_funcs::string2font(cmd.argument, font, toggle)) {
1405 toggleAndShow(cur, this, freefont, toggleall);
1406 cur.message(_("Character set"));
1411 case LFUN_FINISHED_LEFT:
1412 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_LEFT:\n" << cur << endl;
1415 case LFUN_FINISHED_RIGHT:
1416 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_RIGHT:\n" << cur << endl;
1420 case LFUN_FINISHED_UP:
1421 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_UP:\n" << cur << endl;
1425 case LFUN_FINISHED_DOWN:
1426 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_DOWN:\n" << cur << endl;
1430 case LFUN_LAYOUT_PARAGRAPH: {
1432 params2string(cur.paragraph(), data);
1433 data = "show\n" + data;
1434 bv->owner()->getDialogs().show("paragraph", data);
1438 case LFUN_PARAGRAPH_UPDATE: {
1439 if (!bv->owner()->getDialogs().visible("paragraph"))
1442 params2string(cur.paragraph(), data);
1444 // Will the paragraph accept changes from the dialog?
1445 bool const accept = !cur.inset().forceDefaultParagraphs(cur.idx());
1447 data = "update " + convert<string>(accept) + '\n' + data;
1448 bv->owner()->getDialogs().update("paragraph", data);
1452 case LFUN_ACCENT_UMLAUT:
1453 case LFUN_ACCENT_CIRCUMFLEX:
1454 case LFUN_ACCENT_GRAVE:
1455 case LFUN_ACCENT_ACUTE:
1456 case LFUN_ACCENT_TILDE:
1457 case LFUN_ACCENT_CEDILLA:
1458 case LFUN_ACCENT_MACRON:
1459 case LFUN_ACCENT_DOT:
1460 case LFUN_ACCENT_UNDERDOT:
1461 case LFUN_ACCENT_UNDERBAR:
1462 case LFUN_ACCENT_CARON:
1463 case LFUN_ACCENT_SPECIAL_CARON:
1464 case LFUN_ACCENT_BREVE:
1465 case LFUN_ACCENT_TIE:
1466 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1467 case LFUN_ACCENT_CIRCLE:
1468 case LFUN_ACCENT_OGONEK:
1469 bv->owner()->getLyXFunc().handleKeyFunc(cmd.action);
1470 if (!cmd.argument.empty())
1471 bv->owner()->getIntl().getTransManager()
1472 .translateAndInsert(cmd.argument[0], this);
1475 case LFUN_FLOAT_LIST: {
1476 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
1477 if (tclass.floats().typeExist(cmd.argument)) {
1478 // not quite sure if we want this...
1480 cur.clearSelection();
1481 breakParagraph(cur);
1483 if (cur.lastpos() != 0) {
1485 breakParagraph(cur);
1488 setLayout(cur, tclass.defaultLayoutName());
1489 setParagraph(cur, Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
1490 insertInset(cur, new InsetFloatList(cmd.argument));
1493 lyxerr << "Non-existent float type: "
1494 << cmd.argument << endl;
1499 case LFUN_CHANGE_ACCEPT: {
1504 case LFUN_CHANGE_REJECT: {
1509 case LFUN_THESAURUS_ENTRY: {
1510 string arg = cmd.argument;
1512 arg = cur.selectionAsString(false);
1514 if (arg.size() > 100 || arg.empty()) {
1515 // Get word or selection
1516 selectWordWhenUnderCursor(cur, lyx::WHOLE_WORD);
1517 arg = cur.selectionAsString(false);
1520 bv->owner()->getDialogs().show("thesaurus", arg);
1524 case LFUN_PARAGRAPH_PARAMS_APPLY: {
1525 // Given data, an encoding of the ParagraphParameters
1526 // generated in the Paragraph dialog, this function sets
1527 // the current paragraph appropriately.
1528 istringstream is(cmd.argument);
1531 ParagraphParameters params;
1536 params.labelWidthString(),
1538 cur.message(_("Paragraph layout set"));
1542 case LFUN_INSET_DIALOG_SHOW: {
1543 InsetBase * inset = cur.nextInset();
1545 FuncRequest fr(LFUN_INSET_DIALOG_SHOW);
1546 inset->dispatch(cur, fr);
1552 if (cur.selection()) {
1553 cur.selection() = false;
1556 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
1561 lyxerr[Debug::ACTION]
1562 << BOOST_CURRENT_FUNCTION
1563 << ": Command " << cmd
1564 << " not DISPATCHED by LyXText" << endl;
1569 if (singleParUpdate)
1570 // Inserting characters does not change par height
1571 if (cur.bottom().paragraph().dim().height()
1572 == olddim.height()) {
1573 // if so, update _only_ this paragraph
1574 cur.bv().update(Update::SinglePar |
1576 Update::MultiParSel);
1582 && &oldTopSlice.inset() == &cur.inset()
1583 && oldTopSlice.idx() == cur.idx()
1585 && !cur.selection())
1592 bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
1593 FuncStatus & flag) const
1595 BOOST_ASSERT(cur.text() == this);
1597 LyXFont const & font = real_current_font;
1599 InsetBase::Code code = InsetBase::NO_CODE;
1601 switch (cmd.action) {
1603 case LFUN_DEPTH_DECREMENT:
1604 enable = changeDepthAllowed(cur, DEC_DEPTH);
1607 case LFUN_DEPTH_INCREMENT:
1608 enable = changeDepthAllowed(cur, INC_DEPTH);
1612 flag.setOnOff(cur.paragraph().params().startOfAppendix());
1615 case LFUN_BIBITEM_INSERT:
1616 enable = (cur.paragraph().layout()->labeltype == LABEL_BIBLIO);
1619 case LFUN_DIALOG_SHOW_NEW_INSET:
1620 if (cmd.argument == "bibitem")
1621 code = InsetBase::BIBITEM_CODE;
1622 else if (cmd.argument == "bibtex")
1623 code = InsetBase::BIBTEX_CODE;
1624 else if (cmd.argument == "box")
1625 code = InsetBase::BOX_CODE;
1626 else if (cmd.argument == "branch")
1627 code = InsetBase::BRANCH_CODE;
1628 else if (cmd.argument == "citation")
1629 code = InsetBase::CITE_CODE;
1630 else if (cmd.argument == "ert")
1631 code = InsetBase::ERT_CODE;
1632 else if (cmd.argument == "external")
1633 code = InsetBase::EXTERNAL_CODE;
1634 else if (cmd.argument == "float")
1635 code = InsetBase::FLOAT_CODE;
1636 else if (cmd.argument == "graphics")
1637 code = InsetBase::GRAPHICS_CODE;
1638 else if (cmd.argument == "include")
1639 code = InsetBase::INCLUDE_CODE;
1640 else if (cmd.argument == "index")
1641 code = InsetBase::INDEX_CODE;
1642 else if (cmd.argument == "label")
1643 code = InsetBase::LABEL_CODE;
1644 else if (cmd.argument == "note")
1645 code = InsetBase::NOTE_CODE;
1646 else if (cmd.argument == "ref")
1647 code = InsetBase::REF_CODE;
1648 else if (cmd.argument == "toc")
1649 code = InsetBase::TOC_CODE;
1650 else if (cmd.argument == "url")
1651 code = InsetBase::URL_CODE;
1652 else if (cmd.argument == "vspace")
1653 code = InsetBase::VSPACE_CODE;
1654 else if (cmd.argument == "wrap")
1655 code = InsetBase::WRAP_CODE;
1658 case LFUN_ERT_INSERT:
1659 code = InsetBase::ERT_CODE;
1661 case LFUN_FOOTNOTE_INSERT:
1662 code = InsetBase::FOOT_CODE;
1664 case LFUN_TABULAR_INSERT:
1665 code = InsetBase::TABULAR_CODE;
1667 case LFUN_MARGINALNOTE_INSERT:
1668 code = InsetBase::MARGIN_CODE;
1670 case LFUN_FLOAT_INSERT:
1671 case LFUN_FLOAT_WIDE_INSERT:
1672 code = InsetBase::FLOAT_CODE;
1674 case LFUN_WRAP_INSERT:
1675 code = InsetBase::WRAP_CODE;
1677 case LFUN_FLOAT_LIST:
1678 code = InsetBase::FLOAT_LIST_CODE;
1681 case LFUN_LIST_INSERT:
1682 code = InsetBase::LIST_CODE;
1684 case LFUN_THEOREM_INSERT:
1685 code = InsetBase::THEOREM_CODE;
1688 case LFUN_CAPTION_INSERT:
1689 code = InsetBase::CAPTION_CODE;
1691 case LFUN_NOTE_INSERT:
1692 code = InsetBase::NOTE_CODE;
1694 case LFUN_CHARSTYLE_INSERT:
1695 code = InsetBase::CHARSTYLE_CODE;
1696 if (cur.buffer().params().getLyXTextClass().charstyles().empty())
1699 case LFUN_BOX_INSERT:
1700 code = InsetBase::BOX_CODE;
1702 case LFUN_BRANCH_INSERT:
1703 code = InsetBase::BRANCH_CODE;
1704 if (cur.buffer().getMasterBuffer()->params().branchlist().empty())
1707 case LFUN_LABEL_INSERT:
1708 code = InsetBase::LABEL_CODE;
1710 case LFUN_OPTIONAL_INSERT:
1711 code = InsetBase::OPTARG_CODE;
1712 enable = numberOfOptArgs(cur.paragraph())
1713 < cur.paragraph().layout()->optionalargs;
1715 case LFUN_ENVIRONMENT_INSERT:
1716 code = InsetBase::BOX_CODE;
1718 case LFUN_INDEX_INSERT:
1719 code = InsetBase::INDEX_CODE;
1721 case LFUN_INDEX_PRINT:
1722 code = InsetBase::INDEX_PRINT_CODE;
1724 case LFUN_TOC_INSERT:
1725 code = InsetBase::TOC_CODE;
1727 case LFUN_HTML_INSERT:
1728 case LFUN_URL_INSERT:
1729 code = InsetBase::URL_CODE;
1731 case LFUN_QUOTE_INSERT:
1732 // always allow this, since we will inset a raw quote
1733 // if an inset is not allowed.
1735 case LFUN_HYPHENATION_POINT_INSERT:
1736 case LFUN_LIGATURE_BREAK_INSERT:
1737 case LFUN_HFILL_INSERT:
1738 case LFUN_MENU_SEPARATOR_INSERT:
1739 case LFUN_DOTS_INSERT:
1740 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
1741 code = InsetBase::SPECIALCHAR_CODE;
1743 case LFUN_SPACE_INSERT:
1744 // slight hack: we know this is allowed in math mode
1746 code = InsetBase::SPACE_CODE;
1749 #ifdef WITH_WARNINGS
1750 #warning This LFUN is not used anymore and should be nuked (JMarc 29/10/2005)
1753 case LFUN_INSET_DIALOG_SHOW: {
1754 InsetBase * inset = cur.nextInset();
1757 code = inset->lyxCode();
1758 if (!(code == InsetBase::INCLUDE_CODE
1759 || code == InsetBase::BIBTEX_CODE
1760 || code == InsetBase::FLOAT_LIST_CODE
1761 || code == InsetBase::TOC_CODE))
1768 case LFUN_INSET_MODIFY:
1769 // We need to disable this, because we may get called for a
1771 // InsetTabular::getStatus() -> InsetText::getStatus()
1772 // and we don't handle LFUN_INSET_MODIFY.
1776 case LFUN_FONT_EMPH:
1777 flag.setOnOff(font.emph() == LyXFont::ON);
1780 case LFUN_FONT_NOUN:
1781 flag.setOnOff(font.noun() == LyXFont::ON);
1784 case LFUN_FONT_BOLD:
1785 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
1788 case LFUN_FONT_SANS:
1789 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
1792 case LFUN_FONT_ROMAN:
1793 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
1796 case LFUN_FONT_CODE:
1797 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
1802 enable = cur.selection();
1806 enable = lyx::cap::numberOfSelections() > 0;
1809 case LFUN_PARAGRAPH_MOVE_UP: {
1810 enable = cur.pit() > 0 && !cur.selection();
1814 case LFUN_PARAGRAPH_MOVE_DOWN: {
1815 enable = cur.pit() < cur.lastpit() && !cur.selection();
1819 case LFUN_WORD_DELETE_FORWARD:
1820 case LFUN_WORD_DELETE_BACKWARD:
1821 case LFUN_LINE_DELETE:
1822 case LFUN_WORD_FORWARD:
1823 case LFUN_WORD_BACKWARD:
1824 case LFUN_CHAR_FORWARD:
1825 case LFUN_CHAR_FORWARD_SELECT:
1826 case LFUN_CHAR_BACKWARD:
1827 case LFUN_CHAR_BACKWARD_SELECT:
1829 case LFUN_UP_SELECT:
1831 case LFUN_DOWN_SELECT:
1832 case LFUN_PARAGRAPH_UP_SELECT:
1833 case LFUN_PARAGRAPH_DOWN_SELECT:
1834 case LFUN_SCREEN_UP_SELECT:
1835 case LFUN_SCREEN_DOWN_SELECT:
1836 case LFUN_LINE_BEGIN_SELECT:
1837 case LFUN_LINE_END_SELECT:
1838 case LFUN_WORD_FORWARD_SELECT:
1839 case LFUN_WORD_BACKWARD_SELECT:
1840 case LFUN_WORD_SELECT:
1841 case LFUN_PARAGRAPH_UP:
1842 case LFUN_PARAGRAPH_DOWN:
1843 case LFUN_SCREEN_UP:
1844 case LFUN_SCREEN_DOWN:
1845 case LFUN_LINE_BEGIN:
1847 case LFUN_BREAK_LINE:
1848 case LFUN_CHAR_DELETE_FORWARD:
1849 case LFUN_DELETE_FORWARD_SKIP:
1850 case LFUN_CHAR_DELETE_BACKWARD:
1851 case LFUN_DELETE_BACKWARD_SKIP:
1852 case LFUN_BREAK_PARAGRAPH:
1853 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
1854 case LFUN_BREAK_PARAGRAPH_SKIP:
1855 case LFUN_PARAGRAPH_SPACING:
1856 case LFUN_INSET_INSERT:
1857 case LFUN_NEXT_INSET_TOGGLE:
1858 case LFUN_WORD_UPCASE:
1859 case LFUN_WORD_LOWCASE:
1860 case LFUN_WORD_CAPITALIZE:
1861 case LFUN_CHARS_TRANSPOSE:
1862 case LFUN_SERVER_GET_XY:
1863 case LFUN_SERVER_SET_XY:
1864 case LFUN_SERVER_GET_FONT:
1865 case LFUN_SERVER_GET_LAYOUT:
1867 case LFUN_PRIMARY_SELECTION_PASTE:
1868 case LFUN_DATE_INSERT:
1869 case LFUN_SELF_INSERT:
1870 case LFUN_LINE_INSERT:
1871 case LFUN_PAGEBREAK_INSERT:
1872 case LFUN_MATH_DISPLAY:
1873 case LFUN_MATH_IMPORT_SELECTION:
1874 case LFUN_MATH_MODE:
1875 case LFUN_MATH_MACRO:
1876 case LFUN_MATH_INSERT:
1877 case LFUN_MATH_MATRIX:
1878 case LFUN_MATH_DELIM:
1879 case LFUN_MATH_BIGDELIM:
1880 case LFUN_MATH_SUBSCRIPT:
1881 case LFUN_MATH_SUPERSCRIPT:
1882 case LFUN_FONT_DEFAULT:
1883 case LFUN_FONT_UNDERLINE:
1884 case LFUN_FONT_SIZE:
1886 case LFUN_FONT_FREE_APPLY:
1887 case LFUN_FONT_FREE_UPDATE:
1888 case LFUN_LAYOUT_PARAGRAPH:
1889 case LFUN_PARAGRAPH_UPDATE:
1890 case LFUN_ACCENT_UMLAUT:
1891 case LFUN_ACCENT_CIRCUMFLEX:
1892 case LFUN_ACCENT_GRAVE:
1893 case LFUN_ACCENT_ACUTE:
1894 case LFUN_ACCENT_TILDE:
1895 case LFUN_ACCENT_CEDILLA:
1896 case LFUN_ACCENT_MACRON:
1897 case LFUN_ACCENT_DOT:
1898 case LFUN_ACCENT_UNDERDOT:
1899 case LFUN_ACCENT_UNDERBAR:
1900 case LFUN_ACCENT_CARON:
1901 case LFUN_ACCENT_SPECIAL_CARON:
1902 case LFUN_ACCENT_BREVE:
1903 case LFUN_ACCENT_TIE:
1904 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1905 case LFUN_ACCENT_CIRCLE:
1906 case LFUN_ACCENT_OGONEK:
1907 case LFUN_CHANGE_ACCEPT:
1908 case LFUN_CHANGE_REJECT:
1909 case LFUN_THESAURUS_ENTRY:
1910 case LFUN_PARAGRAPH_PARAMS_APPLY:
1912 case LFUN_BUFFER_END:
1913 case LFUN_BUFFER_BEGIN:
1914 case LFUN_BUFFER_BEGIN_SELECT:
1915 case LFUN_BUFFER_END_SELECT:
1916 // these are handled in our dispatch()
1924 if (code != InsetBase::NO_CODE
1925 && (cur.empty() || !cur.inset().insetAllowed(code)))
1928 flag.enabled(enable);