1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2001 The LyX Team.
9 * ====================================================== */
17 #include "bufferlist.h"
18 #include "BufferView.h"
19 #include "lyxserver.h"
23 #include "LyXAction.h"
29 #include "trans_mgr.h"
32 #include "bufferview_funcs.h"
33 #include "frontends/LyXView.h"
34 #include "frontends/lyx_gui.h"
36 #include "FloatList.h"
40 #include "TextCache.h"
42 #include "undo_funcs.h"
43 #include "ParagraphParameters.h"
45 #include "insets/insetcommand.h"
46 #include "insets/insettabular.h"
48 #include "mathed/formulamacro.h"
49 #include "mathed/math_cursor.h"
50 #include "mathed/math_inset.h"
52 #include "frontends/FileDialog.h"
53 #include "frontends/Dialogs.h"
54 #include "frontends/Toolbar.h"
55 #include "frontends/Menubar.h"
56 #include "frontends/Alert.h"
58 #include "graphics/GraphicsCache.h"
60 #include "support/lyxalgo.h"
61 #include "support/LAssert.h"
62 #include "support/filetools.h"
63 #include "support/FileInfo.h"
64 #include "support/forkedcontr.h"
65 #include "support/lstrings.h"
66 #include "support/path.h"
67 #include "support/lyxfunctional.h"
69 #include "support/BoostFormat.h"
85 using std::back_inserter;
86 using namespace bv_funcs;
88 extern BufferList bufferlist;
89 extern LyXServer * lyxserver;
90 extern bool selection_possible;
92 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
95 extern tex_accent_struct get_accent(kb_action action);
97 extern void ShowLatexLog();
100 LyXFunc::LyXFunc(LyXView * o)
103 keyseq(toplevel_keymap.get(), toplevel_keymap.get()),
104 cancel_meta_seq(toplevel_keymap.get(), toplevel_keymap.get()),
105 meta_fake_bit(key_modifier::none)
111 LyXText * LyXFunc::TEXT(bool flag = true) const
115 return view()->getLyXText();
120 void LyXFunc::moveCursorUpdate(bool flag, bool selecting)
122 if (selecting || TEXT(flag)->selection.mark()) {
123 TEXT(flag)->setSelection();
124 if (!TEXT(flag)->isInInset())
125 view()->toggleToggle();
127 view()->update(TEXT(flag), BufferView::SELECT);
128 view()->showCursor();
130 view()->switchKeyMap();
134 void LyXFunc::handleKeyFunc(kb_action action)
136 char c = encoded_last_key;
138 if (keyseq.length()) {
142 owner->getIntl().getTransManager()
143 .deadkey(c, get_accent(action).accent, TEXT(false));
144 // Need to clear, in case the minibuffer calls these
147 // copied verbatim from do_accent_char
148 view()->update(TEXT(false), BufferView::SELECT);
149 TEXT(false)->selection.cursor = TEXT(false)->cursor;
153 void LyXFunc::processKeySym(LyXKeySymPtr keysym,
154 key_modifier::state state)
158 if (lyxerr.debugging(Debug::KEY)) {
159 lyxerr << "KeySym is "
160 << keysym->getSymbolName()
164 // Do nothing if we have nothing (JMarc)
165 if (!keysym->isOK()) {
166 lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
171 if (keysym->isModifier()) {
172 lyxerr[Debug::KEY] << "isModifier true" << endl;
176 Encoding const * encoding = view()->getEncoding();
178 encoded_last_key = keysym->getISOEncoded(encoding ? encoding->Name() : "");
180 // Do a one-deep top-level lookup for
181 // cancel and meta-fake keys. RVDK_PATCH_5
182 cancel_meta_seq.reset();
184 int action = cancel_meta_seq.addkey(keysym, state);
185 lyxerr[Debug::KEY] << "action first set to [" << action << ']' << endl;
187 // When not cancel or meta-fake, do the normal lookup.
188 // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
189 // Mostly, meta_fake_bit = key_modifier::none. RVDK_PATCH_5.
190 if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
191 // remove Caps Lock and Mod2 as a modifiers
192 action = keyseq.addkey(keysym, (state | meta_fake_bit));
193 lyxerr[Debug::KEY] << "action now set to ["
194 << action << ']' << endl;
197 // Dont remove this unless you know what you are doing.
198 meta_fake_bit = key_modifier::none;
200 // can this happen now ?
201 if (action == LFUN_NOACTION) {
202 action = LFUN_PREFIX;
205 if (lyxerr.debugging(Debug::KEY)) {
206 lyxerr << "Key [action="
208 << keyseq.print() << ']'
212 // already here we know if it any point in going further
213 // why not return already here if action == -1 and
214 // num_bytes == 0? (Lgb)
216 if (keyseq.length() > 1) {
217 owner->message(keyseq.print());
221 // Maybe user can only reach the key via holding down shift.
222 // Let's see. But only if shift is the only modifier
223 if (action == LFUN_UNKNOWN_ACTION && state == key_modifier::shift) {
224 lyxerr[Debug::KEY] << "Trying without shift" << endl;
225 action = keyseq.addkey(keysym, key_modifier::none);
226 lyxerr[Debug::KEY] << "Action now " << action << endl;
229 if (action == LFUN_UNKNOWN_ACTION) {
230 // Hmm, we didn't match any of the keysequences. See
231 // if it's normal insertable text not already covered
233 if (keysym->isText() && keyseq.length() == 1) {
234 lyxerr[Debug::KEY] << "isText() is true, inserting." << endl;
235 action = LFUN_SELFINSERT;
237 lyxerr[Debug::KEY] << "Unknown, !isText() - giving up" << endl;
238 owner->message(_("Unknown function."));
243 if (action == LFUN_SELFINSERT) {
244 if (encoded_last_key != 0) {
246 arg += encoded_last_key;
248 dispatch(FuncRequest(view(), LFUN_SELFINSERT, arg));
250 lyxerr[Debug::KEY] << "SelfInsert arg[`"
251 << argument << "']" << endl;
259 FuncStatus LyXFunc::getStatus(int ac) const
261 return getStatus(lyxaction.retrieveActionArg(ac));
265 FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
268 Buffer * buf = owner->buffer();
270 if (ev.action == LFUN_NOACTION) {
271 setStatusMessage(N_("Nothing to do"));
272 return flag.disabled(true);
276 case LFUN_UNKNOWN_ACTION:
277 #ifndef HAVE_LIBAIKSAURUS
278 case LFUN_THESAURUS_ENTRY:
283 flag |= lyx_gui::getStatus(ev);
286 if (flag.unknown()) {
287 setStatusMessage(N_("Unknown action"));
291 // the default error message if we disable the command
292 setStatusMessage(N_("Command disabled"));
294 // Check whether we need a buffer
295 if (!lyxaction.funcHasFlag(ev.action, LyXAction::NoBuffer)) {
296 // Yes we need a buffer, do we have one?
299 // Can we use a readonly buffer?
300 if (buf->isReadonly() &&
301 !lyxaction.funcHasFlag(ev.action,
302 LyXAction::ReadOnly)) {
304 setStatusMessage(N_("Document is read-only"));
309 setStatusMessage(N_("Command not allowed with"
310 "out any document open"));
311 return flag.disabled(true);
315 UpdatableInset * tli = view()->theLockingInset();
317 // I would really like to avoid having this switch and rather try to
318 // encode this in the function itself.
319 bool disable = false;
322 disable = !Exporter::IsExportable(buf, "dvi")
323 || lyxrc.print_command == "none";
326 disable = ev.argument != "custom"
327 && !Exporter::IsExportable(buf, ev.argument);
330 disable = buf->undostack.empty();
333 disable = buf->redostack.empty();
338 UpdatableInset * in = tli;
339 if (in->lyxCode() != Inset::TABULAR_CODE) {
340 in = tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE);
342 if (in && static_cast<InsetTabular*>(in)->hasSelection()) {
347 disable = !mathcursor && !view()->getLyXText()->selection.set();
350 disable = !buf->isLatex() || lyxrc.chktex_command == "none";
353 disable = !Exporter::IsExportable(buf, "program");
356 case LFUN_LAYOUT_CHARACTER:
357 disable = tli && tli->lyxCode() == Inset::ERT_CODE;
360 case LFUN_LAYOUT_TABULAR:
362 || (tli->lyxCode() != Inset::TABULAR_CODE
363 && !tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
367 disable = !changeDepth(view(), TEXT(false), DEC_DEPTH, true);
370 case LFUN_DEPTH_PLUS:
371 disable = !changeDepth(view(), TEXT(false), INC_DEPTH, true);
375 case LFUN_LAYOUT_PARAGRAPH: {
376 Inset * inset = TEXT(false)->cursor.par()->inInset();
377 disable = inset && inset->forceDefaultParagraphs(inset);
381 case LFUN_INSET_OPTARG:
382 disable = (TEXT(false)->cursor.par()->layout()->optionalargs == 0);
385 case LFUN_TABULAR_FEATURE:
388 // FIXME: check temporarily disabled
390 char align = mathcursor->valign();
395 if (ev.argument.empty()) {
399 if (!contains("tcb", ev.argument[0])) {
403 flag.setOnOff(ev.argument[0] == align);
407 char align = mathcursor->halign();
412 if (ev.argument.empty()) {
416 if (!contains("lcr", ev.argument[0])) {
420 flag.setOnOff(ev.argument[0] == align);
423 disable = !mathcursor->halign();
429 //ret.disabled(true);
430 if (tli->lyxCode() == Inset::TABULAR_CODE) {
431 ret = static_cast<InsetTabular *>(tli)
432 ->getStatus(ev.argument);
435 } else if (tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
436 ret = static_cast<InsetTabular *>
437 (tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE))
438 ->getStatus(ev.argument);
445 static InsetTabular inset(*owner->buffer(), 1, 1);
449 ret = inset.getStatus(ev.argument);
450 if (ret.onoff(true) || ret.onoff(false))
451 flag.setOnOff(false);
455 case LFUN_VC_REGISTER:
456 disable = buf->lyxvc.inUse();
458 case LFUN_VC_CHECKIN:
459 disable = !buf->lyxvc.inUse() || buf->isReadonly();
461 case LFUN_VC_CHECKOUT:
462 disable = !buf->lyxvc.inUse() || !buf->isReadonly();
466 case LFUN_VC_HISTORY:
467 disable = !buf->lyxvc.inUse();
469 case LFUN_MENURELOAD:
470 disable = buf->isUnnamed() || buf->isClean();
472 case LFUN_BOOKMARK_GOTO:
474 isSavedPosition(strToUnsignedInt(ev.argument));
476 case LFUN_MERGE_CHANGES:
477 case LFUN_ACCEPT_CHANGE:
478 case LFUN_REJECT_CHANGE:
479 case LFUN_ACCEPT_ALL_CHANGES:
480 case LFUN_REJECT_ALL_CHANGES:
481 disable = !buf->params.tracking_changes;
483 case LFUN_INSET_TOGGLE: {
484 LyXText * lt = view()->getLyXText();
485 disable = !(isEditableInset(lt->getInset())
487 && lt->inset_owner->owner()
488 && lt->inset_owner->owner()->isOpen()));
492 case LFUN_INSET_SETTINGS: {
494 UpdatableInset * inset = view()->theLockingInset();
499 // get the innermost inset
500 inset = inset->getLockingInset();
502 // jump back to owner if an InsetText, so
503 // we get back to the InsetTabular or whatever
504 if (inset->lyxCode() == Inset::TEXT_CODE)
505 inset = static_cast<UpdatableInset*>(inset->owner());
507 Inset::Code code = inset->lyxCode();
509 case Inset::TABULAR_CODE:
510 disable = ev.argument != "tabular";
512 case Inset::ERT_CODE:
513 disable = ev.argument != "ert";
515 case Inset::FLOAT_CODE:
516 disable = ev.argument != "float";
518 case Inset::MINIPAGE_CODE:
519 disable = ev.argument != "minipage";
521 case Inset::WRAP_CODE:
522 disable = ev.argument != "wrap";
531 disable = !IsFileReadable(buf->getLogName().second);
534 case LFUN_MATH_MUTATE:
536 //flag.setOnOff(mathcursor->formula()->hullType() == ev.argument);
537 flag.setOnOff(false);
542 // we just need to be in math mode to enable that
544 case LFUN_MATH_SPACE:
545 case LFUN_MATH_LIMITS:
546 case LFUN_MATH_NONUMBER:
547 case LFUN_MATH_NUMBER:
548 case LFUN_MATH_EXTERN:
549 disable = !mathcursor;
556 // the functions which insert insets
557 Inset::Code code = Inset::NO_CODE;
559 case LFUN_DIALOG_SHOW_NEW_INSET:
560 if (ev.argument == "bibitem")
561 code = Inset::BIBITEM_CODE;
562 else if (ev.argument == "bibtex")
563 code = Inset::BIBTEX_CODE;
564 else if (ev.argument == "citation")
565 code = Inset::CITE_CODE;
566 else if (ev.argument == "ert")
567 code = Inset::ERT_CODE;
568 else if (ev.argument == "external")
569 code = Inset::EXTERNAL_CODE;
570 else if (ev.argument == "float")
571 code = Inset::FLOAT_CODE;
572 else if (ev.argument == "graphics")
573 code = Inset::GRAPHICS_CODE;
574 else if (ev.argument == "include")
575 code = Inset::INCLUDE_CODE;
576 else if (ev.argument == "index")
577 code = Inset::INDEX_CODE;
578 else if (ev.argument == "label")
579 code = Inset::LABEL_CODE;
580 else if (ev.argument == "minipage")
581 code = Inset::MINIPAGE_CODE;
582 else if (ev.argument == "ref")
583 code = Inset::REF_CODE;
584 else if (ev.argument == "toc")
585 code = Inset::TOC_CODE;
586 else if (ev.argument == "url")
587 code = Inset::URL_CODE;
588 else if (ev.argument == "wrap")
589 code = Inset::WRAP_CODE;
593 code = Inset::ERT_CODE;
595 case LFUN_INSET_FOOTNOTE:
596 code = Inset::FOOT_CODE;
598 case LFUN_TABULAR_INSERT:
599 code = Inset::TABULAR_CODE;
601 case LFUN_INSET_MARGINAL:
602 code = Inset::MARGIN_CODE;
604 case LFUN_INSET_MINIPAGE:
605 code = Inset::MINIPAGE_CODE;
607 case LFUN_INSET_FLOAT:
608 case LFUN_INSET_WIDE_FLOAT:
609 code = Inset::FLOAT_CODE;
611 case LFUN_INSET_WRAP:
612 code = Inset::WRAP_CODE;
614 case LFUN_FLOAT_LIST:
615 code = Inset::FLOAT_LIST_CODE;
618 case LFUN_INSET_LIST:
619 code = Inset::LIST_CODE;
621 case LFUN_INSET_THEOREM:
622 code = Inset::THEOREM_CODE;
625 case LFUN_INSET_CAPTION:
626 code = Inset::CAPTION_CODE;
628 case LFUN_INSERT_NOTE:
629 code = Inset::NOTE_CODE;
631 case LFUN_INSERT_LABEL:
632 code = Inset::LABEL_CODE;
634 case LFUN_INSET_OPTARG:
635 code = Inset::OPTARG_CODE;
637 case LFUN_ENVIRONMENT_INSERT:
638 code = Inset::MINIPAGE_CODE;
640 case LFUN_INDEX_INSERT:
641 code = Inset::INDEX_CODE;
643 case LFUN_INDEX_PRINT:
644 code = Inset::INDEX_PRINT_CODE;
646 case LFUN_TOC_INSERT:
647 code = Inset::TOC_CODE;
649 case LFUN_PARENTINSERT:
650 code = Inset::PARENT_CODE;
654 code = Inset::URL_CODE;
657 // always allow this, since we will inset a raw quote
658 // if an inset is not allowed.
660 case LFUN_HYPHENATION:
661 case LFUN_LIGATURE_BREAK:
663 case LFUN_MENU_SEPARATOR:
665 case LFUN_END_OF_SENTENCE:
666 code = Inset::SPECIALCHAR_CODE;
668 case LFUN_PROTECTEDSPACE:
669 // slight hack: we know this is allowed in math mode
671 code = Inset::SPECIALCHAR_CODE;
676 if (code != Inset::NO_CODE && tli && !tli->insetAllowed(code))
682 // A few general toggles
684 case LFUN_TOOLTIPS_TOGGLE:
685 flag.setOnOff(owner->getDialogs().tooltipsEnabled());
688 case LFUN_READ_ONLY_TOGGLE:
689 flag.setOnOff(buf->isReadonly());
692 flag.setOnOff(TEXT(false)->cursor.par()->params().startOfAppendix());
694 case LFUN_SWITCHBUFFER:
695 // toggle on the current buffer, but do not toggle off
696 // the other ones (is that a good idea?)
697 if (ev.argument == buf->fileName())
700 case LFUN_TRACK_CHANGES:
701 flag.setOnOff(buf->params.tracking_changes);
707 // the font related toggles
709 LyXFont const & font = TEXT(false)->real_current_font;
712 flag.setOnOff(font.emph() == LyXFont::ON);
715 flag.setOnOff(font.noun() == LyXFont::ON);
718 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
721 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
724 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
727 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
733 string tc = mathcursor->getLastCode();
736 flag.setOnOff(tc == "mathbf");
739 flag.setOnOff(tc == "mathsf");
742 flag.setOnOff(tc == "mathcal");
745 flag.setOnOff(tc == "mathrm");
748 flag.setOnOff(tc == "mathtt");
751 flag.setOnOff(tc == "mathbb");
754 flag.setOnOff(tc == "mathnormal");
761 // this one is difficult to get right. As a half-baked
762 // solution, we consider only the first action of the sequence
763 if (ev.action == LFUN_SEQUENCE) {
764 // argument contains ';'-terminated commands
765 flag = getStatus(lyxaction.LookupFunc(token(ev.argument, ';', 0)));
772 void LyXFunc::dispatch(string const & s, bool verbose)
774 int const action = lyxaction.LookupFunc(s);
776 if (action == LFUN_UNKNOWN_ACTION) {
778 boost::format fmt(_("Unknown function (%1$s)"));
780 owner->message(fmt.str());
782 string const msg = string(_("Unknown function ("))
789 dispatch(action, verbose);
793 void LyXFunc::dispatch(int ac, bool verbose)
795 dispatch(lyxaction.retrieveActionArg(ac), verbose);
800 void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
802 lyxerr[Debug::ACTION] << "LyXFunc::dispatch: action[" << ev.action
803 <<"] arg[" << ev.argument << ']' << endl;
805 // we have not done anything wrong yet.
807 dispatch_buffer.erase();
809 #ifdef NEW_DISPATCHER
810 // We try do call the most specific dispatcher first:
811 // 1. the lockinginset's dispatch
812 // 2. the bufferview's dispatch
813 // 3. the lyxview's dispatch
816 selection_possible = false;
818 if (view()->available())
819 view()->hideCursor();
821 string argument = ev.argument;
822 kb_action action = ev.action;
824 // We cannot use this function here
825 if (getStatus(ev).disabled()) {
826 lyxerr[Debug::ACTION] << "LyXFunc::dispatch: "
827 << lyxaction.getActionName(action)
828 << " [" << action << "] is disabled at this location"
830 setErrorMessage(getStatusMessage());
831 goto exit_with_message;
834 if (view()->available() && view()->theLockingInset()) {
835 Inset::RESULT result;
836 if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
837 (!keyseq.deleted())))
839 UpdatableInset * inset = view()->theLockingInset();
843 inset->getCursorPos(view(), inset_x, dummy_y);
845 if ((action == LFUN_UNKNOWN_ACTION)
846 && argument.empty()) {
847 argument = encoded_last_key;
849 // Undo/Redo is a bit tricky for insets.
850 if (action == LFUN_UNDO) {
852 goto exit_with_message;
853 } else if (action == LFUN_REDO) {
855 goto exit_with_message;
856 } else if (((result=inset->
857 // Hand-over to inset's own dispatch:
858 localDispatch(FuncRequest(view(), action, argument))) ==
860 (result == DISPATCHED_NOUPDATE))
861 goto exit_with_message;
862 // If UNDISPATCHED, just soldier on
863 else if (result == FINISHED) {
864 owner->clearMessage();
865 goto exit_with_message;
866 // We do not need special RTL handling here:
867 // FINISHED means that the cursor should be
868 // one position after the inset.
869 } else if (result == FINISHED_RIGHT) {
870 TEXT()->cursorRight(view());
871 moveCursorUpdate(true, false);
872 owner->clearMessage();
873 goto exit_with_message;
874 } else if (result == FINISHED_UP) {
875 if (TEXT()->cursor.irow() != TEXT()->rows().begin()) {
877 TEXT()->setCursorFromCoordinates(
878 TEXT()->cursor.ix() + inset_x,
879 TEXT()->cursor.iy() -
880 TEXT()->cursor.irow()->baseline() - 1);
881 TEXT()->cursor.x_fix(TEXT()->cursor.x());
883 TEXT()->cursorUp(view());
885 moveCursorUpdate(true, false);
887 view()->update(TEXT(), BufferView::SELECT);
889 owner->clearMessage();
890 goto exit_with_message;
891 } else if (result == FINISHED_DOWN) {
892 if (boost::next(TEXT()->cursor.irow()) != TEXT()->rows().end()) {
894 TEXT()->setCursorFromCoordinates(
895 TEXT()->cursor.ix() + inset_x,
896 TEXT()->cursor.iy() -
897 TEXT()->cursor.irow()->baseline() +
898 TEXT()->cursor.irow()->height() + 1);
899 TEXT()->cursor.x_fix(TEXT()->cursor.x());
901 TEXT()->cursorDown(view());
904 TEXT()->cursorRight(view());
906 moveCursorUpdate(true, false);
907 owner->clearMessage();
908 goto exit_with_message;
910 #warning I am not sure this is still right, please have a look! (Jug 20020417)
911 else { // result == UNDISPATCHED
912 //setMessage(N_("Text mode"));
914 case LFUN_UNKNOWN_ACTION:
915 case LFUN_BREAKPARAGRAPH:
917 TEXT()->cursorRight(view());
918 view()->switchKeyMap();
919 owner->view_state_changed();
922 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
923 TEXT()->cursorRight(view());
924 moveCursorUpdate(true, false);
925 owner->view_state_changed();
927 goto exit_with_message;
929 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
930 TEXT()->cursorRight(view());
931 moveCursorUpdate(true, false);
932 owner->view_state_changed();
934 goto exit_with_message;
936 if (boost::next(TEXT()->cursor.row()) != TEXT()->rows().end())
937 TEXT()->cursorDown(view());
939 TEXT()->cursorRight(view());
940 moveCursorUpdate(true, false);
941 owner->view_state_changed();
942 goto exit_with_message;
954 if (!view()->available()) break;
955 // this function should be used always [asierra060396]
956 UpdatableInset * tli =
957 view()->theLockingInset();
959 UpdatableInset * lock = tli->getLockingInset();
962 view()->unlockInset(tli);
963 TEXT()->cursorRight(view());
964 moveCursorUpdate(true, false);
965 owner->view_state_changed();
967 tli->unlockInsetInInset(view(),
972 // Tell the paragraph dialog that we changed paragraph
973 dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
978 // --- Misc -------------------------------------------
979 case LFUN_WORDFINDFORWARD :
980 case LFUN_WORDFINDBACKWARD : {
981 static string last_search;
982 string searched_string;
984 if (!argument.empty()) {
985 last_search = argument;
986 searched_string = argument;
988 searched_string = last_search;
990 bool fw = (action == LFUN_WORDFINDFORWARD);
991 if (!searched_string.empty()) {
992 lyxfind::LyXFind(view(), searched_string, fw);
994 // view()->showCursor();
1000 if (view()->available() && !view()->theLockingInset()) {
1001 view()->update(TEXT(), BufferView::SELECT);
1003 owner->message(keyseq.printOptions());
1007 // --- Misc -------------------------------------------
1008 case LFUN_EXEC_COMMAND:
1009 owner->focus_command_buffer();
1012 case LFUN_CANCEL: // RVDK_PATCH_5
1014 meta_fake_bit = key_modifier::none;
1015 if (view()->available())
1016 // cancel any selection
1017 dispatch(LFUN_MARK_OFF);
1018 setMessage(N_("Cancel"));
1021 case LFUN_META_FAKE: // RVDK_PATCH_5
1023 meta_fake_bit = key_modifier::alt;
1024 setMessage(keyseq.print());
1028 case LFUN_READ_ONLY_TOGGLE:
1029 if (owner->buffer()->lyxvc.inUse()) {
1030 owner->buffer()->lyxvc.toggleReadOnly();
1032 owner->buffer()->setReadonly(
1033 !owner->buffer()->isReadonly());
1037 case LFUN_CENTER: // this is center and redraw.
1041 // --- Menus -----------------------------------------------
1043 menuNew(argument, false);
1046 case LFUN_MENUNEWTMPLT:
1047 menuNew(argument, true);
1050 case LFUN_CLOSEBUFFER:
1054 case LFUN_MENUWRITE:
1055 if (!owner->buffer()->isUnnamed()) {
1057 #if USE_BOOST_FORMAT
1058 s1 << boost::format(_("Saving document %1$s..."))
1059 % MakeDisplayPath(owner->buffer()->fileName());
1061 s1 << _("Saving document ")
1062 << MakeDisplayPath(owner->buffer()->fileName())
1065 owner->message(STRCONV(s1.str()));
1066 MenuWrite(view(), owner->buffer());
1068 owner->message(STRCONV(s1.str()));
1070 WriteAs(view(), owner->buffer());
1074 WriteAs(view(), owner->buffer(), argument);
1077 case LFUN_MENURELOAD: {
1078 string const file = MakeDisplayPath(view()->buffer()->fileName(), 20);
1079 #if USE_BOOST_FORMAT
1080 boost::format fmt(_("Any changes will be lost. Are you sure you want to revert to the saved version of the document %1$s?"));
1082 string text = fmt.str();
1084 string text = _("Any changes will be lost. Are you sure you want to revert to the saved version of the document");
1085 text += file + _("?");
1087 int const ret = Alert::prompt(_("Revert to saved document?"),
1088 text, 0, 1, _("&Revert"), _("&Cancel"));
1096 Exporter::Export(owner->buffer(), argument, true);
1100 Exporter::Preview(owner->buffer(), argument);
1103 case LFUN_BUILDPROG:
1104 Exporter::Export(owner->buffer(), "program", true);
1107 case LFUN_RUNCHKTEX:
1108 owner->buffer()->runChktex();
1111 case LFUN_MENUPRINT:
1112 owner->getDialogs().showPrint();
1116 if (argument == "custom")
1117 owner->getDialogs().showSendto();
1119 Exporter::Export(owner->buffer(), argument, false);
1132 InsetCommandParams p("tableofcontents");
1133 string const data = InsetCommandMailer::params2string("toc", p);
1134 owner->getDialogs().show("toc", data, 0);
1150 case LFUN_MENUSEARCH:
1151 owner->getDialogs().showSearch();
1154 case LFUN_REMOVEERRORS:
1155 if (view()->removeAutoInsets()) {
1156 #warning repaint() or update() or nothing ?
1158 view()->fitCursor();
1162 case LFUN_DEPTH_MIN:
1163 changeDepth(view(), TEXT(false), DEC_DEPTH, false);
1164 owner->view_state_changed();
1167 case LFUN_DEPTH_PLUS:
1168 changeDepth(view(), TEXT(false), INC_DEPTH, false);
1169 owner->view_state_changed();
1172 case LFUN_FREEFONT_APPLY:
1173 apply_freefont(view());
1176 case LFUN_FREEFONT_UPDATE:
1177 update_and_apply_freefont(view(), argument);
1180 case LFUN_RECONFIGURE:
1181 Reconfigure(view());
1185 case LFUN_FLOATSOPERATE:
1186 if (argument == "openfoot")
1187 view()->allFloats(1,0);
1188 else if (argument == "closefoot")
1189 view()->allFloats(0,0);
1190 else if (argument == "openfig")
1191 view()->allFloats(1,1);
1192 else if (argument == "closefig")
1193 view()->allFloats(0,1);
1196 #ifdef WITH_WARNINGS
1197 //#warning Find another implementation here (or another lyxfunc)!
1200 case LFUN_HELP_ABOUTLYX:
1201 owner->getDialogs().show("about");
1204 case LFUN_HELP_TEXINFO:
1205 owner->getDialogs().showTexinfo();
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;
1222 #if USE_BOOST_FORMAT
1223 str << boost::format(_("Opening help file %1$s..."))
1224 % MakeDisplayPath(fname);
1226 str << _("Opening help file ")
1227 << MakeDisplayPath(fname) << _("...");
1229 owner->message(STRCONV(str.str()));
1230 view()->buffer(bufferlist.loadLyXFile(fname, false));
1234 // --- version control -------------------------------
1235 case LFUN_VC_REGISTER:
1237 if (!owner->buffer()->lyxvc.inUse())
1238 owner->buffer()->lyxvc.registrer();
1242 case LFUN_VC_CHECKIN:
1244 if (owner->buffer()->lyxvc.inUse()
1245 && !owner->buffer()->isReadonly())
1246 owner->buffer()->lyxvc.checkIn();
1250 case LFUN_VC_CHECKOUT:
1252 if (owner->buffer()->lyxvc.inUse()
1253 && owner->buffer()->isReadonly())
1254 owner->buffer()->lyxvc.checkOut();
1258 case LFUN_VC_REVERT:
1260 owner->buffer()->lyxvc.revert();
1266 owner->buffer()->lyxvc.undoLast();
1270 case LFUN_VC_HISTORY:
1272 owner->getDialogs().show("vclog");
1276 // --- buffers ----------------------------------------
1278 case LFUN_SWITCHBUFFER:
1279 view()->buffer(bufferlist.getBuffer(argument));
1284 // servercmd: argument must be <file>:<template>
1285 Buffer * tmpbuf = NewFile(argument);
1287 view()->buffer(tmpbuf);
1291 case LFUN_FILE_OPEN:
1295 case LFUN_LATEX_LOG:
1296 owner->getDialogs().show("log");
1299 case LFUN_LAYOUT_DOCUMENT:
1300 owner->getDialogs().showDocument();
1303 case LFUN_LAYOUT_CHARACTER: {
1304 string data = freefont2string();
1306 owner->getDialogs().show("character", data);
1310 case LFUN_LAYOUT_TABULAR:
1311 if (view()->theLockingInset()) {
1312 if (view()->theLockingInset()->lyxCode()==Inset::TABULAR_CODE) {
1313 InsetTabular * inset = static_cast<InsetTabular *>
1314 (view()->theLockingInset());
1315 inset->openLayoutDialog(view());
1316 } else if (view()->theLockingInset()->
1317 getFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
1318 InsetTabular * inset = static_cast<InsetTabular *>(
1319 view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
1320 inset->openLayoutDialog(view());
1325 case LFUN_LAYOUT_PREAMBLE:
1326 owner->getDialogs().showPreamble();
1329 case LFUN_DROP_LAYOUTS_CHOICE:
1330 owner->getToolbar().openLayoutList();
1333 case LFUN_MENU_OPEN_BY_NAME:
1334 owner->getMenubar().openByName(argument);
1335 break; // RVDK_PATCH_5
1337 case LFUN_SPELLCHECK:
1338 owner->getDialogs().showSpellchecker();
1341 // --- lyxserver commands ----------------------------
1345 setMessage(owner->buffer()->fileName());
1346 lyxerr[Debug::INFO] << "FNAME["
1347 << owner->buffer()->fileName()
1353 dispatch_buffer = keyseq.print();
1354 lyxserver->notifyClient(dispatch_buffer);
1358 case LFUN_GOTOFILEROW:
1362 istringstream istr(argument.c_str());
1363 istr >> file_name >> row;
1364 // Must replace extension of the file to be .lyx and get full path
1365 string const s(ChangeExtension(file_name, ".lyx"));
1367 // Either change buffer or load the file
1368 if (bufferlist.exists(s)) {
1369 view()->buffer(bufferlist.getBuffer(s));
1371 view()->buffer(bufferlist.loadLyXFile(s));
1374 view()->setCursorFromRow(row);
1377 // see BufferView_pimpl::center()
1378 view()->updateScrollbar();
1382 case LFUN_GOTO_PARAGRAPH:
1384 istringstream istr(argument.c_str());
1388 Paragraph * par = &*owner->buffer()->getParFromID(id);
1390 lyxerr[Debug::INFO] << "No matching paragraph found! ["
1391 << id << ']' << endl;
1394 lyxerr[Debug::INFO] << "Paragraph " << par->id()
1395 << " found." << endl;
1398 if (view()->theLockingInset())
1399 view()->unlockInset(view()->theLockingInset());
1400 if (par->inInset()) {
1401 par->inInset()->edit(view());
1404 view()->getLyXText()->setCursor(par, 0);
1405 view()->switchKeyMap();
1406 owner->view_state_changed();
1409 // see BufferView_pimpl::center()
1410 view()->updateScrollbar();
1414 // --- insert characters ----------------------------------------
1416 // --- Mathed stuff. If we are here, there is no locked inset yet.
1417 case LFUN_MATH_EXTERN:
1418 case LFUN_MATH_NUMBER:
1419 case LFUN_MATH_NONUMBER:
1420 case LFUN_MATH_LIMITS:
1422 setErrorMessage(N_("This is only allowed in math mode!"));
1426 // passthrough hat and underscore outside mathed:
1427 case LFUN_SUBSCRIPT:
1428 dispatch(FuncRequest(view(), LFUN_SELFINSERT, "_"));
1430 case LFUN_SUPERSCRIPT:
1431 dispatch(FuncRequest(view(), LFUN_SELFINSERT, "^"));
1434 case LFUN_MATH_PANEL:
1435 owner->getDialogs().showMathPanel();
1438 case LFUN_DIALOG_SHOW_NEW_INSET: {
1439 string const & name = argument;
1441 if (name == "bibitem" ||
1443 name == "include" ||
1448 InsetCommandParams p(name);
1449 data = InsetCommandMailer::params2string(name, p);
1450 } else if (name == "citation") {
1451 InsetCommandParams p("cite");
1452 data = InsetCommandMailer::params2string(name, p);
1454 owner->getDialogs().show(name, data, 0);
1458 case LFUN_DIALOG_SHOW_NEXT_INSET: {
1462 case LFUN_DIALOG_UPDATE: {
1463 string const & name = argument;
1464 // Can only update a dialog connected to an existing inset
1465 InsetBase * inset = owner->getDialogs().getOpenInset(name);
1467 FuncRequest fr(view(), LFUN_INSET_DIALOG_UPDATE,
1469 inset->localDispatch(fr);
1470 } else if (name == "paragraph") {
1471 dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
1476 case LFUN_DIALOG_HIDE:
1477 Dialogs::hide(argument, 0);
1480 case LFUN_DIALOG_DISCONNECT_INSET:
1481 owner->getDialogs().disconnect(argument);
1484 case LFUN_CHILDOPEN:
1486 string const filename =
1487 MakeAbsPath(argument,
1488 owner->buffer()->filePath());
1489 setMessage(N_("Opening child document ") +
1490 MakeDisplayPath(filename) + "...");
1491 view()->savePosition(0);
1492 if (bufferlist.exists(filename))
1493 view()->buffer(bufferlist.getBuffer(filename));
1495 view()->buffer(bufferlist.loadLyXFile(filename));
1499 case LFUN_TOGGLECURSORFOLLOW:
1500 lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
1504 owner->getIntl().KeyMapOn(false);
1507 case LFUN_KMAP_PRIM:
1508 owner->getIntl().KeyMapPrim();
1512 owner->getIntl().KeyMapSec();
1515 case LFUN_KMAP_TOGGLE:
1516 owner->getIntl().ToggleKeyMap();
1521 // argument contains ';'-terminated commands
1522 while (!argument.empty()) {
1524 argument = split(argument, first, ';');
1530 case LFUN_DIALOG_PREFERENCES:
1531 owner->getDialogs().showPreferences();
1534 case LFUN_SAVEPREFERENCES:
1536 Path p(user_lyxdir);
1537 lyxrc.write("preferences");
1541 case LFUN_SCREEN_FONT_UPDATE:
1543 // handle the screen font changes.
1544 lyxrc.set_font_norm_type();
1545 lyx_gui::update_fonts();
1546 // We also need to empty the textcache so that
1547 // the buffer will be formatted correctly after
1550 // Of course we should only do the resize and the textcache.clear
1551 // if values really changed...but not very important right now. (Lgb)
1552 // All visible buffers will need resize
1558 case LFUN_SET_COLOR:
1561 string const x11_name = split(argument, lyx_name, ' ');
1562 if (lyx_name.empty() || x11_name.empty()) {
1563 setErrorMessage(N_("Syntax: set-color <lyx_name>"
1568 bool const graphicsbg_changed =
1569 (lyx_name == lcolor.getLyXName(LColor::graphicsbg) &&
1570 x11_name != lcolor.getX11Name(LColor::graphicsbg));
1572 if (!lcolor.setColor(lyx_name, x11_name)) {
1573 #if USE_BOOST_FORMAT
1577 _("Set-color \"%1$s\" failed "
1578 "- color is undefined or "
1579 "may not be redefined"))
1582 setErrorMessage(_("Set-color ") + lyx_name
1583 + _(" failed - color is undefined"
1584 " or may not be redefined"));
1590 lyx_gui::update_color(lcolor.getFromLyXName(lyx_name));
1592 if (graphicsbg_changed) {
1593 #ifdef WITH_WARNINGS
1594 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1597 grfx::GCache & gc = grfx::GCache::get();
1598 gc.changeDisplay(true);
1607 owner->message(argument);
1610 case LFUN_FORKS_SHOW:
1611 owner->getDialogs().showForks();
1614 case LFUN_FORKS_KILL:
1616 if (!isStrInt(argument))
1619 pid_t const pid = strToInt(argument);
1620 ForkedcallsController & fcc = ForkedcallsController::get();
1625 case LFUN_TOOLTIPS_TOGGLE:
1626 owner->getDialogs().toggleTooltips();
1630 // Then if it was none of the above
1631 // Trying the BufferView::pimpl dispatch:
1632 if (!view()->dispatch(ev))
1633 lyxerr << "A truly unknown func ["
1634 << lyxaction.getActionName(ev.action) << "]!"
1641 view()->owner()->updateLayoutChoice();
1643 if (view()->available()) {
1644 view()->fitCursor();
1646 // If we executed a mutating lfun, mark the buffer as dirty
1647 if (!lyxaction.funcHasFlag(ev.action, LyXAction::NoBuffer)
1648 && !lyxaction.funcHasFlag(ev.action, LyXAction::ReadOnly))
1649 view()->buffer()->markDirty();
1652 sendDispatchMessage(getMessage(), ev, verbose);
1656 void LyXFunc::sendDispatchMessage(string const & msg, FuncRequest const & ev, bool verbose)
1658 owner->updateMenubar();
1659 owner->updateToolbar();
1661 if (ev.action == LFUN_SELFINSERT || !verbose) {
1662 lyxerr[Debug::ACTION] << "dispatch msg is " << msg << endl;
1664 owner->message(msg);
1668 string dispatch_msg = msg;
1669 if (!dispatch_msg.empty())
1670 dispatch_msg += ' ';
1672 string comname = lyxaction.getActionName(ev.action);
1674 int pseudoaction = ev.action;
1675 bool argsadded = false;
1677 if (!ev.argument.empty()) {
1678 // the pseudoaction is useful for the bindings
1679 pseudoaction = lyxaction.searchActionArg(ev.action, ev.argument);
1681 if (pseudoaction == LFUN_UNKNOWN_ACTION) {
1682 pseudoaction = ev.action;
1684 comname += ' ' + ev.argument;
1689 string const shortcuts = toplevel_keymap->findbinding(pseudoaction);
1691 if (!shortcuts.empty()) {
1692 comname += ": " + shortcuts;
1693 } else if (!argsadded && !ev.argument.empty()) {
1694 comname += ' ' + ev.argument;
1697 if (!comname.empty()) {
1698 comname = rtrim(comname);
1699 dispatch_msg += '(' + comname + ')';
1702 lyxerr[Debug::ACTION] << "verbose dispatch msg " << dispatch_msg << endl;
1703 if (!dispatch_msg.empty())
1704 owner->message(dispatch_msg);
1708 void LyXFunc::setupLocalKeymap()
1710 keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
1711 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap.get();
1715 void LyXFunc::menuNew(string const & name, bool fromTemplate)
1717 string initpath = lyxrc.document_path;
1718 string filename(name);
1720 if (view()->available()) {
1721 string const trypath = owner->buffer()->filePath();
1722 // If directory is writeable, use this as default.
1723 if (IsDirWriteable(trypath))
1727 static int newfile_number;
1729 if (filename.empty()) {
1730 filename = AddName(lyxrc.document_path,
1731 "newfile" + tostr(++newfile_number) + ".lyx");
1732 FileInfo fi(filename);
1733 while (bufferlist.exists(filename) || fi.readable()) {
1735 filename = AddName(lyxrc.document_path,
1736 "newfile" + tostr(newfile_number) +
1738 fi.newFile(filename);
1742 // The template stuff
1745 FileDialog fileDlg(_("Select template file"),
1746 LFUN_SELECT_FILE_SYNC,
1747 make_pair(string(_("Documents|#o#O")),
1748 string(lyxrc.document_path)),
1749 make_pair(string(_("Templates|#T#t")),
1750 string(lyxrc.template_path)));
1752 FileDialog::Result result =
1753 fileDlg.open(lyxrc.template_path,
1754 _("*.lyx| LyX Documents (*.lyx)"));
1756 if (result.first == FileDialog::Later)
1759 string const fname = result.second;
1766 view()->buffer(bufferlist.newFile(filename, templname, !name.empty()));
1770 void LyXFunc::open(string const & fname)
1772 string initpath = lyxrc.document_path;
1774 if (view()->available()) {
1775 string const trypath = owner->buffer()->filePath();
1776 // If directory is writeable, use this as default.
1777 if (IsDirWriteable(trypath))
1783 if (fname.empty()) {
1784 FileDialog fileDlg(_("Select document to open"),
1786 make_pair(string(_("Documents|#o#O")),
1787 string(lyxrc.document_path)),
1788 make_pair(string(_("Examples|#E#e")),
1789 string(AddPath(system_lyxdir, "examples"))));
1791 FileDialog::Result result =
1792 fileDlg.open(initpath,
1793 _("*.lyx| LyX Documents (*.lyx)"));
1795 if (result.first == FileDialog::Later)
1798 filename = result.second;
1800 // check selected filename
1801 if (filename.empty()) {
1802 owner->message(_("Canceled."));
1808 // get absolute path of file and add ".lyx" to the filename if
1810 string const fullpath = FileSearch(string(), filename, "lyx");
1811 if (!fullpath.empty()) {
1812 filename = fullpath;
1815 string const disp_fn(MakeDisplayPath(filename));
1817 // if the file doesn't exist, let the user create one
1818 FileInfo const f(filename, true);
1820 // the user specifically chose this name. Believe them.
1821 Buffer * buffer = bufferlist.newFile(filename, "", true);
1822 view()->buffer(buffer);
1827 #if USE_BOOST_FORMAT
1828 str << boost::format(_("Opening document %1$s...")) % disp_fn;
1830 str << _("Opening document ") << disp_fn << _("...");
1833 owner->message(STRCONV(str.str()));
1835 Buffer * openbuf = bufferlist.loadLyXFile(filename);
1838 view()->buffer(openbuf);
1839 #if USE_BOOST_FORMAT
1840 str2 << boost::format(_("Document %1$s opened.")) % disp_fn;
1842 str2 << _("Document ") << disp_fn << _(" opened.");
1845 #if USE_BOOST_FORMAT
1846 str2 << boost::format(_("Could not open document %1$s"))
1849 str2 << _("Could not open document ") << disp_fn;
1852 owner->message(STRCONV(str2.str()));
1856 void LyXFunc::doImport(string const & argument)
1859 string filename = split(argument, format, ' ');
1861 lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format
1862 << " file: " << filename << endl;
1864 // need user interaction
1865 if (filename.empty()) {
1866 string initpath = lyxrc.document_path;
1868 if (view()->available()) {
1869 string const trypath = owner->buffer()->filePath();
1870 // If directory is writeable, use this as default.
1871 if (IsDirWriteable(trypath))
1875 #if USE_BOOST_FORMAT
1876 boost::format fmt(_("Select %1$s file to import"));
1877 fmt % formats.prettyName(format);
1878 string const text = fmt.str();
1880 string const text = _("Select ") + formats.prettyName(format)
1881 + _(" file to import");;
1884 FileDialog fileDlg(text,
1886 make_pair(string(_("Documents|#o#O")),
1887 string(lyxrc.document_path)),
1888 make_pair(string(_("Examples|#E#e")),
1889 string(AddPath(system_lyxdir, "examples"))));
1891 string const extension = "*." + formats.extension(format)
1892 + "| " + formats.prettyName(format)
1893 + " (*." + formats.extension(format) + ')';
1895 FileDialog::Result result = fileDlg.open(initpath,
1898 if (result.first == FileDialog::Later)
1901 filename = result.second;
1903 // check selected filename
1904 if (filename.empty())
1905 owner->message(_("Canceled."));
1908 if (filename.empty())
1911 // get absolute path of file
1912 filename = MakeAbsPath(filename);
1914 string const lyxfile = ChangeExtension(filename, ".lyx");
1916 // Check if the document already is open
1917 if (lyx_gui::use_gui && bufferlist.exists(lyxfile)) {
1918 if (!bufferlist.close(bufferlist.getBuffer(lyxfile), true)) {
1919 owner->message(_("Canceled."));
1924 // if the file exists already, and we didn't do
1925 // -i lyx thefile.lyx, warn
1926 if (FileInfo(lyxfile, true).exist() && filename != lyxfile) {
1927 string const file = MakeDisplayPath(lyxfile, 30);
1929 #if USE_BOOST_FORMAT
1930 boost::format fmt(_("The document %1$s already exists.\n\nDo you want to over-write that document?"));
1932 string text = fmt.str();
1934 string text = _("The document ");
1935 text += file + _(" already exists.\n\nDo you want to over-write that document?");
1937 int const ret = Alert::prompt(_("Over-write document?"),
1938 text, 0, 1, _("&Over-write"), _("&Cancel"));
1941 owner->message(_("Canceled."));
1946 Importer::Import(owner, filename, format);
1950 void LyXFunc::closeBuffer()
1952 if (bufferlist.close(owner->buffer(), true) && !quitting) {
1953 if (bufferlist.empty()) {
1954 // need this otherwise SEGV may occur while trying to
1955 // set variables that don't exist
1956 // since there's no current buffer
1957 owner->getDialogs().hideBufferDependent();
1959 view()->buffer(bufferlist.first());
1965 // Each "owner" should have it's own message method. lyxview and
1966 // the minibuffer would use the minibuffer, but lyxserver would
1967 // send an ERROR signal to its client. Alejandro 970603
1968 // This func is bit problematic when it comes to NLS, to make the
1969 // lyx servers client be language indepenent we must not translate
1970 // strings sent to this func.
1971 void LyXFunc::setErrorMessage(string const & m) const
1973 dispatch_buffer = m;
1978 void LyXFunc::setMessage(string const & m) const
1980 dispatch_buffer = m;
1984 void LyXFunc::setStatusMessage(string const & m) const
1990 string const LyXFunc::view_status_message()
1992 // When meta-fake key is pressed, show the key sequence so far + "M-".
1994 return keyseq.print() + "M-";
1997 // Else, when a non-complete key sequence is pressed,
1998 // show the available options.
1999 if (keyseq.length() > 0 && !keyseq.deleted()) {
2000 return keyseq.printOptions();
2003 if (!view()->available())
2004 return _("Welcome to LyX!");
2006 return currentState(view());
2010 BufferView * LyXFunc::view() const
2013 return owner->view().get();