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"
68 #include "mathed/InsetMathHull.h"
69 #include "mathed/MathMacroTemplate.h"
71 #include <boost/current_function.hpp>
80 using lyx::cap::copySelection;
81 using lyx::cap::cutSelection;
82 using lyx::cap::pasteSelection;
83 using lyx::cap::replaceSelection;
85 using lyx::support::isStrUnsignedInt;
86 using lyx::support::token;
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 = lyx::to_utf8(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 InsetMathHull(hullSimple));
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 InsetMathHull * formula = new InsetMathHull;
176 formula->read(cur.buffer(), lex);
177 if (formula->getType() == hullNone)
178 // Don't create pseudo formulas if
179 // delimiters are left out
180 formula->mutate(hullSimple);
183 cur.insert(new MathMacroTemplate(is));
185 cur.message(lyx::from_utf8(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));
279 // reset first par to default
280 if (cur.lastpit() != 0 || cur.lastpos() != 0) {
281 LyXLayout_ptr const layout =
282 cur.buffer().params().getLyXTextClass().defaultLayout();
283 cur.text()->paragraphs().begin()->layout(layout);
290 void update(LCursor & cur)
292 //we don't call update(true, false) directly to save a metrics call
293 if (cur.bv().fitCursor())
294 cur.bv().update(Update::Force);
301 void LyXText::number(LCursor & cur)
303 LyXFont font(LyXFont::ALL_IGNORE);
304 font.setNumber(LyXFont::TOGGLE);
305 toggleAndShow(cur, this, font);
309 bool LyXText::isRTL(Paragraph const & par) const
311 return par.isRightToLeftPar(bv()->buffer()->params());
315 void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
317 lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl;
319 BOOST_ASSERT(cur.text() == this);
320 BufferView * bv = &cur.bv();
321 CursorSlice oldTopSlice = cur.top();
322 bool oldBoundary = cur.boundary();
323 bool sel = cur.selection();
324 // Signals that, even if needsUpdate == false, an update of the
325 // cursor paragraph is required
326 bool singleParUpdate = lyxaction.funcHasFlag(cmd.action,
327 LyXAction::SingleParUpdate);
328 // Signals that a full-screen update is required
329 bool needsUpdate = !(lyxaction.funcHasFlag(cmd.action,
330 LyXAction::NoUpdate) || singleParUpdate);
331 // Remember the old paragraph metric (_outer_ paragraph!)
332 Dimension olddim = cur.bottom().paragraph().dim();
334 switch (cmd.action) {
336 case LFUN_PARAGRAPH_MOVE_DOWN: {
337 pit_type const pit = cur.pit();
338 recUndo(pit, pit + 1);
340 std::swap(pars_[pit], pars_[pit + 1]);
342 ParIterator begin(cur);
344 ParIterator end = boost::next(ParIterator(cur));
345 updateLabels(cur.buffer(), begin, end);
351 case LFUN_PARAGRAPH_MOVE_UP: {
352 pit_type const pit = cur.pit();
353 recUndo(pit - 1, pit);
355 std::swap(pars_[pit], pars_[pit - 1]);
357 ParIterator end = boost::next(ParIterator(cur));
359 ParIterator begin(cur);
360 updateLabels(cur.buffer(), begin, end);
366 case LFUN_APPENDIX: {
367 Paragraph & par = cur.paragraph();
368 bool start = !par.params().startOfAppendix();
371 #warning The code below only makes sense at top level.
372 // Should LFUN_APPENDIX be restricted to top-level paragraphs?
374 // ensure that we have only one start_of_appendix in this document
375 for (pit_type tmp = 0, end = pars_.size(); tmp != end; ++tmp) {
376 if (pars_[tmp].params().startOfAppendix()) {
378 pars_[tmp].params().startOfAppendix(false);
384 par.params().startOfAppendix(start);
386 // we can set the refreshing parameters now
387 updateLabels(cur.buffer());
391 case LFUN_WORD_DELETE_FORWARD:
392 cur.clearSelection();
393 deleteWordForward(cur);
394 finishChange(cur, false);
397 case LFUN_WORD_DELETE_BACKWARD:
398 cur.clearSelection();
399 deleteWordBackward(cur);
400 finishChange(cur, false);
403 case LFUN_LINE_DELETE:
404 cur.clearSelection();
405 deleteLineForward(cur);
406 finishChange(cur, false);
409 case LFUN_BUFFER_BEGIN:
410 case LFUN_BUFFER_BEGIN_SELECT:
411 cur.selHandle(cmd.action == LFUN_BUFFER_BEGIN_SELECT);
412 if (cur.depth() == 1) {
413 needsUpdate = cursorTop(cur);
419 case LFUN_BUFFER_END:
420 case LFUN_BUFFER_END_SELECT:
421 cur.selHandle(cmd.action == LFUN_BUFFER_END_SELECT);
422 if (cur.depth() == 1) {
423 needsUpdate = cursorBottom(cur);
429 case LFUN_CHAR_FORWARD:
430 case LFUN_CHAR_FORWARD_SELECT:
431 //lyxerr << BOOST_CURRENT_FUNCTION
432 // << " LFUN_CHAR_FORWARD[SEL]:\n" << cur << endl;
433 cur.selHandle(cmd.action == LFUN_CHAR_FORWARD_SELECT);
434 if (isRTL(cur.paragraph()))
435 needsUpdate = cursorLeft(cur);
437 needsUpdate = cursorRight(cur);
439 if (!needsUpdate && oldTopSlice == cur.top()
440 && cur.boundary() == oldBoundary) {
442 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
446 case LFUN_CHAR_BACKWARD:
447 case LFUN_CHAR_BACKWARD_SELECT:
448 //lyxerr << "handle LFUN_CHAR_BACKWARD[_SELECT]:\n" << cur << endl;
449 cur.selHandle(cmd.action == LFUN_CHAR_BACKWARD_SELECT);
450 if (isRTL(cur.paragraph()))
451 needsUpdate = cursorRight(cur);
453 needsUpdate = cursorLeft(cur);
455 if (!needsUpdate && oldTopSlice == cur.top()
456 && cur.boundary() == oldBoundary) {
458 cmd = FuncRequest(LFUN_FINISHED_LEFT);
465 //lyxerr << "handle LFUN_UP[SEL]:\n" << cur << endl;
466 cur.selHandle(cmd.action == LFUN_UP_SELECT);
468 needsUpdate = cursorUp(cur);
469 if (!needsUpdate && oldTopSlice == cur.top()
470 && cur.boundary() == oldBoundary) {
472 cmd = FuncRequest(LFUN_FINISHED_UP);
477 case LFUN_DOWN_SELECT:
479 //lyxerr << "handle LFUN_DOWN[SEL]:\n" << cur << endl;
480 cur.selHandle(cmd.action == LFUN_DOWN_SELECT);
481 needsUpdate = cursorDown(cur);
482 if (!needsUpdate && oldTopSlice == cur.top() &&
483 cur.boundary() == oldBoundary)
486 cmd = FuncRequest(LFUN_FINISHED_DOWN);
490 case LFUN_PARAGRAPH_UP:
491 case LFUN_PARAGRAPH_UP_SELECT:
492 cur.selHandle(cmd.action == LFUN_PARAGRAPH_UP_SELECT);
493 needsUpdate = cursorUpParagraph(cur);
496 case LFUN_PARAGRAPH_DOWN:
497 case LFUN_PARAGRAPH_DOWN_SELECT:
498 cur.selHandle(cmd.action == LFUN_PARAGRAPH_DOWN_SELECT);
499 needsUpdate = cursorDownParagraph(cur);
503 case LFUN_SCREEN_UP_SELECT:
505 cur.selHandle(cmd.action == LFUN_SCREEN_UP_SELECT);
506 if (cur.pit() == 0 && cur.textRow().pos() == 0) {
508 cmd = FuncRequest(LFUN_FINISHED_UP);
510 needsUpdate = cursorPrevious(cur);
514 case LFUN_SCREEN_DOWN:
515 case LFUN_SCREEN_DOWN_SELECT:
517 cur.selHandle(cmd.action == LFUN_SCREEN_DOWN_SELECT);
518 if (cur.pit() == cur.lastpit()
519 && cur.textRow().endpos() == cur.lastpos()) {
521 cmd = FuncRequest(LFUN_FINISHED_DOWN);
523 needsUpdate = cursorNext(cur);
527 case LFUN_LINE_BEGIN:
528 case LFUN_LINE_BEGIN_SELECT:
530 cur.selHandle(cmd.action == LFUN_LINE_BEGIN_SELECT);
531 needsUpdate = cursorHome(cur);
535 case LFUN_LINE_END_SELECT:
537 cur.selHandle(cmd.action == LFUN_LINE_END_SELECT);
538 needsUpdate = cursorEnd(cur);
541 case LFUN_WORD_FORWARD:
542 case LFUN_WORD_FORWARD_SELECT:
543 cur.selHandle(cmd.action == LFUN_WORD_FORWARD_SELECT);
544 if (isRTL(cur.paragraph()))
545 needsUpdate = cursorLeftOneWord(cur);
547 needsUpdate = cursorRightOneWord(cur);
550 case LFUN_WORD_BACKWARD:
551 case LFUN_WORD_BACKWARD_SELECT:
552 cur.selHandle(cmd.action == LFUN_WORD_BACKWARD_SELECT);
553 if (isRTL(cur.paragraph()))
554 needsUpdate = cursorRightOneWord(cur);
556 needsUpdate = cursorLeftOneWord(cur);
559 case LFUN_WORD_SELECT: {
560 selectWord(cur, lyx::WHOLE_WORD);
561 finishChange(cur, true);
565 case LFUN_BREAK_LINE: {
566 // Not allowed by LaTeX (labels or empty par)
567 if (cur.pos() > cur.paragraph().beginOfBody()) {
568 lyx::cap::replaceSelection(cur);
569 cur.insert(new InsetNewline);
571 moveCursor(cur, false);
576 case LFUN_CHAR_DELETE_FORWARD:
577 if (!cur.selection()) {
578 if (cur.pos() == cur.paragraph().size())
579 // Par boundary, force full-screen update
580 singleParUpdate = false;
581 needsUpdate = erase(cur);
583 // It is possible to make it a lot faster still
584 // just comment out the line below...
586 cutSelection(cur, true, false);
587 singleParUpdate = false;
589 moveCursor(cur, false);
592 case LFUN_DELETE_FORWARD_SKIP:
593 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
594 if (!cur.selection()) {
595 if (cur.pos() == cur.lastpos()) {
602 cutSelection(cur, true, false);
607 case LFUN_CHAR_DELETE_BACKWARD:
608 if (!cur.selection()) {
609 if (bv->getIntl().getTransManager().backspace()) {
610 // Par boundary, full-screen update
612 singleParUpdate = false;
613 needsUpdate = backspace(cur);
615 // It is possible to make it a lot faster still
616 // just comment out the line below...
619 cutSelection(cur, true, false);
620 singleParUpdate = false;
625 case LFUN_DELETE_BACKWARD_SKIP:
626 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
627 if (!cur.selection()) {
631 //CursorSlice cur = cursor();
635 cutSelection(cur, true, false);
639 case LFUN_BREAK_PARAGRAPH:
640 lyx::cap::replaceSelection(cur);
641 breakParagraph(cur, 0);
646 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
647 lyx::cap::replaceSelection(cur);
648 breakParagraph(cur, 1);
653 case LFUN_BREAK_PARAGRAPH_SKIP: {
654 // When at the beginning of a paragraph, remove
655 // indentation. Otherwise, do the same as LFUN_BREAK_PARAGRAPH.
656 lyx::cap::replaceSelection(cur);
658 cur.paragraph().params().labelWidthString(string());
660 breakParagraph(cur, 0);
666 case LFUN_PARAGRAPH_SPACING: {
667 Paragraph & par = cur.paragraph();
668 Spacing::Space cur_spacing = par.params().spacing().getSpace();
669 string cur_value = "1.0";
670 if (cur_spacing == Spacing::Other)
671 cur_value = par.params().spacing().getValueAsString();
673 istringstream is(lyx::to_utf8(cmd.argument()));
676 Spacing::Space new_spacing = cur_spacing;
677 string new_value = cur_value;
679 lyxerr << "Missing argument to `paragraph-spacing'"
681 } else if (tmp == "single") {
682 new_spacing = Spacing::Single;
683 } else if (tmp == "onehalf") {
684 new_spacing = Spacing::Onehalf;
685 } else if (tmp == "double") {
686 new_spacing = Spacing::Double;
687 } else if (tmp == "other") {
688 new_spacing = Spacing::Other;
689 string tmpval = "0.0";
691 lyxerr << "new_value = " << tmpval << endl;
694 } else if (tmp == "default") {
695 new_spacing = Spacing::Default;
697 lyxerr << lyx::to_utf8(_("Unknown spacing argument: "))
698 << lyx::to_utf8(cmd.argument()) << endl;
700 if (cur_spacing != new_spacing || cur_value != new_value)
701 par.params().spacing(Spacing(new_spacing, new_value));
705 case LFUN_INSET_INSERT: {
707 InsetBase * inset = createInset(bv, cmd);
709 insertInset(cur, inset);
715 case LFUN_INSET_DISSOLVE:
716 needsUpdate = dissolveInset(cur);
719 case LFUN_INSET_SETTINGS:
720 cur.inset().showInsetDialog(bv);
723 case LFUN_SPACE_INSERT:
724 if (cur.paragraph().layout()->free_spacing)
725 insertChar(cur, ' ');
727 doInsertInset(cur, this, cmd, false, false);
730 moveCursor(cur, false);
733 case LFUN_HYPHENATION_POINT_INSERT:
734 specialChar(cur, InsetSpecialChar::HYPHENATION);
737 case LFUN_LIGATURE_BREAK_INSERT:
738 specialChar(cur, InsetSpecialChar::LIGATURE_BREAK);
741 case LFUN_DOTS_INSERT:
742 specialChar(cur, InsetSpecialChar::LDOTS);
745 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
746 specialChar(cur, InsetSpecialChar::END_OF_SENTENCE);
749 case LFUN_MENU_SEPARATOR_INSERT:
750 specialChar(cur, InsetSpecialChar::MENU_SEPARATOR);
753 case LFUN_WORD_UPCASE:
754 changeCase(cur, LyXText::text_uppercase);
757 case LFUN_WORD_LOWCASE:
758 changeCase(cur, LyXText::text_lowercase);
761 case LFUN_WORD_CAPITALIZE:
762 changeCase(cur, LyXText::text_capitalization);
765 case LFUN_CHARS_TRANSPOSE:
770 cur.message(_("Paste"));
771 lyx::cap::replaceSelection(cur);
772 if (isStrUnsignedInt(lyx::to_utf8(cmd.argument())))
773 pasteSelection(cur, bv->buffer()->errorList("Paste"),
774 convert<unsigned int>(lyx::to_utf8(cmd.argument())));
776 pasteSelection(cur, bv->buffer()->errorList("Paste"),
778 bv->buffer()->errors("Paste");
779 cur.clearSelection(); // bug 393
785 cutSelection(cur, true, true);
786 cur.message(_("Cut"));
791 cur.message(_("Copy"));
794 case LFUN_SERVER_GET_XY:
795 cur.message(lyx::from_utf8(
796 convert<string>(cursorX(cur.top(), cur.boundary())) + ' '
797 + convert<string>(cursorY(cur.top(), cur.boundary()))));
800 case LFUN_SERVER_SET_XY: {
803 istringstream is(lyx::to_utf8(cmd.argument()));
806 lyxerr << "SETXY: Could not parse coordinates in '"
807 << lyx::to_utf8(cmd.argument()) << std::endl;
809 setCursorFromCoordinates(cur, x, y);
813 case LFUN_SERVER_GET_FONT:
814 if (current_font.shape() == LyXFont::ITALIC_SHAPE)
815 cur.message(lyx::from_utf8("E"));
816 else if (current_font.shape() == LyXFont::SMALLCAPS_SHAPE)
817 cur.message(lyx::from_utf8("N"));
819 cur.message(lyx::from_utf8("0"));
822 case LFUN_SERVER_GET_LAYOUT:
823 cur.message(lyx::from_utf8(cur.paragraph().layout()->name()));
827 lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) "
828 << lyx::to_utf8(cmd.argument()) << endl;
830 // This is not the good solution to the empty argument
831 // problem, but it will hopefully suffice for 1.2.0.
832 // The correct solution would be to augument the
833 // function list/array with information about what
834 // functions needs arguments and their type.
835 if (cmd.argument().empty()) {
836 cur.errorMessage(_("LyX function 'layout' needs an argument."));
840 // Derive layout number from given argument (string)
841 // and current buffer's textclass (number)
842 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
843 bool hasLayout = tclass.hasLayout(lyx::to_utf8(cmd.argument()));
844 string layout = lyx::to_utf8(cmd.argument());
846 // If the entry is obsolete, use the new one instead.
848 string const & obs = tclass[layout]->obsoleted_by();
854 cur.errorMessage(lyx::from_utf8(N_("Layout ")) + cmd.argument() +
855 lyx::from_utf8(N_(" not known")));
859 bool change_layout = (current_layout != layout);
861 if (!change_layout && cur.selection() &&
862 cur.selBegin().pit() != cur.selEnd().pit())
864 pit_type spit = cur.selBegin().pit();
865 pit_type epit = cur.selEnd().pit() + 1;
866 while (spit != epit) {
867 if (pars_[spit].layout()->name() != current_layout) {
868 change_layout = true;
876 current_layout = layout;
877 setLayout(cur, layout);
878 bv->owner()->setLayout(layout);
884 case LFUN_CLIPBOARD_PASTE: {
885 cur.clearSelection();
886 docstring const clip = bv->owner()->gui().clipboard().get();
889 if (cmd.argument() == "paragraph")
890 insertStringAsParagraphs(cur, clip);
892 insertStringAsLines(cur, clip);
897 case LFUN_PRIMARY_SELECTION_PASTE: {
898 cur.clearSelection();
899 docstring const clip = bv->owner()->gui().selection().get();
902 if (cmd.argument() == "paragraph")
903 insertStringAsParagraphs(cur, clip);
905 insertStringAsLines(cur, clip);
910 case LFUN_QUOTE_INSERT: {
911 lyx::cap::replaceSelection(cur);
912 Paragraph & par = cur.paragraph();
913 lyx::pos_type pos = cur.pos();
917 else if (cur.prevInset() && cur.prevInset()->isSpace())
920 c = par.getChar(pos - 1);
922 LyXLayout_ptr const & style = par.layout();
924 BufferParams const & bufparams = bv->buffer()->params();
925 if (!style->pass_thru
926 && par.getFontSettings(bufparams, pos).language()->lang() != "hebrew") {
927 string arg = lyx::to_utf8(cmd.argument());
929 cur.insert(new InsetQuotes(c,
930 bufparams.quotes_language,
931 InsetQuotes::SingleQ));
933 cur.insert(new InsetQuotes(c,
934 bufparams.quotes_language,
935 InsetQuotes::DoubleQ));
939 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT, "\""));
943 case LFUN_DATE_INSERT:
944 if (cmd.argument().empty())
945 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT,
946 lyx::formatted_time(lyx::current_time())));
948 bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT,
949 lyx::formatted_time(lyx::current_time(), lyx::to_utf8(cmd.argument()))));
952 case LFUN_MOUSE_TRIPLE:
953 if (cmd.button() == mouse_button::button1) {
959 bv->owner()->gui().selection().haveSelection(cur.selection());
963 case LFUN_MOUSE_DOUBLE:
964 if (cmd.button() == mouse_button::button1) {
965 selectWord(cur, lyx::WHOLE_WORD_STRICT);
967 bv->owner()->gui().selection().haveSelection(cur.selection());
971 // Single-click on work area
972 case LFUN_MOUSE_PRESS: {
973 // Right click on a footnote flag opens float menu
974 if (cmd.button() == mouse_button::button3)
975 cur.clearSelection();
977 // Middle button press pastes if we have a selection
978 // We do this here as if the selection was inside an inset
979 // it could get cleared on the unlocking of the inset so
980 // we have to check this first
981 bool paste_internally = false;
982 if (cmd.button() == mouse_button::button2 && cur.selection()) {
983 bv->owner()->dispatch(FuncRequest(LFUN_COPY));
984 paste_internally = true;
987 bv->mouseSetCursor(cur);
989 // Insert primary selection with middle mouse
990 // if there is a local selection in the current buffer,
992 if (cmd.button() == mouse_button::button2) {
993 if (paste_internally)
994 bv->owner()->dispatch(FuncRequest(LFUN_PASTE));
996 bv->owner()->dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph"));
1002 case LFUN_MOUSE_MOTION: {
1003 // Only use motion with button 1
1004 //if (cmd.button() != mouse_button::button1)
1007 // ignore motions deeper nested than the real anchor
1008 LCursor & bvcur = cur.bv().cursor();
1009 if (bvcur.anchor_.hasPart(cur)) {
1010 CursorSlice old = bvcur.top();
1012 int const wh = bv->workHeight();
1013 int const y = std::max(0, std::min(wh - 1, cmd.y));
1015 setCursorFromCoordinates(cur, cmd.x, y);
1016 cur.x_target() = cmd.x;
1021 // This is to allow jumping over large insets
1022 if (cur.top() == old) {
1029 if (cur.top() == old)
1032 // don't set anchor_
1033 bvcur.setCursor(cur);
1034 bvcur.selection() = true;
1035 //lyxerr << "MOTION: " << bv->cursor() << endl;
1043 case LFUN_MOUSE_RELEASE: {
1044 if (cmd.button() == mouse_button::button2)
1048 if (cmd.button() == mouse_button::button1)
1049 bv->owner()->gui().selection().haveSelection(cur.selection());
1052 bv->owner()->updateMenubar();
1053 bv->owner()->updateToolbars();
1057 case LFUN_SELF_INSERT: {
1058 if (cmd.argument().empty())
1061 // Automatically delete the currently selected
1062 // text and replace it with what is being
1063 // typed in now. Depends on lyxrc settings
1064 // "auto_region_delete", which defaults to
1067 if (lyxrc.auto_region_delete) {
1068 if (cur.selection())
1069 cutSelection(cur, false, false);
1070 bv->owner()->gui().selection().haveSelection(false);
1073 cur.clearSelection();
1074 LyXFont const old_font = real_current_font;
1076 docstring::const_iterator cit = cmd.argument().begin();
1077 docstring::const_iterator end = cmd.argument().end();
1078 for (; cit != end; ++cit)
1080 bv->getIntl().getTransManager().
1081 translateAndInsert(*cit, this);
1083 insertChar(bv->cursor(), *cit);
1087 moveCursor(cur, false);
1091 case LFUN_URL_INSERT: {
1092 InsetCommandParams p("url");
1093 string const data = InsetCommandMailer::params2string("url", p);
1094 bv->showInsetDialog("url", data, 0);
1098 case LFUN_HTML_INSERT: {
1099 InsetCommandParams p("htmlurl");
1100 string const data = InsetCommandMailer::params2string("url", p);
1101 bv->showInsetDialog("url", data, 0);
1105 case LFUN_LABEL_INSERT: {
1106 // Try to generate a valid label
1107 string const contents = cmd.argument().empty() ?
1108 cur.getPossibleLabel() : lyx::to_utf8(cmd.argument());
1110 InsetCommandParams p("label", contents);
1111 string const data = InsetCommandMailer::params2string("label", p);
1113 if (cmd.argument().empty()) {
1114 bv->showInsetDialog("label", data, 0);
1116 FuncRequest fr(LFUN_INSET_INSERT, data);
1124 case LFUN_LIST_INSERT:
1125 case LFUN_THEOREM_INSERT:
1126 case LFUN_CAPTION_INSERT:
1128 case LFUN_NOTE_INSERT:
1129 case LFUN_CHARSTYLE_INSERT:
1130 case LFUN_BOX_INSERT:
1131 case LFUN_BRANCH_INSERT:
1132 case LFUN_BIBITEM_INSERT:
1133 case LFUN_ERT_INSERT:
1134 case LFUN_FOOTNOTE_INSERT:
1135 case LFUN_MARGINALNOTE_INSERT:
1136 case LFUN_OPTIONAL_INSERT:
1137 case LFUN_ENVIRONMENT_INSERT:
1138 // Open the inset, and move the current selection
1140 doInsertInset(cur, this, cmd, true, true);
1144 case LFUN_TABULAR_INSERT:
1145 // if there were no arguments, just open the dialog
1146 if (doInsertInset(cur, this, cmd, false, true))
1149 bv->showDialog("tabularcreate");
1153 case LFUN_FLOAT_INSERT:
1154 case LFUN_FLOAT_WIDE_INSERT:
1155 case LFUN_WRAP_INSERT:
1156 doInsertInset(cur, this, cmd, true, true);
1158 // FIXME: the "Caption" name should not be hardcoded,
1159 // but given by the float definition.
1160 cur.dispatch(FuncRequest(LFUN_LAYOUT, "Caption"));
1163 case LFUN_INDEX_INSERT: {
1164 InsetBase * inset = createInset(&cur.bv(), cmd);
1169 cur.clearSelection();
1170 insertInset(cur, inset);
1171 inset->edit(cur, true);
1176 case LFUN_INDEX_PRINT:
1177 case LFUN_TOC_INSERT:
1178 case LFUN_HFILL_INSERT:
1179 case LFUN_LINE_INSERT:
1180 case LFUN_PAGEBREAK_INSERT:
1182 doInsertInset(cur, this, cmd, false, false);
1186 case LFUN_DEPTH_DECREMENT:
1187 changeDepth(cur, DEC_DEPTH);
1190 case LFUN_DEPTH_INCREMENT:
1191 changeDepth(cur, INC_DEPTH);
1194 case LFUN_MATH_DISPLAY:
1195 mathDispatch(cur, cmd, true);
1198 case LFUN_MATH_IMPORT_SELECTION:
1199 case LFUN_MATH_MODE:
1200 if (cmd.argument() == "on")
1201 // don't pass "on" as argument
1202 mathDispatch(cur, FuncRequest(LFUN_MATH_MODE), false);
1204 mathDispatch(cur, cmd, false);
1207 case LFUN_MATH_MACRO:
1208 if (cmd.argument().empty())
1209 cur.errorMessage(lyx::from_utf8(N_("Missing argument")));
1211 string s = lyx::to_utf8(cmd.argument());
1212 string const s1 = token(s, ' ', 1);
1213 int const nargs = s1.empty() ? 0 : convert<int>(s1);
1214 string const s2 = token(s, ' ', 2);
1215 string const type = s2.empty() ? "newcommand" : s2;
1216 cur.insert(new MathMacroTemplate(token(s, ' ', 0), nargs, type));
1217 //cur.nextInset()->edit(cur, true);
1221 // passthrough hat and underscore outside mathed:
1222 case LFUN_MATH_SUBSCRIPT:
1223 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "_"), false);
1225 case LFUN_MATH_SUPERSCRIPT:
1226 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "^"), false);
1229 case LFUN_MATH_INSERT:
1230 case LFUN_MATH_MATRIX:
1231 case LFUN_MATH_DELIM:
1232 case LFUN_MATH_BIGDELIM: {
1233 cur.insert(new InsetMathHull(hullSimple));
1234 cur.dispatch(FuncRequest(LFUN_CHAR_FORWARD));
1239 case LFUN_FONT_EMPH: {
1240 LyXFont font(LyXFont::ALL_IGNORE);
1241 font.setEmph(LyXFont::TOGGLE);
1242 toggleAndShow(cur, this, font);
1246 case LFUN_FONT_BOLD: {
1247 LyXFont font(LyXFont::ALL_IGNORE);
1248 font.setSeries(LyXFont::BOLD_SERIES);
1249 toggleAndShow(cur, this, font);
1253 case LFUN_FONT_NOUN: {
1254 LyXFont font(LyXFont::ALL_IGNORE);
1255 font.setNoun(LyXFont::TOGGLE);
1256 toggleAndShow(cur, this, font);
1260 case LFUN_FONT_CODE: {
1261 LyXFont font(LyXFont::ALL_IGNORE);
1262 font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
1263 toggleAndShow(cur, this, font);
1267 case LFUN_FONT_SANS: {
1268 LyXFont font(LyXFont::ALL_IGNORE);
1269 font.setFamily(LyXFont::SANS_FAMILY);
1270 toggleAndShow(cur, this, font);
1274 case LFUN_FONT_ROMAN: {
1275 LyXFont font(LyXFont::ALL_IGNORE);
1276 font.setFamily(LyXFont::ROMAN_FAMILY);
1277 toggleAndShow(cur, this, font);
1281 case LFUN_FONT_DEFAULT: {
1282 LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
1283 toggleAndShow(cur, this, font);
1287 case LFUN_FONT_UNDERLINE: {
1288 LyXFont font(LyXFont::ALL_IGNORE);
1289 font.setUnderbar(LyXFont::TOGGLE);
1290 toggleAndShow(cur, this, font);
1294 case LFUN_FONT_SIZE: {
1295 LyXFont font(LyXFont::ALL_IGNORE);
1296 font.setLyXSize(lyx::to_utf8(cmd.argument()));
1297 toggleAndShow(cur, this, font);
1301 case LFUN_LANGUAGE: {
1302 Language const * lang = languages.getLanguage(lyx::to_utf8(cmd.argument()));
1305 LyXFont font(LyXFont::ALL_IGNORE);
1306 font.setLanguage(lang);
1307 toggleAndShow(cur, this, font);
1312 case LFUN_FONT_FREE_APPLY:
1313 toggleAndShow(cur, this, freefont, toggleall);
1314 cur.message(_("Character set"));
1317 // Set the freefont using the contents of \param data dispatched from
1318 // the frontends and apply it at the current cursor location.
1319 case LFUN_FONT_FREE_UPDATE: {
1322 if (bv_funcs::string2font(lyx::to_utf8(cmd.argument()), font, toggle)) {
1325 toggleAndShow(cur, this, freefont, toggleall);
1326 cur.message(_("Character set"));
1331 case LFUN_FINISHED_LEFT:
1332 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_LEFT:\n" << cur << endl;
1335 case LFUN_FINISHED_RIGHT:
1336 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_RIGHT:\n" << cur << endl;
1340 case LFUN_FINISHED_UP:
1341 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_UP:\n" << cur << endl;
1345 case LFUN_FINISHED_DOWN:
1346 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_DOWN:\n" << cur << endl;
1350 case LFUN_LAYOUT_PARAGRAPH: {
1352 params2string(cur.paragraph(), data);
1353 data = "show\n" + data;
1354 bv->showDialogWithData("paragraph", data);
1358 case LFUN_PARAGRAPH_UPDATE: {
1360 params2string(cur.paragraph(), data);
1362 // Will the paragraph accept changes from the dialog?
1363 bool const accept = !cur.inset().forceDefaultParagraphs(cur.idx());
1365 data = "update " + convert<string>(accept) + '\n' + data;
1366 bv->updateDialog("paragraph", data);
1370 case LFUN_ACCENT_UMLAUT:
1371 case LFUN_ACCENT_CIRCUMFLEX:
1372 case LFUN_ACCENT_GRAVE:
1373 case LFUN_ACCENT_ACUTE:
1374 case LFUN_ACCENT_TILDE:
1375 case LFUN_ACCENT_CEDILLA:
1376 case LFUN_ACCENT_MACRON:
1377 case LFUN_ACCENT_DOT:
1378 case LFUN_ACCENT_UNDERDOT:
1379 case LFUN_ACCENT_UNDERBAR:
1380 case LFUN_ACCENT_CARON:
1381 case LFUN_ACCENT_SPECIAL_CARON:
1382 case LFUN_ACCENT_BREVE:
1383 case LFUN_ACCENT_TIE:
1384 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1385 case LFUN_ACCENT_CIRCLE:
1386 case LFUN_ACCENT_OGONEK:
1387 bv->owner()->getLyXFunc().handleKeyFunc(cmd.action);
1388 if (!cmd.argument().empty())
1389 // FIXME: Are all these characters encoded in one byte in utf8?
1390 bv->getIntl().getTransManager()
1391 .translateAndInsert(cmd.argument()[0], this);
1394 case LFUN_FLOAT_LIST: {
1395 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
1396 if (tclass.floats().typeExist(lyx::to_utf8(cmd.argument()))) {
1397 // not quite sure if we want this...
1399 cur.clearSelection();
1400 breakParagraph(cur);
1402 if (cur.lastpos() != 0) {
1404 breakParagraph(cur);
1407 setLayout(cur, tclass.defaultLayoutName());
1408 setParagraph(cur, Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
1409 insertInset(cur, new InsetFloatList(lyx::to_utf8(cmd.argument())));
1412 lyxerr << "Non-existent float type: "
1413 << lyx::to_utf8(cmd.argument()) << endl;
1418 case LFUN_CHANGE_ACCEPT: {
1423 case LFUN_CHANGE_REJECT: {
1428 case LFUN_THESAURUS_ENTRY: {
1429 docstring arg = cmd.argument();
1431 arg = cur.selectionAsString(false);
1433 if (arg.size() > 100 || arg.empty()) {
1434 // Get word or selection
1435 selectWordWhenUnderCursor(cur, lyx::WHOLE_WORD);
1436 arg = cur.selectionAsString(false);
1439 bv->showDialogWithData("thesaurus", lyx::to_utf8(arg));
1443 case LFUN_PARAGRAPH_PARAMS_APPLY: {
1444 // Given data, an encoding of the ParagraphParameters
1445 // generated in the Paragraph dialog, this function sets
1446 // the current paragraph appropriately.
1447 istringstream is(lyx::to_utf8(cmd.argument()));
1450 ParagraphParameters params;
1455 params.labelWidthString(),
1457 cur.message(_("Paragraph layout set"));
1462 if (cur.selection()) {
1463 cur.selection() = false;
1466 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
1471 lyxerr[Debug::ACTION]
1472 << BOOST_CURRENT_FUNCTION
1473 << ": Command " << cmd
1474 << " not DISPATCHED by LyXText" << endl;
1479 if (singleParUpdate)
1480 // Inserting characters does not change par height
1481 if (cur.bottom().paragraph().dim().height()
1482 == olddim.height()) {
1483 // if so, update _only_ this paragraph
1484 cur.bv().update(Update::SinglePar |
1486 Update::MultiParSel);
1492 && &oldTopSlice.inset() == &cur.inset()
1493 && oldTopSlice.idx() == cur.idx()
1495 && !cur.selection())
1502 bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
1503 FuncStatus & flag) const
1505 BOOST_ASSERT(cur.text() == this);
1507 LyXFont const & font = real_current_font;
1509 InsetBase::Code code = InsetBase::NO_CODE;
1511 switch (cmd.action) {
1513 case LFUN_DEPTH_DECREMENT:
1514 enable = changeDepthAllowed(cur, DEC_DEPTH);
1517 case LFUN_DEPTH_INCREMENT:
1518 enable = changeDepthAllowed(cur, INC_DEPTH);
1522 flag.setOnOff(cur.paragraph().params().startOfAppendix());
1525 case LFUN_BIBITEM_INSERT:
1526 enable = (cur.paragraph().layout()->labeltype == LABEL_BIBLIO);
1529 case LFUN_DIALOG_SHOW_NEW_INSET:
1530 if (cmd.argument() == "bibitem")
1531 code = InsetBase::BIBITEM_CODE;
1532 else if (cmd.argument() == "bibtex")
1533 code = InsetBase::BIBTEX_CODE;
1534 else if (cmd.argument() == "box")
1535 code = InsetBase::BOX_CODE;
1536 else if (cmd.argument() == "branch")
1537 code = InsetBase::BRANCH_CODE;
1538 else if (cmd.argument() == "citation")
1539 code = InsetBase::CITE_CODE;
1540 else if (cmd.argument() == "ert")
1541 code = InsetBase::ERT_CODE;
1542 else if (cmd.argument() == "external")
1543 code = InsetBase::EXTERNAL_CODE;
1544 else if (cmd.argument() == "float")
1545 code = InsetBase::FLOAT_CODE;
1546 else if (cmd.argument() == "graphics")
1547 code = InsetBase::GRAPHICS_CODE;
1548 else if (cmd.argument() == "include")
1549 code = InsetBase::INCLUDE_CODE;
1550 else if (cmd.argument() == "index")
1551 code = InsetBase::INDEX_CODE;
1552 else if (cmd.argument() == "label")
1553 code = InsetBase::LABEL_CODE;
1554 else if (cmd.argument() == "note")
1555 code = InsetBase::NOTE_CODE;
1556 else if (cmd.argument() == "ref")
1557 code = InsetBase::REF_CODE;
1558 else if (cmd.argument() == "toc")
1559 code = InsetBase::TOC_CODE;
1560 else if (cmd.argument() == "url")
1561 code = InsetBase::URL_CODE;
1562 else if (cmd.argument() == "vspace")
1563 code = InsetBase::VSPACE_CODE;
1564 else if (cmd.argument() == "wrap")
1565 code = InsetBase::WRAP_CODE;
1568 case LFUN_ERT_INSERT:
1569 code = InsetBase::ERT_CODE;
1571 case LFUN_FOOTNOTE_INSERT:
1572 code = InsetBase::FOOT_CODE;
1574 case LFUN_TABULAR_INSERT:
1575 code = InsetBase::TABULAR_CODE;
1577 case LFUN_MARGINALNOTE_INSERT:
1578 code = InsetBase::MARGIN_CODE;
1580 case LFUN_FLOAT_INSERT:
1581 case LFUN_FLOAT_WIDE_INSERT:
1582 code = InsetBase::FLOAT_CODE;
1584 case LFUN_WRAP_INSERT:
1585 code = InsetBase::WRAP_CODE;
1587 case LFUN_FLOAT_LIST:
1588 code = InsetBase::FLOAT_LIST_CODE;
1591 case LFUN_LIST_INSERT:
1592 code = InsetBase::LIST_CODE;
1594 case LFUN_THEOREM_INSERT:
1595 code = InsetBase::THEOREM_CODE;
1598 case LFUN_CAPTION_INSERT:
1599 code = InsetBase::CAPTION_CODE;
1601 case LFUN_NOTE_INSERT:
1602 code = InsetBase::NOTE_CODE;
1604 case LFUN_CHARSTYLE_INSERT:
1605 code = InsetBase::CHARSTYLE_CODE;
1606 if (cur.buffer().params().getLyXTextClass().charstyles().empty())
1609 case LFUN_BOX_INSERT:
1610 code = InsetBase::BOX_CODE;
1612 case LFUN_BRANCH_INSERT:
1613 code = InsetBase::BRANCH_CODE;
1614 if (cur.buffer().getMasterBuffer()->params().branchlist().empty())
1617 case LFUN_LABEL_INSERT:
1618 code = InsetBase::LABEL_CODE;
1620 case LFUN_OPTIONAL_INSERT:
1621 code = InsetBase::OPTARG_CODE;
1622 enable = numberOfOptArgs(cur.paragraph())
1623 < cur.paragraph().layout()->optionalargs;
1625 case LFUN_ENVIRONMENT_INSERT:
1626 code = InsetBase::BOX_CODE;
1628 case LFUN_INDEX_INSERT:
1629 code = InsetBase::INDEX_CODE;
1631 case LFUN_INDEX_PRINT:
1632 code = InsetBase::INDEX_PRINT_CODE;
1634 case LFUN_TOC_INSERT:
1635 code = InsetBase::TOC_CODE;
1637 case LFUN_HTML_INSERT:
1638 case LFUN_URL_INSERT:
1639 code = InsetBase::URL_CODE;
1641 case LFUN_QUOTE_INSERT:
1642 // always allow this, since we will inset a raw quote
1643 // if an inset is not allowed.
1645 case LFUN_HYPHENATION_POINT_INSERT:
1646 case LFUN_LIGATURE_BREAK_INSERT:
1647 case LFUN_HFILL_INSERT:
1648 case LFUN_MENU_SEPARATOR_INSERT:
1649 case LFUN_DOTS_INSERT:
1650 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
1651 code = InsetBase::SPECIALCHAR_CODE;
1653 case LFUN_SPACE_INSERT:
1654 // slight hack: we know this is allowed in math mode
1656 code = InsetBase::SPACE_CODE;
1659 case LFUN_INSET_MODIFY:
1660 // We need to disable this, because we may get called for a
1662 // InsetTabular::getStatus() -> InsetText::getStatus()
1663 // and we don't handle LFUN_INSET_MODIFY.
1667 case LFUN_FONT_EMPH:
1668 flag.setOnOff(font.emph() == LyXFont::ON);
1671 case LFUN_FONT_NOUN:
1672 flag.setOnOff(font.noun() == LyXFont::ON);
1675 case LFUN_FONT_BOLD:
1676 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
1679 case LFUN_FONT_SANS:
1680 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
1683 case LFUN_FONT_ROMAN:
1684 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
1687 case LFUN_FONT_CODE:
1688 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
1693 enable = cur.selection();
1697 enable = lyx::cap::numberOfSelections() > 0;
1700 case LFUN_PARAGRAPH_MOVE_UP:
1701 enable = cur.pit() > 0 && !cur.selection();
1704 case LFUN_PARAGRAPH_MOVE_DOWN:
1705 enable = cur.pit() < cur.lastpit() && !cur.selection();
1708 case LFUN_INSET_DISSOLVE:
1709 enable = !isMainText() && cur.inset().nargs() == 1;
1712 case LFUN_WORD_DELETE_FORWARD:
1713 case LFUN_WORD_DELETE_BACKWARD:
1714 case LFUN_LINE_DELETE:
1715 case LFUN_WORD_FORWARD:
1716 case LFUN_WORD_BACKWARD:
1717 case LFUN_CHAR_FORWARD:
1718 case LFUN_CHAR_FORWARD_SELECT:
1719 case LFUN_CHAR_BACKWARD:
1720 case LFUN_CHAR_BACKWARD_SELECT:
1722 case LFUN_UP_SELECT:
1724 case LFUN_DOWN_SELECT:
1725 case LFUN_PARAGRAPH_UP_SELECT:
1726 case LFUN_PARAGRAPH_DOWN_SELECT:
1727 case LFUN_SCREEN_UP_SELECT:
1728 case LFUN_SCREEN_DOWN_SELECT:
1729 case LFUN_LINE_BEGIN_SELECT:
1730 case LFUN_LINE_END_SELECT:
1731 case LFUN_WORD_FORWARD_SELECT:
1732 case LFUN_WORD_BACKWARD_SELECT:
1733 case LFUN_WORD_SELECT:
1734 case LFUN_PARAGRAPH_UP:
1735 case LFUN_PARAGRAPH_DOWN:
1736 case LFUN_SCREEN_UP:
1737 case LFUN_SCREEN_DOWN:
1738 case LFUN_LINE_BEGIN:
1740 case LFUN_BREAK_LINE:
1741 case LFUN_CHAR_DELETE_FORWARD:
1742 case LFUN_DELETE_FORWARD_SKIP:
1743 case LFUN_CHAR_DELETE_BACKWARD:
1744 case LFUN_DELETE_BACKWARD_SKIP:
1745 case LFUN_BREAK_PARAGRAPH:
1746 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
1747 case LFUN_BREAK_PARAGRAPH_SKIP:
1748 case LFUN_PARAGRAPH_SPACING:
1749 case LFUN_INSET_INSERT:
1750 case LFUN_WORD_UPCASE:
1751 case LFUN_WORD_LOWCASE:
1752 case LFUN_WORD_CAPITALIZE:
1753 case LFUN_CHARS_TRANSPOSE:
1754 case LFUN_SERVER_GET_XY:
1755 case LFUN_SERVER_SET_XY:
1756 case LFUN_SERVER_GET_FONT:
1757 case LFUN_SERVER_GET_LAYOUT:
1759 case LFUN_CLIPBOARD_PASTE:
1760 case LFUN_PRIMARY_SELECTION_PASTE:
1761 case LFUN_DATE_INSERT:
1762 case LFUN_SELF_INSERT:
1763 case LFUN_LINE_INSERT:
1764 case LFUN_PAGEBREAK_INSERT:
1765 case LFUN_MATH_DISPLAY:
1766 case LFUN_MATH_IMPORT_SELECTION:
1767 case LFUN_MATH_MODE:
1768 case LFUN_MATH_MACRO:
1769 case LFUN_MATH_INSERT:
1770 case LFUN_MATH_MATRIX:
1771 case LFUN_MATH_DELIM:
1772 case LFUN_MATH_BIGDELIM:
1773 case LFUN_MATH_SUBSCRIPT:
1774 case LFUN_MATH_SUPERSCRIPT:
1775 case LFUN_FONT_DEFAULT:
1776 case LFUN_FONT_UNDERLINE:
1777 case LFUN_FONT_SIZE:
1779 case LFUN_FONT_FREE_APPLY:
1780 case LFUN_FONT_FREE_UPDATE:
1781 case LFUN_LAYOUT_PARAGRAPH:
1782 case LFUN_PARAGRAPH_UPDATE:
1783 case LFUN_ACCENT_UMLAUT:
1784 case LFUN_ACCENT_CIRCUMFLEX:
1785 case LFUN_ACCENT_GRAVE:
1786 case LFUN_ACCENT_ACUTE:
1787 case LFUN_ACCENT_TILDE:
1788 case LFUN_ACCENT_CEDILLA:
1789 case LFUN_ACCENT_MACRON:
1790 case LFUN_ACCENT_DOT:
1791 case LFUN_ACCENT_UNDERDOT:
1792 case LFUN_ACCENT_UNDERBAR:
1793 case LFUN_ACCENT_CARON:
1794 case LFUN_ACCENT_SPECIAL_CARON:
1795 case LFUN_ACCENT_BREVE:
1796 case LFUN_ACCENT_TIE:
1797 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1798 case LFUN_ACCENT_CIRCLE:
1799 case LFUN_ACCENT_OGONEK:
1800 case LFUN_CHANGE_ACCEPT:
1801 case LFUN_CHANGE_REJECT:
1802 case LFUN_THESAURUS_ENTRY:
1803 case LFUN_PARAGRAPH_PARAMS_APPLY:
1805 case LFUN_BUFFER_END:
1806 case LFUN_BUFFER_BEGIN:
1807 case LFUN_BUFFER_BEGIN_SELECT:
1808 case LFUN_BUFFER_END_SELECT:
1809 // these are handled in our dispatch()
1817 if (code != InsetBase::NO_CODE
1818 && (cur.empty() || !cur.inset().insetAllowed(code)))
1821 flag.enabled(enable);