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"
37 #include "bufferview_funcs.h"
38 #include "minibuffer.h"
41 #include "lyx_gui_misc.h"
42 #include "FloatList.h"
43 #include "converter.h"
46 #include "FontLoader.h"
47 #include "TextCache.h"
49 #include "undo_funcs.h"
50 #include "ParagraphParameters.h"
52 #include "insets/inseturl.h"
53 #include "insets/insetlatexaccent.h"
54 #include "insets/insettoc.h"
55 #include "insets/insetref.h"
56 #include "insets/insetparent.h"
57 #include "insets/insetindex.h"
58 #include "insets/insetinclude.h"
59 #include "insets/insetbib.h"
60 #include "insets/insetcite.h"
61 #include "insets/insettext.h"
62 #include "insets/insetert.h"
63 #include "insets/insetexternal.h"
64 #include "insets/insetgraphics.h"
65 #include "insets/insetfoot.h"
66 #include "insets/insetmarginal.h"
67 #include "insets/insetminipage.h"
68 #include "insets/insetfloat.h"
70 #include "insets/insetlist.h"
71 #include "insets/insettheorem.h"
73 #include "insets/insettabular.h"
74 #include "insets/insetcaption.h"
76 #include "mathed/formulamacro.h"
77 #include "mathed/math_cursor.h"
78 #include "mathed/math_inset.h"
80 #include "frontends/FileDialog.h"
81 #include "frontends/Dialogs.h"
82 #include "frontends/Toolbar.h"
83 #include "frontends/Menubar.h"
84 #include "frontends/Alert.h"
86 #include "graphics/GraphicsCache.h"
88 #include "support/lyxalgo.h"
89 #include "support/LAssert.h"
90 #include "support/filetools.h"
91 #include "support/FileInfo.h"
92 #include "support/forkedcontr.h"
93 #include "support/lstrings.h"
94 #include "support/path.h"
95 #include "support/lyxfunctional.h"
107 using std::make_pair;
111 using std::transform;
112 using std::back_inserter;
114 extern BufferList bufferlist;
115 extern LyXServer * lyxserver;
116 extern bool selection_possible;
117 extern void MenuSendto();
119 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
121 extern void show_symbols_form(LyXFunc *);
123 extern LyXAction lyxaction;
125 extern tex_accent_struct get_accent(kb_action action);
127 extern void ShowLatexLog();
133 class MiniBufferController : public SigC::Object {
136 MiniBufferController() {
140 &MiniBufferController::receiveCommand));
144 &MiniBufferController::receiveArg));
147 void receiveCmd(string const & cmd) {}
149 void receiveArg(string const & arg) {}
157 MiniBufferController mb_ctrl;
163 /* === globals =========================================================== */
166 LyXFunc::LyXFunc(LyXView * o)
168 keyseq(toplevel_keymap.get(), toplevel_keymap.get()),
169 cancel_meta_seq(toplevel_keymap.get(), toplevel_keymap.get())
172 lyx_dead_action = LFUN_NOACTION;
173 lyx_calling_dead_action = LFUN_NOACTION;
178 LyXText * LyXFunc::TEXT(bool flag = true) const
181 return owner->view()->text;
182 return owner->view()->getLyXText();
186 // I changed this func slightly. I commented out the ...FinishUndo(),
187 // this means that all places that used to have a moveCursorUpdate, now
188 // have a ...FinishUndo() as the preceeding statement. I have also added
189 // a moveCursorUpdate to some of the functions that updated the cursor, but
190 // that did not show its new position.
192 void LyXFunc::moveCursorUpdate(bool flag, bool selecting)
194 if (selecting || TEXT(flag)->selection.mark()) {
195 TEXT(flag)->setSelection(owner->view());
196 if (TEXT(flag)->bv_owner)
197 owner->view()->toggleToggle();
199 owner->view()->update(TEXT(flag), BufferView::SELECT|BufferView::FITCUR);
200 owner->view()->showCursor();
202 /* ---> Everytime the cursor is moved, show the current font state. */
203 // should this too me moved out of this func?
204 owner->view()->setState();
208 void LyXFunc::handleKeyFunc(kb_action action)
210 char c = keyseq.getiso();
212 if (keyseq.length() > 1) {
216 owner->getIntl()->getTrans()
217 .deadkey(c, get_accent(action).accent, TEXT(false));
218 // Need to clear, in case the minibuffer calls these
221 // copied verbatim from do_accent_char
222 owner->view()->update(TEXT(false),
223 BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
224 TEXT(false)->selection.cursor = TEXT(false)->cursor;
228 void LyXFunc::processKeySym(KeySym keysym, unsigned int state)
232 if (lyxerr.debugging(Debug::KEY)) {
233 char const * tmp = XKeysymToString(keysym);
234 string const stm = (tmp ? tmp : "");
235 lyxerr << "KeySym is "
238 << keysym << "] State is ["
242 // Do nothing if we have nothing (JMarc)
243 if (keysym == NoSymbol) {
244 lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
249 // Can we be sure that this will work for all X Window
250 // implementations? (Lgb)
251 // This code snippet makes lyx ignore some keys. Perhaps
252 // all of them should be explictly mentioned?
253 if ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
254 || keysym == XK_Mode_switch || keysym == 0x0) {
258 // Do a one-deep top-level lookup for
259 // cancel and meta-fake keys. RVDK_PATCH_5
260 cancel_meta_seq.reset();
262 int action = cancel_meta_seq.addkey(keysym, state
263 &(ShiftMask|ControlMask
265 if (lyxerr.debugging(Debug::KEY)) {
266 lyxerr << "action first set to [" << action << "]" << endl;
269 // When not cancel or meta-fake, do the normal lookup.
270 // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
271 // Mostly, meta_fake_bit = 0. RVDK_PATCH_5.
272 if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
273 if (lyxerr.debugging(Debug::KEY)) {
274 lyxerr << "meta_fake_bit is ["
275 << meta_fake_bit << "]" << endl;
277 // remove Caps Lock and Mod2 as a modifiers
278 action = keyseq.addkey(keysym,
279 (state | meta_fake_bit)
280 &(ShiftMask|ControlMask
282 if (lyxerr.debugging(Debug::KEY)) {
283 lyxerr << "action now set to ["
284 << action << "]" << endl;
287 // Dont remove this unless you know what you are doing.
290 // can this happen now ?
291 if (action == LFUN_NOACTION) {
292 action = LFUN_PREFIX;
295 if (lyxerr.debugging(Debug::KEY)) {
296 lyxerr << "Key [action="
298 << keyseq.print() << "]"
302 // already here we know if it any point in going further
303 // why not return already here if action == -1 and
304 // num_bytes == 0? (Lgb)
306 if (keyseq.length() > 1 && !keyseq.deleted()) {
307 owner->message(keyseq.print());
310 if (action == LFUN_UNKNOWN_ACTION) {
311 // It is unknown, but what if we remove all
312 // the modifiers? (Lgb)
313 action = keyseq.addkey(keysym, 0);
315 if (lyxerr.debugging(Debug::KEY)) {
316 lyxerr << "Removing modifiers...\n"
317 << "Action now set to ["
318 << action << "]" << endl;
320 if (action == LFUN_UNKNOWN_ACTION) {
321 owner->message(_("Unknown function."));
326 if (action == LFUN_SELFINSERT) {
327 // This is very X dependent.
328 unsigned int c = keysym;
331 c = kb_keymap::getiso(c);
334 argument = static_cast<char>(c);
336 dispatch(LFUN_SELFINSERT, argument);
337 lyxerr[Debug::KEY] << "SelfInsert arg[`"
338 << argument << "']" << endl;
341 verboseDispatch(action, false);
345 FuncStatus LyXFunc::getStatus(int ac) const
349 action = lyxaction.retrieveActionArg(ac, argument);
350 return getStatus(action, argument);
354 FuncStatus LyXFunc::getStatus(kb_action action,
355 string const & argument) const
358 Buffer * buf = owner->buffer();
360 if (action == LFUN_UNKNOWN_ACTION) {
361 setStatusMessage(N_("Unknown action"));
362 return flag.unknown(true);
365 // the default error message if we disable the command
366 setStatusMessage(N_("Command disabled"));
368 // Check whether we need a buffer
369 if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) {
370 // Yes we need a buffer, do we have one?
373 // Can we use a readonly buffer?
374 if (buf->isReadonly() &&
375 !lyxaction.funcHasFlag(action,
376 LyXAction::ReadOnly)) {
378 setStatusMessage(N_("Document is read-only"));
383 setStatusMessage(N_("Command not allowed with"
384 "out any document open"));
385 return flag.disabled(true);
389 UpdatableInset * tli = owner->view()->theLockingInset();
391 // I would really like to avoid having this switch and rather try to
392 // encode this in the function itself.
393 bool disable = false;
396 disable = !Exporter::IsExportable(buf, "dvi")
397 || lyxrc.print_command == "none";
400 disable = argument == "fax" &&
401 !Exporter::IsExportable(buf, argument);
404 disable = buf->undostack.empty();
407 disable = buf->redostack.empty();
409 case LFUN_SPELLCHECK:
410 disable = lyxrc.isp_command == "none";
412 #ifndef HAVE_LIBAIKSAURUS
413 case LFUN_THESAURUS_ENTRY:
418 disable = lyxrc.chktex_command == "none";
421 disable = !Exporter::IsExportable(buf, "program");
424 case LFUN_LAYOUT_TABULAR:
426 || (tli->lyxCode() != Inset::TABULAR_CODE
427 && !tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
431 case LFUN_LAYOUT_PARAGRAPH: {
432 Inset * inset = TEXT(false)->cursor.par()->inInset();
433 disable = inset && inset->forceDefaultParagraphs(inset);
437 case LFUN_TABULAR_FEATURE:
441 //ret.disabled(true);
442 if (tli->lyxCode() == Inset::TABULAR_CODE) {
443 ret = static_cast<InsetTabular *>(tli)
444 ->getStatus(argument);
445 } else if (tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
446 ret = static_cast<InsetTabular *>
447 (tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE))
448 ->getStatus(argument);
453 static InsetTabular inset(*owner->buffer(), 1, 1);
457 ret = inset.getStatus(argument);
458 if (ret.onoff(true) || ret.onoff(false))
459 flag.setOnOff(false);
463 case LFUN_VC_REGISTER:
464 disable = buf->lyxvc.inUse();
466 case LFUN_VC_CHECKIN:
467 disable = !buf->lyxvc.inUse() || buf->isReadonly();
469 case LFUN_VC_CHECKOUT:
470 disable = !buf->lyxvc.inUse() || !buf->isReadonly();
474 case LFUN_VC_HISTORY:
475 disable = !buf->lyxvc.inUse();
477 case LFUN_BOOKMARK_GOTO:
478 disable = !owner->view()->
479 isSavedPosition(strToUnsignedInt(argument));
483 case LFUN_INSET_TOGGLE: {
484 LyXText * lt = owner->view()->getLyXText();
485 disable = !(isEditableInset(lt->getInset())
487 && lt->inset_owner->owner()
488 && lt->inset_owner->owner()->isOpen()));
491 case LFUN_MATH_VALIGN:
493 char align = mathcursor->valign();
498 if (argument.empty()) {
502 if (!contains("tcb", argument[0])) {
506 flag.setOnOff(argument[0] == align);
511 case LFUN_MATH_HALIGN:
513 char align = mathcursor->halign();
518 if (argument.empty()) {
522 if (!contains("lcr", argument[0])) {
526 flag.setOnOff(argument[0] == align);
531 case LFUN_MATH_MUTATE:
532 if (tli && (tli->lyxCode() == Inset::MATH_CODE)) {
533 MathInsetTypes type = mathcursor->formula()->getType();
534 if (argument == "inline") {
535 flag.setOnOff(type == LM_OT_SIMPLE);
536 } else if (argument == "display") {
537 flag.setOnOff(type == LM_OT_EQUATION);
538 } else if (argument == "eqnarray") {
539 flag.setOnOff(type == LM_OT_EQNARRAY);
540 } else if (argument == "align") {
541 flag.setOnOff(type == LM_OT_ALIGN);
549 // we just need to be in math mode to enable that
551 case LFUN_MATH_SPACE:
552 case LFUN_MATH_LIMITS:
553 case LFUN_MATH_NONUMBER:
554 case LFUN_MATH_NUMBER:
555 disable = !mathcursor;
558 // we need to be math mode and a math array for that
559 // Hack: halign produces non-zero result iff we are in a math array
560 case LFUN_MATH_ROW_INSERT:
561 case LFUN_MATH_ROW_DELETE:
562 case LFUN_MATH_COLUMN_INSERT:
563 case LFUN_MATH_COLUMN_DELETE:
564 disable = !mathcursor || !mathcursor->halign();
571 // the functions which insert insets
572 Inset::Code code = Inset::NO_CODE;
574 case LFUN_INSET_TEXT:
575 code = Inset::TEXT_CODE;
578 code = Inset::ERT_CODE;
580 case LFUN_INSET_GRAPHICS:
581 code = Inset::GRAPHICS_CODE;
583 case LFUN_INSET_FOOTNOTE:
584 code = Inset::FOOT_CODE;
586 case LFUN_DIALOG_TABULAR_INSERT:
587 case LFUN_INSET_TABULAR:
588 code = Inset::TABULAR_CODE;
590 case LFUN_INSET_EXTERNAL:
591 code = Inset::EXTERNAL_CODE;
593 case LFUN_INSET_MARGINAL:
594 code = Inset::MARGIN_CODE;
596 case LFUN_INSET_MINIPAGE:
597 code = Inset::MINIPAGE_CODE;
599 case LFUN_INSET_FLOAT:
600 case LFUN_INSET_WIDE_FLOAT:
601 code = Inset::FLOAT_CODE;
603 case LFUN_FLOAT_LIST:
604 code = Inset::FLOAT_LIST_CODE;
607 case LFUN_INSET_LIST:
608 code = Inset::LIST_CODE;
610 case LFUN_INSET_THEOREM:
611 code = Inset::THEOREM_CODE;
614 case LFUN_INSET_CAPTION:
615 code = Inset::CAPTION_CODE;
617 case LFUN_INSERT_NOTE:
618 code = Inset::IGNORE_CODE;
620 case LFUN_INSERT_LABEL:
621 code = Inset::LABEL_CODE;
623 case LFUN_REF_INSERT:
624 code = Inset::REF_CODE;
626 case LFUN_CITATION_CREATE:
627 case LFUN_CITATION_INSERT:
628 code = Inset::CITE_CODE;
630 case LFUN_INSERT_BIBTEX:
631 code = Inset::BIBTEX_CODE;
633 case LFUN_INDEX_INSERT:
634 case LFUN_INDEX_INSERT_LAST:
635 case LFUN_INDEX_CREATE:
636 code = Inset::INDEX_CODE;
638 case LFUN_INDEX_PRINT:
639 code = Inset::INDEX_PRINT_CODE;
641 case LFUN_CHILD_INSERT:
642 code = Inset::INCLUDE_CODE;
644 case LFUN_TOC_INSERT:
645 code = Inset::TOC_CODE;
647 case LFUN_PARENTINSERT:
648 code = Inset::PARENT_CODE;
652 case LFUN_INSERT_URL:
653 code = Inset::URL_CODE;
656 // always allow this, since we will inset a raw quote
657 // if an inset is not allowed.
659 case LFUN_HYPHENATION:
660 case LFUN_LIGATURE_BREAK:
662 case LFUN_MENU_SEPARATOR:
664 case LFUN_END_OF_SENTENCE:
665 case LFUN_PROTECTEDSPACE:
666 code = Inset::SPECIALCHAR_CODE;
671 if (code != Inset::NO_CODE && tli && !tli->insetAllowed(code)) {
678 // A few general toggles
680 case LFUN_READ_ONLY_TOGGLE:
681 flag.setOnOff(buf->isReadonly());
684 flag.setOnOff(TEXT(false)->cursor.par()->params().startOfAppendix());
686 case LFUN_SWITCHBUFFER:
687 // toggle on the current buffer, but do not toggle off
688 // the other ones (is that a good idea?)
689 if (argument == buf->fileName())
696 // the font related toggles
698 LyXFont const & font = TEXT(false)->real_current_font;
701 flag.setOnOff(font.emph() == LyXFont::ON);
704 flag.setOnOff(font.noun() == LyXFont::ON);
707 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
710 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
713 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
716 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
723 MathTextCodes tc = mathcursor->getLastCode();
726 flag.setOnOff(tc == LM_TC_BF);
729 flag.setOnOff(tc == LM_TC_SF);
732 flag.setOnOff(tc == LM_TC_CAL);
735 flag.setOnOff(tc == LM_TC_RM);
738 flag.setOnOff(tc == LM_TC_TT);
741 flag.setOnOff(tc == LM_TC_BB);
744 flag.setOnOff(tc == LM_TC_VAR);
755 // temporary dispatch method
756 void LyXFunc::miniDispatch(string const & s)
758 string s2(frontStrip(strip(s)));
761 verboseDispatch(s2, true);
766 void LyXFunc::verboseDispatch(string const & s, bool show_sc)
768 int action = lyxaction.LookupFunc(frontStrip(s));
770 if (action == LFUN_UNKNOWN_ACTION) {
771 string const msg = string(_("Unknown function ("))
775 verboseDispatch(action, show_sc);
780 void LyXFunc::verboseDispatch(int ac, bool show_sc)
785 // get the real action and argument
786 action = lyxaction.retrieveActionArg(ac, argument);
788 verboseDispatch(action, argument, show_sc);
793 void LyXFunc::verboseDispatch(kb_action action,
794 string const & argument, bool show_sc)
796 string res = dispatch(action, argument);
798 commandshortcut.erase();
800 if (lyxrc.display_shortcuts && show_sc) {
801 if (action != LFUN_SELFINSERT) {
802 // Put name of command and list of shortcuts
803 // for it in minibuffer
804 string comname = lyxaction.getActionName(action);
806 int pseudoaction = action;
807 bool argsadded = false;
809 if (!argument.empty()) {
810 // the pseudoaction is useful for the bindings
812 lyxaction.searchActionArg(action,
815 if (pseudoaction == LFUN_UNKNOWN_ACTION) {
816 pseudoaction = action;
818 comname += " " + argument;
823 string const shortcuts =
824 toplevel_keymap->findbinding(pseudoaction);
826 if (!shortcuts.empty()) {
827 comname += ": " + shortcuts;
828 } else if (!argsadded && !argument.empty()) {
829 comname += " " + argument;
832 if (!comname.empty()) {
833 comname = strip(comname);
834 commandshortcut = "(" + comname + ')';
840 if (!commandshortcut.empty()) {
841 owner->getMiniBuffer()->addSet(commandshortcut);
844 owner->getMiniBuffer()->addSet(' ' + commandshortcut);
849 string const LyXFunc::dispatch(kb_action action, string argument)
851 lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << action
852 <<"] arg[" << argument << "]" << endl;
854 // we have not done anything wrong yet.
856 dispatch_buffer.erase();
858 #ifdef NEW_DISPATCHER
859 // We try do call the most specific dispatcher first:
860 // 1. the lockinginset's dispatch
861 // 2. the bufferview's dispatch
862 // 3. the lyxview's dispatch
865 selection_possible = false;
867 if (owner->view()->available())
868 owner->view()->hideCursor();
870 // We cannot use this function here
871 if (getStatus(action, argument).disabled()) {
872 lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: "
873 << lyxaction.getActionName(action)
874 << " [" << action << "] is disabled at this location"
876 setErrorMessage(getStatusMessage());
877 goto exit_with_message;
880 if (owner->view()->available() && owner->view()->theLockingInset()) {
881 UpdatableInset::RESULT result;
882 if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
883 (!keyseq.deleted())))
885 if ((action == LFUN_UNKNOWN_ACTION)
886 && argument.empty()) {
887 argument = keyseq.getiso();
889 // Undo/Redo is a bit tricky for insets.
890 if (action == LFUN_UNDO) {
891 owner->view()->menuUndo();
892 goto exit_with_message;
893 } else if (action == LFUN_REDO) {
894 owner->view()->menuRedo();
895 goto exit_with_message;
896 } else if (((result=owner->view()->theLockingInset()->
897 // Hand-over to inset's own dispatch:
898 localDispatch(owner->view(), action, argument)) ==
899 UpdatableInset::DISPATCHED) ||
900 (result == UpdatableInset::DISPATCHED_NOUPDATE))
901 goto exit_with_message;
902 // If UNDISPATCHED, just soldier on
903 else if (result == UpdatableInset::FINISHED) {
904 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
905 TEXT()->cursorRight(owner->view());
906 moveCursorUpdate(true, false);
909 goto exit_with_message;
910 } else if (result == UpdatableInset::FINISHED_RIGHT) {
911 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
912 TEXT()->cursorRight(owner->view());
913 moveCursorUpdate(true, false);
916 goto exit_with_message;
917 } else if (result == UpdatableInset::FINISHED_UP) {
918 if (TEXT()->cursor.row()->previous()) {
919 TEXT()->cursorUp(owner->view());
920 moveCursorUpdate(true, false);
923 goto exit_with_message;
924 } else if (result == UpdatableInset::FINISHED_DOWN) {
925 if (TEXT()->cursor.row()->next())
926 TEXT()->cursorDown(owner->view());
928 TEXT()->cursorRight(owner->view());
929 moveCursorUpdate(true, false);
931 goto exit_with_message;
933 //setMessage(N_("Text mode"));
935 case LFUN_UNKNOWN_ACTION:
936 case LFUN_BREAKPARAGRAPH:
938 TEXT()->cursorRight(owner->view());
939 owner->view()->setState();
943 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
944 TEXT()->cursorRight(owner->view());
945 moveCursorUpdate(true, false);
948 goto exit_with_message;
950 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
951 TEXT()->cursorRight(owner->view());
952 moveCursorUpdate(true, false);
955 goto exit_with_message;
957 if (TEXT()->cursor.row()->next())
958 TEXT()->cursorDown(owner->view());
960 TEXT()->cursorRight(owner->view());
961 moveCursorUpdate(true, false);
963 goto exit_with_message;
975 if (!owner->view()->available()) break;
976 // this function should be used always [asierra060396]
977 UpdatableInset * tli =
978 owner->view()->theLockingInset();
980 UpdatableInset * lock = tli->getLockingInset();
983 owner->view()->unlockInset(tli);
984 TEXT()->cursorRight(owner->view());
985 moveCursorUpdate(true, false);
988 tli->unlockInsetInInset(owner->view(),
997 // --- Misc -------------------------------------------
998 case LFUN_WORDFINDFORWARD :
999 case LFUN_WORDFINDBACKWARD : {
1000 static string last_search;
1001 string searched_string;
1003 if (!argument.empty()) {
1004 last_search = argument;
1005 searched_string = argument;
1007 searched_string = last_search;
1009 bool fw = (action == LFUN_WORDFINDBACKWARD);
1010 if (!searched_string.empty()) {
1011 LyXFind(owner->view(), searched_string, fw);
1013 // owner->view()->showCursor();
1019 if (owner->view()->available() && !owner->view()->theLockingInset()) {
1020 owner->view()->update(TEXT(),
1021 BufferView::SELECT|BufferView::FITCUR);
1023 owner->message(keyseq.print());
1027 // --- Misc -------------------------------------------
1028 case LFUN_EXEC_COMMAND:
1030 vector<string> allCmds;
1031 transform(lyxaction.func_begin(), lyxaction.func_end(),
1032 back_inserter(allCmds), lyx::firster());
1033 static vector<string> hist;
1034 owner->getMiniBuffer()->getString(MiniBuffer::spaces,
1039 case LFUN_CANCEL: // RVDK_PATCH_5
1042 if (owner->view()->available())
1043 // cancel any selection
1044 dispatch(LFUN_MARK_OFF);
1045 setMessage(N_("Cancel"));
1048 case LFUN_META_FAKE: // RVDK_PATCH_5
1050 meta_fake_bit = Mod1Mask;
1051 setMessage(keyseq.print());
1055 case LFUN_READ_ONLY_TOGGLE:
1056 if (owner->buffer()->lyxvc.inUse()) {
1057 owner->buffer()->lyxvc.toggleReadOnly();
1059 owner->buffer()->setReadonly(
1060 !owner->buffer()->isReadonly());
1064 case LFUN_CENTER: // this is center and redraw.
1065 owner->view()->center();
1068 // --- Menus -----------------------------------------------
1073 case LFUN_MENUNEWTMPLT:
1077 case LFUN_CLOSEBUFFER:
1081 case LFUN_MENUWRITE:
1082 if (!owner->buffer()->isUnnamed()) {
1084 s1 << _("Saving document") << ' '
1085 << MakeDisplayPath(owner->buffer()->fileName() + "...");
1086 owner->message(s1.str().c_str());
1087 MenuWrite(owner->view(), owner->buffer());
1089 WriteAs(owner->view(), owner->buffer());
1093 WriteAs(owner->view(), owner->buffer(), argument);
1096 case LFUN_MENURELOAD:
1101 Exporter::Export(owner->buffer(), argument, true);
1105 Exporter::Preview(owner->buffer(), argument);
1108 case LFUN_BUILDPROG:
1109 Exporter::Export(owner->buffer(), "program", true);
1112 case LFUN_RUNCHKTEX:
1113 MenuRunChktex(owner->buffer());
1116 case LFUN_MENUPRINT:
1117 owner->getDialogs()->showPrint();
1121 if (argument == "custom")
1124 Exporter::Export(owner->buffer(), argument, false);
1142 InsetCommandParams p;
1145 if (action == LFUN_TOCVIEW)
1147 p.setCmdName("tableofcontents");
1149 else if (action == LFUN_LOAVIEW)
1150 p.setCmdName("listof{algorithm}{List of Algorithms}");
1151 else if (action == LFUN_LOFVIEW)
1152 p.setCmdName("listoffigures");
1154 p.setCmdName("listoftables");
1156 owner->getDialogs()->createTOC(p.getAsString());
1160 case LFUN_DIALOG_TABULAR_INSERT:
1161 owner->getDialogs()->showTabularCreate();
1165 AutoSave(owner->view());
1169 owner->view()->menuUndo();
1173 owner->view()->menuRedo();
1176 case LFUN_MENUSEARCH:
1177 owner->getDialogs()->showSearch();
1180 case LFUN_REMOVEERRORS:
1181 if (owner->view()->removeAutoInsets()) {
1182 owner->view()->redraw();
1183 owner->view()->fitCursor();
1188 changeDepth(owner->view(), TEXT(false), 0);
1191 case LFUN_DEPTH_MIN:
1192 changeDepth(owner->view(), TEXT(false), -1);
1195 case LFUN_DEPTH_PLUS:
1196 changeDepth(owner->view(), TEXT(false), 1);
1200 owner->getDialogs()->setUserFreeFont();
1203 case LFUN_RECONFIGURE:
1204 Reconfigure(owner->view());
1208 case LFUN_FLOATSOPERATE:
1209 if (argument == "openfoot")
1210 owner->view()->allFloats(1,0);
1211 else if (argument == "closefoot")
1212 owner->view()->allFloats(0,0);
1213 else if (argument == "openfig")
1214 owner->view()->allFloats(1,1);
1215 else if (argument == "closefig")
1216 owner->view()->allFloats(0,1);
1219 #ifdef WITH_WARNINGS
1220 //#warning Find another implementation here (or another lyxfunc)!
1223 case LFUN_HELP_ABOUTLYX:
1224 owner->getDialogs()->showAboutlyx();
1227 case LFUN_HELP_TEXINFO:
1228 owner->getDialogs()->showTexinfo();
1231 case LFUN_HELP_OPEN:
1233 string const arg = argument;
1235 setErrorMessage(N_("Missing argument"));
1238 owner->prohibitInput();
1239 string const fname = i18nLibFileSearch("doc", arg, "lyx");
1240 if (fname.empty()) {
1241 lyxerr << "LyX: unable to find documentation file `"
1242 << arg << "'. Bad installation?" << endl;
1243 owner->allowInput();
1247 str << _("Opening help file") << ' '
1248 << MakeDisplayPath(fname) << "...";
1249 owner->message(str.str().c_str());
1250 owner->view()->buffer(bufferlist.loadLyXFile(fname, false));
1251 owner->allowInput();
1255 // --- version control -------------------------------
1256 case LFUN_VC_REGISTER:
1258 if (!owner->buffer()->lyxvc.inUse())
1259 owner->buffer()->lyxvc.registrer();
1263 case LFUN_VC_CHECKIN:
1265 if (owner->buffer()->lyxvc.inUse()
1266 && !owner->buffer()->isReadonly())
1267 owner->buffer()->lyxvc.checkIn();
1271 case LFUN_VC_CHECKOUT:
1273 if (owner->buffer()->lyxvc.inUse()
1274 && owner->buffer()->isReadonly())
1275 owner->buffer()->lyxvc.checkOut();
1279 case LFUN_VC_REVERT:
1281 owner->buffer()->lyxvc.revert();
1287 owner->buffer()->lyxvc.undoLast();
1291 case LFUN_VC_HISTORY:
1293 owner->getDialogs()->showVCLogFile();
1297 // --- buffers ----------------------------------------
1299 case LFUN_SWITCHBUFFER:
1300 owner->view()->buffer(bufferlist.getBuffer(argument));
1305 // servercmd: argument must be <file>:<template>
1306 Buffer * tmpbuf = NewLyxFile(argument);
1308 owner->view()->buffer(tmpbuf);
1312 case LFUN_FILE_OPEN:
1316 case LFUN_LATEX_LOG:
1317 owner->getDialogs()->showLogFile();
1320 case LFUN_LAYOUT_DOCUMENT:
1321 owner->getDialogs()->showDocument();
1324 case LFUN_LAYOUT_PARAGRAPH:
1325 owner->getDialogs()->showParagraph();
1328 case LFUN_LAYOUT_CHARACTER:
1329 owner->getDialogs()->showCharacter();
1332 case LFUN_LAYOUT_TABULAR:
1333 if (owner->view()->theLockingInset()) {
1334 if (owner->view()->theLockingInset()->lyxCode()==Inset::TABULAR_CODE) {
1335 InsetTabular * inset = static_cast<InsetTabular *>
1336 (owner->view()->theLockingInset());
1337 inset->openLayoutDialog(owner->view());
1338 } else if (owner->view()->theLockingInset()->
1339 getFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
1340 InsetTabular * inset = static_cast<InsetTabular *>(
1341 owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
1342 inset->openLayoutDialog(owner->view());
1347 case LFUN_LAYOUT_PREAMBLE:
1348 owner->getDialogs()->showPreamble();
1351 case LFUN_DROP_LAYOUTS_CHOICE:
1352 owner->getToolbar()->openLayoutList();
1355 case LFUN_MENU_OPEN_BY_NAME:
1356 owner->getMenubar()->openByName(argument);
1357 break; // RVDK_PATCH_5
1359 case LFUN_SPELLCHECK:
1360 if (lyxrc.isp_command != "none")
1361 owner->getDialogs()->showSpellchecker();
1364 // --- lyxserver commands ----------------------------
1368 setMessage(owner->buffer()->fileName());
1369 lyxerr[Debug::INFO] << "FNAME["
1370 << owner->buffer()->fileName()
1376 dispatch_buffer = keyseq.print();
1377 lyxserver->notifyClient(dispatch_buffer);
1381 case LFUN_GOTOFILEROW:
1385 istringstream istr(argument.c_str());
1386 istr >> file_name >> row;
1387 // Must replace extension of the file to be .lyx and get full path
1388 string const s(ChangeExtension(file_name, ".lyx"));
1390 // Either change buffer or load the file
1391 if (bufferlist.exists(s)) {
1392 owner->view()->buffer(bufferlist.getBuffer(s));
1394 owner->view()->buffer(bufferlist.loadLyXFile(s));
1398 owner->view()->setCursorFromRow(row);
1401 owner->view()->center();
1405 case LFUN_GOTO_PARAGRAPH:
1407 istringstream istr(argument.c_str());
1411 Paragraph * par = owner->buffer()->getParFromID(id);
1413 lyxerr[Debug::INFO] << "No matching paragraph found! ["
1414 << id << "]" << endl;
1417 lyxerr << "Paragraph " << par->id()
1418 << " found." << endl;
1421 if (owner->view()->theLockingInset())
1422 owner->view()->unlockInset(owner->view()->theLockingInset());
1423 if (par->inInset()) {
1424 par->inInset()->edit(owner->view());
1427 owner->view()->getLyXText()->setCursor(owner->view(), par, 0);
1428 owner->view()->setState();
1432 owner->view()->center();
1439 int const qa = lyxaction.LookupFunc(argument);
1440 setMessage(lyxaction.helpText(static_cast<kb_action>(qa)));
1444 // --- toolbar ----------------------------------
1445 case LFUN_PUSH_TOOLBAR:
1447 int nth = strToInt(argument);
1449 setErrorMessage(N_("Push-toolbar needs argument > 0"));
1451 owner->getToolbar()->push(nth);
1456 case LFUN_ADD_TO_TOOLBAR:
1458 if (lyxerr.debugging(Debug::GUI)) {
1459 lyxerr << "LFUN_ADD_TO_TOOLBAR:"
1460 "argument = `" << argument << '\'' << endl;
1462 string tmp(argument);
1463 //lyxerr <<string("Argument: ") + argument);
1464 //lyxerr <<string("Tmp : ") + tmp);
1466 setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
1468 owner->getToolbar()->add(argument, false);
1469 owner->getToolbar()->set();
1474 // --- insert characters ----------------------------------------
1476 // --- Mathed stuff. If we are here, there is no locked inset yet.
1477 case LFUN_MATH_EXTERN:
1478 case LFUN_MATH_NUMBER:
1479 case LFUN_MATH_NONUMBER:
1480 case LFUN_MATH_LIMITS:
1482 setErrorMessage(N_("This is only allowed in math mode!"));
1486 // passthrough hat and underscore outside mathed:
1487 case LFUN_SUBSCRIPT:
1488 dispatch(LFUN_SELFINSERT, "_");
1490 case LFUN_SUPERSCRIPT:
1491 dispatch(LFUN_SELFINSERT, "^");
1494 case LFUN_MATH_PANEL:
1495 owner->getDialogs()->showMathPanel();
1498 case LFUN_CITATION_CREATE:
1500 InsetCommandParams p("cite");
1502 if (!argument.empty()) {
1503 // This should be set at source, ie when typing
1504 // "citation-insert foo" in the minibuffer.
1505 // Question: would pybibliographer also need to be
1506 // changed. Suspect so. Leave as-is therefore.
1507 if (contains(argument, "|")) {
1508 p.setContents(token(argument, '|', 0));
1509 p.setOptions( token(argument, '|', 1));
1511 p.setContents(argument);
1513 dispatch(LFUN_CITATION_INSERT, p.getAsString());
1515 owner->getDialogs()->createCitation(p.getAsString());
1519 case LFUN_CHILDOPEN:
1521 string const filename =
1522 MakeAbsPath(argument,
1523 owner->buffer()->filePath());
1524 setMessage(N_("Opening child document ") +
1525 MakeDisplayPath(filename) + "...");
1526 owner->view()->savePosition(0);
1527 if (bufferlist.exists(filename))
1528 owner->view()->buffer(bufferlist.getBuffer(filename));
1530 owner->view()->buffer(bufferlist.loadLyXFile(filename));
1534 case LFUN_TOGGLECURSORFOLLOW:
1535 lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
1538 case LFUN_KMAP_OFF: // keymap off
1539 owner->getIntl()->KeyMapOn(false);
1542 case LFUN_KMAP_PRIM: // primary keymap
1543 owner->getIntl()->KeyMapPrim();
1546 case LFUN_KMAP_SEC: // secondary keymap
1547 owner->getIntl()->KeyMapSec();
1550 case LFUN_KMAP_TOGGLE: // toggle keymap
1551 owner->getIntl()->ToggleKeyMap();
1556 // argument contains ';'-terminated commands
1557 while (argument.find(';') != string::npos) {
1559 argument = split(argument, first, ';');
1560 verboseDispatch(first, false);
1565 case LFUN_DIALOG_PREFERENCES:
1566 owner->getDialogs()->showPreferences();
1569 case LFUN_SAVEPREFERENCES:
1571 Path p(user_lyxdir);
1572 lyxrc.write("preferences");
1576 case LFUN_SCREEN_FONT_UPDATE:
1578 // handle the screen font changes.
1580 lyxrc.set_font_norm_type();
1581 fontloader.update();
1582 // Of course we should only do the resize and the textcache.clear
1583 // if values really changed...but not very important right now. (Lgb)
1584 // All visible buffers will need resize
1586 // We also need to empty the textcache so that
1587 // the buffer will be formatted correctly after
1593 case LFUN_SET_COLOR:
1596 string const x11_name = split(argument, lyx_name, ' ');
1597 if (lyx_name.empty() || x11_name.empty()) {
1598 setErrorMessage(N_("Syntax: set-color <lyx_name>"
1603 bool const graphicsbg_changed =
1604 (lyx_name == lcolor.getLyXName(LColor::graphicsbg) &&
1605 x11_name != lcolor.getX11Name(LColor::graphicsbg));
1607 if (!lcolor.setColor(lyx_name, x11_name)) {
1608 static string const err1 (N_("Set-color \""));
1609 static string const err2 (
1610 N_("\" failed - color is undefined "
1611 "or may not be redefined"));
1612 setErrorMessage(_(err1) + lyx_name + _(err2));
1616 lyxColorHandler->updateColor(lcolor.getFromLyXName(lyx_name));
1618 if (graphicsbg_changed) {
1619 grfx::GCache & gc = grfx::GCache::get();
1620 gc.changeDisplay(true);
1623 owner->view()->redraw();
1628 owner->message(argument);
1631 case LFUN_MESSAGE_PUSH:
1632 owner->messagePush(argument);
1635 case LFUN_MESSAGE_POP:
1636 owner->messagePop();
1639 case LFUN_FORKS_SHOW:
1640 owner->getDialogs()->showForks();
1643 case LFUN_FORKS_KILL:
1645 if (!isStrInt(argument))
1648 pid_t const pid = strToInt(argument);
1649 ForkedcallsController & fcc = ForkedcallsController::get();
1655 // Then if it was none of the above
1656 // Trying the BufferView::pimpl dispatch:
1657 if (!owner->view()->Dispatch(action, argument))
1658 lyxerr << "A truly unknown func ["
1659 << lyxaction.getActionName(action) << "]!"
1666 string const res = getMessage();
1669 owner->message(_(res));
1670 owner->updateMenubar();
1671 owner->updateToolbar();
1677 void LyXFunc::setupLocalKeymap()
1679 keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
1680 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap.get();
1684 void LyXFunc::menuNew(bool fromTemplate)
1686 string initpath = lyxrc.document_path;
1688 if (owner->view()->available()) {
1689 string const trypath = owner->buffer()->filePath();
1690 // If directory is writeable, use this as default.
1691 if (IsDirWriteable(trypath))
1695 static int newfile_number;
1698 if (lyxrc.new_ask_filename) {
1699 FileDialog fileDlg(owner, _("Enter filename for new document"),
1700 LFUN_SELECT_FILE_SYNC,
1701 make_pair(string(_("Documents|#o#O")),
1702 string(lyxrc.document_path)),
1703 make_pair(string(_("Templates|#T#t")),
1704 string(lyxrc.template_path)));
1706 FileDialog::Result result =
1707 fileDlg.Select(initpath,
1708 _("*.lyx|LyX Documents (*.lyx)"),
1711 if (result.second.empty()) {
1712 owner->message(_("Canceled."));
1713 lyxerr[Debug::INFO] << "New Document Cancelled." << endl;
1717 // get absolute path of file and make sure the filename ends
1719 s = MakeAbsPath(result.second);
1720 if (!IsLyXFilename(s))
1723 // Check if the document already is open
1724 if (bufferlist.exists(s)) {
1725 switch (Alert::askConfirmation(_("Document is already open:"),
1726 MakeDisplayPath(s, 50),
1727 _("Do you want to close that document now?\n"
1728 "('No' will just switch to the open version)")))
1730 case 1: // Yes: close the document
1731 if (!bufferlist.close(bufferlist.getBuffer(s)))
1732 // If close is canceled, we cancel here too.
1735 case 2: // No: switch to the open document
1736 owner->view()->buffer(bufferlist.getBuffer(s));
1738 case 3: // Cancel: Do nothing
1739 owner->message(_("Canceled."));
1743 // Check whether the file already exists
1745 if (fi.readable() &&
1746 Alert::askQuestion(_("File already exists:"),
1747 MakeDisplayPath(s, 50),
1748 _("Do you want to open the document?"))) {
1750 string const disp_fn(MakeDisplayPath(s));
1753 str << _("Opening document") << ' '
1754 << disp_fn << "...";
1756 owner->message(str.str().c_str());
1757 //XFlush(fl_get_display());
1758 owner->view()->buffer(bufferlist.loadLyXFile(s));
1760 str2 << _("Document") << ' '
1761 << disp_fn << ' ' << _("opened.");
1763 owner->message(str2.str().c_str());
1768 s = AddName(lyxrc.document_path,
1769 "newfile" + tostr(++newfile_number) + ".lyx");
1771 while (bufferlist.exists(s) || fi.readable()) {
1773 s = AddName(lyxrc.document_path,
1774 "newfile" + tostr(newfile_number) +
1780 // The template stuff
1783 FileDialog fileDlg(owner, _("Select template file"),
1784 LFUN_SELECT_FILE_SYNC,
1785 make_pair(string(_("Documents|#o#O")),
1786 string(lyxrc.document_path)),
1787 make_pair(string(_("Templates|#T#t")),
1788 string(lyxrc.template_path)));
1790 FileDialog::Result result =
1791 fileDlg.Select(lyxrc.template_path,
1792 _("*.lyx|LyX Documents (*.lyx)"));
1794 if (result.first == FileDialog::Later)
1797 string const fname = result.second;
1804 // find a free buffer
1805 lyxerr[Debug::INFO] << "Find a free buffer." << endl;
1806 owner->view()->buffer(bufferlist.newFile(s, templname));
1810 void LyXFunc::open(string const & fname)
1812 string initpath = lyxrc.document_path;
1814 if (owner->view()->available()) {
1815 string const trypath = owner->buffer()->filePath();
1816 // If directory is writeable, use this as default.
1817 if (IsDirWriteable(trypath))
1823 if (fname.empty()) {
1824 FileDialog fileDlg(owner, _("Select document to open"),
1826 make_pair(string(_("Documents|#o#O")),
1827 string(lyxrc.document_path)),
1828 make_pair(string(_("Examples|#E#e")),
1829 string(AddPath(system_lyxdir, "examples"))));
1831 FileDialog::Result result =
1832 fileDlg.Select(initpath,
1833 "*.lyx|LyX Documents (*.lyx)");
1835 if (result.first == FileDialog::Later)
1838 filename = result.second;
1840 // check selected filename
1841 if (filename.empty()) {
1842 owner->message(_("Canceled."));
1848 // get absolute path of file and add ".lyx" to the filename if
1850 string const fullpath = FileSearch(string(), filename, "lyx");
1851 if (fullpath.empty()) {
1852 Alert::alert(_("Error"), _("Could not find file"), filename);
1856 filename = fullpath;
1859 string const disp_fn(MakeDisplayPath(filename));
1862 str << _("Opening document") << ' ' << disp_fn << "...";
1864 owner->message(str.str().c_str());
1866 Buffer * openbuf = bufferlist.loadLyXFile(filename);
1868 owner->view()->buffer(openbuf);
1870 str << _("Document") << ' ' << disp_fn << ' ' << _("opened.");
1871 owner->message(str.str().c_str());
1874 str << _("Could not open document") << ' ' << disp_fn;
1875 owner->message(str.str().c_str());
1880 // checks for running without gui are missing.
1881 void LyXFunc::doImport(string const & argument)
1884 string filename = split(argument, format, ' ');
1885 lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format
1886 << " file: " << filename << endl;
1888 if (filename.empty()) { // need user interaction
1889 string initpath = lyxrc.document_path;
1891 if (owner->view()->available()) {
1892 string const trypath = owner->buffer()->filePath();
1893 // If directory is writeable, use this as default.
1894 if (IsDirWriteable(trypath))
1898 string const text = _("Select ") + formats.prettyName(format)
1899 + _(" file to import");
1901 FileDialog fileDlg(owner, text,
1903 make_pair(string(_("Documents|#o#O")),
1904 string(lyxrc.document_path)),
1905 make_pair(string(_("Examples|#E#e")),
1906 string(AddPath(system_lyxdir, "examples"))));
1908 string const extension = "*." + formats.extension(format)
1909 + "| " + formats.prettyName(format)
1910 + " (*." + formats.extension(format) + ")";
1912 FileDialog::Result result = fileDlg.Select(initpath,
1915 if (result.first == FileDialog::Later)
1918 filename = result.second;
1920 // check selected filename
1921 if (filename.empty())
1922 owner->message(_("Canceled."));
1925 // still no filename? abort
1926 if (filename.empty())
1929 // get absolute path of file
1930 filename = MakeAbsPath(filename);
1932 string const lyxfile = ChangeExtension(filename, ".lyx");
1934 // Check if the document already is open
1935 if (bufferlist.exists(lyxfile)) {
1936 switch (Alert::askConfirmation(_("Document is already open:"),
1937 MakeDisplayPath(lyxfile, 50),
1938 _("Do you want to close that document now?\n"
1939 "('No' will just switch to the open version)")))
1941 case 1: // Yes: close the document
1942 if (!bufferlist.close(bufferlist.getBuffer(lyxfile)))
1943 // If close is canceled, we cancel here too.
1946 case 2: // No: switch to the open document
1947 owner->view()->buffer(bufferlist.getBuffer(lyxfile));
1949 case 3: // Cancel: Do nothing
1950 owner->message(_("Canceled."));
1955 // Check if a LyX document by the same root exists in filesystem
1956 FileInfo const f(lyxfile, true);
1957 if (f.exist() && !Alert::askQuestion(_("A document by the name"),
1958 MakeDisplayPath(lyxfile),
1959 _("already exists. Overwrite?"))) {
1960 owner->message(_("Canceled"));
1963 // filename should be valid now
1965 Importer::Import(owner, filename, format);
1969 void LyXFunc::reloadBuffer()
1971 string const fn = owner->buffer()->fileName();
1972 if (bufferlist.close(owner->buffer()))
1973 owner->view()->buffer(bufferlist.loadLyXFile(fn));
1977 void LyXFunc::closeBuffer()
1979 if (bufferlist.close(owner->buffer()) && !quitting) {
1980 if (bufferlist.empty()) {
1981 // need this otherwise SEGV may occur while trying to
1982 // set variables that don't exist
1983 // since there's no current buffer
1984 owner->getDialogs()->hideBufferDependent();
1986 owner->view()->buffer(bufferlist.first());
1992 // Each "owner" should have it's own message method. lyxview and
1993 // the minibuffer would use the minibuffer, but lyxserver would
1994 // send an ERROR signal to its client. Alejandro 970603
1995 // This func is bit problematic when it comes to NLS, to make the
1996 // lyx servers client be language indepenent we must not translate
1997 // strings sent to this func.
1998 void LyXFunc::setErrorMessage(string const & m) const
2000 dispatch_buffer = m;
2005 void LyXFunc::setMessage(string const & m) const
2007 dispatch_buffer = m;
2011 void LyXFunc::setStatusMessage(string const & m) const
2017 void LyXFunc::initMiniBuffer()
2019 string text = _("Welcome to LyX!");
2021 // When meta-fake key is pressed, show the key sequence so far + "M-".
2023 text = keyseq.print();
2027 // Else, when a non-complete key sequence is pressed,
2028 // show the available options.
2029 if (keyseq.length() > 0 && !keyseq.deleted()) {
2030 text = keyseq.printOptions();
2033 // Else, show the buffer state.
2034 else if (owner->view()->available()) {
2035 Buffer * tmpbuf = owner->buffer();
2037 string const nicename =
2038 MakeDisplayPath(tmpbuf->fileName());
2039 // Should we do this instead? (kindo like emacs)
2040 // leaves more room for other information
2043 if (tmpbuf->lyxvc.inUse()) {
2045 text += tmpbuf->lyxvc.versionString();
2047 text += tmpbuf->lyxvc.locker();
2048 if (tmpbuf->isReadonly())
2051 } else if (tmpbuf->isReadonly())
2053 if (!tmpbuf->isLyxClean())
2054 text += _(" (Changed)");
2056 if (text != _("Welcome to LyX!")) // this is a hack
2057 text = _("* No document open *");
2060 owner->message(text);