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.
24 #include "bufferlist.h"
26 #include "buffer_funcs.h"
27 #include "BufferView.h"
28 #include "funcrequest.h"
29 #include "iterators.h"
30 #include "lyxserver.h"
33 #include "LyXAction.h"
36 #include "support/std_sstream.h"
38 #include "frontends/LyXView.h"
39 #include "frontends/lyx_gui.h"
43 #include "TextCache.h"
45 #include "undo_funcs.h"
46 #include "ParagraphParameters.h"
48 #include "insets/insetcommand.h"
49 #include "insets/insetexternal.h"
50 #include "insets/insettabular.h"
52 #include "mathed/math_cursor.h"
54 #include "frontends/FileDialog.h"
55 #include "frontends/Dialogs.h"
56 #include "frontends/Toolbar.h"
57 #include "frontends/Menubar.h"
58 #include "frontends/Alert.h"
61 #include "support/LAssert.h"
62 #include "support/filetools.h"
63 #include "support/FileInfo.h"
64 #include "support/forkedcontr.h"
65 #include "support/tostr.h"
66 #include "support/path.h"
67 #include "support/path_defines.h"
71 using namespace lyx::support;
77 using std::istringstream;
80 using std::back_inserter;
81 using namespace bv_funcs;
83 extern BufferList bufferlist;
84 extern LyXServer * lyxserver;
85 extern bool selection_possible;
87 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
90 extern tex_accent_struct get_accent(kb_action action);
92 extern void ShowLatexLog();
95 LyXFunc::LyXFunc(LyXView * o)
98 keyseq(toplevel_keymap.get(), toplevel_keymap.get()),
99 cancel_meta_seq(toplevel_keymap.get(), toplevel_keymap.get()),
100 meta_fake_bit(key_modifier::none)
105 void LyXFunc::moveCursorUpdate()
107 LyXText * lt = view()->text;
108 if (lt->selection.mark())
111 view()->switchKeyMap();
115 void LyXFunc::handleKeyFunc(kb_action action)
117 char c = encoded_last_key;
119 if (keyseq.length()) {
123 owner->getIntl().getTransManager()
124 .deadkey(c, get_accent(action).accent, view()->getLyXText());
125 // Need to clear, in case the minibuffer calls these
128 // copied verbatim from do_accent_char
130 view()->getLyXText()->selection.cursor = view()->getLyXText()->cursor;
134 void LyXFunc::processKeySym(LyXKeySymPtr keysym,
135 key_modifier::state state)
139 if (lyxerr.debugging(Debug::KEY)) {
140 lyxerr << "KeySym is "
141 << keysym->getSymbolName()
145 // Do nothing if we have nothing (JMarc)
146 if (!keysym->isOK()) {
147 lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
152 if (keysym->isModifier()) {
153 lyxerr[Debug::KEY] << "isModifier true" << endl;
157 Encoding const * encoding = view()->getEncoding();
159 encoded_last_key = keysym->getISOEncoded(encoding ? encoding->Name() : "");
161 // Do a one-deep top-level lookup for
162 // cancel and meta-fake keys. RVDK_PATCH_5
163 cancel_meta_seq.reset();
165 int action = cancel_meta_seq.addkey(keysym, state);
166 lyxerr[Debug::KEY] << "action first set to [" << action << ']' << endl;
168 // When not cancel or meta-fake, do the normal lookup.
169 // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
170 // Mostly, meta_fake_bit = key_modifier::none. RVDK_PATCH_5.
171 if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
172 // remove Caps Lock and Mod2 as a modifiers
173 action = keyseq.addkey(keysym, (state | meta_fake_bit));
174 lyxerr[Debug::KEY] << "action now set to ["
175 << action << ']' << endl;
178 // Dont remove this unless you know what you are doing.
179 meta_fake_bit = key_modifier::none;
181 // can this happen now ?
182 if (action == LFUN_NOACTION) {
183 action = LFUN_PREFIX;
186 if (lyxerr.debugging(Debug::KEY)) {
187 lyxerr << "Key [action="
189 << keyseq.print() << ']'
193 // already here we know if it any point in going further
194 // why not return already here if action == -1 and
195 // num_bytes == 0? (Lgb)
197 if (keyseq.length() > 1) {
198 owner->message(keyseq.print());
202 // Maybe user can only reach the key via holding down shift.
203 // Let's see. But only if shift is the only modifier
204 if (action == LFUN_UNKNOWN_ACTION && state == key_modifier::shift) {
205 lyxerr[Debug::KEY] << "Trying without shift" << endl;
206 action = keyseq.addkey(keysym, key_modifier::none);
207 lyxerr[Debug::KEY] << "Action now " << action << endl;
210 if (action == LFUN_UNKNOWN_ACTION) {
211 // Hmm, we didn't match any of the keysequences. See
212 // if it's normal insertable text not already covered
214 if (keysym->isText() && keyseq.length() == 1) {
215 lyxerr[Debug::KEY] << "isText() is true, inserting." << endl;
216 action = LFUN_SELFINSERT;
218 lyxerr[Debug::KEY] << "Unknown, !isText() - giving up" << endl;
219 owner->message(_("Unknown function."));
224 if (action == LFUN_SELFINSERT) {
225 if (encoded_last_key != 0) {
227 arg += encoded_last_key;
229 dispatch(FuncRequest(view(), LFUN_SELFINSERT, arg));
231 lyxerr[Debug::KEY] << "SelfInsert arg[`"
232 << argument << "']" << endl;
240 FuncStatus LyXFunc::getStatus(int ac) const
242 return getStatus(lyxaction.retrieveActionArg(ac));
246 FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
249 Buffer * buf = owner->buffer();
251 if (ev.action == LFUN_NOACTION) {
252 setStatusMessage(N_("Nothing to do"));
253 return flag.disabled(true);
257 case LFUN_UNKNOWN_ACTION:
258 #ifndef HAVE_LIBAIKSAURUS
259 case LFUN_THESAURUS_ENTRY:
264 flag |= lyx_gui::getStatus(ev);
267 if (flag.unknown()) {
268 setStatusMessage(N_("Unknown action"));
272 // the default error message if we disable the command
273 setStatusMessage(N_("Command disabled"));
275 // Check whether we need a buffer
276 if (!lyxaction.funcHasFlag(ev.action, LyXAction::NoBuffer)) {
277 // Yes we need a buffer, do we have one?
280 // Can we use a readonly buffer?
281 if (buf->isReadonly() &&
282 !lyxaction.funcHasFlag(ev.action,
283 LyXAction::ReadOnly)) {
285 setStatusMessage(N_("Document is read-only"));
290 setStatusMessage(N_("Command not allowed with"
291 "out any document open"));
292 return flag.disabled(true);
296 UpdatableInset * tli = view()->theLockingInset();
298 // I would really like to avoid having this switch and rather try to
299 // encode this in the function itself.
300 bool disable = false;
303 disable = ev.argument != "custom"
304 && !Exporter::IsExportable(*buf, ev.argument);
307 disable = buf->undostack.empty();
310 disable = buf->redostack.empty();
315 UpdatableInset * in = tli;
316 if (in->lyxCode() != InsetOld::TABULAR_CODE) {
317 in = tli->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE);
319 if (in && static_cast<InsetTabular*>(in)->hasSelection()) {
324 disable = !mathcursor && !view()->getLyXText()->selection.set();
327 disable = !buf->isLatex() || lyxrc.chktex_command == "none";
330 disable = !Exporter::IsExportable(*buf, "program");
333 case LFUN_LAYOUT_TABULAR:
335 || (tli->lyxCode() != InsetOld::TABULAR_CODE
336 && !tli->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE));
340 disable = !changeDepth(view(), view()->getLyXText(), DEC_DEPTH, true);
343 case LFUN_DEPTH_PLUS:
344 disable = !changeDepth(view(), view()->getLyXText(), INC_DEPTH, true);
348 case LFUN_LAYOUT_PARAGRAPH: {
349 InsetOld * inset = view()->getLyXText()->cursor.par()->inInset();
350 disable = inset && inset->forceDefaultParagraphs(inset);
354 case LFUN_INSET_OPTARG:
355 disable = (view()->getLyXText()->cursor.par()->layout()->optionalargs == 0);
358 case LFUN_TABULAR_FEATURE:
361 // FIXME: check temporarily disabled
363 char align = mathcursor->valign();
368 if (ev.argument.empty()) {
372 if (!contains("tcb", ev.argument[0])) {
376 flag.setOnOff(ev.argument[0] == align);
380 char align = mathcursor->halign();
385 if (ev.argument.empty()) {
389 if (!contains("lcr", ev.argument[0])) {
393 flag.setOnOff(ev.argument[0] == align);
396 disable = !mathcursor->halign();
402 //ret.disabled(true);
403 if (tli->lyxCode() == InsetOld::TABULAR_CODE) {
404 ret = static_cast<InsetTabular *>(tli)
405 ->getStatus(ev.argument);
408 } else if (tli->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE)) {
409 ret = static_cast<InsetTabular *>
410 (tli->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE))
411 ->getStatus(ev.argument);
418 static InsetTabular inset(*owner->buffer(), 1, 1);
422 ret = inset.getStatus(ev.argument);
423 if (ret.onoff(true) || ret.onoff(false))
424 flag.setOnOff(false);
428 case LFUN_VC_REGISTER:
429 disable = buf->lyxvc.inUse();
431 case LFUN_VC_CHECKIN:
432 disable = !buf->lyxvc.inUse() || buf->isReadonly();
434 case LFUN_VC_CHECKOUT:
435 disable = !buf->lyxvc.inUse() || !buf->isReadonly();
439 disable = !buf->lyxvc.inUse();
441 case LFUN_MENURELOAD:
442 disable = buf->isUnnamed() || buf->isClean();
444 case LFUN_BOOKMARK_GOTO:
446 isSavedPosition(strToUnsignedInt(ev.argument));
448 case LFUN_MERGE_CHANGES:
449 case LFUN_ACCEPT_CHANGE:
450 case LFUN_REJECT_CHANGE:
451 case LFUN_ACCEPT_ALL_CHANGES:
452 case LFUN_REJECT_ALL_CHANGES:
453 disable = !buf->params.tracking_changes;
455 case LFUN_INSET_TOGGLE: {
456 LyXText * lt = view()->getLyXText();
457 disable = !(isEditableInset(lt->getInset())
459 && lt->inset_owner->owner()
460 && lt->inset_owner->owner()->isOpen()));
464 case LFUN_INSET_SETTINGS: {
466 UpdatableInset * inset = view()->theLockingInset();
471 // get the innermost inset
472 inset = inset->getLockingInset();
474 // jump back to owner if an InsetText, so
475 // we get back to the InsetTabular or whatever
476 if (inset->lyxCode() == InsetOld::TEXT_CODE)
477 inset = inset->owner();
479 InsetOld::Code code = inset->lyxCode();
481 case InsetOld::TABULAR_CODE:
482 disable = ev.argument != "tabular";
484 case InsetOld::ERT_CODE:
485 disable = ev.argument != "ert";
487 case InsetOld::FLOAT_CODE:
488 disable = ev.argument != "float";
490 case InsetOld::MINIPAGE_CODE:
491 disable = ev.argument != "minipage";
493 case InsetOld::WRAP_CODE:
494 disable = ev.argument != "wrap";
496 case InsetOld::NOTE_CODE:
497 disable = ev.argument != "note";
499 case InsetOld::BRANCH_CODE:
500 disable = ev.argument != "branch";
508 case LFUN_MATH_MUTATE:
510 //flag.setOnOff(mathcursor->formula()->hullType() == ev.argument);
511 flag.setOnOff(false);
516 // we just need to be in math mode to enable that
518 case LFUN_MATH_SPACE:
519 case LFUN_MATH_LIMITS:
520 case LFUN_MATH_NONUMBER:
521 case LFUN_MATH_NUMBER:
522 case LFUN_MATH_EXTERN:
523 disable = !mathcursor;
526 case LFUN_DIALOG_SHOW: {
527 string const name = ev.getArg(0);
529 disable = !(name == "aboutlyx" ||
532 name == "preferences" ||
537 if (name == "print") {
538 disable = !Exporter::IsExportable(*buf, "dvi") ||
539 lyxrc.print_command == "none";
540 } else if (name == "character") {
541 UpdatableInset * tli = view()->theLockingInset();
542 disable = tli && tli->lyxCode() == InsetOld::ERT_CODE;
543 } else if (name == "vclog") {
544 disable = !buf->lyxvc.inUse();
545 } else if (name == "latexlog") {
546 disable = !IsFileReadable(buf->getLogName().second);
555 // the functions which insert insets
556 InsetOld::Code code = InsetOld::NO_CODE;
558 case LFUN_DIALOG_SHOW_NEW_INSET:
559 if (ev.argument == "bibitem")
560 code = InsetOld::BIBITEM_CODE;
561 else if (ev.argument == "bibtex")
562 code = InsetOld::BIBTEX_CODE;
563 else if (ev.argument == "citation")
564 code = InsetOld::CITE_CODE;
565 else if (ev.argument == "ert")
566 code = InsetOld::ERT_CODE;
567 else if (ev.argument == "external")
568 code = InsetOld::EXTERNAL_CODE;
569 else if (ev.argument == "float")
570 code = InsetOld::FLOAT_CODE;
571 else if (ev.argument == "graphics")
572 code = InsetOld::GRAPHICS_CODE;
573 else if (ev.argument == "include")
574 code = InsetOld::INCLUDE_CODE;
575 else if (ev.argument == "index")
576 code = InsetOld::INDEX_CODE;
577 else if (ev.argument == "label")
578 code = InsetOld::LABEL_CODE;
579 else if (ev.argument == "minipage")
580 code = InsetOld::MINIPAGE_CODE;
581 else if (ev.argument == "ref")
582 code = InsetOld::REF_CODE;
583 else if (ev.argument == "toc")
584 code = InsetOld::TOC_CODE;
585 else if (ev.argument == "url")
586 code = InsetOld::URL_CODE;
587 else if (ev.argument == "wrap")
588 code = InsetOld::WRAP_CODE;
592 code = InsetOld::ERT_CODE;
594 case LFUN_INSET_FOOTNOTE:
595 code = InsetOld::FOOT_CODE;
597 case LFUN_TABULAR_INSERT:
598 code = InsetOld::TABULAR_CODE;
600 case LFUN_INSET_MARGINAL:
601 code = InsetOld::MARGIN_CODE;
603 case LFUN_INSET_MINIPAGE:
604 code = InsetOld::MINIPAGE_CODE;
606 case LFUN_INSET_FLOAT:
607 case LFUN_INSET_WIDE_FLOAT:
608 code = InsetOld::FLOAT_CODE;
610 case LFUN_INSET_WRAP:
611 code = InsetOld::WRAP_CODE;
613 case LFUN_FLOAT_LIST:
614 code = InsetOld::FLOAT_LIST_CODE;
617 case LFUN_INSET_LIST:
618 code = InsetOld::LIST_CODE;
620 case LFUN_INSET_THEOREM:
621 code = InsetOld::THEOREM_CODE;
624 case LFUN_INSET_CAPTION:
625 code = InsetOld::CAPTION_CODE;
627 case LFUN_INSERT_NOTE:
628 code = InsetOld::NOTE_CODE;
630 case LFUN_INSERT_BRANCH:
631 code = InsetOld::BRANCH_CODE;
632 if (buf->params.branchlist.empty())
635 case LFUN_INSERT_LABEL:
636 code = InsetOld::LABEL_CODE;
638 case LFUN_INSET_OPTARG:
639 code = InsetOld::OPTARG_CODE;
641 case LFUN_ENVIRONMENT_INSERT:
642 code = InsetOld::MINIPAGE_CODE;
644 case LFUN_INDEX_INSERT:
645 code = InsetOld::INDEX_CODE;
647 case LFUN_INDEX_PRINT:
648 code = InsetOld::INDEX_PRINT_CODE;
650 case LFUN_TOC_INSERT:
651 code = InsetOld::TOC_CODE;
655 code = InsetOld::URL_CODE;
658 // always allow this, since we will inset a raw quote
659 // if an inset is not allowed.
661 case LFUN_HYPHENATION:
662 case LFUN_LIGATURE_BREAK:
664 case LFUN_MENU_SEPARATOR:
666 case LFUN_END_OF_SENTENCE:
667 code = InsetOld::SPECIALCHAR_CODE;
669 case LFUN_SPACE_INSERT:
670 // slight hack: we know this is allowed in math mode
672 code = InsetOld::SPACE_CODE;
674 case LFUN_INSET_DIALOG_SHOW: {
675 LyXText * lt = view()->getLyXText();
676 InsetOld * inset = lt->getInset();
679 code = inset->lyxCode();
680 if (!(code == InsetOld::INCLUDE_CODE
681 || code == InsetOld::BIBTEX_CODE
682 || code == InsetOld::FLOAT_LIST_CODE
683 || code == InsetOld::TOC_CODE))
691 if (code != InsetOld::NO_CODE && tli && !tli->insetAllowed(code))
697 // A few general toggles
699 case LFUN_TOOLTIPS_TOGGLE:
700 flag.setOnOff(owner->getDialogs().tooltipsEnabled());
703 case LFUN_READ_ONLY_TOGGLE:
704 flag.setOnOff(buf->isReadonly());
707 flag.setOnOff(view()->getLyXText()->cursor.par()->params().startOfAppendix());
709 case LFUN_SWITCHBUFFER:
710 // toggle on the current buffer, but do not toggle off
711 // the other ones (is that a good idea?)
712 if (ev.argument == buf->fileName())
715 case LFUN_TRACK_CHANGES:
716 flag.setOnOff(buf->params.tracking_changes);
722 // the font related toggles
724 LyXFont const & font = view()->getLyXText()->real_current_font;
727 flag.setOnOff(font.emph() == LyXFont::ON);
730 flag.setOnOff(font.noun() == LyXFont::ON);
733 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
736 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
739 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
742 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
748 string tc = mathcursor->getLastCode();
751 flag.setOnOff(tc == "mathbf");
754 flag.setOnOff(tc == "mathsf");
757 flag.setOnOff(tc == "mathcal");
760 flag.setOnOff(tc == "mathrm");
763 flag.setOnOff(tc == "mathtt");
766 flag.setOnOff(tc == "mathbb");
769 flag.setOnOff(tc == "mathnormal");
776 // this one is difficult to get right. As a half-baked
777 // solution, we consider only the first action of the sequence
778 if (ev.action == LFUN_SEQUENCE) {
779 // argument contains ';'-terminated commands
780 flag = getStatus(lyxaction.LookupFunc(token(ev.argument, ';', 0)));
787 void LyXFunc::dispatch(string const & s, bool verbose)
789 int const action = lyxaction.LookupFunc(s);
791 if (action == LFUN_UNKNOWN_ACTION) {
792 owner->message(bformat(_("Unknown function (%1$s)"), s));
796 dispatch(action, verbose);
800 void LyXFunc::dispatch(int ac, bool verbose)
802 dispatch(lyxaction.retrieveActionArg(ac), verbose);
806 bool ensureBufferClean(BufferView * bv) {
808 Buffer & buf = *bv->buffer();
812 string const file = MakeDisplayPath(buf.fileName(), 30);
813 string text = bformat(_("The document %1$s has unsaved "
814 "changes.\n\nDo you want to save "
815 "the document?"), file);
816 int const ret = Alert::prompt(_("Save changed document?"),
817 text, 0, 1, _("&Save"),
821 bv->owner()->dispatch(FuncRequest(LFUN_MENUWRITE));
823 return buf.isClean();
829 void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
831 lyxerr[Debug::ACTION] << "LyXFunc::dispatch: action[" << ev.action
832 <<"] arg[" << ev.argument << ']' << endl;
834 // we have not done anything wrong yet.
836 dispatch_buffer.erase();
838 #ifdef NEW_DISPATCHER
839 // We try do call the most specific dispatcher first:
840 // 1. the lockinginset's dispatch
841 // 2. the bufferview's dispatch
842 // 3. the lyxview's dispatch
845 selection_possible = false;
847 string argument = ev.argument;
848 kb_action action = ev.action;
850 // We cannot use this function here
851 if (getStatus(ev).disabled()) {
852 lyxerr[Debug::ACTION] << "LyXFunc::dispatch: "
853 << lyxaction.getActionName(action)
854 << " [" << action << "] is disabled at this location"
856 setErrorMessage(getStatusMessage());
857 goto exit_with_message;
860 if (view()->available())
861 view()->hideCursor();
863 if (view()->available() && view()->theLockingInset()) {
864 InsetOld::RESULT result;
865 if (action > 1 || (action == LFUN_UNKNOWN_ACTION &&
868 UpdatableInset * inset = view()->theLockingInset();
872 inset->getCursorPos(view(), inset_x, dummy_y);
874 if ((action == LFUN_UNKNOWN_ACTION)
875 && argument.empty()) {
876 argument = encoded_last_key;
879 // the insets can't try to handle this,
880 // a table cell in the dummy position will
881 // lock its insettext, the insettext will
882 // pass it the bufferview, and succeed,
883 // so it will stay not locked. Not good
884 // if we've just done LFUN_ESCAPE (which
885 // injects an LFUN_PARAGRAPH_UPDATE)
886 if (action == LFUN_PARAGRAPH_UPDATE) {
887 view()->dispatch(ev);
888 goto exit_with_message;
891 // Undo/Redo is a bit tricky for insets.
892 if (action == LFUN_UNDO) {
894 goto exit_with_message;
895 } else if (action == LFUN_REDO) {
897 goto exit_with_message;
898 } else if (((result=inset->
899 // Hand-over to inset's own dispatch:
900 localDispatch(FuncRequest(view(), action, argument))) ==
902 (result == DISPATCHED_NOUPDATE))
903 goto exit_with_message;
904 // If UNDISPATCHED, just soldier on
905 else if (result == FINISHED) {
906 owner->clearMessage();
907 goto exit_with_message;
908 // We do not need special RTL handling here:
909 // FINISHED means that the cursor should be
910 // one position after the inset.
911 } else if (result == FINISHED_RIGHT) {
912 view()->text->cursorRight(view());
914 owner->clearMessage();
915 goto exit_with_message;
916 } else if (result == FINISHED_UP) {
917 RowList::iterator const irow = view()->text->cursorIRow();
918 if (irow != view()->text->firstRow()) {
920 view()->text->setCursorFromCoordinates(
921 view()->text->cursor.x() + inset_x,
922 view()->text->cursor.y() -
923 irow->baseline() - 1);
924 view()->text->cursor.x_fix(view()->text->cursor.x());
926 view()->text->cursorUp(view());
932 owner->clearMessage();
933 goto exit_with_message;
934 } else if (result == FINISHED_DOWN) {
935 RowList::iterator const irow = view()->text->cursorIRow();
936 if (irow != view()->text->lastRow()) {
938 view()->text->setCursorFromCoordinates(
939 view()->text->cursor.x() + inset_x,
940 view()->text->cursor.y() -
943 view()->text->cursor.x_fix(view()->text->cursor.x());
945 view()->text->cursorDown(view());
948 view()->text->cursorRight(view());
951 owner->clearMessage();
952 goto exit_with_message;
954 #warning I am not sure this is still right, please have a look! (Jug 20020417)
955 else { // result == UNDISPATCHED
956 //setMessage(N_("Text mode"));
958 case LFUN_UNKNOWN_ACTION:
959 case LFUN_BREAKPARAGRAPH:
961 view()->text->cursorRight(view());
962 view()->switchKeyMap();
963 owner->view_state_changed();
966 if (!view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
967 view()->text->cursorRight(view());
969 owner->view_state_changed();
971 goto exit_with_message;
973 if (view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
974 view()->text->cursorRight(view());
976 owner->view_state_changed();
978 goto exit_with_message;
980 if (view()->text->cursorRow() != view()->text->lastRow())
981 view()->text->cursorDown(view());
983 view()->text->cursorRight(view());
985 owner->view_state_changed();
986 goto exit_with_message;
997 if (!view()->available())
999 // this function should be used always [asierra060396]
1000 UpdatableInset * tli = view()->theLockingInset();
1002 UpdatableInset * lock = tli->getLockingInset();
1005 view()->unlockInset(tli);
1006 view()->text->cursorRight(view());
1008 owner->view_state_changed();
1010 tli->unlockInsetInInset(view(), lock, true);
1013 // Tell the paragraph dialog that we changed paragraph
1014 dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
1019 case LFUN_WORDFINDFORWARD:
1020 case LFUN_WORDFINDBACKWARD: {
1021 static string last_search;
1022 string searched_string;
1024 if (!argument.empty()) {
1025 last_search = argument;
1026 searched_string = argument;
1028 searched_string = last_search;
1030 bool fw = (action == LFUN_WORDFINDFORWARD);
1031 if (!searched_string.empty())
1032 lyx::find::find(view(), searched_string, fw);
1037 if (view()->available() && !view()->theLockingInset())
1039 owner->message(keyseq.printOptions());
1042 // --- Misc -------------------------------------------
1043 case LFUN_EXEC_COMMAND:
1044 owner->focus_command_buffer();
1049 meta_fake_bit = key_modifier::none;
1050 if (view()->available())
1051 // cancel any selection
1052 dispatch(LFUN_MARK_OFF);
1053 setMessage(N_("Cancel"));
1056 case LFUN_META_FAKE:
1057 meta_fake_bit = key_modifier::alt;
1058 setMessage(keyseq.print());
1061 case LFUN_READ_ONLY_TOGGLE:
1062 if (owner->buffer()->lyxvc.inUse())
1063 owner->buffer()->lyxvc.toggleReadOnly();
1065 owner->buffer()->setReadonly(
1066 !owner->buffer()->isReadonly());
1069 case LFUN_CENTER: // this is center and redraw.
1073 // --- Menus -----------------------------------------------
1075 menuNew(argument, false);
1078 case LFUN_MENUNEWTMPLT:
1079 menuNew(argument, true);
1082 case LFUN_CLOSEBUFFER:
1086 case LFUN_MENUWRITE:
1087 if (!owner->buffer()->isUnnamed()) {
1088 string const str = bformat(_("Saving document %1$s..."),
1089 MakeDisplayPath(owner->buffer()->fileName()));
1090 owner->message(str);
1091 MenuWrite(owner->buffer());
1092 owner->message(str + _(" done."));
1094 WriteAs(owner->buffer());
1098 WriteAs(owner->buffer(), argument);
1101 case LFUN_MENURELOAD: {
1102 string const file = MakeDisplayPath(view()->buffer()->fileName(), 20);
1103 string text = bformat(_("Any changes will be lost. Are you sure "
1104 "you want to revert to the saved version of the document %1$s?"), file);
1105 int const ret = Alert::prompt(_("Revert to saved document?"),
1106 text, 0, 1, _("&Revert"), _("&Cancel"));
1114 Exporter::Export(owner->buffer(), argument, true);
1115 view()->showErrorList(BufferFormat(*owner->buffer()));
1119 Exporter::Preview(owner->buffer(), argument);
1120 view()->showErrorList(BufferFormat(*owner->buffer()));
1123 case LFUN_BUILDPROG:
1124 Exporter::Export(owner->buffer(), "program", true);
1125 view()->showErrorList(_("Build"));
1128 case LFUN_RUNCHKTEX:
1129 owner->buffer()->runChktex();
1130 view()->showErrorList(_("ChkTeX"));
1134 if (argument == "custom")
1135 owner->getDialogs().showSendto();
1137 Exporter::Export(owner->buffer(), argument, false);
1138 view()->showErrorList(BufferFormat(*owner->buffer()));
1152 InsetCommandParams p("tableofcontents");
1153 string const data = InsetCommandMailer::params2string("toc", p);
1154 owner->getDialogs().show("toc", data, 0);
1170 case LFUN_DEPTH_MIN:
1171 changeDepth(view(), view()->getLyXText(), DEC_DEPTH, false);
1172 owner->view_state_changed();
1175 case LFUN_DEPTH_PLUS:
1176 changeDepth(view(), view()->getLyXText(), INC_DEPTH, false);
1177 owner->view_state_changed();
1180 case LFUN_FREEFONT_APPLY:
1181 apply_freefont(view());
1184 case LFUN_FREEFONT_UPDATE:
1185 update_and_apply_freefont(view(), argument);
1188 case LFUN_RECONFIGURE:
1189 Reconfigure(view());
1193 case LFUN_FLOATSOPERATE:
1194 if (argument == "openfoot")
1195 view()->allFloats(1,0);
1196 else if (argument == "closefoot")
1197 view()->allFloats(0,0);
1198 else if (argument == "openfig")
1199 view()->allFloats(1,1);
1200 else if (argument == "closefig")
1201 view()->allFloats(0,1);
1204 #ifdef WITH_WARNINGS
1205 //#warning Find another implementation here (or another lyxfunc)!
1208 case LFUN_HELP_OPEN:
1210 string const arg = argument;
1212 setErrorMessage(N_("Missing argument"));
1215 string const fname = i18nLibFileSearch("doc", arg, "lyx");
1216 if (fname.empty()) {
1217 lyxerr << "LyX: unable to find documentation file `"
1218 << arg << "'. Bad installation?" << endl;
1221 owner->message(bformat(_("Opening help file %1$s..."),
1222 MakeDisplayPath(fname)));
1223 view()->loadLyXFile(fname, false);
1227 // --- version control -------------------------------
1228 case LFUN_VC_REGISTER:
1230 if (!ensureBufferClean(view()))
1232 if (!owner->buffer()->lyxvc.inUse()) {
1233 owner->buffer()->lyxvc.registrer();
1239 case LFUN_VC_CHECKIN:
1241 if (!ensureBufferClean(view()))
1243 if (owner->buffer()->lyxvc.inUse()
1244 && !owner->buffer()->isReadonly()) {
1245 owner->buffer()->lyxvc.checkIn();
1251 case LFUN_VC_CHECKOUT:
1253 if (!ensureBufferClean(view()))
1255 if (owner->buffer()->lyxvc.inUse()
1256 && owner->buffer()->isReadonly()) {
1257 owner->buffer()->lyxvc.checkOut();
1263 case LFUN_VC_REVERT:
1265 owner->buffer()->lyxvc.revert();
1272 owner->buffer()->lyxvc.undoLast();
1277 // --- buffers ----------------------------------------
1279 case LFUN_SWITCHBUFFER:
1280 view()->buffer(bufferlist.getBuffer(argument));
1284 NewFile(view(), argument);
1287 case LFUN_FILE_OPEN:
1291 case LFUN_LAYOUT_TABULAR:
1292 if (view()->theLockingInset()) {
1293 if (view()->theLockingInset()->lyxCode()== InsetOld::TABULAR_CODE) {
1294 InsetTabular * inset = static_cast<InsetTabular *>
1295 (view()->theLockingInset());
1296 inset->openLayoutDialog(view());
1297 } else if (view()->theLockingInset()->
1298 getFirstLockingInsetOfType(InsetOld::TABULAR_CODE)!=0) {
1299 InsetTabular * inset = static_cast<InsetTabular *>(
1300 view()->theLockingInset()->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE));
1301 inset->openLayoutDialog(view());
1306 case LFUN_DROP_LAYOUTS_CHOICE:
1307 owner->getToolbar().openLayoutList();
1310 case LFUN_MENU_OPEN_BY_NAME:
1311 owner->getMenubar().openByName(argument);
1312 break; // RVDK_PATCH_5
1314 // --- lyxserver commands ----------------------------
1318 setMessage(owner->buffer()->fileName());
1319 lyxerr[Debug::INFO] << "FNAME["
1320 << owner->buffer()->fileName()
1326 dispatch_buffer = keyseq.print();
1327 lyxserver->notifyClient(dispatch_buffer);
1331 case LFUN_GOTOFILEROW:
1335 istringstream istr(argument.c_str());
1336 istr >> file_name >> row;
1337 // Must replace extension of the file to be .lyx and get full path
1338 string const s(ChangeExtension(file_name, ".lyx"));
1340 // Either change buffer or load the file
1341 if (bufferlist.exists(s)) {
1342 view()->buffer(bufferlist.getBuffer(s));
1344 view()->loadLyXFile(s);
1347 view()->setCursorFromRow(row);
1350 // see BufferView_pimpl::center()
1351 view()->updateScrollbar();
1355 case LFUN_GOTO_PARAGRAPH:
1357 istringstream istr(argument.c_str());
1361 ParIterator par = owner->buffer()->getParFromID(id);
1362 if (par == owner->buffer()->par_iterator_end()) {
1363 lyxerr[Debug::INFO] << "No matching paragraph found! ["
1364 << id << ']' << endl;
1367 lyxerr[Debug::INFO] << "Paragraph " << par->id()
1368 << " found." << endl;
1371 if (view()->theLockingInset())
1372 view()->unlockInset(view()->theLockingInset());
1373 if (par->inInset()) {
1374 FuncRequest cmd(view(), LFUN_INSET_EDIT, "left");
1375 par->inInset()->localDispatch(cmd);
1378 view()->getLyXText()->setCursor(par.pit(), 0);
1379 view()->switchKeyMap();
1380 owner->view_state_changed();
1383 // see BufferView_pimpl::center()
1384 view()->updateScrollbar();
1388 // --- insert characters ----------------------------------------
1390 // --- Mathed stuff. If we are here, there is no locked inset yet.
1391 case LFUN_MATH_EXTERN:
1392 case LFUN_MATH_NUMBER:
1393 case LFUN_MATH_NONUMBER:
1394 case LFUN_MATH_LIMITS:
1396 setErrorMessage(N_("This is only allowed in math mode!"));
1400 // passthrough hat and underscore outside mathed:
1401 case LFUN_SUBSCRIPT:
1402 dispatch(FuncRequest(view(), LFUN_SELFINSERT, "_"));
1404 case LFUN_SUPERSCRIPT:
1405 dispatch(FuncRequest(view(), LFUN_SELFINSERT, "^"));
1408 case LFUN_DIALOG_SHOW: {
1409 string const name = ev.getArg(0);
1410 string data = trim(ev.argument.substr(name.size()));
1412 if (name == "character") {
1413 data = freefont2string();
1415 owner->getDialogs().show("character", data);
1416 } else if (name == "document")
1417 owner->getDialogs().showDocument();
1418 else if (name == "findreplace")
1419 owner->getDialogs().showSearch();
1420 else if (name == "forks")
1421 owner->getDialogs().showForks();
1422 else if (name == "preamble")
1423 owner->getDialogs().showPreamble();
1424 else if (name == "preferences")
1425 owner->getDialogs().showPreferences();
1426 else if (name == "print")
1427 owner->getDialogs().showPrint();
1428 else if (name == "spellchecker")
1429 owner->getDialogs().showSpellchecker();
1431 owner->getDialogs().show(name, data);
1435 case LFUN_DIALOG_SHOW_NEW_INSET: {
1436 string const & name = argument;
1438 if (name == "bibitem" ||
1440 name == "include" ||
1445 InsetCommandParams p(name);
1446 data = InsetCommandMailer::params2string(name, p);
1447 } else if (name == "citation") {
1448 InsetCommandParams p("cite");
1449 data = InsetCommandMailer::params2string(name, p);
1451 owner->getDialogs().show(name, data, 0);
1455 case LFUN_DIALOG_SHOW_NEXT_INSET: {
1459 case LFUN_INSET_DIALOG_SHOW: {
1460 LyXText * lt = view()->getLyXText();
1461 InsetOld * inset = lt->getInset();
1463 FuncRequest cmd(view(), LFUN_INSET_DIALOG_SHOW);
1464 inset->localDispatch(cmd);
1469 case LFUN_DIALOG_UPDATE: {
1470 string const & name = argument;
1471 // Can only update a dialog connected to an existing inset
1472 InsetBase * inset = owner->getDialogs().getOpenInset(name);
1474 FuncRequest fr(view(), LFUN_INSET_DIALOG_UPDATE,
1476 inset->localDispatch(fr);
1477 } else if (name == "paragraph") {
1478 dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
1483 case LFUN_DIALOG_HIDE:
1484 Dialogs::hide(argument, 0);
1487 case LFUN_DIALOG_DISCONNECT_INSET:
1488 owner->getDialogs().disconnect(argument);
1491 case LFUN_CHILDOPEN:
1493 string const filename =
1494 MakeAbsPath(argument,
1495 owner->buffer()->filePath());
1496 setMessage(N_("Opening child document ") +
1497 MakeDisplayPath(filename) + "...");
1498 view()->savePosition(0);
1499 if (bufferlist.exists(filename))
1500 view()->buffer(bufferlist.getBuffer(filename));
1502 view()->loadLyXFile(filename);
1506 case LFUN_TOGGLECURSORFOLLOW:
1507 lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
1511 owner->getIntl().KeyMapOn(false);
1514 case LFUN_KMAP_PRIM:
1515 owner->getIntl().KeyMapPrim();
1519 owner->getIntl().KeyMapSec();
1522 case LFUN_KMAP_TOGGLE:
1523 owner->getIntl().ToggleKeyMap();
1528 // argument contains ';'-terminated commands
1529 while (!argument.empty()) {
1531 argument = split(argument, first, ';');
1537 case LFUN_SAVEPREFERENCES:
1539 Path p(user_lyxdir());
1540 lyxrc.write("preferences");
1544 case LFUN_SCREEN_FONT_UPDATE:
1546 // handle the screen font changes.
1547 lyxrc.set_font_norm_type();
1548 lyx_gui::update_fonts();
1549 // We also need to empty the textcache so that
1550 // the buffer will be formatted correctly after
1553 // Of course we should only do the resize and the textcache.clear
1554 // if values really changed...but not very important right now. (Lgb)
1555 // All visible buffers will need resize
1561 case LFUN_SET_COLOR:
1564 string const x11_name = split(argument, lyx_name, ' ');
1565 if (lyx_name.empty() || x11_name.empty()) {
1566 setErrorMessage(N_("Syntax: set-color <lyx_name>"
1571 bool const graphicsbg_changed =
1572 (lyx_name == lcolor.getLyXName(LColor::graphicsbg) &&
1573 x11_name != lcolor.getX11Name(LColor::graphicsbg));
1575 if (!lcolor.setColor(lyx_name, x11_name)) {
1577 bformat(_("Set-color \"%1$s\" failed "
1578 "- color is undefined or "
1579 "may not be redefined"), lyx_name));
1583 lyx_gui::update_color(lcolor.getFromLyXName(lyx_name));
1585 if (graphicsbg_changed) {
1586 #ifdef WITH_WARNINGS
1587 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1590 lyx::graphics::GCache & gc =
1591 lyx::graphics::GCache::get();
1592 gc.changeDisplay(true);
1601 owner->message(argument);
1604 case LFUN_FORKS_KILL:
1606 if (!isStrInt(argument))
1609 pid_t const pid = strToInt(argument);
1610 ForkedcallsController & fcc = ForkedcallsController::get();
1615 case LFUN_TOOLTIPS_TOGGLE:
1616 owner->getDialogs().toggleTooltips();
1619 case LFUN_EXTERNAL_EDIT: {
1621 .localDispatch(FuncRequest(view(), action, argument));
1626 // Then if it was none of the above
1627 // Trying the BufferView::pimpl dispatch:
1628 if (!view()->dispatch(ev))
1629 lyxerr << "A truly unknown func ["
1630 << lyxaction.getActionName(ev.action) << "]!"
1637 view()->owner()->updateLayoutChoice();
1639 if (view()->available()) {
1640 if (view()->fitCursor()) {
1641 lyxerr << "LyXFunc->fitCursor->update" << endl;
1646 // If we executed a mutating lfun, mark the buffer as dirty
1647 if (!getStatus(ev).disabled()
1648 && !lyxaction.funcHasFlag(ev.action, LyXAction::NoBuffer)
1649 && !lyxaction.funcHasFlag(ev.action, LyXAction::ReadOnly))
1650 view()->buffer()->markDirty();
1653 sendDispatchMessage(getMessage(), ev, verbose);
1657 void LyXFunc::sendDispatchMessage(string const & msg, FuncRequest const & ev, bool verbose)
1659 owner->updateMenubar();
1660 owner->updateToolbar();
1662 if (ev.action == LFUN_SELFINSERT || !verbose) {
1663 lyxerr[Debug::ACTION] << "dispatch msg is " << msg << endl;
1665 owner->message(msg);
1669 string dispatch_msg = msg;
1670 if (!dispatch_msg.empty())
1671 dispatch_msg += ' ';
1673 string comname = lyxaction.getActionName(ev.action);
1675 int pseudoaction = ev.action;
1676 bool argsadded = false;
1678 if (!ev.argument.empty()) {
1679 // the pseudoaction is useful for the bindings
1680 pseudoaction = lyxaction.searchActionArg(ev.action, ev.argument);
1682 if (pseudoaction == LFUN_UNKNOWN_ACTION) {
1683 pseudoaction = ev.action;
1685 comname += ' ' + ev.argument;
1690 string const shortcuts = toplevel_keymap->findbinding(pseudoaction);
1692 if (!shortcuts.empty()) {
1693 comname += ": " + shortcuts;
1694 } else if (!argsadded && !ev.argument.empty()) {
1695 comname += ' ' + ev.argument;
1698 if (!comname.empty()) {
1699 comname = rtrim(comname);
1700 dispatch_msg += '(' + comname + ')';
1703 lyxerr[Debug::ACTION] << "verbose dispatch msg " << dispatch_msg << endl;
1704 if (!dispatch_msg.empty())
1705 owner->message(dispatch_msg);
1709 void LyXFunc::setupLocalKeymap()
1711 keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
1712 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap.get();
1716 void LyXFunc::menuNew(string const & name, bool fromTemplate)
1718 string initpath = lyxrc.document_path;
1719 string filename(name);
1721 if (view()->available()) {
1722 string const trypath = owner->buffer()->filePath();
1723 // If directory is writeable, use this as default.
1724 if (IsDirWriteable(trypath))
1728 static int newfile_number;
1730 if (filename.empty()) {
1731 filename = AddName(lyxrc.document_path,
1732 "newfile" + tostr(++newfile_number) + ".lyx");
1733 FileInfo fi(filename);
1734 while (bufferlist.exists(filename) || fi.readable()) {
1736 filename = AddName(lyxrc.document_path,
1737 "newfile" + tostr(newfile_number) +
1739 fi.newFile(filename);
1743 // The template stuff
1746 FileDialog fileDlg(_("Select template file"),
1747 LFUN_SELECT_FILE_SYNC,
1748 make_pair(string(_("Documents|#o#O")),
1749 string(lyxrc.document_path)),
1750 make_pair(string(_("Templates|#T#t")),
1751 string(lyxrc.template_path)));
1753 FileDialog::Result result =
1754 fileDlg.open(lyxrc.template_path,
1755 _("*.lyx| LyX Documents (*.lyx)"));
1757 if (result.first == FileDialog::Later)
1760 string const fname = result.second;
1767 view()->newFile(filename, templname, !name.empty());
1771 void LyXFunc::open(string const & fname)
1773 string initpath = lyxrc.document_path;
1775 if (view()->available()) {
1776 string const trypath = owner->buffer()->filePath();
1777 // If directory is writeable, use this as default.
1778 if (IsDirWriteable(trypath))
1784 if (fname.empty()) {
1785 FileDialog fileDlg(_("Select document to open"),
1787 make_pair(string(_("Documents|#o#O")),
1788 string(lyxrc.document_path)),
1789 make_pair(string(_("Examples|#E#e")),
1790 string(AddPath(system_lyxdir(), "examples"))));
1792 FileDialog::Result result =
1793 fileDlg.open(initpath,
1794 _("*.lyx| LyX Documents (*.lyx)"));
1796 if (result.first == FileDialog::Later)
1799 filename = result.second;
1801 // check selected filename
1802 if (filename.empty()) {
1803 owner->message(_("Canceled."));
1809 // get absolute path of file and add ".lyx" to the filename if
1811 string const fullpath = FileSearch(string(), filename, "lyx");
1812 if (!fullpath.empty()) {
1813 filename = fullpath;
1816 string const disp_fn(MakeDisplayPath(filename));
1818 // if the file doesn't exist, let the user create one
1819 FileInfo const f(filename, true);
1821 // the user specifically chose this name. Believe them.
1822 view()->newFile(filename, "", true);
1826 owner->message(bformat(_("Opening document %1$s..."), disp_fn));
1829 if (view()->loadLyXFile(filename)) {
1830 str2 = bformat(_("Document %1$s opened."), disp_fn);
1832 str2 = bformat(_("Could not open document %1$s"), disp_fn);
1834 owner->message(str2);
1838 void LyXFunc::doImport(string const & argument)
1841 string filename = split(argument, format, ' ');
1843 lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format
1844 << " file: " << filename << endl;
1846 // need user interaction
1847 if (filename.empty()) {
1848 string initpath = lyxrc.document_path;
1850 if (view()->available()) {
1851 string const trypath = owner->buffer()->filePath();
1852 // If directory is writeable, use this as default.
1853 if (IsDirWriteable(trypath))
1857 string const text = bformat(_("Select %1$s file to import"),
1858 formats.prettyName(format));
1860 FileDialog fileDlg(text,
1862 make_pair(string(_("Documents|#o#O")),
1863 string(lyxrc.document_path)),
1864 make_pair(string(_("Examples|#E#e")),
1865 string(AddPath(system_lyxdir(), "examples"))));
1867 string const extension = "*." + formats.extension(format)
1868 + "| " + formats.prettyName(format)
1869 + " (*." + formats.extension(format) + ')';
1871 FileDialog::Result result = fileDlg.open(initpath,
1874 if (result.first == FileDialog::Later)
1877 filename = result.second;
1879 // check selected filename
1880 if (filename.empty())
1881 owner->message(_("Canceled."));
1884 if (filename.empty())
1887 // get absolute path of file
1888 filename = MakeAbsPath(filename);
1890 string const lyxfile = ChangeExtension(filename, ".lyx");
1892 // Check if the document already is open
1893 if (lyx_gui::use_gui && bufferlist.exists(lyxfile)) {
1894 if (!bufferlist.close(bufferlist.getBuffer(lyxfile), true)) {
1895 owner->message(_("Canceled."));
1900 // if the file exists already, and we didn't do
1901 // -i lyx thefile.lyx, warn
1902 if (FileInfo(lyxfile, true).exist() && filename != lyxfile) {
1903 string const file = MakeDisplayPath(lyxfile, 30);
1905 string text = bformat(_("The document %1$s already exists.\n\n"
1906 "Do you want to over-write that document?"), file);
1907 int const ret = Alert::prompt(_("Over-write document?"),
1908 text, 0, 1, _("&Over-write"), _("&Cancel"));
1911 owner->message(_("Canceled."));
1916 Importer::Import(owner, filename, format);
1920 void LyXFunc::closeBuffer()
1922 if (bufferlist.close(owner->buffer(), true) && !quitting) {
1923 if (bufferlist.empty()) {
1924 // need this otherwise SEGV may occur while
1925 // trying to set variables that don't exist
1926 // since there's no current buffer
1927 owner->getDialogs().hideBufferDependent();
1929 view()->buffer(bufferlist.first());
1935 // Each "owner" should have it's own message method. lyxview and
1936 // the minibuffer would use the minibuffer, but lyxserver would
1937 // send an ERROR signal to its client. Alejandro 970603
1938 // This func is bit problematic when it comes to NLS, to make the
1939 // lyx servers client be language indepenent we must not translate
1940 // strings sent to this func.
1941 void LyXFunc::setErrorMessage(string const & m) const
1943 dispatch_buffer = m;
1948 void LyXFunc::setMessage(string const & m) const
1950 dispatch_buffer = m;
1954 void LyXFunc::setStatusMessage(string const & m) const
1960 string const LyXFunc::view_status_message()
1962 // When meta-fake key is pressed, show the key sequence so far + "M-".
1964 return keyseq.print() + "M-";
1967 // Else, when a non-complete key sequence is pressed,
1968 // show the available options.
1969 if (keyseq.length() > 0 && !keyseq.deleted()) {
1970 return keyseq.printOptions();
1973 if (!view()->available())
1974 return _("Welcome to LyX!");
1976 return currentState(view());
1980 BufferView * LyXFunc::view() const
1983 return owner->view().get();
1987 bool LyXFunc::wasMetaKey() const
1989 return (meta_fake_bit != key_modifier::none);