3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Asger Alstrup
7 * \author Lars Gullik Bjønnes
8 * \author Alfredo Braunstein
9 * \author Angus Leeming
11 * \author André Pönitz
13 * Full author contact details are available in file CREDITS.
20 #include "BranchList.h"
21 #include "FloatList.h"
22 #include "FuncStatus.h"
24 #include "buffer_funcs.h"
25 #include "bufferparams.h"
26 #include "BufferView.h"
28 #include "coordcache.h"
29 #include "CutAndPaste.h"
31 #include "dispatchresult.h"
32 #include "errorlist.h"
34 #include "funcrequest.h"
38 #include "LyXAction.h"
43 #include "paragraph.h"
44 #include "paragraph_funcs.h"
45 #include "ParagraphParameters.h"
48 #include "pariterator.h"
50 #include "frontends/Dialogs.h"
51 #include "frontends/Gui.h"
52 #include "frontends/LyXView.h"
53 #include "frontends/Clipboard.h"
54 #include "frontends/Selection.h"
56 #include "insets/insetcommand.h"
57 #include "insets/insetfloatlist.h"
58 #include "insets/insetnewline.h"
59 #include "insets/insetquotes.h"
60 #include "insets/insetspecialchar.h"
61 #include "insets/insettext.h"
63 #include "support/lstrings.h"
64 #include "support/lyxlib.h"
65 #include "support/convert.h"
66 #include "support/lyxtime.h"
67 #include "support/unicode.h"
69 #include "mathed/math_hullinset.h"
70 #include "mathed/math_macrotemplate.h"
72 #include <boost/current_function.hpp>
80 using lyx::cap::copySelection;
81 using lyx::cap::cutSelection;
82 using lyx::cap::pasteParagraphList;
83 using lyx::cap::pasteSelection;
84 using lyx::cap::replaceSelection;
86 using lyx::support::isStrUnsignedInt;
87 using lyx::support::token;
89 using lyx::frontend::Gui;
90 using lyx::frontend::Clipboard;
94 using std::istringstream;
95 using std::ostringstream;
98 extern string current_layout;
104 LyXFont freefont(LyXFont::ALL_IGNORE);
105 bool toggleall = false;
108 void toggleAndShow(LCursor & cur, LyXText * text,
109 LyXFont const & font, bool toggleall = true)
111 text->toggleFree(cur, font, toggleall);
113 if (font.language() != ignore_language ||
114 font.number() != LyXFont::IGNORE) {
115 Paragraph & par = cur.paragraph();
116 text->bidi.computeTables(par, cur.buffer(), cur.textRow());
117 if (cur.boundary() !=
118 text->bidi.isBoundary(cur.buffer(), par,
120 text->real_current_font))
121 text->setCursor(cur, cur.pit(), cur.pos(),
122 false, !cur.boundary());
127 void moveCursor(LCursor & cur, bool selecting)
129 if (selecting || cur.mark())
131 if (!cur.selection())
132 cur.bv().owner()->gui().selection().haveSelection(false);
133 cur.bv().switchKeyMap();
137 void finishChange(LCursor & cur, bool selecting)
140 moveCursor(cur, selecting);
144 void mathDispatch(LCursor & cur, FuncRequest const & cmd, bool display)
147 string sel = cur.selectionAsString(false);
148 //lyxerr << "selection is: '" << sel << "'" << endl;
150 // It may happen that sel is empty but there is a selection
151 replaceSelection(cur);
154 const int old_pos = cur.pos();
155 cur.insert(new MathHullInset("simple"));
156 BOOST_ASSERT(old_pos == cur.pos());
157 cur.nextInset()->edit(cur, true);
158 // don't do that also for LFUN_MATH_MODE
159 // unless you want end up with always changing
160 // to mathrm when opening an inlined inset --
161 // I really hate "LyXfunc overloading"...
163 cur.dispatch(FuncRequest(LFUN_MATH_DISPLAY));
164 // Avoid an unnecessary undo step if cmd.argument
166 if (!cmd.argument.empty())
167 cur.dispatch(FuncRequest(LFUN_MATH_INSERT,
170 // create a macro if we see "\\newcommand"
171 // somewhere, and an ordinary formula
173 istringstream is(sel);
174 if (sel.find("\\newcommand") == string::npos
175 && sel.find("\\def") == string::npos)
177 MathHullInset * formula = new MathHullInset;
180 formula->read(cur.buffer(), lex);
181 if (formula->getType() == "none")
182 // Don't create pseudo formulas if
183 // delimiters are left out
184 formula->mutate("simple");
187 cur.insert(new MathMacroTemplate(is));
189 cur.message(N_("Math editor mode"));
198 string const freefont2string()
201 if (font2string(freefont, toggleall, data))
208 bool LyXText::cursorPrevious(LCursor & cur)
210 pos_type cpos = cur.pos();
211 lyx::pit_type cpar = cur.pit();
213 int x = cur.x_target();
215 bool updated = setCursorFromCoordinates(cur, x, 0);
218 updated |= cursorUp(cur);
220 if (cpar == cur.pit() && cpos == cur.pos()) {
221 // we have a row which is taller than the workarea. The
222 // simplest solution is to move to the previous row instead.
223 updated |= cursorUp(cur);
231 bool LyXText::cursorNext(LCursor & cur)
233 pos_type cpos = cur.pos();
234 lyx::pit_type cpar = cur.pit();
236 int x = cur.x_target();
237 bool updated = setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1);
240 updated |= cursorDown(cur);
242 if (cpar == cur.pit() && cpos == cur.pos()) {
243 // we have a row which is taller than the workarea. The
244 // simplest solution is to move to the next row instead.
245 updated |= cursorDown(cur);
255 void specialChar(LCursor & cur, InsetSpecialChar::Kind kind)
257 lyx::cap::replaceSelection(cur);
258 cur.insert(new InsetSpecialChar(kind));
263 bool doInsertInset(LCursor & cur, LyXText * text,
264 FuncRequest const & cmd, bool edit, bool pastesel)
266 InsetBase * inset = createInset(&cur.bv(), cmd);
272 if (cur.selection()) {
273 cur.bv().owner()->dispatch(FuncRequest(LFUN_CUT));
276 text->insertInset(cur, inset);
279 inset->edit(cur, true);
281 if (gotsel && pastesel)
282 cur.bv().owner()->dispatch(FuncRequest(LFUN_PASTE));
287 void update(LCursor & cur)
289 //we don't call update(true, false) directly to save a metrics call
290 if (cur.bv().fitCursor())
291 cur.bv().update(Update::Force);
298 void LyXText::number(LCursor & cur)
300 LyXFont font(LyXFont::ALL_IGNORE);
301 font.setNumber(LyXFont::TOGGLE);
302 toggleAndShow(cur, this, font);
306 bool LyXText::isRTL(Paragraph const & par) const
308 return par.isRightToLeftPar(bv()->buffer()->params());
312 void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
314 lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl;
316 BOOST_ASSERT(cur.text() == this);
317 BufferView * bv = &cur.bv();
318 CursorSlice oldTopSlice = cur.top();
319 bool oldBoundary = cur.boundary();
320 bool sel = cur.selection();
321 // Signals that, even if needsUpdate == false, an update of the
322 // cursor paragraph is required
323 bool singleParUpdate = lyxaction.funcHasFlag(cmd.action,
324 LyXAction::SingleParUpdate);
325 // Signals that a full-screen update is required
326 bool needsUpdate = !(lyxaction.funcHasFlag(cmd.action,
327 LyXAction::NoUpdate) || singleParUpdate);
328 // Remember the old paragraph metric (_outer_ paragraph!)
329 Dimension olddim = cur.bottom().paragraph().dim();
331 switch (cmd.action) {
333 case LFUN_PARAGRAPH_MOVE_DOWN: {
334 pit_type const pit = cur.pit();
335 recUndo(pit, pit + 1);
337 std::swap(pars_[pit], pars_[pit + 1]);
339 ParIterator begin(cur);
341 ParIterator end = boost::next(ParIterator(cur));
342 updateLabels(cur.buffer(), begin, end);
348 case LFUN_PARAGRAPH_MOVE_UP: {
349 pit_type const pit = cur.pit();
350 recUndo(pit - 1, pit);
352 std::swap(pars_[pit], pars_[pit - 1]);
354 ParIterator end = boost::next(ParIterator(cur));
356 ParIterator begin(cur);
357 updateLabels(cur.buffer(), begin, end);
363 case LFUN_APPENDIX: {
364 Paragraph & par = cur.paragraph();
365 bool start = !par.params().startOfAppendix();
368 #warning The code below only makes sense at top level.
369 // Should LFUN_APPENDIX be restricted to top-level paragraphs?
371 // ensure that we have only one start_of_appendix in this document
372 for (pit_type tmp = 0, end = pars_.size(); tmp != end; ++tmp) {
373 if (pars_[tmp].params().startOfAppendix()) {
375 pars_[tmp].params().startOfAppendix(false);
381 par.params().startOfAppendix(start);
383 // we can set the refreshing parameters now
384 updateLabels(cur.buffer());
388 case LFUN_WORD_DELETE_FORWARD:
389 cur.clearSelection();
390 deleteWordForward(cur);
391 finishChange(cur, false);
394 case LFUN_WORD_DELETE_BACKWARD:
395 cur.clearSelection();
396 deleteWordBackward(cur);
397 finishChange(cur, false);
400 case LFUN_LINE_DELETE:
401 cur.clearSelection();
402 deleteLineForward(cur);
403 finishChange(cur, false);
406 case LFUN_BUFFER_BEGIN:
407 case LFUN_BUFFER_BEGIN_SELECT:
408 cur.selHandle(cmd.action == LFUN_BUFFER_BEGIN_SELECT);
409 if (cur.depth() == 1) {
410 needsUpdate = cursorTop(cur);
416 case LFUN_BUFFER_END:
417 case LFUN_BUFFER_END_SELECT:
418 cur.selHandle(cmd.action == LFUN_BUFFER_END_SELECT);
419 if (cur.depth() == 1) {
420 needsUpdate = cursorBottom(cur);
426 case LFUN_CHAR_FORWARD:
427 case LFUN_CHAR_FORWARD_SELECT:
428 //lyxerr << BOOST_CURRENT_FUNCTION
429 // << " LFUN_CHAR_FORWARD[SEL]:\n" << cur << endl;
430 cur.selHandle(cmd.action == LFUN_CHAR_FORWARD_SELECT);
431 if (isRTL(cur.paragraph()))
432 needsUpdate = cursorLeft(cur);
434 needsUpdate = cursorRight(cur);
436 if (!needsUpdate && oldTopSlice == cur.top()
437 && cur.boundary() == oldBoundary) {
439 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
443 case LFUN_CHAR_BACKWARD:
444 case LFUN_CHAR_BACKWARD_SELECT:
445 //lyxerr << "handle LFUN_CHAR_BACKWARD[_SELECT]:\n" << cur << endl;
446 cur.selHandle(cmd.action == LFUN_CHAR_BACKWARD_SELECT);
447 if (isRTL(cur.paragraph()))
448 needsUpdate = cursorRight(cur);
450 needsUpdate = cursorLeft(cur);
452 if (!needsUpdate && oldTopSlice == cur.top()
453 && cur.boundary() == oldBoundary) {
455 cmd = FuncRequest(LFUN_FINISHED_LEFT);
462 //lyxerr << "handle LFUN_UP[SEL]:\n" << cur << endl;
463 cur.selHandle(cmd.action == LFUN_UP_SELECT);
465 needsUpdate = cursorUp(cur);
466 if (!needsUpdate && oldTopSlice == cur.top()
467 && cur.boundary() == oldBoundary) {
469 cmd = FuncRequest(LFUN_FINISHED_UP);
474 case LFUN_DOWN_SELECT:
476 //lyxerr << "handle LFUN_DOWN[SEL]:\n" << cur << endl;
477 cur.selHandle(cmd.action == LFUN_DOWN_SELECT);
478 needsUpdate = cursorDown(cur);
479 if (!needsUpdate && oldTopSlice == cur.top() &&
480 cur.boundary() == oldBoundary)
483 cmd = FuncRequest(LFUN_FINISHED_DOWN);
487 case LFUN_PARAGRAPH_UP:
488 case LFUN_PARAGRAPH_UP_SELECT:
489 cur.selHandle(cmd.action == LFUN_PARAGRAPH_UP_SELECT);
490 needsUpdate = cursorUpParagraph(cur);
493 case LFUN_PARAGRAPH_DOWN:
494 case LFUN_PARAGRAPH_DOWN_SELECT:
495 cur.selHandle(cmd.action == LFUN_PARAGRAPH_DOWN_SELECT);
496 needsUpdate = cursorDownParagraph(cur);
500 case LFUN_SCREEN_UP_SELECT:
502 cur.selHandle(cmd.action == LFUN_SCREEN_UP_SELECT);
503 if (cur.pit() == 0 && cur.textRow().pos() == 0) {
505 cmd = FuncRequest(LFUN_FINISHED_UP);
507 needsUpdate = cursorPrevious(cur);
511 case LFUN_SCREEN_DOWN:
512 case LFUN_SCREEN_DOWN_SELECT:
514 cur.selHandle(cmd.action == LFUN_SCREEN_DOWN_SELECT);
515 if (cur.pit() == cur.lastpit()
516 && cur.textRow().endpos() == cur.lastpos()) {
518 cmd = FuncRequest(LFUN_FINISHED_DOWN);
520 needsUpdate = cursorNext(cur);
524 case LFUN_LINE_BEGIN:
525 case LFUN_LINE_BEGIN_SELECT:
527 cur.selHandle(cmd.action == LFUN_LINE_BEGIN_SELECT);
528 needsUpdate = cursorHome(cur);
532 case LFUN_LINE_END_SELECT:
534 cur.selHandle(cmd.action == LFUN_LINE_END_SELECT);
535 needsUpdate = cursorEnd(cur);
538 case LFUN_WORD_FORWARD:
539 case LFUN_WORD_FORWARD_SELECT:
540 cur.selHandle(cmd.action == LFUN_WORD_FORWARD_SELECT);
541 if (isRTL(cur.paragraph()))
542 needsUpdate = cursorLeftOneWord(cur);
544 needsUpdate = cursorRightOneWord(cur);
547 case LFUN_WORD_BACKWARD:
548 case LFUN_WORD_BACKWARD_SELECT:
549 cur.selHandle(cmd.action == LFUN_WORD_BACKWARD_SELECT);
550 if (isRTL(cur.paragraph()))
551 needsUpdate = cursorRightOneWord(cur);
553 needsUpdate = cursorLeftOneWord(cur);
556 case LFUN_WORD_SELECT: {
557 selectWord(cur, lyx::WHOLE_WORD);
558 finishChange(cur, true);
562 case LFUN_BREAK_LINE: {
563 // Not allowed by LaTeX (labels or empty par)
564 if (cur.pos() > cur.paragraph().beginOfBody()) {
565 lyx::cap::replaceSelection(cur);
566 cur.insert(new InsetNewline);
568 moveCursor(cur, false);
573 case LFUN_CHAR_DELETE_FORWARD:
574 if (!cur.selection()) {
575 if (cur.pos() == cur.paragraph().size())
576 // Par boundary, force full-screen update
577 singleParUpdate = false;
578 needsUpdate = erase(cur);
580 // It is possible to make it a lot faster still
581 // just comment out the line below...
583 cutSelection(cur, true, false);
584 singleParUpdate = false;
586 moveCursor(cur, false);
589 case LFUN_DELETE_FORWARD_SKIP:
590 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
591 if (!cur.selection()) {
592 if (cur.pos() == cur.lastpos()) {
599 cutSelection(cur, true, false);
604 case LFUN_CHAR_DELETE_BACKWARD:
605 if (!cur.selection()) {
606 if (bv->owner()->getIntl().getTransManager().backspace()) {
607 // Par boundary, full-screen update
609 singleParUpdate = false;
610 needsUpdate = backspace(cur);
612 // It is possible to make it a lot faster still
613 // just comment out the line below...
616 cutSelection(cur, true, false);
617 singleParUpdate = false;
622 case LFUN_DELETE_BACKWARD_SKIP:
623 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
624 if (!cur.selection()) {
628 //CursorSlice cur = cursor();
632 cutSelection(cur, true, false);
636 case LFUN_BREAK_PARAGRAPH:
637 lyx::cap::replaceSelection(cur);
638 breakParagraph(cur, 0);
643 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
644 lyx::cap::replaceSelection(cur);
645 breakParagraph(cur, 1);
650 case LFUN_BREAK_PARAGRAPH_SKIP: {
651 // When at the beginning of a paragraph, remove
652 // indentation. Otherwise, do the same as LFUN_BREAK_PARAGRAPH.
653 lyx::cap::replaceSelection(cur);
655 cur.paragraph().params().labelWidthString(string());
657 breakParagraph(cur, 0);
663 case LFUN_PARAGRAPH_SPACING: {
664 Paragraph & par = cur.paragraph();
665 Spacing::Space cur_spacing = par.params().spacing().getSpace();
666 string cur_value = "1.0";
667 if (cur_spacing == Spacing::Other)
668 cur_value = par.params().spacing().getValueAsString();
670 istringstream is(cmd.argument);
673 Spacing::Space new_spacing = cur_spacing;
674 string new_value = cur_value;
676 lyxerr << "Missing argument to `paragraph-spacing'"
678 } else if (tmp == "single") {
679 new_spacing = Spacing::Single;
680 } else if (tmp == "onehalf") {
681 new_spacing = Spacing::Onehalf;
682 } else if (tmp == "double") {
683 new_spacing = Spacing::Double;
684 } else if (tmp == "other") {
685 new_spacing = Spacing::Other;
686 string tmpval = "0.0";
688 lyxerr << "new_value = " << tmpval << endl;
691 } else if (tmp == "default") {
692 new_spacing = Spacing::Default;
694 lyxerr << _("Unknown spacing argument: ")
695 << cmd.argument << endl;
697 if (cur_spacing != new_spacing || cur_value != new_value)
698 par.params().spacing(Spacing(new_spacing, new_value));
702 case LFUN_INSET_INSERT: {
704 InsetBase * inset = createInset(bv, cmd);
706 insertInset(cur, inset);
712 case LFUN_INSET_DISSOLVE: {
713 recordUndoInset(cur);
714 cur.selHandle(false);
716 lyx::pos_type spos = cur.pos();
717 lyx::pit_type spit = cur.pit();
719 if (cur.lastpit() != 0 || cur.lastpos() != 0)
720 plist = paragraphs();
722 // store cursor offset
726 cur.paragraph().erase(cur.pos());
727 if (!plist.empty()) {
728 Buffer * b = bv->buffer();
729 pasteParagraphList(cur, plist, b->params().textclass,
730 b->errorList("Paste"));
732 cur.pit() = std::min(cur.lastpit(), spit);
733 cur.pos() = std::min(cur.lastpos(), spos);
735 cur.clearSelection();
741 case LFUN_INSET_SETTINGS:
742 cur.inset().showInsetDialog(bv);
745 case LFUN_SPACE_INSERT:
746 if (cur.paragraph().layout()->free_spacing)
747 insertChar(cur, ' ');
749 doInsertInset(cur, this, cmd, false, false);
752 moveCursor(cur, false);
755 case LFUN_HYPHENATION_POINT_INSERT:
756 specialChar(cur, InsetSpecialChar::HYPHENATION);
759 case LFUN_LIGATURE_BREAK_INSERT:
760 specialChar(cur, InsetSpecialChar::LIGATURE_BREAK);
763 case LFUN_DOTS_INSERT:
764 specialChar(cur, InsetSpecialChar::LDOTS);
767 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
768 specialChar(cur, InsetSpecialChar::END_OF_SENTENCE);
771 case LFUN_MENU_SEPARATOR_INSERT:
772 specialChar(cur, InsetSpecialChar::MENU_SEPARATOR);
775 case LFUN_WORD_UPCASE:
776 changeCase(cur, LyXText::text_uppercase);
779 case LFUN_WORD_LOWCASE:
780 changeCase(cur, LyXText::text_lowercase);
783 case LFUN_WORD_CAPITALIZE:
784 changeCase(cur, LyXText::text_capitalization);
787 case LFUN_CHARS_TRANSPOSE:
792 cur.message(_("Paste"));
793 lyx::cap::replaceSelection(cur);
794 if (isStrUnsignedInt(cmd.argument))
795 pasteSelection(cur, bv->buffer()->errorList("Paste"),
796 convert<unsigned int>(cmd.argument));
798 pasteSelection(cur, bv->buffer()->errorList("Paste"),
800 bv->buffer()->errors("Paste");
801 cur.clearSelection(); // bug 393
807 cutSelection(cur, true, true);
808 cur.message(_("Cut"));
813 cur.message(_("Copy"));
816 case LFUN_SERVER_GET_XY:
817 cur.message(convert<string>(cursorX(cur.top(), cur.boundary())) + ' '
818 + convert<string>(cursorY(cur.top(), cur.boundary())));
821 case LFUN_SERVER_SET_XY: {
824 istringstream is(cmd.argument);
827 lyxerr << "SETXY: Could not parse coordinates in '"
828 << cmd.argument << std::endl;
830 setCursorFromCoordinates(cur, x, y);
834 case LFUN_SERVER_GET_FONT:
835 if (current_font.shape() == LyXFont::ITALIC_SHAPE)
837 else if (current_font.shape() == LyXFont::SMALLCAPS_SHAPE)
843 case LFUN_SERVER_GET_LAYOUT:
844 cur.message(cur.paragraph().layout()->name());
848 lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) "
849 << cmd.argument << endl;
851 // This is not the good solution to the empty argument
852 // problem, but it will hopefully suffice for 1.2.0.
853 // The correct solution would be to augument the
854 // function list/array with information about what
855 // functions needs arguments and their type.
856 if (cmd.argument.empty()) {
857 cur.errorMessage(_("LyX function 'layout' needs an argument."));
861 // Derive layout number from given argument (string)
862 // and current buffer's textclass (number)
863 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
864 bool hasLayout = tclass.hasLayout(cmd.argument);
865 string layout = cmd.argument;
867 // If the entry is obsolete, use the new one instead.
869 string const & obs = tclass[layout]->obsoleted_by();
875 cur.errorMessage(string(N_("Layout ")) + cmd.argument +
880 bool change_layout = (current_layout != layout);
882 if (!change_layout && cur.selection() &&
883 cur.selBegin().pit() != cur.selEnd().pit())
885 pit_type spit = cur.selBegin().pit();
886 pit_type epit = cur.selEnd().pit() + 1;
887 while (spit != epit) {
888 if (pars_[spit].layout()->name() != current_layout) {
889 change_layout = true;
897 current_layout = layout;
898 setLayout(cur, layout);
899 bv->owner()->setLayout(layout);
905 case LFUN_CLIPBOARD_PASTE: {
906 cur.clearSelection();
907 string const clip = bv->owner()->gui().clipboard().get();
910 if (cmd.argument == "paragraph")
911 insertStringAsParagraphs(cur, clip);
913 insertStringAsLines(cur, clip);
918 case LFUN_PRIMARY_SELECTION_PASTE: {
919 cur.clearSelection();
920 string const clip = bv->owner()->gui().selection().get();
923 if (cmd.argument == "paragraph")
924 insertStringAsParagraphs(cur, clip);
926 insertStringAsLines(cur, clip);
931 case LFUN_QUOTE_INSERT: {
932 lyx::cap::replaceSelection(cur);
933 Paragraph & par = cur.paragraph();
934 lyx::pos_type pos = cur.pos();
938 else if (cur.prevInset() && cur.prevInset()->isSpace())
941 c = par.getChar(pos - 1);
943 LyXLayout_ptr const & style = par.layout();
945 BufferParams const & bufparams = bv->buffer()->params();
946 if (!style->pass_thru
947 && par.getFontSettings(bufparams, pos).language()->lang() != "hebrew") {
948 string arg = cmd.argument;
950 cur.insert(new InsetQuotes(c,
951 bufparams.quotes_language,
952 InsetQuotes::SingleQ));
954 cur.insert(new InsetQuotes(c,
955 bufparams.quotes_language,
956 InsetQuotes::DoubleQ));
960 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT, "\""));
964 case LFUN_DATE_INSERT:
965 if (cmd.argument.empty())
966 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT,
967 lyx::formatted_time(lyx::current_time())));
969 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT,
970 lyx::formatted_time(lyx::current_time(), cmd.argument)));
973 case LFUN_MOUSE_TRIPLE:
974 if (cmd.button() == mouse_button::button1) {
980 bv->owner()->gui().selection().haveSelection(cur.selection());
984 case LFUN_MOUSE_DOUBLE:
985 if (cmd.button() == mouse_button::button1) {
986 selectWord(cur, lyx::WHOLE_WORD_STRICT);
988 bv->owner()->gui().selection().haveSelection(cur.selection());
992 // Single-click on work area
993 case LFUN_MOUSE_PRESS: {
994 // Right click on a footnote flag opens float menu
995 if (cmd.button() == mouse_button::button3)
996 cur.clearSelection();
998 // Middle button press pastes if we have a selection
999 // We do this here as if the selection was inside an inset
1000 // it could get cleared on the unlocking of the inset so
1001 // we have to check this first
1002 bool paste_internally = false;
1003 if (cmd.button() == mouse_button::button2 && cur.selection()) {
1004 bv->owner()->dispatch(FuncRequest(LFUN_COPY));
1005 paste_internally = true;
1008 bv->mouseSetCursor(cur);
1010 // Insert primary selection with middle mouse
1011 // if there is a local selection in the current buffer,
1013 if (cmd.button() == mouse_button::button2) {
1014 if (paste_internally)
1015 bv->owner()->dispatch(FuncRequest(LFUN_PASTE));
1017 bv->owner()->dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph"));
1023 case LFUN_MOUSE_MOTION: {
1024 // Only use motion with button 1
1025 //if (cmd.button() != mouse_button::button1)
1028 // ignore motions deeper nested than the real anchor
1029 LCursor & bvcur = cur.bv().cursor();
1030 if (bvcur.anchor_.hasPart(cur)) {
1031 CursorSlice old = bvcur.top();
1033 int const wh = bv->workHeight();
1034 int const y = std::max(0, std::min(wh - 1, cmd.y));
1036 setCursorFromCoordinates(cur, cmd.x, y);
1037 cur.x_target() = cmd.x;
1042 // This is to allow jumping over large insets
1043 if (cur.top() == old) {
1050 if (cur.top() == old)
1053 // don't set anchor_
1054 bvcur.setCursor(cur);
1055 bvcur.selection() = true;
1056 //lyxerr << "MOTION: " << bv->cursor() << endl;
1064 case LFUN_MOUSE_RELEASE: {
1065 if (cmd.button() == mouse_button::button2)
1069 if (cmd.button() == mouse_button::button1)
1070 bv->owner()->gui().selection().haveSelection(cur.selection());
1073 bv->owner()->updateMenubar();
1074 bv->owner()->updateToolbars();
1078 case LFUN_SELF_INSERT: {
1079 if (cmd.argument.empty())
1082 // Automatically delete the currently selected
1083 // text and replace it with what is being
1084 // typed in now. Depends on lyxrc settings
1085 // "auto_region_delete", which defaults to
1088 if (lyxrc.auto_region_delete) {
1089 if (cur.selection())
1090 cutSelection(cur, false, false);
1091 bv->owner()->gui().selection().haveSelection(false);
1094 cur.clearSelection();
1095 LyXFont const old_font = real_current_font;
1098 string::const_iterator cit = cmd.argument.begin();
1099 string::const_iterator end = cmd.argument.end();
1100 for (; cit != end; ++cit)
1101 bv->owner()->getIntl().getTransManager().
1102 translateAndInsert(*cit, this);
1104 std::vector<char> in(cmd.argument.begin(), cmd.argument.end());
1105 std::vector<boost::uint32_t> const res = utf8_to_ucs4(in);
1106 std::vector<boost::uint32_t>::const_iterator cit = res.begin();
1107 std::vector<boost::uint32_t>::const_iterator end = res.end();
1108 for (; cit != end; ++cit)
1109 insertChar(bv->cursor(), *cit);
1113 moveCursor(cur, false);
1117 case LFUN_URL_INSERT: {
1118 InsetCommandParams p("url");
1119 string const data = InsetCommandMailer::params2string("url", p);
1120 bv->owner()->getDialogs().show("url", data, 0);
1124 case LFUN_HTML_INSERT: {
1125 InsetCommandParams p("htmlurl");
1126 string const data = InsetCommandMailer::params2string("url", p);
1127 bv->owner()->getDialogs().show("url", data, 0);
1131 case LFUN_LABEL_INSERT: {
1132 // Try to generate a valid label
1133 string const contents = cmd.argument.empty() ?
1134 cur.getPossibleLabel() : cmd.argument;
1136 InsetCommandParams p("label", contents);
1137 string const data = InsetCommandMailer::params2string("label", p);
1139 if (cmd.argument.empty()) {
1140 bv->owner()->getDialogs().show("label", data, 0);
1142 FuncRequest fr(LFUN_INSET_INSERT, data);
1150 case LFUN_LIST_INSERT:
1151 case LFUN_THEOREM_INSERT:
1152 case LFUN_CAPTION_INSERT:
1154 case LFUN_NOTE_INSERT:
1155 case LFUN_CHARSTYLE_INSERT:
1156 case LFUN_BOX_INSERT:
1157 case LFUN_BRANCH_INSERT:
1158 case LFUN_BIBITEM_INSERT:
1159 case LFUN_ERT_INSERT:
1160 case LFUN_FOOTNOTE_INSERT:
1161 case LFUN_MARGINALNOTE_INSERT:
1162 case LFUN_OPTIONAL_INSERT:
1163 case LFUN_ENVIRONMENT_INSERT:
1164 // Open the inset, and move the current selection
1166 doInsertInset(cur, this, cmd, true, true);
1170 case LFUN_TABULAR_INSERT:
1171 // if there were no arguments, just open the dialog
1172 if (doInsertInset(cur, this, cmd, false, true))
1175 bv->owner()->getDialogs().show("tabularcreate");
1179 case LFUN_FLOAT_INSERT:
1180 case LFUN_FLOAT_WIDE_INSERT:
1181 case LFUN_WRAP_INSERT:
1182 doInsertInset(cur, this, cmd, true, true);
1184 // FIXME: the "Caption" name should not be hardcoded,
1185 // but given by the float definition.
1186 cur.dispatch(FuncRequest(LFUN_LAYOUT, "Caption"));
1189 case LFUN_INDEX_INSERT: {
1190 InsetBase * inset = createInset(&cur.bv(), cmd);
1195 cur.clearSelection();
1196 insertInset(cur, inset);
1197 inset->edit(cur, true);
1202 case LFUN_INDEX_PRINT:
1203 case LFUN_TOC_INSERT:
1204 case LFUN_HFILL_INSERT:
1205 case LFUN_LINE_INSERT:
1206 case LFUN_PAGEBREAK_INSERT:
1208 doInsertInset(cur, this, cmd, false, false);
1212 case LFUN_DEPTH_DECREMENT:
1213 changeDepth(cur, DEC_DEPTH);
1216 case LFUN_DEPTH_INCREMENT:
1217 changeDepth(cur, INC_DEPTH);
1220 case LFUN_MATH_DISPLAY:
1221 mathDispatch(cur, cmd, true);
1224 case LFUN_MATH_IMPORT_SELECTION:
1225 case LFUN_MATH_MODE:
1226 if (cmd.argument == "on")
1227 // don't pass "on" as argument
1228 mathDispatch(cur, FuncRequest(LFUN_MATH_MODE), false);
1230 mathDispatch(cur, cmd, false);
1233 case LFUN_MATH_MACRO:
1234 if (cmd.argument.empty())
1235 cur.errorMessage(N_("Missing argument"));
1237 string s = cmd.argument;
1238 string const s1 = token(s, ' ', 1);
1239 int const nargs = s1.empty() ? 0 : convert<int>(s1);
1240 string const s2 = token(s, ' ', 2);
1241 string const type = s2.empty() ? "newcommand" : s2;
1242 cur.insert(new MathMacroTemplate(token(s, ' ', 0), nargs, type));
1243 //cur.nextInset()->edit(cur, true);
1247 // passthrough hat and underscore outside mathed:
1248 case LFUN_MATH_SUBSCRIPT:
1249 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "_"), false);
1251 case LFUN_MATH_SUPERSCRIPT:
1252 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "^"), false);
1255 case LFUN_MATH_INSERT:
1256 case LFUN_MATH_MATRIX:
1257 case LFUN_MATH_DELIM:
1258 case LFUN_MATH_BIGDELIM: {
1259 cur.insert(new MathHullInset("simple"));
1260 cur.dispatch(FuncRequest(LFUN_CHAR_FORWARD));
1265 case LFUN_FONT_EMPH: {
1266 LyXFont font(LyXFont::ALL_IGNORE);
1267 font.setEmph(LyXFont::TOGGLE);
1268 toggleAndShow(cur, this, font);
1272 case LFUN_FONT_BOLD: {
1273 LyXFont font(LyXFont::ALL_IGNORE);
1274 font.setSeries(LyXFont::BOLD_SERIES);
1275 toggleAndShow(cur, this, font);
1279 case LFUN_FONT_NOUN: {
1280 LyXFont font(LyXFont::ALL_IGNORE);
1281 font.setNoun(LyXFont::TOGGLE);
1282 toggleAndShow(cur, this, font);
1286 case LFUN_FONT_CODE: {
1287 LyXFont font(LyXFont::ALL_IGNORE);
1288 font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
1289 toggleAndShow(cur, this, font);
1293 case LFUN_FONT_SANS: {
1294 LyXFont font(LyXFont::ALL_IGNORE);
1295 font.setFamily(LyXFont::SANS_FAMILY);
1296 toggleAndShow(cur, this, font);
1300 case LFUN_FONT_ROMAN: {
1301 LyXFont font(LyXFont::ALL_IGNORE);
1302 font.setFamily(LyXFont::ROMAN_FAMILY);
1303 toggleAndShow(cur, this, font);
1307 case LFUN_FONT_DEFAULT: {
1308 LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
1309 toggleAndShow(cur, this, font);
1313 case LFUN_FONT_UNDERLINE: {
1314 LyXFont font(LyXFont::ALL_IGNORE);
1315 font.setUnderbar(LyXFont::TOGGLE);
1316 toggleAndShow(cur, this, font);
1320 case LFUN_FONT_SIZE: {
1321 LyXFont font(LyXFont::ALL_IGNORE);
1322 font.setLyXSize(cmd.argument);
1323 toggleAndShow(cur, this, font);
1327 case LFUN_LANGUAGE: {
1328 Language const * lang = languages.getLanguage(cmd.argument);
1331 LyXFont font(LyXFont::ALL_IGNORE);
1332 font.setLanguage(lang);
1333 toggleAndShow(cur, this, font);
1338 case LFUN_FONT_FREE_APPLY:
1339 toggleAndShow(cur, this, freefont, toggleall);
1340 cur.message(_("Character set"));
1343 // Set the freefont using the contents of \param data dispatched from
1344 // the frontends and apply it at the current cursor location.
1345 case LFUN_FONT_FREE_UPDATE: {
1348 if (bv_funcs::string2font(cmd.argument, font, toggle)) {
1351 toggleAndShow(cur, this, freefont, toggleall);
1352 cur.message(_("Character set"));
1357 case LFUN_FINISHED_LEFT:
1358 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_LEFT:\n" << cur << endl;
1361 case LFUN_FINISHED_RIGHT:
1362 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_RIGHT:\n" << cur << endl;
1366 case LFUN_FINISHED_UP:
1367 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_UP:\n" << cur << endl;
1371 case LFUN_FINISHED_DOWN:
1372 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_DOWN:\n" << cur << endl;
1376 case LFUN_LAYOUT_PARAGRAPH: {
1378 params2string(cur.paragraph(), data);
1379 data = "show\n" + data;
1380 bv->owner()->getDialogs().show("paragraph", data);
1384 case LFUN_PARAGRAPH_UPDATE: {
1385 if (!bv->owner()->getDialogs().visible("paragraph"))
1388 params2string(cur.paragraph(), data);
1390 // Will the paragraph accept changes from the dialog?
1391 bool const accept = !cur.inset().forceDefaultParagraphs(cur.idx());
1393 data = "update " + convert<string>(accept) + '\n' + data;
1394 bv->owner()->getDialogs().update("paragraph", data);
1398 case LFUN_ACCENT_UMLAUT:
1399 case LFUN_ACCENT_CIRCUMFLEX:
1400 case LFUN_ACCENT_GRAVE:
1401 case LFUN_ACCENT_ACUTE:
1402 case LFUN_ACCENT_TILDE:
1403 case LFUN_ACCENT_CEDILLA:
1404 case LFUN_ACCENT_MACRON:
1405 case LFUN_ACCENT_DOT:
1406 case LFUN_ACCENT_UNDERDOT:
1407 case LFUN_ACCENT_UNDERBAR:
1408 case LFUN_ACCENT_CARON:
1409 case LFUN_ACCENT_SPECIAL_CARON:
1410 case LFUN_ACCENT_BREVE:
1411 case LFUN_ACCENT_TIE:
1412 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1413 case LFUN_ACCENT_CIRCLE:
1414 case LFUN_ACCENT_OGONEK:
1415 bv->owner()->getLyXFunc().handleKeyFunc(cmd.action);
1416 if (!cmd.argument.empty())
1417 bv->owner()->getIntl().getTransManager()
1418 .translateAndInsert(cmd.argument[0], this);
1421 case LFUN_FLOAT_LIST: {
1422 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
1423 if (tclass.floats().typeExist(cmd.argument)) {
1424 // not quite sure if we want this...
1426 cur.clearSelection();
1427 breakParagraph(cur);
1429 if (cur.lastpos() != 0) {
1431 breakParagraph(cur);
1434 setLayout(cur, tclass.defaultLayoutName());
1435 setParagraph(cur, Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
1436 insertInset(cur, new InsetFloatList(cmd.argument));
1439 lyxerr << "Non-existent float type: "
1440 << cmd.argument << endl;
1445 case LFUN_CHANGE_ACCEPT: {
1450 case LFUN_CHANGE_REJECT: {
1455 case LFUN_THESAURUS_ENTRY: {
1456 string arg = cmd.argument;
1458 arg = cur.selectionAsString(false);
1460 if (arg.size() > 100 || arg.empty()) {
1461 // Get word or selection
1462 selectWordWhenUnderCursor(cur, lyx::WHOLE_WORD);
1463 arg = cur.selectionAsString(false);
1466 bv->owner()->getDialogs().show("thesaurus", arg);
1470 case LFUN_PARAGRAPH_PARAMS_APPLY: {
1471 // Given data, an encoding of the ParagraphParameters
1472 // generated in the Paragraph dialog, this function sets
1473 // the current paragraph appropriately.
1474 istringstream is(cmd.argument);
1477 ParagraphParameters params;
1482 params.labelWidthString(),
1484 cur.message(_("Paragraph layout set"));
1489 if (cur.selection()) {
1490 cur.selection() = false;
1493 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
1498 lyxerr[Debug::ACTION]
1499 << BOOST_CURRENT_FUNCTION
1500 << ": Command " << cmd
1501 << " not DISPATCHED by LyXText" << endl;
1506 if (singleParUpdate)
1507 // Inserting characters does not change par height
1508 if (cur.bottom().paragraph().dim().height()
1509 == olddim.height()) {
1510 // if so, update _only_ this paragraph
1511 cur.bv().update(Update::SinglePar |
1513 Update::MultiParSel);
1519 && &oldTopSlice.inset() == &cur.inset()
1520 && oldTopSlice.idx() == cur.idx()
1522 && !cur.selection())
1529 bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
1530 FuncStatus & flag) const
1532 BOOST_ASSERT(cur.text() == this);
1534 LyXFont const & font = real_current_font;
1536 InsetBase::Code code = InsetBase::NO_CODE;
1538 switch (cmd.action) {
1540 case LFUN_DEPTH_DECREMENT:
1541 enable = changeDepthAllowed(cur, DEC_DEPTH);
1544 case LFUN_DEPTH_INCREMENT:
1545 enable = changeDepthAllowed(cur, INC_DEPTH);
1549 flag.setOnOff(cur.paragraph().params().startOfAppendix());
1552 case LFUN_BIBITEM_INSERT:
1553 enable = (cur.paragraph().layout()->labeltype == LABEL_BIBLIO);
1556 case LFUN_DIALOG_SHOW_NEW_INSET:
1557 if (cmd.argument == "bibitem")
1558 code = InsetBase::BIBITEM_CODE;
1559 else if (cmd.argument == "bibtex")
1560 code = InsetBase::BIBTEX_CODE;
1561 else if (cmd.argument == "box")
1562 code = InsetBase::BOX_CODE;
1563 else if (cmd.argument == "branch")
1564 code = InsetBase::BRANCH_CODE;
1565 else if (cmd.argument == "citation")
1566 code = InsetBase::CITE_CODE;
1567 else if (cmd.argument == "ert")
1568 code = InsetBase::ERT_CODE;
1569 else if (cmd.argument == "external")
1570 code = InsetBase::EXTERNAL_CODE;
1571 else if (cmd.argument == "float")
1572 code = InsetBase::FLOAT_CODE;
1573 else if (cmd.argument == "graphics")
1574 code = InsetBase::GRAPHICS_CODE;
1575 else if (cmd.argument == "include")
1576 code = InsetBase::INCLUDE_CODE;
1577 else if (cmd.argument == "index")
1578 code = InsetBase::INDEX_CODE;
1579 else if (cmd.argument == "label")
1580 code = InsetBase::LABEL_CODE;
1581 else if (cmd.argument == "note")
1582 code = InsetBase::NOTE_CODE;
1583 else if (cmd.argument == "ref")
1584 code = InsetBase::REF_CODE;
1585 else if (cmd.argument == "toc")
1586 code = InsetBase::TOC_CODE;
1587 else if (cmd.argument == "url")
1588 code = InsetBase::URL_CODE;
1589 else if (cmd.argument == "vspace")
1590 code = InsetBase::VSPACE_CODE;
1591 else if (cmd.argument == "wrap")
1592 code = InsetBase::WRAP_CODE;
1595 case LFUN_ERT_INSERT:
1596 code = InsetBase::ERT_CODE;
1598 case LFUN_FOOTNOTE_INSERT:
1599 code = InsetBase::FOOT_CODE;
1601 case LFUN_TABULAR_INSERT:
1602 code = InsetBase::TABULAR_CODE;
1604 case LFUN_MARGINALNOTE_INSERT:
1605 code = InsetBase::MARGIN_CODE;
1607 case LFUN_FLOAT_INSERT:
1608 case LFUN_FLOAT_WIDE_INSERT:
1609 code = InsetBase::FLOAT_CODE;
1611 case LFUN_WRAP_INSERT:
1612 code = InsetBase::WRAP_CODE;
1614 case LFUN_FLOAT_LIST:
1615 code = InsetBase::FLOAT_LIST_CODE;
1618 case LFUN_LIST_INSERT:
1619 code = InsetBase::LIST_CODE;
1621 case LFUN_THEOREM_INSERT:
1622 code = InsetBase::THEOREM_CODE;
1625 case LFUN_CAPTION_INSERT:
1626 code = InsetBase::CAPTION_CODE;
1628 case LFUN_NOTE_INSERT:
1629 code = InsetBase::NOTE_CODE;
1631 case LFUN_CHARSTYLE_INSERT:
1632 code = InsetBase::CHARSTYLE_CODE;
1633 if (cur.buffer().params().getLyXTextClass().charstyles().empty())
1636 case LFUN_BOX_INSERT:
1637 code = InsetBase::BOX_CODE;
1639 case LFUN_BRANCH_INSERT:
1640 code = InsetBase::BRANCH_CODE;
1641 if (cur.buffer().getMasterBuffer()->params().branchlist().empty())
1644 case LFUN_LABEL_INSERT:
1645 code = InsetBase::LABEL_CODE;
1647 case LFUN_OPTIONAL_INSERT:
1648 code = InsetBase::OPTARG_CODE;
1649 enable = numberOfOptArgs(cur.paragraph())
1650 < cur.paragraph().layout()->optionalargs;
1652 case LFUN_ENVIRONMENT_INSERT:
1653 code = InsetBase::BOX_CODE;
1655 case LFUN_INDEX_INSERT:
1656 code = InsetBase::INDEX_CODE;
1658 case LFUN_INDEX_PRINT:
1659 code = InsetBase::INDEX_PRINT_CODE;
1661 case LFUN_TOC_INSERT:
1662 code = InsetBase::TOC_CODE;
1664 case LFUN_HTML_INSERT:
1665 case LFUN_URL_INSERT:
1666 code = InsetBase::URL_CODE;
1668 case LFUN_QUOTE_INSERT:
1669 // always allow this, since we will inset a raw quote
1670 // if an inset is not allowed.
1672 case LFUN_HYPHENATION_POINT_INSERT:
1673 case LFUN_LIGATURE_BREAK_INSERT:
1674 case LFUN_HFILL_INSERT:
1675 case LFUN_MENU_SEPARATOR_INSERT:
1676 case LFUN_DOTS_INSERT:
1677 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
1678 code = InsetBase::SPECIALCHAR_CODE;
1680 case LFUN_SPACE_INSERT:
1681 // slight hack: we know this is allowed in math mode
1683 code = InsetBase::SPACE_CODE;
1686 case LFUN_INSET_MODIFY:
1687 // We need to disable this, because we may get called for a
1689 // InsetTabular::getStatus() -> InsetText::getStatus()
1690 // and we don't handle LFUN_INSET_MODIFY.
1694 case LFUN_FONT_EMPH:
1695 flag.setOnOff(font.emph() == LyXFont::ON);
1698 case LFUN_FONT_NOUN:
1699 flag.setOnOff(font.noun() == LyXFont::ON);
1702 case LFUN_FONT_BOLD:
1703 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
1706 case LFUN_FONT_SANS:
1707 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
1710 case LFUN_FONT_ROMAN:
1711 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
1714 case LFUN_FONT_CODE:
1715 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
1720 enable = cur.selection();
1724 enable = lyx::cap::numberOfSelections() > 0;
1727 case LFUN_PARAGRAPH_MOVE_UP: {
1728 enable = cur.pit() > 0 && !cur.selection();
1732 case LFUN_PARAGRAPH_MOVE_DOWN: {
1733 enable = cur.pit() < cur.lastpit() && !cur.selection();
1737 case LFUN_INSET_DISSOLVE: {
1738 enable = &cur.inset() && cur.inTexted();
1742 case LFUN_WORD_DELETE_FORWARD:
1743 case LFUN_WORD_DELETE_BACKWARD:
1744 case LFUN_LINE_DELETE:
1745 case LFUN_WORD_FORWARD:
1746 case LFUN_WORD_BACKWARD:
1747 case LFUN_CHAR_FORWARD:
1748 case LFUN_CHAR_FORWARD_SELECT:
1749 case LFUN_CHAR_BACKWARD:
1750 case LFUN_CHAR_BACKWARD_SELECT:
1752 case LFUN_UP_SELECT:
1754 case LFUN_DOWN_SELECT:
1755 case LFUN_PARAGRAPH_UP_SELECT:
1756 case LFUN_PARAGRAPH_DOWN_SELECT:
1757 case LFUN_SCREEN_UP_SELECT:
1758 case LFUN_SCREEN_DOWN_SELECT:
1759 case LFUN_LINE_BEGIN_SELECT:
1760 case LFUN_LINE_END_SELECT:
1761 case LFUN_WORD_FORWARD_SELECT:
1762 case LFUN_WORD_BACKWARD_SELECT:
1763 case LFUN_WORD_SELECT:
1764 case LFUN_PARAGRAPH_UP:
1765 case LFUN_PARAGRAPH_DOWN:
1766 case LFUN_SCREEN_UP:
1767 case LFUN_SCREEN_DOWN:
1768 case LFUN_LINE_BEGIN:
1770 case LFUN_BREAK_LINE:
1771 case LFUN_CHAR_DELETE_FORWARD:
1772 case LFUN_DELETE_FORWARD_SKIP:
1773 case LFUN_CHAR_DELETE_BACKWARD:
1774 case LFUN_DELETE_BACKWARD_SKIP:
1775 case LFUN_BREAK_PARAGRAPH:
1776 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
1777 case LFUN_BREAK_PARAGRAPH_SKIP:
1778 case LFUN_PARAGRAPH_SPACING:
1779 case LFUN_INSET_INSERT:
1780 case LFUN_WORD_UPCASE:
1781 case LFUN_WORD_LOWCASE:
1782 case LFUN_WORD_CAPITALIZE:
1783 case LFUN_CHARS_TRANSPOSE:
1784 case LFUN_SERVER_GET_XY:
1785 case LFUN_SERVER_SET_XY:
1786 case LFUN_SERVER_GET_FONT:
1787 case LFUN_SERVER_GET_LAYOUT:
1789 case LFUN_CLIPBOARD_PASTE:
1790 case LFUN_PRIMARY_SELECTION_PASTE:
1791 case LFUN_DATE_INSERT:
1792 case LFUN_SELF_INSERT:
1793 case LFUN_LINE_INSERT:
1794 case LFUN_PAGEBREAK_INSERT:
1795 case LFUN_MATH_DISPLAY:
1796 case LFUN_MATH_IMPORT_SELECTION:
1797 case LFUN_MATH_MODE:
1798 case LFUN_MATH_MACRO:
1799 case LFUN_MATH_INSERT:
1800 case LFUN_MATH_MATRIX:
1801 case LFUN_MATH_DELIM:
1802 case LFUN_MATH_BIGDELIM:
1803 case LFUN_MATH_SUBSCRIPT:
1804 case LFUN_MATH_SUPERSCRIPT:
1805 case LFUN_FONT_DEFAULT:
1806 case LFUN_FONT_UNDERLINE:
1807 case LFUN_FONT_SIZE:
1809 case LFUN_FONT_FREE_APPLY:
1810 case LFUN_FONT_FREE_UPDATE:
1811 case LFUN_LAYOUT_PARAGRAPH:
1812 case LFUN_PARAGRAPH_UPDATE:
1813 case LFUN_ACCENT_UMLAUT:
1814 case LFUN_ACCENT_CIRCUMFLEX:
1815 case LFUN_ACCENT_GRAVE:
1816 case LFUN_ACCENT_ACUTE:
1817 case LFUN_ACCENT_TILDE:
1818 case LFUN_ACCENT_CEDILLA:
1819 case LFUN_ACCENT_MACRON:
1820 case LFUN_ACCENT_DOT:
1821 case LFUN_ACCENT_UNDERDOT:
1822 case LFUN_ACCENT_UNDERBAR:
1823 case LFUN_ACCENT_CARON:
1824 case LFUN_ACCENT_SPECIAL_CARON:
1825 case LFUN_ACCENT_BREVE:
1826 case LFUN_ACCENT_TIE:
1827 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1828 case LFUN_ACCENT_CIRCLE:
1829 case LFUN_ACCENT_OGONEK:
1830 case LFUN_CHANGE_ACCEPT:
1831 case LFUN_CHANGE_REJECT:
1832 case LFUN_THESAURUS_ENTRY:
1833 case LFUN_PARAGRAPH_PARAMS_APPLY:
1835 case LFUN_BUFFER_END:
1836 case LFUN_BUFFER_BEGIN:
1837 case LFUN_BUFFER_BEGIN_SELECT:
1838 case LFUN_BUFFER_END_SELECT:
1839 // these are handled in our dispatch()
1847 if (code != InsetBase::NO_CODE
1848 && (cur.empty() || !cur.inset().insetAllowed(code)))
1851 flag.enabled(enable);