3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Asger Alstrup
7 * \author Lars Gullik Bjønnes
8 * \author Alfredo Braunstein
9 * \author Angus Leeming
11 * \author André Pönitz
13 * Full author contact details are available in file CREDITS.
20 #include "BranchList.h"
21 #include "FloatList.h"
22 #include "FuncStatus.h"
24 #include "buffer_funcs.h"
25 #include "bufferparams.h"
26 #include "BufferView.h"
28 #include "coordcache.h"
29 #include "CutAndPaste.h"
31 #include "dispatchresult.h"
33 #include "funcrequest.h"
37 #include "LyXAction.h"
42 #include "paragraph.h"
43 #include "paragraph_funcs.h"
44 #include "ParagraphParameters.h"
47 #include "pariterator.h"
49 #include "frontends/Dialogs.h"
50 #include "frontends/Gui.h"
51 #include "frontends/LyXView.h"
52 #include "frontends/Clipboard.h"
53 #include "frontends/Selection.h"
55 #include "insets/insetcommand.h"
56 #include "insets/insetfloatlist.h"
57 #include "insets/insetnewline.h"
58 #include "insets/insetquotes.h"
59 #include "insets/insetspecialchar.h"
60 #include "insets/insettext.h"
62 #include "support/lstrings.h"
63 #include "support/lyxlib.h"
64 #include "support/convert.h"
65 #include "support/lyxtime.h"
67 #include "mathed/math_hullinset.h"
68 #include "mathed/math_macrotemplate.h"
70 #include <boost/current_function.hpp>
77 using lyx::cap::copySelection;
78 using lyx::cap::cutSelection;
79 using lyx::cap::pasteSelection;
80 using lyx::cap::replaceSelection;
82 using lyx::support::isStrUnsignedInt;
83 using lyx::support::token;
85 using lyx::frontend::Gui;
86 using lyx::frontend::Clipboard;
90 using std::istringstream;
91 using std::ostringstream;
94 extern string current_layout;
100 LyXFont freefont(LyXFont::ALL_IGNORE);
101 bool toggleall = false;
104 void toggleAndShow(LCursor & cur, LyXText * text,
105 LyXFont const & font, bool toggleall = true)
107 text->toggleFree(cur, font, toggleall);
109 if (font.language() != ignore_language ||
110 font.number() != LyXFont::IGNORE) {
111 Paragraph & par = cur.paragraph();
112 text->bidi.computeTables(par, cur.buffer(), cur.textRow());
113 if (cur.boundary() !=
114 text->bidi.isBoundary(cur.buffer(), par,
116 text->real_current_font))
117 text->setCursor(cur, cur.pit(), cur.pos(),
118 false, !cur.boundary());
123 void moveCursor(LCursor & cur, bool selecting)
125 if (selecting || cur.mark())
127 if (!cur.selection())
128 cur.bv().owner()->gui().selection().haveSelection(false);
129 cur.bv().switchKeyMap();
133 void finishChange(LCursor & cur, bool selecting)
136 moveCursor(cur, selecting);
140 void mathDispatch(LCursor & cur, FuncRequest const & cmd, bool display)
143 string sel = cur.selectionAsString(false);
144 //lyxerr << "selection is: '" << sel << "'" << endl;
146 // It may happen that sel is empty but there is a selection
147 replaceSelection(cur);
150 const int old_pos = cur.pos();
151 cur.insert(new MathHullInset("simple"));
152 BOOST_ASSERT(old_pos == cur.pos());
153 cur.nextInset()->edit(cur, true);
154 // don't do that also for LFUN_MATH_MODE
155 // unless you want end up with always changing
156 // to mathrm when opening an inlined inset --
157 // I really hate "LyXfunc overloading"...
159 cur.dispatch(FuncRequest(LFUN_MATH_DISPLAY));
160 // Avoid an unnecessary undo step if cmd.argument
162 if (!cmd.argument.empty())
163 cur.dispatch(FuncRequest(LFUN_MATH_INSERT,
166 // create a macro if we see "\\newcommand"
167 // somewhere, and an ordinary formula
169 istringstream is(sel);
170 if (sel.find("\\newcommand") == string::npos
171 && sel.find("\\def") == string::npos)
173 MathHullInset * formula = new MathHullInset;
176 formula->read(cur.buffer(), lex);
177 if (formula->getType() == "none")
178 // Don't create pseudo formulas if
179 // delimiters are left out
180 formula->mutate("simple");
183 cur.insert(new MathMacroTemplate(is));
185 cur.message(N_("Math editor mode"));
194 string const freefont2string()
197 if (font2string(freefont, toggleall, data))
204 bool LyXText::cursorPrevious(LCursor & cur)
206 pos_type cpos = cur.pos();
207 lyx::pit_type cpar = cur.pit();
209 int x = cur.x_target();
211 bool updated = setCursorFromCoordinates(cur, x, 0);
214 updated |= cursorUp(cur);
216 if (cpar == cur.pit() && cpos == cur.pos()) {
217 // we have a row which is taller than the workarea. The
218 // simplest solution is to move to the previous row instead.
219 updated |= cursorUp(cur);
227 bool LyXText::cursorNext(LCursor & cur)
229 pos_type cpos = cur.pos();
230 lyx::pit_type cpar = cur.pit();
232 int x = cur.x_target();
233 bool updated = setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1);
236 updated |= cursorDown(cur);
238 if (cpar == cur.pit() && cpos == cur.pos()) {
239 // we have a row which is taller than the workarea. The
240 // simplest solution is to move to the next row instead.
241 updated |= cursorDown(cur);
251 void specialChar(LCursor & cur, InsetSpecialChar::Kind kind)
253 lyx::cap::replaceSelection(cur);
254 cur.insert(new InsetSpecialChar(kind));
259 bool doInsertInset(LCursor & cur, LyXText * text,
260 FuncRequest const & cmd, bool edit, bool pastesel)
262 InsetBase * inset = createInset(&cur.bv(), cmd);
268 if (cur.selection()) {
269 cur.bv().owner()->dispatch(FuncRequest(LFUN_CUT));
272 text->insertInset(cur, inset);
275 inset->edit(cur, true);
277 if (gotsel && pastesel)
278 cur.bv().owner()->dispatch(FuncRequest(LFUN_PASTE));
283 void update(LCursor & cur)
285 //we don't call update(true, false) directly to save a metrics call
286 if (cur.bv().fitCursor())
287 cur.bv().update(Update::Force);
294 void LyXText::number(LCursor & cur)
296 LyXFont font(LyXFont::ALL_IGNORE);
297 font.setNumber(LyXFont::TOGGLE);
298 toggleAndShow(cur, this, font);
302 bool LyXText::isRTL(Paragraph const & par) const
304 return par.isRightToLeftPar(bv()->buffer()->params());
308 void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
310 lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl;
312 BOOST_ASSERT(cur.text() == this);
313 BufferView * bv = &cur.bv();
314 CursorSlice oldTopSlice = cur.top();
315 bool oldBoundary = cur.boundary();
316 bool sel = cur.selection();
317 // Signals that, even if needsUpdate == false, an update of the
318 // cursor paragraph is required
319 bool singleParUpdate = lyxaction.funcHasFlag(cmd.action,
320 LyXAction::SingleParUpdate);
321 // Signals that a full-screen update is required
322 bool needsUpdate = !(lyxaction.funcHasFlag(cmd.action,
323 LyXAction::NoUpdate) || singleParUpdate);
324 // Remember the old paragraph metric (_outer_ paragraph!)
325 Dimension olddim = cur.bottom().paragraph().dim();
327 switch (cmd.action) {
329 case LFUN_PARAGRAPH_MOVE_DOWN: {
330 pit_type const pit = cur.pit();
331 recUndo(pit, pit + 1);
333 std::swap(pars_[pit], pars_[pit + 1]);
335 ParIterator begin(cur);
337 ParIterator end = boost::next(ParIterator(cur));
338 updateLabels(cur.buffer(), begin, end);
344 case LFUN_PARAGRAPH_MOVE_UP: {
345 pit_type const pit = cur.pit();
346 recUndo(pit - 1, pit);
348 std::swap(pars_[pit], pars_[pit - 1]);
350 ParIterator end = boost::next(ParIterator(cur));
352 ParIterator begin(cur);
353 updateLabels(cur.buffer(), begin, end);
359 case LFUN_APPENDIX: {
360 Paragraph & par = cur.paragraph();
361 bool start = !par.params().startOfAppendix();
364 #warning The code below only makes sense at top level.
365 // Should LFUN_APPENDIX be restricted to top-level paragraphs?
367 // ensure that we have only one start_of_appendix in this document
368 for (pit_type tmp = 0, end = pars_.size(); tmp != end; ++tmp) {
369 if (pars_[tmp].params().startOfAppendix()) {
371 pars_[tmp].params().startOfAppendix(false);
377 par.params().startOfAppendix(start);
379 // we can set the refreshing parameters now
380 updateLabels(cur.buffer());
384 case LFUN_WORD_DELETE_FORWARD:
385 cur.clearSelection();
386 deleteWordForward(cur);
387 finishChange(cur, false);
390 case LFUN_WORD_DELETE_BACKWARD:
391 cur.clearSelection();
392 deleteWordBackward(cur);
393 finishChange(cur, false);
396 case LFUN_LINE_DELETE:
397 cur.clearSelection();
398 deleteLineForward(cur);
399 finishChange(cur, false);
402 case LFUN_BUFFER_BEGIN:
403 case LFUN_BUFFER_BEGIN_SELECT:
404 cur.selHandle(cmd.action == LFUN_BUFFER_BEGIN_SELECT);
405 if (cur.depth() == 1) {
406 needsUpdate = cursorTop(cur);
412 case LFUN_BUFFER_END:
413 case LFUN_BUFFER_END_SELECT:
414 cur.selHandle(cmd.action == LFUN_BUFFER_END_SELECT);
415 if (cur.depth() == 1) {
416 needsUpdate = cursorBottom(cur);
422 case LFUN_CHAR_FORWARD:
423 case LFUN_CHAR_FORWARD_SELECT:
424 //lyxerr << BOOST_CURRENT_FUNCTION
425 // << " LFUN_CHAR_FORWARD[SEL]:\n" << cur << endl;
426 cur.selHandle(cmd.action == LFUN_CHAR_FORWARD_SELECT);
427 if (isRTL(cur.paragraph()))
428 needsUpdate = cursorLeft(cur);
430 needsUpdate = cursorRight(cur);
432 if (!needsUpdate && oldTopSlice == cur.top()
433 && cur.boundary() == oldBoundary) {
435 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
439 case LFUN_CHAR_BACKWARD:
440 case LFUN_CHAR_BACKWARD_SELECT:
441 //lyxerr << "handle LFUN_CHAR_BACKWARD[_SELECT]:\n" << cur << endl;
442 cur.selHandle(cmd.action == LFUN_CHAR_BACKWARD_SELECT);
443 if (isRTL(cur.paragraph()))
444 needsUpdate = cursorRight(cur);
446 needsUpdate = cursorLeft(cur);
448 if (!needsUpdate && oldTopSlice == cur.top()
449 && cur.boundary() == oldBoundary) {
451 cmd = FuncRequest(LFUN_FINISHED_LEFT);
458 //lyxerr << "handle LFUN_UP[SEL]:\n" << cur << endl;
459 cur.selHandle(cmd.action == LFUN_UP_SELECT);
461 needsUpdate = cursorUp(cur);
462 if (!needsUpdate && oldTopSlice == cur.top()
463 && cur.boundary() == oldBoundary) {
465 cmd = FuncRequest(LFUN_FINISHED_UP);
470 case LFUN_DOWN_SELECT:
472 //lyxerr << "handle LFUN_DOWN[SEL]:\n" << cur << endl;
473 cur.selHandle(cmd.action == LFUN_DOWN_SELECT);
474 needsUpdate = cursorDown(cur);
475 if (!needsUpdate && oldTopSlice == cur.top() &&
476 cur.boundary() == oldBoundary)
479 cmd = FuncRequest(LFUN_FINISHED_DOWN);
483 case LFUN_PARAGRAPH_UP:
484 case LFUN_PARAGRAPH_UP_SELECT:
485 cur.selHandle(cmd.action == LFUN_PARAGRAPH_UP_SELECT);
486 needsUpdate = cursorUpParagraph(cur);
489 case LFUN_PARAGRAPH_DOWN:
490 case LFUN_PARAGRAPH_DOWN_SELECT:
491 cur.selHandle(cmd.action == LFUN_PARAGRAPH_DOWN_SELECT);
492 needsUpdate = cursorDownParagraph(cur);
496 case LFUN_SCREEN_UP_SELECT:
498 cur.selHandle(cmd.action == LFUN_SCREEN_UP_SELECT);
499 if (cur.pit() == 0 && cur.textRow().pos() == 0) {
501 cmd = FuncRequest(LFUN_FINISHED_UP);
503 needsUpdate = cursorPrevious(cur);
507 case LFUN_SCREEN_DOWN:
508 case LFUN_SCREEN_DOWN_SELECT:
510 cur.selHandle(cmd.action == LFUN_SCREEN_DOWN_SELECT);
511 if (cur.pit() == cur.lastpit()
512 && cur.textRow().endpos() == cur.lastpos()) {
514 cmd = FuncRequest(LFUN_FINISHED_DOWN);
516 needsUpdate = cursorNext(cur);
520 case LFUN_LINE_BEGIN:
521 case LFUN_LINE_BEGIN_SELECT:
523 cur.selHandle(cmd.action == LFUN_LINE_BEGIN_SELECT);
524 needsUpdate = cursorHome(cur);
528 case LFUN_LINE_END_SELECT:
530 cur.selHandle(cmd.action == LFUN_LINE_END_SELECT);
531 needsUpdate = cursorEnd(cur);
534 case LFUN_WORD_FORWARD:
535 case LFUN_WORD_FORWARD_SELECT:
536 cur.selHandle(cmd.action == LFUN_WORD_FORWARD_SELECT);
537 if (isRTL(cur.paragraph()))
538 needsUpdate = cursorLeftOneWord(cur);
540 needsUpdate = cursorRightOneWord(cur);
543 case LFUN_WORD_BACKWARD:
544 case LFUN_WORD_BACKWARD_SELECT:
545 cur.selHandle(cmd.action == LFUN_WORD_BACKWARD_SELECT);
546 if (isRTL(cur.paragraph()))
547 needsUpdate = cursorRightOneWord(cur);
549 needsUpdate = cursorLeftOneWord(cur);
552 case LFUN_WORD_SELECT: {
553 selectWord(cur, lyx::WHOLE_WORD);
554 finishChange(cur, true);
558 case LFUN_BREAK_LINE: {
559 // Not allowed by LaTeX (labels or empty par)
560 if (cur.pos() > cur.paragraph().beginOfBody()) {
561 lyx::cap::replaceSelection(cur);
562 cur.insert(new InsetNewline);
564 moveCursor(cur, false);
569 case LFUN_CHAR_DELETE_FORWARD:
570 if (!cur.selection()) {
571 if (cur.pos() == cur.paragraph().size())
572 // Par boundary, force full-screen update
573 singleParUpdate = false;
574 needsUpdate = erase(cur);
576 // It is possible to make it a lot faster still
577 // just comment out the line below...
579 cutSelection(cur, true, false);
580 singleParUpdate = false;
582 moveCursor(cur, false);
585 case LFUN_DELETE_FORWARD_SKIP:
586 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
587 if (!cur.selection()) {
588 if (cur.pos() == cur.lastpos()) {
595 cutSelection(cur, true, false);
600 case LFUN_CHAR_DELETE_BACKWARD:
601 if (!cur.selection()) {
602 if (bv->owner()->getIntl().getTransManager().backspace()) {
603 // Par boundary, full-screen update
605 singleParUpdate = false;
606 needsUpdate = backspace(cur);
608 // It is possible to make it a lot faster still
609 // just comment out the line below...
612 cutSelection(cur, true, false);
613 singleParUpdate = false;
618 case LFUN_DELETE_BACKWARD_SKIP:
619 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
620 if (!cur.selection()) {
624 //CursorSlice cur = cursor();
628 cutSelection(cur, true, false);
632 case LFUN_BREAK_PARAGRAPH:
633 lyx::cap::replaceSelection(cur);
634 breakParagraph(cur, 0);
639 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
640 lyx::cap::replaceSelection(cur);
641 breakParagraph(cur, 1);
646 case LFUN_BREAK_PARAGRAPH_SKIP: {
647 // When at the beginning of a paragraph, remove
648 // indentation. Otherwise, do the same as LFUN_BREAK_PARAGRAPH.
649 lyx::cap::replaceSelection(cur);
651 cur.paragraph().params().labelWidthString(string());
653 breakParagraph(cur, 0);
659 case LFUN_PARAGRAPH_SPACING: {
660 Paragraph & par = cur.paragraph();
661 Spacing::Space cur_spacing = par.params().spacing().getSpace();
662 string cur_value = "1.0";
663 if (cur_spacing == Spacing::Other)
664 cur_value = par.params().spacing().getValueAsString();
666 istringstream is(cmd.argument);
669 Spacing::Space new_spacing = cur_spacing;
670 string new_value = cur_value;
672 lyxerr << "Missing argument to `paragraph-spacing'"
674 } else if (tmp == "single") {
675 new_spacing = Spacing::Single;
676 } else if (tmp == "onehalf") {
677 new_spacing = Spacing::Onehalf;
678 } else if (tmp == "double") {
679 new_spacing = Spacing::Double;
680 } else if (tmp == "other") {
681 new_spacing = Spacing::Other;
682 string tmpval = "0.0";
684 lyxerr << "new_value = " << tmpval << endl;
687 } else if (tmp == "default") {
688 new_spacing = Spacing::Default;
690 lyxerr << _("Unknown spacing argument: ")
691 << cmd.argument << endl;
693 if (cur_spacing != new_spacing || cur_value != new_value)
694 par.params().spacing(Spacing(new_spacing, new_value));
698 case LFUN_INSET_INSERT: {
700 InsetBase * inset = createInset(bv, cmd);
702 insertInset(cur, inset);
708 case LFUN_INSET_DISSOLVE: {
710 cur.selHandle(false);
712 lyx::pos_type spos = cur.pos();
713 lyx::pit_type spit = cur.pit();
714 bool content = false;
715 if (cur.lastpit() != 0 || cur.lastpos() != 0) {
716 setCursor(cur, 0, 0);
718 cur.pit() = cur.lastpit();
719 cur.pos() = cur.lastpos();
726 // store cursor offset
733 lyx::cap::replaceSelection(cur);
734 pasteSelection(cur, 0);
735 cur.clearSelection();
737 cur.pit() = std::min(cur.lastpit(), spit);
738 cur.pos() = std::min(cur.lastpos(), spos);
741 cutSelection(cur, false, false);
746 case LFUN_INSET_SETTINGS:
747 cur.inset().showInsetDialog(bv);
750 case LFUN_NEXT_INSET_TOGGLE: {
751 InsetBase * inset = cur.nextInset();
752 // this is the real function we want to invoke
753 cmd = FuncRequest(LFUN_INSET_TOGGLE);
755 // if there is an inset at cursor, see whether it
758 LCursor tmpcur = cur;
759 tmpcur.pushLeft(*inset);
760 inset->dispatch(tmpcur, cmd);
761 if (tmpcur.result().dispatched()) {
762 cur.clearSelection();
766 // if it did not work, try the underlying inset.
767 if (!cur.result().dispatched())
768 cur.inset().dispatch(cur, cmd);
772 case LFUN_SPACE_INSERT:
773 if (cur.paragraph().layout()->free_spacing)
774 insertChar(cur, ' ');
776 doInsertInset(cur, this, cmd, false, false);
779 moveCursor(cur, false);
782 case LFUN_HYPHENATION_POINT_INSERT:
783 specialChar(cur, InsetSpecialChar::HYPHENATION);
786 case LFUN_LIGATURE_BREAK_INSERT:
787 specialChar(cur, InsetSpecialChar::LIGATURE_BREAK);
790 case LFUN_DOTS_INSERT:
791 specialChar(cur, InsetSpecialChar::LDOTS);
794 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
795 specialChar(cur, InsetSpecialChar::END_OF_SENTENCE);
798 case LFUN_MENU_SEPARATOR_INSERT:
799 specialChar(cur, InsetSpecialChar::MENU_SEPARATOR);
802 case LFUN_WORD_UPCASE:
803 changeCase(cur, LyXText::text_uppercase);
806 case LFUN_WORD_LOWCASE:
807 changeCase(cur, LyXText::text_lowercase);
810 case LFUN_WORD_CAPITALIZE:
811 changeCase(cur, LyXText::text_capitalization);
814 case LFUN_CHARS_TRANSPOSE:
819 cur.message(_("Paste"));
820 lyx::cap::replaceSelection(cur);
821 if (isStrUnsignedInt(cmd.argument))
822 pasteSelection(cur, convert<unsigned int>(cmd.argument));
824 pasteSelection(cur, 0);
825 cur.clearSelection(); // bug 393
831 cutSelection(cur, true, true);
832 cur.message(_("Cut"));
837 cur.message(_("Copy"));
840 case LFUN_SERVER_GET_XY:
841 cur.message(convert<string>(cursorX(cur.top(), cur.boundary())) + ' '
842 + convert<string>(cursorY(cur.top(), cur.boundary())));
845 case LFUN_SERVER_SET_XY: {
848 istringstream is(cmd.argument);
851 lyxerr << "SETXY: Could not parse coordinates in '"
852 << cmd.argument << std::endl;
854 setCursorFromCoordinates(cur, x, y);
858 case LFUN_SERVER_GET_FONT:
859 if (current_font.shape() == LyXFont::ITALIC_SHAPE)
861 else if (current_font.shape() == LyXFont::SMALLCAPS_SHAPE)
867 case LFUN_SERVER_GET_LAYOUT:
868 cur.message(cur.paragraph().layout()->name());
872 lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) "
873 << cmd.argument << endl;
875 // This is not the good solution to the empty argument
876 // problem, but it will hopefully suffice for 1.2.0.
877 // The correct solution would be to augument the
878 // function list/array with information about what
879 // functions needs arguments and their type.
880 if (cmd.argument.empty()) {
881 cur.errorMessage(_("LyX function 'layout' needs an argument."));
885 // Derive layout number from given argument (string)
886 // and current buffer's textclass (number)
887 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
888 bool hasLayout = tclass.hasLayout(cmd.argument);
889 string layout = cmd.argument;
891 // If the entry is obsolete, use the new one instead.
893 string const & obs = tclass[layout]->obsoleted_by();
899 cur.errorMessage(string(N_("Layout ")) + cmd.argument +
904 bool change_layout = (current_layout != layout);
906 if (!change_layout && cur.selection() &&
907 cur.selBegin().pit() != cur.selEnd().pit())
909 pit_type spit = cur.selBegin().pit();
910 pit_type epit = cur.selEnd().pit() + 1;
911 while (spit != epit) {
912 if (pars_[spit].layout()->name() != current_layout) {
913 change_layout = true;
921 current_layout = layout;
922 setLayout(cur, layout);
923 bv->owner()->setLayout(layout);
929 case LFUN_CLIPBOARD_PASTE: {
930 cur.clearSelection();
931 string const clip = bv->owner()->gui().clipboard().get();
934 if (cmd.argument == "paragraph")
935 insertStringAsParagraphs(cur, clip);
937 insertStringAsLines(cur, clip);
942 case LFUN_PRIMARY_SELECTION_PASTE: {
943 cur.clearSelection();
944 string const clip = bv->owner()->gui().selection().get();
947 if (cmd.argument == "paragraph")
948 insertStringAsParagraphs(cur, clip);
950 insertStringAsLines(cur, clip);
955 case LFUN_QUOTE_INSERT: {
956 lyx::cap::replaceSelection(cur);
957 Paragraph & par = cur.paragraph();
958 lyx::pos_type pos = cur.pos();
962 else if (cur.prevInset() && cur.prevInset()->isSpace())
965 c = par.getChar(pos - 1);
967 LyXLayout_ptr const & style = par.layout();
969 BufferParams const & bufparams = bv->buffer()->params();
970 if (!style->pass_thru
971 && par.getFontSettings(bufparams, pos).language()->lang() != "hebrew") {
972 string arg = cmd.argument;
974 cur.insert(new InsetQuotes(c,
975 bufparams.quotes_language,
976 InsetQuotes::SingleQ));
978 cur.insert(new InsetQuotes(c,
979 bufparams.quotes_language,
980 InsetQuotes::DoubleQ));
984 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT, "\""));
988 case LFUN_DATE_INSERT:
989 if (cmd.argument.empty())
990 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT,
991 lyx::formatted_time(lyx::current_time())));
993 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT,
994 lyx::formatted_time(lyx::current_time(), cmd.argument)));
997 case LFUN_MOUSE_TRIPLE:
998 if (cmd.button() == mouse_button::button1) {
1004 bv->owner()->gui().selection().haveSelection(cur.selection());
1008 case LFUN_MOUSE_DOUBLE:
1009 if (cmd.button() == mouse_button::button1) {
1010 selectWord(cur, lyx::WHOLE_WORD_STRICT);
1012 bv->owner()->gui().selection().haveSelection(cur.selection());
1016 // Single-click on work area
1017 case LFUN_MOUSE_PRESS: {
1018 // Right click on a footnote flag opens float menu
1019 if (cmd.button() == mouse_button::button3)
1020 cur.clearSelection();
1022 // Middle button press pastes if we have a selection
1023 // We do this here as if the selection was inside an inset
1024 // it could get cleared on the unlocking of the inset so
1025 // we have to check this first
1026 bool paste_internally = false;
1027 if (cmd.button() == mouse_button::button2 && cur.selection()) {
1028 bv->owner()->dispatch(FuncRequest(LFUN_COPY));
1029 paste_internally = true;
1032 bv->mouseSetCursor(cur);
1034 // Insert primary selection with middle mouse
1035 // if there is a local selection in the current buffer,
1037 if (cmd.button() == mouse_button::button2) {
1038 if (paste_internally)
1039 bv->owner()->dispatch(FuncRequest(LFUN_PASTE));
1041 bv->owner()->dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph"));
1047 case LFUN_MOUSE_MOTION: {
1048 // Only use motion with button 1
1049 //if (cmd.button() != mouse_button::button1)
1052 // ignore motions deeper nested than the real anchor
1053 LCursor & bvcur = cur.bv().cursor();
1054 if (bvcur.anchor_.hasPart(cur)) {
1055 CursorSlice old = bvcur.top();
1057 int const wh = bv->workHeight();
1058 int const y = std::max(0, std::min(wh - 1, cmd.y));
1060 setCursorFromCoordinates(cur, cmd.x, y);
1061 cur.x_target() = cmd.x;
1066 // This is to allow jumping over large insets
1067 if (cur.top() == old) {
1074 if (cur.top() == old)
1077 // don't set anchor_
1078 bvcur.setCursor(cur);
1079 bvcur.selection() = true;
1080 //lyxerr << "MOTION: " << bv->cursor() << endl;
1088 case LFUN_MOUSE_RELEASE: {
1089 if (cmd.button() == mouse_button::button2)
1093 if (cmd.button() == mouse_button::button1)
1094 bv->owner()->gui().selection().haveSelection(cur.selection());
1097 bv->owner()->updateMenubar();
1098 bv->owner()->updateToolbars();
1102 case LFUN_SELF_INSERT: {
1103 if (cmd.argument.empty())
1106 // Automatically delete the currently selected
1107 // text and replace it with what is being
1108 // typed in now. Depends on lyxrc settings
1109 // "auto_region_delete", which defaults to
1112 if (lyxrc.auto_region_delete) {
1113 if (cur.selection())
1114 cutSelection(cur, false, false);
1115 bv->owner()->gui().selection().haveSelection(false);
1118 cur.clearSelection();
1119 LyXFont const old_font = real_current_font;
1121 string::const_iterator cit = cmd.argument.begin();
1122 string::const_iterator end = cmd.argument.end();
1123 for (; cit != end; ++cit)
1124 bv->owner()->getIntl().getTransManager().
1125 translateAndInsert(*cit, this);
1128 moveCursor(cur, false);
1132 case LFUN_URL_INSERT: {
1133 InsetCommandParams p("url");
1134 string const data = InsetCommandMailer::params2string("url", p);
1135 bv->owner()->getDialogs().show("url", data, 0);
1139 case LFUN_HTML_INSERT: {
1140 InsetCommandParams p("htmlurl");
1141 string const data = InsetCommandMailer::params2string("url", p);
1142 bv->owner()->getDialogs().show("url", data, 0);
1146 case LFUN_LABEL_INSERT: {
1147 // Try to generate a valid label
1148 string const contents = cmd.argument.empty() ?
1149 cur.getPossibleLabel() : cmd.argument;
1151 InsetCommandParams p("label", contents);
1152 string const data = InsetCommandMailer::params2string("label", p);
1154 if (cmd.argument.empty()) {
1155 bv->owner()->getDialogs().show("label", data, 0);
1157 FuncRequest fr(LFUN_INSET_INSERT, data);
1165 case LFUN_LIST_INSERT:
1166 case LFUN_THEOREM_INSERT:
1167 case LFUN_CAPTION_INSERT:
1169 case LFUN_NOTE_INSERT:
1170 case LFUN_CHARSTYLE_INSERT:
1171 case LFUN_BOX_INSERT:
1172 case LFUN_BRANCH_INSERT:
1173 case LFUN_BIBITEM_INSERT:
1174 case LFUN_ERT_INSERT:
1175 case LFUN_FOOTNOTE_INSERT:
1176 case LFUN_MARGINALNOTE_INSERT:
1177 case LFUN_OPTIONAL_INSERT:
1178 case LFUN_ENVIRONMENT_INSERT:
1179 // Open the inset, and move the current selection
1181 doInsertInset(cur, this, cmd, true, true);
1185 case LFUN_TABULAR_INSERT:
1186 // if there were no arguments, just open the dialog
1187 if (doInsertInset(cur, this, cmd, false, true))
1190 bv->owner()->getDialogs().show("tabularcreate");
1194 case LFUN_FLOAT_INSERT:
1195 case LFUN_FLOAT_WIDE_INSERT:
1196 case LFUN_WRAP_INSERT:
1197 doInsertInset(cur, this, cmd, true, true);
1199 // FIXME: the "Caption" name should not be hardcoded,
1200 // but given by the float definition.
1201 cur.dispatch(FuncRequest(LFUN_LAYOUT, "Caption"));
1204 case LFUN_INDEX_INSERT: {
1205 InsetBase * inset = createInset(&cur.bv(), cmd);
1210 cur.clearSelection();
1211 insertInset(cur, inset);
1212 inset->edit(cur, true);
1217 case LFUN_INDEX_PRINT:
1218 case LFUN_TOC_INSERT:
1219 case LFUN_HFILL_INSERT:
1220 case LFUN_LINE_INSERT:
1221 case LFUN_PAGEBREAK_INSERT:
1223 doInsertInset(cur, this, cmd, false, false);
1227 case LFUN_DEPTH_DECREMENT:
1228 changeDepth(cur, DEC_DEPTH);
1231 case LFUN_DEPTH_INCREMENT:
1232 changeDepth(cur, INC_DEPTH);
1235 case LFUN_MATH_DISPLAY:
1236 mathDispatch(cur, cmd, true);
1239 case LFUN_MATH_IMPORT_SELECTION:
1240 case LFUN_MATH_MODE:
1241 if (cmd.argument == "on")
1242 // don't pass "on" as argument
1243 mathDispatch(cur, FuncRequest(LFUN_MATH_MODE), false);
1245 mathDispatch(cur, cmd, false);
1248 case LFUN_MATH_MACRO:
1249 if (cmd.argument.empty())
1250 cur.errorMessage(N_("Missing argument"));
1252 string s = cmd.argument;
1253 string const s1 = token(s, ' ', 1);
1254 int const nargs = s1.empty() ? 0 : convert<int>(s1);
1255 string const s2 = token(s, ' ', 2);
1256 string const type = s2.empty() ? "newcommand" : s2;
1257 cur.insert(new MathMacroTemplate(token(s, ' ', 0), nargs, type));
1258 //cur.nextInset()->edit(cur, true);
1262 // passthrough hat and underscore outside mathed:
1263 case LFUN_MATH_SUBSCRIPT:
1264 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "_"), false);
1266 case LFUN_MATH_SUPERSCRIPT:
1267 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "^"), false);
1270 case LFUN_MATH_INSERT:
1271 case LFUN_MATH_MATRIX:
1272 case LFUN_MATH_DELIM:
1273 case LFUN_MATH_BIGDELIM: {
1274 cur.insert(new MathHullInset("simple"));
1275 cur.dispatch(FuncRequest(LFUN_CHAR_FORWARD));
1280 case LFUN_FONT_EMPH: {
1281 LyXFont font(LyXFont::ALL_IGNORE);
1282 font.setEmph(LyXFont::TOGGLE);
1283 toggleAndShow(cur, this, font);
1287 case LFUN_FONT_BOLD: {
1288 LyXFont font(LyXFont::ALL_IGNORE);
1289 font.setSeries(LyXFont::BOLD_SERIES);
1290 toggleAndShow(cur, this, font);
1294 case LFUN_FONT_NOUN: {
1295 LyXFont font(LyXFont::ALL_IGNORE);
1296 font.setNoun(LyXFont::TOGGLE);
1297 toggleAndShow(cur, this, font);
1301 case LFUN_FONT_CODE: {
1302 LyXFont font(LyXFont::ALL_IGNORE);
1303 font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
1304 toggleAndShow(cur, this, font);
1308 case LFUN_FONT_SANS: {
1309 LyXFont font(LyXFont::ALL_IGNORE);
1310 font.setFamily(LyXFont::SANS_FAMILY);
1311 toggleAndShow(cur, this, font);
1315 case LFUN_FONT_ROMAN: {
1316 LyXFont font(LyXFont::ALL_IGNORE);
1317 font.setFamily(LyXFont::ROMAN_FAMILY);
1318 toggleAndShow(cur, this, font);
1322 case LFUN_FONT_DEFAULT: {
1323 LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
1324 toggleAndShow(cur, this, font);
1328 case LFUN_FONT_UNDERLINE: {
1329 LyXFont font(LyXFont::ALL_IGNORE);
1330 font.setUnderbar(LyXFont::TOGGLE);
1331 toggleAndShow(cur, this, font);
1335 case LFUN_FONT_SIZE: {
1336 LyXFont font(LyXFont::ALL_IGNORE);
1337 font.setLyXSize(cmd.argument);
1338 toggleAndShow(cur, this, font);
1342 case LFUN_LANGUAGE: {
1343 Language const * lang = languages.getLanguage(cmd.argument);
1346 LyXFont font(LyXFont::ALL_IGNORE);
1347 font.setLanguage(lang);
1348 toggleAndShow(cur, this, font);
1353 case LFUN_FONT_FREE_APPLY:
1354 toggleAndShow(cur, this, freefont, toggleall);
1355 cur.message(_("Character set"));
1358 // Set the freefont using the contents of \param data dispatched from
1359 // the frontends and apply it at the current cursor location.
1360 case LFUN_FONT_FREE_UPDATE: {
1363 if (bv_funcs::string2font(cmd.argument, font, toggle)) {
1366 toggleAndShow(cur, this, freefont, toggleall);
1367 cur.message(_("Character set"));
1372 case LFUN_FINISHED_LEFT:
1373 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_LEFT:\n" << cur << endl;
1376 case LFUN_FINISHED_RIGHT:
1377 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_RIGHT:\n" << cur << endl;
1381 case LFUN_FINISHED_UP:
1382 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_UP:\n" << cur << endl;
1386 case LFUN_FINISHED_DOWN:
1387 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_DOWN:\n" << cur << endl;
1391 case LFUN_LAYOUT_PARAGRAPH: {
1393 params2string(cur.paragraph(), data);
1394 data = "show\n" + data;
1395 bv->owner()->getDialogs().show("paragraph", data);
1399 case LFUN_PARAGRAPH_UPDATE: {
1400 if (!bv->owner()->getDialogs().visible("paragraph"))
1403 params2string(cur.paragraph(), data);
1405 // Will the paragraph accept changes from the dialog?
1406 bool const accept = !cur.inset().forceDefaultParagraphs(cur.idx());
1408 data = "update " + convert<string>(accept) + '\n' + data;
1409 bv->owner()->getDialogs().update("paragraph", data);
1413 case LFUN_ACCENT_UMLAUT:
1414 case LFUN_ACCENT_CIRCUMFLEX:
1415 case LFUN_ACCENT_GRAVE:
1416 case LFUN_ACCENT_ACUTE:
1417 case LFUN_ACCENT_TILDE:
1418 case LFUN_ACCENT_CEDILLA:
1419 case LFUN_ACCENT_MACRON:
1420 case LFUN_ACCENT_DOT:
1421 case LFUN_ACCENT_UNDERDOT:
1422 case LFUN_ACCENT_UNDERBAR:
1423 case LFUN_ACCENT_CARON:
1424 case LFUN_ACCENT_SPECIAL_CARON:
1425 case LFUN_ACCENT_BREVE:
1426 case LFUN_ACCENT_TIE:
1427 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1428 case LFUN_ACCENT_CIRCLE:
1429 case LFUN_ACCENT_OGONEK:
1430 bv->owner()->getLyXFunc().handleKeyFunc(cmd.action);
1431 if (!cmd.argument.empty())
1432 bv->owner()->getIntl().getTransManager()
1433 .translateAndInsert(cmd.argument[0], this);
1436 case LFUN_FLOAT_LIST: {
1437 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
1438 if (tclass.floats().typeExist(cmd.argument)) {
1439 // not quite sure if we want this...
1441 cur.clearSelection();
1442 breakParagraph(cur);
1444 if (cur.lastpos() != 0) {
1446 breakParagraph(cur);
1449 setLayout(cur, tclass.defaultLayoutName());
1450 setParagraph(cur, Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
1451 insertInset(cur, new InsetFloatList(cmd.argument));
1454 lyxerr << "Non-existent float type: "
1455 << cmd.argument << endl;
1460 case LFUN_CHANGE_ACCEPT: {
1465 case LFUN_CHANGE_REJECT: {
1470 case LFUN_THESAURUS_ENTRY: {
1471 string arg = cmd.argument;
1473 arg = cur.selectionAsString(false);
1475 if (arg.size() > 100 || arg.empty()) {
1476 // Get word or selection
1477 selectWordWhenUnderCursor(cur, lyx::WHOLE_WORD);
1478 arg = cur.selectionAsString(false);
1481 bv->owner()->getDialogs().show("thesaurus", arg);
1485 case LFUN_PARAGRAPH_PARAMS_APPLY: {
1486 // Given data, an encoding of the ParagraphParameters
1487 // generated in the Paragraph dialog, this function sets
1488 // the current paragraph appropriately.
1489 istringstream is(cmd.argument);
1492 ParagraphParameters params;
1497 params.labelWidthString(),
1499 cur.message(_("Paragraph layout set"));
1504 if (cur.selection()) {
1505 cur.selection() = false;
1508 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
1513 lyxerr[Debug::ACTION]
1514 << BOOST_CURRENT_FUNCTION
1515 << ": Command " << cmd
1516 << " not DISPATCHED by LyXText" << endl;
1521 if (singleParUpdate)
1522 // Inserting characters does not change par height
1523 if (cur.bottom().paragraph().dim().height()
1524 == olddim.height()) {
1525 // if so, update _only_ this paragraph
1526 cur.bv().update(Update::SinglePar |
1528 Update::MultiParSel);
1534 && &oldTopSlice.inset() == &cur.inset()
1535 && oldTopSlice.idx() == cur.idx()
1537 && !cur.selection())
1544 bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
1545 FuncStatus & flag) const
1547 BOOST_ASSERT(cur.text() == this);
1549 LyXFont const & font = real_current_font;
1551 InsetBase::Code code = InsetBase::NO_CODE;
1553 switch (cmd.action) {
1555 case LFUN_DEPTH_DECREMENT:
1556 enable = changeDepthAllowed(cur, DEC_DEPTH);
1559 case LFUN_DEPTH_INCREMENT:
1560 enable = changeDepthAllowed(cur, INC_DEPTH);
1564 flag.setOnOff(cur.paragraph().params().startOfAppendix());
1567 case LFUN_BIBITEM_INSERT:
1568 enable = (cur.paragraph().layout()->labeltype == LABEL_BIBLIO);
1571 case LFUN_DIALOG_SHOW_NEW_INSET:
1572 if (cmd.argument == "bibitem")
1573 code = InsetBase::BIBITEM_CODE;
1574 else if (cmd.argument == "bibtex")
1575 code = InsetBase::BIBTEX_CODE;
1576 else if (cmd.argument == "box")
1577 code = InsetBase::BOX_CODE;
1578 else if (cmd.argument == "branch")
1579 code = InsetBase::BRANCH_CODE;
1580 else if (cmd.argument == "citation")
1581 code = InsetBase::CITE_CODE;
1582 else if (cmd.argument == "ert")
1583 code = InsetBase::ERT_CODE;
1584 else if (cmd.argument == "external")
1585 code = InsetBase::EXTERNAL_CODE;
1586 else if (cmd.argument == "float")
1587 code = InsetBase::FLOAT_CODE;
1588 else if (cmd.argument == "graphics")
1589 code = InsetBase::GRAPHICS_CODE;
1590 else if (cmd.argument == "include")
1591 code = InsetBase::INCLUDE_CODE;
1592 else if (cmd.argument == "index")
1593 code = InsetBase::INDEX_CODE;
1594 else if (cmd.argument == "label")
1595 code = InsetBase::LABEL_CODE;
1596 else if (cmd.argument == "note")
1597 code = InsetBase::NOTE_CODE;
1598 else if (cmd.argument == "ref")
1599 code = InsetBase::REF_CODE;
1600 else if (cmd.argument == "toc")
1601 code = InsetBase::TOC_CODE;
1602 else if (cmd.argument == "url")
1603 code = InsetBase::URL_CODE;
1604 else if (cmd.argument == "vspace")
1605 code = InsetBase::VSPACE_CODE;
1606 else if (cmd.argument == "wrap")
1607 code = InsetBase::WRAP_CODE;
1610 case LFUN_ERT_INSERT:
1611 code = InsetBase::ERT_CODE;
1613 case LFUN_FOOTNOTE_INSERT:
1614 code = InsetBase::FOOT_CODE;
1616 case LFUN_TABULAR_INSERT:
1617 code = InsetBase::TABULAR_CODE;
1619 case LFUN_MARGINALNOTE_INSERT:
1620 code = InsetBase::MARGIN_CODE;
1622 case LFUN_FLOAT_INSERT:
1623 case LFUN_FLOAT_WIDE_INSERT:
1624 code = InsetBase::FLOAT_CODE;
1626 case LFUN_WRAP_INSERT:
1627 code = InsetBase::WRAP_CODE;
1629 case LFUN_FLOAT_LIST:
1630 code = InsetBase::FLOAT_LIST_CODE;
1633 case LFUN_LIST_INSERT:
1634 code = InsetBase::LIST_CODE;
1636 case LFUN_THEOREM_INSERT:
1637 code = InsetBase::THEOREM_CODE;
1640 case LFUN_CAPTION_INSERT:
1641 code = InsetBase::CAPTION_CODE;
1643 case LFUN_NOTE_INSERT:
1644 code = InsetBase::NOTE_CODE;
1646 case LFUN_CHARSTYLE_INSERT:
1647 code = InsetBase::CHARSTYLE_CODE;
1648 if (cur.buffer().params().getLyXTextClass().charstyles().empty())
1651 case LFUN_BOX_INSERT:
1652 code = InsetBase::BOX_CODE;
1654 case LFUN_BRANCH_INSERT:
1655 code = InsetBase::BRANCH_CODE;
1656 if (cur.buffer().getMasterBuffer()->params().branchlist().empty())
1659 case LFUN_LABEL_INSERT:
1660 code = InsetBase::LABEL_CODE;
1662 case LFUN_OPTIONAL_INSERT:
1663 code = InsetBase::OPTARG_CODE;
1664 enable = numberOfOptArgs(cur.paragraph())
1665 < cur.paragraph().layout()->optionalargs;
1667 case LFUN_ENVIRONMENT_INSERT:
1668 code = InsetBase::BOX_CODE;
1670 case LFUN_INDEX_INSERT:
1671 code = InsetBase::INDEX_CODE;
1673 case LFUN_INDEX_PRINT:
1674 code = InsetBase::INDEX_PRINT_CODE;
1676 case LFUN_TOC_INSERT:
1677 code = InsetBase::TOC_CODE;
1679 case LFUN_HTML_INSERT:
1680 case LFUN_URL_INSERT:
1681 code = InsetBase::URL_CODE;
1683 case LFUN_QUOTE_INSERT:
1684 // always allow this, since we will inset a raw quote
1685 // if an inset is not allowed.
1687 case LFUN_HYPHENATION_POINT_INSERT:
1688 case LFUN_LIGATURE_BREAK_INSERT:
1689 case LFUN_HFILL_INSERT:
1690 case LFUN_MENU_SEPARATOR_INSERT:
1691 case LFUN_DOTS_INSERT:
1692 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
1693 code = InsetBase::SPECIALCHAR_CODE;
1695 case LFUN_SPACE_INSERT:
1696 // slight hack: we know this is allowed in math mode
1698 code = InsetBase::SPACE_CODE;
1701 case LFUN_INSET_MODIFY:
1702 // We need to disable this, because we may get called for a
1704 // InsetTabular::getStatus() -> InsetText::getStatus()
1705 // and we don't handle LFUN_INSET_MODIFY.
1709 case LFUN_FONT_EMPH:
1710 flag.setOnOff(font.emph() == LyXFont::ON);
1713 case LFUN_FONT_NOUN:
1714 flag.setOnOff(font.noun() == LyXFont::ON);
1717 case LFUN_FONT_BOLD:
1718 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
1721 case LFUN_FONT_SANS:
1722 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
1725 case LFUN_FONT_ROMAN:
1726 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
1729 case LFUN_FONT_CODE:
1730 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
1735 enable = cur.selection();
1739 enable = lyx::cap::numberOfSelections() > 0;
1742 case LFUN_PARAGRAPH_MOVE_UP: {
1743 enable = cur.pit() > 0 && !cur.selection();
1747 case LFUN_PARAGRAPH_MOVE_DOWN: {
1748 enable = cur.pit() < cur.lastpit() && !cur.selection();
1752 case LFUN_INSET_DISSOLVE: {
1753 enable = &cur.inset() && cur.inTexted();
1757 case LFUN_WORD_DELETE_FORWARD:
1758 case LFUN_WORD_DELETE_BACKWARD:
1759 case LFUN_LINE_DELETE:
1760 case LFUN_WORD_FORWARD:
1761 case LFUN_WORD_BACKWARD:
1762 case LFUN_CHAR_FORWARD:
1763 case LFUN_CHAR_FORWARD_SELECT:
1764 case LFUN_CHAR_BACKWARD:
1765 case LFUN_CHAR_BACKWARD_SELECT:
1767 case LFUN_UP_SELECT:
1769 case LFUN_DOWN_SELECT:
1770 case LFUN_PARAGRAPH_UP_SELECT:
1771 case LFUN_PARAGRAPH_DOWN_SELECT:
1772 case LFUN_SCREEN_UP_SELECT:
1773 case LFUN_SCREEN_DOWN_SELECT:
1774 case LFUN_LINE_BEGIN_SELECT:
1775 case LFUN_LINE_END_SELECT:
1776 case LFUN_WORD_FORWARD_SELECT:
1777 case LFUN_WORD_BACKWARD_SELECT:
1778 case LFUN_WORD_SELECT:
1779 case LFUN_PARAGRAPH_UP:
1780 case LFUN_PARAGRAPH_DOWN:
1781 case LFUN_SCREEN_UP:
1782 case LFUN_SCREEN_DOWN:
1783 case LFUN_LINE_BEGIN:
1785 case LFUN_BREAK_LINE:
1786 case LFUN_CHAR_DELETE_FORWARD:
1787 case LFUN_DELETE_FORWARD_SKIP:
1788 case LFUN_CHAR_DELETE_BACKWARD:
1789 case LFUN_DELETE_BACKWARD_SKIP:
1790 case LFUN_BREAK_PARAGRAPH:
1791 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
1792 case LFUN_BREAK_PARAGRAPH_SKIP:
1793 case LFUN_PARAGRAPH_SPACING:
1794 case LFUN_INSET_INSERT:
1795 case LFUN_NEXT_INSET_TOGGLE:
1796 case LFUN_WORD_UPCASE:
1797 case LFUN_WORD_LOWCASE:
1798 case LFUN_WORD_CAPITALIZE:
1799 case LFUN_CHARS_TRANSPOSE:
1800 case LFUN_SERVER_GET_XY:
1801 case LFUN_SERVER_SET_XY:
1802 case LFUN_SERVER_GET_FONT:
1803 case LFUN_SERVER_GET_LAYOUT:
1805 case LFUN_CLIPBOARD_PASTE:
1806 case LFUN_PRIMARY_SELECTION_PASTE:
1807 case LFUN_DATE_INSERT:
1808 case LFUN_SELF_INSERT:
1809 case LFUN_LINE_INSERT:
1810 case LFUN_PAGEBREAK_INSERT:
1811 case LFUN_MATH_DISPLAY:
1812 case LFUN_MATH_IMPORT_SELECTION:
1813 case LFUN_MATH_MODE:
1814 case LFUN_MATH_MACRO:
1815 case LFUN_MATH_INSERT:
1816 case LFUN_MATH_MATRIX:
1817 case LFUN_MATH_DELIM:
1818 case LFUN_MATH_BIGDELIM:
1819 case LFUN_MATH_SUBSCRIPT:
1820 case LFUN_MATH_SUPERSCRIPT:
1821 case LFUN_FONT_DEFAULT:
1822 case LFUN_FONT_UNDERLINE:
1823 case LFUN_FONT_SIZE:
1825 case LFUN_FONT_FREE_APPLY:
1826 case LFUN_FONT_FREE_UPDATE:
1827 case LFUN_LAYOUT_PARAGRAPH:
1828 case LFUN_PARAGRAPH_UPDATE:
1829 case LFUN_ACCENT_UMLAUT:
1830 case LFUN_ACCENT_CIRCUMFLEX:
1831 case LFUN_ACCENT_GRAVE:
1832 case LFUN_ACCENT_ACUTE:
1833 case LFUN_ACCENT_TILDE:
1834 case LFUN_ACCENT_CEDILLA:
1835 case LFUN_ACCENT_MACRON:
1836 case LFUN_ACCENT_DOT:
1837 case LFUN_ACCENT_UNDERDOT:
1838 case LFUN_ACCENT_UNDERBAR:
1839 case LFUN_ACCENT_CARON:
1840 case LFUN_ACCENT_SPECIAL_CARON:
1841 case LFUN_ACCENT_BREVE:
1842 case LFUN_ACCENT_TIE:
1843 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1844 case LFUN_ACCENT_CIRCLE:
1845 case LFUN_ACCENT_OGONEK:
1846 case LFUN_CHANGE_ACCEPT:
1847 case LFUN_CHANGE_REJECT:
1848 case LFUN_THESAURUS_ENTRY:
1849 case LFUN_PARAGRAPH_PARAMS_APPLY:
1851 case LFUN_BUFFER_END:
1852 case LFUN_BUFFER_BEGIN:
1853 case LFUN_BUFFER_BEGIN_SELECT:
1854 case LFUN_BUFFER_END_SELECT:
1855 // these are handled in our dispatch()
1863 if (code != InsetBase::NO_CODE
1864 && (cur.empty() || !cur.inset().insetAllowed(code)))
1867 flag.enabled(enable);