3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Alfredo Braunstein
7 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
9 * \author Angus Leeming
11 * \author André Pönitz
14 * \author Martin Vermeer
15 * \author Jürgen Vigna
17 * Full author contact details are available in file CREDITS.
25 #include "bufferlist.h"
27 #include "buffer_funcs.h"
28 #include "BufferView.h"
29 #include "lyxserver.h"
33 #include "LyXAction.h"
39 #include "trans_mgr.h"
42 #include "bufferview_funcs.h"
43 #include "frontends/LyXView.h"
44 #include "frontends/lyx_gui.h"
46 #include "FloatList.h"
50 #include "TextCache.h"
52 #include "undo_funcs.h"
53 #include "ParagraphParameters.h"
55 #include "insets/insetcommand.h"
56 #include "insets/insetexternal.h"
57 #include "insets/insettabular.h"
59 #include "mathed/formulamacro.h"
60 #include "mathed/math_cursor.h"
61 #include "mathed/math_inset.h"
63 #include "frontends/FileDialog.h"
64 #include "frontends/Dialogs.h"
65 #include "frontends/Toolbar.h"
66 #include "frontends/Menubar.h"
67 #include "frontends/Alert.h"
69 #include "graphics/GraphicsCache.h"
71 #include "support/lyxalgo.h"
72 #include "support/LAssert.h"
73 #include "support/filetools.h"
74 #include "support/FileInfo.h"
75 #include "support/forkedcontr.h"
76 #include "support/lstrings.h"
77 #include "support/tostr.h"
78 #include "support/path.h"
79 #include "support/path_defines.h"
80 #include "support/lyxfunctional.h"
90 using namespace lyx::support;
98 using std::back_inserter;
99 using namespace bv_funcs;
101 extern BufferList bufferlist;
102 extern LyXServer * lyxserver;
103 extern bool selection_possible;
105 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
108 extern tex_accent_struct get_accent(kb_action action);
110 extern void ShowLatexLog();
113 LyXFunc::LyXFunc(LyXView * o)
116 keyseq(toplevel_keymap.get(), toplevel_keymap.get()),
117 cancel_meta_seq(toplevel_keymap.get(), toplevel_keymap.get()),
118 meta_fake_bit(key_modifier::none)
123 void LyXFunc::moveCursorUpdate()
125 LyXText * lt = view()->text;
126 if (lt->selection.mark())
129 view()->switchKeyMap();
133 void LyXFunc::handleKeyFunc(kb_action action)
135 char c = encoded_last_key;
137 if (keyseq.length()) {
141 owner->getIntl().getTransManager()
142 .deadkey(c, get_accent(action).accent, view()->getLyXText());
143 // Need to clear, in case the minibuffer calls these
146 // copied verbatim from do_accent_char
148 view()->getLyXText()->selection.cursor = view()->getLyXText()->cursor;
152 void LyXFunc::processKeySym(LyXKeySymPtr keysym,
153 key_modifier::state state)
157 if (lyxerr.debugging(Debug::KEY)) {
158 lyxerr << "KeySym is "
159 << keysym->getSymbolName()
163 // Do nothing if we have nothing (JMarc)
164 if (!keysym->isOK()) {
165 lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
170 if (keysym->isModifier()) {
171 lyxerr[Debug::KEY] << "isModifier true" << endl;
175 Encoding const * encoding = view()->getEncoding();
177 encoded_last_key = keysym->getISOEncoded(encoding ? encoding->Name() : "");
179 // Do a one-deep top-level lookup for
180 // cancel and meta-fake keys. RVDK_PATCH_5
181 cancel_meta_seq.reset();
183 int action = cancel_meta_seq.addkey(keysym, state);
184 lyxerr[Debug::KEY] << "action first set to [" << action << ']' << endl;
186 // When not cancel or meta-fake, do the normal lookup.
187 // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
188 // Mostly, meta_fake_bit = key_modifier::none. RVDK_PATCH_5.
189 if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
190 // remove Caps Lock and Mod2 as a modifiers
191 action = keyseq.addkey(keysym, (state | meta_fake_bit));
192 lyxerr[Debug::KEY] << "action now set to ["
193 << action << ']' << endl;
196 // Dont remove this unless you know what you are doing.
197 meta_fake_bit = key_modifier::none;
199 // can this happen now ?
200 if (action == LFUN_NOACTION) {
201 action = LFUN_PREFIX;
204 if (lyxerr.debugging(Debug::KEY)) {
205 lyxerr << "Key [action="
207 << keyseq.print() << ']'
211 // already here we know if it any point in going further
212 // why not return already here if action == -1 and
213 // num_bytes == 0? (Lgb)
215 if (keyseq.length() > 1) {
216 owner->message(keyseq.print());
220 // Maybe user can only reach the key via holding down shift.
221 // Let's see. But only if shift is the only modifier
222 if (action == LFUN_UNKNOWN_ACTION && state == key_modifier::shift) {
223 lyxerr[Debug::KEY] << "Trying without shift" << endl;
224 action = keyseq.addkey(keysym, key_modifier::none);
225 lyxerr[Debug::KEY] << "Action now " << action << endl;
228 if (action == LFUN_UNKNOWN_ACTION) {
229 // Hmm, we didn't match any of the keysequences. See
230 // if it's normal insertable text not already covered
232 if (keysym->isText() && keyseq.length() == 1) {
233 lyxerr[Debug::KEY] << "isText() is true, inserting." << endl;
234 action = LFUN_SELFINSERT;
236 lyxerr[Debug::KEY] << "Unknown, !isText() - giving up" << endl;
237 owner->message(_("Unknown function."));
242 if (action == LFUN_SELFINSERT) {
243 if (encoded_last_key != 0) {
245 arg += encoded_last_key;
247 dispatch(FuncRequest(view(), LFUN_SELFINSERT, arg));
249 lyxerr[Debug::KEY] << "SelfInsert arg[`"
250 << argument << "']" << endl;
258 FuncStatus LyXFunc::getStatus(int ac) const
260 return getStatus(lyxaction.retrieveActionArg(ac));
264 FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
267 Buffer * buf = owner->buffer();
269 if (ev.action == LFUN_NOACTION) {
270 setStatusMessage(N_("Nothing to do"));
271 return flag.disabled(true);
275 case LFUN_UNKNOWN_ACTION:
276 #ifndef HAVE_LIBAIKSAURUS
277 case LFUN_THESAURUS_ENTRY:
282 flag |= lyx_gui::getStatus(ev);
285 if (flag.unknown()) {
286 setStatusMessage(N_("Unknown action"));
290 // the default error message if we disable the command
291 setStatusMessage(N_("Command disabled"));
293 // Check whether we need a buffer
294 if (!lyxaction.funcHasFlag(ev.action, LyXAction::NoBuffer)) {
295 // Yes we need a buffer, do we have one?
298 // Can we use a readonly buffer?
299 if (buf->isReadonly() &&
300 !lyxaction.funcHasFlag(ev.action,
301 LyXAction::ReadOnly)) {
303 setStatusMessage(N_("Document is read-only"));
308 setStatusMessage(N_("Command not allowed with"
309 "out any document open"));
310 return flag.disabled(true);
314 UpdatableInset * tli = view()->theLockingInset();
316 // I would really like to avoid having this switch and rather try to
317 // encode this in the function itself.
318 bool disable = false;
321 disable = ev.argument != "custom"
322 && !Exporter::IsExportable(*buf, ev.argument);
325 disable = buf->undostack.empty();
328 disable = buf->redostack.empty();
333 UpdatableInset * in = tli;
334 if (in->lyxCode() != InsetOld::TABULAR_CODE) {
335 in = tli->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE);
337 if (in && static_cast<InsetTabular*>(in)->hasSelection()) {
342 disable = !mathcursor && !view()->getLyXText()->selection.set();
345 disable = !buf->isLatex() || lyxrc.chktex_command == "none";
348 disable = !Exporter::IsExportable(*buf, "program");
351 case LFUN_LAYOUT_TABULAR:
353 || (tli->lyxCode() != InsetOld::TABULAR_CODE
354 && !tli->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE));
358 disable = !changeDepth(view(), view()->getLyXText(), DEC_DEPTH, true);
361 case LFUN_DEPTH_PLUS:
362 disable = !changeDepth(view(), view()->getLyXText(), INC_DEPTH, true);
366 case LFUN_LAYOUT_PARAGRAPH: {
367 InsetOld * inset = view()->getLyXText()->cursor.par()->inInset();
368 disable = inset && inset->forceDefaultParagraphs(inset);
372 case LFUN_INSET_OPTARG:
373 disable = (view()->getLyXText()->cursor.par()->layout()->optionalargs == 0);
376 case LFUN_TABULAR_FEATURE:
379 // FIXME: check temporarily disabled
381 char align = mathcursor->valign();
386 if (ev.argument.empty()) {
390 if (!contains("tcb", ev.argument[0])) {
394 flag.setOnOff(ev.argument[0] == align);
398 char align = mathcursor->halign();
403 if (ev.argument.empty()) {
407 if (!contains("lcr", ev.argument[0])) {
411 flag.setOnOff(ev.argument[0] == align);
414 disable = !mathcursor->halign();
420 //ret.disabled(true);
421 if (tli->lyxCode() == InsetOld::TABULAR_CODE) {
422 ret = static_cast<InsetTabular *>(tli)
423 ->getStatus(ev.argument);
426 } else if (tli->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE)) {
427 ret = static_cast<InsetTabular *>
428 (tli->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE))
429 ->getStatus(ev.argument);
436 static InsetTabular inset(*owner->buffer(), 1, 1);
440 ret = inset.getStatus(ev.argument);
441 if (ret.onoff(true) || ret.onoff(false))
442 flag.setOnOff(false);
446 case LFUN_VC_REGISTER:
447 disable = buf->lyxvc.inUse();
449 case LFUN_VC_CHECKIN:
450 disable = !buf->lyxvc.inUse() || buf->isReadonly();
452 case LFUN_VC_CHECKOUT:
453 disable = !buf->lyxvc.inUse() || !buf->isReadonly();
457 disable = !buf->lyxvc.inUse();
459 case LFUN_MENURELOAD:
460 disable = buf->isUnnamed() || buf->isClean();
462 case LFUN_BOOKMARK_GOTO:
464 isSavedPosition(strToUnsignedInt(ev.argument));
466 case LFUN_MERGE_CHANGES:
467 case LFUN_ACCEPT_CHANGE:
468 case LFUN_REJECT_CHANGE:
469 case LFUN_ACCEPT_ALL_CHANGES:
470 case LFUN_REJECT_ALL_CHANGES:
471 disable = !buf->params.tracking_changes;
473 case LFUN_INSET_TOGGLE: {
474 LyXText * lt = view()->getLyXText();
475 disable = !(isEditableInset(lt->getInset())
477 && lt->inset_owner->owner()
478 && lt->inset_owner->owner()->isOpen()));
482 case LFUN_INSET_SETTINGS: {
484 UpdatableInset * inset = view()->theLockingInset();
489 // get the innermost inset
490 inset = inset->getLockingInset();
492 // jump back to owner if an InsetText, so
493 // we get back to the InsetTabular or whatever
494 if (inset->lyxCode() == InsetOld::TEXT_CODE)
495 inset = inset->owner();
497 InsetOld::Code code = inset->lyxCode();
499 case InsetOld::TABULAR_CODE:
500 disable = ev.argument != "tabular";
502 case InsetOld::ERT_CODE:
503 disable = ev.argument != "ert";
505 case InsetOld::FLOAT_CODE:
506 disable = ev.argument != "float";
508 case InsetOld::MINIPAGE_CODE:
509 disable = ev.argument != "minipage";
511 case InsetOld::WRAP_CODE:
512 disable = ev.argument != "wrap";
514 case InsetOld::NOTE_CODE:
515 disable = ev.argument != "note";
517 case InsetOld::BRANCH_CODE:
518 disable = ev.argument != "branch";
526 case LFUN_MATH_MUTATE:
528 //flag.setOnOff(mathcursor->formula()->hullType() == ev.argument);
529 flag.setOnOff(false);
534 // we just need to be in math mode to enable that
536 case LFUN_MATH_SPACE:
537 case LFUN_MATH_LIMITS:
538 case LFUN_MATH_NONUMBER:
539 case LFUN_MATH_NUMBER:
540 case LFUN_MATH_EXTERN:
541 disable = !mathcursor;
544 case LFUN_DIALOG_SHOW: {
545 string const name = ev.getArg(0);
547 disable = !(name == "aboutlyx" ||
550 name == "preferences" ||
555 if (name == "print") {
556 disable = !Exporter::IsExportable(*buf, "dvi") ||
557 lyxrc.print_command == "none";
558 } else if (name == "character") {
559 UpdatableInset * tli = view()->theLockingInset();
560 disable = tli && tli->lyxCode() == InsetOld::ERT_CODE;
561 } else if (name == "vclog") {
562 disable = !buf->lyxvc.inUse();
563 } else if (name == "latexlog") {
564 disable = !IsFileReadable(buf->getLogName().second);
573 // the functions which insert insets
574 InsetOld::Code code = InsetOld::NO_CODE;
576 case LFUN_DIALOG_SHOW_NEW_INSET:
577 if (ev.argument == "bibitem")
578 code = InsetOld::BIBITEM_CODE;
579 else if (ev.argument == "bibtex")
580 code = InsetOld::BIBTEX_CODE;
581 else if (ev.argument == "citation")
582 code = InsetOld::CITE_CODE;
583 else if (ev.argument == "ert")
584 code = InsetOld::ERT_CODE;
585 else if (ev.argument == "external")
586 code = InsetOld::EXTERNAL_CODE;
587 else if (ev.argument == "float")
588 code = InsetOld::FLOAT_CODE;
589 else if (ev.argument == "graphics")
590 code = InsetOld::GRAPHICS_CODE;
591 else if (ev.argument == "include")
592 code = InsetOld::INCLUDE_CODE;
593 else if (ev.argument == "index")
594 code = InsetOld::INDEX_CODE;
595 else if (ev.argument == "label")
596 code = InsetOld::LABEL_CODE;
597 else if (ev.argument == "minipage")
598 code = InsetOld::MINIPAGE_CODE;
599 else if (ev.argument == "ref")
600 code = InsetOld::REF_CODE;
601 else if (ev.argument == "toc")
602 code = InsetOld::TOC_CODE;
603 else if (ev.argument == "url")
604 code = InsetOld::URL_CODE;
605 else if (ev.argument == "wrap")
606 code = InsetOld::WRAP_CODE;
610 code = InsetOld::ERT_CODE;
612 case LFUN_INSET_FOOTNOTE:
613 code = InsetOld::FOOT_CODE;
615 case LFUN_TABULAR_INSERT:
616 code = InsetOld::TABULAR_CODE;
618 case LFUN_INSET_MARGINAL:
619 code = InsetOld::MARGIN_CODE;
621 case LFUN_INSET_MINIPAGE:
622 code = InsetOld::MINIPAGE_CODE;
624 case LFUN_INSET_FLOAT:
625 case LFUN_INSET_WIDE_FLOAT:
626 code = InsetOld::FLOAT_CODE;
628 case LFUN_INSET_WRAP:
629 code = InsetOld::WRAP_CODE;
631 case LFUN_FLOAT_LIST:
632 code = InsetOld::FLOAT_LIST_CODE;
635 case LFUN_INSET_LIST:
636 code = InsetOld::LIST_CODE;
638 case LFUN_INSET_THEOREM:
639 code = InsetOld::THEOREM_CODE;
642 case LFUN_INSET_CAPTION:
643 code = InsetOld::CAPTION_CODE;
645 case LFUN_INSERT_NOTE:
646 code = InsetOld::NOTE_CODE;
648 case LFUN_INSERT_BRANCH:
649 code = InsetOld::BRANCH_CODE;
650 if (buf->params.branchlist.empty())
653 case LFUN_INSERT_LABEL:
654 code = InsetOld::LABEL_CODE;
656 case LFUN_INSET_OPTARG:
657 code = InsetOld::OPTARG_CODE;
659 case LFUN_ENVIRONMENT_INSERT:
660 code = InsetOld::MINIPAGE_CODE;
662 case LFUN_INDEX_INSERT:
663 code = InsetOld::INDEX_CODE;
665 case LFUN_INDEX_PRINT:
666 code = InsetOld::INDEX_PRINT_CODE;
668 case LFUN_TOC_INSERT:
669 code = InsetOld::TOC_CODE;
673 code = InsetOld::URL_CODE;
676 // always allow this, since we will inset a raw quote
677 // if an inset is not allowed.
679 case LFUN_HYPHENATION:
680 case LFUN_LIGATURE_BREAK:
682 case LFUN_MENU_SEPARATOR:
684 case LFUN_END_OF_SENTENCE:
685 code = InsetOld::SPECIALCHAR_CODE;
687 case LFUN_SPACE_INSERT:
688 // slight hack: we know this is allowed in math mode
690 code = InsetOld::SPACE_CODE;
695 if (code != InsetOld::NO_CODE && tli && !tli->insetAllowed(code))
701 // A few general toggles
703 case LFUN_TOOLTIPS_TOGGLE:
704 flag.setOnOff(owner->getDialogs().tooltipsEnabled());
707 case LFUN_READ_ONLY_TOGGLE:
708 flag.setOnOff(buf->isReadonly());
711 flag.setOnOff(view()->getLyXText()->cursor.par()->params().startOfAppendix());
713 case LFUN_SWITCHBUFFER:
714 // toggle on the current buffer, but do not toggle off
715 // the other ones (is that a good idea?)
716 if (ev.argument == buf->fileName())
719 case LFUN_TRACK_CHANGES:
720 flag.setOnOff(buf->params.tracking_changes);
726 // the font related toggles
728 LyXFont const & font = view()->getLyXText()->real_current_font;
731 flag.setOnOff(font.emph() == LyXFont::ON);
734 flag.setOnOff(font.noun() == LyXFont::ON);
737 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
740 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
743 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
746 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
752 string tc = mathcursor->getLastCode();
755 flag.setOnOff(tc == "mathbf");
758 flag.setOnOff(tc == "mathsf");
761 flag.setOnOff(tc == "mathcal");
764 flag.setOnOff(tc == "mathrm");
767 flag.setOnOff(tc == "mathtt");
770 flag.setOnOff(tc == "mathbb");
773 flag.setOnOff(tc == "mathnormal");
780 // this one is difficult to get right. As a half-baked
781 // solution, we consider only the first action of the sequence
782 if (ev.action == LFUN_SEQUENCE) {
783 // argument contains ';'-terminated commands
784 flag = getStatus(lyxaction.LookupFunc(token(ev.argument, ';', 0)));
791 void LyXFunc::dispatch(string const & s, bool verbose)
793 int const action = lyxaction.LookupFunc(s);
795 if (action == LFUN_UNKNOWN_ACTION) {
796 owner->message(bformat(_("Unknown function (%1$s)"), s));
800 dispatch(action, verbose);
804 void LyXFunc::dispatch(int ac, bool verbose)
806 dispatch(lyxaction.retrieveActionArg(ac), verbose);
810 bool ensureBufferClean(BufferView * bv) {
812 Buffer & buf = *bv->buffer();
816 string const file = MakeDisplayPath(buf.fileName(), 30);
817 string text = bformat(_("The document %1$s has unsaved "
818 "changes.\n\nDo you want to save "
819 "the document?"), file);
820 int const ret = Alert::prompt(_("Save changed document?"),
821 text, 0, 1, _("&Save"),
825 bv->owner()->dispatch(FuncRequest(LFUN_MENUWRITE));
827 return buf.isClean();
833 void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
835 lyxerr[Debug::ACTION] << "LyXFunc::dispatch: action[" << ev.action
836 <<"] arg[" << ev.argument << ']' << endl;
838 // we have not done anything wrong yet.
840 dispatch_buffer.erase();
842 #ifdef NEW_DISPATCHER
843 // We try do call the most specific dispatcher first:
844 // 1. the lockinginset's dispatch
845 // 2. the bufferview's dispatch
846 // 3. the lyxview's dispatch
849 selection_possible = false;
851 string argument = ev.argument;
852 kb_action action = ev.action;
854 // We cannot use this function here
855 if (getStatus(ev).disabled()) {
856 lyxerr[Debug::ACTION] << "LyXFunc::dispatch: "
857 << lyxaction.getActionName(action)
858 << " [" << action << "] is disabled at this location"
860 setErrorMessage(getStatusMessage());
861 goto exit_with_message;
864 if (view()->available())
865 view()->hideCursor();
867 if (view()->available() && view()->theLockingInset()) {
868 InsetOld::RESULT result;
869 if (action > 1 || (action == LFUN_UNKNOWN_ACTION &&
872 UpdatableInset * inset = view()->theLockingInset();
876 inset->getCursorPos(view(), inset_x, dummy_y);
878 if ((action == LFUN_UNKNOWN_ACTION)
879 && argument.empty()) {
880 argument = encoded_last_key;
883 // the insets can't try to handle this,
884 // a table cell in the dummy position will
885 // lock its insettext, the insettext will
886 // pass it the bufferview, and succeed,
887 // so it will stay not locked. Not good
888 // if we've just done LFUN_ESCAPE (which
889 // injects an LFUN_PARAGRAPH_UPDATE)
890 if (action == LFUN_PARAGRAPH_UPDATE) {
891 view()->dispatch(ev);
892 goto exit_with_message;
895 // Undo/Redo is a bit tricky for insets.
896 if (action == LFUN_UNDO) {
898 goto exit_with_message;
899 } else if (action == LFUN_REDO) {
901 goto exit_with_message;
902 } else if (((result=inset->
903 // Hand-over to inset's own dispatch:
904 localDispatch(FuncRequest(view(), action, argument))) ==
906 (result == DISPATCHED_NOUPDATE))
907 goto exit_with_message;
908 // If UNDISPATCHED, just soldier on
909 else if (result == FINISHED) {
910 owner->clearMessage();
911 goto exit_with_message;
912 // We do not need special RTL handling here:
913 // FINISHED means that the cursor should be
914 // one position after the inset.
915 } else if (result == FINISHED_RIGHT) {
916 view()->text->cursorRight(view());
918 owner->clearMessage();
919 goto exit_with_message;
920 } else if (result == FINISHED_UP) {
921 RowList::iterator const irow = view()->text->cursorIRow();
922 if (irow != view()->text->firstRow()) {
924 view()->text->setCursorFromCoordinates(
925 view()->text->cursor.x() + inset_x,
926 view()->text->cursor.y() -
927 irow->baseline() - 1);
928 view()->text->cursor.x_fix(view()->text->cursor.x());
930 view()->text->cursorUp(view());
936 owner->clearMessage();
937 goto exit_with_message;
938 } else if (result == FINISHED_DOWN) {
939 RowList::iterator const irow = view()->text->cursorIRow();
940 if (irow != view()->text->lastRow()) {
942 view()->text->setCursorFromCoordinates(
943 view()->text->cursor.x() + inset_x,
944 view()->text->cursor.y() -
947 view()->text->cursor.x_fix(view()->text->cursor.x());
949 view()->text->cursorDown(view());
952 view()->text->cursorRight(view());
955 owner->clearMessage();
956 goto exit_with_message;
958 #warning I am not sure this is still right, please have a look! (Jug 20020417)
959 else { // result == UNDISPATCHED
960 //setMessage(N_("Text mode"));
962 case LFUN_UNKNOWN_ACTION:
963 case LFUN_BREAKPARAGRAPH:
965 view()->text->cursorRight(view());
966 view()->switchKeyMap();
967 owner->view_state_changed();
970 if (!view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
971 view()->text->cursorRight(view());
973 owner->view_state_changed();
975 goto exit_with_message;
977 if (view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
978 view()->text->cursorRight(view());
980 owner->view_state_changed();
982 goto exit_with_message;
984 if (view()->text->cursorRow() != view()->text->lastRow())
985 view()->text->cursorDown(view());
987 view()->text->cursorRight(view());
989 owner->view_state_changed();
990 goto exit_with_message;
1001 if (!view()->available())
1003 // this function should be used always [asierra060396]
1004 UpdatableInset * tli = view()->theLockingInset();
1006 UpdatableInset * lock = tli->getLockingInset();
1009 view()->unlockInset(tli);
1010 view()->text->cursorRight(view());
1012 owner->view_state_changed();
1014 tli->unlockInsetInInset(view(), lock, true);
1017 // Tell the paragraph dialog that we changed paragraph
1018 dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
1023 case LFUN_WORDFINDFORWARD:
1024 case LFUN_WORDFINDBACKWARD: {
1025 static string last_search;
1026 string searched_string;
1028 if (!argument.empty()) {
1029 last_search = argument;
1030 searched_string = argument;
1032 searched_string = last_search;
1034 bool fw = (action == LFUN_WORDFINDFORWARD);
1035 if (!searched_string.empty())
1036 lyx::find::find(view(), searched_string, fw);
1041 if (view()->available() && !view()->theLockingInset())
1043 owner->message(keyseq.printOptions());
1046 // --- Misc -------------------------------------------
1047 case LFUN_EXEC_COMMAND:
1048 owner->focus_command_buffer();
1053 meta_fake_bit = key_modifier::none;
1054 if (view()->available())
1055 // cancel any selection
1056 dispatch(LFUN_MARK_OFF);
1057 setMessage(N_("Cancel"));
1060 case LFUN_META_FAKE:
1061 meta_fake_bit = key_modifier::alt;
1062 setMessage(keyseq.print());
1065 case LFUN_READ_ONLY_TOGGLE:
1066 if (owner->buffer()->lyxvc.inUse())
1067 owner->buffer()->lyxvc.toggleReadOnly();
1069 owner->buffer()->setReadonly(
1070 !owner->buffer()->isReadonly());
1073 case LFUN_CENTER: // this is center and redraw.
1077 // --- Menus -----------------------------------------------
1079 menuNew(argument, false);
1082 case LFUN_MENUNEWTMPLT:
1083 menuNew(argument, true);
1086 case LFUN_CLOSEBUFFER:
1090 case LFUN_MENUWRITE:
1091 if (!owner->buffer()->isUnnamed()) {
1092 string const str = bformat(_("Saving document %1$s..."),
1093 MakeDisplayPath(owner->buffer()->fileName()));
1094 owner->message(str);
1095 MenuWrite(owner->buffer());
1096 owner->message(str + _(" done."));
1098 WriteAs(owner->buffer());
1102 WriteAs(owner->buffer(), argument);
1105 case LFUN_MENURELOAD: {
1106 string const file = MakeDisplayPath(view()->buffer()->fileName(), 20);
1107 string text = bformat(_("Any changes will be lost. Are you sure "
1108 "you want to revert to the saved version of the document %1$s?"), file);
1109 int const ret = Alert::prompt(_("Revert to saved document?"),
1110 text, 0, 1, _("&Revert"), _("&Cancel"));
1118 Exporter::Export(owner->buffer(), argument, true);
1119 view()->showErrorList(BufferFormat(*owner->buffer()));
1123 Exporter::Preview(owner->buffer(), argument);
1124 view()->showErrorList(BufferFormat(*owner->buffer()));
1127 case LFUN_BUILDPROG:
1128 Exporter::Export(owner->buffer(), "program", true);
1129 view()->showErrorList(_("Build"));
1132 case LFUN_RUNCHKTEX:
1133 owner->buffer()->runChktex();
1134 view()->showErrorList(_("ChkTeX"));
1138 if (argument == "custom")
1139 owner->getDialogs().showSendto();
1141 Exporter::Export(owner->buffer(), argument, false);
1142 view()->showErrorList(BufferFormat(*owner->buffer()));
1156 InsetCommandParams p("tableofcontents");
1157 string const data = InsetCommandMailer::params2string("toc", p);
1158 owner->getDialogs().show("toc", data, 0);
1174 case LFUN_DEPTH_MIN:
1175 changeDepth(view(), view()->getLyXText(), DEC_DEPTH, false);
1176 owner->view_state_changed();
1179 case LFUN_DEPTH_PLUS:
1180 changeDepth(view(), view()->getLyXText(), INC_DEPTH, false);
1181 owner->view_state_changed();
1184 case LFUN_FREEFONT_APPLY:
1185 apply_freefont(view());
1188 case LFUN_FREEFONT_UPDATE:
1189 update_and_apply_freefont(view(), argument);
1192 case LFUN_RECONFIGURE:
1193 Reconfigure(view());
1197 case LFUN_FLOATSOPERATE:
1198 if (argument == "openfoot")
1199 view()->allFloats(1,0);
1200 else if (argument == "closefoot")
1201 view()->allFloats(0,0);
1202 else if (argument == "openfig")
1203 view()->allFloats(1,1);
1204 else if (argument == "closefig")
1205 view()->allFloats(0,1);
1208 #ifdef WITH_WARNINGS
1209 //#warning Find another implementation here (or another lyxfunc)!
1212 case LFUN_HELP_OPEN:
1214 string const arg = argument;
1216 setErrorMessage(N_("Missing argument"));
1219 string const fname = i18nLibFileSearch("doc", arg, "lyx");
1220 if (fname.empty()) {
1221 lyxerr << "LyX: unable to find documentation file `"
1222 << arg << "'. Bad installation?" << endl;
1225 owner->message(bformat(_("Opening help file %1$s..."),
1226 MakeDisplayPath(fname)));
1227 view()->loadLyXFile(fname, false);
1231 // --- version control -------------------------------
1232 case LFUN_VC_REGISTER:
1234 if (!ensureBufferClean(view()))
1236 if (!owner->buffer()->lyxvc.inUse()) {
1237 owner->buffer()->lyxvc.registrer();
1243 case LFUN_VC_CHECKIN:
1245 if (!ensureBufferClean(view()))
1247 if (owner->buffer()->lyxvc.inUse()
1248 && !owner->buffer()->isReadonly()) {
1249 owner->buffer()->lyxvc.checkIn();
1255 case LFUN_VC_CHECKOUT:
1257 if (!ensureBufferClean(view()))
1259 if (owner->buffer()->lyxvc.inUse()
1260 && owner->buffer()->isReadonly()) {
1261 owner->buffer()->lyxvc.checkOut();
1267 case LFUN_VC_REVERT:
1269 owner->buffer()->lyxvc.revert();
1276 owner->buffer()->lyxvc.undoLast();
1281 // --- buffers ----------------------------------------
1283 case LFUN_SWITCHBUFFER:
1284 view()->buffer(bufferlist.getBuffer(argument));
1288 NewFile(view(), argument);
1291 case LFUN_FILE_OPEN:
1295 case LFUN_LAYOUT_TABULAR:
1296 if (view()->theLockingInset()) {
1297 if (view()->theLockingInset()->lyxCode()== InsetOld::TABULAR_CODE) {
1298 InsetTabular * inset = static_cast<InsetTabular *>
1299 (view()->theLockingInset());
1300 inset->openLayoutDialog(view());
1301 } else if (view()->theLockingInset()->
1302 getFirstLockingInsetOfType(InsetOld::TABULAR_CODE)!=0) {
1303 InsetTabular * inset = static_cast<InsetTabular *>(
1304 view()->theLockingInset()->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE));
1305 inset->openLayoutDialog(view());
1310 case LFUN_DROP_LAYOUTS_CHOICE:
1311 owner->getToolbar().openLayoutList();
1314 case LFUN_MENU_OPEN_BY_NAME:
1315 owner->getMenubar().openByName(argument);
1316 break; // RVDK_PATCH_5
1318 // --- lyxserver commands ----------------------------
1322 setMessage(owner->buffer()->fileName());
1323 lyxerr[Debug::INFO] << "FNAME["
1324 << owner->buffer()->fileName()
1330 dispatch_buffer = keyseq.print();
1331 lyxserver->notifyClient(dispatch_buffer);
1335 case LFUN_GOTOFILEROW:
1339 istringstream istr(argument.c_str());
1340 istr >> file_name >> row;
1341 // Must replace extension of the file to be .lyx and get full path
1342 string const s(ChangeExtension(file_name, ".lyx"));
1344 // Either change buffer or load the file
1345 if (bufferlist.exists(s)) {
1346 view()->buffer(bufferlist.getBuffer(s));
1348 view()->loadLyXFile(s);
1351 view()->setCursorFromRow(row);
1354 // see BufferView_pimpl::center()
1355 view()->updateScrollbar();
1359 case LFUN_GOTO_PARAGRAPH:
1361 istringstream istr(argument.c_str());
1365 ParIterator par = owner->buffer()->getParFromID(id);
1366 if (par == owner->buffer()->par_iterator_end()) {
1367 lyxerr[Debug::INFO] << "No matching paragraph found! ["
1368 << id << ']' << endl;
1371 lyxerr[Debug::INFO] << "Paragraph " << par->id()
1372 << " found." << endl;
1375 if (view()->theLockingInset())
1376 view()->unlockInset(view()->theLockingInset());
1377 if (par->inInset()) {
1378 FuncRequest cmd(view(), LFUN_INSET_EDIT, "left");
1379 par->inInset()->localDispatch(cmd);
1382 view()->getLyXText()->setCursor(par.pit(), 0);
1383 view()->switchKeyMap();
1384 owner->view_state_changed();
1387 // see BufferView_pimpl::center()
1388 view()->updateScrollbar();
1392 // --- insert characters ----------------------------------------
1394 // --- Mathed stuff. If we are here, there is no locked inset yet.
1395 case LFUN_MATH_EXTERN:
1396 case LFUN_MATH_NUMBER:
1397 case LFUN_MATH_NONUMBER:
1398 case LFUN_MATH_LIMITS:
1400 setErrorMessage(N_("This is only allowed in math mode!"));
1404 // passthrough hat and underscore outside mathed:
1405 case LFUN_SUBSCRIPT:
1406 dispatch(FuncRequest(view(), LFUN_SELFINSERT, "_"));
1408 case LFUN_SUPERSCRIPT:
1409 dispatch(FuncRequest(view(), LFUN_SELFINSERT, "^"));
1412 case LFUN_DIALOG_SHOW: {
1413 string const name = ev.getArg(0);
1414 string data = trim(ev.argument.substr(name.size()));
1416 if (name == "character") {
1417 data = freefont2string();
1419 owner->getDialogs().show("character", data);
1420 } else if (name == "document")
1421 owner->getDialogs().showDocument();
1422 else if (name == "findreplace")
1423 owner->getDialogs().showSearch();
1424 else if (name == "forks")
1425 owner->getDialogs().showForks();
1426 else if (name == "preamble")
1427 owner->getDialogs().showPreamble();
1428 else if (name == "preferences")
1429 owner->getDialogs().showPreferences();
1430 else if (name == "print")
1431 owner->getDialogs().showPrint();
1432 else if (name == "spellchecker")
1433 owner->getDialogs().showSpellchecker();
1435 owner->getDialogs().show(name, data);
1439 case LFUN_DIALOG_SHOW_NEW_INSET: {
1440 string const & name = argument;
1442 if (name == "bibitem" ||
1444 name == "include" ||
1449 InsetCommandParams p(name);
1450 data = InsetCommandMailer::params2string(name, p);
1451 } else if (name == "citation") {
1452 InsetCommandParams p("cite");
1453 data = InsetCommandMailer::params2string(name, p);
1455 owner->getDialogs().show(name, data, 0);
1459 case LFUN_DIALOG_SHOW_NEXT_INSET: {
1463 case LFUN_DIALOG_UPDATE: {
1464 string const & name = argument;
1465 // Can only update a dialog connected to an existing inset
1466 InsetBase * inset = owner->getDialogs().getOpenInset(name);
1468 FuncRequest fr(view(), LFUN_INSET_DIALOG_UPDATE,
1470 inset->localDispatch(fr);
1471 } else if (name == "paragraph") {
1472 dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
1477 case LFUN_DIALOG_HIDE:
1478 Dialogs::hide(argument, 0);
1481 case LFUN_DIALOG_DISCONNECT_INSET:
1482 owner->getDialogs().disconnect(argument);
1485 case LFUN_CHILDOPEN:
1487 string const filename =
1488 MakeAbsPath(argument,
1489 owner->buffer()->filePath());
1490 setMessage(N_("Opening child document ") +
1491 MakeDisplayPath(filename) + "...");
1492 view()->savePosition(0);
1493 if (bufferlist.exists(filename))
1494 view()->buffer(bufferlist.getBuffer(filename));
1496 view()->loadLyXFile(filename);
1500 case LFUN_TOGGLECURSORFOLLOW:
1501 lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
1505 owner->getIntl().KeyMapOn(false);
1508 case LFUN_KMAP_PRIM:
1509 owner->getIntl().KeyMapPrim();
1513 owner->getIntl().KeyMapSec();
1516 case LFUN_KMAP_TOGGLE:
1517 owner->getIntl().ToggleKeyMap();
1522 // argument contains ';'-terminated commands
1523 while (!argument.empty()) {
1525 argument = split(argument, first, ';');
1531 case LFUN_SAVEPREFERENCES:
1533 Path p(user_lyxdir());
1534 lyxrc.write("preferences");
1538 case LFUN_SCREEN_FONT_UPDATE:
1540 // handle the screen font changes.
1541 lyxrc.set_font_norm_type();
1542 lyx_gui::update_fonts();
1543 // We also need to empty the textcache so that
1544 // the buffer will be formatted correctly after
1547 // Of course we should only do the resize and the textcache.clear
1548 // if values really changed...but not very important right now. (Lgb)
1549 // All visible buffers will need resize
1555 case LFUN_SET_COLOR:
1558 string const x11_name = split(argument, lyx_name, ' ');
1559 if (lyx_name.empty() || x11_name.empty()) {
1560 setErrorMessage(N_("Syntax: set-color <lyx_name>"
1565 bool const graphicsbg_changed =
1566 (lyx_name == lcolor.getLyXName(LColor::graphicsbg) &&
1567 x11_name != lcolor.getX11Name(LColor::graphicsbg));
1569 if (!lcolor.setColor(lyx_name, x11_name)) {
1571 bformat(_("Set-color \"%1$s\" failed "
1572 "- color is undefined or "
1573 "may not be redefined"), lyx_name));
1577 lyx_gui::update_color(lcolor.getFromLyXName(lyx_name));
1579 if (graphicsbg_changed) {
1580 #ifdef WITH_WARNINGS
1581 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1584 lyx::graphics::GCache & gc =
1585 lyx::graphics::GCache::get();
1586 gc.changeDisplay(true);
1595 owner->message(argument);
1598 case LFUN_FORKS_KILL:
1600 if (!isStrInt(argument))
1603 pid_t const pid = strToInt(argument);
1604 ForkedcallsController & fcc = ForkedcallsController::get();
1609 case LFUN_TOOLTIPS_TOGGLE:
1610 owner->getDialogs().toggleTooltips();
1613 case LFUN_EXTERNAL_EDIT: {
1615 .localDispatch(FuncRequest(view(), action, argument));
1620 // Then if it was none of the above
1621 // Trying the BufferView::pimpl dispatch:
1622 if (!view()->dispatch(ev))
1623 lyxerr << "A truly unknown func ["
1624 << lyxaction.getActionName(ev.action) << "]!"
1631 view()->owner()->updateLayoutChoice();
1633 if (view()->available()) {
1634 if (view()->fitCursor()) {
1635 lyxerr << "LyXFunc->fitCursor->update" << endl;
1640 // If we executed a mutating lfun, mark the buffer as dirty
1641 if (!getStatus(ev).disabled()
1642 && !lyxaction.funcHasFlag(ev.action, LyXAction::NoBuffer)
1643 && !lyxaction.funcHasFlag(ev.action, LyXAction::ReadOnly))
1644 view()->buffer()->markDirty();
1647 sendDispatchMessage(getMessage(), ev, verbose);
1651 void LyXFunc::sendDispatchMessage(string const & msg, FuncRequest const & ev, bool verbose)
1653 owner->updateMenubar();
1654 owner->updateToolbar();
1656 if (ev.action == LFUN_SELFINSERT || !verbose) {
1657 lyxerr[Debug::ACTION] << "dispatch msg is " << msg << endl;
1659 owner->message(msg);
1663 string dispatch_msg = msg;
1664 if (!dispatch_msg.empty())
1665 dispatch_msg += ' ';
1667 string comname = lyxaction.getActionName(ev.action);
1669 int pseudoaction = ev.action;
1670 bool argsadded = false;
1672 if (!ev.argument.empty()) {
1673 // the pseudoaction is useful for the bindings
1674 pseudoaction = lyxaction.searchActionArg(ev.action, ev.argument);
1676 if (pseudoaction == LFUN_UNKNOWN_ACTION) {
1677 pseudoaction = ev.action;
1679 comname += ' ' + ev.argument;
1684 string const shortcuts = toplevel_keymap->findbinding(pseudoaction);
1686 if (!shortcuts.empty()) {
1687 comname += ": " + shortcuts;
1688 } else if (!argsadded && !ev.argument.empty()) {
1689 comname += ' ' + ev.argument;
1692 if (!comname.empty()) {
1693 comname = rtrim(comname);
1694 dispatch_msg += '(' + comname + ')';
1697 lyxerr[Debug::ACTION] << "verbose dispatch msg " << dispatch_msg << endl;
1698 if (!dispatch_msg.empty())
1699 owner->message(dispatch_msg);
1703 void LyXFunc::setupLocalKeymap()
1705 keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
1706 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap.get();
1710 void LyXFunc::menuNew(string const & name, bool fromTemplate)
1712 string initpath = lyxrc.document_path;
1713 string filename(name);
1715 if (view()->available()) {
1716 string const trypath = owner->buffer()->filePath();
1717 // If directory is writeable, use this as default.
1718 if (IsDirWriteable(trypath))
1722 static int newfile_number;
1724 if (filename.empty()) {
1725 filename = AddName(lyxrc.document_path,
1726 "newfile" + tostr(++newfile_number) + ".lyx");
1727 FileInfo fi(filename);
1728 while (bufferlist.exists(filename) || fi.readable()) {
1730 filename = AddName(lyxrc.document_path,
1731 "newfile" + tostr(newfile_number) +
1733 fi.newFile(filename);
1737 // The template stuff
1740 FileDialog fileDlg(_("Select template file"),
1741 LFUN_SELECT_FILE_SYNC,
1742 make_pair(string(_("Documents|#o#O")),
1743 string(lyxrc.document_path)),
1744 make_pair(string(_("Templates|#T#t")),
1745 string(lyxrc.template_path)));
1747 FileDialog::Result result =
1748 fileDlg.open(lyxrc.template_path,
1749 _("*.lyx| LyX Documents (*.lyx)"));
1751 if (result.first == FileDialog::Later)
1754 string const fname = result.second;
1761 view()->newFile(filename, templname, !name.empty());
1765 void LyXFunc::open(string const & fname)
1767 string initpath = lyxrc.document_path;
1769 if (view()->available()) {
1770 string const trypath = owner->buffer()->filePath();
1771 // If directory is writeable, use this as default.
1772 if (IsDirWriteable(trypath))
1778 if (fname.empty()) {
1779 FileDialog fileDlg(_("Select document to open"),
1781 make_pair(string(_("Documents|#o#O")),
1782 string(lyxrc.document_path)),
1783 make_pair(string(_("Examples|#E#e")),
1784 string(AddPath(system_lyxdir(), "examples"))));
1786 FileDialog::Result result =
1787 fileDlg.open(initpath,
1788 _("*.lyx| LyX Documents (*.lyx)"));
1790 if (result.first == FileDialog::Later)
1793 filename = result.second;
1795 // check selected filename
1796 if (filename.empty()) {
1797 owner->message(_("Canceled."));
1803 // get absolute path of file and add ".lyx" to the filename if
1805 string const fullpath = FileSearch(string(), filename, "lyx");
1806 if (!fullpath.empty()) {
1807 filename = fullpath;
1810 string const disp_fn(MakeDisplayPath(filename));
1812 // if the file doesn't exist, let the user create one
1813 FileInfo const f(filename, true);
1815 // the user specifically chose this name. Believe them.
1816 view()->newFile(filename, "", true);
1820 owner->message(bformat(_("Opening document %1$s..."), disp_fn));
1823 if (view()->loadLyXFile(filename)) {
1824 str2 = bformat(_("Document %1$s opened."), disp_fn);
1826 str2 = bformat(_("Could not open document %1$s"), disp_fn);
1828 owner->message(str2);
1832 void LyXFunc::doImport(string const & argument)
1835 string filename = split(argument, format, ' ');
1837 lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format
1838 << " file: " << filename << endl;
1840 // need user interaction
1841 if (filename.empty()) {
1842 string initpath = lyxrc.document_path;
1844 if (view()->available()) {
1845 string const trypath = owner->buffer()->filePath();
1846 // If directory is writeable, use this as default.
1847 if (IsDirWriteable(trypath))
1851 string const text = bformat(_("Select %1$s file to import"),
1852 formats.prettyName(format));
1854 FileDialog fileDlg(text,
1856 make_pair(string(_("Documents|#o#O")),
1857 string(lyxrc.document_path)),
1858 make_pair(string(_("Examples|#E#e")),
1859 string(AddPath(system_lyxdir(), "examples"))));
1861 string const extension = "*." + formats.extension(format)
1862 + "| " + formats.prettyName(format)
1863 + " (*." + formats.extension(format) + ')';
1865 FileDialog::Result result = fileDlg.open(initpath,
1868 if (result.first == FileDialog::Later)
1871 filename = result.second;
1873 // check selected filename
1874 if (filename.empty())
1875 owner->message(_("Canceled."));
1878 if (filename.empty())
1881 // get absolute path of file
1882 filename = MakeAbsPath(filename);
1884 string const lyxfile = ChangeExtension(filename, ".lyx");
1886 // Check if the document already is open
1887 if (lyx_gui::use_gui && bufferlist.exists(lyxfile)) {
1888 if (!bufferlist.close(bufferlist.getBuffer(lyxfile), true)) {
1889 owner->message(_("Canceled."));
1894 // if the file exists already, and we didn't do
1895 // -i lyx thefile.lyx, warn
1896 if (FileInfo(lyxfile, true).exist() && filename != lyxfile) {
1897 string const file = MakeDisplayPath(lyxfile, 30);
1899 string text = bformat(_("The document %1$s already exists.\n\n"
1900 "Do you want to over-write that document?"), file);
1901 int const ret = Alert::prompt(_("Over-write document?"),
1902 text, 0, 1, _("&Over-write"), _("&Cancel"));
1905 owner->message(_("Canceled."));
1910 Importer::Import(owner, filename, format);
1914 void LyXFunc::closeBuffer()
1916 if (bufferlist.close(owner->buffer(), true) && !quitting) {
1917 if (bufferlist.empty()) {
1918 // need this otherwise SEGV may occur while
1919 // trying to set variables that don't exist
1920 // since there's no current buffer
1921 owner->getDialogs().hideBufferDependent();
1923 view()->buffer(bufferlist.first());
1929 // Each "owner" should have it's own message method. lyxview and
1930 // the minibuffer would use the minibuffer, but lyxserver would
1931 // send an ERROR signal to its client. Alejandro 970603
1932 // This func is bit problematic when it comes to NLS, to make the
1933 // lyx servers client be language indepenent we must not translate
1934 // strings sent to this func.
1935 void LyXFunc::setErrorMessage(string const & m) const
1937 dispatch_buffer = m;
1942 void LyXFunc::setMessage(string const & m) const
1944 dispatch_buffer = m;
1948 void LyXFunc::setStatusMessage(string const & m) const
1954 string const LyXFunc::view_status_message()
1956 // When meta-fake key is pressed, show the key sequence so far + "M-".
1958 return keyseq.print() + "M-";
1961 // Else, when a non-complete key sequence is pressed,
1962 // show the available options.
1963 if (keyseq.length() > 0 && !keyseq.deleted()) {
1964 return keyseq.printOptions();
1967 if (!view()->available())
1968 return _("Welcome to LyX!");
1970 return currentState(view());
1974 BufferView * LyXFunc::view() const
1977 return owner->view().get();
1981 bool LyXFunc::wasMetaKey() const
1983 return (meta_fake_bit != key_modifier::none);