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 * ====================================================== */
14 #pragma implementation
21 #include "bufferlist.h"
22 #include "BufferView.h"
23 #include "ColorHandler.h"
24 #include "lyxserver.h"
28 #include "LyXAction.h"
34 #include "trans_mgr.h"
36 #include "bufferview_funcs.h"
37 #include "minibuffer.h"
40 #include "FloatList.h"
41 #include "converter.h"
44 #include "FontLoader.h"
45 #include "TextCache.h"
47 #include "undo_funcs.h"
48 #include "ParagraphParameters.h"
50 #include "insets/inseturl.h"
51 #include "insets/insetlatexaccent.h"
52 #include "insets/insettoc.h"
53 #include "insets/insetref.h"
54 #include "insets/insetparent.h"
55 #include "insets/insetindex.h"
56 #include "insets/insetinclude.h"
57 #include "insets/insetbib.h"
58 #include "insets/insetcite.h"
59 #include "insets/insettext.h"
60 #include "insets/insetert.h"
61 #include "insets/insetexternal.h"
62 #include "insets/insetgraphics.h"
63 #include "insets/insetfoot.h"
64 #include "insets/insetmarginal.h"
65 #include "insets/insetminipage.h"
66 #include "insets/insetfloat.h"
68 #include "insets/insetlist.h"
69 #include "insets/insettheorem.h"
71 #include "insets/insettabular.h"
72 #include "insets/insetcaption.h"
74 #include "mathed/formulamacro.h"
75 #include "mathed/math_cursor.h"
76 #include "mathed/math_inset.h"
78 #include "frontends/FileDialog.h"
79 #include "frontends/Dialogs.h"
80 #include "frontends/Toolbar.h"
81 #include "frontends/Menubar.h"
82 #include "frontends/Alert.h"
84 #include "graphics/GraphicsCache.h"
86 #include "support/lyxalgo.h"
87 #include "support/LAssert.h"
88 #include "support/filetools.h"
89 #include "support/FileInfo.h"
90 #include "support/forkedcontr.h"
91 #include "support/lstrings.h"
92 #include "support/path.h"
93 #include "support/lyxfunctional.h"
105 using std::make_pair;
109 using std::transform;
110 using std::back_inserter;
112 extern BufferList bufferlist;
113 extern LyXServer * lyxserver;
114 extern bool selection_possible;
116 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
118 extern void show_symbols_form(LyXFunc *);
120 extern LyXAction lyxaction;
122 extern tex_accent_struct get_accent(kb_action action);
124 extern void ShowLatexLog();
130 class MiniBufferController : public SigC::Object {
133 MiniBufferController() {
137 &MiniBufferController::receiveCommand));
141 &MiniBufferController::receiveArg));
144 void receiveCmd(string const & cmd) {}
146 void receiveArg(string const & arg) {}
154 MiniBufferController mb_ctrl;
160 /* === globals =========================================================== */
163 LyXFunc::LyXFunc(LyXView * o)
165 keyseq(toplevel_keymap.get(), toplevel_keymap.get()),
166 cancel_meta_seq(toplevel_keymap.get(), toplevel_keymap.get())
169 lyx_dead_action = LFUN_NOACTION;
170 lyx_calling_dead_action = LFUN_NOACTION;
175 LyXText * LyXFunc::TEXT(bool flag = true) const
178 return owner->view()->text;
179 return owner->view()->getLyXText();
183 // I changed this func slightly. I commented out the ...FinishUndo(),
184 // this means that all places that used to have a moveCursorUpdate, now
185 // have a ...FinishUndo() as the preceeding statement. I have also added
186 // a moveCursorUpdate to some of the functions that updated the cursor, but
187 // that did not show its new position.
189 void LyXFunc::moveCursorUpdate(bool flag, bool selecting)
191 if (selecting || TEXT(flag)->selection.mark()) {
192 TEXT(flag)->setSelection(owner->view());
193 if (TEXT(flag)->bv_owner)
194 owner->view()->toggleToggle();
196 owner->view()->update(TEXT(flag), BufferView::SELECT|BufferView::FITCUR);
197 owner->view()->showCursor();
199 /* ---> Everytime the cursor is moved, show the current font state. */
200 // should this too me moved out of this func?
201 owner->view()->setState();
205 void LyXFunc::handleKeyFunc(kb_action action)
207 char c = keyseq.getiso();
209 if (keyseq.length() > 1) {
213 owner->getIntl()->getTrans()
214 .deadkey(c, get_accent(action).accent, TEXT(false));
215 // Need to clear, in case the minibuffer calls these
218 // copied verbatim from do_accent_char
219 owner->view()->update(TEXT(false),
220 BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
221 TEXT(false)->selection.cursor = TEXT(false)->cursor;
225 void LyXFunc::processKeySym(KeySym keysym, unsigned int state)
229 if (lyxerr.debugging(Debug::KEY)) {
230 char const * tmp = XKeysymToString(keysym);
231 string const stm = (tmp ? tmp : "");
232 lyxerr << "KeySym is "
235 << keysym << "] State is ["
239 // Do nothing if we have nothing (JMarc)
240 if (keysym == NoSymbol) {
241 lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
246 // Can we be sure that this will work for all X Window
247 // implementations? (Lgb)
248 // This code snippet makes lyx ignore some keys. Perhaps
249 // all of them should be explictly mentioned?
250 if ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
251 || keysym == XK_Mode_switch || keysym == 0x0) {
255 // Do a one-deep top-level lookup for
256 // cancel and meta-fake keys. RVDK_PATCH_5
257 cancel_meta_seq.reset();
259 int action = cancel_meta_seq.addkey(keysym, state
260 &(ShiftMask|ControlMask
262 if (lyxerr.debugging(Debug::KEY)) {
263 lyxerr << "action first set to [" << action << "]" << endl;
266 // When not cancel or meta-fake, do the normal lookup.
267 // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
268 // Mostly, meta_fake_bit = 0. RVDK_PATCH_5.
269 if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
270 if (lyxerr.debugging(Debug::KEY)) {
271 lyxerr << "meta_fake_bit is ["
272 << meta_fake_bit << "]" << endl;
274 // remove Caps Lock and Mod2 as a modifiers
275 action = keyseq.addkey(keysym,
276 (state | meta_fake_bit)
277 &(ShiftMask|ControlMask
279 if (lyxerr.debugging(Debug::KEY)) {
280 lyxerr << "action now set to ["
281 << action << "]" << endl;
284 // Dont remove this unless you know what you are doing.
287 // can this happen now ?
288 if (action == LFUN_NOACTION) {
289 action = LFUN_PREFIX;
292 if (lyxerr.debugging(Debug::KEY)) {
293 lyxerr << "Key [action="
295 << keyseq.print() << "]"
299 // already here we know if it any point in going further
300 // why not return already here if action == -1 and
301 // num_bytes == 0? (Lgb)
303 if (keyseq.length() > 1) {
304 owner->message(keyseq.print());
307 if (action == LFUN_UNKNOWN_ACTION) {
308 // It is unknown, but what if we remove all
309 // the modifiers? (Lgb)
310 action = keyseq.addkey(keysym, 0);
312 if (lyxerr.debugging(Debug::KEY)) {
313 lyxerr << "Removing modifiers...\n"
314 << "Action now set to ["
315 << action << "]" << endl;
317 if (action == LFUN_UNKNOWN_ACTION) {
318 owner->message(_("Unknown function."));
323 if (action == LFUN_SELFINSERT) {
324 // This is very X dependent.
325 unsigned int c = keysym;
328 c = kb_keymap::getiso(c);
331 argument = static_cast<char>(c);
333 dispatch(LFUN_SELFINSERT, argument);
334 lyxerr[Debug::KEY] << "SelfInsert arg[`"
335 << argument << "']" << endl;
338 verboseDispatch(action, false);
342 FuncStatus LyXFunc::getStatus(int ac) const
346 action = lyxaction.retrieveActionArg(ac, argument);
347 return getStatus(action, argument);
351 FuncStatus LyXFunc::getStatus(kb_action action,
352 string const & argument) const
355 Buffer * buf = owner->buffer();
357 if (action == LFUN_UNKNOWN_ACTION) {
358 setStatusMessage(N_("Unknown action"));
359 return flag.unknown(true);
362 // the default error message if we disable the command
363 setStatusMessage(N_("Command disabled"));
365 // Check whether we need a buffer
366 if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) {
367 // Yes we need a buffer, do we have one?
370 // Can we use a readonly buffer?
371 if (buf->isReadonly() &&
372 !lyxaction.funcHasFlag(action,
373 LyXAction::ReadOnly)) {
375 setStatusMessage(N_("Document is read-only"));
380 setStatusMessage(N_("Command not allowed with"
381 "out any document open"));
382 return flag.disabled(true);
386 UpdatableInset * tli = owner->view()->theLockingInset();
388 // I would really like to avoid having this switch and rather try to
389 // encode this in the function itself.
390 bool disable = false;
393 disable = !Exporter::IsExportable(buf, "dvi")
394 || lyxrc.print_command == "none";
397 disable = argument == "fax" &&
398 !Exporter::IsExportable(buf, argument);
401 disable = buf->undostack.empty();
404 disable = buf->redostack.empty();
406 case LFUN_SPELLCHECK:
407 disable = lyxrc.isp_command == "none";
409 #ifndef HAVE_LIBAIKSAURUS
410 case LFUN_THESAURUS_ENTRY:
415 disable = lyxrc.chktex_command == "none";
418 disable = !Exporter::IsExportable(buf, "program");
421 case LFUN_LAYOUT_TABULAR:
423 || (tli->lyxCode() != Inset::TABULAR_CODE
424 && !tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
428 case LFUN_LAYOUT_PARAGRAPH: {
429 Inset * inset = TEXT(false)->cursor.par()->inInset();
430 disable = inset && inset->forceDefaultParagraphs(inset);
434 case LFUN_TABULAR_FEATURE:
438 //ret.disabled(true);
439 if (tli->lyxCode() == Inset::TABULAR_CODE) {
440 ret = static_cast<InsetTabular *>(tli)
441 ->getStatus(argument);
442 } else if (tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
443 ret = static_cast<InsetTabular *>
444 (tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE))
445 ->getStatus(argument);
450 static InsetTabular inset(*owner->buffer(), 1, 1);
454 ret = inset.getStatus(argument);
455 if (ret.onoff(true) || ret.onoff(false))
456 flag.setOnOff(false);
460 case LFUN_VC_REGISTER:
461 disable = buf->lyxvc.inUse();
463 case LFUN_VC_CHECKIN:
464 disable = !buf->lyxvc.inUse() || buf->isReadonly();
466 case LFUN_VC_CHECKOUT:
467 disable = !buf->lyxvc.inUse() || !buf->isReadonly();
471 case LFUN_VC_HISTORY:
472 disable = !buf->lyxvc.inUse();
474 case LFUN_BOOKMARK_GOTO:
475 disable = !owner->view()->
476 isSavedPosition(strToUnsignedInt(argument));
480 case LFUN_INSET_TOGGLE: {
481 LyXText * lt = owner->view()->getLyXText();
482 disable = !(isEditableInset(lt->getInset())
484 && lt->inset_owner->owner()
485 && lt->inset_owner->owner()->isOpen()));
488 case LFUN_MATH_VALIGN:
490 char align = mathcursor->valign();
495 if (argument.empty()) {
499 if (!contains("tcb", argument[0])) {
503 flag.setOnOff(argument[0] == align);
508 case LFUN_MATH_HALIGN:
510 char align = mathcursor->halign();
515 if (argument.empty()) {
519 if (!contains("lcr", argument[0])) {
523 flag.setOnOff(argument[0] == align);
528 case LFUN_MATH_MUTATE:
529 if (tli && (tli->lyxCode() == Inset::MATH_CODE)) {
530 MathInsetTypes type = mathcursor->formula()->getType();
531 if (argument == "inline") {
532 flag.setOnOff(type == LM_OT_SIMPLE);
533 } else if (argument == "display") {
534 flag.setOnOff(type == LM_OT_EQUATION);
535 } else if (argument == "eqnarray") {
536 flag.setOnOff(type == LM_OT_EQNARRAY);
537 } else if (argument == "align") {
538 flag.setOnOff(type == LM_OT_ALIGN);
546 // we just need to be in math mode to enable that
548 case LFUN_MATH_SPACE:
549 case LFUN_MATH_LIMITS:
550 case LFUN_MATH_NONUMBER:
551 case LFUN_MATH_NUMBER:
552 disable = !mathcursor;
555 // we need to be math mode and a math array for that
556 // Hack: halign produces non-zero result iff we are in a math array
557 case LFUN_MATH_ROW_INSERT:
558 case LFUN_MATH_ROW_DELETE:
559 case LFUN_MATH_COLUMN_INSERT:
560 case LFUN_MATH_COLUMN_DELETE:
561 disable = !mathcursor || !mathcursor->halign();
568 // the functions which insert insets
569 Inset::Code code = Inset::NO_CODE;
572 code = Inset::ERT_CODE;
574 case LFUN_INSET_GRAPHICS:
575 code = Inset::GRAPHICS_CODE;
577 case LFUN_INSET_FOOTNOTE:
578 code = Inset::FOOT_CODE;
580 case LFUN_DIALOG_TABULAR_INSERT:
581 case LFUN_INSET_TABULAR:
582 code = Inset::TABULAR_CODE;
584 case LFUN_INSET_EXTERNAL:
585 code = Inset::EXTERNAL_CODE;
587 case LFUN_INSET_MARGINAL:
588 code = Inset::MARGIN_CODE;
590 case LFUN_INSET_MINIPAGE:
591 code = Inset::MINIPAGE_CODE;
593 case LFUN_INSET_FLOAT:
594 case LFUN_INSET_WIDE_FLOAT:
595 code = Inset::FLOAT_CODE;
597 case LFUN_FLOAT_LIST:
598 code = Inset::FLOAT_LIST_CODE;
601 case LFUN_INSET_LIST:
602 code = Inset::LIST_CODE;
604 case LFUN_INSET_THEOREM:
605 code = Inset::THEOREM_CODE;
608 case LFUN_INSET_CAPTION:
609 code = Inset::CAPTION_CODE;
611 case LFUN_INSERT_NOTE:
612 code = Inset::IGNORE_CODE;
614 case LFUN_INSERT_LABEL:
615 code = Inset::LABEL_CODE;
617 case LFUN_REF_INSERT:
618 code = Inset::REF_CODE;
620 case LFUN_CITATION_CREATE:
621 case LFUN_CITATION_INSERT:
622 code = Inset::CITE_CODE;
624 case LFUN_INSERT_BIBTEX:
625 code = Inset::BIBTEX_CODE;
627 case LFUN_INDEX_INSERT:
628 case LFUN_INDEX_INSERT_LAST:
629 case LFUN_INDEX_CREATE:
630 code = Inset::INDEX_CODE;
632 case LFUN_INDEX_PRINT:
633 code = Inset::INDEX_PRINT_CODE;
635 case LFUN_CHILD_INSERT:
636 code = Inset::INCLUDE_CODE;
638 case LFUN_TOC_INSERT:
639 code = Inset::TOC_CODE;
641 case LFUN_PARENTINSERT:
642 code = Inset::PARENT_CODE;
646 case LFUN_INSERT_URL:
647 code = Inset::URL_CODE;
650 // always allow this, since we will inset a raw quote
651 // if an inset is not allowed.
653 case LFUN_HYPHENATION:
654 case LFUN_LIGATURE_BREAK:
656 case LFUN_MENU_SEPARATOR:
658 case LFUN_END_OF_SENTENCE:
659 case LFUN_PROTECTEDSPACE:
660 code = Inset::SPECIALCHAR_CODE;
665 if (code != Inset::NO_CODE && tli && !tli->insetAllowed(code)) {
672 // A few general toggles
674 case LFUN_TOOLTIPS_TOGGLE:
675 flag.setOnOff(owner->getDialogs()->tooltipsEnabled());
678 case LFUN_READ_ONLY_TOGGLE:
679 flag.setOnOff(buf->isReadonly());
682 flag.setOnOff(TEXT(false)->cursor.par()->params().startOfAppendix());
684 case LFUN_SWITCHBUFFER:
685 // toggle on the current buffer, but do not toggle off
686 // the other ones (is that a good idea?)
687 if (argument == buf->fileName())
694 // the font related toggles
696 LyXFont const & font = TEXT(false)->real_current_font;
699 flag.setOnOff(font.emph() == LyXFont::ON);
702 flag.setOnOff(font.noun() == LyXFont::ON);
705 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
708 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
711 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
714 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
721 MathTextCodes tc = mathcursor->getLastCode();
724 flag.setOnOff(tc == LM_TC_BF);
727 flag.setOnOff(tc == LM_TC_SF);
730 flag.setOnOff(tc == LM_TC_CAL);
733 flag.setOnOff(tc == LM_TC_RM);
736 flag.setOnOff(tc == LM_TC_TT);
739 flag.setOnOff(tc == LM_TC_BB);
742 flag.setOnOff(tc == LM_TC_VAR);
753 // temporary dispatch method
754 void LyXFunc::miniDispatch(string const & s)
756 string s2(frontStrip(strip(s)));
759 verboseDispatch(s2, true);
764 void LyXFunc::verboseDispatch(string const & s, bool show_sc)
766 int action = lyxaction.LookupFunc(frontStrip(s));
768 if (action == LFUN_UNKNOWN_ACTION) {
769 string const msg = string(_("Unknown function ("))
773 verboseDispatch(action, show_sc);
778 void LyXFunc::verboseDispatch(int ac, bool show_sc)
783 // get the real action and argument
784 action = lyxaction.retrieveActionArg(ac, argument);
786 verboseDispatch(action, argument, show_sc);
791 void LyXFunc::verboseDispatch(kb_action action,
792 string const & argument, bool show_sc)
794 string res = dispatch(action, argument);
796 commandshortcut.erase();
798 if (lyxrc.display_shortcuts && show_sc) {
799 if (action != LFUN_SELFINSERT) {
800 // Put name of command and list of shortcuts
801 // for it in minibuffer
802 string comname = lyxaction.getActionName(action);
804 int pseudoaction = action;
805 bool argsadded = false;
807 if (!argument.empty()) {
808 // the pseudoaction is useful for the bindings
810 lyxaction.searchActionArg(action,
813 if (pseudoaction == LFUN_UNKNOWN_ACTION) {
814 pseudoaction = action;
816 comname += " " + argument;
821 string const shortcuts =
822 toplevel_keymap->findbinding(pseudoaction);
824 if (!shortcuts.empty()) {
825 comname += ": " + shortcuts;
826 } else if (!argsadded && !argument.empty()) {
827 comname += " " + argument;
830 if (!comname.empty()) {
831 comname = strip(comname);
832 commandshortcut = "(" + comname + ')';
838 if (!commandshortcut.empty()) {
839 owner->getMiniBuffer()->addSet(commandshortcut);
842 owner->getMiniBuffer()->addSet(' ' + commandshortcut);
847 string const LyXFunc::dispatch(kb_action action, string argument)
849 lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << action
850 <<"] arg[" << argument << "]" << endl;
852 // we have not done anything wrong yet.
854 dispatch_buffer.erase();
856 #ifdef NEW_DISPATCHER
857 // We try do call the most specific dispatcher first:
858 // 1. the lockinginset's dispatch
859 // 2. the bufferview's dispatch
860 // 3. the lyxview's dispatch
863 selection_possible = false;
865 if (owner->view()->available())
866 owner->view()->hideCursor();
868 // We cannot use this function here
869 if (getStatus(action, argument).disabled()) {
870 lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: "
871 << lyxaction.getActionName(action)
872 << " [" << action << "] is disabled at this location"
874 setErrorMessage(getStatusMessage());
875 goto exit_with_message;
878 if (owner->view()->available() && owner->view()->theLockingInset()) {
879 UpdatableInset::RESULT result;
880 if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
881 (!keyseq.deleted())))
883 if ((action == LFUN_UNKNOWN_ACTION)
884 && argument.empty()) {
885 argument = keyseq.getiso();
887 // Undo/Redo is a bit tricky for insets.
888 if (action == LFUN_UNDO) {
889 owner->view()->menuUndo();
890 goto exit_with_message;
891 } else if (action == LFUN_REDO) {
892 owner->view()->menuRedo();
893 goto exit_with_message;
894 } else if (((result=owner->view()->theLockingInset()->
895 // Hand-over to inset's own dispatch:
896 localDispatch(owner->view(), action, argument)) ==
897 UpdatableInset::DISPATCHED) ||
898 (result == UpdatableInset::DISPATCHED_NOUPDATE))
899 goto exit_with_message;
900 // If UNDISPATCHED, just soldier on
901 else if (result == UpdatableInset::FINISHED) {
902 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
903 TEXT()->cursorRight(owner->view());
904 moveCursorUpdate(true, false);
907 goto exit_with_message;
908 } else if (result == UpdatableInset::FINISHED_RIGHT) {
909 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
910 TEXT()->cursorRight(owner->view());
911 moveCursorUpdate(true, false);
914 goto exit_with_message;
915 } else if (result == UpdatableInset::FINISHED_UP) {
916 if (TEXT()->cursor.row()->previous()) {
917 TEXT()->cursorUp(owner->view());
918 moveCursorUpdate(true, false);
921 goto exit_with_message;
922 } else if (result == UpdatableInset::FINISHED_DOWN) {
923 if (TEXT()->cursor.row()->next())
924 TEXT()->cursorDown(owner->view());
926 TEXT()->cursorRight(owner->view());
927 moveCursorUpdate(true, false);
929 goto exit_with_message;
931 //setMessage(N_("Text mode"));
933 case LFUN_UNKNOWN_ACTION:
934 case LFUN_BREAKPARAGRAPH:
936 TEXT()->cursorRight(owner->view());
937 owner->view()->setState();
941 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
942 TEXT()->cursorRight(owner->view());
943 moveCursorUpdate(true, false);
946 goto exit_with_message;
948 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
949 TEXT()->cursorRight(owner->view());
950 moveCursorUpdate(true, false);
953 goto exit_with_message;
955 if (TEXT()->cursor.row()->next())
956 TEXT()->cursorDown(owner->view());
958 TEXT()->cursorRight(owner->view());
959 moveCursorUpdate(true, false);
961 goto exit_with_message;
973 if (!owner->view()->available()) break;
974 // this function should be used always [asierra060396]
975 UpdatableInset * tli =
976 owner->view()->theLockingInset();
978 UpdatableInset * lock = tli->getLockingInset();
981 owner->view()->unlockInset(tli);
982 TEXT()->cursorRight(owner->view());
983 moveCursorUpdate(true, false);
986 tli->unlockInsetInInset(owner->view(),
995 // --- Misc -------------------------------------------
996 case LFUN_WORDFINDFORWARD :
997 case LFUN_WORDFINDBACKWARD : {
998 static string last_search;
999 string searched_string;
1001 if (!argument.empty()) {
1002 last_search = argument;
1003 searched_string = argument;
1005 searched_string = last_search;
1007 bool fw = (action == LFUN_WORDFINDBACKWARD);
1008 if (!searched_string.empty()) {
1009 LyXFind(owner->view(), searched_string, fw);
1011 // owner->view()->showCursor();
1017 if (owner->view()->available() && !owner->view()->theLockingInset()) {
1018 owner->view()->update(TEXT(),
1019 BufferView::SELECT|BufferView::FITCUR);
1021 owner->message(keyseq.printOptions());
1025 // --- Misc -------------------------------------------
1026 case LFUN_EXEC_COMMAND:
1028 vector<string> allCmds;
1029 transform(lyxaction.func_begin(), lyxaction.func_end(),
1030 back_inserter(allCmds), lyx::firster());
1031 static vector<string> hist;
1032 owner->getMiniBuffer()->getString(MiniBuffer::spaces,
1037 case LFUN_CANCEL: // RVDK_PATCH_5
1040 if (owner->view()->available())
1041 // cancel any selection
1042 dispatch(LFUN_MARK_OFF);
1043 setMessage(N_("Cancel"));
1046 case LFUN_META_FAKE: // RVDK_PATCH_5
1048 meta_fake_bit = Mod1Mask;
1049 setMessage(keyseq.print());
1053 case LFUN_READ_ONLY_TOGGLE:
1054 if (owner->buffer()->lyxvc.inUse()) {
1055 owner->buffer()->lyxvc.toggleReadOnly();
1057 owner->buffer()->setReadonly(
1058 !owner->buffer()->isReadonly());
1062 case LFUN_CENTER: // this is center and redraw.
1063 owner->view()->center();
1066 // --- Menus -----------------------------------------------
1071 case LFUN_MENUNEWTMPLT:
1075 case LFUN_CLOSEBUFFER:
1079 case LFUN_MENUWRITE:
1080 if (!owner->buffer()->isUnnamed()) {
1082 s1 << _("Saving document") << ' '
1083 << MakeDisplayPath(owner->buffer()->fileName() + "...");
1084 owner->message(s1.str().c_str());
1085 MenuWrite(owner->view(), owner->buffer());
1087 WriteAs(owner->view(), owner->buffer());
1091 WriteAs(owner->view(), owner->buffer(), argument);
1094 case LFUN_MENURELOAD:
1099 Exporter::Export(owner->buffer(), argument, true);
1103 Exporter::Preview(owner->buffer(), argument);
1106 case LFUN_BUILDPROG:
1107 Exporter::Export(owner->buffer(), "program", true);
1110 case LFUN_RUNCHKTEX:
1111 MenuRunChktex(owner->buffer());
1114 case LFUN_MENUPRINT:
1115 owner->getDialogs()->showPrint();
1119 if (argument == "custom")
1120 owner->getDialogs()->showSendto();
1122 Exporter::Export(owner->buffer(), argument, false);
1140 InsetCommandParams p;
1143 if (action == LFUN_TOCVIEW)
1145 p.setCmdName("tableofcontents");
1147 else if (action == LFUN_LOAVIEW)
1148 p.setCmdName("listof{algorithm}{List of Algorithms}");
1149 else if (action == LFUN_LOFVIEW)
1150 p.setCmdName("listoffigures");
1152 p.setCmdName("listoftables");
1154 owner->getDialogs()->createTOC(p.getAsString());
1158 case LFUN_DIALOG_TABULAR_INSERT:
1159 owner->getDialogs()->showTabularCreate();
1163 AutoSave(owner->view());
1167 owner->view()->menuUndo();
1171 owner->view()->menuRedo();
1174 case LFUN_MENUSEARCH:
1175 owner->getDialogs()->showSearch();
1178 case LFUN_REMOVEERRORS:
1179 if (owner->view()->removeAutoInsets()) {
1180 owner->view()->redraw();
1181 owner->view()->fitCursor();
1185 case LFUN_DEPTH_MIN:
1186 changeDepth(owner->view(), TEXT(false), -1);
1189 case LFUN_DEPTH_PLUS:
1190 changeDepth(owner->view(), TEXT(false), 1);
1194 owner->getDialogs()->setUserFreeFont();
1197 case LFUN_RECONFIGURE:
1198 Reconfigure(owner->view());
1202 case LFUN_FLOATSOPERATE:
1203 if (argument == "openfoot")
1204 owner->view()->allFloats(1,0);
1205 else if (argument == "closefoot")
1206 owner->view()->allFloats(0,0);
1207 else if (argument == "openfig")
1208 owner->view()->allFloats(1,1);
1209 else if (argument == "closefig")
1210 owner->view()->allFloats(0,1);
1213 #ifdef WITH_WARNINGS
1214 //#warning Find another implementation here (or another lyxfunc)!
1217 case LFUN_HELP_ABOUTLYX:
1218 owner->getDialogs()->showAboutlyx();
1221 case LFUN_HELP_TEXINFO:
1222 owner->getDialogs()->showTexinfo();
1225 case LFUN_HELP_OPEN:
1227 string const arg = argument;
1229 setErrorMessage(N_("Missing argument"));
1232 owner->prohibitInput();
1233 string const fname = i18nLibFileSearch("doc", arg, "lyx");
1234 if (fname.empty()) {
1235 lyxerr << "LyX: unable to find documentation file `"
1236 << arg << "'. Bad installation?" << endl;
1237 owner->allowInput();
1241 str << _("Opening help file") << ' '
1242 << MakeDisplayPath(fname) << "...";
1243 owner->message(str.str().c_str());
1244 owner->view()->buffer(bufferlist.loadLyXFile(fname, false));
1245 owner->allowInput();
1249 // --- version control -------------------------------
1250 case LFUN_VC_REGISTER:
1252 if (!owner->buffer()->lyxvc.inUse())
1253 owner->buffer()->lyxvc.registrer();
1257 case LFUN_VC_CHECKIN:
1259 if (owner->buffer()->lyxvc.inUse()
1260 && !owner->buffer()->isReadonly())
1261 owner->buffer()->lyxvc.checkIn();
1265 case LFUN_VC_CHECKOUT:
1267 if (owner->buffer()->lyxvc.inUse()
1268 && owner->buffer()->isReadonly())
1269 owner->buffer()->lyxvc.checkOut();
1273 case LFUN_VC_REVERT:
1275 owner->buffer()->lyxvc.revert();
1281 owner->buffer()->lyxvc.undoLast();
1285 case LFUN_VC_HISTORY:
1287 owner->getDialogs()->showVCLogFile();
1291 // --- buffers ----------------------------------------
1293 case LFUN_SWITCHBUFFER:
1294 owner->view()->buffer(bufferlist.getBuffer(argument));
1299 // servercmd: argument must be <file>:<template>
1300 Buffer * tmpbuf = NewLyxFile(argument);
1302 owner->view()->buffer(tmpbuf);
1306 case LFUN_FILE_OPEN:
1310 case LFUN_LATEX_LOG:
1311 owner->getDialogs()->showLogFile();
1314 case LFUN_LAYOUT_DOCUMENT:
1315 owner->getDialogs()->showDocument();
1318 case LFUN_LAYOUT_PARAGRAPH:
1319 owner->getDialogs()->showParagraph();
1322 case LFUN_LAYOUT_CHARACTER:
1323 owner->getDialogs()->showCharacter();
1326 case LFUN_LAYOUT_TABULAR:
1327 if (owner->view()->theLockingInset()) {
1328 if (owner->view()->theLockingInset()->lyxCode()==Inset::TABULAR_CODE) {
1329 InsetTabular * inset = static_cast<InsetTabular *>
1330 (owner->view()->theLockingInset());
1331 inset->openLayoutDialog(owner->view());
1332 } else if (owner->view()->theLockingInset()->
1333 getFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
1334 InsetTabular * inset = static_cast<InsetTabular *>(
1335 owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
1336 inset->openLayoutDialog(owner->view());
1341 case LFUN_LAYOUT_PREAMBLE:
1342 owner->getDialogs()->showPreamble();
1345 case LFUN_DROP_LAYOUTS_CHOICE:
1346 owner->getToolbar()->openLayoutList();
1349 case LFUN_MENU_OPEN_BY_NAME:
1350 owner->getMenubar()->openByName(argument);
1351 break; // RVDK_PATCH_5
1353 case LFUN_SPELLCHECK:
1354 if (lyxrc.isp_command != "none")
1355 owner->getDialogs()->showSpellchecker();
1358 // --- lyxserver commands ----------------------------
1362 setMessage(owner->buffer()->fileName());
1363 lyxerr[Debug::INFO] << "FNAME["
1364 << owner->buffer()->fileName()
1370 dispatch_buffer = keyseq.print();
1371 lyxserver->notifyClient(dispatch_buffer);
1375 case LFUN_GOTOFILEROW:
1379 istringstream istr(argument.c_str());
1380 istr >> file_name >> row;
1381 // Must replace extension of the file to be .lyx and get full path
1382 string const s(ChangeExtension(file_name, ".lyx"));
1384 // Either change buffer or load the file
1385 if (bufferlist.exists(s)) {
1386 owner->view()->buffer(bufferlist.getBuffer(s));
1388 owner->view()->buffer(bufferlist.loadLyXFile(s));
1392 owner->view()->setCursorFromRow(row);
1395 owner->view()->center();
1399 case LFUN_GOTO_PARAGRAPH:
1401 istringstream istr(argument.c_str());
1405 Paragraph * par = owner->buffer()->getParFromID(id);
1407 lyxerr[Debug::INFO] << "No matching paragraph found! ["
1408 << id << "]" << endl;
1411 lyxerr << "Paragraph " << par->id()
1412 << " found." << endl;
1415 if (owner->view()->theLockingInset())
1416 owner->view()->unlockInset(owner->view()->theLockingInset());
1417 if (par->inInset()) {
1418 par->inInset()->edit(owner->view());
1421 owner->view()->getLyXText()->setCursor(owner->view(), par, 0);
1422 owner->view()->setState();
1426 owner->view()->center();
1433 int const qa = lyxaction.LookupFunc(argument);
1434 setMessage(lyxaction.helpText(static_cast<kb_action>(qa)));
1438 // --- toolbar ----------------------------------
1439 case LFUN_PUSH_TOOLBAR:
1441 int nth = strToInt(argument);
1443 setErrorMessage(N_("Push-toolbar needs argument > 0"));
1445 owner->getToolbar()->push(nth);
1450 case LFUN_ADD_TO_TOOLBAR:
1452 if (lyxerr.debugging(Debug::GUI)) {
1453 lyxerr << "LFUN_ADD_TO_TOOLBAR:"
1454 "argument = `" << argument << '\'' << endl;
1456 string tmp(argument);
1457 //lyxerr <<string("Argument: ") + argument);
1458 //lyxerr <<string("Tmp : ") + tmp);
1460 setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
1462 owner->getToolbar()->add(argument, false);
1463 owner->getToolbar()->set();
1468 // --- insert characters ----------------------------------------
1470 // --- Mathed stuff. If we are here, there is no locked inset yet.
1471 case LFUN_MATH_EXTERN:
1472 case LFUN_MATH_NUMBER:
1473 case LFUN_MATH_NONUMBER:
1474 case LFUN_MATH_LIMITS:
1476 setErrorMessage(N_("This is only allowed in math mode!"));
1480 // passthrough hat and underscore outside mathed:
1481 case LFUN_SUBSCRIPT:
1482 dispatch(LFUN_SELFINSERT, "_");
1484 case LFUN_SUPERSCRIPT:
1485 dispatch(LFUN_SELFINSERT, "^");
1488 case LFUN_MATH_PANEL:
1489 owner->getDialogs()->showMathPanel();
1492 case LFUN_CITATION_CREATE:
1494 InsetCommandParams p("cite");
1496 if (!argument.empty()) {
1497 // This should be set at source, ie when typing
1498 // "citation-insert foo" in the minibuffer.
1499 // Question: would pybibliographer also need to be
1500 // changed. Suspect so. Leave as-is therefore.
1501 if (contains(argument, "|")) {
1502 p.setContents(token(argument, '|', 0));
1503 p.setOptions( token(argument, '|', 1));
1505 p.setContents(argument);
1507 dispatch(LFUN_CITATION_INSERT, p.getAsString());
1509 owner->getDialogs()->createCitation(p.getAsString());
1513 case LFUN_CHILDOPEN:
1515 string const filename =
1516 MakeAbsPath(argument,
1517 owner->buffer()->filePath());
1518 setMessage(N_("Opening child document ") +
1519 MakeDisplayPath(filename) + "...");
1520 owner->view()->savePosition(0);
1521 if (bufferlist.exists(filename))
1522 owner->view()->buffer(bufferlist.getBuffer(filename));
1524 owner->view()->buffer(bufferlist.loadLyXFile(filename));
1528 case LFUN_TOGGLECURSORFOLLOW:
1529 lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
1532 case LFUN_KMAP_OFF: // keymap off
1533 owner->getIntl()->KeyMapOn(false);
1536 case LFUN_KMAP_PRIM: // primary keymap
1537 owner->getIntl()->KeyMapPrim();
1540 case LFUN_KMAP_SEC: // secondary keymap
1541 owner->getIntl()->KeyMapSec();
1544 case LFUN_KMAP_TOGGLE: // toggle keymap
1545 owner->getIntl()->ToggleKeyMap();
1550 // argument contains ';'-terminated commands
1551 while (argument.find(';') != string::npos) {
1553 argument = split(argument, first, ';');
1554 verboseDispatch(first, false);
1559 case LFUN_DIALOG_PREFERENCES:
1560 owner->getDialogs()->showPreferences();
1563 case LFUN_SAVEPREFERENCES:
1565 Path p(user_lyxdir);
1566 lyxrc.write("preferences");
1570 case LFUN_SCREEN_FONT_UPDATE:
1572 // handle the screen font changes.
1574 lyxrc.set_font_norm_type();
1575 fontloader.update();
1576 // Of course we should only do the resize and the textcache.clear
1577 // if values really changed...but not very important right now. (Lgb)
1578 // All visible buffers will need resize
1580 // We also need to empty the textcache so that
1581 // the buffer will be formatted correctly after
1587 case LFUN_SET_COLOR:
1590 string const x11_name = split(argument, lyx_name, ' ');
1591 if (lyx_name.empty() || x11_name.empty()) {
1592 setErrorMessage(N_("Syntax: set-color <lyx_name>"
1597 bool const graphicsbg_changed =
1598 (lyx_name == lcolor.getLyXName(LColor::graphicsbg) &&
1599 x11_name != lcolor.getX11Name(LColor::graphicsbg));
1601 if (!lcolor.setColor(lyx_name, x11_name)) {
1602 static string const err1 (N_("Set-color \""));
1603 static string const err2 (
1604 N_("\" failed - color is undefined "
1605 "or may not be redefined"));
1606 setErrorMessage(_(err1) + lyx_name + _(err2));
1610 lyxColorHandler->updateColor(lcolor.getFromLyXName(lyx_name));
1612 if (graphicsbg_changed) {
1613 grfx::GCache & gc = grfx::GCache::get();
1614 gc.changeDisplay(true);
1617 owner->view()->redraw();
1622 owner->message(argument);
1625 case LFUN_MESSAGE_PUSH:
1626 owner->messagePush(argument);
1629 case LFUN_MESSAGE_POP:
1630 owner->messagePop();
1633 case LFUN_FORKS_SHOW:
1634 owner->getDialogs()->showForks();
1637 case LFUN_FORKS_KILL:
1639 if (!isStrInt(argument))
1642 pid_t const pid = strToInt(argument);
1643 ForkedcallsController & fcc = ForkedcallsController::get();
1648 case LFUN_TOOLTIPS_TOGGLE:
1649 owner->getDialogs()->toggleTooltips();
1653 // Then if it was none of the above
1654 // Trying the BufferView::pimpl dispatch:
1655 if (!owner->view()->Dispatch(action, argument))
1656 lyxerr << "A truly unknown func ["
1657 << lyxaction.getActionName(action) << "]!"
1664 string const res = getMessage();
1667 owner->message(_(res));
1668 owner->updateMenubar();
1669 owner->updateToolbar();
1675 void LyXFunc::setupLocalKeymap()
1677 keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
1678 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap.get();
1682 void LyXFunc::menuNew(bool fromTemplate)
1684 string initpath = lyxrc.document_path;
1686 if (owner->view()->available()) {
1687 string const trypath = owner->buffer()->filePath();
1688 // If directory is writeable, use this as default.
1689 if (IsDirWriteable(trypath))
1693 static int newfile_number;
1696 if (lyxrc.new_ask_filename) {
1697 FileDialog fileDlg(owner, _("Enter filename for new document"),
1698 LFUN_SELECT_FILE_SYNC,
1699 make_pair(string(_("Documents|#o#O")),
1700 string(lyxrc.document_path)),
1701 make_pair(string(_("Templates|#T#t")),
1702 string(lyxrc.template_path)));
1704 FileDialog::Result result =
1705 fileDlg.Select(initpath,
1706 _("*.lyx|LyX Documents (*.lyx)"),
1709 if (result.second.empty()) {
1710 owner->message(_("Canceled."));
1711 lyxerr[Debug::INFO] << "New Document Cancelled." << endl;
1715 // get absolute path of file and make sure the filename ends
1717 s = MakeAbsPath(result.second);
1718 if (!IsLyXFilename(s))
1721 // Check if the document already is open
1722 if (bufferlist.exists(s)) {
1723 switch (Alert::askConfirmation(_("Document is already open:"),
1724 MakeDisplayPath(s, 50),
1725 _("Do you want to close that document now?\n"
1726 "('No' will just switch to the open version)")))
1728 case 1: // Yes: close the document
1729 if (!bufferlist.close(bufferlist.getBuffer(s)))
1730 // If close is canceled, we cancel here too.
1733 case 2: // No: switch to the open document
1734 owner->view()->buffer(bufferlist.getBuffer(s));
1736 case 3: // Cancel: Do nothing
1737 owner->message(_("Canceled."));
1741 // Check whether the file already exists
1743 if (fi.readable() &&
1744 Alert::askQuestion(_("File already exists:"),
1745 MakeDisplayPath(s, 50),
1746 _("Do you want to open the document?"))) {
1748 string const disp_fn(MakeDisplayPath(s));
1751 str << _("Opening document") << ' '
1752 << disp_fn << "...";
1754 owner->message(str.str().c_str());
1755 //XFlush(fl_get_display());
1756 owner->view()->buffer(bufferlist.loadLyXFile(s));
1758 str2 << _("Document") << ' '
1759 << disp_fn << ' ' << _("opened.");
1761 owner->message(str2.str().c_str());
1766 s = AddName(lyxrc.document_path,
1767 "newfile" + tostr(++newfile_number) + ".lyx");
1769 while (bufferlist.exists(s) || fi.readable()) {
1771 s = AddName(lyxrc.document_path,
1772 "newfile" + tostr(newfile_number) +
1778 // The template stuff
1781 FileDialog fileDlg(owner, _("Select template file"),
1782 LFUN_SELECT_FILE_SYNC,
1783 make_pair(string(_("Documents|#o#O")),
1784 string(lyxrc.document_path)),
1785 make_pair(string(_("Templates|#T#t")),
1786 string(lyxrc.template_path)));
1788 FileDialog::Result result =
1789 fileDlg.Select(lyxrc.template_path,
1790 _("*.lyx|LyX Documents (*.lyx)"));
1792 if (result.first == FileDialog::Later)
1795 string const fname = result.second;
1802 // find a free buffer
1803 lyxerr[Debug::INFO] << "Find a free buffer." << endl;
1804 owner->view()->buffer(bufferlist.newFile(s, templname));
1808 void LyXFunc::open(string const & fname)
1810 string initpath = lyxrc.document_path;
1812 if (owner->view()->available()) {
1813 string const trypath = owner->buffer()->filePath();
1814 // If directory is writeable, use this as default.
1815 if (IsDirWriteable(trypath))
1821 if (fname.empty()) {
1822 FileDialog fileDlg(owner, _("Select document to open"),
1824 make_pair(string(_("Documents|#o#O")),
1825 string(lyxrc.document_path)),
1826 make_pair(string(_("Examples|#E#e")),
1827 string(AddPath(system_lyxdir, "examples"))));
1829 FileDialog::Result result =
1830 fileDlg.Select(initpath,
1831 "*.lyx|LyX Documents (*.lyx)");
1833 if (result.first == FileDialog::Later)
1836 filename = result.second;
1838 // check selected filename
1839 if (filename.empty()) {
1840 owner->message(_("Canceled."));
1846 // get absolute path of file and add ".lyx" to the filename if
1848 string const fullpath = FileSearch(string(), filename, "lyx");
1849 if (fullpath.empty()) {
1850 Alert::alert(_("Error"), _("Could not find file"), filename);
1854 filename = fullpath;
1857 string const disp_fn(MakeDisplayPath(filename));
1860 str << _("Opening document") << ' ' << disp_fn << "...";
1862 owner->message(str.str().c_str());
1864 Buffer * openbuf = bufferlist.loadLyXFile(filename);
1866 owner->view()->buffer(openbuf);
1868 str << _("Document") << ' ' << disp_fn << ' ' << _("opened.");
1869 owner->message(str.str().c_str());
1872 str << _("Could not open document") << ' ' << disp_fn;
1873 owner->message(str.str().c_str());
1878 // checks for running without gui are missing.
1879 void LyXFunc::doImport(string const & argument)
1882 string filename = split(argument, format, ' ');
1883 lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format
1884 << " file: " << filename << endl;
1886 if (filename.empty()) { // need user interaction
1887 string initpath = lyxrc.document_path;
1889 if (owner->view()->available()) {
1890 string const trypath = owner->buffer()->filePath();
1891 // If directory is writeable, use this as default.
1892 if (IsDirWriteable(trypath))
1896 string const text = _("Select ") + formats.prettyName(format)
1897 + _(" file to import");
1899 FileDialog fileDlg(owner, text,
1901 make_pair(string(_("Documents|#o#O")),
1902 string(lyxrc.document_path)),
1903 make_pair(string(_("Examples|#E#e")),
1904 string(AddPath(system_lyxdir, "examples"))));
1906 string const extension = "*." + formats.extension(format)
1907 + "| " + formats.prettyName(format)
1908 + " (*." + formats.extension(format) + ")";
1910 FileDialog::Result result = fileDlg.Select(initpath,
1913 if (result.first == FileDialog::Later)
1916 filename = result.second;
1918 // check selected filename
1919 if (filename.empty())
1920 owner->message(_("Canceled."));
1923 // still no filename? abort
1924 if (filename.empty())
1927 // get absolute path of file
1928 filename = MakeAbsPath(filename);
1930 string const lyxfile = ChangeExtension(filename, ".lyx");
1932 // Check if the document already is open
1933 if (bufferlist.exists(lyxfile)) {
1934 switch (Alert::askConfirmation(_("Document is already open:"),
1935 MakeDisplayPath(lyxfile, 50),
1936 _("Do you want to close that document now?\n"
1937 "('No' will just switch to the open version)")))
1939 case 1: // Yes: close the document
1940 if (!bufferlist.close(bufferlist.getBuffer(lyxfile)))
1941 // If close is canceled, we cancel here too.
1944 case 2: // No: switch to the open document
1945 owner->view()->buffer(bufferlist.getBuffer(lyxfile));
1947 case 3: // Cancel: Do nothing
1948 owner->message(_("Canceled."));
1953 // Check if a LyX document by the same root exists in filesystem
1954 FileInfo const f(lyxfile, true);
1955 if (f.exist() && !Alert::askQuestion(_("A document by the name"),
1956 MakeDisplayPath(lyxfile),
1957 _("already exists. Overwrite?"))) {
1958 owner->message(_("Canceled"));
1961 // filename should be valid now
1963 Importer::Import(owner, filename, format);
1967 void LyXFunc::reloadBuffer()
1969 string const fn = owner->buffer()->fileName();
1970 if (bufferlist.close(owner->buffer()))
1971 owner->view()->buffer(bufferlist.loadLyXFile(fn));
1975 void LyXFunc::closeBuffer()
1977 if (bufferlist.close(owner->buffer()) && !quitting) {
1978 if (bufferlist.empty()) {
1979 // need this otherwise SEGV may occur while trying to
1980 // set variables that don't exist
1981 // since there's no current buffer
1982 owner->getDialogs()->hideBufferDependent();
1984 owner->view()->buffer(bufferlist.first());
1990 // Each "owner" should have it's own message method. lyxview and
1991 // the minibuffer would use the minibuffer, but lyxserver would
1992 // send an ERROR signal to its client. Alejandro 970603
1993 // This func is bit problematic when it comes to NLS, to make the
1994 // lyx servers client be language indepenent we must not translate
1995 // strings sent to this func.
1996 void LyXFunc::setErrorMessage(string const & m) const
1998 dispatch_buffer = m;
2003 void LyXFunc::setMessage(string const & m) const
2005 dispatch_buffer = m;
2009 void LyXFunc::setStatusMessage(string const & m) const
2015 void LyXFunc::initMiniBuffer()
2017 string text = _("Welcome to LyX!");
2019 // When meta-fake key is pressed, show the key sequence so far + "M-".
2021 text = keyseq.print();
2025 // Else, when a non-complete key sequence is pressed,
2026 // show the available options.
2027 if (keyseq.length() > 0 && !keyseq.deleted()) {
2028 text = keyseq.printOptions();
2031 // Else, show the buffer state.
2032 else if (owner->view()->available()) {
2033 Buffer * tmpbuf = owner->buffer();
2035 string const nicename =
2036 MakeDisplayPath(tmpbuf->fileName());
2037 // Should we do this instead? (kindo like emacs)
2038 // leaves more room for other information
2041 if (tmpbuf->lyxvc.inUse()) {
2043 text += tmpbuf->lyxvc.versionString();
2045 text += tmpbuf->lyxvc.locker();
2046 if (tmpbuf->isReadonly())
2049 } else if (tmpbuf->isReadonly())
2051 if (!tmpbuf->isLyxClean())
2052 text += _(" (Changed)");
2054 if (text != _("Welcome to LyX!")) // this is a hack
2055 text = _("* No document open *");
2058 owner->message(text);