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/Application.h"
51 #include "frontends/Clipboard.h"
52 #include "frontends/Selection.h"
54 #include "insets/insetcommand.h"
55 #include "insets/insetfloatlist.h"
56 #include "insets/insetnewline.h"
57 #include "insets/insetquotes.h"
58 #include "insets/insetspecialchar.h"
59 #include "insets/insettext.h"
61 #include "support/lstrings.h"
62 #include "support/lyxlib.h"
63 #include "support/convert.h"
64 #include "support/lyxtime.h"
66 #include "mathed/InsetMathHull.h"
67 #include "mathed/MathMacroTemplate.h"
69 #include <boost/current_function.hpp>
78 using lyx::cap::copySelection;
79 using lyx::cap::cutSelection;
80 using lyx::cap::pasteSelection;
81 using lyx::cap::replaceSelection;
83 using lyx::support::isStrUnsignedInt;
84 using lyx::support::token;
88 using std::istringstream;
89 using std::ostringstream;
92 extern string current_layout;
98 LyXFont freefont(LyXFont::ALL_IGNORE);
99 bool toggleall = false;
102 void toggleAndShow(LCursor & cur, LyXText * text,
103 LyXFont const & font, bool toggleall = true)
105 text->toggleFree(cur, font, toggleall);
107 if (font.language() != ignore_language ||
108 font.number() != LyXFont::IGNORE) {
109 Paragraph & par = cur.paragraph();
110 text->bidi.computeTables(par, cur.buffer(), cur.textRow());
111 if (cur.boundary() !=
112 text->bidi.isBoundary(cur.buffer(), par,
114 text->real_current_font))
115 text->setCursor(cur, cur.pit(), cur.pos(),
116 false, !cur.boundary());
121 void moveCursor(LCursor & cur, bool selecting)
123 if (selecting || cur.mark())
125 if (!cur.selection())
126 theApp->selection().haveSelection(false);
127 cur.bv().switchKeyMap();
131 void finishChange(LCursor & cur, bool selecting)
134 moveCursor(cur, selecting);
138 void mathDispatch(LCursor & cur, FuncRequest const & cmd, bool display)
141 string sel = lyx::to_utf8(cur.selectionAsString(false));
142 //lyxerr << "selection is: '" << sel << "'" << endl;
144 // It may happen that sel is empty but there is a selection
145 replaceSelection(cur);
148 const int old_pos = cur.pos();
149 cur.insert(new InsetMathHull(hullSimple));
150 BOOST_ASSERT(old_pos == cur.pos());
151 cur.nextInset()->edit(cur, true);
152 // don't do that also for LFUN_MATH_MODE
153 // unless you want end up with always changing
154 // to mathrm when opening an inlined inset --
155 // I really hate "LyXfunc overloading"...
157 cur.dispatch(FuncRequest(LFUN_MATH_DISPLAY));
158 // Avoid an unnecessary undo step if cmd.argument
160 if (!cmd.argument().empty())
161 cur.dispatch(FuncRequest(LFUN_MATH_INSERT,
164 // create a macro if we see "\\newcommand"
165 // somewhere, and an ordinary formula
167 istringstream is(sel);
168 if (sel.find("\\newcommand") == string::npos
169 && sel.find("\\def") == string::npos)
171 InsetMathHull * formula = new InsetMathHull;
174 formula->read(cur.buffer(), lex);
175 if (formula->getType() == hullNone)
176 // Don't create pseudo formulas if
177 // delimiters are left out
178 formula->mutate(hullSimple);
181 cur.insert(new MathMacroTemplate(is));
183 cur.message(lyx::from_utf8(N_("Math editor mode")));
192 string const freefont2string()
195 if (font2string(freefont, toggleall, data))
202 bool LyXText::cursorPrevious(LCursor & cur)
204 pos_type cpos = cur.pos();
205 lyx::pit_type cpar = cur.pit();
207 int x = cur.x_target();
209 bool updated = setCursorFromCoordinates(cur, x, 0);
212 updated |= cursorUp(cur);
214 if (cpar == cur.pit() && cpos == cur.pos()) {
215 // we have a row which is taller than the workarea. The
216 // simplest solution is to move to the previous row instead.
217 updated |= cursorUp(cur);
225 bool LyXText::cursorNext(LCursor & cur)
227 pos_type cpos = cur.pos();
228 lyx::pit_type cpar = cur.pit();
230 int x = cur.x_target();
231 bool updated = setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1);
234 updated |= cursorDown(cur);
236 if (cpar == cur.pit() && cpos == cur.pos()) {
237 // we have a row which is taller than the workarea. The
238 // simplest solution is to move to the next row instead.
239 updated |= cursorDown(cur);
249 void specialChar(LCursor & cur, InsetSpecialChar::Kind kind)
251 lyx::cap::replaceSelection(cur);
252 cur.insert(new InsetSpecialChar(kind));
257 bool doInsertInset(LCursor & cur, LyXText * text,
258 FuncRequest const & cmd, bool edit, bool pastesel)
260 InsetBase * inset = createInset(&cur.bv(), cmd);
266 if (cur.selection()) {
267 theApp->lyxFunc().dispatch(FuncRequest(LFUN_CUT));
270 text->insertInset(cur, inset);
273 inset->edit(cur, true);
275 if (gotsel && pastesel) {
276 theApp->lyxFunc().dispatch(FuncRequest(LFUN_PASTE));
277 // reset first par to default
278 if (cur.lastpit() != 0 || cur.lastpos() != 0) {
279 LyXLayout_ptr const layout =
280 cur.buffer().params().getLyXTextClass().defaultLayout();
281 cur.text()->paragraphs().begin()->layout(layout);
288 void update(LCursor & cur)
290 //we don't call update(true, false) directly to save a metrics call
291 if (cur.bv().fitCursor())
292 cur.bv().update(Update::Force);
299 void LyXText::number(LCursor & cur)
301 LyXFont font(LyXFont::ALL_IGNORE);
302 font.setNumber(LyXFont::TOGGLE);
303 toggleAndShow(cur, this, font);
307 bool LyXText::isRTL(Paragraph const & par) const
309 return par.isRightToLeftPar(bv()->buffer()->params());
313 void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
315 lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl;
317 BOOST_ASSERT(cur.text() == this);
318 BufferView * bv = &cur.bv();
319 CursorSlice oldTopSlice = cur.top();
320 bool oldBoundary = cur.boundary();
321 bool sel = cur.selection();
322 // Signals that, even if needsUpdate == false, an update of the
323 // cursor paragraph is required
324 bool singleParUpdate = lyxaction.funcHasFlag(cmd.action,
325 LyXAction::SingleParUpdate);
326 // Signals that a full-screen update is required
327 bool needsUpdate = !(lyxaction.funcHasFlag(cmd.action,
328 LyXAction::NoUpdate) || singleParUpdate);
329 // Remember the old paragraph metric (_outer_ paragraph!)
330 Dimension olddim = cur.bottom().paragraph().dim();
332 switch (cmd.action) {
334 case LFUN_PARAGRAPH_MOVE_DOWN: {
335 pit_type const pit = cur.pit();
336 recUndo(pit, pit + 1);
338 std::swap(pars_[pit], pars_[pit + 1]);
340 ParIterator begin(cur);
342 ParIterator end = boost::next(ParIterator(cur));
343 updateLabels(cur.buffer(), begin, end);
349 case LFUN_PARAGRAPH_MOVE_UP: {
350 pit_type const pit = cur.pit();
351 recUndo(pit - 1, pit);
353 std::swap(pars_[pit], pars_[pit - 1]);
355 ParIterator end = boost::next(ParIterator(cur));
357 ParIterator begin(cur);
358 updateLabels(cur.buffer(), begin, end);
364 case LFUN_APPENDIX: {
365 Paragraph & par = cur.paragraph();
366 bool start = !par.params().startOfAppendix();
369 #warning The code below only makes sense at top level.
370 // Should LFUN_APPENDIX be restricted to top-level paragraphs?
372 // ensure that we have only one start_of_appendix in this document
373 for (pit_type tmp = 0, end = pars_.size(); tmp != end; ++tmp) {
374 if (pars_[tmp].params().startOfAppendix()) {
376 pars_[tmp].params().startOfAppendix(false);
382 par.params().startOfAppendix(start);
384 // we can set the refreshing parameters now
385 updateLabels(cur.buffer());
389 case LFUN_WORD_DELETE_FORWARD:
390 cur.clearSelection();
391 deleteWordForward(cur);
392 finishChange(cur, false);
395 case LFUN_WORD_DELETE_BACKWARD:
396 cur.clearSelection();
397 deleteWordBackward(cur);
398 finishChange(cur, false);
401 case LFUN_LINE_DELETE:
402 cur.clearSelection();
403 deleteLineForward(cur);
404 finishChange(cur, false);
407 case LFUN_BUFFER_BEGIN:
408 case LFUN_BUFFER_BEGIN_SELECT:
409 cur.selHandle(cmd.action == LFUN_BUFFER_BEGIN_SELECT);
410 if (cur.depth() == 1) {
411 needsUpdate = cursorTop(cur);
417 case LFUN_BUFFER_END:
418 case LFUN_BUFFER_END_SELECT:
419 cur.selHandle(cmd.action == LFUN_BUFFER_END_SELECT);
420 if (cur.depth() == 1) {
421 needsUpdate = cursorBottom(cur);
427 case LFUN_CHAR_FORWARD:
428 case LFUN_CHAR_FORWARD_SELECT:
429 //lyxerr << BOOST_CURRENT_FUNCTION
430 // << " LFUN_CHAR_FORWARD[SEL]:\n" << cur << endl;
431 cur.selHandle(cmd.action == LFUN_CHAR_FORWARD_SELECT);
432 if (isRTL(cur.paragraph()))
433 needsUpdate = cursorLeft(cur);
435 needsUpdate = cursorRight(cur);
437 if (!needsUpdate && oldTopSlice == cur.top()
438 && cur.boundary() == oldBoundary) {
440 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
444 case LFUN_CHAR_BACKWARD:
445 case LFUN_CHAR_BACKWARD_SELECT:
446 //lyxerr << "handle LFUN_CHAR_BACKWARD[_SELECT]:\n" << cur << endl;
447 cur.selHandle(cmd.action == LFUN_CHAR_BACKWARD_SELECT);
448 if (isRTL(cur.paragraph()))
449 needsUpdate = cursorRight(cur);
451 needsUpdate = cursorLeft(cur);
453 if (!needsUpdate && oldTopSlice == cur.top()
454 && cur.boundary() == oldBoundary) {
456 cmd = FuncRequest(LFUN_FINISHED_LEFT);
463 //lyxerr << "handle LFUN_UP[SEL]:\n" << cur << endl;
464 cur.selHandle(cmd.action == LFUN_UP_SELECT);
466 needsUpdate = cursorUp(cur);
467 if (!needsUpdate && oldTopSlice == cur.top()
468 && cur.boundary() == oldBoundary) {
470 cmd = FuncRequest(LFUN_FINISHED_UP);
475 case LFUN_DOWN_SELECT:
477 //lyxerr << "handle LFUN_DOWN[SEL]:\n" << cur << endl;
478 cur.selHandle(cmd.action == LFUN_DOWN_SELECT);
479 needsUpdate = cursorDown(cur);
480 if (!needsUpdate && oldTopSlice == cur.top() &&
481 cur.boundary() == oldBoundary)
484 cmd = FuncRequest(LFUN_FINISHED_DOWN);
488 case LFUN_PARAGRAPH_UP:
489 case LFUN_PARAGRAPH_UP_SELECT:
490 cur.selHandle(cmd.action == LFUN_PARAGRAPH_UP_SELECT);
491 needsUpdate = cursorUpParagraph(cur);
494 case LFUN_PARAGRAPH_DOWN:
495 case LFUN_PARAGRAPH_DOWN_SELECT:
496 cur.selHandle(cmd.action == LFUN_PARAGRAPH_DOWN_SELECT);
497 needsUpdate = cursorDownParagraph(cur);
501 case LFUN_SCREEN_UP_SELECT:
503 cur.selHandle(cmd.action == LFUN_SCREEN_UP_SELECT);
504 if (cur.pit() == 0 && cur.textRow().pos() == 0) {
506 cmd = FuncRequest(LFUN_FINISHED_UP);
508 needsUpdate = cursorPrevious(cur);
512 case LFUN_SCREEN_DOWN:
513 case LFUN_SCREEN_DOWN_SELECT:
515 cur.selHandle(cmd.action == LFUN_SCREEN_DOWN_SELECT);
516 if (cur.pit() == cur.lastpit()
517 && cur.textRow().endpos() == cur.lastpos()) {
519 cmd = FuncRequest(LFUN_FINISHED_DOWN);
521 needsUpdate = cursorNext(cur);
525 case LFUN_LINE_BEGIN:
526 case LFUN_LINE_BEGIN_SELECT:
528 cur.selHandle(cmd.action == LFUN_LINE_BEGIN_SELECT);
529 needsUpdate = cursorHome(cur);
533 case LFUN_LINE_END_SELECT:
535 cur.selHandle(cmd.action == LFUN_LINE_END_SELECT);
536 needsUpdate = cursorEnd(cur);
539 case LFUN_WORD_FORWARD:
540 case LFUN_WORD_FORWARD_SELECT:
541 cur.selHandle(cmd.action == LFUN_WORD_FORWARD_SELECT);
542 if (isRTL(cur.paragraph()))
543 needsUpdate = cursorLeftOneWord(cur);
545 needsUpdate = cursorRightOneWord(cur);
548 case LFUN_WORD_BACKWARD:
549 case LFUN_WORD_BACKWARD_SELECT:
550 cur.selHandle(cmd.action == LFUN_WORD_BACKWARD_SELECT);
551 if (isRTL(cur.paragraph()))
552 needsUpdate = cursorRightOneWord(cur);
554 needsUpdate = cursorLeftOneWord(cur);
557 case LFUN_WORD_SELECT: {
558 selectWord(cur, lyx::WHOLE_WORD);
559 finishChange(cur, true);
563 case LFUN_BREAK_LINE: {
564 // Not allowed by LaTeX (labels or empty par)
565 if (cur.pos() > cur.paragraph().beginOfBody()) {
566 lyx::cap::replaceSelection(cur);
567 cur.insert(new InsetNewline);
569 moveCursor(cur, false);
574 case LFUN_CHAR_DELETE_FORWARD:
575 if (!cur.selection()) {
576 if (cur.pos() == cur.paragraph().size())
577 // Par boundary, force full-screen update
578 singleParUpdate = false;
579 needsUpdate = erase(cur);
581 // It is possible to make it a lot faster still
582 // just comment out the line below...
584 cutSelection(cur, true, false);
585 singleParUpdate = false;
587 moveCursor(cur, false);
590 case LFUN_DELETE_FORWARD_SKIP:
591 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
592 if (!cur.selection()) {
593 if (cur.pos() == cur.lastpos()) {
600 cutSelection(cur, true, false);
605 case LFUN_CHAR_DELETE_BACKWARD:
606 if (!cur.selection()) {
607 if (bv->getIntl().getTransManager().backspace()) {
608 // Par boundary, full-screen update
610 singleParUpdate = false;
611 needsUpdate = backspace(cur);
613 // It is possible to make it a lot faster still
614 // just comment out the line below...
617 cutSelection(cur, true, false);
618 singleParUpdate = false;
623 case LFUN_DELETE_BACKWARD_SKIP:
624 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
625 if (!cur.selection()) {
629 //CursorSlice cur = cursor();
633 cutSelection(cur, true, false);
637 case LFUN_BREAK_PARAGRAPH:
638 lyx::cap::replaceSelection(cur);
639 breakParagraph(cur, 0);
644 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
645 lyx::cap::replaceSelection(cur);
646 breakParagraph(cur, 1);
651 case LFUN_BREAK_PARAGRAPH_SKIP: {
652 // When at the beginning of a paragraph, remove
653 // indentation. Otherwise, do the same as LFUN_BREAK_PARAGRAPH.
654 lyx::cap::replaceSelection(cur);
656 cur.paragraph().params().labelWidthString(string());
658 breakParagraph(cur, 0);
664 case LFUN_PARAGRAPH_SPACING: {
665 Paragraph & par = cur.paragraph();
666 Spacing::Space cur_spacing = par.params().spacing().getSpace();
667 string cur_value = "1.0";
668 if (cur_spacing == Spacing::Other)
669 cur_value = par.params().spacing().getValueAsString();
671 istringstream is(lyx::to_utf8(cmd.argument()));
674 Spacing::Space new_spacing = cur_spacing;
675 string new_value = cur_value;
677 lyxerr << "Missing argument to `paragraph-spacing'"
679 } else if (tmp == "single") {
680 new_spacing = Spacing::Single;
681 } else if (tmp == "onehalf") {
682 new_spacing = Spacing::Onehalf;
683 } else if (tmp == "double") {
684 new_spacing = Spacing::Double;
685 } else if (tmp == "other") {
686 new_spacing = Spacing::Other;
687 string tmpval = "0.0";
689 lyxerr << "new_value = " << tmpval << endl;
692 } else if (tmp == "default") {
693 new_spacing = Spacing::Default;
695 lyxerr << lyx::to_utf8(_("Unknown spacing argument: "))
696 << lyx::to_utf8(cmd.argument()) << endl;
698 if (cur_spacing != new_spacing || cur_value != new_value)
699 par.params().spacing(Spacing(new_spacing, new_value));
703 case LFUN_INSET_INSERT: {
705 InsetBase * inset = createInset(bv, cmd);
707 insertInset(cur, inset);
713 case LFUN_INSET_DISSOLVE:
714 needsUpdate = dissolveInset(cur);
717 case LFUN_INSET_SETTINGS:
718 cur.inset().showInsetDialog(bv);
721 case LFUN_SPACE_INSERT:
722 if (cur.paragraph().layout()->free_spacing)
723 insertChar(cur, ' ');
725 doInsertInset(cur, this, cmd, false, false);
728 moveCursor(cur, false);
731 case LFUN_HYPHENATION_POINT_INSERT:
732 specialChar(cur, InsetSpecialChar::HYPHENATION);
735 case LFUN_LIGATURE_BREAK_INSERT:
736 specialChar(cur, InsetSpecialChar::LIGATURE_BREAK);
739 case LFUN_DOTS_INSERT:
740 specialChar(cur, InsetSpecialChar::LDOTS);
743 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
744 specialChar(cur, InsetSpecialChar::END_OF_SENTENCE);
747 case LFUN_MENU_SEPARATOR_INSERT:
748 specialChar(cur, InsetSpecialChar::MENU_SEPARATOR);
751 case LFUN_WORD_UPCASE:
752 changeCase(cur, LyXText::text_uppercase);
755 case LFUN_WORD_LOWCASE:
756 changeCase(cur, LyXText::text_lowercase);
759 case LFUN_WORD_CAPITALIZE:
760 changeCase(cur, LyXText::text_capitalization);
763 case LFUN_CHARS_TRANSPOSE:
768 cur.message(_("Paste"));
769 lyx::cap::replaceSelection(cur);
770 if (isStrUnsignedInt(lyx::to_utf8(cmd.argument())))
771 pasteSelection(cur, bv->buffer()->errorList("Paste"),
772 convert<unsigned int>(lyx::to_utf8(cmd.argument())));
774 pasteSelection(cur, bv->buffer()->errorList("Paste"),
776 bv->buffer()->errors("Paste");
777 cur.clearSelection(); // bug 393
783 cutSelection(cur, true, true);
784 cur.message(_("Cut"));
789 cur.message(_("Copy"));
792 case LFUN_SERVER_GET_XY:
793 cur.message(lyx::from_utf8(
794 convert<string>(cursorX(cur.top(), cur.boundary())) + ' '
795 + convert<string>(cursorY(cur.top(), cur.boundary()))));
798 case LFUN_SERVER_SET_XY: {
801 istringstream is(lyx::to_utf8(cmd.argument()));
804 lyxerr << "SETXY: Could not parse coordinates in '"
805 << lyx::to_utf8(cmd.argument()) << std::endl;
807 setCursorFromCoordinates(cur, x, y);
811 case LFUN_SERVER_GET_FONT:
812 if (current_font.shape() == LyXFont::ITALIC_SHAPE)
813 cur.message(lyx::from_ascii("E"));
814 else if (current_font.shape() == LyXFont::SMALLCAPS_SHAPE)
815 cur.message(lyx::from_ascii("N"));
817 cur.message(lyx::from_ascii("0"));
820 case LFUN_SERVER_GET_LAYOUT:
821 cur.message(lyx::from_utf8(cur.paragraph().layout()->name()));
825 lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) "
826 << lyx::to_utf8(cmd.argument()) << endl;
828 // This is not the good solution to the empty argument
829 // problem, but it will hopefully suffice for 1.2.0.
830 // The correct solution would be to augument the
831 // function list/array with information about what
832 // functions needs arguments and their type.
833 if (cmd.argument().empty()) {
834 cur.errorMessage(_("LyX function 'layout' needs an argument."));
838 // Derive layout number from given argument (string)
839 // and current buffer's textclass (number)
840 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
841 bool hasLayout = tclass.hasLayout(lyx::to_utf8(cmd.argument()));
842 string layout = lyx::to_utf8(cmd.argument());
844 // If the entry is obsolete, use the new one instead.
846 string const & obs = tclass[layout]->obsoleted_by();
852 cur.errorMessage(lyx::from_utf8(N_("Layout ")) + cmd.argument() +
853 lyx::from_utf8(N_(" not known")));
857 bool change_layout = (current_layout != layout);
859 if (!change_layout && cur.selection() &&
860 cur.selBegin().pit() != cur.selEnd().pit())
862 pit_type spit = cur.selBegin().pit();
863 pit_type epit = cur.selEnd().pit() + 1;
864 while (spit != epit) {
865 if (pars_[spit].layout()->name() != current_layout) {
866 change_layout = true;
874 current_layout = layout;
875 setLayout(cur, layout);
876 // inform the GUI that the layout has changed.
877 bv->layoutChanged(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());
1054 case LFUN_SELF_INSERT: {
1055 if (cmd.argument().empty())
1058 // Automatically delete the currently selected
1059 // text and replace it with what is being
1060 // typed in now. Depends on lyxrc settings
1061 // "auto_region_delete", which defaults to
1064 if (lyxrc.auto_region_delete) {
1065 if (cur.selection())
1066 cutSelection(cur, false, false);
1067 theApp->selection().haveSelection(false);
1070 cur.clearSelection();
1071 LyXFont const old_font = real_current_font;
1073 docstring::const_iterator cit = cmd.argument().begin();
1074 docstring::const_iterator end = cmd.argument().end();
1075 for (; cit != end; ++cit)
1077 bv->getIntl().getTransManager().
1078 translateAndInsert(*cit, this);
1080 insertChar(bv->cursor(), *cit);
1084 moveCursor(cur, false);
1088 case LFUN_URL_INSERT: {
1089 InsetCommandParams p("url");
1090 string const data = InsetCommandMailer::params2string("url", p);
1091 bv->showInsetDialog("url", data, 0);
1095 case LFUN_HTML_INSERT: {
1096 InsetCommandParams p("htmlurl");
1097 string const data = InsetCommandMailer::params2string("url", p);
1098 bv->showInsetDialog("url", data, 0);
1102 case LFUN_LABEL_INSERT: {
1103 // Try to generate a valid label
1104 string const contents = cmd.argument().empty() ?
1105 cur.getPossibleLabel() : lyx::to_utf8(cmd.argument());
1107 InsetCommandParams p("label", contents);
1108 string const data = InsetCommandMailer::params2string("label", p);
1110 if (cmd.argument().empty()) {
1111 bv->showInsetDialog("label", data, 0);
1113 FuncRequest fr(LFUN_INSET_INSERT, data);
1121 case LFUN_LIST_INSERT:
1122 case LFUN_THEOREM_INSERT:
1123 case LFUN_CAPTION_INSERT:
1125 case LFUN_NOTE_INSERT:
1126 case LFUN_CHARSTYLE_INSERT:
1127 case LFUN_BOX_INSERT:
1128 case LFUN_BRANCH_INSERT:
1129 case LFUN_BIBITEM_INSERT:
1130 case LFUN_ERT_INSERT:
1131 case LFUN_FOOTNOTE_INSERT:
1132 case LFUN_MARGINALNOTE_INSERT:
1133 case LFUN_OPTIONAL_INSERT:
1134 case LFUN_ENVIRONMENT_INSERT:
1135 // Open the inset, and move the current selection
1137 doInsertInset(cur, this, cmd, true, true);
1141 case LFUN_TABULAR_INSERT:
1142 // if there were no arguments, just open the dialog
1143 if (doInsertInset(cur, this, cmd, false, true))
1146 bv->showDialog("tabularcreate");
1150 case LFUN_FLOAT_INSERT:
1151 case LFUN_FLOAT_WIDE_INSERT:
1152 case LFUN_WRAP_INSERT:
1153 doInsertInset(cur, this, cmd, true, true);
1155 // FIXME: the "Caption" name should not be hardcoded,
1156 // but given by the float definition.
1157 cur.dispatch(FuncRequest(LFUN_LAYOUT, "Caption"));
1160 case LFUN_INDEX_INSERT: {
1161 InsetBase * inset = createInset(&cur.bv(), cmd);
1166 cur.clearSelection();
1167 insertInset(cur, inset);
1168 inset->edit(cur, true);
1173 case LFUN_INDEX_PRINT:
1174 case LFUN_TOC_INSERT:
1175 case LFUN_HFILL_INSERT:
1176 case LFUN_LINE_INSERT:
1177 case LFUN_PAGEBREAK_INSERT:
1179 doInsertInset(cur, this, cmd, false, false);
1183 case LFUN_DEPTH_DECREMENT:
1184 changeDepth(cur, DEC_DEPTH);
1187 case LFUN_DEPTH_INCREMENT:
1188 changeDepth(cur, INC_DEPTH);
1191 case LFUN_MATH_DISPLAY:
1192 mathDispatch(cur, cmd, true);
1195 case LFUN_MATH_IMPORT_SELECTION:
1196 case LFUN_MATH_MODE:
1197 if (cmd.argument() == "on")
1198 // don't pass "on" as argument
1199 mathDispatch(cur, FuncRequest(LFUN_MATH_MODE), false);
1201 mathDispatch(cur, cmd, false);
1204 case LFUN_MATH_MACRO:
1205 if (cmd.argument().empty())
1206 cur.errorMessage(lyx::from_utf8(N_("Missing argument")));
1208 string s = lyx::to_utf8(cmd.argument());
1209 string const s1 = token(s, ' ', 1);
1210 int const nargs = s1.empty() ? 0 : convert<int>(s1);
1211 string const s2 = token(s, ' ', 2);
1212 string const type = s2.empty() ? "newcommand" : s2;
1213 cur.insert(new MathMacroTemplate(token(s, ' ', 0), nargs, type));
1214 //cur.nextInset()->edit(cur, true);
1218 // passthrough hat and underscore outside mathed:
1219 case LFUN_MATH_SUBSCRIPT:
1220 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "_"), false);
1222 case LFUN_MATH_SUPERSCRIPT:
1223 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "^"), false);
1226 case LFUN_MATH_INSERT:
1227 case LFUN_MATH_MATRIX:
1228 case LFUN_MATH_DELIM:
1229 case LFUN_MATH_BIGDELIM: {
1230 cur.insert(new InsetMathHull(hullSimple));
1231 cur.dispatch(FuncRequest(LFUN_CHAR_FORWARD));
1236 case LFUN_FONT_EMPH: {
1237 LyXFont font(LyXFont::ALL_IGNORE);
1238 font.setEmph(LyXFont::TOGGLE);
1239 toggleAndShow(cur, this, font);
1243 case LFUN_FONT_BOLD: {
1244 LyXFont font(LyXFont::ALL_IGNORE);
1245 font.setSeries(LyXFont::BOLD_SERIES);
1246 toggleAndShow(cur, this, font);
1250 case LFUN_FONT_NOUN: {
1251 LyXFont font(LyXFont::ALL_IGNORE);
1252 font.setNoun(LyXFont::TOGGLE);
1253 toggleAndShow(cur, this, font);
1257 case LFUN_FONT_CODE: {
1258 LyXFont font(LyXFont::ALL_IGNORE);
1259 font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
1260 toggleAndShow(cur, this, font);
1264 case LFUN_FONT_SANS: {
1265 LyXFont font(LyXFont::ALL_IGNORE);
1266 font.setFamily(LyXFont::SANS_FAMILY);
1267 toggleAndShow(cur, this, font);
1271 case LFUN_FONT_ROMAN: {
1272 LyXFont font(LyXFont::ALL_IGNORE);
1273 font.setFamily(LyXFont::ROMAN_FAMILY);
1274 toggleAndShow(cur, this, font);
1278 case LFUN_FONT_DEFAULT: {
1279 LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
1280 toggleAndShow(cur, this, font);
1284 case LFUN_FONT_UNDERLINE: {
1285 LyXFont font(LyXFont::ALL_IGNORE);
1286 font.setUnderbar(LyXFont::TOGGLE);
1287 toggleAndShow(cur, this, font);
1291 case LFUN_FONT_SIZE: {
1292 LyXFont font(LyXFont::ALL_IGNORE);
1293 font.setLyXSize(lyx::to_utf8(cmd.argument()));
1294 toggleAndShow(cur, this, font);
1298 case LFUN_LANGUAGE: {
1299 Language const * lang = languages.getLanguage(lyx::to_utf8(cmd.argument()));
1302 LyXFont font(LyXFont::ALL_IGNORE);
1303 font.setLanguage(lang);
1304 toggleAndShow(cur, this, font);
1309 case LFUN_FONT_FREE_APPLY:
1310 toggleAndShow(cur, this, freefont, toggleall);
1311 cur.message(_("Character set"));
1314 // Set the freefont using the contents of \param data dispatched from
1315 // the frontends and apply it at the current cursor location.
1316 case LFUN_FONT_FREE_UPDATE: {
1319 if (bv_funcs::string2font(lyx::to_utf8(cmd.argument()), font, toggle)) {
1322 toggleAndShow(cur, this, freefont, toggleall);
1323 cur.message(_("Character set"));
1328 case LFUN_FINISHED_LEFT:
1329 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_LEFT:\n" << cur << endl;
1332 case LFUN_FINISHED_RIGHT:
1333 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_RIGHT:\n" << cur << endl;
1337 case LFUN_FINISHED_UP:
1338 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_UP:\n" << cur << endl;
1342 case LFUN_FINISHED_DOWN:
1343 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_DOWN:\n" << cur << endl;
1347 case LFUN_LAYOUT_PARAGRAPH: {
1349 params2string(cur.paragraph(), data);
1350 data = "show\n" + data;
1351 bv->showDialogWithData("paragraph", data);
1355 case LFUN_PARAGRAPH_UPDATE: {
1357 params2string(cur.paragraph(), data);
1359 // Will the paragraph accept changes from the dialog?
1360 bool const accept = !cur.inset().forceDefaultParagraphs(cur.idx());
1362 data = "update " + convert<string>(accept) + '\n' + data;
1363 bv->updateDialog("paragraph", data);
1367 case LFUN_ACCENT_UMLAUT:
1368 case LFUN_ACCENT_CIRCUMFLEX:
1369 case LFUN_ACCENT_GRAVE:
1370 case LFUN_ACCENT_ACUTE:
1371 case LFUN_ACCENT_TILDE:
1372 case LFUN_ACCENT_CEDILLA:
1373 case LFUN_ACCENT_MACRON:
1374 case LFUN_ACCENT_DOT:
1375 case LFUN_ACCENT_UNDERDOT:
1376 case LFUN_ACCENT_UNDERBAR:
1377 case LFUN_ACCENT_CARON:
1378 case LFUN_ACCENT_SPECIAL_CARON:
1379 case LFUN_ACCENT_BREVE:
1380 case LFUN_ACCENT_TIE:
1381 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1382 case LFUN_ACCENT_CIRCLE:
1383 case LFUN_ACCENT_OGONEK:
1384 theApp->lyxFunc().handleKeyFunc(cmd.action);
1385 if (!cmd.argument().empty())
1386 // FIXME: Are all these characters encoded in one byte in utf8?
1387 bv->getIntl().getTransManager()
1388 .translateAndInsert(cmd.argument()[0], this);
1391 case LFUN_FLOAT_LIST: {
1392 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
1393 if (tclass.floats().typeExist(lyx::to_utf8(cmd.argument()))) {
1394 // not quite sure if we want this...
1396 cur.clearSelection();
1397 breakParagraph(cur);
1399 if (cur.lastpos() != 0) {
1401 breakParagraph(cur);
1404 setLayout(cur, tclass.defaultLayoutName());
1405 setParagraph(cur, Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
1406 insertInset(cur, new InsetFloatList(lyx::to_utf8(cmd.argument())));
1409 lyxerr << "Non-existent float type: "
1410 << lyx::to_utf8(cmd.argument()) << endl;
1415 case LFUN_CHANGE_ACCEPT: {
1420 case LFUN_CHANGE_REJECT: {
1425 case LFUN_THESAURUS_ENTRY: {
1426 docstring arg = cmd.argument();
1428 arg = cur.selectionAsString(false);
1430 if (arg.size() > 100 || arg.empty()) {
1431 // Get word or selection
1432 selectWordWhenUnderCursor(cur, lyx::WHOLE_WORD);
1433 arg = cur.selectionAsString(false);
1436 bv->showDialogWithData("thesaurus", lyx::to_utf8(arg));
1440 case LFUN_PARAGRAPH_PARAMS_APPLY: {
1441 // Given data, an encoding of the ParagraphParameters
1442 // generated in the Paragraph dialog, this function sets
1443 // the current paragraph appropriately.
1444 istringstream is(lyx::to_utf8(cmd.argument()));
1447 ParagraphParameters params;
1452 params.labelWidthString(),
1454 cur.message(_("Paragraph layout set"));
1459 if (cur.selection()) {
1460 cur.selection() = false;
1463 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
1468 lyxerr[Debug::ACTION]
1469 << BOOST_CURRENT_FUNCTION
1470 << ": Command " << cmd
1471 << " not DISPATCHED by LyXText" << endl;
1476 if (singleParUpdate)
1477 // Inserting characters does not change par height
1478 if (cur.bottom().paragraph().dim().height()
1479 == olddim.height()) {
1480 // if so, update _only_ this paragraph
1481 cur.bv().update(Update::SinglePar |
1483 Update::MultiParSel);
1489 && &oldTopSlice.inset() == &cur.inset()
1490 && oldTopSlice.idx() == cur.idx()
1492 && !cur.selection())
1499 bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
1500 FuncStatus & flag) const
1502 BOOST_ASSERT(cur.text() == this);
1504 LyXFont const & font = real_current_font;
1506 InsetBase::Code code = InsetBase::NO_CODE;
1508 switch (cmd.action) {
1510 case LFUN_DEPTH_DECREMENT:
1511 enable = changeDepthAllowed(cur, DEC_DEPTH);
1514 case LFUN_DEPTH_INCREMENT:
1515 enable = changeDepthAllowed(cur, INC_DEPTH);
1519 flag.setOnOff(cur.paragraph().params().startOfAppendix());
1522 case LFUN_BIBITEM_INSERT:
1523 enable = (cur.paragraph().layout()->labeltype == LABEL_BIBLIO);
1526 case LFUN_DIALOG_SHOW_NEW_INSET:
1527 if (cmd.argument() == "bibitem")
1528 code = InsetBase::BIBITEM_CODE;
1529 else if (cmd.argument() == "bibtex")
1530 code = InsetBase::BIBTEX_CODE;
1531 else if (cmd.argument() == "box")
1532 code = InsetBase::BOX_CODE;
1533 else if (cmd.argument() == "branch")
1534 code = InsetBase::BRANCH_CODE;
1535 else if (cmd.argument() == "citation")
1536 code = InsetBase::CITE_CODE;
1537 else if (cmd.argument() == "ert")
1538 code = InsetBase::ERT_CODE;
1539 else if (cmd.argument() == "external")
1540 code = InsetBase::EXTERNAL_CODE;
1541 else if (cmd.argument() == "float")
1542 code = InsetBase::FLOAT_CODE;
1543 else if (cmd.argument() == "graphics")
1544 code = InsetBase::GRAPHICS_CODE;
1545 else if (cmd.argument() == "include")
1546 code = InsetBase::INCLUDE_CODE;
1547 else if (cmd.argument() == "index")
1548 code = InsetBase::INDEX_CODE;
1549 else if (cmd.argument() == "label")
1550 code = InsetBase::LABEL_CODE;
1551 else if (cmd.argument() == "note")
1552 code = InsetBase::NOTE_CODE;
1553 else if (cmd.argument() == "ref")
1554 code = InsetBase::REF_CODE;
1555 else if (cmd.argument() == "toc")
1556 code = InsetBase::TOC_CODE;
1557 else if (cmd.argument() == "url")
1558 code = InsetBase::URL_CODE;
1559 else if (cmd.argument() == "vspace")
1560 code = InsetBase::VSPACE_CODE;
1561 else if (cmd.argument() == "wrap")
1562 code = InsetBase::WRAP_CODE;
1565 case LFUN_ERT_INSERT:
1566 code = InsetBase::ERT_CODE;
1568 case LFUN_FOOTNOTE_INSERT:
1569 code = InsetBase::FOOT_CODE;
1571 case LFUN_TABULAR_INSERT:
1572 code = InsetBase::TABULAR_CODE;
1574 case LFUN_MARGINALNOTE_INSERT:
1575 code = InsetBase::MARGIN_CODE;
1577 case LFUN_FLOAT_INSERT:
1578 case LFUN_FLOAT_WIDE_INSERT:
1579 code = InsetBase::FLOAT_CODE;
1581 case LFUN_WRAP_INSERT:
1582 code = InsetBase::WRAP_CODE;
1584 case LFUN_FLOAT_LIST:
1585 code = InsetBase::FLOAT_LIST_CODE;
1588 case LFUN_LIST_INSERT:
1589 code = InsetBase::LIST_CODE;
1591 case LFUN_THEOREM_INSERT:
1592 code = InsetBase::THEOREM_CODE;
1595 case LFUN_CAPTION_INSERT:
1596 code = InsetBase::CAPTION_CODE;
1598 case LFUN_NOTE_INSERT:
1599 code = InsetBase::NOTE_CODE;
1601 case LFUN_CHARSTYLE_INSERT:
1602 code = InsetBase::CHARSTYLE_CODE;
1603 if (cur.buffer().params().getLyXTextClass().charstyles().empty())
1606 case LFUN_BOX_INSERT:
1607 code = InsetBase::BOX_CODE;
1609 case LFUN_BRANCH_INSERT:
1610 code = InsetBase::BRANCH_CODE;
1611 if (cur.buffer().getMasterBuffer()->params().branchlist().empty())
1614 case LFUN_LABEL_INSERT:
1615 code = InsetBase::LABEL_CODE;
1617 case LFUN_OPTIONAL_INSERT:
1618 code = InsetBase::OPTARG_CODE;
1619 enable = numberOfOptArgs(cur.paragraph())
1620 < cur.paragraph().layout()->optionalargs;
1622 case LFUN_ENVIRONMENT_INSERT:
1623 code = InsetBase::BOX_CODE;
1625 case LFUN_INDEX_INSERT:
1626 code = InsetBase::INDEX_CODE;
1628 case LFUN_INDEX_PRINT:
1629 code = InsetBase::INDEX_PRINT_CODE;
1631 case LFUN_TOC_INSERT:
1632 code = InsetBase::TOC_CODE;
1634 case LFUN_HTML_INSERT:
1635 case LFUN_URL_INSERT:
1636 code = InsetBase::URL_CODE;
1638 case LFUN_QUOTE_INSERT:
1639 // always allow this, since we will inset a raw quote
1640 // if an inset is not allowed.
1642 case LFUN_HYPHENATION_POINT_INSERT:
1643 case LFUN_LIGATURE_BREAK_INSERT:
1644 case LFUN_HFILL_INSERT:
1645 case LFUN_MENU_SEPARATOR_INSERT:
1646 case LFUN_DOTS_INSERT:
1647 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
1648 code = InsetBase::SPECIALCHAR_CODE;
1650 case LFUN_SPACE_INSERT:
1651 // slight hack: we know this is allowed in math mode
1653 code = InsetBase::SPACE_CODE;
1656 case LFUN_INSET_MODIFY:
1657 // We need to disable this, because we may get called for a
1659 // InsetTabular::getStatus() -> InsetText::getStatus()
1660 // and we don't handle LFUN_INSET_MODIFY.
1664 case LFUN_FONT_EMPH:
1665 flag.setOnOff(font.emph() == LyXFont::ON);
1668 case LFUN_FONT_NOUN:
1669 flag.setOnOff(font.noun() == LyXFont::ON);
1672 case LFUN_FONT_BOLD:
1673 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
1676 case LFUN_FONT_SANS:
1677 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
1680 case LFUN_FONT_ROMAN:
1681 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
1684 case LFUN_FONT_CODE:
1685 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
1690 enable = cur.selection();
1694 enable = lyx::cap::numberOfSelections() > 0;
1697 case LFUN_PARAGRAPH_MOVE_UP:
1698 enable = cur.pit() > 0 && !cur.selection();
1701 case LFUN_PARAGRAPH_MOVE_DOWN:
1702 enable = cur.pit() < cur.lastpit() && !cur.selection();
1705 case LFUN_INSET_DISSOLVE:
1706 enable = !isMainText() && cur.inset().nargs() == 1;
1709 case LFUN_CHANGE_ACCEPT:
1710 case LFUN_CHANGE_REJECT:
1711 enable = true; // FIXME: Change tracking (MG)
1714 case LFUN_WORD_DELETE_FORWARD:
1715 case LFUN_WORD_DELETE_BACKWARD:
1716 case LFUN_LINE_DELETE:
1717 case LFUN_WORD_FORWARD:
1718 case LFUN_WORD_BACKWARD:
1719 case LFUN_CHAR_FORWARD:
1720 case LFUN_CHAR_FORWARD_SELECT:
1721 case LFUN_CHAR_BACKWARD:
1722 case LFUN_CHAR_BACKWARD_SELECT:
1724 case LFUN_UP_SELECT:
1726 case LFUN_DOWN_SELECT:
1727 case LFUN_PARAGRAPH_UP_SELECT:
1728 case LFUN_PARAGRAPH_DOWN_SELECT:
1729 case LFUN_SCREEN_UP_SELECT:
1730 case LFUN_SCREEN_DOWN_SELECT:
1731 case LFUN_LINE_BEGIN_SELECT:
1732 case LFUN_LINE_END_SELECT:
1733 case LFUN_WORD_FORWARD_SELECT:
1734 case LFUN_WORD_BACKWARD_SELECT:
1735 case LFUN_WORD_SELECT:
1736 case LFUN_PARAGRAPH_UP:
1737 case LFUN_PARAGRAPH_DOWN:
1738 case LFUN_SCREEN_UP:
1739 case LFUN_SCREEN_DOWN:
1740 case LFUN_LINE_BEGIN:
1742 case LFUN_BREAK_LINE:
1743 case LFUN_CHAR_DELETE_FORWARD:
1744 case LFUN_DELETE_FORWARD_SKIP:
1745 case LFUN_CHAR_DELETE_BACKWARD:
1746 case LFUN_DELETE_BACKWARD_SKIP:
1747 case LFUN_BREAK_PARAGRAPH:
1748 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
1749 case LFUN_BREAK_PARAGRAPH_SKIP:
1750 case LFUN_PARAGRAPH_SPACING:
1751 case LFUN_INSET_INSERT:
1752 case LFUN_WORD_UPCASE:
1753 case LFUN_WORD_LOWCASE:
1754 case LFUN_WORD_CAPITALIZE:
1755 case LFUN_CHARS_TRANSPOSE:
1756 case LFUN_SERVER_GET_XY:
1757 case LFUN_SERVER_SET_XY:
1758 case LFUN_SERVER_GET_FONT:
1759 case LFUN_SERVER_GET_LAYOUT:
1761 case LFUN_CLIPBOARD_PASTE:
1762 case LFUN_PRIMARY_SELECTION_PASTE:
1763 case LFUN_DATE_INSERT:
1764 case LFUN_SELF_INSERT:
1765 case LFUN_LINE_INSERT:
1766 case LFUN_PAGEBREAK_INSERT:
1767 case LFUN_MATH_DISPLAY:
1768 case LFUN_MATH_IMPORT_SELECTION:
1769 case LFUN_MATH_MODE:
1770 case LFUN_MATH_MACRO:
1771 case LFUN_MATH_MATRIX:
1772 case LFUN_MATH_DELIM:
1773 case LFUN_MATH_BIGDELIM:
1774 case LFUN_MATH_SUBSCRIPT:
1775 case LFUN_MATH_SUPERSCRIPT:
1776 case LFUN_FONT_DEFAULT:
1777 case LFUN_FONT_UNDERLINE:
1778 case LFUN_FONT_SIZE:
1780 case LFUN_FONT_FREE_APPLY:
1781 case LFUN_FONT_FREE_UPDATE:
1782 case LFUN_LAYOUT_PARAGRAPH:
1783 case LFUN_PARAGRAPH_UPDATE:
1784 case LFUN_ACCENT_UMLAUT:
1785 case LFUN_ACCENT_CIRCUMFLEX:
1786 case LFUN_ACCENT_GRAVE:
1787 case LFUN_ACCENT_ACUTE:
1788 case LFUN_ACCENT_TILDE:
1789 case LFUN_ACCENT_CEDILLA:
1790 case LFUN_ACCENT_MACRON:
1791 case LFUN_ACCENT_DOT:
1792 case LFUN_ACCENT_UNDERDOT:
1793 case LFUN_ACCENT_UNDERBAR:
1794 case LFUN_ACCENT_CARON:
1795 case LFUN_ACCENT_SPECIAL_CARON:
1796 case LFUN_ACCENT_BREVE:
1797 case LFUN_ACCENT_TIE:
1798 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1799 case LFUN_ACCENT_CIRCLE:
1800 case LFUN_ACCENT_OGONEK:
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);