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/LyXView.h"
52 #include "frontends/Clipboard.h"
53 #include "frontends/Selection.h"
55 #include "insets/insetcommand.h"
56 #include "insets/insetfloatlist.h"
57 #include "insets/insetnewline.h"
58 #include "insets/insetquotes.h"
59 #include "insets/insetspecialchar.h"
60 #include "insets/insettext.h"
62 #include "support/lstrings.h"
63 #include "support/lyxlib.h"
64 #include "support/convert.h"
65 #include "support/lyxtime.h"
67 #include "mathed/InsetMathHull.h"
68 #include "mathed/MathMacroTemplate.h"
70 #include <boost/current_function.hpp>
79 using lyx::cap::copySelection;
80 using lyx::cap::cutSelection;
81 using lyx::cap::pasteSelection;
82 using lyx::cap::replaceSelection;
84 using lyx::support::isStrUnsignedInt;
85 using lyx::support::token;
89 using std::istringstream;
90 using std::ostringstream;
93 extern string current_layout;
99 LyXFont freefont(LyXFont::ALL_IGNORE);
100 bool toggleall = false;
103 void toggleAndShow(LCursor & cur, LyXText * text,
104 LyXFont const & font, bool toggleall = true)
106 text->toggleFree(cur, font, toggleall);
108 if (font.language() != ignore_language ||
109 font.number() != LyXFont::IGNORE) {
110 Paragraph & par = cur.paragraph();
111 text->bidi.computeTables(par, cur.buffer(), cur.textRow());
112 if (cur.boundary() !=
113 text->bidi.isBoundary(cur.buffer(), par,
115 text->real_current_font))
116 text->setCursor(cur, cur.pit(), cur.pos(),
117 false, !cur.boundary());
122 void moveCursor(LCursor & cur, bool selecting)
124 if (selecting || cur.mark())
126 if (!cur.selection())
127 theApp->selection().haveSelection(false);
128 cur.bv().switchKeyMap();
132 void finishChange(LCursor & cur, bool selecting)
135 moveCursor(cur, selecting);
139 void mathDispatch(LCursor & cur, FuncRequest const & cmd, bool display)
142 string sel = lyx::to_utf8(cur.selectionAsString(false));
143 //lyxerr << "selection is: '" << sel << "'" << endl;
145 // It may happen that sel is empty but there is a selection
146 replaceSelection(cur);
149 const int old_pos = cur.pos();
150 cur.insert(new InsetMathHull(hullSimple));
151 BOOST_ASSERT(old_pos == cur.pos());
152 cur.nextInset()->edit(cur, true);
153 // don't do that also for LFUN_MATH_MODE
154 // unless you want end up with always changing
155 // to mathrm when opening an inlined inset --
156 // I really hate "LyXfunc overloading"...
158 cur.dispatch(FuncRequest(LFUN_MATH_DISPLAY));
159 // Avoid an unnecessary undo step if cmd.argument
161 if (!cmd.argument().empty())
162 cur.dispatch(FuncRequest(LFUN_MATH_INSERT,
165 // create a macro if we see "\\newcommand"
166 // somewhere, and an ordinary formula
168 istringstream is(sel);
169 if (sel.find("\\newcommand") == string::npos
170 && sel.find("\\def") == string::npos)
172 InsetMathHull * formula = new InsetMathHull;
175 formula->read(cur.buffer(), lex);
176 if (formula->getType() == hullNone)
177 // Don't create pseudo formulas if
178 // delimiters are left out
179 formula->mutate(hullSimple);
182 cur.insert(new MathMacroTemplate(is));
184 cur.message(lyx::from_utf8(N_("Math editor mode")));
193 string const freefont2string()
196 if (font2string(freefont, toggleall, data))
203 bool LyXText::cursorPrevious(LCursor & cur)
205 pos_type cpos = cur.pos();
206 lyx::pit_type cpar = cur.pit();
208 int x = cur.x_target();
210 bool updated = setCursorFromCoordinates(cur, x, 0);
213 updated |= cursorUp(cur);
215 if (cpar == cur.pit() && cpos == cur.pos()) {
216 // we have a row which is taller than the workarea. The
217 // simplest solution is to move to the previous row instead.
218 updated |= cursorUp(cur);
226 bool LyXText::cursorNext(LCursor & cur)
228 pos_type cpos = cur.pos();
229 lyx::pit_type cpar = cur.pit();
231 int x = cur.x_target();
232 bool updated = setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1);
235 updated |= cursorDown(cur);
237 if (cpar == cur.pit() && cpos == cur.pos()) {
238 // we have a row which is taller than the workarea. The
239 // simplest solution is to move to the next row instead.
240 updated |= cursorDown(cur);
250 void specialChar(LCursor & cur, InsetSpecialChar::Kind kind)
252 lyx::cap::replaceSelection(cur);
253 cur.insert(new InsetSpecialChar(kind));
258 bool doInsertInset(LCursor & cur, LyXText * text,
259 FuncRequest const & cmd, bool edit, bool pastesel)
261 InsetBase * inset = createInset(&cur.bv(), cmd);
267 if (cur.selection()) {
268 theApp->lyxFunc().dispatch(FuncRequest(LFUN_CUT));
271 text->insertInset(cur, inset);
274 inset->edit(cur, true);
276 if (gotsel && pastesel) {
277 theApp->lyxFunc().dispatch(FuncRequest(LFUN_PASTE));
278 // reset first par to default
279 if (cur.lastpit() != 0 || cur.lastpos() != 0) {
280 LyXLayout_ptr const layout =
281 cur.buffer().params().getLyXTextClass().defaultLayout();
282 cur.text()->paragraphs().begin()->layout(layout);
289 void update(LCursor & cur)
291 //we don't call update(true, false) directly to save a metrics call
292 if (cur.bv().fitCursor())
293 cur.bv().update(Update::Force);
300 void LyXText::number(LCursor & cur)
302 LyXFont font(LyXFont::ALL_IGNORE);
303 font.setNumber(LyXFont::TOGGLE);
304 toggleAndShow(cur, this, font);
308 bool LyXText::isRTL(Paragraph const & par) const
310 return par.isRightToLeftPar(bv()->buffer()->params());
314 void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
316 lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl;
318 BOOST_ASSERT(cur.text() == this);
319 BufferView * bv = &cur.bv();
320 CursorSlice oldTopSlice = cur.top();
321 bool oldBoundary = cur.boundary();
322 bool sel = cur.selection();
323 // Signals that, even if needsUpdate == false, an update of the
324 // cursor paragraph is required
325 bool singleParUpdate = lyxaction.funcHasFlag(cmd.action,
326 LyXAction::SingleParUpdate);
327 // Signals that a full-screen update is required
328 bool needsUpdate = !(lyxaction.funcHasFlag(cmd.action,
329 LyXAction::NoUpdate) || singleParUpdate);
330 // Remember the old paragraph metric (_outer_ paragraph!)
331 Dimension olddim = cur.bottom().paragraph().dim();
333 switch (cmd.action) {
335 case LFUN_PARAGRAPH_MOVE_DOWN: {
336 pit_type const pit = cur.pit();
337 recUndo(pit, pit + 1);
339 std::swap(pars_[pit], pars_[pit + 1]);
341 ParIterator begin(cur);
343 ParIterator end = boost::next(ParIterator(cur));
344 updateLabels(cur.buffer(), begin, end);
350 case LFUN_PARAGRAPH_MOVE_UP: {
351 pit_type const pit = cur.pit();
352 recUndo(pit - 1, pit);
354 std::swap(pars_[pit], pars_[pit - 1]);
356 ParIterator end = boost::next(ParIterator(cur));
358 ParIterator begin(cur);
359 updateLabels(cur.buffer(), begin, end);
365 case LFUN_APPENDIX: {
366 Paragraph & par = cur.paragraph();
367 bool start = !par.params().startOfAppendix();
370 #warning The code below only makes sense at top level.
371 // Should LFUN_APPENDIX be restricted to top-level paragraphs?
373 // ensure that we have only one start_of_appendix in this document
374 for (pit_type tmp = 0, end = pars_.size(); tmp != end; ++tmp) {
375 if (pars_[tmp].params().startOfAppendix()) {
377 pars_[tmp].params().startOfAppendix(false);
383 par.params().startOfAppendix(start);
385 // we can set the refreshing parameters now
386 updateLabels(cur.buffer());
390 case LFUN_WORD_DELETE_FORWARD:
391 cur.clearSelection();
392 deleteWordForward(cur);
393 finishChange(cur, false);
396 case LFUN_WORD_DELETE_BACKWARD:
397 cur.clearSelection();
398 deleteWordBackward(cur);
399 finishChange(cur, false);
402 case LFUN_LINE_DELETE:
403 cur.clearSelection();
404 deleteLineForward(cur);
405 finishChange(cur, false);
408 case LFUN_BUFFER_BEGIN:
409 case LFUN_BUFFER_BEGIN_SELECT:
410 cur.selHandle(cmd.action == LFUN_BUFFER_BEGIN_SELECT);
411 if (cur.depth() == 1) {
412 needsUpdate = cursorTop(cur);
418 case LFUN_BUFFER_END:
419 case LFUN_BUFFER_END_SELECT:
420 cur.selHandle(cmd.action == LFUN_BUFFER_END_SELECT);
421 if (cur.depth() == 1) {
422 needsUpdate = cursorBottom(cur);
428 case LFUN_CHAR_FORWARD:
429 case LFUN_CHAR_FORWARD_SELECT:
430 //lyxerr << BOOST_CURRENT_FUNCTION
431 // << " LFUN_CHAR_FORWARD[SEL]:\n" << cur << endl;
432 cur.selHandle(cmd.action == LFUN_CHAR_FORWARD_SELECT);
433 if (isRTL(cur.paragraph()))
434 needsUpdate = cursorLeft(cur);
436 needsUpdate = cursorRight(cur);
438 if (!needsUpdate && oldTopSlice == cur.top()
439 && cur.boundary() == oldBoundary) {
441 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
445 case LFUN_CHAR_BACKWARD:
446 case LFUN_CHAR_BACKWARD_SELECT:
447 //lyxerr << "handle LFUN_CHAR_BACKWARD[_SELECT]:\n" << cur << endl;
448 cur.selHandle(cmd.action == LFUN_CHAR_BACKWARD_SELECT);
449 if (isRTL(cur.paragraph()))
450 needsUpdate = cursorRight(cur);
452 needsUpdate = cursorLeft(cur);
454 if (!needsUpdate && oldTopSlice == cur.top()
455 && cur.boundary() == oldBoundary) {
457 cmd = FuncRequest(LFUN_FINISHED_LEFT);
464 //lyxerr << "handle LFUN_UP[SEL]:\n" << cur << endl;
465 cur.selHandle(cmd.action == LFUN_UP_SELECT);
467 needsUpdate = cursorUp(cur);
468 if (!needsUpdate && oldTopSlice == cur.top()
469 && cur.boundary() == oldBoundary) {
471 cmd = FuncRequest(LFUN_FINISHED_UP);
476 case LFUN_DOWN_SELECT:
478 //lyxerr << "handle LFUN_DOWN[SEL]:\n" << cur << endl;
479 cur.selHandle(cmd.action == LFUN_DOWN_SELECT);
480 needsUpdate = cursorDown(cur);
481 if (!needsUpdate && oldTopSlice == cur.top() &&
482 cur.boundary() == oldBoundary)
485 cmd = FuncRequest(LFUN_FINISHED_DOWN);
489 case LFUN_PARAGRAPH_UP:
490 case LFUN_PARAGRAPH_UP_SELECT:
491 cur.selHandle(cmd.action == LFUN_PARAGRAPH_UP_SELECT);
492 needsUpdate = cursorUpParagraph(cur);
495 case LFUN_PARAGRAPH_DOWN:
496 case LFUN_PARAGRAPH_DOWN_SELECT:
497 cur.selHandle(cmd.action == LFUN_PARAGRAPH_DOWN_SELECT);
498 needsUpdate = cursorDownParagraph(cur);
502 case LFUN_SCREEN_UP_SELECT:
504 cur.selHandle(cmd.action == LFUN_SCREEN_UP_SELECT);
505 if (cur.pit() == 0 && cur.textRow().pos() == 0) {
507 cmd = FuncRequest(LFUN_FINISHED_UP);
509 needsUpdate = cursorPrevious(cur);
513 case LFUN_SCREEN_DOWN:
514 case LFUN_SCREEN_DOWN_SELECT:
516 cur.selHandle(cmd.action == LFUN_SCREEN_DOWN_SELECT);
517 if (cur.pit() == cur.lastpit()
518 && cur.textRow().endpos() == cur.lastpos()) {
520 cmd = FuncRequest(LFUN_FINISHED_DOWN);
522 needsUpdate = cursorNext(cur);
526 case LFUN_LINE_BEGIN:
527 case LFUN_LINE_BEGIN_SELECT:
529 cur.selHandle(cmd.action == LFUN_LINE_BEGIN_SELECT);
530 needsUpdate = cursorHome(cur);
534 case LFUN_LINE_END_SELECT:
536 cur.selHandle(cmd.action == LFUN_LINE_END_SELECT);
537 needsUpdate = cursorEnd(cur);
540 case LFUN_WORD_FORWARD:
541 case LFUN_WORD_FORWARD_SELECT:
542 cur.selHandle(cmd.action == LFUN_WORD_FORWARD_SELECT);
543 if (isRTL(cur.paragraph()))
544 needsUpdate = cursorLeftOneWord(cur);
546 needsUpdate = cursorRightOneWord(cur);
549 case LFUN_WORD_BACKWARD:
550 case LFUN_WORD_BACKWARD_SELECT:
551 cur.selHandle(cmd.action == LFUN_WORD_BACKWARD_SELECT);
552 if (isRTL(cur.paragraph()))
553 needsUpdate = cursorRightOneWord(cur);
555 needsUpdate = cursorLeftOneWord(cur);
558 case LFUN_WORD_SELECT: {
559 selectWord(cur, lyx::WHOLE_WORD);
560 finishChange(cur, true);
564 case LFUN_BREAK_LINE: {
565 // Not allowed by LaTeX (labels or empty par)
566 if (cur.pos() > cur.paragraph().beginOfBody()) {
567 lyx::cap::replaceSelection(cur);
568 cur.insert(new InsetNewline);
570 moveCursor(cur, false);
575 case LFUN_CHAR_DELETE_FORWARD:
576 if (!cur.selection()) {
577 if (cur.pos() == cur.paragraph().size())
578 // Par boundary, force full-screen update
579 singleParUpdate = false;
580 needsUpdate = erase(cur);
582 // It is possible to make it a lot faster still
583 // just comment out the line below...
585 cutSelection(cur, true, false);
586 singleParUpdate = false;
588 moveCursor(cur, false);
591 case LFUN_DELETE_FORWARD_SKIP:
592 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
593 if (!cur.selection()) {
594 if (cur.pos() == cur.lastpos()) {
601 cutSelection(cur, true, false);
606 case LFUN_CHAR_DELETE_BACKWARD:
607 if (!cur.selection()) {
608 if (bv->getIntl().getTransManager().backspace()) {
609 // Par boundary, full-screen update
611 singleParUpdate = false;
612 needsUpdate = backspace(cur);
614 // It is possible to make it a lot faster still
615 // just comment out the line below...
618 cutSelection(cur, true, false);
619 singleParUpdate = false;
624 case LFUN_DELETE_BACKWARD_SKIP:
625 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
626 if (!cur.selection()) {
630 //CursorSlice cur = cursor();
634 cutSelection(cur, true, false);
638 case LFUN_BREAK_PARAGRAPH:
639 lyx::cap::replaceSelection(cur);
640 breakParagraph(cur, 0);
645 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
646 lyx::cap::replaceSelection(cur);
647 breakParagraph(cur, 1);
652 case LFUN_BREAK_PARAGRAPH_SKIP: {
653 // When at the beginning of a paragraph, remove
654 // indentation. Otherwise, do the same as LFUN_BREAK_PARAGRAPH.
655 lyx::cap::replaceSelection(cur);
657 cur.paragraph().params().labelWidthString(string());
659 breakParagraph(cur, 0);
665 case LFUN_PARAGRAPH_SPACING: {
666 Paragraph & par = cur.paragraph();
667 Spacing::Space cur_spacing = par.params().spacing().getSpace();
668 string cur_value = "1.0";
669 if (cur_spacing == Spacing::Other)
670 cur_value = par.params().spacing().getValueAsString();
672 istringstream is(lyx::to_utf8(cmd.argument()));
675 Spacing::Space new_spacing = cur_spacing;
676 string new_value = cur_value;
678 lyxerr << "Missing argument to `paragraph-spacing'"
680 } else if (tmp == "single") {
681 new_spacing = Spacing::Single;
682 } else if (tmp == "onehalf") {
683 new_spacing = Spacing::Onehalf;
684 } else if (tmp == "double") {
685 new_spacing = Spacing::Double;
686 } else if (tmp == "other") {
687 new_spacing = Spacing::Other;
688 string tmpval = "0.0";
690 lyxerr << "new_value = " << tmpval << endl;
693 } else if (tmp == "default") {
694 new_spacing = Spacing::Default;
696 lyxerr << lyx::to_utf8(_("Unknown spacing argument: "))
697 << lyx::to_utf8(cmd.argument()) << endl;
699 if (cur_spacing != new_spacing || cur_value != new_value)
700 par.params().spacing(Spacing(new_spacing, new_value));
704 case LFUN_INSET_INSERT: {
706 InsetBase * inset = createInset(bv, cmd);
708 insertInset(cur, inset);
714 case LFUN_INSET_DISSOLVE:
715 needsUpdate = dissolveInset(cur);
718 case LFUN_INSET_SETTINGS:
719 cur.inset().showInsetDialog(bv);
722 case LFUN_SPACE_INSERT:
723 if (cur.paragraph().layout()->free_spacing)
724 insertChar(cur, ' ');
726 doInsertInset(cur, this, cmd, false, false);
729 moveCursor(cur, false);
732 case LFUN_HYPHENATION_POINT_INSERT:
733 specialChar(cur, InsetSpecialChar::HYPHENATION);
736 case LFUN_LIGATURE_BREAK_INSERT:
737 specialChar(cur, InsetSpecialChar::LIGATURE_BREAK);
740 case LFUN_DOTS_INSERT:
741 specialChar(cur, InsetSpecialChar::LDOTS);
744 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
745 specialChar(cur, InsetSpecialChar::END_OF_SENTENCE);
748 case LFUN_MENU_SEPARATOR_INSERT:
749 specialChar(cur, InsetSpecialChar::MENU_SEPARATOR);
752 case LFUN_WORD_UPCASE:
753 changeCase(cur, LyXText::text_uppercase);
756 case LFUN_WORD_LOWCASE:
757 changeCase(cur, LyXText::text_lowercase);
760 case LFUN_WORD_CAPITALIZE:
761 changeCase(cur, LyXText::text_capitalization);
764 case LFUN_CHARS_TRANSPOSE:
769 cur.message(_("Paste"));
770 lyx::cap::replaceSelection(cur);
771 if (isStrUnsignedInt(lyx::to_utf8(cmd.argument())))
772 pasteSelection(cur, bv->buffer()->errorList("Paste"),
773 convert<unsigned int>(lyx::to_utf8(cmd.argument())));
775 pasteSelection(cur, bv->buffer()->errorList("Paste"),
777 bv->buffer()->errors("Paste");
778 cur.clearSelection(); // bug 393
784 cutSelection(cur, true, true);
785 cur.message(_("Cut"));
790 cur.message(_("Copy"));
793 case LFUN_SERVER_GET_XY:
794 cur.message(lyx::from_utf8(
795 convert<string>(cursorX(cur.top(), cur.boundary())) + ' '
796 + convert<string>(cursorY(cur.top(), cur.boundary()))));
799 case LFUN_SERVER_SET_XY: {
802 istringstream is(lyx::to_utf8(cmd.argument()));
805 lyxerr << "SETXY: Could not parse coordinates in '"
806 << lyx::to_utf8(cmd.argument()) << std::endl;
808 setCursorFromCoordinates(cur, x, y);
812 case LFUN_SERVER_GET_FONT:
813 if (current_font.shape() == LyXFont::ITALIC_SHAPE)
814 cur.message(lyx::from_utf8("E"));
815 else if (current_font.shape() == LyXFont::SMALLCAPS_SHAPE)
816 cur.message(lyx::from_utf8("N"));
818 cur.message(lyx::from_utf8("0"));
821 case LFUN_SERVER_GET_LAYOUT:
822 cur.message(lyx::from_utf8(cur.paragraph().layout()->name()));
826 lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) "
827 << lyx::to_utf8(cmd.argument()) << endl;
829 // This is not the good solution to the empty argument
830 // problem, but it will hopefully suffice for 1.2.0.
831 // The correct solution would be to augument the
832 // function list/array with information about what
833 // functions needs arguments and their type.
834 if (cmd.argument().empty()) {
835 cur.errorMessage(_("LyX function 'layout' needs an argument."));
839 // Derive layout number from given argument (string)
840 // and current buffer's textclass (number)
841 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
842 bool hasLayout = tclass.hasLayout(lyx::to_utf8(cmd.argument()));
843 string layout = lyx::to_utf8(cmd.argument());
845 // If the entry is obsolete, use the new one instead.
847 string const & obs = tclass[layout]->obsoleted_by();
853 cur.errorMessage(lyx::from_utf8(N_("Layout ")) + cmd.argument() +
854 lyx::from_utf8(N_(" not known")));
858 bool change_layout = (current_layout != layout);
860 if (!change_layout && cur.selection() &&
861 cur.selBegin().pit() != cur.selEnd().pit())
863 pit_type spit = cur.selBegin().pit();
864 pit_type epit = cur.selEnd().pit() + 1;
865 while (spit != epit) {
866 if (pars_[spit].layout()->name() != current_layout) {
867 change_layout = true;
875 current_layout = layout;
876 setLayout(cur, layout);
877 bv->owner()->setLayout(layout);
883 case LFUN_CLIPBOARD_PASTE: {
884 cur.clearSelection();
885 docstring const clip = theApp->clipboard().get();
888 if (cmd.argument() == "paragraph")
889 insertStringAsParagraphs(cur, clip);
891 insertStringAsLines(cur, clip);
896 case LFUN_PRIMARY_SELECTION_PASTE: {
897 cur.clearSelection();
898 docstring const clip = theApp->selection().get();
901 if (cmd.argument() == "paragraph")
902 insertStringAsParagraphs(cur, clip);
904 insertStringAsLines(cur, clip);
909 case LFUN_QUOTE_INSERT: {
910 lyx::cap::replaceSelection(cur);
911 Paragraph & par = cur.paragraph();
912 lyx::pos_type pos = cur.pos();
916 else if (cur.prevInset() && cur.prevInset()->isSpace())
919 c = par.getChar(pos - 1);
921 LyXLayout_ptr const & style = par.layout();
923 BufferParams const & bufparams = bv->buffer()->params();
924 if (!style->pass_thru
925 && par.getFontSettings(bufparams, pos).language()->lang() != "hebrew") {
926 string arg = lyx::to_utf8(cmd.argument());
928 cur.insert(new InsetQuotes(c,
929 bufparams.quotes_language,
930 InsetQuotes::SingleQ));
932 cur.insert(new InsetQuotes(c,
933 bufparams.quotes_language,
934 InsetQuotes::DoubleQ));
938 theApp->lyxFunc().dispatch(FuncRequest(LFUN_SELF_INSERT, "\""));
942 case LFUN_DATE_INSERT:
943 if (cmd.argument().empty())
944 theApp->lyxFunc().dispatch(FuncRequest(LFUN_SELF_INSERT,
945 lyx::formatted_time(lyx::current_time())));
947 theApp->lyxFunc().dispatch(FuncRequest(LFUN_SELF_INSERT,
948 lyx::formatted_time(lyx::current_time(), lyx::to_utf8(cmd.argument()))));
951 case LFUN_MOUSE_TRIPLE:
952 if (cmd.button() == mouse_button::button1) {
958 theApp->selection().haveSelection(cur.selection());
962 case LFUN_MOUSE_DOUBLE:
963 if (cmd.button() == mouse_button::button1) {
964 selectWord(cur, lyx::WHOLE_WORD_STRICT);
966 theApp->selection().haveSelection(cur.selection());
970 // Single-click on work area
971 case LFUN_MOUSE_PRESS: {
972 // Right click on a footnote flag opens float menu
973 if (cmd.button() == mouse_button::button3)
974 cur.clearSelection();
976 // Middle button press pastes if we have a selection
977 // We do this here as if the selection was inside an inset
978 // it could get cleared on the unlocking of the inset so
979 // we have to check this first
980 bool paste_internally = false;
981 if (cmd.button() == mouse_button::button2 && cur.selection()) {
982 theApp->lyxFunc().dispatch(FuncRequest(LFUN_COPY));
983 paste_internally = true;
986 bv->mouseSetCursor(cur);
988 // Insert primary selection with middle mouse
989 // if there is a local selection in the current buffer,
991 if (cmd.button() == mouse_button::button2) {
992 if (paste_internally)
993 theApp->lyxFunc().dispatch(FuncRequest(LFUN_PASTE));
995 theApp->lyxFunc().dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph"));
1001 case LFUN_MOUSE_MOTION: {
1002 // Only use motion with button 1
1003 //if (cmd.button() != mouse_button::button1)
1006 // ignore motions deeper nested than the real anchor
1007 LCursor & bvcur = cur.bv().cursor();
1008 if (bvcur.anchor_.hasPart(cur)) {
1009 CursorSlice old = bvcur.top();
1011 int const wh = bv->workHeight();
1012 int const y = std::max(0, std::min(wh - 1, cmd.y));
1014 setCursorFromCoordinates(cur, cmd.x, y);
1015 cur.x_target() = cmd.x;
1020 // This is to allow jumping over large insets
1021 if (cur.top() == old) {
1028 if (cur.top() == old)
1031 // don't set anchor_
1032 bvcur.setCursor(cur);
1033 bvcur.selection() = true;
1034 //lyxerr << "MOTION: " << bv->cursor() << endl;
1042 case LFUN_MOUSE_RELEASE: {
1043 if (cmd.button() == mouse_button::button2)
1047 if (cmd.button() == mouse_button::button1)
1048 theApp->selection().haveSelection(cur.selection());
1051 bv->owner()->updateMenubar();
1052 bv->owner()->updateToolbars();
1056 case LFUN_SELF_INSERT: {
1057 if (cmd.argument().empty())
1060 // Automatically delete the currently selected
1061 // text and replace it with what is being
1062 // typed in now. Depends on lyxrc settings
1063 // "auto_region_delete", which defaults to
1066 if (lyxrc.auto_region_delete) {
1067 if (cur.selection())
1068 cutSelection(cur, false, false);
1069 theApp->selection().haveSelection(false);
1072 cur.clearSelection();
1073 LyXFont const old_font = real_current_font;
1075 docstring::const_iterator cit = cmd.argument().begin();
1076 docstring::const_iterator end = cmd.argument().end();
1077 for (; cit != end; ++cit)
1079 bv->getIntl().getTransManager().
1080 translateAndInsert(*cit, this);
1082 insertChar(bv->cursor(), *cit);
1086 moveCursor(cur, false);
1090 case LFUN_URL_INSERT: {
1091 InsetCommandParams p("url");
1092 string const data = InsetCommandMailer::params2string("url", p);
1093 bv->showInsetDialog("url", data, 0);
1097 case LFUN_HTML_INSERT: {
1098 InsetCommandParams p("htmlurl");
1099 string const data = InsetCommandMailer::params2string("url", p);
1100 bv->showInsetDialog("url", data, 0);
1104 case LFUN_LABEL_INSERT: {
1105 // Try to generate a valid label
1106 string const contents = cmd.argument().empty() ?
1107 cur.getPossibleLabel() : lyx::to_utf8(cmd.argument());
1109 InsetCommandParams p("label", contents);
1110 string const data = InsetCommandMailer::params2string("label", p);
1112 if (cmd.argument().empty()) {
1113 bv->showInsetDialog("label", data, 0);
1115 FuncRequest fr(LFUN_INSET_INSERT, data);
1123 case LFUN_LIST_INSERT:
1124 case LFUN_THEOREM_INSERT:
1125 case LFUN_CAPTION_INSERT:
1127 case LFUN_NOTE_INSERT:
1128 case LFUN_CHARSTYLE_INSERT:
1129 case LFUN_BOX_INSERT:
1130 case LFUN_BRANCH_INSERT:
1131 case LFUN_BIBITEM_INSERT:
1132 case LFUN_ERT_INSERT:
1133 case LFUN_FOOTNOTE_INSERT:
1134 case LFUN_MARGINALNOTE_INSERT:
1135 case LFUN_OPTIONAL_INSERT:
1136 case LFUN_ENVIRONMENT_INSERT:
1137 // Open the inset, and move the current selection
1139 doInsertInset(cur, this, cmd, true, true);
1143 case LFUN_TABULAR_INSERT:
1144 // if there were no arguments, just open the dialog
1145 if (doInsertInset(cur, this, cmd, false, true))
1148 bv->showDialog("tabularcreate");
1152 case LFUN_FLOAT_INSERT:
1153 case LFUN_FLOAT_WIDE_INSERT:
1154 case LFUN_WRAP_INSERT:
1155 doInsertInset(cur, this, cmd, true, true);
1157 // FIXME: the "Caption" name should not be hardcoded,
1158 // but given by the float definition.
1159 cur.dispatch(FuncRequest(LFUN_LAYOUT, "Caption"));
1162 case LFUN_INDEX_INSERT: {
1163 InsetBase * inset = createInset(&cur.bv(), cmd);
1168 cur.clearSelection();
1169 insertInset(cur, inset);
1170 inset->edit(cur, true);
1175 case LFUN_INDEX_PRINT:
1176 case LFUN_TOC_INSERT:
1177 case LFUN_HFILL_INSERT:
1178 case LFUN_LINE_INSERT:
1179 case LFUN_PAGEBREAK_INSERT:
1181 doInsertInset(cur, this, cmd, false, false);
1185 case LFUN_DEPTH_DECREMENT:
1186 changeDepth(cur, DEC_DEPTH);
1189 case LFUN_DEPTH_INCREMENT:
1190 changeDepth(cur, INC_DEPTH);
1193 case LFUN_MATH_DISPLAY:
1194 mathDispatch(cur, cmd, true);
1197 case LFUN_MATH_IMPORT_SELECTION:
1198 case LFUN_MATH_MODE:
1199 if (cmd.argument() == "on")
1200 // don't pass "on" as argument
1201 mathDispatch(cur, FuncRequest(LFUN_MATH_MODE), false);
1203 mathDispatch(cur, cmd, false);
1206 case LFUN_MATH_MACRO:
1207 if (cmd.argument().empty())
1208 cur.errorMessage(lyx::from_utf8(N_("Missing argument")));
1210 string s = lyx::to_utf8(cmd.argument());
1211 string const s1 = token(s, ' ', 1);
1212 int const nargs = s1.empty() ? 0 : convert<int>(s1);
1213 string const s2 = token(s, ' ', 2);
1214 string const type = s2.empty() ? "newcommand" : s2;
1215 cur.insert(new MathMacroTemplate(token(s, ' ', 0), nargs, type));
1216 //cur.nextInset()->edit(cur, true);
1220 // passthrough hat and underscore outside mathed:
1221 case LFUN_MATH_SUBSCRIPT:
1222 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "_"), false);
1224 case LFUN_MATH_SUPERSCRIPT:
1225 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "^"), false);
1228 case LFUN_MATH_INSERT:
1229 case LFUN_MATH_MATRIX:
1230 case LFUN_MATH_DELIM:
1231 case LFUN_MATH_BIGDELIM: {
1232 cur.insert(new InsetMathHull(hullSimple));
1233 cur.dispatch(FuncRequest(LFUN_CHAR_FORWARD));
1238 case LFUN_FONT_EMPH: {
1239 LyXFont font(LyXFont::ALL_IGNORE);
1240 font.setEmph(LyXFont::TOGGLE);
1241 toggleAndShow(cur, this, font);
1245 case LFUN_FONT_BOLD: {
1246 LyXFont font(LyXFont::ALL_IGNORE);
1247 font.setSeries(LyXFont::BOLD_SERIES);
1248 toggleAndShow(cur, this, font);
1252 case LFUN_FONT_NOUN: {
1253 LyXFont font(LyXFont::ALL_IGNORE);
1254 font.setNoun(LyXFont::TOGGLE);
1255 toggleAndShow(cur, this, font);
1259 case LFUN_FONT_CODE: {
1260 LyXFont font(LyXFont::ALL_IGNORE);
1261 font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
1262 toggleAndShow(cur, this, font);
1266 case LFUN_FONT_SANS: {
1267 LyXFont font(LyXFont::ALL_IGNORE);
1268 font.setFamily(LyXFont::SANS_FAMILY);
1269 toggleAndShow(cur, this, font);
1273 case LFUN_FONT_ROMAN: {
1274 LyXFont font(LyXFont::ALL_IGNORE);
1275 font.setFamily(LyXFont::ROMAN_FAMILY);
1276 toggleAndShow(cur, this, font);
1280 case LFUN_FONT_DEFAULT: {
1281 LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
1282 toggleAndShow(cur, this, font);
1286 case LFUN_FONT_UNDERLINE: {
1287 LyXFont font(LyXFont::ALL_IGNORE);
1288 font.setUnderbar(LyXFont::TOGGLE);
1289 toggleAndShow(cur, this, font);
1293 case LFUN_FONT_SIZE: {
1294 LyXFont font(LyXFont::ALL_IGNORE);
1295 font.setLyXSize(lyx::to_utf8(cmd.argument()));
1296 toggleAndShow(cur, this, font);
1300 case LFUN_LANGUAGE: {
1301 Language const * lang = languages.getLanguage(lyx::to_utf8(cmd.argument()));
1304 LyXFont font(LyXFont::ALL_IGNORE);
1305 font.setLanguage(lang);
1306 toggleAndShow(cur, this, font);
1311 case LFUN_FONT_FREE_APPLY:
1312 toggleAndShow(cur, this, freefont, toggleall);
1313 cur.message(_("Character set"));
1316 // Set the freefont using the contents of \param data dispatched from
1317 // the frontends and apply it at the current cursor location.
1318 case LFUN_FONT_FREE_UPDATE: {
1321 if (bv_funcs::string2font(lyx::to_utf8(cmd.argument()), font, toggle)) {
1324 toggleAndShow(cur, this, freefont, toggleall);
1325 cur.message(_("Character set"));
1330 case LFUN_FINISHED_LEFT:
1331 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_LEFT:\n" << cur << endl;
1334 case LFUN_FINISHED_RIGHT:
1335 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_RIGHT:\n" << cur << endl;
1339 case LFUN_FINISHED_UP:
1340 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_UP:\n" << cur << endl;
1344 case LFUN_FINISHED_DOWN:
1345 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_DOWN:\n" << cur << endl;
1349 case LFUN_LAYOUT_PARAGRAPH: {
1351 params2string(cur.paragraph(), data);
1352 data = "show\n" + data;
1353 bv->showDialogWithData("paragraph", data);
1357 case LFUN_PARAGRAPH_UPDATE: {
1359 params2string(cur.paragraph(), data);
1361 // Will the paragraph accept changes from the dialog?
1362 bool const accept = !cur.inset().forceDefaultParagraphs(cur.idx());
1364 data = "update " + convert<string>(accept) + '\n' + data;
1365 bv->updateDialog("paragraph", data);
1369 case LFUN_ACCENT_UMLAUT:
1370 case LFUN_ACCENT_CIRCUMFLEX:
1371 case LFUN_ACCENT_GRAVE:
1372 case LFUN_ACCENT_ACUTE:
1373 case LFUN_ACCENT_TILDE:
1374 case LFUN_ACCENT_CEDILLA:
1375 case LFUN_ACCENT_MACRON:
1376 case LFUN_ACCENT_DOT:
1377 case LFUN_ACCENT_UNDERDOT:
1378 case LFUN_ACCENT_UNDERBAR:
1379 case LFUN_ACCENT_CARON:
1380 case LFUN_ACCENT_SPECIAL_CARON:
1381 case LFUN_ACCENT_BREVE:
1382 case LFUN_ACCENT_TIE:
1383 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1384 case LFUN_ACCENT_CIRCLE:
1385 case LFUN_ACCENT_OGONEK:
1386 theApp->lyxFunc().handleKeyFunc(cmd.action);
1387 if (!cmd.argument().empty())
1388 // FIXME: Are all these characters encoded in one byte in utf8?
1389 bv->getIntl().getTransManager()
1390 .translateAndInsert(cmd.argument()[0], this);
1393 case LFUN_FLOAT_LIST: {
1394 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
1395 if (tclass.floats().typeExist(lyx::to_utf8(cmd.argument()))) {
1396 // not quite sure if we want this...
1398 cur.clearSelection();
1399 breakParagraph(cur);
1401 if (cur.lastpos() != 0) {
1403 breakParagraph(cur);
1406 setLayout(cur, tclass.defaultLayoutName());
1407 setParagraph(cur, Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
1408 insertInset(cur, new InsetFloatList(lyx::to_utf8(cmd.argument())));
1411 lyxerr << "Non-existent float type: "
1412 << lyx::to_utf8(cmd.argument()) << endl;
1417 case LFUN_CHANGE_ACCEPT: {
1422 case LFUN_CHANGE_REJECT: {
1427 case LFUN_THESAURUS_ENTRY: {
1428 docstring arg = cmd.argument();
1430 arg = cur.selectionAsString(false);
1432 if (arg.size() > 100 || arg.empty()) {
1433 // Get word or selection
1434 selectWordWhenUnderCursor(cur, lyx::WHOLE_WORD);
1435 arg = cur.selectionAsString(false);
1438 bv->showDialogWithData("thesaurus", lyx::to_utf8(arg));
1442 case LFUN_PARAGRAPH_PARAMS_APPLY: {
1443 // Given data, an encoding of the ParagraphParameters
1444 // generated in the Paragraph dialog, this function sets
1445 // the current paragraph appropriately.
1446 istringstream is(lyx::to_utf8(cmd.argument()));
1449 ParagraphParameters params;
1454 params.labelWidthString(),
1456 cur.message(_("Paragraph layout set"));
1461 if (cur.selection()) {
1462 cur.selection() = false;
1465 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
1470 lyxerr[Debug::ACTION]
1471 << BOOST_CURRENT_FUNCTION
1472 << ": Command " << cmd
1473 << " not DISPATCHED by LyXText" << endl;
1478 if (singleParUpdate)
1479 // Inserting characters does not change par height
1480 if (cur.bottom().paragraph().dim().height()
1481 == olddim.height()) {
1482 // if so, update _only_ this paragraph
1483 cur.bv().update(Update::SinglePar |
1485 Update::MultiParSel);
1491 && &oldTopSlice.inset() == &cur.inset()
1492 && oldTopSlice.idx() == cur.idx()
1494 && !cur.selection())
1501 bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
1502 FuncStatus & flag) const
1504 BOOST_ASSERT(cur.text() == this);
1506 LyXFont const & font = real_current_font;
1508 InsetBase::Code code = InsetBase::NO_CODE;
1510 switch (cmd.action) {
1512 case LFUN_DEPTH_DECREMENT:
1513 enable = changeDepthAllowed(cur, DEC_DEPTH);
1516 case LFUN_DEPTH_INCREMENT:
1517 enable = changeDepthAllowed(cur, INC_DEPTH);
1521 flag.setOnOff(cur.paragraph().params().startOfAppendix());
1524 case LFUN_BIBITEM_INSERT:
1525 enable = (cur.paragraph().layout()->labeltype == LABEL_BIBLIO);
1528 case LFUN_DIALOG_SHOW_NEW_INSET:
1529 if (cmd.argument() == "bibitem")
1530 code = InsetBase::BIBITEM_CODE;
1531 else if (cmd.argument() == "bibtex")
1532 code = InsetBase::BIBTEX_CODE;
1533 else if (cmd.argument() == "box")
1534 code = InsetBase::BOX_CODE;
1535 else if (cmd.argument() == "branch")
1536 code = InsetBase::BRANCH_CODE;
1537 else if (cmd.argument() == "citation")
1538 code = InsetBase::CITE_CODE;
1539 else if (cmd.argument() == "ert")
1540 code = InsetBase::ERT_CODE;
1541 else if (cmd.argument() == "external")
1542 code = InsetBase::EXTERNAL_CODE;
1543 else if (cmd.argument() == "float")
1544 code = InsetBase::FLOAT_CODE;
1545 else if (cmd.argument() == "graphics")
1546 code = InsetBase::GRAPHICS_CODE;
1547 else if (cmd.argument() == "include")
1548 code = InsetBase::INCLUDE_CODE;
1549 else if (cmd.argument() == "index")
1550 code = InsetBase::INDEX_CODE;
1551 else if (cmd.argument() == "label")
1552 code = InsetBase::LABEL_CODE;
1553 else if (cmd.argument() == "note")
1554 code = InsetBase::NOTE_CODE;
1555 else if (cmd.argument() == "ref")
1556 code = InsetBase::REF_CODE;
1557 else if (cmd.argument() == "toc")
1558 code = InsetBase::TOC_CODE;
1559 else if (cmd.argument() == "url")
1560 code = InsetBase::URL_CODE;
1561 else if (cmd.argument() == "vspace")
1562 code = InsetBase::VSPACE_CODE;
1563 else if (cmd.argument() == "wrap")
1564 code = InsetBase::WRAP_CODE;
1567 case LFUN_ERT_INSERT:
1568 code = InsetBase::ERT_CODE;
1570 case LFUN_FOOTNOTE_INSERT:
1571 code = InsetBase::FOOT_CODE;
1573 case LFUN_TABULAR_INSERT:
1574 code = InsetBase::TABULAR_CODE;
1576 case LFUN_MARGINALNOTE_INSERT:
1577 code = InsetBase::MARGIN_CODE;
1579 case LFUN_FLOAT_INSERT:
1580 case LFUN_FLOAT_WIDE_INSERT:
1581 code = InsetBase::FLOAT_CODE;
1583 case LFUN_WRAP_INSERT:
1584 code = InsetBase::WRAP_CODE;
1586 case LFUN_FLOAT_LIST:
1587 code = InsetBase::FLOAT_LIST_CODE;
1590 case LFUN_LIST_INSERT:
1591 code = InsetBase::LIST_CODE;
1593 case LFUN_THEOREM_INSERT:
1594 code = InsetBase::THEOREM_CODE;
1597 case LFUN_CAPTION_INSERT:
1598 code = InsetBase::CAPTION_CODE;
1600 case LFUN_NOTE_INSERT:
1601 code = InsetBase::NOTE_CODE;
1603 case LFUN_CHARSTYLE_INSERT:
1604 code = InsetBase::CHARSTYLE_CODE;
1605 if (cur.buffer().params().getLyXTextClass().charstyles().empty())
1608 case LFUN_BOX_INSERT:
1609 code = InsetBase::BOX_CODE;
1611 case LFUN_BRANCH_INSERT:
1612 code = InsetBase::BRANCH_CODE;
1613 if (cur.buffer().getMasterBuffer()->params().branchlist().empty())
1616 case LFUN_LABEL_INSERT:
1617 code = InsetBase::LABEL_CODE;
1619 case LFUN_OPTIONAL_INSERT:
1620 code = InsetBase::OPTARG_CODE;
1621 enable = numberOfOptArgs(cur.paragraph())
1622 < cur.paragraph().layout()->optionalargs;
1624 case LFUN_ENVIRONMENT_INSERT:
1625 code = InsetBase::BOX_CODE;
1627 case LFUN_INDEX_INSERT:
1628 code = InsetBase::INDEX_CODE;
1630 case LFUN_INDEX_PRINT:
1631 code = InsetBase::INDEX_PRINT_CODE;
1633 case LFUN_TOC_INSERT:
1634 code = InsetBase::TOC_CODE;
1636 case LFUN_HTML_INSERT:
1637 case LFUN_URL_INSERT:
1638 code = InsetBase::URL_CODE;
1640 case LFUN_QUOTE_INSERT:
1641 // always allow this, since we will inset a raw quote
1642 // if an inset is not allowed.
1644 case LFUN_HYPHENATION_POINT_INSERT:
1645 case LFUN_LIGATURE_BREAK_INSERT:
1646 case LFUN_HFILL_INSERT:
1647 case LFUN_MENU_SEPARATOR_INSERT:
1648 case LFUN_DOTS_INSERT:
1649 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
1650 code = InsetBase::SPECIALCHAR_CODE;
1652 case LFUN_SPACE_INSERT:
1653 // slight hack: we know this is allowed in math mode
1655 code = InsetBase::SPACE_CODE;
1658 case LFUN_INSET_MODIFY:
1659 // We need to disable this, because we may get called for a
1661 // InsetTabular::getStatus() -> InsetText::getStatus()
1662 // and we don't handle LFUN_INSET_MODIFY.
1666 case LFUN_FONT_EMPH:
1667 flag.setOnOff(font.emph() == LyXFont::ON);
1670 case LFUN_FONT_NOUN:
1671 flag.setOnOff(font.noun() == LyXFont::ON);
1674 case LFUN_FONT_BOLD:
1675 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
1678 case LFUN_FONT_SANS:
1679 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
1682 case LFUN_FONT_ROMAN:
1683 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
1686 case LFUN_FONT_CODE:
1687 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
1692 enable = cur.selection();
1696 enable = lyx::cap::numberOfSelections() > 0;
1699 case LFUN_PARAGRAPH_MOVE_UP:
1700 enable = cur.pit() > 0 && !cur.selection();
1703 case LFUN_PARAGRAPH_MOVE_DOWN:
1704 enable = cur.pit() < cur.lastpit() && !cur.selection();
1707 case LFUN_INSET_DISSOLVE:
1708 enable = !isMainText() && cur.inset().nargs() == 1;
1711 case LFUN_WORD_DELETE_FORWARD:
1712 case LFUN_WORD_DELETE_BACKWARD:
1713 case LFUN_LINE_DELETE:
1714 case LFUN_WORD_FORWARD:
1715 case LFUN_WORD_BACKWARD:
1716 case LFUN_CHAR_FORWARD:
1717 case LFUN_CHAR_FORWARD_SELECT:
1718 case LFUN_CHAR_BACKWARD:
1719 case LFUN_CHAR_BACKWARD_SELECT:
1721 case LFUN_UP_SELECT:
1723 case LFUN_DOWN_SELECT:
1724 case LFUN_PARAGRAPH_UP_SELECT:
1725 case LFUN_PARAGRAPH_DOWN_SELECT:
1726 case LFUN_SCREEN_UP_SELECT:
1727 case LFUN_SCREEN_DOWN_SELECT:
1728 case LFUN_LINE_BEGIN_SELECT:
1729 case LFUN_LINE_END_SELECT:
1730 case LFUN_WORD_FORWARD_SELECT:
1731 case LFUN_WORD_BACKWARD_SELECT:
1732 case LFUN_WORD_SELECT:
1733 case LFUN_PARAGRAPH_UP:
1734 case LFUN_PARAGRAPH_DOWN:
1735 case LFUN_SCREEN_UP:
1736 case LFUN_SCREEN_DOWN:
1737 case LFUN_LINE_BEGIN:
1739 case LFUN_BREAK_LINE:
1740 case LFUN_CHAR_DELETE_FORWARD:
1741 case LFUN_DELETE_FORWARD_SKIP:
1742 case LFUN_CHAR_DELETE_BACKWARD:
1743 case LFUN_DELETE_BACKWARD_SKIP:
1744 case LFUN_BREAK_PARAGRAPH:
1745 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
1746 case LFUN_BREAK_PARAGRAPH_SKIP:
1747 case LFUN_PARAGRAPH_SPACING:
1748 case LFUN_INSET_INSERT:
1749 case LFUN_WORD_UPCASE:
1750 case LFUN_WORD_LOWCASE:
1751 case LFUN_WORD_CAPITALIZE:
1752 case LFUN_CHARS_TRANSPOSE:
1753 case LFUN_SERVER_GET_XY:
1754 case LFUN_SERVER_SET_XY:
1755 case LFUN_SERVER_GET_FONT:
1756 case LFUN_SERVER_GET_LAYOUT:
1758 case LFUN_CLIPBOARD_PASTE:
1759 case LFUN_PRIMARY_SELECTION_PASTE:
1760 case LFUN_DATE_INSERT:
1761 case LFUN_SELF_INSERT:
1762 case LFUN_LINE_INSERT:
1763 case LFUN_PAGEBREAK_INSERT:
1764 case LFUN_MATH_DISPLAY:
1765 case LFUN_MATH_IMPORT_SELECTION:
1766 case LFUN_MATH_MODE:
1767 case LFUN_MATH_MACRO:
1768 case LFUN_MATH_INSERT:
1769 case LFUN_MATH_MATRIX:
1770 case LFUN_MATH_DELIM:
1771 case LFUN_MATH_BIGDELIM:
1772 case LFUN_MATH_SUBSCRIPT:
1773 case LFUN_MATH_SUPERSCRIPT:
1774 case LFUN_FONT_DEFAULT:
1775 case LFUN_FONT_UNDERLINE:
1776 case LFUN_FONT_SIZE:
1778 case LFUN_FONT_FREE_APPLY:
1779 case LFUN_FONT_FREE_UPDATE:
1780 case LFUN_LAYOUT_PARAGRAPH:
1781 case LFUN_PARAGRAPH_UPDATE:
1782 case LFUN_ACCENT_UMLAUT:
1783 case LFUN_ACCENT_CIRCUMFLEX:
1784 case LFUN_ACCENT_GRAVE:
1785 case LFUN_ACCENT_ACUTE:
1786 case LFUN_ACCENT_TILDE:
1787 case LFUN_ACCENT_CEDILLA:
1788 case LFUN_ACCENT_MACRON:
1789 case LFUN_ACCENT_DOT:
1790 case LFUN_ACCENT_UNDERDOT:
1791 case LFUN_ACCENT_UNDERBAR:
1792 case LFUN_ACCENT_CARON:
1793 case LFUN_ACCENT_SPECIAL_CARON:
1794 case LFUN_ACCENT_BREVE:
1795 case LFUN_ACCENT_TIE:
1796 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1797 case LFUN_ACCENT_CIRCLE:
1798 case LFUN_ACCENT_OGONEK:
1799 case LFUN_CHANGE_ACCEPT:
1800 case LFUN_CHANGE_REJECT:
1801 case LFUN_THESAURUS_ENTRY:
1802 case LFUN_PARAGRAPH_PARAMS_APPLY:
1804 case LFUN_BUFFER_END:
1805 case LFUN_BUFFER_BEGIN:
1806 case LFUN_BUFFER_BEGIN_SELECT:
1807 case LFUN_BUFFER_END_SELECT:
1808 // these are handled in our dispatch()
1816 if (code != InsetBase::NO_CODE
1817 && (cur.empty() || !cur.inset().insetAllowed(code)))
1820 flag.enabled(enable);