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 "BranchList.h"
26 #include "buffer_funcs.h"
27 #include "bufferlist.h"
28 #include "bufferparams.h"
29 #include "BufferView.h"
35 #include "funcrequest.h"
39 #include "iterators.h"
43 #include "LyXAction.h"
47 #include "lyxserver.h"
49 #include "paragraph.h"
50 #include "ParagraphParameters.h"
53 #include "insets/insetcommand.h"
54 #include "insets/insetexternal.h"
55 #include "insets/insettabular.h"
57 #include "mathed/math_cursor.h"
59 #include "frontends/Alert.h"
60 #include "frontends/Dialogs.h"
61 #include "frontends/FileDialog.h"
62 #include "frontends/lyx_gui.h"
63 #include "frontends/LyXKeySym.h"
64 #include "frontends/LyXView.h"
65 #include "frontends/Menubar.h"
66 #include "frontends/Toolbar.h"
68 #include "support/FileInfo.h"
69 #include "support/filetools.h"
70 #include "support/forkedcontr.h"
71 #include "support/path.h"
72 #include "support/path_defines.h"
73 #include "support/tostr.h"
74 #include "support/std_sstream.h"
75 #include "support/os.h"
77 using bv_funcs::apply_freefont;
78 using bv_funcs::changeDepth;
79 using bv_funcs::currentState;
80 using bv_funcs::DEC_DEPTH;
81 using bv_funcs::freefont2string;
82 using bv_funcs::INC_DEPTH;
83 using bv_funcs::update_and_apply_freefont;
85 using lyx::support::AddName;
86 using lyx::support::AddPath;
87 using lyx::support::bformat;
88 using lyx::support::ChangeExtension;
89 using lyx::support::FileInfo;
90 using lyx::support::FileSearch;
91 using lyx::support::ForkedcallsController;
92 using lyx::support::i18nLibFileSearch;
93 using lyx::support::IsDirWriteable;
94 using lyx::support::IsFileReadable;
95 using lyx::support::isStrInt;
96 using lyx::support::MakeAbsPath;
97 using lyx::support::MakeDisplayPath;
98 using lyx::support::Path;
99 using lyx::support::rtrim;
100 using lyx::support::split;
101 using lyx::support::strToInt;
102 using lyx::support::strToUnsignedInt;
103 using lyx::support::system_lyxdir;
104 using lyx::support::token;
105 using lyx::support::trim;
106 using lyx::support::user_lyxdir;
107 using lyx::support::prefixIs;
108 using lyx::support::os::getTmpDir;
111 using std::make_pair;
113 using std::istringstream;
116 extern BufferList bufferlist;
117 extern LyXServer * lyxserver;
118 extern bool selection_possible;
120 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
123 extern tex_accent_struct get_accent(kb_action action);
125 extern void ShowLatexLog();
128 LyXFunc::LyXFunc(LyXView * o)
131 keyseq(toplevel_keymap.get(), toplevel_keymap.get()),
132 cancel_meta_seq(toplevel_keymap.get(), toplevel_keymap.get()),
133 meta_fake_bit(key_modifier::none)
138 void LyXFunc::moveCursorUpdate()
140 LyXText * lt = view()->text;
141 if (lt->selection.mark())
144 view()->switchKeyMap();
148 void LyXFunc::handleKeyFunc(kb_action action)
150 char c = encoded_last_key;
152 if (keyseq.length()) {
156 owner->getIntl().getTransManager()
157 .deadkey(c, get_accent(action).accent, view()->getLyXText());
158 // Need to clear, in case the minibuffer calls these
161 // copied verbatim from do_accent_char
163 view()->getLyXText()->selection.cursor = view()->getLyXText()->cursor;
167 void LyXFunc::processKeySym(LyXKeySymPtr keysym,
168 key_modifier::state state)
172 if (lyxerr.debugging(Debug::KEY)) {
173 lyxerr << "KeySym is "
174 << keysym->getSymbolName()
178 // Do nothing if we have nothing (JMarc)
179 if (!keysym->isOK()) {
180 lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
185 if (keysym->isModifier()) {
186 lyxerr[Debug::KEY] << "isModifier true" << endl;
190 Encoding const * encoding = view()->getEncoding();
192 encoded_last_key = keysym->getISOEncoded(encoding ? encoding->Name() : "");
194 // Do a one-deep top-level lookup for
195 // cancel and meta-fake keys. RVDK_PATCH_5
196 cancel_meta_seq.reset();
198 FuncRequest func = cancel_meta_seq.addkey(keysym, state);
199 lyxerr[Debug::KEY] << "action first set to [" << func.action << ']' << endl;
201 // When not cancel or meta-fake, do the normal lookup.
202 // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
203 // Mostly, meta_fake_bit = key_modifier::none. RVDK_PATCH_5.
204 if ((func.action != LFUN_CANCEL) && (func.action != LFUN_META_FAKE)) {
205 // remove Caps Lock and Mod2 as a modifiers
206 func = keyseq.addkey(keysym, (state | meta_fake_bit));
207 lyxerr[Debug::KEY] << "action now set to ["
208 << func.action << ']' << endl;
211 // Dont remove this unless you know what you are doing.
212 meta_fake_bit = key_modifier::none;
214 // can this happen now ?
215 if (func.action == LFUN_NOACTION) {
216 func = FuncRequest(LFUN_PREFIX);
219 if (lyxerr.debugging(Debug::KEY)) {
220 lyxerr << "Key [action="
221 << func.action << "]["
222 << keyseq.print() << ']'
226 // already here we know if it any point in going further
227 // why not return already here if action == -1 and
228 // num_bytes == 0? (Lgb)
230 if (keyseq.length() > 1) {
231 owner->message(keyseq.print());
235 // Maybe user can only reach the key via holding down shift.
236 // Let's see. But only if shift is the only modifier
237 if (func.action == LFUN_UNKNOWN_ACTION &&
238 state == key_modifier::shift) {
239 lyxerr[Debug::KEY] << "Trying without shift" << endl;
240 func = keyseq.addkey(keysym, key_modifier::none);
241 lyxerr[Debug::KEY] << "Action now " << func.action << endl;
244 if (func.action == LFUN_UNKNOWN_ACTION) {
245 // Hmm, we didn't match any of the keysequences. See
246 // if it's normal insertable text not already covered
248 if (keysym->isText() && keyseq.length() == 1) {
249 lyxerr[Debug::KEY] << "isText() is true, inserting." << endl;
250 func = FuncRequest(LFUN_SELFINSERT);
252 lyxerr[Debug::KEY] << "Unknown, !isText() - giving up" << endl;
253 owner->message(_("Unknown function."));
258 if (func.action == LFUN_SELFINSERT) {
259 if (encoded_last_key != 0) {
261 arg += encoded_last_key;
263 dispatch(FuncRequest(view(), LFUN_SELFINSERT, arg));
265 lyxerr[Debug::KEY] << "SelfInsert arg[`"
266 << argument << "']" << endl;
274 FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
277 Buffer * buf = owner->buffer();
279 if (ev.action == LFUN_NOACTION) {
280 setStatusMessage(N_("Nothing to do"));
281 return flag.disabled(true);
285 case LFUN_UNKNOWN_ACTION:
286 #ifndef HAVE_LIBAIKSAURUS
287 case LFUN_THESAURUS_ENTRY:
293 flag |= lyx_gui::getStatus(ev);
296 if (flag.unknown()) {
297 setStatusMessage(N_("Unknown action"));
301 // the default error message if we disable the command
302 setStatusMessage(N_("Command disabled"));
304 // Check whether we need a buffer
305 if (!lyxaction.funcHasFlag(ev.action, LyXAction::NoBuffer)) {
306 // Yes we need a buffer, do we have one?
309 // Can we use a readonly buffer?
310 if (buf->isReadonly() &&
311 !lyxaction.funcHasFlag(ev.action,
312 LyXAction::ReadOnly)) {
314 setStatusMessage(N_("Document is read-only"));
319 setStatusMessage(N_("Command not allowed with"
320 "out any document open"));
321 return flag.disabled(true);
325 UpdatableInset * tli = view()->theLockingInset();
327 // I would really like to avoid having this switch and rather try to
328 // encode this in the function itself.
329 bool disable = false;
332 disable = ev.argument != "custom"
333 && !Exporter::IsExportable(*buf, ev.argument);
336 disable = buf->undostack().empty();
339 disable = buf->redostack().empty();
344 UpdatableInset * in = tli;
345 if (in->lyxCode() != InsetOld::TABULAR_CODE) {
346 in = tli->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE);
348 if (in && static_cast<InsetTabular*>(in)->hasSelection()) {
353 disable = !mathcursor && !view()->getLyXText()->selection.set();
356 disable = !buf->isLatex() || lyxrc.chktex_command == "none";
359 disable = !Exporter::IsExportable(*buf, "program");
362 case LFUN_LAYOUT_TABULAR:
364 || (tli->lyxCode() != InsetOld::TABULAR_CODE
365 && !tli->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE));
369 disable = !changeDepth(view(), view()->getLyXText(), DEC_DEPTH, true);
372 case LFUN_DEPTH_PLUS:
373 disable = !changeDepth(view(), view()->getLyXText(), INC_DEPTH, true);
377 case LFUN_LAYOUT_PARAGRAPH: {
378 InsetOld * inset = view()->getLyXText()->cursorPar()->inInset();
379 disable = inset && inset->forceDefaultParagraphs(inset);
383 case LFUN_INSET_OPTARG:
384 disable = (view()->getLyXText()->cursorPar()->layout()->optionalargs == 0);
387 case LFUN_TABULAR_FEATURE:
390 // FIXME: check temporarily disabled
392 char align = mathcursor->valign();
397 if (ev.argument.empty()) {
401 if (!contains("tcb", ev.argument[0])) {
405 flag.setOnOff(ev.argument[0] == align);
409 char align = mathcursor->halign();
414 if (ev.argument.empty()) {
418 if (!contains("lcr", ev.argument[0])) {
422 flag.setOnOff(ev.argument[0] == align);
425 disable = !mathcursor->halign();
431 //ret.disabled(true);
432 if (tli->lyxCode() == InsetOld::TABULAR_CODE) {
433 ret = static_cast<InsetTabular *>(tli)
434 ->getStatus(ev.argument);
437 } else if (tli->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE)) {
438 ret = static_cast<InsetTabular *>
439 (tli->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE))
440 ->getStatus(ev.argument);
447 static InsetTabular inset(*owner->buffer(), 1, 1);
451 ret = inset.getStatus(ev.argument);
452 if (ret.onoff(true) || ret.onoff(false))
453 flag.setOnOff(false);
457 case LFUN_VC_REGISTER:
458 disable = buf->lyxvc().inUse();
460 case LFUN_VC_CHECKIN:
461 disable = !buf->lyxvc().inUse() || buf->isReadonly();
463 case LFUN_VC_CHECKOUT:
464 disable = !buf->lyxvc().inUse() || !buf->isReadonly();
468 disable = !buf->lyxvc().inUse();
470 case LFUN_MENURELOAD:
471 disable = buf->isUnnamed() || buf->isClean();
473 case LFUN_BOOKMARK_GOTO:
475 isSavedPosition(strToUnsignedInt(ev.argument));
477 case LFUN_MERGE_CHANGES:
478 case LFUN_ACCEPT_CHANGE:
479 case LFUN_REJECT_CHANGE:
480 case LFUN_ACCEPT_ALL_CHANGES:
481 case LFUN_REJECT_ALL_CHANGES:
482 disable = !buf->params().tracking_changes;
484 case LFUN_INSET_TOGGLE: {
485 LyXText * lt = view()->getLyXText();
486 disable = !(isEditableInset(lt->getInset())
488 && lt->inset_owner->owner()
489 && lt->inset_owner->owner()->isOpen()));
493 case LFUN_INSET_SETTINGS: {
495 UpdatableInset * inset = view()->theLockingInset();
500 // get the innermost inset
501 inset = inset->getLockingInset();
503 // jump back to owner if an InsetText, so
504 // we get back to the InsetTabular or whatever
505 if (inset->lyxCode() == InsetOld::TEXT_CODE)
506 inset = inset->owner();
508 InsetOld::Code code = inset->lyxCode();
510 case InsetOld::TABULAR_CODE:
511 disable = ev.argument != "tabular";
513 case InsetOld::ERT_CODE:
514 disable = ev.argument != "ert";
516 case InsetOld::FLOAT_CODE:
517 disable = ev.argument != "float";
519 case InsetOld::MINIPAGE_CODE:
520 disable = ev.argument != "minipage";
522 case InsetOld::WRAP_CODE:
523 disable = ev.argument != "wrap";
525 case InsetOld::NOTE_CODE:
526 disable = ev.argument != "note";
528 case InsetOld::BRANCH_CODE:
529 disable = ev.argument != "branch";
531 case InsetOld::BOX_CODE:
532 disable = ev.argument != "box";
540 case LFUN_MATH_MUTATE:
542 //flag.setOnOff(mathcursor->formula()->hullType() == ev.argument);
543 flag.setOnOff(false);
548 // we just need to be in math mode to enable that
550 case LFUN_MATH_SPACE:
551 case LFUN_MATH_LIMITS:
552 case LFUN_MATH_NONUMBER:
553 case LFUN_MATH_NUMBER:
554 case LFUN_MATH_EXTERN:
555 disable = !mathcursor;
558 case LFUN_DIALOG_SHOW: {
559 string const name = ev.getArg(0);
561 disable = !(name == "aboutlyx" ||
564 name == "preferences" ||
569 if (name == "print") {
570 disable = !Exporter::IsExportable(*buf, "dvi") ||
571 lyxrc.print_command == "none";
572 } else if (name == "character") {
573 UpdatableInset * tli = view()->theLockingInset();
574 disable = tli && tli->lyxCode() == InsetOld::ERT_CODE;
575 } else if (name == "vclog") {
576 disable = !buf->lyxvc().inUse();
577 } else if (name == "latexlog") {
578 disable = !IsFileReadable(buf->getLogName().second);
587 // the functions which insert insets
588 InsetOld::Code code = InsetOld::NO_CODE;
590 case LFUN_DIALOG_SHOW_NEW_INSET:
591 if (ev.argument == "bibitem")
592 code = InsetOld::BIBITEM_CODE;
593 else if (ev.argument == "bibtex")
594 code = InsetOld::BIBTEX_CODE;
595 else if (ev.argument == "citation")
596 code = InsetOld::CITE_CODE;
597 else if (ev.argument == "ert")
598 code = InsetOld::ERT_CODE;
599 else if (ev.argument == "external")
600 code = InsetOld::EXTERNAL_CODE;
601 else if (ev.argument == "float")
602 code = InsetOld::FLOAT_CODE;
603 else if (ev.argument == "graphics")
604 code = InsetOld::GRAPHICS_CODE;
605 else if (ev.argument == "include")
606 code = InsetOld::INCLUDE_CODE;
607 else if (ev.argument == "index")
608 code = InsetOld::INDEX_CODE;
609 else if (ev.argument == "label")
610 code = InsetOld::LABEL_CODE;
611 else if (ev.argument == "minipage")
612 code = InsetOld::MINIPAGE_CODE;
613 else if (ev.argument == "ref")
614 code = InsetOld::REF_CODE;
615 else if (ev.argument == "toc")
616 code = InsetOld::TOC_CODE;
617 else if (ev.argument == "url")
618 code = InsetOld::URL_CODE;
619 else if (ev.argument == "wrap")
620 code = InsetOld::WRAP_CODE;
624 code = InsetOld::ERT_CODE;
626 case LFUN_INSET_FOOTNOTE:
627 code = InsetOld::FOOT_CODE;
629 case LFUN_TABULAR_INSERT:
630 code = InsetOld::TABULAR_CODE;
632 case LFUN_INSET_MARGINAL:
633 code = InsetOld::MARGIN_CODE;
635 case LFUN_INSET_MINIPAGE:
636 code = InsetOld::MINIPAGE_CODE;
638 case LFUN_INSET_FLOAT:
639 case LFUN_INSET_WIDE_FLOAT:
640 code = InsetOld::FLOAT_CODE;
642 case LFUN_INSET_WRAP:
643 code = InsetOld::WRAP_CODE;
645 case LFUN_FLOAT_LIST:
646 code = InsetOld::FLOAT_LIST_CODE;
649 case LFUN_INSET_LIST:
650 code = InsetOld::LIST_CODE;
652 case LFUN_INSET_THEOREM:
653 code = InsetOld::THEOREM_CODE;
656 case LFUN_INSET_CAPTION:
657 code = InsetOld::CAPTION_CODE;
659 case LFUN_INSERT_NOTE:
660 code = InsetOld::NOTE_CODE;
662 case LFUN_INSERT_BOX:
663 code = InsetOld::BOX_CODE;
665 case LFUN_INSERT_BRANCH:
666 code = InsetOld::BRANCH_CODE;
667 if (buf->params().branchlist().empty())
670 case LFUN_INSERT_LABEL:
671 code = InsetOld::LABEL_CODE;
673 case LFUN_INSET_OPTARG:
674 code = InsetOld::OPTARG_CODE;
676 case LFUN_ENVIRONMENT_INSERT:
677 code = InsetOld::MINIPAGE_CODE;
679 case LFUN_INDEX_INSERT:
680 code = InsetOld::INDEX_CODE;
682 case LFUN_INDEX_PRINT:
683 code = InsetOld::INDEX_PRINT_CODE;
685 case LFUN_TOC_INSERT:
686 code = InsetOld::TOC_CODE;
690 code = InsetOld::URL_CODE;
693 // always allow this, since we will inset a raw quote
694 // if an inset is not allowed.
696 case LFUN_HYPHENATION:
697 case LFUN_LIGATURE_BREAK:
699 case LFUN_MENU_SEPARATOR:
701 case LFUN_END_OF_SENTENCE:
702 code = InsetOld::SPECIALCHAR_CODE;
704 case LFUN_SPACE_INSERT:
705 // slight hack: we know this is allowed in math mode
707 code = InsetOld::SPACE_CODE;
709 case LFUN_INSET_DIALOG_SHOW: {
710 LyXText * lt = view()->getLyXText();
711 InsetOld * inset = lt->getInset();
714 code = inset->lyxCode();
715 if (!(code == InsetOld::INCLUDE_CODE
716 || code == InsetOld::BIBTEX_CODE
717 || code == InsetOld::FLOAT_LIST_CODE
718 || code == InsetOld::TOC_CODE))
726 if (code != InsetOld::NO_CODE && tli && !tli->insetAllowed(code))
732 // A few general toggles
734 case LFUN_TOOLTIPS_TOGGLE:
735 flag.setOnOff(owner->getDialogs().tooltipsEnabled());
738 case LFUN_READ_ONLY_TOGGLE:
739 flag.setOnOff(buf->isReadonly());
742 flag.setOnOff(view()->getLyXText()->cursorPar()->params().startOfAppendix());
744 case LFUN_SWITCHBUFFER:
745 // toggle on the current buffer, but do not toggle off
746 // the other ones (is that a good idea?)
747 if (ev.argument == buf->fileName())
750 case LFUN_TRACK_CHANGES:
751 flag.setOnOff(buf->params().tracking_changes);
757 // the font related toggles
759 LyXFont const & font = view()->getLyXText()->real_current_font;
762 flag.setOnOff(font.emph() == LyXFont::ON);
765 flag.setOnOff(font.noun() == LyXFont::ON);
768 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
771 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
774 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
777 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
783 string tc = mathcursor->getLastCode();
786 flag.setOnOff(tc == "mathbf");
789 flag.setOnOff(tc == "mathsf");
792 flag.setOnOff(tc == "mathcal");
795 flag.setOnOff(tc == "mathrm");
798 flag.setOnOff(tc == "mathtt");
801 flag.setOnOff(tc == "mathbb");
804 flag.setOnOff(tc == "mathnormal");
811 // this one is difficult to get right. As a half-baked
812 // solution, we consider only the first action of the sequence
813 if (ev.action == LFUN_SEQUENCE) {
814 // argument contains ';'-terminated commands
815 #warning LyXAction arguements not handled here.
816 flag = getStatus(FuncRequest(lyxaction.lookupFunc(token(ev.argument, ';', 0))));
825 bool ensureBufferClean(BufferView * bv)
827 Buffer & buf = *bv->buffer();
831 string const file = MakeDisplayPath(buf.fileName(), 30);
832 string text = bformat(_("The document %1$s has unsaved "
833 "changes.\n\nDo you want to save "
834 "the document?"), file);
835 int const ret = Alert::prompt(_("Save changed document?"),
836 text, 0, 1, _("&Save"),
840 bv->owner()->dispatch(FuncRequest(LFUN_MENUWRITE));
842 return buf.isClean();
848 void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
850 string argument = func.argument;
851 kb_action action = func.action;
853 lyxerr[Debug::ACTION] << "LyXFunc::dispatch: action[" << action
854 <<"] arg[" << argument << ']' << endl;
856 // we have not done anything wrong yet.
858 dispatch_buffer.erase();
860 #ifdef NEW_DISPATCHER
861 // We try do call the most specific dispatcher first:
862 // 1. the lockinginset's dispatch
863 // 2. the bufferview's dispatch
864 // 3. the lyxview's dispatch
867 selection_possible = false;
869 // We cannot use this function here
870 if (getStatus(func).disabled()) {
871 lyxerr[Debug::ACTION] << "LyXFunc::dispatch: "
872 << lyxaction.getActionName(action)
873 << " [" << action << "] is disabled at this location"
875 setErrorMessage(getStatusMessage());
876 goto exit_with_message;
879 if (view()->available())
880 view()->hideCursor();
885 buildCursor(cursor, *view());
886 if (cursor.dispatch(FuncRequest(func, view())) == DISPATCHED) {
887 lyxerr << "dispatched by Cursor::dispatch()\n";
888 goto exit_with_message;
894 if (view()->available() && view()->theLockingInset()) {
895 dispatch_result result;
896 if (action > 1 || (action == LFUN_UNKNOWN_ACTION &&
899 UpdatableInset * inset = view()->theLockingInset();
903 inset->getCursorPos(view(), inset_x, dummy_y);
905 if (action == LFUN_UNKNOWN_ACTION
906 && argument.empty()) {
907 argument = encoded_last_key;
910 // the insets can't try to handle this,
911 // a table cell in the dummy position will
912 // lock its insettext, the insettext will
913 // pass it the bufferview, and succeed,
914 // so it will stay not locked. Not good
915 // if we've just done LFUN_ESCAPE (which
916 // injects an LFUN_PARAGRAPH_UPDATE)
917 if (action == LFUN_PARAGRAPH_UPDATE) {
918 view()->dispatch(func);
919 goto exit_with_message;
922 // Undo/Redo is a bit tricky for insets.
923 if (action == LFUN_UNDO) {
925 goto exit_with_message;
928 if (action == LFUN_REDO) {
930 goto exit_with_message;
933 // Hand-over to inset's own dispatch:
934 result = inset->localDispatch(FuncRequest(view(), action, argument));
935 if (result == DISPATCHED || result == DISPATCHED_NOUPDATE) {
936 goto exit_with_message;
939 // If UNDISPATCHED, just soldier on
940 if (result == FINISHED) {
941 owner->clearMessage();
942 goto exit_with_message;
943 // We do not need special RTL handling here:
944 // FINISHED means that the cursor should be
945 // one position after the inset.
948 if (result == FINISHED_RIGHT) {
949 view()->text->cursorRight(view());
951 owner->clearMessage();
952 goto exit_with_message;
955 if (result == FINISHED_UP) {
956 RowList::iterator const irow = view()->text->cursorRow();
957 if (irow != view()->text->firstRow()) {
959 view()->text->setCursorFromCoordinates(
960 view()->text->cursor.x() + inset_x,
961 view()->text->cursor.y() -
962 irow->baseline() - 1);
963 view()->text->cursor.x_fix(view()->text->cursor.x());
965 view()->text->cursorUp(view());
971 owner->clearMessage();
972 goto exit_with_message;
975 if (result == FINISHED_DOWN) {
976 RowList::iterator const irow = view()->text->cursorRow();
977 if (irow != view()->text->lastRow()) {
979 view()->text->setCursorFromCoordinates(
980 view()->text->cursor.x() + inset_x,
981 view()->text->cursor.y() -
984 view()->text->cursor.x_fix(view()->text->cursor.x());
986 view()->text->cursorDown(view());
989 view()->text->cursorRight(view());
992 owner->clearMessage();
993 goto exit_with_message;
996 #warning I am not sure this is still right, please have a look! (Jug 20020417)
997 // result == UNDISPATCHED
998 //setMessage(N_("Text mode"));
1000 case LFUN_UNKNOWN_ACTION:
1001 case LFUN_BREAKPARAGRAPH:
1002 case LFUN_BREAKLINE:
1003 view()->text->cursorRight(view());
1004 view()->switchKeyMap();
1005 owner->view_state_changed();
1008 if (!view()->text->cursorPar()->isRightToLeftPar(owner->buffer()->params())) {
1009 view()->text->cursorRight(view());
1011 owner->view_state_changed();
1013 goto exit_with_message;
1015 if (view()->text->cursorPar()->isRightToLeftPar(owner->buffer()->params())) {
1016 view()->text->cursorRight(view());
1018 owner->view_state_changed();
1020 goto exit_with_message;
1022 if (view()->text->cursorRow() != view()->text->lastRow())
1023 view()->text->cursorDown(view());
1025 view()->text->cursorRight(view());
1027 owner->view_state_changed();
1028 goto exit_with_message;
1038 if (!view()->available())
1040 // this function should be used always [asierra060396]
1041 UpdatableInset * tli = view()->theLockingInset();
1043 UpdatableInset * lock = tli->getLockingInset();
1046 view()->unlockInset(tli);
1047 view()->text->cursorRight(view());
1049 owner->view_state_changed();
1051 tli->unlockInsetInInset(view(), lock, true);
1054 // Tell the paragraph dialog that we changed paragraph
1055 dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
1060 case LFUN_WORDFINDFORWARD:
1061 case LFUN_WORDFINDBACKWARD: {
1062 static string last_search;
1063 string searched_string;
1065 if (!argument.empty()) {
1066 last_search = argument;
1067 searched_string = argument;
1069 searched_string = last_search;
1071 bool fw = (action == LFUN_WORDFINDFORWARD);
1072 if (!searched_string.empty())
1073 lyx::find::find(view(), searched_string, fw);
1078 if (view()->available() && !view()->theLockingInset())
1080 owner->message(keyseq.printOptions());
1083 // --- Misc -------------------------------------------
1084 case LFUN_EXEC_COMMAND:
1085 owner->focus_command_buffer();
1090 meta_fake_bit = key_modifier::none;
1091 if (view()->available())
1092 // cancel any selection
1093 dispatch(FuncRequest(LFUN_MARK_OFF));
1094 setMessage(N_("Cancel"));
1097 case LFUN_META_FAKE:
1098 meta_fake_bit = key_modifier::alt;
1099 setMessage(keyseq.print());
1102 case LFUN_READ_ONLY_TOGGLE:
1103 if (owner->buffer()->lyxvc().inUse())
1104 owner->buffer()->lyxvc().toggleReadOnly();
1106 owner->buffer()->setReadonly(
1107 !owner->buffer()->isReadonly());
1110 case LFUN_CENTER: // this is center and redraw.
1114 // --- Menus -----------------------------------------------
1116 menuNew(argument, false);
1119 case LFUN_MENUNEWTMPLT:
1120 menuNew(argument, true);
1123 case LFUN_CLOSEBUFFER:
1127 case LFUN_MENUWRITE:
1128 if (!owner->buffer()->isUnnamed()) {
1129 string const str = bformat(_("Saving document %1$s..."),
1130 MakeDisplayPath(owner->buffer()->fileName()));
1131 owner->message(str);
1132 MenuWrite(owner->buffer());
1133 owner->message(str + _(" done."));
1135 WriteAs(owner->buffer());
1139 WriteAs(owner->buffer(), argument);
1142 case LFUN_MENURELOAD: {
1143 string const file = MakeDisplayPath(view()->buffer()->fileName(), 20);
1144 string text = bformat(_("Any changes will be lost. Are you sure "
1145 "you want to revert to the saved version of the document %1$s?"), file);
1146 int const ret = Alert::prompt(_("Revert to saved document?"),
1147 text, 0, 1, _("&Revert"), _("&Cancel"));
1155 Exporter::Export(owner->buffer(), argument, true);
1156 view()->showErrorList(BufferFormat(*owner->buffer()));
1160 Exporter::Preview(owner->buffer(), argument);
1161 view()->showErrorList(BufferFormat(*owner->buffer()));
1164 case LFUN_BUILDPROG:
1165 Exporter::Export(owner->buffer(), "program", true);
1166 view()->showErrorList(_("Build"));
1169 case LFUN_RUNCHKTEX:
1170 owner->buffer()->runChktex();
1171 view()->showErrorList(_("ChkTeX"));
1175 if (argument == "custom")
1176 owner->getDialogs().showSendto();
1178 Exporter::Export(owner->buffer(), argument, false);
1179 view()->showErrorList(BufferFormat(*owner->buffer()));
1193 InsetCommandParams p("tableofcontents");
1194 string const data = InsetCommandMailer::params2string("toc", p);
1195 owner->getDialogs().show("toc", data, 0);
1211 case LFUN_FREEFONT_APPLY:
1212 apply_freefont(view());
1215 case LFUN_FREEFONT_UPDATE:
1216 update_and_apply_freefont(view(), argument);
1219 case LFUN_RECONFIGURE:
1220 Reconfigure(view());
1224 case LFUN_FLOATSOPERATE:
1225 if (argument == "openfoot")
1226 view()->allFloats(1,0);
1227 else if (argument == "closefoot")
1228 view()->allFloats(0,0);
1229 else if (argument == "openfig")
1230 view()->allFloats(1,1);
1231 else if (argument == "closefig")
1232 view()->allFloats(0,1);
1235 #ifdef WITH_WARNINGS
1236 //#warning Find another implementation here (or another lyxfunc)!
1239 case LFUN_HELP_OPEN:
1241 string const arg = argument;
1243 setErrorMessage(N_("Missing argument"));
1246 string const fname = i18nLibFileSearch("doc", arg, "lyx");
1247 if (fname.empty()) {
1248 lyxerr << "LyX: unable to find documentation file `"
1249 << arg << "'. Bad installation?" << endl;
1252 owner->message(bformat(_("Opening help file %1$s..."),
1253 MakeDisplayPath(fname)));
1254 view()->loadLyXFile(fname, false);
1258 // --- version control -------------------------------
1259 case LFUN_VC_REGISTER:
1261 if (!ensureBufferClean(view()))
1263 if (!owner->buffer()->lyxvc().inUse()) {
1264 owner->buffer()->lyxvc().registrer();
1270 case LFUN_VC_CHECKIN:
1272 if (!ensureBufferClean(view()))
1274 if (owner->buffer()->lyxvc().inUse()
1275 && !owner->buffer()->isReadonly()) {
1276 owner->buffer()->lyxvc().checkIn();
1282 case LFUN_VC_CHECKOUT:
1284 if (!ensureBufferClean(view()))
1286 if (owner->buffer()->lyxvc().inUse()
1287 && owner->buffer()->isReadonly()) {
1288 owner->buffer()->lyxvc().checkOut();
1294 case LFUN_VC_REVERT:
1296 owner->buffer()->lyxvc().revert();
1303 owner->buffer()->lyxvc().undoLast();
1308 // --- buffers ----------------------------------------
1310 case LFUN_SWITCHBUFFER:
1311 view()->buffer(bufferlist.getBuffer(argument));
1315 NewFile(view(), argument);
1318 case LFUN_FILE_OPEN:
1322 case LFUN_LAYOUT_TABULAR:
1323 if (view()->theLockingInset()) {
1324 if (view()->theLockingInset()->lyxCode()== InsetOld::TABULAR_CODE) {
1325 InsetTabular * inset = static_cast<InsetTabular *>
1326 (view()->theLockingInset());
1327 inset->openLayoutDialog(view());
1328 } else if (view()->theLockingInset()->
1329 getFirstLockingInsetOfType(InsetOld::TABULAR_CODE)!=0) {
1330 InsetTabular * inset = static_cast<InsetTabular *>(
1331 view()->theLockingInset()->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE));
1332 inset->openLayoutDialog(view());
1337 case LFUN_DROP_LAYOUTS_CHOICE:
1338 owner->getToolbar().openLayoutList();
1341 case LFUN_MENU_OPEN_BY_NAME:
1342 owner->getMenubar().openByName(argument);
1343 break; // RVDK_PATCH_5
1345 // --- lyxserver commands ----------------------------
1349 setMessage(owner->buffer()->fileName());
1350 lyxerr[Debug::INFO] << "FNAME["
1351 << owner->buffer()->fileName()
1357 dispatch_buffer = keyseq.print();
1358 lyxserver->notifyClient(dispatch_buffer);
1362 case LFUN_GOTOFILEROW:
1366 istringstream istr(argument.c_str());
1367 istr >> file_name >> row;
1368 if (prefixIs(file_name, getTmpDir())) {
1369 // Needed by inverse dvi search. If it is a file
1370 // in tmpdir, call the apropriated function
1371 view()->buffer(bufferlist.getBufferFromTmp(file_name));
1373 // Must replace extension of the file to be .lyx
1374 // and get full path
1375 string const s(ChangeExtension(file_name, ".lyx"));
1376 // Either change buffer or load the file
1377 if (bufferlist.exists(s)) {
1378 view()->buffer(bufferlist.getBuffer(s));
1380 view()->loadLyXFile(s);
1384 view()->setCursorFromRow(row);
1387 // see BufferView_pimpl::center()
1388 view()->updateScrollbar();
1392 case LFUN_GOTO_PARAGRAPH:
1394 istringstream istr(argument.c_str());
1398 ParIterator par = owner->buffer()->getParFromID(id);
1399 if (par == owner->buffer()->par_iterator_end()) {
1400 lyxerr[Debug::INFO] << "No matching paragraph found! ["
1401 << id << ']' << endl;
1404 lyxerr[Debug::INFO] << "Paragraph " << par->id()
1405 << " found." << endl;
1408 if (view()->theLockingInset())
1409 view()->unlockInset(view()->theLockingInset());
1410 if (par->inInset()) {
1411 FuncRequest cmd(view(), LFUN_INSET_EDIT, "left");
1412 par->inInset()->localDispatch(cmd);
1415 view()->getLyXText()->setCursor(par.pit(), 0);
1416 view()->switchKeyMap();
1417 owner->view_state_changed();
1420 // see BufferView_pimpl::center()
1421 view()->updateScrollbar();
1425 // --- insert characters ----------------------------------------
1427 // --- Mathed stuff. If we are here, there is no locked inset yet.
1428 case LFUN_MATH_EXTERN:
1429 case LFUN_MATH_NUMBER:
1430 case LFUN_MATH_NONUMBER:
1431 case LFUN_MATH_LIMITS:
1433 setErrorMessage(N_("This is only allowed in math mode!"));
1437 // passthrough hat and underscore outside mathed:
1438 case LFUN_SUBSCRIPT:
1439 dispatch(FuncRequest(view(), LFUN_SELFINSERT, "_"));
1441 case LFUN_SUPERSCRIPT:
1442 dispatch(FuncRequest(view(), LFUN_SELFINSERT, "^"));
1445 case LFUN_DIALOG_SHOW: {
1446 string const name = func.getArg(0);
1447 string data = trim(func.argument.substr(name.size()));
1449 if (name == "character") {
1450 data = freefont2string();
1452 owner->getDialogs().show("character", data);
1453 } else if (name == "document")
1454 owner->getDialogs().showDocument();
1455 else if (name == "findreplace")
1456 owner->getDialogs().showSearch();
1457 else if (name == "forks")
1458 owner->getDialogs().showForks();
1459 else if (name == "preamble")
1460 owner->getDialogs().showPreamble();
1461 else if (name == "preferences")
1462 owner->getDialogs().showPreferences();
1463 else if (name == "print")
1464 owner->getDialogs().showPrint();
1465 else if (name == "spellchecker")
1466 owner->getDialogs().showSpellchecker();
1468 owner->getDialogs().show(name, data);
1472 case LFUN_DIALOG_SHOW_NEW_INSET: {
1473 string const & name = argument;
1475 if (name == "bibitem" ||
1477 name == "include" ||
1482 InsetCommandParams p(name);
1483 data = InsetCommandMailer::params2string(name, p);
1484 } else if (name == "citation") {
1485 InsetCommandParams p("cite");
1486 data = InsetCommandMailer::params2string(name, p);
1488 owner->getDialogs().show(name, data, 0);
1492 case LFUN_DIALOG_SHOW_NEXT_INSET: {
1496 case LFUN_INSET_DIALOG_SHOW: {
1497 LyXText * lt = view()->getLyXText();
1498 InsetOld * inset = lt->getInset();
1500 FuncRequest cmd(view(), LFUN_INSET_DIALOG_SHOW);
1501 inset->localDispatch(cmd);
1506 case LFUN_DIALOG_UPDATE: {
1507 string const & name = argument;
1508 // Can only update a dialog connected to an existing inset
1509 InsetBase * inset = owner->getDialogs().getOpenInset(name);
1511 FuncRequest fr(view(), LFUN_INSET_DIALOG_UPDATE,
1513 inset->localDispatch(fr);
1514 } else if (name == "paragraph") {
1515 dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
1520 case LFUN_DIALOG_HIDE:
1521 Dialogs::hide(argument, 0);
1524 case LFUN_DIALOG_DISCONNECT_INSET:
1525 owner->getDialogs().disconnect(argument);
1528 case LFUN_CHILDOPEN:
1530 string const filename =
1531 MakeAbsPath(argument, owner->buffer()->filePath());
1532 setMessage(N_("Opening child document ") +
1533 MakeDisplayPath(filename) + "...");
1534 view()->savePosition(0);
1535 if (bufferlist.exists(filename))
1536 view()->buffer(bufferlist.getBuffer(filename));
1538 view()->loadLyXFile(filename);
1542 case LFUN_TOGGLECURSORFOLLOW:
1543 lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
1547 owner->getIntl().KeyMapOn(false);
1550 case LFUN_KMAP_PRIM:
1551 owner->getIntl().KeyMapPrim();
1555 owner->getIntl().KeyMapSec();
1558 case LFUN_KMAP_TOGGLE:
1559 owner->getIntl().ToggleKeyMap();
1564 // argument contains ';'-terminated commands
1565 while (!argument.empty()) {
1567 argument = split(argument, first, ';');
1568 dispatch(lyxaction.lookupFunc(first));
1573 case LFUN_SAVEPREFERENCES:
1575 Path p(user_lyxdir());
1576 lyxrc.write("preferences");
1580 case LFUN_SCREEN_FONT_UPDATE:
1582 // handle the screen font changes.
1583 lyxrc.set_font_norm_type();
1584 lyx_gui::update_fonts();
1585 // All visible buffers will need resize
1591 case LFUN_SET_COLOR:
1594 string const x11_name = split(argument, lyx_name, ' ');
1595 if (lyx_name.empty() || x11_name.empty()) {
1596 setErrorMessage(N_("Syntax: set-color <lyx_name>"
1601 bool const graphicsbg_changed =
1602 (lyx_name == lcolor.getLyXName(LColor::graphicsbg) &&
1603 x11_name != lcolor.getX11Name(LColor::graphicsbg));
1605 if (!lcolor.setColor(lyx_name, x11_name)) {
1607 bformat(_("Set-color \"%1$s\" failed "
1608 "- color is undefined or "
1609 "may not be redefined"), lyx_name));
1613 lyx_gui::update_color(lcolor.getFromLyXName(lyx_name));
1615 if (graphicsbg_changed) {
1616 #ifdef WITH_WARNINGS
1617 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1620 lyx::graphics::GCache & gc =
1621 lyx::graphics::GCache::get();
1622 gc.changeDisplay(true);
1631 owner->message(argument);
1634 case LFUN_FORKS_KILL:
1636 if (!isStrInt(argument))
1639 pid_t const pid = strToInt(argument);
1640 ForkedcallsController & fcc = ForkedcallsController::get();
1645 case LFUN_TOOLTIPS_TOGGLE:
1646 owner->getDialogs().toggleTooltips();
1649 case LFUN_EXTERNAL_EDIT: {
1650 InsetExternal().localDispatch(FuncRequest(view(), action, argument));
1655 // Then if it was none of the above
1656 // Trying the BufferView::pimpl dispatch:
1657 if (!view()->dispatch(func))
1658 lyxerr << "A truly unknown func ["
1659 << lyxaction.getActionName(func.action) << "]!"
1666 view()->owner()->updateLayoutChoice();
1668 if (view()->available()) {
1669 if (view()->fitCursor()) {
1670 //lyxerr << "LyXFunc->fitCursor->update" << endl;
1674 // If we executed a mutating lfun, mark the buffer as dirty
1675 if (!getStatus(func).disabled()
1676 && !lyxaction.funcHasFlag(func.action, LyXAction::NoBuffer)
1677 && !lyxaction.funcHasFlag(func.action, LyXAction::ReadOnly))
1678 view()->buffer()->markDirty();
1681 sendDispatchMessage(getMessage(), func, verbose);
1685 void LyXFunc::sendDispatchMessage(string const & msg,
1686 FuncRequest const & func, bool verbose)
1688 owner->updateMenubar();
1689 owner->updateToolbar();
1691 if (func.action == LFUN_SELFINSERT || !verbose) {
1692 lyxerr[Debug::ACTION] << "dispatch msg is " << msg << endl;
1694 owner->message(msg);
1698 string dispatch_msg = msg;
1699 if (!dispatch_msg.empty())
1700 dispatch_msg += ' ';
1702 string comname = lyxaction.getActionName(func.action);
1704 bool argsadded = false;
1706 if (!func.argument.empty()) {
1707 if (func.action != LFUN_UNKNOWN_ACTION) {
1708 comname += ' ' + func.argument;
1713 string const shortcuts = toplevel_keymap->findbinding(func);
1715 if (!shortcuts.empty()) {
1716 comname += ": " + shortcuts;
1717 } else if (!argsadded && !func.argument.empty()) {
1718 comname += ' ' + func.argument;
1721 if (!comname.empty()) {
1722 comname = rtrim(comname);
1723 dispatch_msg += '(' + comname + ')';
1726 lyxerr[Debug::ACTION] << "verbose dispatch msg " << dispatch_msg << endl;
1727 if (!dispatch_msg.empty())
1728 owner->message(dispatch_msg);
1732 void LyXFunc::setupLocalKeymap()
1734 keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
1735 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap.get();
1739 void LyXFunc::menuNew(string const & name, bool fromTemplate)
1741 string initpath = lyxrc.document_path;
1742 string filename(name);
1744 if (view()->available()) {
1745 string const trypath = owner->buffer()->filePath();
1746 // If directory is writeable, use this as default.
1747 if (IsDirWriteable(trypath))
1751 static int newfile_number;
1753 if (filename.empty()) {
1754 filename = AddName(lyxrc.document_path,
1755 "newfile" + tostr(++newfile_number) + ".lyx");
1756 FileInfo fi(filename);
1757 while (bufferlist.exists(filename) || fi.readable()) {
1759 filename = AddName(lyxrc.document_path,
1760 "newfile" + tostr(newfile_number) +
1762 fi.newFile(filename);
1766 // The template stuff
1769 FileDialog fileDlg(_("Select template file"),
1770 LFUN_SELECT_FILE_SYNC,
1771 make_pair(string(_("Documents|#o#O")),
1772 string(lyxrc.document_path)),
1773 make_pair(string(_("Templates|#T#t")),
1774 string(lyxrc.template_path)));
1776 FileDialog::Result result =
1777 fileDlg.open(lyxrc.template_path,
1778 _("*.lyx| LyX Documents (*.lyx)"));
1780 if (result.first == FileDialog::Later)
1783 string const fname = result.second;
1790 view()->newFile(filename, templname, !name.empty());
1794 void LyXFunc::open(string const & fname)
1796 string initpath = lyxrc.document_path;
1798 if (view()->available()) {
1799 string const trypath = owner->buffer()->filePath();
1800 // If directory is writeable, use this as default.
1801 if (IsDirWriteable(trypath))
1807 if (fname.empty()) {
1808 FileDialog fileDlg(_("Select document to open"),
1810 make_pair(string(_("Documents|#o#O")),
1811 string(lyxrc.document_path)),
1812 make_pair(string(_("Examples|#E#e")),
1813 string(AddPath(system_lyxdir(), "examples"))));
1815 FileDialog::Result result =
1816 fileDlg.open(initpath,
1817 _("*.lyx| LyX Documents (*.lyx)"));
1819 if (result.first == FileDialog::Later)
1822 filename = result.second;
1824 // check selected filename
1825 if (filename.empty()) {
1826 owner->message(_("Canceled."));
1832 // get absolute path of file and add ".lyx" to the filename if
1834 string const fullpath = FileSearch(string(), filename, "lyx");
1835 if (!fullpath.empty()) {
1836 filename = fullpath;
1839 string const disp_fn(MakeDisplayPath(filename));
1841 // if the file doesn't exist, let the user create one
1842 FileInfo const f(filename, true);
1844 // the user specifically chose this name. Believe them.
1845 view()->newFile(filename, "", true);
1849 owner->message(bformat(_("Opening document %1$s..."), disp_fn));
1852 if (view()->loadLyXFile(filename)) {
1853 str2 = bformat(_("Document %1$s opened."), disp_fn);
1855 str2 = bformat(_("Could not open document %1$s"), disp_fn);
1857 owner->message(str2);
1861 void LyXFunc::doImport(string const & argument)
1864 string filename = split(argument, format, ' ');
1866 lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format
1867 << " file: " << filename << endl;
1869 // need user interaction
1870 if (filename.empty()) {
1871 string initpath = lyxrc.document_path;
1873 if (view()->available()) {
1874 string const trypath = owner->buffer()->filePath();
1875 // If directory is writeable, use this as default.
1876 if (IsDirWriteable(trypath))
1880 string const text = bformat(_("Select %1$s file to import"),
1881 formats.prettyName(format));
1883 FileDialog fileDlg(text,
1885 make_pair(string(_("Documents|#o#O")),
1886 string(lyxrc.document_path)),
1887 make_pair(string(_("Examples|#E#e")),
1888 string(AddPath(system_lyxdir(), "examples"))));
1890 string const extension = "*." + formats.extension(format)
1891 + "| " + formats.prettyName(format)
1892 + " (*." + formats.extension(format) + ')';
1894 FileDialog::Result result = fileDlg.open(initpath,
1897 if (result.first == FileDialog::Later)
1900 filename = result.second;
1902 // check selected filename
1903 if (filename.empty())
1904 owner->message(_("Canceled."));
1907 if (filename.empty())
1910 // get absolute path of file
1911 filename = MakeAbsPath(filename);
1913 string const lyxfile = ChangeExtension(filename, ".lyx");
1915 // Check if the document already is open
1916 if (lyx_gui::use_gui && bufferlist.exists(lyxfile)) {
1917 if (!bufferlist.close(bufferlist.getBuffer(lyxfile), true)) {
1918 owner->message(_("Canceled."));
1923 // if the file exists already, and we didn't do
1924 // -i lyx thefile.lyx, warn
1925 if (FileInfo(lyxfile, true).exist() && filename != lyxfile) {
1926 string const file = MakeDisplayPath(lyxfile, 30);
1928 string text = bformat(_("The document %1$s already exists.\n\n"
1929 "Do you want to over-write that document?"), file);
1930 int const ret = Alert::prompt(_("Over-write document?"),
1931 text, 0, 1, _("&Over-write"), _("&Cancel"));
1934 owner->message(_("Canceled."));
1939 Importer::Import(owner, filename, format);
1943 void LyXFunc::closeBuffer()
1945 if (bufferlist.close(owner->buffer(), true) && !quitting) {
1946 if (bufferlist.empty()) {
1947 // need this otherwise SEGV may occur while
1948 // trying to set variables that don't exist
1949 // since there's no current buffer
1950 owner->getDialogs().hideBufferDependent();
1952 view()->buffer(bufferlist.first());
1958 // Each "owner" should have it's own message method. lyxview and
1959 // the minibuffer would use the minibuffer, but lyxserver would
1960 // send an ERROR signal to its client. Alejandro 970603
1961 // This func is bit problematic when it comes to NLS, to make the
1962 // lyx servers client be language indepenent we must not translate
1963 // strings sent to this func.
1964 void LyXFunc::setErrorMessage(string const & m) const
1966 dispatch_buffer = m;
1971 void LyXFunc::setMessage(string const & m) const
1973 dispatch_buffer = m;
1977 void LyXFunc::setStatusMessage(string const & m) const
1983 string const LyXFunc::view_status_message()
1985 // When meta-fake key is pressed, show the key sequence so far + "M-".
1987 return keyseq.print() + "M-";
1990 // Else, when a non-complete key sequence is pressed,
1991 // show the available options.
1992 if (keyseq.length() > 0 && !keyseq.deleted()) {
1993 return keyseq.printOptions();
1996 if (!view()->available())
1997 return _("Welcome to LyX!");
1999 return currentState(view());
2003 BufferView * LyXFunc::view() const
2005 BOOST_ASSERT(owner);
2006 return owner->view().get();
2010 bool LyXFunc::wasMetaKey() const
2012 return (meta_fake_bit != key_modifier::none);