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"
51 #include "TextCache.h"
52 #include "undo_funcs.h"
54 #include "insets/insetcommand.h"
55 #include "insets/insetexternal.h"
56 #include "insets/insettabular.h"
58 #include "mathed/math_cursor.h"
60 #include "frontends/Alert.h"
61 #include "frontends/Dialogs.h"
62 #include "frontends/FileDialog.h"
63 #include "frontends/lyx_gui.h"
64 #include "frontends/LyXKeySym.h"
65 #include "frontends/LyXView.h"
66 #include "frontends/Menubar.h"
67 #include "frontends/Toolbar.h"
69 #include "support/FileInfo.h"
70 #include "support/filetools.h"
71 #include "support/forkedcontr.h"
72 #include "support/path.h"
73 #include "support/path_defines.h"
74 #include "support/tostr.h"
75 #include "support/std_sstream.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;
109 using std::make_pair;
111 using std::istringstream;
114 extern BufferList bufferlist;
115 extern LyXServer * lyxserver;
116 extern bool selection_possible;
118 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
121 extern tex_accent_struct get_accent(kb_action action);
123 extern void ShowLatexLog();
126 LyXFunc::LyXFunc(LyXView * o)
129 keyseq(toplevel_keymap.get(), toplevel_keymap.get()),
130 cancel_meta_seq(toplevel_keymap.get(), toplevel_keymap.get()),
131 meta_fake_bit(key_modifier::none)
136 void LyXFunc::moveCursorUpdate()
138 LyXText * lt = view()->text;
139 if (lt->selection.mark())
142 view()->switchKeyMap();
146 void LyXFunc::handleKeyFunc(kb_action action)
148 char c = encoded_last_key;
150 if (keyseq.length()) {
154 owner->getIntl().getTransManager()
155 .deadkey(c, get_accent(action).accent, view()->getLyXText());
156 // Need to clear, in case the minibuffer calls these
159 // copied verbatim from do_accent_char
161 view()->getLyXText()->selection.cursor = view()->getLyXText()->cursor;
165 void LyXFunc::processKeySym(LyXKeySymPtr keysym,
166 key_modifier::state state)
170 if (lyxerr.debugging(Debug::KEY)) {
171 lyxerr << "KeySym is "
172 << keysym->getSymbolName()
176 // Do nothing if we have nothing (JMarc)
177 if (!keysym->isOK()) {
178 lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
183 if (keysym->isModifier()) {
184 lyxerr[Debug::KEY] << "isModifier true" << endl;
188 Encoding const * encoding = view()->getEncoding();
190 encoded_last_key = keysym->getISOEncoded(encoding ? encoding->Name() : "");
192 // Do a one-deep top-level lookup for
193 // cancel and meta-fake keys. RVDK_PATCH_5
194 cancel_meta_seq.reset();
196 FuncRequest func = cancel_meta_seq.addkey(keysym, state);
197 lyxerr[Debug::KEY] << "action first set to [" << func.action << ']' << endl;
199 // When not cancel or meta-fake, do the normal lookup.
200 // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
201 // Mostly, meta_fake_bit = key_modifier::none. RVDK_PATCH_5.
202 if ((func.action != LFUN_CANCEL) && (func.action != LFUN_META_FAKE)) {
203 // remove Caps Lock and Mod2 as a modifiers
204 func = keyseq.addkey(keysym, (state | meta_fake_bit));
205 lyxerr[Debug::KEY] << "action now set to ["
206 << func.action << ']' << endl;
209 // Dont remove this unless you know what you are doing.
210 meta_fake_bit = key_modifier::none;
212 // can this happen now ?
213 if (func.action == LFUN_NOACTION) {
214 func = FuncRequest(LFUN_PREFIX);
217 if (lyxerr.debugging(Debug::KEY)) {
218 lyxerr << "Key [action="
219 << func.action << "]["
220 << keyseq.print() << ']'
224 // already here we know if it any point in going further
225 // why not return already here if action == -1 and
226 // num_bytes == 0? (Lgb)
228 if (keyseq.length() > 1) {
229 owner->message(keyseq.print());
233 // Maybe user can only reach the key via holding down shift.
234 // Let's see. But only if shift is the only modifier
235 if (func.action == LFUN_UNKNOWN_ACTION &&
236 state == key_modifier::shift) {
237 lyxerr[Debug::KEY] << "Trying without shift" << endl;
238 func = keyseq.addkey(keysym, key_modifier::none);
239 lyxerr[Debug::KEY] << "Action now " << func.action << endl;
242 if (func.action == LFUN_UNKNOWN_ACTION) {
243 // Hmm, we didn't match any of the keysequences. See
244 // if it's normal insertable text not already covered
246 if (keysym->isText() && keyseq.length() == 1) {
247 lyxerr[Debug::KEY] << "isText() is true, inserting." << endl;
248 func = FuncRequest(LFUN_SELFINSERT);
250 lyxerr[Debug::KEY] << "Unknown, !isText() - giving up" << endl;
251 owner->message(_("Unknown function."));
256 if (func.action == LFUN_SELFINSERT) {
257 if (encoded_last_key != 0) {
259 arg += encoded_last_key;
261 dispatch(FuncRequest(view(), LFUN_SELFINSERT, arg));
263 lyxerr[Debug::KEY] << "SelfInsert arg[`"
264 << argument << "']" << endl;
272 FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
275 Buffer * buf = owner->buffer();
277 if (ev.action == LFUN_NOACTION) {
278 setStatusMessage(N_("Nothing to do"));
279 return flag.disabled(true);
283 case LFUN_UNKNOWN_ACTION:
284 #ifndef HAVE_LIBAIKSAURUS
285 case LFUN_THESAURUS_ENTRY:
290 flag |= lyx_gui::getStatus(ev);
293 if (flag.unknown()) {
294 setStatusMessage(N_("Unknown action"));
298 // the default error message if we disable the command
299 setStatusMessage(N_("Command disabled"));
301 // Check whether we need a buffer
302 if (!lyxaction.funcHasFlag(ev.action, LyXAction::NoBuffer)) {
303 // Yes we need a buffer, do we have one?
306 // Can we use a readonly buffer?
307 if (buf->isReadonly() &&
308 !lyxaction.funcHasFlag(ev.action,
309 LyXAction::ReadOnly)) {
311 setStatusMessage(N_("Document is read-only"));
316 setStatusMessage(N_("Command not allowed with"
317 "out any document open"));
318 return flag.disabled(true);
322 UpdatableInset * tli = view()->theLockingInset();
324 // I would really like to avoid having this switch and rather try to
325 // encode this in the function itself.
326 bool disable = false;
329 disable = ev.argument != "custom"
330 && !Exporter::IsExportable(*buf, ev.argument);
333 disable = buf->undostack().empty();
336 disable = buf->redostack().empty();
341 UpdatableInset * in = tli;
342 if (in->lyxCode() != InsetOld::TABULAR_CODE) {
343 in = tli->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE);
345 if (in && static_cast<InsetTabular*>(in)->hasSelection()) {
350 disable = !mathcursor && !view()->getLyXText()->selection.set();
353 disable = !buf->isLatex() || lyxrc.chktex_command == "none";
356 disable = !Exporter::IsExportable(*buf, "program");
359 case LFUN_LAYOUT_TABULAR:
361 || (tli->lyxCode() != InsetOld::TABULAR_CODE
362 && !tli->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE));
366 disable = !changeDepth(view(), view()->getLyXText(), DEC_DEPTH, true);
369 case LFUN_DEPTH_PLUS:
370 disable = !changeDepth(view(), view()->getLyXText(), INC_DEPTH, true);
374 case LFUN_LAYOUT_PARAGRAPH: {
375 InsetOld * inset = view()->getLyXText()->cursorPar()->inInset();
376 disable = inset && inset->forceDefaultParagraphs(inset);
380 case LFUN_INSET_OPTARG:
381 disable = (view()->getLyXText()->cursorPar()->layout()->optionalargs == 0);
384 case LFUN_TABULAR_FEATURE:
387 // FIXME: check temporarily disabled
389 char align = mathcursor->valign();
394 if (ev.argument.empty()) {
398 if (!contains("tcb", ev.argument[0])) {
402 flag.setOnOff(ev.argument[0] == align);
406 char align = mathcursor->halign();
411 if (ev.argument.empty()) {
415 if (!contains("lcr", ev.argument[0])) {
419 flag.setOnOff(ev.argument[0] == align);
422 disable = !mathcursor->halign();
428 //ret.disabled(true);
429 if (tli->lyxCode() == InsetOld::TABULAR_CODE) {
430 ret = static_cast<InsetTabular *>(tli)
431 ->getStatus(ev.argument);
434 } else if (tli->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE)) {
435 ret = static_cast<InsetTabular *>
436 (tli->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE))
437 ->getStatus(ev.argument);
444 static InsetTabular inset(*owner->buffer(), 1, 1);
448 ret = inset.getStatus(ev.argument);
449 if (ret.onoff(true) || ret.onoff(false))
450 flag.setOnOff(false);
454 case LFUN_VC_REGISTER:
455 disable = buf->lyxvc().inUse();
457 case LFUN_VC_CHECKIN:
458 disable = !buf->lyxvc().inUse() || buf->isReadonly();
460 case LFUN_VC_CHECKOUT:
461 disable = !buf->lyxvc().inUse() || !buf->isReadonly();
465 disable = !buf->lyxvc().inUse();
467 case LFUN_MENURELOAD:
468 disable = buf->isUnnamed() || buf->isClean();
470 case LFUN_BOOKMARK_GOTO:
472 isSavedPosition(strToUnsignedInt(ev.argument));
474 case LFUN_MERGE_CHANGES:
475 case LFUN_ACCEPT_CHANGE:
476 case LFUN_REJECT_CHANGE:
477 case LFUN_ACCEPT_ALL_CHANGES:
478 case LFUN_REJECT_ALL_CHANGES:
479 disable = !buf->params().tracking_changes;
481 case LFUN_INSET_TOGGLE: {
482 LyXText * lt = view()->getLyXText();
483 disable = !(isEditableInset(lt->getInset())
485 && lt->inset_owner->owner()
486 && lt->inset_owner->owner()->isOpen()));
490 case LFUN_INSET_SETTINGS: {
492 UpdatableInset * inset = view()->theLockingInset();
497 // get the innermost inset
498 inset = inset->getLockingInset();
500 // jump back to owner if an InsetText, so
501 // we get back to the InsetTabular or whatever
502 if (inset->lyxCode() == InsetOld::TEXT_CODE)
503 inset = inset->owner();
505 InsetOld::Code code = inset->lyxCode();
507 case InsetOld::TABULAR_CODE:
508 disable = ev.argument != "tabular";
510 case InsetOld::ERT_CODE:
511 disable = ev.argument != "ert";
513 case InsetOld::FLOAT_CODE:
514 disable = ev.argument != "float";
516 case InsetOld::MINIPAGE_CODE:
517 disable = ev.argument != "minipage";
519 case InsetOld::WRAP_CODE:
520 disable = ev.argument != "wrap";
522 case InsetOld::NOTE_CODE:
523 disable = ev.argument != "note";
525 case InsetOld::BRANCH_CODE:
526 disable = ev.argument != "branch";
528 case InsetOld::BOX_CODE:
529 disable = ev.argument != "box";
537 case LFUN_MATH_MUTATE:
539 //flag.setOnOff(mathcursor->formula()->hullType() == ev.argument);
540 flag.setOnOff(false);
545 // we just need to be in math mode to enable that
547 case LFUN_MATH_SPACE:
548 case LFUN_MATH_LIMITS:
549 case LFUN_MATH_NONUMBER:
550 case LFUN_MATH_NUMBER:
551 case LFUN_MATH_EXTERN:
552 disable = !mathcursor;
555 case LFUN_DIALOG_SHOW: {
556 string const name = ev.getArg(0);
558 disable = !(name == "aboutlyx" ||
561 name == "preferences" ||
566 if (name == "print") {
567 disable = !Exporter::IsExportable(*buf, "dvi") ||
568 lyxrc.print_command == "none";
569 } else if (name == "character") {
570 UpdatableInset * tli = view()->theLockingInset();
571 disable = tli && tli->lyxCode() == InsetOld::ERT_CODE;
572 } else if (name == "vclog") {
573 disable = !buf->lyxvc().inUse();
574 } else if (name == "latexlog") {
575 disable = !IsFileReadable(buf->getLogName().second);
584 // the functions which insert insets
585 InsetOld::Code code = InsetOld::NO_CODE;
587 case LFUN_DIALOG_SHOW_NEW_INSET:
588 if (ev.argument == "bibitem")
589 code = InsetOld::BIBITEM_CODE;
590 else if (ev.argument == "bibtex")
591 code = InsetOld::BIBTEX_CODE;
592 else if (ev.argument == "citation")
593 code = InsetOld::CITE_CODE;
594 else if (ev.argument == "ert")
595 code = InsetOld::ERT_CODE;
596 else if (ev.argument == "external")
597 code = InsetOld::EXTERNAL_CODE;
598 else if (ev.argument == "float")
599 code = InsetOld::FLOAT_CODE;
600 else if (ev.argument == "graphics")
601 code = InsetOld::GRAPHICS_CODE;
602 else if (ev.argument == "include")
603 code = InsetOld::INCLUDE_CODE;
604 else if (ev.argument == "index")
605 code = InsetOld::INDEX_CODE;
606 else if (ev.argument == "label")
607 code = InsetOld::LABEL_CODE;
608 else if (ev.argument == "minipage")
609 code = InsetOld::MINIPAGE_CODE;
610 else if (ev.argument == "ref")
611 code = InsetOld::REF_CODE;
612 else if (ev.argument == "toc")
613 code = InsetOld::TOC_CODE;
614 else if (ev.argument == "url")
615 code = InsetOld::URL_CODE;
616 else if (ev.argument == "wrap")
617 code = InsetOld::WRAP_CODE;
621 code = InsetOld::ERT_CODE;
623 case LFUN_INSET_FOOTNOTE:
624 code = InsetOld::FOOT_CODE;
626 case LFUN_TABULAR_INSERT:
627 code = InsetOld::TABULAR_CODE;
629 case LFUN_INSET_MARGINAL:
630 code = InsetOld::MARGIN_CODE;
632 case LFUN_INSET_MINIPAGE:
633 code = InsetOld::MINIPAGE_CODE;
635 case LFUN_INSET_FLOAT:
636 case LFUN_INSET_WIDE_FLOAT:
637 code = InsetOld::FLOAT_CODE;
639 case LFUN_INSET_WRAP:
640 code = InsetOld::WRAP_CODE;
642 case LFUN_FLOAT_LIST:
643 code = InsetOld::FLOAT_LIST_CODE;
646 case LFUN_INSET_LIST:
647 code = InsetOld::LIST_CODE;
649 case LFUN_INSET_THEOREM:
650 code = InsetOld::THEOREM_CODE;
653 case LFUN_INSET_CAPTION:
654 code = InsetOld::CAPTION_CODE;
656 case LFUN_INSERT_NOTE:
657 code = InsetOld::NOTE_CODE;
659 case LFUN_INSERT_BOX:
660 code = InsetOld::BOX_CODE;
662 case LFUN_INSERT_BRANCH:
663 code = InsetOld::BRANCH_CODE;
664 if (buf->params().branchlist().empty())
667 case LFUN_INSERT_LABEL:
668 code = InsetOld::LABEL_CODE;
670 case LFUN_INSET_OPTARG:
671 code = InsetOld::OPTARG_CODE;
673 case LFUN_ENVIRONMENT_INSERT:
674 code = InsetOld::MINIPAGE_CODE;
676 case LFUN_INDEX_INSERT:
677 code = InsetOld::INDEX_CODE;
679 case LFUN_INDEX_PRINT:
680 code = InsetOld::INDEX_PRINT_CODE;
682 case LFUN_TOC_INSERT:
683 code = InsetOld::TOC_CODE;
687 code = InsetOld::URL_CODE;
690 // always allow this, since we will inset a raw quote
691 // if an inset is not allowed.
693 case LFUN_HYPHENATION:
694 case LFUN_LIGATURE_BREAK:
696 case LFUN_MENU_SEPARATOR:
698 case LFUN_END_OF_SENTENCE:
699 code = InsetOld::SPECIALCHAR_CODE;
701 case LFUN_SPACE_INSERT:
702 // slight hack: we know this is allowed in math mode
704 code = InsetOld::SPACE_CODE;
706 case LFUN_INSET_DIALOG_SHOW: {
707 LyXText * lt = view()->getLyXText();
708 InsetOld * inset = lt->getInset();
711 code = inset->lyxCode();
712 if (!(code == InsetOld::INCLUDE_CODE
713 || code == InsetOld::BIBTEX_CODE
714 || code == InsetOld::FLOAT_LIST_CODE
715 || code == InsetOld::TOC_CODE))
723 if (code != InsetOld::NO_CODE && tli && !tli->insetAllowed(code))
729 // A few general toggles
731 case LFUN_TOOLTIPS_TOGGLE:
732 flag.setOnOff(owner->getDialogs().tooltipsEnabled());
735 case LFUN_READ_ONLY_TOGGLE:
736 flag.setOnOff(buf->isReadonly());
739 flag.setOnOff(view()->getLyXText()->cursorPar()->params().startOfAppendix());
741 case LFUN_SWITCHBUFFER:
742 // toggle on the current buffer, but do not toggle off
743 // the other ones (is that a good idea?)
744 if (ev.argument == buf->fileName())
747 case LFUN_TRACK_CHANGES:
748 flag.setOnOff(buf->params().tracking_changes);
754 // the font related toggles
756 LyXFont const & font = view()->getLyXText()->real_current_font;
759 flag.setOnOff(font.emph() == LyXFont::ON);
762 flag.setOnOff(font.noun() == LyXFont::ON);
765 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
768 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
771 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
774 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
780 string tc = mathcursor->getLastCode();
783 flag.setOnOff(tc == "mathbf");
786 flag.setOnOff(tc == "mathsf");
789 flag.setOnOff(tc == "mathcal");
792 flag.setOnOff(tc == "mathrm");
795 flag.setOnOff(tc == "mathtt");
798 flag.setOnOff(tc == "mathbb");
801 flag.setOnOff(tc == "mathnormal");
808 // this one is difficult to get right. As a half-baked
809 // solution, we consider only the first action of the sequence
810 if (ev.action == LFUN_SEQUENCE) {
811 // argument contains ';'-terminated commands
812 #warning LyXAction arguements not handled here.
813 flag = getStatus(FuncRequest(lyxaction.lookupFunc(token(ev.argument, ';', 0))));
822 bool ensureBufferClean(BufferView * bv)
824 Buffer & buf = *bv->buffer();
828 string const file = MakeDisplayPath(buf.fileName(), 30);
829 string text = bformat(_("The document %1$s has unsaved "
830 "changes.\n\nDo you want to save "
831 "the document?"), file);
832 int const ret = Alert::prompt(_("Save changed document?"),
833 text, 0, 1, _("&Save"),
837 bv->owner()->dispatch(FuncRequest(LFUN_MENUWRITE));
839 return buf.isClean();
845 void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
847 string argument = func.argument;
848 kb_action action = func.action;
850 lyxerr[Debug::ACTION] << "LyXFunc::dispatch: action[" << action
851 <<"] arg[" << argument << ']' << endl;
853 // we have not done anything wrong yet.
855 dispatch_buffer.erase();
857 #ifdef NEW_DISPATCHER
858 // We try do call the most specific dispatcher first:
859 // 1. the lockinginset's dispatch
860 // 2. the bufferview's dispatch
861 // 3. the lyxview's dispatch
864 selection_possible = false;
866 // We cannot use this function here
867 if (getStatus(func).disabled()) {
868 lyxerr[Debug::ACTION] << "LyXFunc::dispatch: "
869 << lyxaction.getActionName(action)
870 << " [" << action << "] is disabled at this location"
872 setErrorMessage(getStatusMessage());
873 goto exit_with_message;
876 if (view()->available())
877 view()->hideCursor();
882 buildCursor(cursor, *view());
883 if (cursor.dispatch(FuncRequest(func, view())) == DISPATCHED) {
884 lyxerr << "dispatched by Cursor::dispatch()\n";
885 goto exit_with_message;
891 if (view()->available() && view()->theLockingInset()) {
892 dispatch_result result;
893 if (action > 1 || (action == LFUN_UNKNOWN_ACTION &&
896 UpdatableInset * inset = view()->theLockingInset();
900 inset->getCursorPos(view(), inset_x, dummy_y);
902 if (action == LFUN_UNKNOWN_ACTION
903 && argument.empty()) {
904 argument = encoded_last_key;
907 // the insets can't try to handle this,
908 // a table cell in the dummy position will
909 // lock its insettext, the insettext will
910 // pass it the bufferview, and succeed,
911 // so it will stay not locked. Not good
912 // if we've just done LFUN_ESCAPE (which
913 // injects an LFUN_PARAGRAPH_UPDATE)
914 if (action == LFUN_PARAGRAPH_UPDATE) {
915 view()->dispatch(func);
916 goto exit_with_message;
919 // Undo/Redo is a bit tricky for insets.
920 if (action == LFUN_UNDO) {
922 goto exit_with_message;
925 if (action == LFUN_REDO) {
927 goto exit_with_message;
930 // Hand-over to inset's own dispatch:
931 result = inset->localDispatch(FuncRequest(view(), action, argument));
932 if (result == DISPATCHED || result == DISPATCHED_NOUPDATE) {
933 goto exit_with_message;
936 // If UNDISPATCHED, just soldier on
937 if (result == FINISHED) {
938 owner->clearMessage();
939 goto exit_with_message;
940 // We do not need special RTL handling here:
941 // FINISHED means that the cursor should be
942 // one position after the inset.
945 if (result == FINISHED_RIGHT) {
946 view()->text->cursorRight(view());
948 owner->clearMessage();
949 goto exit_with_message;
952 if (result == FINISHED_UP) {
953 RowList::iterator const irow = view()->text->cursorIRow();
954 if (irow != view()->text->firstRow()) {
956 view()->text->setCursorFromCoordinates(
957 view()->text->cursor.x() + inset_x,
958 view()->text->cursor.y() -
959 irow->baseline() - 1);
960 view()->text->cursor.x_fix(view()->text->cursor.x());
962 view()->text->cursorUp(view());
968 owner->clearMessage();
969 goto exit_with_message;
972 if (result == FINISHED_DOWN) {
973 RowList::iterator const irow = view()->text->cursorIRow();
974 if (irow != view()->text->lastRow()) {
976 view()->text->setCursorFromCoordinates(
977 view()->text->cursor.x() + inset_x,
978 view()->text->cursor.y() -
981 view()->text->cursor.x_fix(view()->text->cursor.x());
983 view()->text->cursorDown(view());
986 view()->text->cursorRight(view());
989 owner->clearMessage();
990 goto exit_with_message;
993 #warning I am not sure this is still right, please have a look! (Jug 20020417)
994 // result == UNDISPATCHED
995 //setMessage(N_("Text mode"));
997 case LFUN_UNKNOWN_ACTION:
998 case LFUN_BREAKPARAGRAPH:
1000 view()->text->cursorRight(view());
1001 view()->switchKeyMap();
1002 owner->view_state_changed();
1005 if (!view()->text->cursorPar()->isRightToLeftPar(owner->buffer()->params())) {
1006 view()->text->cursorRight(view());
1008 owner->view_state_changed();
1010 goto exit_with_message;
1012 if (view()->text->cursorPar()->isRightToLeftPar(owner->buffer()->params())) {
1013 view()->text->cursorRight(view());
1015 owner->view_state_changed();
1017 goto exit_with_message;
1019 if (view()->text->cursorRow() != view()->text->lastRow())
1020 view()->text->cursorDown(view());
1022 view()->text->cursorRight(view());
1024 owner->view_state_changed();
1025 goto exit_with_message;
1035 if (!view()->available())
1037 // this function should be used always [asierra060396]
1038 UpdatableInset * tli = view()->theLockingInset();
1040 UpdatableInset * lock = tli->getLockingInset();
1043 view()->unlockInset(tli);
1044 view()->text->cursorRight(view());
1046 owner->view_state_changed();
1048 tli->unlockInsetInInset(view(), lock, true);
1051 // Tell the paragraph dialog that we changed paragraph
1052 dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
1057 case LFUN_WORDFINDFORWARD:
1058 case LFUN_WORDFINDBACKWARD: {
1059 static string last_search;
1060 string searched_string;
1062 if (!argument.empty()) {
1063 last_search = argument;
1064 searched_string = argument;
1066 searched_string = last_search;
1068 bool fw = (action == LFUN_WORDFINDFORWARD);
1069 if (!searched_string.empty())
1070 lyx::find::find(view(), searched_string, fw);
1075 if (view()->available() && !view()->theLockingInset())
1077 owner->message(keyseq.printOptions());
1080 // --- Misc -------------------------------------------
1081 case LFUN_EXEC_COMMAND:
1082 owner->focus_command_buffer();
1087 meta_fake_bit = key_modifier::none;
1088 if (view()->available())
1089 // cancel any selection
1090 dispatch(FuncRequest(LFUN_MARK_OFF));
1091 setMessage(N_("Cancel"));
1094 case LFUN_META_FAKE:
1095 meta_fake_bit = key_modifier::alt;
1096 setMessage(keyseq.print());
1099 case LFUN_READ_ONLY_TOGGLE:
1100 if (owner->buffer()->lyxvc().inUse())
1101 owner->buffer()->lyxvc().toggleReadOnly();
1103 owner->buffer()->setReadonly(
1104 !owner->buffer()->isReadonly());
1107 case LFUN_CENTER: // this is center and redraw.
1111 // --- Menus -----------------------------------------------
1113 menuNew(argument, false);
1116 case LFUN_MENUNEWTMPLT:
1117 menuNew(argument, true);
1120 case LFUN_CLOSEBUFFER:
1124 case LFUN_MENUWRITE:
1125 if (!owner->buffer()->isUnnamed()) {
1126 string const str = bformat(_("Saving document %1$s..."),
1127 MakeDisplayPath(owner->buffer()->fileName()));
1128 owner->message(str);
1129 MenuWrite(owner->buffer());
1130 owner->message(str + _(" done."));
1132 WriteAs(owner->buffer());
1136 WriteAs(owner->buffer(), argument);
1139 case LFUN_MENURELOAD: {
1140 string const file = MakeDisplayPath(view()->buffer()->fileName(), 20);
1141 string text = bformat(_("Any changes will be lost. Are you sure "
1142 "you want to revert to the saved version of the document %1$s?"), file);
1143 int const ret = Alert::prompt(_("Revert to saved document?"),
1144 text, 0, 1, _("&Revert"), _("&Cancel"));
1152 Exporter::Export(owner->buffer(), argument, true);
1153 view()->showErrorList(BufferFormat(*owner->buffer()));
1157 Exporter::Preview(owner->buffer(), argument);
1158 view()->showErrorList(BufferFormat(*owner->buffer()));
1161 case LFUN_BUILDPROG:
1162 Exporter::Export(owner->buffer(), "program", true);
1163 view()->showErrorList(_("Build"));
1166 case LFUN_RUNCHKTEX:
1167 owner->buffer()->runChktex();
1168 view()->showErrorList(_("ChkTeX"));
1172 if (argument == "custom")
1173 owner->getDialogs().showSendto();
1175 Exporter::Export(owner->buffer(), argument, false);
1176 view()->showErrorList(BufferFormat(*owner->buffer()));
1190 InsetCommandParams p("tableofcontents");
1191 string const data = InsetCommandMailer::params2string("toc", p);
1192 owner->getDialogs().show("toc", data, 0);
1208 case LFUN_FREEFONT_APPLY:
1209 apply_freefont(view());
1212 case LFUN_FREEFONT_UPDATE:
1213 update_and_apply_freefont(view(), argument);
1216 case LFUN_RECONFIGURE:
1217 Reconfigure(view());
1221 case LFUN_FLOATSOPERATE:
1222 if (argument == "openfoot")
1223 view()->allFloats(1,0);
1224 else if (argument == "closefoot")
1225 view()->allFloats(0,0);
1226 else if (argument == "openfig")
1227 view()->allFloats(1,1);
1228 else if (argument == "closefig")
1229 view()->allFloats(0,1);
1232 #ifdef WITH_WARNINGS
1233 //#warning Find another implementation here (or another lyxfunc)!
1236 case LFUN_HELP_OPEN:
1238 string const arg = argument;
1240 setErrorMessage(N_("Missing argument"));
1243 string const fname = i18nLibFileSearch("doc", arg, "lyx");
1244 if (fname.empty()) {
1245 lyxerr << "LyX: unable to find documentation file `"
1246 << arg << "'. Bad installation?" << endl;
1249 owner->message(bformat(_("Opening help file %1$s..."),
1250 MakeDisplayPath(fname)));
1251 view()->loadLyXFile(fname, false);
1255 // --- version control -------------------------------
1256 case LFUN_VC_REGISTER:
1258 if (!ensureBufferClean(view()))
1260 if (!owner->buffer()->lyxvc().inUse()) {
1261 owner->buffer()->lyxvc().registrer();
1267 case LFUN_VC_CHECKIN:
1269 if (!ensureBufferClean(view()))
1271 if (owner->buffer()->lyxvc().inUse()
1272 && !owner->buffer()->isReadonly()) {
1273 owner->buffer()->lyxvc().checkIn();
1279 case LFUN_VC_CHECKOUT:
1281 if (!ensureBufferClean(view()))
1283 if (owner->buffer()->lyxvc().inUse()
1284 && owner->buffer()->isReadonly()) {
1285 owner->buffer()->lyxvc().checkOut();
1291 case LFUN_VC_REVERT:
1293 owner->buffer()->lyxvc().revert();
1300 owner->buffer()->lyxvc().undoLast();
1305 // --- buffers ----------------------------------------
1307 case LFUN_SWITCHBUFFER:
1308 view()->buffer(bufferlist.getBuffer(argument));
1312 NewFile(view(), argument);
1315 case LFUN_FILE_OPEN:
1319 case LFUN_LAYOUT_TABULAR:
1320 if (view()->theLockingInset()) {
1321 if (view()->theLockingInset()->lyxCode()== InsetOld::TABULAR_CODE) {
1322 InsetTabular * inset = static_cast<InsetTabular *>
1323 (view()->theLockingInset());
1324 inset->openLayoutDialog(view());
1325 } else if (view()->theLockingInset()->
1326 getFirstLockingInsetOfType(InsetOld::TABULAR_CODE)!=0) {
1327 InsetTabular * inset = static_cast<InsetTabular *>(
1328 view()->theLockingInset()->getFirstLockingInsetOfType(InsetOld::TABULAR_CODE));
1329 inset->openLayoutDialog(view());
1334 case LFUN_DROP_LAYOUTS_CHOICE:
1335 owner->getToolbar().openLayoutList();
1338 case LFUN_MENU_OPEN_BY_NAME:
1339 owner->getMenubar().openByName(argument);
1340 break; // RVDK_PATCH_5
1342 // --- lyxserver commands ----------------------------
1346 setMessage(owner->buffer()->fileName());
1347 lyxerr[Debug::INFO] << "FNAME["
1348 << owner->buffer()->fileName()
1354 dispatch_buffer = keyseq.print();
1355 lyxserver->notifyClient(dispatch_buffer);
1359 case LFUN_GOTOFILEROW:
1363 istringstream istr(argument.c_str());
1364 istr >> file_name >> row;
1365 // Must replace extension of the file to be .lyx and get full path
1366 string const s(ChangeExtension(file_name, ".lyx"));
1368 // Either change buffer or load the file
1369 if (bufferlist.exists(s)) {
1370 view()->buffer(bufferlist.getBuffer(s));
1372 view()->loadLyXFile(s);
1375 view()->setCursorFromRow(row);
1378 // see BufferView_pimpl::center()
1379 view()->updateScrollbar();
1383 case LFUN_GOTO_PARAGRAPH:
1385 istringstream istr(argument.c_str());
1389 ParIterator par = owner->buffer()->getParFromID(id);
1390 if (par == owner->buffer()->par_iterator_end()) {
1391 lyxerr[Debug::INFO] << "No matching paragraph found! ["
1392 << id << ']' << endl;
1395 lyxerr[Debug::INFO] << "Paragraph " << par->id()
1396 << " found." << endl;
1399 if (view()->theLockingInset())
1400 view()->unlockInset(view()->theLockingInset());
1401 if (par->inInset()) {
1402 FuncRequest cmd(view(), LFUN_INSET_EDIT, "left");
1403 par->inInset()->localDispatch(cmd);
1406 view()->getLyXText()->setCursor(par.pit(), 0);
1407 view()->switchKeyMap();
1408 owner->view_state_changed();
1411 // see BufferView_pimpl::center()
1412 view()->updateScrollbar();
1416 // --- insert characters ----------------------------------------
1418 // --- Mathed stuff. If we are here, there is no locked inset yet.
1419 case LFUN_MATH_EXTERN:
1420 case LFUN_MATH_NUMBER:
1421 case LFUN_MATH_NONUMBER:
1422 case LFUN_MATH_LIMITS:
1424 setErrorMessage(N_("This is only allowed in math mode!"));
1428 // passthrough hat and underscore outside mathed:
1429 case LFUN_SUBSCRIPT:
1430 dispatch(FuncRequest(view(), LFUN_SELFINSERT, "_"));
1432 case LFUN_SUPERSCRIPT:
1433 dispatch(FuncRequest(view(), LFUN_SELFINSERT, "^"));
1436 case LFUN_DIALOG_SHOW: {
1437 string const name = func.getArg(0);
1438 string data = trim(func.argument.substr(name.size()));
1440 if (name == "character") {
1441 data = freefont2string();
1443 owner->getDialogs().show("character", data);
1444 } else if (name == "document")
1445 owner->getDialogs().showDocument();
1446 else if (name == "findreplace")
1447 owner->getDialogs().showSearch();
1448 else if (name == "forks")
1449 owner->getDialogs().showForks();
1450 else if (name == "preamble")
1451 owner->getDialogs().showPreamble();
1452 else if (name == "preferences")
1453 owner->getDialogs().showPreferences();
1454 else if (name == "print")
1455 owner->getDialogs().showPrint();
1456 else if (name == "spellchecker")
1457 owner->getDialogs().showSpellchecker();
1459 owner->getDialogs().show(name, data);
1463 case LFUN_DIALOG_SHOW_NEW_INSET: {
1464 string const & name = argument;
1466 if (name == "bibitem" ||
1468 name == "include" ||
1473 InsetCommandParams p(name);
1474 data = InsetCommandMailer::params2string(name, p);
1475 } else if (name == "citation") {
1476 InsetCommandParams p("cite");
1477 data = InsetCommandMailer::params2string(name, p);
1479 owner->getDialogs().show(name, data, 0);
1483 case LFUN_DIALOG_SHOW_NEXT_INSET: {
1487 case LFUN_INSET_DIALOG_SHOW: {
1488 LyXText * lt = view()->getLyXText();
1489 InsetOld * inset = lt->getInset();
1491 FuncRequest cmd(view(), LFUN_INSET_DIALOG_SHOW);
1492 inset->localDispatch(cmd);
1497 case LFUN_DIALOG_UPDATE: {
1498 string const & name = argument;
1499 // Can only update a dialog connected to an existing inset
1500 InsetBase * inset = owner->getDialogs().getOpenInset(name);
1502 FuncRequest fr(view(), LFUN_INSET_DIALOG_UPDATE,
1504 inset->localDispatch(fr);
1505 } else if (name == "paragraph") {
1506 dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
1511 case LFUN_DIALOG_HIDE:
1512 Dialogs::hide(argument, 0);
1515 case LFUN_DIALOG_DISCONNECT_INSET:
1516 owner->getDialogs().disconnect(argument);
1519 case LFUN_CHILDOPEN:
1521 string const filename =
1522 MakeAbsPath(argument, owner->buffer()->filePath());
1523 setMessage(N_("Opening child document ") +
1524 MakeDisplayPath(filename) + "...");
1525 view()->savePosition(0);
1526 if (bufferlist.exists(filename))
1527 view()->buffer(bufferlist.getBuffer(filename));
1529 view()->loadLyXFile(filename);
1533 case LFUN_TOGGLECURSORFOLLOW:
1534 lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
1538 owner->getIntl().KeyMapOn(false);
1541 case LFUN_KMAP_PRIM:
1542 owner->getIntl().KeyMapPrim();
1546 owner->getIntl().KeyMapSec();
1549 case LFUN_KMAP_TOGGLE:
1550 owner->getIntl().ToggleKeyMap();
1555 // argument contains ';'-terminated commands
1556 while (!argument.empty()) {
1558 argument = split(argument, first, ';');
1559 dispatch(lyxaction.lookupFunc(first));
1564 case LFUN_SAVEPREFERENCES:
1566 Path p(user_lyxdir());
1567 lyxrc.write("preferences");
1571 case LFUN_SCREEN_FONT_UPDATE:
1573 // handle the screen font changes.
1574 lyxrc.set_font_norm_type();
1575 lyx_gui::update_fonts();
1576 // We also need to empty the textcache so that
1577 // the buffer will be formatted correctly after
1580 // Of course we should only do the resize and the textcache.clear
1581 // if values really changed...but not very important right now. (Lgb)
1582 // All visible buffers will need resize
1588 case LFUN_SET_COLOR:
1591 string const x11_name = split(argument, lyx_name, ' ');
1592 if (lyx_name.empty() || x11_name.empty()) {
1593 setErrorMessage(N_("Syntax: set-color <lyx_name>"
1598 bool const graphicsbg_changed =
1599 (lyx_name == lcolor.getLyXName(LColor::graphicsbg) &&
1600 x11_name != lcolor.getX11Name(LColor::graphicsbg));
1602 if (!lcolor.setColor(lyx_name, x11_name)) {
1604 bformat(_("Set-color \"%1$s\" failed "
1605 "- color is undefined or "
1606 "may not be redefined"), lyx_name));
1610 lyx_gui::update_color(lcolor.getFromLyXName(lyx_name));
1612 if (graphicsbg_changed) {
1613 #ifdef WITH_WARNINGS
1614 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1617 lyx::graphics::GCache & gc =
1618 lyx::graphics::GCache::get();
1619 gc.changeDisplay(true);
1628 owner->message(argument);
1631 case LFUN_FORKS_KILL:
1633 if (!isStrInt(argument))
1636 pid_t const pid = strToInt(argument);
1637 ForkedcallsController & fcc = ForkedcallsController::get();
1642 case LFUN_TOOLTIPS_TOGGLE:
1643 owner->getDialogs().toggleTooltips();
1646 case LFUN_EXTERNAL_EDIT: {
1647 InsetExternal().localDispatch(FuncRequest(view(), action, argument));
1652 // Then if it was none of the above
1653 // Trying the BufferView::pimpl dispatch:
1654 if (!view()->dispatch(func))
1655 lyxerr << "A truly unknown func ["
1656 << lyxaction.getActionName(func.action) << "]!"
1663 view()->owner()->updateLayoutChoice();
1665 if (view()->available()) {
1666 if (view()->fitCursor()) {
1667 //lyxerr << "LyXFunc->fitCursor->update" << endl;
1671 // If we executed a mutating lfun, mark the buffer as dirty
1672 if (!getStatus(func).disabled()
1673 && !lyxaction.funcHasFlag(func.action, LyXAction::NoBuffer)
1674 && !lyxaction.funcHasFlag(func.action, LyXAction::ReadOnly))
1675 view()->buffer()->markDirty();
1678 sendDispatchMessage(getMessage(), func, verbose);
1682 void LyXFunc::sendDispatchMessage(string const & msg,
1683 FuncRequest const & func, bool verbose)
1685 owner->updateMenubar();
1686 owner->updateToolbar();
1688 if (func.action == LFUN_SELFINSERT || !verbose) {
1689 lyxerr[Debug::ACTION] << "dispatch msg is " << msg << endl;
1691 owner->message(msg);
1695 string dispatch_msg = msg;
1696 if (!dispatch_msg.empty())
1697 dispatch_msg += ' ';
1699 string comname = lyxaction.getActionName(func.action);
1701 bool argsadded = false;
1703 if (!func.argument.empty()) {
1704 if (func.action != LFUN_UNKNOWN_ACTION) {
1705 comname += ' ' + func.argument;
1710 string const shortcuts = toplevel_keymap->findbinding(func);
1712 if (!shortcuts.empty()) {
1713 comname += ": " + shortcuts;
1714 } else if (!argsadded && !func.argument.empty()) {
1715 comname += ' ' + func.argument;
1718 if (!comname.empty()) {
1719 comname = rtrim(comname);
1720 dispatch_msg += '(' + comname + ')';
1723 lyxerr[Debug::ACTION] << "verbose dispatch msg " << dispatch_msg << endl;
1724 if (!dispatch_msg.empty())
1725 owner->message(dispatch_msg);
1729 void LyXFunc::setupLocalKeymap()
1731 keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
1732 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap.get();
1736 void LyXFunc::menuNew(string const & name, bool fromTemplate)
1738 string initpath = lyxrc.document_path;
1739 string filename(name);
1741 if (view()->available()) {
1742 string const trypath = owner->buffer()->filePath();
1743 // If directory is writeable, use this as default.
1744 if (IsDirWriteable(trypath))
1748 static int newfile_number;
1750 if (filename.empty()) {
1751 filename = AddName(lyxrc.document_path,
1752 "newfile" + tostr(++newfile_number) + ".lyx");
1753 FileInfo fi(filename);
1754 while (bufferlist.exists(filename) || fi.readable()) {
1756 filename = AddName(lyxrc.document_path,
1757 "newfile" + tostr(newfile_number) +
1759 fi.newFile(filename);
1763 // The template stuff
1766 FileDialog fileDlg(_("Select template file"),
1767 LFUN_SELECT_FILE_SYNC,
1768 make_pair(string(_("Documents|#o#O")),
1769 string(lyxrc.document_path)),
1770 make_pair(string(_("Templates|#T#t")),
1771 string(lyxrc.template_path)));
1773 FileDialog::Result result =
1774 fileDlg.open(lyxrc.template_path,
1775 _("*.lyx| LyX Documents (*.lyx)"));
1777 if (result.first == FileDialog::Later)
1780 string const fname = result.second;
1787 view()->newFile(filename, templname, !name.empty());
1791 void LyXFunc::open(string const & fname)
1793 string initpath = lyxrc.document_path;
1795 if (view()->available()) {
1796 string const trypath = owner->buffer()->filePath();
1797 // If directory is writeable, use this as default.
1798 if (IsDirWriteable(trypath))
1804 if (fname.empty()) {
1805 FileDialog fileDlg(_("Select document to open"),
1807 make_pair(string(_("Documents|#o#O")),
1808 string(lyxrc.document_path)),
1809 make_pair(string(_("Examples|#E#e")),
1810 string(AddPath(system_lyxdir(), "examples"))));
1812 FileDialog::Result result =
1813 fileDlg.open(initpath,
1814 _("*.lyx| LyX Documents (*.lyx)"));
1816 if (result.first == FileDialog::Later)
1819 filename = result.second;
1821 // check selected filename
1822 if (filename.empty()) {
1823 owner->message(_("Canceled."));
1829 // get absolute path of file and add ".lyx" to the filename if
1831 string const fullpath = FileSearch(string(), filename, "lyx");
1832 if (!fullpath.empty()) {
1833 filename = fullpath;
1836 string const disp_fn(MakeDisplayPath(filename));
1838 // if the file doesn't exist, let the user create one
1839 FileInfo const f(filename, true);
1841 // the user specifically chose this name. Believe them.
1842 view()->newFile(filename, "", true);
1846 owner->message(bformat(_("Opening document %1$s..."), disp_fn));
1849 if (view()->loadLyXFile(filename)) {
1850 str2 = bformat(_("Document %1$s opened."), disp_fn);
1852 str2 = bformat(_("Could not open document %1$s"), disp_fn);
1854 owner->message(str2);
1858 void LyXFunc::doImport(string const & argument)
1861 string filename = split(argument, format, ' ');
1863 lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format
1864 << " file: " << filename << endl;
1866 // need user interaction
1867 if (filename.empty()) {
1868 string initpath = lyxrc.document_path;
1870 if (view()->available()) {
1871 string const trypath = owner->buffer()->filePath();
1872 // If directory is writeable, use this as default.
1873 if (IsDirWriteable(trypath))
1877 string const text = bformat(_("Select %1$s file to import"),
1878 formats.prettyName(format));
1880 FileDialog fileDlg(text,
1882 make_pair(string(_("Documents|#o#O")),
1883 string(lyxrc.document_path)),
1884 make_pair(string(_("Examples|#E#e")),
1885 string(AddPath(system_lyxdir(), "examples"))));
1887 string const extension = "*." + formats.extension(format)
1888 + "| " + formats.prettyName(format)
1889 + " (*." + formats.extension(format) + ')';
1891 FileDialog::Result result = fileDlg.open(initpath,
1894 if (result.first == FileDialog::Later)
1897 filename = result.second;
1899 // check selected filename
1900 if (filename.empty())
1901 owner->message(_("Canceled."));
1904 if (filename.empty())
1907 // get absolute path of file
1908 filename = MakeAbsPath(filename);
1910 string const lyxfile = ChangeExtension(filename, ".lyx");
1912 // Check if the document already is open
1913 if (lyx_gui::use_gui && bufferlist.exists(lyxfile)) {
1914 if (!bufferlist.close(bufferlist.getBuffer(lyxfile), true)) {
1915 owner->message(_("Canceled."));
1920 // if the file exists already, and we didn't do
1921 // -i lyx thefile.lyx, warn
1922 if (FileInfo(lyxfile, true).exist() && filename != lyxfile) {
1923 string const file = MakeDisplayPath(lyxfile, 30);
1925 string text = bformat(_("The document %1$s already exists.\n\n"
1926 "Do you want to over-write that document?"), file);
1927 int const ret = Alert::prompt(_("Over-write document?"),
1928 text, 0, 1, _("&Over-write"), _("&Cancel"));
1931 owner->message(_("Canceled."));
1936 Importer::Import(owner, filename, format);
1940 void LyXFunc::closeBuffer()
1942 if (bufferlist.close(owner->buffer(), true) && !quitting) {
1943 if (bufferlist.empty()) {
1944 // need this otherwise SEGV may occur while
1945 // trying to set variables that don't exist
1946 // since there's no current buffer
1947 owner->getDialogs().hideBufferDependent();
1949 view()->buffer(bufferlist.first());
1955 // Each "owner" should have it's own message method. lyxview and
1956 // the minibuffer would use the minibuffer, but lyxserver would
1957 // send an ERROR signal to its client. Alejandro 970603
1958 // This func is bit problematic when it comes to NLS, to make the
1959 // lyx servers client be language indepenent we must not translate
1960 // strings sent to this func.
1961 void LyXFunc::setErrorMessage(string const & m) const
1963 dispatch_buffer = m;
1968 void LyXFunc::setMessage(string const & m) const
1970 dispatch_buffer = m;
1974 void LyXFunc::setStatusMessage(string const & m) const
1980 string const LyXFunc::view_status_message()
1982 // When meta-fake key is pressed, show the key sequence so far + "M-".
1984 return keyseq.print() + "M-";
1987 // Else, when a non-complete key sequence is pressed,
1988 // show the available options.
1989 if (keyseq.length() > 0 && !keyseq.deleted()) {
1990 return keyseq.printOptions();
1993 if (!view()->available())
1994 return _("Welcome to LyX!");
1996 return currentState(view());
2000 BufferView * LyXFunc::view() const
2002 BOOST_ASSERT(owner);
2003 return owner->view().get();
2007 bool LyXFunc::wasMetaKey() const
2009 return (meta_fake_bit != key_modifier::none);