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()) ?
1109 from_utf8(cur.getPossibleLabel()) :
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 case LFUN_NOMENCL_INSERT: {
1165 InsetBase * inset = createInset(&cur.bv(), cmd);
1170 cur.clearSelection();
1171 insertInset(cur, inset);
1172 inset->edit(cur, true);
1173 // Show the dialog for the nomenclature entry, since the
1174 // description entry still needs to be filled in.
1175 if (cmd.action == LFUN_NOMENCL_INSERT)
1176 InsetCommandMailer("nomenclature",
1177 *reinterpret_cast<InsetCommand *>(inset)).showDialog(&cur.bv());
1182 case LFUN_INDEX_PRINT:
1183 case LFUN_NOMENCL_PRINT:
1184 case LFUN_TOC_INSERT:
1185 case LFUN_HFILL_INSERT:
1186 case LFUN_LINE_INSERT:
1187 case LFUN_PAGEBREAK_INSERT:
1189 doInsertInset(cur, this, cmd, false, false);
1193 case LFUN_DEPTH_DECREMENT:
1194 changeDepth(cur, DEC_DEPTH);
1197 case LFUN_DEPTH_INCREMENT:
1198 changeDepth(cur, INC_DEPTH);
1201 case LFUN_MATH_DISPLAY:
1202 mathDispatch(cur, cmd, true);
1205 case LFUN_MATH_IMPORT_SELECTION:
1206 case LFUN_MATH_MODE:
1207 if (cmd.argument() == "on")
1208 // don't pass "on" as argument
1209 mathDispatch(cur, FuncRequest(LFUN_MATH_MODE), false);
1211 mathDispatch(cur, cmd, false);
1214 case LFUN_MATH_MACRO:
1215 if (cmd.argument().empty())
1216 cur.errorMessage(from_utf8(N_("Missing argument")));
1218 string s = to_utf8(cmd.argument());
1219 string const s1 = token(s, ' ', 1);
1220 int const nargs = s1.empty() ? 0 : convert<int>(s1);
1221 string const s2 = token(s, ' ', 2);
1222 string const type = s2.empty() ? "newcommand" : s2;
1223 cur.insert(new MathMacroTemplate(from_utf8(token(s, ' ', 0)), nargs, from_utf8(type)));
1224 //cur.nextInset()->edit(cur, true);
1228 // passthrough hat and underscore outside mathed:
1229 case LFUN_MATH_SUBSCRIPT:
1230 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "_"), false);
1232 case LFUN_MATH_SUPERSCRIPT:
1233 mathDispatch(cur, FuncRequest(LFUN_SELF_INSERT, "^"), false);
1236 case LFUN_MATH_INSERT:
1237 case LFUN_MATH_MATRIX:
1238 case LFUN_MATH_DELIM:
1239 case LFUN_MATH_BIGDELIM: {
1240 cur.insert(new InsetMathHull(hullSimple));
1241 cur.dispatch(FuncRequest(LFUN_CHAR_FORWARD));
1246 case LFUN_FONT_EMPH: {
1247 LyXFont font(LyXFont::ALL_IGNORE);
1248 font.setEmph(LyXFont::TOGGLE);
1249 toggleAndShow(cur, this, font);
1253 case LFUN_FONT_BOLD: {
1254 LyXFont font(LyXFont::ALL_IGNORE);
1255 font.setSeries(LyXFont::BOLD_SERIES);
1256 toggleAndShow(cur, this, font);
1260 case LFUN_FONT_NOUN: {
1261 LyXFont font(LyXFont::ALL_IGNORE);
1262 font.setNoun(LyXFont::TOGGLE);
1263 toggleAndShow(cur, this, font);
1267 case LFUN_FONT_CODE: {
1268 LyXFont font(LyXFont::ALL_IGNORE);
1269 font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
1270 toggleAndShow(cur, this, font);
1274 case LFUN_FONT_SANS: {
1275 LyXFont font(LyXFont::ALL_IGNORE);
1276 font.setFamily(LyXFont::SANS_FAMILY);
1277 toggleAndShow(cur, this, font);
1281 case LFUN_FONT_ROMAN: {
1282 LyXFont font(LyXFont::ALL_IGNORE);
1283 font.setFamily(LyXFont::ROMAN_FAMILY);
1284 toggleAndShow(cur, this, font);
1288 case LFUN_FONT_DEFAULT: {
1289 LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
1290 toggleAndShow(cur, this, font);
1294 case LFUN_FONT_UNDERLINE: {
1295 LyXFont font(LyXFont::ALL_IGNORE);
1296 font.setUnderbar(LyXFont::TOGGLE);
1297 toggleAndShow(cur, this, font);
1301 case LFUN_FONT_SIZE: {
1302 LyXFont font(LyXFont::ALL_IGNORE);
1303 font.setLyXSize(to_utf8(cmd.argument()));
1304 toggleAndShow(cur, this, font);
1308 case LFUN_LANGUAGE: {
1309 Language const * lang = languages.getLanguage(to_utf8(cmd.argument()));
1312 LyXFont font(LyXFont::ALL_IGNORE);
1313 font.setLanguage(lang);
1314 toggleAndShow(cur, this, font);
1319 case LFUN_FONT_FREE_APPLY:
1320 toggleAndShow(cur, this, freefont, toggleall);
1321 cur.message(_("Character set"));
1324 // Set the freefont using the contents of \param data dispatched from
1325 // the frontends and apply it at the current cursor location.
1326 case LFUN_FONT_FREE_UPDATE: {
1329 if (bv_funcs::string2font(to_utf8(cmd.argument()), font, toggle)) {
1332 toggleAndShow(cur, this, freefont, toggleall);
1333 cur.message(_("Character set"));
1338 case LFUN_FINISHED_LEFT:
1339 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_LEFT:\n" << cur << endl;
1342 case LFUN_FINISHED_RIGHT:
1343 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_RIGHT:\n" << cur << endl;
1347 case LFUN_FINISHED_UP:
1348 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_UP:\n" << cur << endl;
1352 case LFUN_FINISHED_DOWN:
1353 lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_DOWN:\n" << cur << endl;
1357 case LFUN_LAYOUT_PARAGRAPH: {
1359 params2string(cur.paragraph(), data);
1360 data = "show\n" + data;
1361 bv->showDialogWithData("paragraph", data);
1365 case LFUN_PARAGRAPH_UPDATE: {
1367 params2string(cur.paragraph(), data);
1369 // Will the paragraph accept changes from the dialog?
1370 bool const accept = !cur.inset().forceDefaultParagraphs(cur.idx());
1372 data = "update " + convert<string>(accept) + '\n' + data;
1373 bv->updateDialog("paragraph", data);
1377 case LFUN_ACCENT_UMLAUT:
1378 case LFUN_ACCENT_CIRCUMFLEX:
1379 case LFUN_ACCENT_GRAVE:
1380 case LFUN_ACCENT_ACUTE:
1381 case LFUN_ACCENT_TILDE:
1382 case LFUN_ACCENT_CEDILLA:
1383 case LFUN_ACCENT_MACRON:
1384 case LFUN_ACCENT_DOT:
1385 case LFUN_ACCENT_UNDERDOT:
1386 case LFUN_ACCENT_UNDERBAR:
1387 case LFUN_ACCENT_CARON:
1388 case LFUN_ACCENT_SPECIAL_CARON:
1389 case LFUN_ACCENT_BREVE:
1390 case LFUN_ACCENT_TIE:
1391 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1392 case LFUN_ACCENT_CIRCLE:
1393 case LFUN_ACCENT_OGONEK:
1394 theLyXFunc().handleKeyFunc(cmd.action);
1395 if (!cmd.argument().empty())
1396 // FIXME: Are all these characters encoded in one byte in utf8?
1397 bv->getIntl().getTransManager()
1398 .translateAndInsert(cmd.argument()[0], this, cur);
1401 case LFUN_FLOAT_LIST: {
1402 LyXTextClass const & tclass = bv->buffer()->params().getLyXTextClass();
1403 if (tclass.floats().typeExist(to_utf8(cmd.argument()))) {
1404 // not quite sure if we want this...
1406 cur.clearSelection();
1407 breakParagraph(cur);
1409 if (cur.lastpos() != 0) {
1411 breakParagraph(cur);
1414 setLayout(cur, tclass.defaultLayoutName());
1415 setParagraph(cur, Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
1416 insertInset(cur, new InsetFloatList(to_utf8(cmd.argument())));
1419 lyxerr << "Non-existent float type: "
1420 << to_utf8(cmd.argument()) << endl;
1425 case LFUN_CHANGE_ACCEPT: {
1430 case LFUN_CHANGE_REJECT: {
1435 case LFUN_THESAURUS_ENTRY: {
1436 docstring arg = cmd.argument();
1438 arg = cur.selectionAsString(false);
1440 if (arg.size() > 100 || arg.empty()) {
1441 // Get word or selection
1442 selectWordWhenUnderCursor(cur, WHOLE_WORD);
1443 arg = cur.selectionAsString(false);
1446 bv->showDialogWithData("thesaurus", to_utf8(arg));
1450 case LFUN_PARAGRAPH_PARAMS_APPLY: {
1451 // Given data, an encoding of the ParagraphParameters
1452 // generated in the Paragraph dialog, this function sets
1453 // the current paragraph appropriately.
1454 istringstream is(to_utf8(cmd.argument()));
1457 ParagraphParameters params;
1463 to_ascii(params.labelWidthString()),
1465 cur.message(_("Paragraph layout set"));
1470 if (cur.selection()) {
1471 cur.selection() = false;
1474 cmd = FuncRequest(LFUN_FINISHED_RIGHT);
1479 lyxerr[Debug::ACTION]
1480 << BOOST_CURRENT_FUNCTION
1481 << ": Command " << cmd
1482 << " not DISPATCHED by LyXText" << endl;
1487 needsUpdate |= (cur.pos() != cur.lastpos()) && cur.selection();
1488 if (singleParUpdate)
1489 // Inserting characters does not change par height
1490 if (cur.bottom().paragraph().dim().height()
1491 == olddim.height()) {
1492 // if so, update _only_ this paragraph
1493 cur.updateFlags(Update::SinglePar |
1495 Update::MultiParSel);
1500 && &oldTopSlice.inset() == &cur.inset()
1501 && oldTopSlice.idx() == cur.idx()
1503 && !cur.selection())
1506 cur.updateFlags(Update::Force | Update::FitCursor);
1510 bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
1511 FuncStatus & flag) const
1513 BOOST_ASSERT(cur.text() == this);
1515 LyXFont const & font = real_current_font;
1517 InsetBase::Code code = InsetBase::NO_CODE;
1519 switch (cmd.action) {
1521 case LFUN_DEPTH_DECREMENT:
1522 enable = changeDepthAllowed(cur, DEC_DEPTH);
1525 case LFUN_DEPTH_INCREMENT:
1526 enable = changeDepthAllowed(cur, INC_DEPTH);
1530 flag.setOnOff(cur.paragraph().params().startOfAppendix());
1533 case LFUN_BIBITEM_INSERT:
1534 enable = (cur.paragraph().layout()->labeltype == LABEL_BIBLIO);
1537 case LFUN_DIALOG_SHOW_NEW_INSET:
1538 if (cmd.argument() == "bibitem")
1539 code = InsetBase::BIBITEM_CODE;
1540 else if (cmd.argument() == "bibtex")
1541 code = InsetBase::BIBTEX_CODE;
1542 else if (cmd.argument() == "box")
1543 code = InsetBase::BOX_CODE;
1544 else if (cmd.argument() == "branch")
1545 code = InsetBase::BRANCH_CODE;
1546 else if (cmd.argument() == "citation")
1547 code = InsetBase::CITE_CODE;
1548 else if (cmd.argument() == "ert")
1549 code = InsetBase::ERT_CODE;
1550 else if (cmd.argument() == "external")
1551 code = InsetBase::EXTERNAL_CODE;
1552 else if (cmd.argument() == "float")
1553 code = InsetBase::FLOAT_CODE;
1554 else if (cmd.argument() == "graphics")
1555 code = InsetBase::GRAPHICS_CODE;
1556 else if (cmd.argument() == "include")
1557 code = InsetBase::INCLUDE_CODE;
1558 else if (cmd.argument() == "index")
1559 code = InsetBase::INDEX_CODE;
1560 else if (cmd.argument() == "nomenclature")
1561 code = InsetBase::NOMENCL_CODE;
1562 else if (cmd.argument() == "label")
1563 code = InsetBase::LABEL_CODE;
1564 else if (cmd.argument() == "note")
1565 code = InsetBase::NOTE_CODE;
1566 else if (cmd.argument() == "ref")
1567 code = InsetBase::REF_CODE;
1568 else if (cmd.argument() == "toc")
1569 code = InsetBase::TOC_CODE;
1570 else if (cmd.argument() == "url")
1571 code = InsetBase::URL_CODE;
1572 else if (cmd.argument() == "vspace")
1573 code = InsetBase::VSPACE_CODE;
1574 else if (cmd.argument() == "wrap")
1575 code = InsetBase::WRAP_CODE;
1578 case LFUN_ERT_INSERT:
1579 code = InsetBase::ERT_CODE;
1581 case LFUN_FOOTNOTE_INSERT:
1582 code = InsetBase::FOOT_CODE;
1584 case LFUN_TABULAR_INSERT:
1585 code = InsetBase::TABULAR_CODE;
1587 case LFUN_MARGINALNOTE_INSERT:
1588 code = InsetBase::MARGIN_CODE;
1590 case LFUN_FLOAT_INSERT:
1591 case LFUN_FLOAT_WIDE_INSERT:
1592 code = InsetBase::FLOAT_CODE;
1594 case LFUN_WRAP_INSERT:
1595 code = InsetBase::WRAP_CODE;
1597 case LFUN_FLOAT_LIST:
1598 code = InsetBase::FLOAT_LIST_CODE;
1601 case LFUN_LIST_INSERT:
1602 code = InsetBase::LIST_CODE;
1604 case LFUN_THEOREM_INSERT:
1605 code = InsetBase::THEOREM_CODE;
1608 case LFUN_CAPTION_INSERT:
1609 code = InsetBase::CAPTION_CODE;
1611 case LFUN_NOTE_INSERT:
1612 code = InsetBase::NOTE_CODE;
1614 case LFUN_CHARSTYLE_INSERT:
1615 code = InsetBase::CHARSTYLE_CODE;
1616 if (cur.buffer().params().getLyXTextClass().charstyles().empty())
1619 case LFUN_BOX_INSERT:
1620 code = InsetBase::BOX_CODE;
1622 case LFUN_BRANCH_INSERT:
1623 code = InsetBase::BRANCH_CODE;
1624 if (cur.buffer().getMasterBuffer()->params().branchlist().empty())
1627 case LFUN_LABEL_INSERT:
1628 code = InsetBase::LABEL_CODE;
1630 case LFUN_OPTIONAL_INSERT:
1631 code = InsetBase::OPTARG_CODE;
1632 enable = numberOfOptArgs(cur.paragraph())
1633 < cur.paragraph().layout()->optionalargs;
1635 case LFUN_ENVIRONMENT_INSERT:
1636 code = InsetBase::BOX_CODE;
1638 case LFUN_INDEX_INSERT:
1639 code = InsetBase::INDEX_CODE;
1641 case LFUN_INDEX_PRINT:
1642 code = InsetBase::INDEX_PRINT_CODE;
1644 case LFUN_NOMENCL_INSERT:
1645 code = InsetBase::NOMENCL_CODE;
1647 case LFUN_NOMENCL_PRINT:
1648 code = InsetBase::NOMENCL_PRINT_CODE;
1650 case LFUN_TOC_INSERT:
1651 code = InsetBase::TOC_CODE;
1653 case LFUN_HTML_INSERT:
1654 case LFUN_URL_INSERT:
1655 code = InsetBase::URL_CODE;
1657 case LFUN_QUOTE_INSERT:
1658 // always allow this, since we will inset a raw quote
1659 // if an inset is not allowed.
1661 case LFUN_HYPHENATION_POINT_INSERT:
1662 case LFUN_LIGATURE_BREAK_INSERT:
1663 case LFUN_HFILL_INSERT:
1664 case LFUN_MENU_SEPARATOR_INSERT:
1665 case LFUN_DOTS_INSERT:
1666 case LFUN_END_OF_SENTENCE_PERIOD_INSERT:
1667 code = InsetBase::SPECIALCHAR_CODE;
1669 case LFUN_SPACE_INSERT:
1670 // slight hack: we know this is allowed in math mode
1672 code = InsetBase::SPACE_CODE;
1675 case LFUN_INSET_MODIFY:
1676 // We need to disable this, because we may get called for a
1678 // InsetTabular::getStatus() -> InsetText::getStatus()
1679 // and we don't handle LFUN_INSET_MODIFY.
1683 case LFUN_FONT_EMPH:
1684 flag.setOnOff(font.emph() == LyXFont::ON);
1687 case LFUN_FONT_NOUN:
1688 flag.setOnOff(font.noun() == LyXFont::ON);
1691 case LFUN_FONT_BOLD:
1692 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
1695 case LFUN_FONT_SANS:
1696 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
1699 case LFUN_FONT_ROMAN:
1700 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
1703 case LFUN_FONT_CODE:
1704 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
1709 enable = cur.selection();
1713 enable = cap::numberOfSelections() > 0;
1716 case LFUN_PARAGRAPH_MOVE_UP:
1717 enable = cur.pit() > 0 && !cur.selection();
1720 case LFUN_PARAGRAPH_MOVE_DOWN:
1721 enable = cur.pit() < cur.lastpit() && !cur.selection();
1724 case LFUN_INSET_DISSOLVE:
1725 enable = !isMainText(*cur.bv().buffer()) && cur.inset().nargs() == 1;
1728 case LFUN_CHANGE_ACCEPT:
1729 case LFUN_CHANGE_REJECT:
1730 enable = true; // FIXME: Change tracking (MG)
1733 case LFUN_WORD_DELETE_FORWARD:
1734 case LFUN_WORD_DELETE_BACKWARD:
1735 case LFUN_LINE_DELETE:
1736 case LFUN_WORD_FORWARD:
1737 case LFUN_WORD_BACKWARD:
1738 case LFUN_CHAR_FORWARD:
1739 case LFUN_CHAR_FORWARD_SELECT:
1740 case LFUN_CHAR_BACKWARD:
1741 case LFUN_CHAR_BACKWARD_SELECT:
1743 case LFUN_UP_SELECT:
1745 case LFUN_DOWN_SELECT:
1746 case LFUN_PARAGRAPH_UP_SELECT:
1747 case LFUN_PARAGRAPH_DOWN_SELECT:
1748 case LFUN_SCREEN_UP_SELECT:
1749 case LFUN_SCREEN_DOWN_SELECT:
1750 case LFUN_LINE_BEGIN_SELECT:
1751 case LFUN_LINE_END_SELECT:
1752 case LFUN_WORD_FORWARD_SELECT:
1753 case LFUN_WORD_BACKWARD_SELECT:
1754 case LFUN_WORD_SELECT:
1755 case LFUN_PARAGRAPH_UP:
1756 case LFUN_PARAGRAPH_DOWN:
1757 case LFUN_SCREEN_UP:
1758 case LFUN_SCREEN_DOWN:
1759 case LFUN_LINE_BEGIN:
1761 case LFUN_BREAK_LINE:
1762 case LFUN_CHAR_DELETE_FORWARD:
1763 case LFUN_DELETE_FORWARD_SKIP:
1764 case LFUN_CHAR_DELETE_BACKWARD:
1765 case LFUN_DELETE_BACKWARD_SKIP:
1766 case LFUN_BREAK_PARAGRAPH:
1767 case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
1768 case LFUN_BREAK_PARAGRAPH_SKIP:
1769 case LFUN_PARAGRAPH_SPACING:
1770 case LFUN_INSET_INSERT:
1771 case LFUN_WORD_UPCASE:
1772 case LFUN_WORD_LOWCASE:
1773 case LFUN_WORD_CAPITALIZE:
1774 case LFUN_CHARS_TRANSPOSE:
1775 case LFUN_SERVER_GET_XY:
1776 case LFUN_SERVER_SET_XY:
1777 case LFUN_SERVER_GET_FONT:
1778 case LFUN_SERVER_GET_LAYOUT:
1780 case LFUN_CLIPBOARD_PASTE:
1781 case LFUN_PRIMARY_SELECTION_PASTE:
1782 case LFUN_DATE_INSERT:
1783 case LFUN_SELF_INSERT:
1784 case LFUN_LINE_INSERT:
1785 case LFUN_PAGEBREAK_INSERT:
1786 case LFUN_MATH_DISPLAY:
1787 case LFUN_MATH_IMPORT_SELECTION:
1788 case LFUN_MATH_MODE:
1789 case LFUN_MATH_MACRO:
1790 case LFUN_MATH_MATRIX:
1791 case LFUN_MATH_DELIM:
1792 case LFUN_MATH_BIGDELIM:
1793 case LFUN_MATH_SUBSCRIPT:
1794 case LFUN_MATH_SUPERSCRIPT:
1795 case LFUN_FONT_DEFAULT:
1796 case LFUN_FONT_UNDERLINE:
1797 case LFUN_FONT_SIZE:
1799 case LFUN_FONT_FREE_APPLY:
1800 case LFUN_FONT_FREE_UPDATE:
1801 case LFUN_LAYOUT_PARAGRAPH:
1802 case LFUN_PARAGRAPH_UPDATE:
1803 case LFUN_ACCENT_UMLAUT:
1804 case LFUN_ACCENT_CIRCUMFLEX:
1805 case LFUN_ACCENT_GRAVE:
1806 case LFUN_ACCENT_ACUTE:
1807 case LFUN_ACCENT_TILDE:
1808 case LFUN_ACCENT_CEDILLA:
1809 case LFUN_ACCENT_MACRON:
1810 case LFUN_ACCENT_DOT:
1811 case LFUN_ACCENT_UNDERDOT:
1812 case LFUN_ACCENT_UNDERBAR:
1813 case LFUN_ACCENT_CARON:
1814 case LFUN_ACCENT_SPECIAL_CARON:
1815 case LFUN_ACCENT_BREVE:
1816 case LFUN_ACCENT_TIE:
1817 case LFUN_ACCENT_HUNGARIAN_UMLAUT:
1818 case LFUN_ACCENT_CIRCLE:
1819 case LFUN_ACCENT_OGONEK:
1820 case LFUN_THESAURUS_ENTRY:
1821 case LFUN_PARAGRAPH_PARAMS_APPLY:
1823 case LFUN_BUFFER_END:
1824 case LFUN_BUFFER_BEGIN:
1825 case LFUN_BUFFER_BEGIN_SELECT:
1826 case LFUN_BUFFER_END_SELECT:
1827 case LFUN_UNICODE_INSERT:
1828 // these are handled in our dispatch()
1836 if (code != InsetBase::NO_CODE
1837 && (cur.empty() || !cur.inset().insetAllowed(code)))
1840 flag.enabled(enable);