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/Clipboard.h"
51 #include "frontends/Selection.h"
53 #include "insets/insetcommand.h"
54 #include "insets/insetfloatlist.h"
55 #include "insets/insetnewline.h"
56 #include "insets/insetquotes.h"
57 #include "insets/insetspecialchar.h"
58 #include "insets/insettext.h"
60 #include "support/lstrings.h"
61 #include "support/lyxlib.h"
62 #include "support/convert.h"
63 #include "support/lyxtime.h"
65 #include "mathed/InsetMathHull.h"
66 #include "mathed/MathMacroTemplate.h"
68 #include <boost/current_function.hpp>
76 using cap::copySelection;
77 using cap::cutSelection;
78 using cap::pasteSelection;
79 using cap::replaceSelection;
81 using support::isStrUnsignedInt;
86 using std::istringstream;
87 using std::ostringstream;
90 extern string current_layout;
96 LyXFont freefont(LyXFont::ALL_IGNORE);
97 bool toggleall = false;
100 void toggleAndShow(LCursor & cur, LyXText * text,
101 LyXFont const & font, bool toggleall = true)
103 text->toggleFree(cur, font, toggleall);
105 if (font.language() != ignore_language ||
106 font.number() != LyXFont::IGNORE) {
107 Paragraph & par = cur.paragraph();
108 text->bidi.computeTables(par, cur.buffer(), cur.textRow());
109 if (cur.boundary() !=
110 text->bidi.isBoundary(cur.buffer(), par,
112 text->real_current_font))
113 text->setCursor(cur, cur.pit(), cur.pos(),
114 false, !cur.boundary());
119 void moveCursor(LCursor & cur, bool selecting)
121 if (selecting || cur.mark())
123 if (!cur.selection())
124 theSelection().haveSelection(false);
125 cur.bv().switchKeyMap();
129 void finishChange(LCursor & cur, bool selecting)
132 moveCursor(cur, selecting);
136 void mathDispatch(LCursor & cur, FuncRequest const & cmd, bool display)
139 string sel = to_utf8(cur.selectionAsString(false));
140 //lyxerr << "selection is: '" << sel << "'" << endl;
142 // It may happen that sel is empty but there is a selection
143 replaceSelection(cur);
146 const int old_pos = cur.pos();
147 cur.insert(new InsetMathHull(hullSimple));
148 BOOST_ASSERT(old_pos == cur.pos());
149 cur.nextInset()->edit(cur, true);
150 // don't do that also for LFUN_MATH_MODE
151 // unless you want end up with always changing
152 // to mathrm when opening an inlined inset --
153 // I really hate "LyXfunc overloading"...
155 cur.dispatch(FuncRequest(LFUN_MATH_DISPLAY));
156 // Avoid an unnecessary undo step if cmd.argument
158 if (!cmd.argument().empty())
159 cur.dispatch(FuncRequest(LFUN_MATH_INSERT,
162 // create a macro if we see "\\newcommand"
163 // somewhere, and an ordinary formula
165 istringstream is(sel);
166 if (sel.find("\\newcommand") == string::npos
167 && sel.find("\\def") == string::npos)
169 InsetMathHull * formula = new InsetMathHull;
172 formula->read(cur.buffer(), lex);
173 if (formula->getType() == hullNone)
174 // Don't create pseudo formulas if
175 // delimiters are left out
176 formula->mutate(hullSimple);
179 cur.insert(new MathMacroTemplate(is));
181 cur.message(from_utf8(N_("Math editor mode")));
190 string const freefont2string()
193 if (font2string(freefont, toggleall, data))
200 bool LyXText::cursorPrevious(LCursor & cur)
202 pos_type cpos = cur.pos();
203 pit_type cpar = cur.pit();
205 int x = cur.x_target();
207 bool updated = setCursorFromCoordinates(cur, x, 0);
210 updated |= cursorUp(cur);
212 if (cpar == cur.pit() && cpos == cur.pos()) {
213 // we have a row which is taller than the workarea. The
214 // simplest solution is to move to the previous row instead.
215 updated |= cursorUp(cur);
223 bool LyXText::cursorNext(LCursor & cur)
225 pos_type cpos = cur.pos();
226 pit_type cpar = cur.pit();
228 int x = cur.x_target();
229 bool updated = setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1);
232 updated |= cursorDown(cur);
234 if (cpar == cur.pit() && cpos == cur.pos()) {
235 // we have a row which is taller than the workarea. The
236 // simplest solution is to move to the next row instead.
237 updated |= cursorDown(cur);
247 void specialChar(LCursor & cur, InsetSpecialChar::Kind kind)
249 cap::replaceSelection(cur);
250 cur.insert(new InsetSpecialChar(kind));
255 bool doInsertInset(LCursor & cur, LyXText * text,
256 FuncRequest const & cmd, bool edit, bool pastesel)
258 InsetBase * inset = createInset(&cur.bv(), cmd);
264 if (cur.selection()) {
265 lyx::dispatch(FuncRequest(LFUN_CUT));
268 text->insertInset(cur, inset);
271 inset->edit(cur, true);
273 if (gotsel && pastesel) {
274 lyx::dispatch(FuncRequest(LFUN_PASTE));
275 // reset first par to default
276 if (cur.lastpit() != 0 || cur.lastpos() != 0) {
277 LyXLayout_ptr const layout =
278 cur.buffer().params().getLyXTextClass().defaultLayout();
279 cur.text()->paragraphs().begin()->layout(layout);
289 void LyXText::number(LCursor & cur)
291 LyXFont font(LyXFont::ALL_IGNORE);
292 font.setNumber(LyXFont::TOGGLE);
293 toggleAndShow(cur, this, font);
297 bool LyXText::isRTL(Paragraph const & par) const
299 return par.isRightToLeftPar(bv()->buffer()->params());
303 void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
305 lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl;
307 BOOST_ASSERT(cur.text() == this);
308 BufferView * bv = &cur.bv();
309 CursorSlice oldTopSlice = cur.top();
310 bool oldBoundary = cur.boundary();
311 bool sel = cur.selection();
312 // Signals that, even if needsUpdate == false, an update of the
313 // cursor paragraph is required
314 bool singleParUpdate = lyxaction.funcHasFlag(cmd.action,
315 LyXAction::SingleParUpdate);
316 // Signals that a full-screen update is required
317 bool needsUpdate = !(lyxaction.funcHasFlag(cmd.action,
318 LyXAction::NoUpdate) || singleParUpdate);
319 // Remember the old paragraph metric (_outer_ paragraph!)
320 Dimension olddim = cur.bottom().paragraph().dim();
322 switch (cmd.action) {
324 case LFUN_PARAGRAPH_MOVE_DOWN: {
325 pit_type const pit = cur.pit();
326 recUndo(pit, pit + 1);
328 std::swap(pars_[pit], pars_[pit + 1]);
330 ParIterator begin(cur);
332 ParIterator end = boost::next(ParIterator(cur));
333 updateLabels(cur.buffer(), begin, end);
339 case LFUN_PARAGRAPH_MOVE_UP: {
340 pit_type const pit = cur.pit();
341 recUndo(pit - 1, pit);
343 std::swap(pars_[pit], pars_[pit - 1]);
345 ParIterator end = boost::next(ParIterator(cur));
347 ParIterator begin(cur);
348 updateLabels(cur.buffer(), begin, end);
354 case LFUN_APPENDIX: {
355 Paragraph & par = cur.paragraph();
356 bool start = !par.params().startOfAppendix();
359 #warning The code below only makes sense at top level.
360 // Should LFUN_APPENDIX be restricted to top-level paragraphs?
362 // ensure that we have only one start_of_appendix in this document
363 for (pit_type tmp = 0, end = pars_.size(); tmp != end; ++tmp) {
364 if (pars_[tmp].params().startOfAppendix()) {
366 pars_[tmp].params().startOfAppendix(false);
372 par.params().startOfAppendix(start);
374 // we can set the refreshing parameters now
375 updateLabels(cur.buffer());
379 case LFUN_WORD_DELETE_FORWARD:
380 cur.clearSelection();
381 deleteWordForward(cur);
382 finishChange(cur, false);
385 case LFUN_WORD_DELETE_BACKWARD:
386 cur.clearSelection();
387 deleteWordBackward(cur);
388 finishChange(cur, false);
391 case LFUN_LINE_DELETE:
392 cur.clearSelection();
393 deleteLineForward(cur);
394 finishChange(cur, false);
397 case LFUN_BUFFER_BEGIN:
398 case LFUN_BUFFER_BEGIN_SELECT:
399 needsUpdate |= cur.selHandle(cmd.action == LFUN_BUFFER_BEGIN_SELECT);
400 if (cur.depth() == 1) {
401 needsUpdate |= cursorTop(cur);
407 case LFUN_BUFFER_END:
408 case LFUN_BUFFER_END_SELECT:
409 needsUpdate |= cur.selHandle(cmd.action == LFUN_BUFFER_END_SELECT);
410 if (cur.depth() == 1) {
411 needsUpdate |= cursorBottom(cur);
417 case LFUN_CHAR_FORWARD:
418 case LFUN_CHAR_FORWARD_SELECT:
419 //lyxerr << BOOST_CURRENT_FUNCTION
420 // << " LFUN_CHAR_FORWARD[SEL]:\n" << cur << endl;
421 needsUpdate |= cur.selHandle(cmd.action == LFUN_CHAR_FORWARD_SELECT);
422 if (isRTL(cur.paragraph()))
423 needsUpdate |= cursorLeft(cur);
425 needsUpdate |= cursorRight(cur);
427 if (!needsUpdate && oldTopSlice == cur.top()
428 && cur.boundary() == oldBoundary) {
430 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
434 case LFUN_CHAR_BACKWARD:
435 case LFUN_CHAR_BACKWARD_SELECT:
436 //lyxerr << "handle LFUN_CHAR_BACKWARD[_SELECT]:\n" << cur << endl;
437 needsUpdate |= cur.selHandle(cmd.action == LFUN_CHAR_BACKWARD_SELECT);
438 if (isRTL(cur.paragraph()))
439 needsUpdate |= cursorRight(cur);
441 needsUpdate |= cursorLeft(cur);
443 if (!needsUpdate && oldTopSlice == cur.top()
444 && cur.boundary() == oldBoundary) {
446 cmd = FuncRequest(LFUN_FINISHED_LEFT);
452 //lyxerr << "handle LFUN_UP[SEL]:\n" << cur << endl;
453 needsUpdate |= cur.selHandle(cmd.action == LFUN_UP_SELECT);
455 needsUpdate |= cursorUp(cur);
457 if (!needsUpdate && oldTopSlice == cur.top()
458 && cur.boundary() == oldBoundary) {
460 cmd = FuncRequest(LFUN_FINISHED_UP);
465 case LFUN_DOWN_SELECT:
466 //lyxerr << "handle LFUN_DOWN[SEL]:\n" << cur << endl;
467 needsUpdate |= cur.selHandle(cmd.action == LFUN_DOWN_SELECT);
468 needsUpdate |= cursorDown(cur);
470 if (!needsUpdate && oldTopSlice == cur.top() &&
471 cur.boundary() == oldBoundary)
474 cmd = FuncRequest(LFUN_FINISHED_DOWN);
478 case LFUN_PARAGRAPH_UP:
479 case LFUN_PARAGRAPH_UP_SELECT:
480 needsUpdate |= cur.selHandle(cmd.action == LFUN_PARAGRAPH_UP_SELECT);
481 needsUpdate |= cursorUpParagraph(cur);
484 case LFUN_PARAGRAPH_DOWN:
485 case LFUN_PARAGRAPH_DOWN_SELECT:
486 needsUpdate |= cur.selHandle(cmd.action == LFUN_PARAGRAPH_DOWN_SELECT);
487 needsUpdate |= cursorDownParagraph(cur);
491 case LFUN_SCREEN_UP_SELECT:
492 needsUpdate |= cur.selHandle(cmd.action == LFUN_SCREEN_UP_SELECT);
493 if (cur.pit() == 0 && cur.textRow().pos() == 0) {
495 cmd = FuncRequest(LFUN_FINISHED_UP);
497 needsUpdate |= cursorPrevious(cur);
501 case LFUN_SCREEN_DOWN:
502 case LFUN_SCREEN_DOWN_SELECT:
503 needsUpdate |= cur.selHandle(cmd.action == LFUN_SCREEN_DOWN_SELECT);
504 if (cur.pit() == cur.lastpit()
505 && cur.textRow().endpos() == cur.lastpos()) {
507 cmd = FuncRequest(LFUN_FINISHED_DOWN);
509 needsUpdate |= cursorNext(cur);
513 case LFUN_LINE_BEGIN:
514 case LFUN_LINE_BEGIN_SELECT:
515 needsUpdate |= cur.selHandle(cmd.action == LFUN_LINE_BEGIN_SELECT);
516 needsUpdate |= cursorHome(cur);
520 case LFUN_LINE_END_SELECT:
521 needsUpdate |= cur.selHandle(cmd.action == LFUN_LINE_END_SELECT);
522 needsUpdate |= cursorEnd(cur);
525 case LFUN_WORD_FORWARD:
526 case LFUN_WORD_FORWARD_SELECT:
527 needsUpdate |= cur.selHandle(cmd.action == LFUN_WORD_FORWARD_SELECT);
528 if (isRTL(cur.paragraph()))
529 needsUpdate |= cursorLeftOneWord(cur);
531 needsUpdate |= cursorRightOneWord(cur);
534 case LFUN_WORD_BACKWARD:
535 case LFUN_WORD_BACKWARD_SELECT:
536 needsUpdate |= cur.selHandle(cmd.action == LFUN_WORD_BACKWARD_SELECT);
537 if (isRTL(cur.paragraph()))
538 needsUpdate |= cursorRightOneWord(cur);
540 needsUpdate |= cursorLeftOneWord(cur);
543 case LFUN_WORD_SELECT: {
544 selectWord(cur, WHOLE_WORD);
545 finishChange(cur, true);
549 case LFUN_BREAK_LINE: {
550 // Not allowed by LaTeX (labels or empty par)
551 if (cur.pos() > cur.paragraph().beginOfBody()) {
552 cap::replaceSelection(cur);
553 cur.insert(new InsetNewline);
555 moveCursor(cur, false);
560 case LFUN_CHAR_DELETE_FORWARD:
561 if (!cur.selection()) {
562 if (cur.pos() == cur.paragraph().size())
563 // Par boundary, force full-screen update
564 singleParUpdate = false;
565 needsUpdate |= erase(cur);
567 // It is possible to make it a lot faster still
568 // just comment out the line below...
570 cutSelection(cur, true, false);
571 singleParUpdate = false;
573 moveCursor(cur, false);
576 case LFUN_DELETE_FORWARD_SKIP:
577 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
578 if (!cur.selection()) {
579 if (cur.pos() == cur.lastpos()) {
586 cutSelection(cur, true, false);
591 case LFUN_CHAR_DELETE_BACKWARD:
592 if (!cur.selection()) {
593 if (bv->getIntl().getTransManager().backspace()) {
594 // Par boundary, full-screen update
596 singleParUpdate = false;
597 needsUpdate |= backspace(cur);
599 // It is possible to make it a lot faster still
600 // just comment out the line below...
603 cutSelection(cur, true, false);
604 singleParUpdate = false;
609 case LFUN_DELETE_BACKWARD_SKIP:
610 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
611 if (!cur.selection()) {
615 //CursorSlice cur = cursor();
619 cutSelection(cur, true, false);
623 case LFUN_BREAK_PARAGRAPH:
624 cap::replaceSelection(cur);
625 breakParagraph(cur, 0);
630 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
631 cap::replaceSelection(cur);
632 breakParagraph(cur, 1);
637 case LFUN_BREAK_PARAGRAPH_SKIP: {
638 // When at the beginning of a paragraph, remove
639 // indentation. Otherwise, do the same as LFUN_BREAK_PARAGRAPH.
640 cap::replaceSelection(cur);
642 cur.paragraph().params().labelWidthString(docstring());
644 breakParagraph(cur, 0);
650 case LFUN_PARAGRAPH_SPACING: {
651 Paragraph & par = cur.paragraph();
652 Spacing::Space cur_spacing = par.params().spacing().getSpace();
653 string cur_value = "1.0";
654 if (cur_spacing == Spacing::Other)
655 cur_value = par.params().spacing().getValueAsString();
657 istringstream is(to_utf8(cmd.argument()));
660 Spacing::Space new_spacing = cur_spacing;
661 string new_value = cur_value;
663 lyxerr << "Missing argument to `paragraph-spacing'"
665 } else if (tmp == "single") {
666 new_spacing = Spacing::Single;
667 } else if (tmp == "onehalf") {
668 new_spacing = Spacing::Onehalf;
669 } else if (tmp == "double") {
670 new_spacing = Spacing::Double;
671 } else if (tmp == "other") {
672 new_spacing = Spacing::Other;
673 string tmpval = "0.0";
675 lyxerr << "new_value = " << tmpval << endl;
678 } else if (tmp == "default") {
679 new_spacing = Spacing::Default;
681 lyxerr << to_utf8(_("Unknown spacing argument: "))
682 << to_utf8(cmd.argument()) << endl;
684 if (cur_spacing != new_spacing || cur_value != new_value)
685 par.params().spacing(Spacing(new_spacing, new_value));
689 case LFUN_INSET_INSERT: {
691 InsetBase * inset = createInset(bv, cmd);
693 insertInset(cur, inset);
699 case LFUN_INSET_DISSOLVE:
700 needsUpdate |= dissolveInset(cur);
703 case LFUN_INSET_SETTINGS:
704 cur.inset().showInsetDialog(bv);
707 case LFUN_SPACE_INSERT:
708 if (cur.paragraph().layout()->free_spacing)
709 insertChar(cur, ' ');
711 doInsertInset(cur, this, cmd, false, false);
714 moveCursor(cur, false);
717 case LFUN_HYPHENATION_POINT_INSERT:
718 specialChar(cur, InsetSpecialChar::HYPHENATION);
721 case LFUN_LIGATURE_BREAK_INSERT:
722 specialChar(cur, InsetSpecialChar::LIGATURE_BREAK);
725 case LFUN_DOTS_INSERT:
726 specialChar(cur, InsetSpecialChar::LDOTS);
729 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
730 specialChar(cur, InsetSpecialChar::END_OF_SENTENCE);
733 case LFUN_MENU_SEPARATOR_INSERT:
734 specialChar(cur, InsetSpecialChar::MENU_SEPARATOR);
737 case LFUN_WORD_UPCASE:
738 changeCase(cur, LyXText::text_uppercase);
741 case LFUN_WORD_LOWCASE:
742 changeCase(cur, LyXText::text_lowercase);
745 case LFUN_WORD_CAPITALIZE:
746 changeCase(cur, LyXText::text_capitalization);
749 case LFUN_CHARS_TRANSPOSE:
754 cur.message(_("Paste"));
755 cap::replaceSelection(cur);
756 if (isStrUnsignedInt(to_utf8(cmd.argument())))
757 pasteSelection(cur, bv->buffer()->errorList("Paste"),
758 convert<unsigned int>(to_utf8(cmd.argument())));
760 pasteSelection(cur, bv->buffer()->errorList("Paste"),
762 bv->buffer()->errors("Paste");
763 cur.clearSelection(); // bug 393
769 cutSelection(cur, true, true);
770 cur.message(_("Cut"));
775 cur.message(_("Copy"));
778 case LFUN_SERVER_GET_XY:
779 cur.message(from_utf8(
780 convert<string>(cursorX(cur.top(), cur.boundary())) + ' '
781 + convert<string>(cursorY(cur.top(), cur.boundary()))));
784 case LFUN_SERVER_SET_XY: {
787 istringstream is(to_utf8(cmd.argument()));
790 lyxerr << "SETXY: Could not parse coordinates in '"
791 << to_utf8(cmd.argument()) << std::endl;
793 setCursorFromCoordinates(cur, x, y);
797 case LFUN_SERVER_GET_FONT:
798 if (current_font.shape() == LyXFont::ITALIC_SHAPE)
799 cur.message(from_ascii("E"));
800 else if (current_font.shape() == LyXFont::SMALLCAPS_SHAPE)
801 cur.message(from_ascii("N"));
803 cur.message(from_ascii("0"));
806 case LFUN_SERVER_GET_LAYOUT:
807 cur.message(from_utf8(cur.paragraph().layout()->name()));
811 lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) "
812 << to_utf8(cmd.argument()) << endl;
814 // This is not the good solution to the empty argument
815 // problem, but it will hopefully suffice for 1.2.0.
816 // The correct solution would be to augument the
817 // function list/array with information about what
818 // functions needs arguments and their type.
819 if (cmd.argument().empty()) {
820 cur.errorMessage(_("LyX function 'layout' needs an argument."));
824 // Derive layout number from given argument (string)
825 // and current buffer's textclass (number)
826 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
827 bool hasLayout = tclass.hasLayout(to_utf8(cmd.argument()));
828 string layout = to_utf8(cmd.argument());
830 // If the entry is obsolete, use the new one instead.
832 string const & obs = tclass[layout]->obsoleted_by();
838 cur.errorMessage(from_utf8(N_("Layout ")) + cmd.argument() +
839 from_utf8(N_(" not known")));
843 bool change_layout = (current_layout != layout);
845 if (!change_layout && cur.selection() &&
846 cur.selBegin().pit() != cur.selEnd().pit())
848 pit_type spit = cur.selBegin().pit();
849 pit_type epit = cur.selEnd().pit() + 1;
850 while (spit != epit) {
851 if (pars_[spit].layout()->name() != current_layout) {
852 change_layout = true;
860 current_layout = layout;
861 setLayout(cur, layout);
862 // inform the GUI that the layout has changed.
863 bv->layoutChanged(layout);
869 case LFUN_CLIPBOARD_PASTE: {
870 cur.clearSelection();
871 docstring const clip = theClipboard().get();
874 if (cmd.argument() == "paragraph")
875 insertStringAsParagraphs(cur, clip);
877 insertStringAsLines(cur, clip);
882 case LFUN_PRIMARY_SELECTION_PASTE: {
883 cur.clearSelection();
884 docstring const clip = theSelection().get();
887 if (cmd.argument() == "paragraph")
888 insertStringAsParagraphs(cur, clip);
890 insertStringAsLines(cur, clip);
895 case LFUN_QUOTE_INSERT: {
896 cap::replaceSelection(cur);
897 Paragraph & par = cur.paragraph();
898 pos_type pos = cur.pos();
902 else if (cur.prevInset() && cur.prevInset()->isSpace())
905 c = par.getChar(pos - 1);
907 LyXLayout_ptr const & style = par.layout();
909 BufferParams const & bufparams = bv->buffer()->params();
910 if (!style->pass_thru
911 && par.getFontSettings(bufparams, pos).language()->lang() != "hebrew") {
912 string arg = to_utf8(cmd.argument());
914 cur.insert(new InsetQuotes(c,
915 bufparams.quotes_language,
916 InsetQuotes::SingleQ));
918 cur.insert(new InsetQuotes(c,
919 bufparams.quotes_language,
920 InsetQuotes::DoubleQ));
924 lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, "\""));
928 case LFUN_DATE_INSERT:
929 if (cmd.argument().empty())
930 lyx::dispatch(FuncRequest(LFUN_SELF_INSERT,
931 formatted_time(current_time())));
933 lyx::dispatch(FuncRequest(LFUN_SELF_INSERT,
934 formatted_time(current_time(), to_utf8(cmd.argument()))));
937 case LFUN_MOUSE_TRIPLE:
938 if (cmd.button() == mouse_button::button1) {
944 theSelection().haveSelection(cur.selection());
948 case LFUN_MOUSE_DOUBLE:
949 if (cmd.button() == mouse_button::button1) {
950 selectWord(cur, WHOLE_WORD_STRICT);
952 theSelection().haveSelection(cur.selection());
956 // Single-click on work area
957 case LFUN_MOUSE_PRESS: {
958 // Right click on a footnote flag opens float menu
959 if (cmd.button() == mouse_button::button3)
960 cur.clearSelection();
962 // Middle button press pastes if we have a selection
963 // We do this here as if the selection was inside an inset
964 // it could get cleared on the unlocking of the inset so
965 // we have to check this first
966 bool paste_internally = false;
967 if (cmd.button() == mouse_button::button2 && cur.selection()) {
968 lyx::dispatch(FuncRequest(LFUN_COPY));
969 paste_internally = true;
972 bv->mouseSetCursor(cur);
974 // Insert primary selection with middle mouse
975 // if there is a local selection in the current buffer,
977 if (cmd.button() == mouse_button::button2) {
978 if (paste_internally)
979 lyx::dispatch(FuncRequest(LFUN_PASTE));
981 lyx::dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph"));
987 case LFUN_MOUSE_MOTION: {
988 // Only use motion with button 1
989 //if (cmd.button() != mouse_button::button1)
992 // ignore motions deeper nested than the real anchor
993 LCursor & bvcur = cur.bv().cursor();
994 if (bvcur.anchor_.hasPart(cur)) {
995 CursorSlice old = bvcur.top();
997 int const wh = bv->workHeight();
998 int const y = std::max(0, std::min(wh - 1, cmd.y));
1000 setCursorFromCoordinates(cur, cmd.x, y);
1001 cur.x_target() = cmd.x;
1006 // This is to allow jumping over large insets
1007 if (cur.top() == old) {
1014 if (cur.top() == old)
1017 // don't set anchor_
1018 bvcur.setCursor(cur);
1019 bvcur.selection() = true;
1020 //lyxerr << "MOTION: " << bv->cursor() << endl;
1028 case LFUN_MOUSE_RELEASE: {
1029 if (cmd.button() == mouse_button::button2)
1033 if (cmd.button() == mouse_button::button1)
1034 theSelection().haveSelection(cur.selection());
1040 case LFUN_SELF_INSERT: {
1041 if (cmd.argument().empty())
1044 // Automatically delete the currently selected
1045 // text and replace it with what is being
1046 // typed in now. Depends on lyxrc settings
1047 // "auto_region_delete", which defaults to
1050 if (lyxrc.auto_region_delete) {
1051 if (cur.selection())
1052 cutSelection(cur, false, false);
1053 theSelection().haveSelection(false);
1056 cur.clearSelection();
1057 LyXFont const old_font = real_current_font;
1059 docstring::const_iterator cit = cmd.argument().begin();
1060 docstring::const_iterator end = cmd.argument().end();
1061 for (; cit != end; ++cit)
1063 bv->getIntl().getTransManager().
1064 translateAndInsert(*cit, this);
1066 insertChar(bv->cursor(), *cit);
1070 moveCursor(cur, false);
1074 case LFUN_URL_INSERT: {
1075 InsetCommandParams p("url");
1076 string const data = InsetCommandMailer::params2string("url", p);
1077 bv->showInsetDialog("url", data, 0);
1081 case LFUN_HTML_INSERT: {
1082 InsetCommandParams p("htmlurl");
1083 string const data = InsetCommandMailer::params2string("url", p);
1084 bv->showInsetDialog("url", data, 0);
1088 case LFUN_LABEL_INSERT: {
1089 InsetCommandParams p("label");
1090 // Try to generate a valid label
1091 p["name"] = (cmd.argument().empty()) ?
1093 from_utf8(cur.getPossibleLabel()) :
1095 string const data = InsetCommandMailer::params2string("label", p);
1097 if (cmd.argument().empty()) {
1098 bv->showInsetDialog("label", data, 0);
1100 FuncRequest fr(LFUN_INSET_INSERT, data);
1108 case LFUN_LIST_INSERT:
1109 case LFUN_THEOREM_INSERT:
1110 case LFUN_CAPTION_INSERT:
1112 case LFUN_NOTE_INSERT:
1113 case LFUN_CHARSTYLE_INSERT:
1114 case LFUN_BOX_INSERT:
1115 case LFUN_BRANCH_INSERT:
1116 case LFUN_BIBITEM_INSERT:
1117 case LFUN_ERT_INSERT:
1118 case LFUN_FOOTNOTE_INSERT:
1119 case LFUN_MARGINALNOTE_INSERT:
1120 case LFUN_OPTIONAL_INSERT:
1121 case LFUN_ENVIRONMENT_INSERT:
1122 // Open the inset, and move the current selection
1124 doInsertInset(cur, this, cmd, true, true);
1128 case LFUN_TABULAR_INSERT:
1129 // if there were no arguments, just open the dialog
1130 if (doInsertInset(cur, this, cmd, false, true))
1133 bv->showDialog("tabularcreate");
1137 case LFUN_FLOAT_INSERT:
1138 case LFUN_FLOAT_WIDE_INSERT:
1139 case LFUN_WRAP_INSERT:
1140 doInsertInset(cur, this, cmd, true, true);
1142 // FIXME: the "Caption" name should not be hardcoded,
1143 // but given by the float definition.
1144 cur.dispatch(FuncRequest(LFUN_LAYOUT, "Caption"));
1147 case LFUN_INDEX_INSERT: {
1148 InsetBase * inset = createInset(&cur.bv(), cmd);
1153 cur.clearSelection();
1154 insertInset(cur, inset);
1155 inset->edit(cur, true);
1160 case LFUN_INDEX_PRINT:
1161 case LFUN_TOC_INSERT:
1162 case LFUN_HFILL_INSERT:
1163 case LFUN_LINE_INSERT:
1164 case LFUN_PAGEBREAK_INSERT:
1166 doInsertInset(cur, this, cmd, false, false);
1170 case LFUN_DEPTH_DECREMENT:
1171 changeDepth(cur, DEC_DEPTH);
1174 case LFUN_DEPTH_INCREMENT:
1175 changeDepth(cur, INC_DEPTH);
1178 case LFUN_MATH_DISPLAY:
1179 mathDispatch(cur, cmd, true);
1182 case LFUN_MATH_IMPORT_SELECTION:
1183 case LFUN_MATH_MODE:
1184 if (cmd.argument() == "on")
1185 // don't pass "on" as argument
1186 mathDispatch(cur, FuncRequest(LFUN_MATH_MODE), false);
1188 mathDispatch(cur, cmd, false);
1191 case LFUN_MATH_MACRO:
1192 if (cmd.argument().empty())
1193 cur.errorMessage(from_utf8(N_("Missing argument")));
1195 string s = to_utf8(cmd.argument());
1196 string const s1 = token(s, ' ', 1);
1197 int const nargs = s1.empty() ? 0 : convert<int>(s1);
1198 string const s2 = token(s, ' ', 2);
1199 string const type = s2.empty() ? "newcommand" : s2;
1200 cur.insert(new MathMacroTemplate(from_utf8(token(s, ' ', 0)), nargs, from_utf8(type)));
1201 //cur.nextInset()->edit(cur, true);
1205 // passthrough hat and underscore outside mathed:
1206 case LFUN_MATH_SUBSCRIPT:
1207 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "_"), false);
1209 case LFUN_MATH_SUPERSCRIPT:
1210 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "^"), false);
1213 case LFUN_MATH_INSERT:
1214 case LFUN_MATH_MATRIX:
1215 case LFUN_MATH_DELIM:
1216 case LFUN_MATH_BIGDELIM: {
1217 cur.insert(new InsetMathHull(hullSimple));
1218 cur.dispatch(FuncRequest(LFUN_CHAR_FORWARD));
1223 case LFUN_FONT_EMPH: {
1224 LyXFont font(LyXFont::ALL_IGNORE);
1225 font.setEmph(LyXFont::TOGGLE);
1226 toggleAndShow(cur, this, font);
1230 case LFUN_FONT_BOLD: {
1231 LyXFont font(LyXFont::ALL_IGNORE);
1232 font.setSeries(LyXFont::BOLD_SERIES);
1233 toggleAndShow(cur, this, font);
1237 case LFUN_FONT_NOUN: {
1238 LyXFont font(LyXFont::ALL_IGNORE);
1239 font.setNoun(LyXFont::TOGGLE);
1240 toggleAndShow(cur, this, font);
1244 case LFUN_FONT_CODE: {
1245 LyXFont font(LyXFont::ALL_IGNORE);
1246 font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
1247 toggleAndShow(cur, this, font);
1251 case LFUN_FONT_SANS: {
1252 LyXFont font(LyXFont::ALL_IGNORE);
1253 font.setFamily(LyXFont::SANS_FAMILY);
1254 toggleAndShow(cur, this, font);
1258 case LFUN_FONT_ROMAN: {
1259 LyXFont font(LyXFont::ALL_IGNORE);
1260 font.setFamily(LyXFont::ROMAN_FAMILY);
1261 toggleAndShow(cur, this, font);
1265 case LFUN_FONT_DEFAULT: {
1266 LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
1267 toggleAndShow(cur, this, font);
1271 case LFUN_FONT_UNDERLINE: {
1272 LyXFont font(LyXFont::ALL_IGNORE);
1273 font.setUnderbar(LyXFont::TOGGLE);
1274 toggleAndShow(cur, this, font);
1278 case LFUN_FONT_SIZE: {
1279 LyXFont font(LyXFont::ALL_IGNORE);
1280 font.setLyXSize(to_utf8(cmd.argument()));
1281 toggleAndShow(cur, this, font);
1285 case LFUN_LANGUAGE: {
1286 Language const * lang = languages.getLanguage(to_utf8(cmd.argument()));
1289 LyXFont font(LyXFont::ALL_IGNORE);
1290 font.setLanguage(lang);
1291 toggleAndShow(cur, this, font);
1296 case LFUN_FONT_FREE_APPLY:
1297 toggleAndShow(cur, this, freefont, toggleall);
1298 cur.message(_("Character set"));
1301 // Set the freefont using the contents of \param data dispatched from
1302 // the frontends and apply it at the current cursor location.
1303 case LFUN_FONT_FREE_UPDATE: {
1306 if (bv_funcs::string2font(to_utf8(cmd.argument()), font, toggle)) {
1309 toggleAndShow(cur, this, freefont, toggleall);
1310 cur.message(_("Character set"));
1315 case LFUN_FINISHED_LEFT:
1316 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_LEFT:\n" << cur << endl;
1319 case LFUN_FINISHED_RIGHT:
1320 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_RIGHT:\n" << cur << endl;
1324 case LFUN_FINISHED_UP:
1325 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_UP:\n" << cur << endl;
1329 case LFUN_FINISHED_DOWN:
1330 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_DOWN:\n" << cur << endl;
1334 case LFUN_LAYOUT_PARAGRAPH: {
1336 params2string(cur.paragraph(), data);
1337 data = "show\n" + data;
1338 bv->showDialogWithData("paragraph", data);
1342 case LFUN_PARAGRAPH_UPDATE: {
1344 params2string(cur.paragraph(), data);
1346 // Will the paragraph accept changes from the dialog?
1347 bool const accept = !cur.inset().forceDefaultParagraphs(cur.idx());
1349 data = "update " + convert<string>(accept) + '\n' + data;
1350 bv->updateDialog("paragraph", data);
1354 case LFUN_ACCENT_UMLAUT:
1355 case LFUN_ACCENT_CIRCUMFLEX:
1356 case LFUN_ACCENT_GRAVE:
1357 case LFUN_ACCENT_ACUTE:
1358 case LFUN_ACCENT_TILDE:
1359 case LFUN_ACCENT_CEDILLA:
1360 case LFUN_ACCENT_MACRON:
1361 case LFUN_ACCENT_DOT:
1362 case LFUN_ACCENT_UNDERDOT:
1363 case LFUN_ACCENT_UNDERBAR:
1364 case LFUN_ACCENT_CARON:
1365 case LFUN_ACCENT_SPECIAL_CARON:
1366 case LFUN_ACCENT_BREVE:
1367 case LFUN_ACCENT_TIE:
1368 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1369 case LFUN_ACCENT_CIRCLE:
1370 case LFUN_ACCENT_OGONEK:
1371 theLyXFunc().handleKeyFunc(cmd.action);
1372 if (!cmd.argument().empty())
1373 // FIXME: Are all these characters encoded in one byte in utf8?
1374 bv->getIntl().getTransManager()
1375 .translateAndInsert(cmd.argument()[0], this);
1378 case LFUN_FLOAT_LIST: {
1379 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
1380 if (tclass.floats().typeExist(to_utf8(cmd.argument()))) {
1381 // not quite sure if we want this...
1383 cur.clearSelection();
1384 breakParagraph(cur);
1386 if (cur.lastpos() != 0) {
1388 breakParagraph(cur);
1391 setLayout(cur, tclass.defaultLayoutName());
1392 setParagraph(cur, Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
1393 insertInset(cur, new InsetFloatList(to_utf8(cmd.argument())));
1396 lyxerr << "Non-existent float type: "
1397 << to_utf8(cmd.argument()) << endl;
1402 case LFUN_CHANGE_ACCEPT: {
1407 case LFUN_CHANGE_REJECT: {
1412 case LFUN_THESAURUS_ENTRY: {
1413 docstring arg = cmd.argument();
1415 arg = cur.selectionAsString(false);
1417 if (arg.size() > 100 || arg.empty()) {
1418 // Get word or selection
1419 selectWordWhenUnderCursor(cur, WHOLE_WORD);
1420 arg = cur.selectionAsString(false);
1423 bv->showDialogWithData("thesaurus", to_utf8(arg));
1427 case LFUN_PARAGRAPH_PARAMS_APPLY: {
1428 // Given data, an encoding of the ParagraphParameters
1429 // generated in the Paragraph dialog, this function sets
1430 // the current paragraph appropriately.
1431 istringstream is(to_utf8(cmd.argument()));
1434 ParagraphParameters params;
1440 to_ascii(params.labelWidthString()),
1442 cur.message(_("Paragraph layout set"));
1447 if (cur.selection()) {
1448 cur.selection() = false;
1451 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
1456 lyxerr[Debug::ACTION]
1457 << BOOST_CURRENT_FUNCTION
1458 << ": Command " << cmd
1459 << " not DISPATCHED by LyXText" << endl;
1464 needsUpdate |= (cur.pos() != cur.lastpos()) && cur.selection();
1465 if (singleParUpdate)
1466 // Inserting characters does not change par height
1467 if (cur.bottom().paragraph().dim().height()
1468 == olddim.height()) {
1469 // if so, update _only_ this paragraph
1470 cur.updateFlags(Update::SinglePar |
1472 Update::MultiParSel);
1477 && &oldTopSlice.inset() == &cur.inset()
1478 && oldTopSlice.idx() == cur.idx()
1480 && !cur.selection())
1483 cur.updateFlags(Update::Force | Update::FitCursor);
1487 bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
1488 FuncStatus & flag) const
1490 BOOST_ASSERT(cur.text() == this);
1492 LyXFont const & font = real_current_font;
1494 InsetBase::Code code = InsetBase::NO_CODE;
1496 switch (cmd.action) {
1498 case LFUN_DEPTH_DECREMENT:
1499 enable = changeDepthAllowed(cur, DEC_DEPTH);
1502 case LFUN_DEPTH_INCREMENT:
1503 enable = changeDepthAllowed(cur, INC_DEPTH);
1507 flag.setOnOff(cur.paragraph().params().startOfAppendix());
1510 case LFUN_BIBITEM_INSERT:
1511 enable = (cur.paragraph().layout()->labeltype == LABEL_BIBLIO);
1514 case LFUN_DIALOG_SHOW_NEW_INSET:
1515 if (cmd.argument() == "bibitem")
1516 code = InsetBase::BIBITEM_CODE;
1517 else if (cmd.argument() == "bibtex")
1518 code = InsetBase::BIBTEX_CODE;
1519 else if (cmd.argument() == "box")
1520 code = InsetBase::BOX_CODE;
1521 else if (cmd.argument() == "branch")
1522 code = InsetBase::BRANCH_CODE;
1523 else if (cmd.argument() == "citation")
1524 code = InsetBase::CITE_CODE;
1525 else if (cmd.argument() == "ert")
1526 code = InsetBase::ERT_CODE;
1527 else if (cmd.argument() == "external")
1528 code = InsetBase::EXTERNAL_CODE;
1529 else if (cmd.argument() == "float")
1530 code = InsetBase::FLOAT_CODE;
1531 else if (cmd.argument() == "graphics")
1532 code = InsetBase::GRAPHICS_CODE;
1533 else if (cmd.argument() == "include")
1534 code = InsetBase::INCLUDE_CODE;
1535 else if (cmd.argument() == "index")
1536 code = InsetBase::INDEX_CODE;
1537 else if (cmd.argument() == "label")
1538 code = InsetBase::LABEL_CODE;
1539 else if (cmd.argument() == "note")
1540 code = InsetBase::NOTE_CODE;
1541 else if (cmd.argument() == "ref")
1542 code = InsetBase::REF_CODE;
1543 else if (cmd.argument() == "toc")
1544 code = InsetBase::TOC_CODE;
1545 else if (cmd.argument() == "url")
1546 code = InsetBase::URL_CODE;
1547 else if (cmd.argument() == "vspace")
1548 code = InsetBase::VSPACE_CODE;
1549 else if (cmd.argument() == "wrap")
1550 code = InsetBase::WRAP_CODE;
1553 case LFUN_ERT_INSERT:
1554 code = InsetBase::ERT_CODE;
1556 case LFUN_FOOTNOTE_INSERT:
1557 code = InsetBase::FOOT_CODE;
1559 case LFUN_TABULAR_INSERT:
1560 code = InsetBase::TABULAR_CODE;
1562 case LFUN_MARGINALNOTE_INSERT:
1563 code = InsetBase::MARGIN_CODE;
1565 case LFUN_FLOAT_INSERT:
1566 case LFUN_FLOAT_WIDE_INSERT:
1567 code = InsetBase::FLOAT_CODE;
1569 case LFUN_WRAP_INSERT:
1570 code = InsetBase::WRAP_CODE;
1572 case LFUN_FLOAT_LIST:
1573 code = InsetBase::FLOAT_LIST_CODE;
1576 case LFUN_LIST_INSERT:
1577 code = InsetBase::LIST_CODE;
1579 case LFUN_THEOREM_INSERT:
1580 code = InsetBase::THEOREM_CODE;
1583 case LFUN_CAPTION_INSERT:
1584 code = InsetBase::CAPTION_CODE;
1586 case LFUN_NOTE_INSERT:
1587 code = InsetBase::NOTE_CODE;
1589 case LFUN_CHARSTYLE_INSERT:
1590 code = InsetBase::CHARSTYLE_CODE;
1591 if (cur.buffer().params().getLyXTextClass().charstyles().empty())
1594 case LFUN_BOX_INSERT:
1595 code = InsetBase::BOX_CODE;
1597 case LFUN_BRANCH_INSERT:
1598 code = InsetBase::BRANCH_CODE;
1599 if (cur.buffer().getMasterBuffer()->params().branchlist().empty())
1602 case LFUN_LABEL_INSERT:
1603 code = InsetBase::LABEL_CODE;
1605 case LFUN_OPTIONAL_INSERT:
1606 code = InsetBase::OPTARG_CODE;
1607 enable = numberOfOptArgs(cur.paragraph())
1608 < cur.paragraph().layout()->optionalargs;
1610 case LFUN_ENVIRONMENT_INSERT:
1611 code = InsetBase::BOX_CODE;
1613 case LFUN_INDEX_INSERT:
1614 code = InsetBase::INDEX_CODE;
1616 case LFUN_INDEX_PRINT:
1617 code = InsetBase::INDEX_PRINT_CODE;
1619 case LFUN_TOC_INSERT:
1620 code = InsetBase::TOC_CODE;
1622 case LFUN_HTML_INSERT:
1623 case LFUN_URL_INSERT:
1624 code = InsetBase::URL_CODE;
1626 case LFUN_QUOTE_INSERT:
1627 // always allow this, since we will inset a raw quote
1628 // if an inset is not allowed.
1630 case LFUN_HYPHENATION_POINT_INSERT:
1631 case LFUN_LIGATURE_BREAK_INSERT:
1632 case LFUN_HFILL_INSERT:
1633 case LFUN_MENU_SEPARATOR_INSERT:
1634 case LFUN_DOTS_INSERT:
1635 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
1636 code = InsetBase::SPECIALCHAR_CODE;
1638 case LFUN_SPACE_INSERT:
1639 // slight hack: we know this is allowed in math mode
1641 code = InsetBase::SPACE_CODE;
1644 case LFUN_INSET_MODIFY:
1645 // We need to disable this, because we may get called for a
1647 // InsetTabular::getStatus() -> InsetText::getStatus()
1648 // and we don't handle LFUN_INSET_MODIFY.
1652 case LFUN_FONT_EMPH:
1653 flag.setOnOff(font.emph() == LyXFont::ON);
1656 case LFUN_FONT_NOUN:
1657 flag.setOnOff(font.noun() == LyXFont::ON);
1660 case LFUN_FONT_BOLD:
1661 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
1664 case LFUN_FONT_SANS:
1665 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
1668 case LFUN_FONT_ROMAN:
1669 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
1672 case LFUN_FONT_CODE:
1673 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
1678 enable = cur.selection();
1682 enable = cap::numberOfSelections() > 0;
1685 case LFUN_PARAGRAPH_MOVE_UP:
1686 enable = cur.pit() > 0 && !cur.selection();
1689 case LFUN_PARAGRAPH_MOVE_DOWN:
1690 enable = cur.pit() < cur.lastpit() && !cur.selection();
1693 case LFUN_INSET_DISSOLVE:
1694 enable = !isMainText() && cur.inset().nargs() == 1;
1697 case LFUN_CHANGE_ACCEPT:
1698 case LFUN_CHANGE_REJECT:
1699 enable = true; // FIXME: Change tracking (MG)
1702 case LFUN_WORD_DELETE_FORWARD:
1703 case LFUN_WORD_DELETE_BACKWARD:
1704 case LFUN_LINE_DELETE:
1705 case LFUN_WORD_FORWARD:
1706 case LFUN_WORD_BACKWARD:
1707 case LFUN_CHAR_FORWARD:
1708 case LFUN_CHAR_FORWARD_SELECT:
1709 case LFUN_CHAR_BACKWARD:
1710 case LFUN_CHAR_BACKWARD_SELECT:
1712 case LFUN_UP_SELECT:
1714 case LFUN_DOWN_SELECT:
1715 case LFUN_PARAGRAPH_UP_SELECT:
1716 case LFUN_PARAGRAPH_DOWN_SELECT:
1717 case LFUN_SCREEN_UP_SELECT:
1718 case LFUN_SCREEN_DOWN_SELECT:
1719 case LFUN_LINE_BEGIN_SELECT:
1720 case LFUN_LINE_END_SELECT:
1721 case LFUN_WORD_FORWARD_SELECT:
1722 case LFUN_WORD_BACKWARD_SELECT:
1723 case LFUN_WORD_SELECT:
1724 case LFUN_PARAGRAPH_UP:
1725 case LFUN_PARAGRAPH_DOWN:
1726 case LFUN_SCREEN_UP:
1727 case LFUN_SCREEN_DOWN:
1728 case LFUN_LINE_BEGIN:
1730 case LFUN_BREAK_LINE:
1731 case LFUN_CHAR_DELETE_FORWARD:
1732 case LFUN_DELETE_FORWARD_SKIP:
1733 case LFUN_CHAR_DELETE_BACKWARD:
1734 case LFUN_DELETE_BACKWARD_SKIP:
1735 case LFUN_BREAK_PARAGRAPH:
1736 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
1737 case LFUN_BREAK_PARAGRAPH_SKIP:
1738 case LFUN_PARAGRAPH_SPACING:
1739 case LFUN_INSET_INSERT:
1740 case LFUN_WORD_UPCASE:
1741 case LFUN_WORD_LOWCASE:
1742 case LFUN_WORD_CAPITALIZE:
1743 case LFUN_CHARS_TRANSPOSE:
1744 case LFUN_SERVER_GET_XY:
1745 case LFUN_SERVER_SET_XY:
1746 case LFUN_SERVER_GET_FONT:
1747 case LFUN_SERVER_GET_LAYOUT:
1749 case LFUN_CLIPBOARD_PASTE:
1750 case LFUN_PRIMARY_SELECTION_PASTE:
1751 case LFUN_DATE_INSERT:
1752 case LFUN_SELF_INSERT:
1753 case LFUN_LINE_INSERT:
1754 case LFUN_PAGEBREAK_INSERT:
1755 case LFUN_MATH_DISPLAY:
1756 case LFUN_MATH_IMPORT_SELECTION:
1757 case LFUN_MATH_MODE:
1758 case LFUN_MATH_MACRO:
1759 case LFUN_MATH_MATRIX:
1760 case LFUN_MATH_DELIM:
1761 case LFUN_MATH_BIGDELIM:
1762 case LFUN_MATH_SUBSCRIPT:
1763 case LFUN_MATH_SUPERSCRIPT:
1764 case LFUN_FONT_DEFAULT:
1765 case LFUN_FONT_UNDERLINE:
1766 case LFUN_FONT_SIZE:
1768 case LFUN_FONT_FREE_APPLY:
1769 case LFUN_FONT_FREE_UPDATE:
1770 case LFUN_LAYOUT_PARAGRAPH:
1771 case LFUN_PARAGRAPH_UPDATE:
1772 case LFUN_ACCENT_UMLAUT:
1773 case LFUN_ACCENT_CIRCUMFLEX:
1774 case LFUN_ACCENT_GRAVE:
1775 case LFUN_ACCENT_ACUTE:
1776 case LFUN_ACCENT_TILDE:
1777 case LFUN_ACCENT_CEDILLA:
1778 case LFUN_ACCENT_MACRON:
1779 case LFUN_ACCENT_DOT:
1780 case LFUN_ACCENT_UNDERDOT:
1781 case LFUN_ACCENT_UNDERBAR:
1782 case LFUN_ACCENT_CARON:
1783 case LFUN_ACCENT_SPECIAL_CARON:
1784 case LFUN_ACCENT_BREVE:
1785 case LFUN_ACCENT_TIE:
1786 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1787 case LFUN_ACCENT_CIRCLE:
1788 case LFUN_ACCENT_OGONEK:
1789 case LFUN_THESAURUS_ENTRY:
1790 case LFUN_PARAGRAPH_PARAMS_APPLY:
1792 case LFUN_BUFFER_END:
1793 case LFUN_BUFFER_BEGIN:
1794 case LFUN_BUFFER_BEGIN_SELECT:
1795 case LFUN_BUFFER_END_SELECT:
1796 // these are handled in our dispatch()
1804 if (code != InsetBase::NO_CODE
1805 && (cur.empty() || !cur.inset().insetAllowed(code)))
1808 flag.enabled(enable);