3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Asger Alstrup
7 * \author Lars Gullik Bjønnes
8 * \author Alfredo Braunstein
9 * \author Angus Leeming
11 * \author André Pönitz
13 * Full author contact details are available in file CREDITS.
20 #include "BranchList.h"
21 #include "FloatList.h"
22 #include "FuncStatus.h"
24 #include "buffer_funcs.h"
25 #include "bufferparams.h"
26 #include "BufferView.h"
28 #include "coordcache.h"
29 #include "CutAndPaste.h"
31 #include "dispatchresult.h"
32 #include "errorlist.h"
34 #include "funcrequest.h"
38 #include "LyXAction.h"
43 #include "paragraph.h"
44 #include "paragraph_funcs.h"
45 #include "ParagraphParameters.h"
48 #include "pariterator.h"
50 #include "frontends/Clipboard.h"
51 #include "frontends/Selection.h"
53 #include "insets/insetcommand.h"
54 #include "insets/insetfloatlist.h"
55 #include "insets/insetnewline.h"
56 #include "insets/insetquotes.h"
57 #include "insets/insetspecialchar.h"
58 #include "insets/insettext.h"
60 #include "support/lstrings.h"
61 #include "support/lyxlib.h"
62 #include "support/convert.h"
63 #include "support/lyxtime.h"
65 #include "mathed/InsetMathHull.h"
66 #include "mathed/MathMacroTemplate.h"
68 #include <boost/current_function.hpp>
76 using cap::copySelection;
77 using cap::cutSelection;
78 using cap::pasteSelection;
79 using cap::replaceSelection;
81 using support::isStrUnsignedInt;
86 using std::istringstream;
87 using std::ostringstream;
90 extern string current_layout;
96 LyXFont freefont(LyXFont::ALL_IGNORE);
97 bool toggleall = false;
100 void toggleAndShow(LCursor & cur, LyXText * text,
101 LyXFont const & font, bool toggleall = true)
103 text->toggleFree(cur, font, toggleall);
105 if (font.language() != ignore_language ||
106 font.number() != LyXFont::IGNORE) {
107 Paragraph & par = cur.paragraph();
108 text->bidi.computeTables(par, cur.buffer(), cur.textRow());
109 if (cur.boundary() !=
110 text->bidi.isBoundary(cur.buffer(), par,
112 text->real_current_font))
113 text->setCursor(cur, cur.pit(), cur.pos(),
114 false, !cur.boundary());
119 void moveCursor(LCursor & cur, bool selecting)
121 if (selecting || cur.mark())
123 if (!cur.selection())
124 theSelection().haveSelection(false);
125 cur.bv().switchKeyMap();
129 void finishChange(LCursor & cur, bool selecting)
132 moveCursor(cur, selecting);
136 void mathDispatch(LCursor & cur, FuncRequest const & cmd, bool display)
139 docstring sel = cur.selectionAsString(false);
140 //lyxerr << "selection is: '" << sel << "'" << endl;
142 // It may happen that sel is empty but there is a selection
143 replaceSelection(cur);
146 const int old_pos = cur.pos();
147 cur.insert(new InsetMathHull(hullSimple));
148 BOOST_ASSERT(old_pos == cur.pos());
149 cur.nextInset()->edit(cur, true);
150 // don't do that also for LFUN_MATH_MODE
151 // unless you want end up with always changing
152 // to mathrm when opening an inlined inset --
153 // I really hate "LyXfunc overloading"...
155 cur.dispatch(FuncRequest(LFUN_MATH_DISPLAY));
156 // Avoid an unnecessary undo step if cmd.argument
158 if (!cmd.argument().empty())
159 cur.dispatch(FuncRequest(LFUN_MATH_INSERT,
162 // create a macro if we see "\\newcommand"
163 // somewhere, and an ordinary formula
165 if (sel.find(from_ascii("\\newcommand")) == string::npos
166 && sel.find(from_ascii("\\def")) == string::npos)
168 InsetMathHull * formula = new InsetMathHull;
169 istringstream is(to_utf8(sel));
172 formula->read(cur.buffer(), lex);
173 if (formula->getType() == hullNone)
174 // Don't create pseudo formulas if
175 // delimiters are left out
176 formula->mutate(hullSimple);
179 cur.insert(new MathMacroTemplate(sel));
182 cur.message(from_utf8(N_("Math editor mode")));
191 string const freefont2string()
194 if (font2string(freefont, toggleall, data))
201 bool LyXText::cursorPrevious(LCursor & cur)
203 pos_type cpos = cur.pos();
204 pit_type cpar = cur.pit();
206 int x = cur.x_target();
208 bool updated = setCursorFromCoordinates(cur, x, 0);
211 updated |= cursorUp(cur);
213 if (cpar == cur.pit() && cpos == cur.pos()) {
214 // we have a row which is taller than the workarea. The
215 // simplest solution is to move to the previous row instead.
216 updated |= cursorUp(cur);
224 bool LyXText::cursorNext(LCursor & cur)
226 pos_type cpos = cur.pos();
227 pit_type cpar = cur.pit();
229 int x = cur.x_target();
230 bool updated = setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1);
233 updated |= cursorDown(cur);
235 if (cpar == cur.pit() && cpos == cur.pos()) {
236 // we have a row which is taller than the workarea. The
237 // simplest solution is to move to the next row instead.
238 updated |= cursorDown(cur);
248 void specialChar(LCursor & cur, InsetSpecialChar::Kind kind)
250 cap::replaceSelection(cur);
251 cur.insert(new InsetSpecialChar(kind));
256 bool doInsertInset(LCursor & cur, LyXText * text,
257 FuncRequest const & cmd, bool edit, bool pastesel)
259 InsetBase * inset = createInset(&cur.bv(), cmd);
265 if (cur.selection()) {
266 lyx::dispatch(FuncRequest(LFUN_CUT));
269 text->insertInset(cur, inset);
272 inset->edit(cur, true);
274 if (gotsel && pastesel) {
275 lyx::dispatch(FuncRequest(LFUN_PASTE));
276 // reset first par to default
277 if (cur.lastpit() != 0 || cur.lastpos() != 0) {
278 LyXLayout_ptr const layout =
279 cur.buffer().params().getLyXTextClass().defaultLayout();
280 cur.text()->paragraphs().begin()->layout(layout);
290 void LyXText::number(LCursor & cur)
292 LyXFont font(LyXFont::ALL_IGNORE);
293 font.setNumber(LyXFont::TOGGLE);
294 toggleAndShow(cur, this, font);
298 bool LyXText::isRTL(Buffer const & buffer, Paragraph const & par) const
300 return par.isRightToLeftPar(buffer.params());
304 void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
306 lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl;
308 BOOST_ASSERT(cur.text() == this);
309 BufferView * bv = &cur.bv();
310 CursorSlice oldTopSlice = cur.top();
311 bool oldBoundary = cur.boundary();
312 bool sel = cur.selection();
313 // Signals that, even if needsUpdate == false, an update of the
314 // cursor paragraph is required
315 bool singleParUpdate = lyxaction.funcHasFlag(cmd.action,
316 LyXAction::SingleParUpdate);
317 // Signals that a full-screen update is required
318 bool needsUpdate = !(lyxaction.funcHasFlag(cmd.action,
319 LyXAction::NoUpdate) || singleParUpdate);
320 // Remember the old paragraph metric (_outer_ paragraph!)
321 Dimension olddim = cur.bottom().paragraph().dim();
323 switch (cmd.action) {
325 case LFUN_PARAGRAPH_MOVE_DOWN: {
326 pit_type const pit = cur.pit();
327 recUndo(cur, pit, pit + 1);
329 std::swap(pars_[pit], pars_[pit + 1]);
331 ParIterator begin(cur);
333 ParIterator end = boost::next(ParIterator(cur));
334 updateLabels(cur.buffer(), begin, end);
340 case LFUN_PARAGRAPH_MOVE_UP: {
341 pit_type const pit = cur.pit();
342 recUndo(cur, pit - 1, pit);
344 std::swap(pars_[pit], pars_[pit - 1]);
346 ParIterator end = boost::next(ParIterator(cur));
348 ParIterator begin(cur);
349 updateLabels(cur.buffer(), begin, end);
355 case LFUN_APPENDIX: {
356 Paragraph & par = cur.paragraph();
357 bool start = !par.params().startOfAppendix();
360 #warning The code below only makes sense at top level.
361 // Should LFUN_APPENDIX be restricted to top-level paragraphs?
363 // ensure that we have only one start_of_appendix in this document
364 for (pit_type tmp = 0, end = pars_.size(); tmp != end; ++tmp) {
365 if (pars_[tmp].params().startOfAppendix()) {
367 pars_[tmp].params().startOfAppendix(false);
373 par.params().startOfAppendix(start);
375 // we can set the refreshing parameters now
376 updateLabels(cur.buffer());
380 case LFUN_WORD_DELETE_FORWARD:
381 cur.clearSelection();
382 deleteWordForward(cur);
383 finishChange(cur, false);
386 case LFUN_WORD_DELETE_BACKWARD:
387 cur.clearSelection();
388 deleteWordBackward(cur);
389 finishChange(cur, false);
392 case LFUN_LINE_DELETE:
393 cur.clearSelection();
394 deleteLineForward(cur);
395 finishChange(cur, false);
398 case LFUN_BUFFER_BEGIN:
399 case LFUN_BUFFER_BEGIN_SELECT:
400 needsUpdate |= cur.selHandle(cmd.action == LFUN_BUFFER_BEGIN_SELECT);
401 if (cur.depth() == 1) {
402 needsUpdate |= cursorTop(cur);
408 case LFUN_BUFFER_END:
409 case LFUN_BUFFER_END_SELECT:
410 needsUpdate |= cur.selHandle(cmd.action == LFUN_BUFFER_END_SELECT);
411 if (cur.depth() == 1) {
412 needsUpdate |= cursorBottom(cur);
418 case LFUN_CHAR_FORWARD:
419 case LFUN_CHAR_FORWARD_SELECT:
420 //lyxerr << BOOST_CURRENT_FUNCTION
421 // << " LFUN_CHAR_FORWARD[SEL]:\n" << cur << endl;
422 needsUpdate |= cur.selHandle(cmd.action == LFUN_CHAR_FORWARD_SELECT);
423 if (isRTL(*cur.bv().buffer(), cur.paragraph()))
424 needsUpdate |= cursorLeft(cur);
426 needsUpdate |= cursorRight(cur);
428 if (!needsUpdate && oldTopSlice == cur.top()
429 && cur.boundary() == oldBoundary) {
431 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
435 case LFUN_CHAR_BACKWARD:
436 case LFUN_CHAR_BACKWARD_SELECT:
437 //lyxerr << "handle LFUN_CHAR_BACKWARD[_SELECT]:\n" << cur << endl;
438 needsUpdate |= cur.selHandle(cmd.action == LFUN_CHAR_BACKWARD_SELECT);
439 if (isRTL(*cur.bv().buffer(), cur.paragraph()))
440 needsUpdate |= cursorRight(cur);
442 needsUpdate |= cursorLeft(cur);
444 if (!needsUpdate && oldTopSlice == cur.top()
445 && cur.boundary() == oldBoundary) {
447 cmd = FuncRequest(LFUN_FINISHED_LEFT);
453 //lyxerr << "handle LFUN_UP[SEL]:\n" << cur << endl;
454 needsUpdate |= cur.selHandle(cmd.action == LFUN_UP_SELECT);
456 needsUpdate |= cursorUp(cur);
458 if (!needsUpdate && oldTopSlice == cur.top()
459 && cur.boundary() == oldBoundary) {
461 cmd = FuncRequest(LFUN_FINISHED_UP);
466 case LFUN_DOWN_SELECT:
467 //lyxerr << "handle LFUN_DOWN[SEL]:\n" << cur << endl;
468 needsUpdate |= cur.selHandle(cmd.action == LFUN_DOWN_SELECT);
469 needsUpdate |= cursorDown(cur);
471 if (!needsUpdate && oldTopSlice == cur.top() &&
472 cur.boundary() == oldBoundary)
475 cmd = FuncRequest(LFUN_FINISHED_DOWN);
479 case LFUN_PARAGRAPH_UP:
480 case LFUN_PARAGRAPH_UP_SELECT:
481 needsUpdate |= cur.selHandle(cmd.action == LFUN_PARAGRAPH_UP_SELECT);
482 needsUpdate |= cursorUpParagraph(cur);
485 case LFUN_PARAGRAPH_DOWN:
486 case LFUN_PARAGRAPH_DOWN_SELECT:
487 needsUpdate |= cur.selHandle(cmd.action == LFUN_PARAGRAPH_DOWN_SELECT);
488 needsUpdate |= cursorDownParagraph(cur);
492 case LFUN_SCREEN_UP_SELECT:
493 needsUpdate |= cur.selHandle(cmd.action == LFUN_SCREEN_UP_SELECT);
494 if (cur.pit() == 0 && cur.textRow().pos() == 0) {
496 cmd = FuncRequest(LFUN_FINISHED_UP);
498 needsUpdate |= cursorPrevious(cur);
502 case LFUN_SCREEN_DOWN:
503 case LFUN_SCREEN_DOWN_SELECT:
504 needsUpdate |= cur.selHandle(cmd.action == LFUN_SCREEN_DOWN_SELECT);
505 if (cur.pit() == cur.lastpit()
506 && cur.textRow().endpos() == cur.lastpos()) {
508 cmd = FuncRequest(LFUN_FINISHED_DOWN);
510 needsUpdate |= cursorNext(cur);
514 case LFUN_LINE_BEGIN:
515 case LFUN_LINE_BEGIN_SELECT:
516 needsUpdate |= cur.selHandle(cmd.action == LFUN_LINE_BEGIN_SELECT);
517 needsUpdate |= cursorHome(cur);
521 case LFUN_LINE_END_SELECT:
522 needsUpdate |= cur.selHandle(cmd.action == LFUN_LINE_END_SELECT);
523 needsUpdate |= cursorEnd(cur);
526 case LFUN_WORD_FORWARD:
527 case LFUN_WORD_FORWARD_SELECT:
528 needsUpdate |= cur.selHandle(cmd.action == LFUN_WORD_FORWARD_SELECT);
529 if (isRTL(*cur.bv().buffer(), cur.paragraph()))
530 needsUpdate |= cursorLeftOneWord(cur);
532 needsUpdate |= cursorRightOneWord(cur);
535 case LFUN_WORD_BACKWARD:
536 case LFUN_WORD_BACKWARD_SELECT:
537 needsUpdate |= cur.selHandle(cmd.action == LFUN_WORD_BACKWARD_SELECT);
538 if (isRTL(*cur.bv().buffer(), cur.paragraph()))
539 needsUpdate |= cursorRightOneWord(cur);
541 needsUpdate |= cursorLeftOneWord(cur);
544 case LFUN_WORD_SELECT: {
545 selectWord(cur, WHOLE_WORD);
546 finishChange(cur, true);
550 case LFUN_BREAK_LINE: {
551 // Not allowed by LaTeX (labels or empty par)
552 if (cur.pos() > cur.paragraph().beginOfBody()) {
553 cap::replaceSelection(cur);
554 cur.insert(new InsetNewline);
556 moveCursor(cur, false);
561 case LFUN_CHAR_DELETE_FORWARD:
562 if (!cur.selection()) {
563 if (cur.pos() == cur.paragraph().size())
564 // Par boundary, force full-screen update
565 singleParUpdate = false;
566 needsUpdate |= erase(cur);
568 // It is possible to make it a lot faster still
569 // just comment out the line below...
571 cutSelection(cur, true, false);
572 singleParUpdate = false;
574 moveCursor(cur, false);
577 case LFUN_DELETE_FORWARD_SKIP:
578 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
579 if (!cur.selection()) {
580 if (cur.pos() == cur.lastpos()) {
587 cutSelection(cur, true, false);
592 case LFUN_CHAR_DELETE_BACKWARD:
593 if (!cur.selection()) {
594 if (bv->getIntl().getTransManager().backspace()) {
595 // Par boundary, full-screen update
597 singleParUpdate = false;
598 needsUpdate |= backspace(cur);
600 // It is possible to make it a lot faster still
601 // just comment out the line below...
604 cutSelection(cur, true, false);
605 singleParUpdate = false;
610 case LFUN_DELETE_BACKWARD_SKIP:
611 // Reverse the effect of LFUN_BREAK_PARAGRAPH_SKIP.
612 if (!cur.selection()) {
616 //CursorSlice cur = cursor();
620 cutSelection(cur, true, false);
624 case LFUN_BREAK_PARAGRAPH:
625 cap::replaceSelection(cur);
626 breakParagraph(cur, 0);
631 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
632 cap::replaceSelection(cur);
633 breakParagraph(cur, 1);
638 case LFUN_BREAK_PARAGRAPH_SKIP: {
639 // When at the beginning of a paragraph, remove
640 // indentation. Otherwise, do the same as LFUN_BREAK_PARAGRAPH.
641 cap::replaceSelection(cur);
643 cur.paragraph().params().labelWidthString(docstring());
645 breakParagraph(cur, 0);
651 case LFUN_PARAGRAPH_SPACING: {
652 Paragraph & par = cur.paragraph();
653 Spacing::Space cur_spacing = par.params().spacing().getSpace();
654 string cur_value = "1.0";
655 if (cur_spacing == Spacing::Other)
656 cur_value = par.params().spacing().getValueAsString();
658 istringstream is(to_utf8(cmd.argument()));
661 Spacing::Space new_spacing = cur_spacing;
662 string new_value = cur_value;
664 lyxerr << "Missing argument to `paragraph-spacing'"
666 } else if (tmp == "single") {
667 new_spacing = Spacing::Single;
668 } else if (tmp == "onehalf") {
669 new_spacing = Spacing::Onehalf;
670 } else if (tmp == "double") {
671 new_spacing = Spacing::Double;
672 } else if (tmp == "other") {
673 new_spacing = Spacing::Other;
674 string tmpval = "0.0";
676 lyxerr << "new_value = " << tmpval << endl;
679 } else if (tmp == "default") {
680 new_spacing = Spacing::Default;
682 lyxerr << to_utf8(_("Unknown spacing argument: "))
683 << to_utf8(cmd.argument()) << endl;
685 if (cur_spacing != new_spacing || cur_value != new_value)
686 par.params().spacing(Spacing(new_spacing, new_value));
690 case LFUN_INSET_INSERT: {
692 InsetBase * inset = createInset(bv, cmd);
694 insertInset(cur, inset);
700 case LFUN_INSET_DISSOLVE:
701 needsUpdate |= dissolveInset(cur);
704 case LFUN_INSET_SETTINGS:
705 cur.inset().showInsetDialog(bv);
708 case LFUN_SPACE_INSERT:
709 if (cur.paragraph().layout()->free_spacing)
710 insertChar(cur, ' ');
712 doInsertInset(cur, this, cmd, false, false);
715 moveCursor(cur, false);
718 case LFUN_HYPHENATION_POINT_INSERT:
719 specialChar(cur, InsetSpecialChar::HYPHENATION);
722 case LFUN_LIGATURE_BREAK_INSERT:
723 specialChar(cur, InsetSpecialChar::LIGATURE_BREAK);
726 case LFUN_DOTS_INSERT:
727 specialChar(cur, InsetSpecialChar::LDOTS);
730 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
731 specialChar(cur, InsetSpecialChar::END_OF_SENTENCE);
734 case LFUN_MENU_SEPARATOR_INSERT:
735 specialChar(cur, InsetSpecialChar::MENU_SEPARATOR);
738 case LFUN_WORD_UPCASE:
739 changeCase(cur, LyXText::text_uppercase);
742 case LFUN_WORD_LOWCASE:
743 changeCase(cur, LyXText::text_lowercase);
746 case LFUN_WORD_CAPITALIZE:
747 changeCase(cur, LyXText::text_capitalization);
750 case LFUN_CHARS_TRANSPOSE:
755 cur.message(_("Paste"));
756 cap::replaceSelection(cur);
757 if (isStrUnsignedInt(to_utf8(cmd.argument())))
758 pasteSelection(cur, bv->buffer()->errorList("Paste"),
759 convert<unsigned int>(to_utf8(cmd.argument())));
761 pasteSelection(cur, bv->buffer()->errorList("Paste"),
763 bv->buffer()->errors("Paste");
764 cur.clearSelection(); // bug 393
770 cutSelection(cur, true, true);
771 cur.message(_("Cut"));
776 cur.message(_("Copy"));
779 case LFUN_SERVER_GET_XY:
780 cur.message(from_utf8(
781 convert<string>(cursorX(cur.buffer(), cur.top(), cur.boundary()))
782 + ' ' + convert<string>(cursorY(cur.top(), cur.boundary()))));
785 case LFUN_SERVER_SET_XY: {
788 istringstream is(to_utf8(cmd.argument()));
791 lyxerr << "SETXY: Could not parse coordinates in '"
792 << to_utf8(cmd.argument()) << std::endl;
794 setCursorFromCoordinates(cur, x, y);
798 case LFUN_SERVER_GET_FONT:
799 if (current_font.shape() == LyXFont::ITALIC_SHAPE)
800 cur.message(from_ascii("E"));
801 else if (current_font.shape() == LyXFont::SMALLCAPS_SHAPE)
802 cur.message(from_ascii("N"));
804 cur.message(from_ascii("0"));
807 case LFUN_SERVER_GET_LAYOUT:
808 cur.message(from_utf8(cur.paragraph().layout()->name()));
812 lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) "
813 << to_utf8(cmd.argument()) << endl;
815 // This is not the good solution to the empty argument
816 // problem, but it will hopefully suffice for 1.2.0.
817 // The correct solution would be to augument the
818 // function list/array with information about what
819 // functions needs arguments and their type.
820 if (cmd.argument().empty()) {
821 cur.errorMessage(_("LyX function 'layout' needs an argument."));
825 // Derive layout number from given argument (string)
826 // and current buffer's textclass (number)
827 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
828 bool hasLayout = tclass.hasLayout(to_utf8(cmd.argument()));
829 string layout = to_utf8(cmd.argument());
831 // If the entry is obsolete, use the new one instead.
833 string const & obs = tclass[layout]->obsoleted_by();
839 cur.errorMessage(from_utf8(N_("Layout ")) + cmd.argument() +
840 from_utf8(N_(" not known")));
844 bool change_layout = (current_layout != layout);
846 if (!change_layout && cur.selection() &&
847 cur.selBegin().pit() != cur.selEnd().pit())
849 pit_type spit = cur.selBegin().pit();
850 pit_type epit = cur.selEnd().pit() + 1;
851 while (spit != epit) {
852 if (pars_[spit].layout()->name() != current_layout) {
853 change_layout = true;
861 current_layout = layout;
862 setLayout(cur, layout);
863 // inform the GUI that the layout has changed.
864 bv->layoutChanged(layout);
870 case LFUN_CLIPBOARD_PASTE: {
871 cur.clearSelection();
872 docstring const clip = theClipboard().get();
875 if (cmd.argument() == "paragraph")
876 insertStringAsParagraphs(cur, clip);
878 insertStringAsLines(cur, clip);
883 case LFUN_PRIMARY_SELECTION_PASTE: {
884 cur.clearSelection();
885 docstring const clip = theSelection().get();
888 if (cmd.argument() == "paragraph")
889 insertStringAsParagraphs(cur, clip);
891 insertStringAsLines(cur, clip);
896 case LFUN_UNICODE_INSERT: {
897 if (cmd.argument().empty())
899 docstring hexstring = cmd.argument();
900 if (lyx::support::isHex(hexstring)) {
901 char_type c = lyx::support::hexToInt(hexstring);
902 if (c > 32 && c < 0x10ffff) {
903 lyxerr << "Inserting c: " << c << endl;
904 docstring s = docstring(1, c);
905 lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, s));
911 case LFUN_QUOTE_INSERT: {
912 cap::replaceSelection(cur);
913 Paragraph & par = cur.paragraph();
914 pos_type pos = cur.pos();
918 else if (cur.prevInset() && cur.prevInset()->isSpace())
921 c = par.getChar(pos - 1);
923 LyXLayout_ptr const & style = par.layout();
925 BufferParams const & bufparams = bv->buffer()->params();
926 if (!style->pass_thru
927 && par.getFontSettings(bufparams, pos).language()->lang() != "hebrew") {
928 string arg = to_utf8(cmd.argument());
930 cur.insert(new InsetQuotes(c,
931 bufparams.quotes_language,
932 InsetQuotes::SingleQ));
934 cur.insert(new InsetQuotes(c,
935 bufparams.quotes_language,
936 InsetQuotes::DoubleQ));
940 lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, "\""));
944 case LFUN_DATE_INSERT:
945 if (cmd.argument().empty())
946 lyx::dispatch(FuncRequest(LFUN_SELF_INSERT,
947 formatted_time(current_time())));
949 lyx::dispatch(FuncRequest(LFUN_SELF_INSERT,
950 formatted_time(current_time(), to_utf8(cmd.argument()))));
953 case LFUN_MOUSE_TRIPLE:
954 if (cmd.button() == mouse_button::button1) {
960 theSelection().haveSelection(cur.selection());
964 case LFUN_MOUSE_DOUBLE:
965 if (cmd.button() == mouse_button::button1) {
966 selectWord(cur, WHOLE_WORD_STRICT);
968 theSelection().haveSelection(cur.selection());
972 // Single-click on work area
973 case LFUN_MOUSE_PRESS: {
974 // Right click on a footnote flag opens float menu
975 if (cmd.button() == mouse_button::button3)
976 cur.clearSelection();
978 // Middle button press pastes if we have a selection
979 // We do this here as if the selection was inside an inset
980 // it could get cleared on the unlocking of the inset so
981 // we have to check this first
982 bool paste_internally = false;
983 if (cmd.button() == mouse_button::button2 && cur.selection()) {
984 lyx::dispatch(FuncRequest(LFUN_COPY));
985 paste_internally = true;
988 bv->mouseSetCursor(cur);
990 // Insert primary selection with middle mouse
991 // if there is a local selection in the current buffer,
993 if (cmd.button() == mouse_button::button2) {
994 if (paste_internally)
995 lyx::dispatch(FuncRequest(LFUN_PASTE));
997 lyx::dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph"));
1003 case LFUN_MOUSE_MOTION: {
1004 // Only use motion with button 1
1005 //if (cmd.button() != mouse_button::button1)
1008 // ignore motions deeper nested than the real anchor
1009 LCursor & bvcur = cur.bv().cursor();
1010 if (bvcur.anchor_.hasPart(cur)) {
1011 CursorSlice old = bvcur.top();
1013 int const wh = bv->workHeight();
1014 int const y = std::max(0, std::min(wh - 1, cmd.y));
1016 setCursorFromCoordinates(cur, cmd.x, y);
1017 cur.x_target() = cmd.x;
1022 // This is to allow jumping over large insets
1023 if (cur.top() == old) {
1030 if (cur.top() == old)
1033 // don't set anchor_
1034 bvcur.setCursor(cur);
1035 bvcur.selection() = true;
1036 //lyxerr << "MOTION: " << bv->cursor() << endl;
1044 case LFUN_MOUSE_RELEASE: {
1045 if (cmd.button() == mouse_button::button2)
1049 if (cmd.button() == mouse_button::button1)
1050 theSelection().haveSelection(cur.selection());
1056 case LFUN_SELF_INSERT: {
1057 if (cmd.argument().empty())
1060 // Automatically delete the currently selected
1061 // text and replace it with what is being
1062 // typed in now. Depends on lyxrc settings
1063 // "auto_region_delete", which defaults to
1066 if (lyxrc.auto_region_delete) {
1067 if (cur.selection())
1068 cutSelection(cur, false, false);
1069 theSelection().haveSelection(false);
1072 cur.clearSelection();
1073 LyXFont const old_font = real_current_font;
1075 docstring::const_iterator cit = cmd.argument().begin();
1076 docstring::const_iterator end = cmd.argument().end();
1077 for (; cit != end; ++cit)
1079 bv->getIntl().getTransManager().
1080 translateAndInsert(*cit, this);
1082 insertChar(bv->cursor(), *cit);
1086 moveCursor(cur, false);
1090 case LFUN_URL_INSERT: {
1091 InsetCommandParams p("url");
1092 string const data = InsetCommandMailer::params2string("url", p);
1093 bv->showInsetDialog("url", data, 0);
1097 case LFUN_HTML_INSERT: {
1098 InsetCommandParams p("htmlurl");
1099 string const data = InsetCommandMailer::params2string("url", p);
1100 bv->showInsetDialog("url", data, 0);
1104 case LFUN_LABEL_INSERT: {
1105 InsetCommandParams p("label");
1106 // Try to generate a valid label
1107 p["name"] = (cmd.argument().empty()) ?
1108 cur.getPossibleLabel() :
1110 string const data = InsetCommandMailer::params2string("label", p);
1112 if (cmd.argument().empty()) {
1113 bv->showInsetDialog("label", data, 0);
1115 FuncRequest fr(LFUN_INSET_INSERT, data);
1123 case LFUN_LIST_INSERT:
1124 case LFUN_THEOREM_INSERT:
1125 case LFUN_CAPTION_INSERT:
1127 case LFUN_NOTE_INSERT:
1128 case LFUN_CHARSTYLE_INSERT:
1129 case LFUN_BOX_INSERT:
1130 case LFUN_BRANCH_INSERT:
1131 case LFUN_BIBITEM_INSERT:
1132 case LFUN_ERT_INSERT:
1133 case LFUN_FOOTNOTE_INSERT:
1134 case LFUN_MARGINALNOTE_INSERT:
1135 case LFUN_OPTIONAL_INSERT:
1136 case LFUN_ENVIRONMENT_INSERT:
1137 // Open the inset, and move the current selection
1139 doInsertInset(cur, this, cmd, true, true);
1143 case LFUN_TABULAR_INSERT:
1144 // if there were no arguments, just open the dialog
1145 if (doInsertInset(cur, this, cmd, false, true))
1148 bv->showDialog("tabularcreate");
1152 case LFUN_FLOAT_INSERT:
1153 case LFUN_FLOAT_WIDE_INSERT:
1154 case LFUN_WRAP_INSERT:
1155 doInsertInset(cur, this, cmd, true, true);
1157 // FIXME: the "Caption" name should not be hardcoded,
1158 // but given by the float definition.
1159 cur.dispatch(FuncRequest(LFUN_LAYOUT, "Caption"));
1162 case LFUN_INDEX_INSERT:
1163 case LFUN_NOMENCL_INSERT: {
1164 InsetBase * inset = createInset(&cur.bv(), cmd);
1169 cur.clearSelection();
1170 insertInset(cur, inset);
1171 inset->edit(cur, true);
1172 // Show the dialog for the nomenclature entry, since the
1173 // description entry still needs to be filled in.
1174 if (cmd.action == LFUN_NOMENCL_INSERT)
1175 InsetCommandMailer("nomenclature",
1176 *reinterpret_cast<InsetCommand *>(inset)).showDialog(&cur.bv());
1181 case LFUN_INDEX_PRINT:
1182 case LFUN_NOMENCL_PRINT:
1183 case LFUN_TOC_INSERT:
1184 case LFUN_HFILL_INSERT:
1185 case LFUN_LINE_INSERT:
1186 case LFUN_PAGEBREAK_INSERT:
1188 doInsertInset(cur, this, cmd, false, false);
1192 case LFUN_DEPTH_DECREMENT:
1193 changeDepth(cur, DEC_DEPTH);
1196 case LFUN_DEPTH_INCREMENT:
1197 changeDepth(cur, INC_DEPTH);
1200 case LFUN_MATH_DISPLAY:
1201 mathDispatch(cur, cmd, true);
1204 case LFUN_MATH_IMPORT_SELECTION:
1205 case LFUN_MATH_MODE:
1206 if (cmd.argument() == "on")
1207 // don't pass "on" as argument
1208 mathDispatch(cur, FuncRequest(LFUN_MATH_MODE), false);
1210 mathDispatch(cur, cmd, false);
1213 case LFUN_MATH_MACRO:
1214 if (cmd.argument().empty())
1215 cur.errorMessage(from_utf8(N_("Missing argument")));
1217 string s = to_utf8(cmd.argument());
1218 string const s1 = token(s, ' ', 1);
1219 int const nargs = s1.empty() ? 0 : convert<int>(s1);
1220 string const s2 = token(s, ' ', 2);
1221 string const type = s2.empty() ? "newcommand" : s2;
1222 cur.insert(new MathMacroTemplate(from_utf8(token(s, ' ', 0)), nargs, from_utf8(type)));
1223 //cur.nextInset()->edit(cur, true);
1227 // passthrough hat and underscore outside mathed:
1228 case LFUN_MATH_SUBSCRIPT:
1229 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "_"), false);
1231 case LFUN_MATH_SUPERSCRIPT:
1232 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "^"), false);
1235 case LFUN_MATH_INSERT:
1236 case LFUN_MATH_MATRIX:
1237 case LFUN_MATH_DELIM:
1238 case LFUN_MATH_BIGDELIM: {
1239 cur.insert(new InsetMathHull(hullSimple));
1240 cur.dispatch(FuncRequest(LFUN_CHAR_FORWARD));
1245 case LFUN_FONT_EMPH: {
1246 LyXFont font(LyXFont::ALL_IGNORE);
1247 font.setEmph(LyXFont::TOGGLE);
1248 toggleAndShow(cur, this, font);
1252 case LFUN_FONT_BOLD: {
1253 LyXFont font(LyXFont::ALL_IGNORE);
1254 font.setSeries(LyXFont::BOLD_SERIES);
1255 toggleAndShow(cur, this, font);
1259 case LFUN_FONT_NOUN: {
1260 LyXFont font(LyXFont::ALL_IGNORE);
1261 font.setNoun(LyXFont::TOGGLE);
1262 toggleAndShow(cur, this, font);
1266 case LFUN_FONT_CODE: {
1267 LyXFont font(LyXFont::ALL_IGNORE);
1268 font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
1269 toggleAndShow(cur, this, font);
1273 case LFUN_FONT_SANS: {
1274 LyXFont font(LyXFont::ALL_IGNORE);
1275 font.setFamily(LyXFont::SANS_FAMILY);
1276 toggleAndShow(cur, this, font);
1280 case LFUN_FONT_ROMAN: {
1281 LyXFont font(LyXFont::ALL_IGNORE);
1282 font.setFamily(LyXFont::ROMAN_FAMILY);
1283 toggleAndShow(cur, this, font);
1287 case LFUN_FONT_DEFAULT: {
1288 LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
1289 toggleAndShow(cur, this, font);
1293 case LFUN_FONT_UNDERLINE: {
1294 LyXFont font(LyXFont::ALL_IGNORE);
1295 font.setUnderbar(LyXFont::TOGGLE);
1296 toggleAndShow(cur, this, font);
1300 case LFUN_FONT_SIZE: {
1301 LyXFont font(LyXFont::ALL_IGNORE);
1302 font.setLyXSize(to_utf8(cmd.argument()));
1303 toggleAndShow(cur, this, font);
1307 case LFUN_LANGUAGE: {
1308 Language const * lang = languages.getLanguage(to_utf8(cmd.argument()));
1311 LyXFont font(LyXFont::ALL_IGNORE);
1312 font.setLanguage(lang);
1313 toggleAndShow(cur, this, font);
1318 case LFUN_FONT_FREE_APPLY:
1319 toggleAndShow(cur, this, freefont, toggleall);
1320 cur.message(_("Character set"));
1323 // Set the freefont using the contents of \param data dispatched from
1324 // the frontends and apply it at the current cursor location.
1325 case LFUN_FONT_FREE_UPDATE: {
1328 if (bv_funcs::string2font(to_utf8(cmd.argument()), font, toggle)) {
1331 toggleAndShow(cur, this, freefont, toggleall);
1332 cur.message(_("Character set"));
1337 case LFUN_FINISHED_LEFT:
1338 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_LEFT:\n" << cur << endl;
1341 case LFUN_FINISHED_RIGHT:
1342 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_RIGHT:\n" << cur << endl;
1346 case LFUN_FINISHED_UP:
1347 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_UP:\n" << cur << endl;
1351 case LFUN_FINISHED_DOWN:
1352 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_DOWN:\n" << cur << endl;
1356 case LFUN_LAYOUT_PARAGRAPH: {
1358 params2string(cur.paragraph(), data);
1359 data = "show\n" + data;
1360 bv->showDialogWithData("paragraph", data);
1364 case LFUN_PARAGRAPH_UPDATE: {
1366 params2string(cur.paragraph(), data);
1368 // Will the paragraph accept changes from the dialog?
1369 bool const accept = !cur.inset().forceDefaultParagraphs(cur.idx());
1371 data = "update " + convert<string>(accept) + '\n' + data;
1372 bv->updateDialog("paragraph", data);
1376 case LFUN_ACCENT_UMLAUT:
1377 case LFUN_ACCENT_CIRCUMFLEX:
1378 case LFUN_ACCENT_GRAVE:
1379 case LFUN_ACCENT_ACUTE:
1380 case LFUN_ACCENT_TILDE:
1381 case LFUN_ACCENT_CEDILLA:
1382 case LFUN_ACCENT_MACRON:
1383 case LFUN_ACCENT_DOT:
1384 case LFUN_ACCENT_UNDERDOT:
1385 case LFUN_ACCENT_UNDERBAR:
1386 case LFUN_ACCENT_CARON:
1387 case LFUN_ACCENT_SPECIAL_CARON:
1388 case LFUN_ACCENT_BREVE:
1389 case LFUN_ACCENT_TIE:
1390 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1391 case LFUN_ACCENT_CIRCLE:
1392 case LFUN_ACCENT_OGONEK:
1393 theLyXFunc().handleKeyFunc(cmd.action);
1394 if (!cmd.argument().empty())
1395 // FIXME: Are all these characters encoded in one byte in utf8?
1396 bv->getIntl().getTransManager()
1397 .translateAndInsert(cmd.argument()[0], this, cur);
1400 case LFUN_FLOAT_LIST: {
1401 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
1402 if (tclass.floats().typeExist(to_utf8(cmd.argument()))) {
1403 // not quite sure if we want this...
1405 cur.clearSelection();
1406 breakParagraph(cur);
1408 if (cur.lastpos() != 0) {
1410 breakParagraph(cur);
1413 setLayout(cur, tclass.defaultLayoutName());
1414 setParagraph(cur, Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
1415 insertInset(cur, new InsetFloatList(to_utf8(cmd.argument())));
1418 lyxerr << "Non-existent float type: "
1419 << to_utf8(cmd.argument()) << endl;
1424 case LFUN_CHANGE_ACCEPT: {
1429 case LFUN_CHANGE_REJECT: {
1434 case LFUN_THESAURUS_ENTRY: {
1435 docstring arg = cmd.argument();
1437 arg = cur.selectionAsString(false);
1439 if (arg.size() > 100 || arg.empty()) {
1440 // Get word or selection
1441 selectWordWhenUnderCursor(cur, WHOLE_WORD);
1442 arg = cur.selectionAsString(false);
1445 bv->showDialogWithData("thesaurus", to_utf8(arg));
1449 case LFUN_PARAGRAPH_PARAMS_APPLY: {
1450 // Given data, an encoding of the ParagraphParameters
1451 // generated in the Paragraph dialog, this function sets
1452 // the current paragraph appropriately.
1453 istringstream is(to_utf8(cmd.argument()));
1456 ParagraphParameters params;
1462 to_ascii(params.labelWidthString()),
1464 cur.message(_("Paragraph layout set"));
1469 if (cur.selection()) {
1470 cur.selection() = false;
1473 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
1478 lyxerr[Debug::ACTION]
1479 << BOOST_CURRENT_FUNCTION
1480 << ": Command " << cmd
1481 << " not DISPATCHED by LyXText" << endl;
1486 needsUpdate |= (cur.pos() != cur.lastpos()) && cur.selection();
1487 if (singleParUpdate)
1488 // Inserting characters does not change par height
1489 if (cur.bottom().paragraph().dim().height()
1490 == olddim.height()) {
1491 // if so, update _only_ this paragraph
1492 cur.updateFlags(Update::SinglePar |
1494 Update::MultiParSel);
1499 && &oldTopSlice.inset() == &cur.inset()
1500 && oldTopSlice.idx() == cur.idx()
1502 && !cur.selection())
1505 cur.updateFlags(Update::Force | Update::FitCursor);
1509 bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
1510 FuncStatus & flag) const
1512 BOOST_ASSERT(cur.text() == this);
1514 LyXFont const & font = real_current_font;
1516 InsetBase::Code code = InsetBase::NO_CODE;
1518 switch (cmd.action) {
1520 case LFUN_DEPTH_DECREMENT:
1521 enable = changeDepthAllowed(cur, DEC_DEPTH);
1524 case LFUN_DEPTH_INCREMENT:
1525 enable = changeDepthAllowed(cur, INC_DEPTH);
1529 flag.setOnOff(cur.paragraph().params().startOfAppendix());
1532 case LFUN_BIBITEM_INSERT:
1533 enable = (cur.paragraph().layout()->labeltype == LABEL_BIBLIO);
1536 case LFUN_DIALOG_SHOW_NEW_INSET:
1537 if (cmd.argument() == "bibitem")
1538 code = InsetBase::BIBITEM_CODE;
1539 else if (cmd.argument() == "bibtex")
1540 code = InsetBase::BIBTEX_CODE;
1541 else if (cmd.argument() == "box")
1542 code = InsetBase::BOX_CODE;
1543 else if (cmd.argument() == "branch")
1544 code = InsetBase::BRANCH_CODE;
1545 else if (cmd.argument() == "citation")
1546 code = InsetBase::CITE_CODE;
1547 else if (cmd.argument() == "ert")
1548 code = InsetBase::ERT_CODE;
1549 else if (cmd.argument() == "external")
1550 code = InsetBase::EXTERNAL_CODE;
1551 else if (cmd.argument() == "float")
1552 code = InsetBase::FLOAT_CODE;
1553 else if (cmd.argument() == "graphics")
1554 code = InsetBase::GRAPHICS_CODE;
1555 else if (cmd.argument() == "include")
1556 code = InsetBase::INCLUDE_CODE;
1557 else if (cmd.argument() == "index")
1558 code = InsetBase::INDEX_CODE;
1559 else if (cmd.argument() == "nomenclature")
1560 code = InsetBase::NOMENCL_CODE;
1561 else if (cmd.argument() == "label")
1562 code = InsetBase::LABEL_CODE;
1563 else if (cmd.argument() == "note")
1564 code = InsetBase::NOTE_CODE;
1565 else if (cmd.argument() == "ref")
1566 code = InsetBase::REF_CODE;
1567 else if (cmd.argument() == "toc")
1568 code = InsetBase::TOC_CODE;
1569 else if (cmd.argument() == "url")
1570 code = InsetBase::URL_CODE;
1571 else if (cmd.argument() == "vspace")
1572 code = InsetBase::VSPACE_CODE;
1573 else if (cmd.argument() == "wrap")
1574 code = InsetBase::WRAP_CODE;
1577 case LFUN_ERT_INSERT:
1578 code = InsetBase::ERT_CODE;
1580 case LFUN_FOOTNOTE_INSERT:
1581 code = InsetBase::FOOT_CODE;
1583 case LFUN_TABULAR_INSERT:
1584 code = InsetBase::TABULAR_CODE;
1586 case LFUN_MARGINALNOTE_INSERT:
1587 code = InsetBase::MARGIN_CODE;
1589 case LFUN_FLOAT_INSERT:
1590 case LFUN_FLOAT_WIDE_INSERT:
1591 code = InsetBase::FLOAT_CODE;
1593 case LFUN_WRAP_INSERT:
1594 code = InsetBase::WRAP_CODE;
1596 case LFUN_FLOAT_LIST:
1597 code = InsetBase::FLOAT_LIST_CODE;
1600 case LFUN_LIST_INSERT:
1601 code = InsetBase::LIST_CODE;
1603 case LFUN_THEOREM_INSERT:
1604 code = InsetBase::THEOREM_CODE;
1607 case LFUN_CAPTION_INSERT:
1608 code = InsetBase::CAPTION_CODE;
1610 case LFUN_NOTE_INSERT:
1611 code = InsetBase::NOTE_CODE;
1613 case LFUN_CHARSTYLE_INSERT:
1614 code = InsetBase::CHARSTYLE_CODE;
1615 if (cur.buffer().params().getLyXTextClass().charstyles().empty())
1618 case LFUN_BOX_INSERT:
1619 code = InsetBase::BOX_CODE;
1621 case LFUN_BRANCH_INSERT:
1622 code = InsetBase::BRANCH_CODE;
1623 if (cur.buffer().getMasterBuffer()->params().branchlist().empty())
1626 case LFUN_LABEL_INSERT:
1627 code = InsetBase::LABEL_CODE;
1629 case LFUN_OPTIONAL_INSERT:
1630 code = InsetBase::OPTARG_CODE;
1631 enable = numberOfOptArgs(cur.paragraph())
1632 < cur.paragraph().layout()->optionalargs;
1634 case LFUN_ENVIRONMENT_INSERT:
1635 code = InsetBase::BOX_CODE;
1637 case LFUN_INDEX_INSERT:
1638 code = InsetBase::INDEX_CODE;
1640 case LFUN_INDEX_PRINT:
1641 code = InsetBase::INDEX_PRINT_CODE;
1643 case LFUN_NOMENCL_INSERT:
1644 code = InsetBase::NOMENCL_CODE;
1646 case LFUN_NOMENCL_PRINT:
1647 code = InsetBase::NOMENCL_PRINT_CODE;
1649 case LFUN_TOC_INSERT:
1650 code = InsetBase::TOC_CODE;
1652 case LFUN_HTML_INSERT:
1653 case LFUN_URL_INSERT:
1654 code = InsetBase::URL_CODE;
1656 case LFUN_QUOTE_INSERT:
1657 // always allow this, since we will inset a raw quote
1658 // if an inset is not allowed.
1660 case LFUN_HYPHENATION_POINT_INSERT:
1661 case LFUN_LIGATURE_BREAK_INSERT:
1662 case LFUN_HFILL_INSERT:
1663 case LFUN_MENU_SEPARATOR_INSERT:
1664 case LFUN_DOTS_INSERT:
1665 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
1666 code = InsetBase::SPECIALCHAR_CODE;
1668 case LFUN_SPACE_INSERT:
1669 // slight hack: we know this is allowed in math mode
1671 code = InsetBase::SPACE_CODE;
1674 case LFUN_INSET_MODIFY:
1675 // We need to disable this, because we may get called for a
1677 // InsetTabular::getStatus() -> InsetText::getStatus()
1678 // and we don't handle LFUN_INSET_MODIFY.
1682 case LFUN_FONT_EMPH:
1683 flag.setOnOff(font.emph() == LyXFont::ON);
1686 case LFUN_FONT_NOUN:
1687 flag.setOnOff(font.noun() == LyXFont::ON);
1690 case LFUN_FONT_BOLD:
1691 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
1694 case LFUN_FONT_SANS:
1695 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
1698 case LFUN_FONT_ROMAN:
1699 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
1702 case LFUN_FONT_CODE:
1703 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
1708 enable = cur.selection();
1712 enable = cap::numberOfSelections() > 0;
1715 case LFUN_PARAGRAPH_MOVE_UP:
1716 enable = cur.pit() > 0 && !cur.selection();
1719 case LFUN_PARAGRAPH_MOVE_DOWN:
1720 enable = cur.pit() < cur.lastpit() && !cur.selection();
1723 case LFUN_INSET_DISSOLVE:
1724 enable = !isMainText(*cur.bv().buffer()) && cur.inset().nargs() == 1;
1727 case LFUN_CHANGE_ACCEPT:
1728 case LFUN_CHANGE_REJECT:
1729 enable = true; // FIXME: Change tracking (MG)
1732 case LFUN_WORD_DELETE_FORWARD:
1733 case LFUN_WORD_DELETE_BACKWARD:
1734 case LFUN_LINE_DELETE:
1735 case LFUN_WORD_FORWARD:
1736 case LFUN_WORD_BACKWARD:
1737 case LFUN_CHAR_FORWARD:
1738 case LFUN_CHAR_FORWARD_SELECT:
1739 case LFUN_CHAR_BACKWARD:
1740 case LFUN_CHAR_BACKWARD_SELECT:
1742 case LFUN_UP_SELECT:
1744 case LFUN_DOWN_SELECT:
1745 case LFUN_PARAGRAPH_UP_SELECT:
1746 case LFUN_PARAGRAPH_DOWN_SELECT:
1747 case LFUN_SCREEN_UP_SELECT:
1748 case LFUN_SCREEN_DOWN_SELECT:
1749 case LFUN_LINE_BEGIN_SELECT:
1750 case LFUN_LINE_END_SELECT:
1751 case LFUN_WORD_FORWARD_SELECT:
1752 case LFUN_WORD_BACKWARD_SELECT:
1753 case LFUN_WORD_SELECT:
1754 case LFUN_PARAGRAPH_UP:
1755 case LFUN_PARAGRAPH_DOWN:
1756 case LFUN_SCREEN_UP:
1757 case LFUN_SCREEN_DOWN:
1758 case LFUN_LINE_BEGIN:
1760 case LFUN_BREAK_LINE:
1761 case LFUN_CHAR_DELETE_FORWARD:
1762 case LFUN_DELETE_FORWARD_SKIP:
1763 case LFUN_CHAR_DELETE_BACKWARD:
1764 case LFUN_DELETE_BACKWARD_SKIP:
1765 case LFUN_BREAK_PARAGRAPH:
1766 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
1767 case LFUN_BREAK_PARAGRAPH_SKIP:
1768 case LFUN_PARAGRAPH_SPACING:
1769 case LFUN_INSET_INSERT:
1770 case LFUN_WORD_UPCASE:
1771 case LFUN_WORD_LOWCASE:
1772 case LFUN_WORD_CAPITALIZE:
1773 case LFUN_CHARS_TRANSPOSE:
1774 case LFUN_SERVER_GET_XY:
1775 case LFUN_SERVER_SET_XY:
1776 case LFUN_SERVER_GET_FONT:
1777 case LFUN_SERVER_GET_LAYOUT:
1779 case LFUN_CLIPBOARD_PASTE:
1780 case LFUN_PRIMARY_SELECTION_PASTE:
1781 case LFUN_DATE_INSERT:
1782 case LFUN_SELF_INSERT:
1783 case LFUN_LINE_INSERT:
1784 case LFUN_PAGEBREAK_INSERT:
1785 case LFUN_MATH_DISPLAY:
1786 case LFUN_MATH_IMPORT_SELECTION:
1787 case LFUN_MATH_MODE:
1788 case LFUN_MATH_MACRO:
1789 case LFUN_MATH_MATRIX:
1790 case LFUN_MATH_DELIM:
1791 case LFUN_MATH_BIGDELIM:
1792 case LFUN_MATH_SUBSCRIPT:
1793 case LFUN_MATH_SUPERSCRIPT:
1794 case LFUN_FONT_DEFAULT:
1795 case LFUN_FONT_UNDERLINE:
1796 case LFUN_FONT_SIZE:
1798 case LFUN_FONT_FREE_APPLY:
1799 case LFUN_FONT_FREE_UPDATE:
1800 case LFUN_LAYOUT_PARAGRAPH:
1801 case LFUN_PARAGRAPH_UPDATE:
1802 case LFUN_ACCENT_UMLAUT:
1803 case LFUN_ACCENT_CIRCUMFLEX:
1804 case LFUN_ACCENT_GRAVE:
1805 case LFUN_ACCENT_ACUTE:
1806 case LFUN_ACCENT_TILDE:
1807 case LFUN_ACCENT_CEDILLA:
1808 case LFUN_ACCENT_MACRON:
1809 case LFUN_ACCENT_DOT:
1810 case LFUN_ACCENT_UNDERDOT:
1811 case LFUN_ACCENT_UNDERBAR:
1812 case LFUN_ACCENT_CARON:
1813 case LFUN_ACCENT_SPECIAL_CARON:
1814 case LFUN_ACCENT_BREVE:
1815 case LFUN_ACCENT_TIE:
1816 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1817 case LFUN_ACCENT_CIRCLE:
1818 case LFUN_ACCENT_OGONEK:
1819 case LFUN_THESAURUS_ENTRY:
1820 case LFUN_PARAGRAPH_PARAMS_APPLY:
1822 case LFUN_BUFFER_END:
1823 case LFUN_BUFFER_BEGIN:
1824 case LFUN_BUFFER_BEGIN_SELECT:
1825 case LFUN_BUFFER_END_SELECT:
1826 case LFUN_UNICODE_INSERT:
1827 // these are handled in our dispatch()
1835 if (code != InsetBase::NO_CODE
1836 && (cur.empty() || !cur.inset().insetAllowed(code)))
1839 flag.enabled(enable);