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 "FloatList.h"
42 #include "converter.h"
45 #include "FontLoader.h"
46 #include "TextCache.h"
48 #include "undo_funcs.h"
49 #include "ParagraphParameters.h"
51 #include "insets/inseturl.h"
52 #include "insets/insetlatexaccent.h"
53 #include "insets/insettoc.h"
54 #include "insets/insetref.h"
55 #include "insets/insetparent.h"
56 #include "insets/insetindex.h"
57 #include "insets/insetinclude.h"
58 #include "insets/insetbib.h"
59 #include "insets/insetcite.h"
60 #include "insets/insettext.h"
61 #include "insets/insetert.h"
62 #include "insets/insetexternal.h"
63 #include "insets/insetgraphics.h"
64 #include "insets/insetfoot.h"
65 #include "insets/insetmarginal.h"
66 #include "insets/insetminipage.h"
67 #include "insets/insetfloat.h"
69 #include "insets/insetlist.h"
70 #include "insets/insettheorem.h"
72 #include "insets/insettabular.h"
73 #include "insets/insetcaption.h"
75 #include "mathed/formulamacro.h"
76 #include "mathed/math_cursor.h"
77 #include "mathed/math_inset.h"
79 #include "frontends/FileDialog.h"
80 #include "frontends/Dialogs.h"
81 #include "frontends/Toolbar.h"
82 #include "frontends/Menubar.h"
83 #include "frontends/Alert.h"
85 #include "graphics/GraphicsCache.h"
87 #include "support/lyxalgo.h"
88 #include "support/LAssert.h"
89 #include "support/filetools.h"
90 #include "support/FileInfo.h"
91 #include "support/forkedcontr.h"
92 #include "support/lstrings.h"
93 #include "support/path.h"
94 #include "support/lyxfunctional.h"
106 using std::make_pair;
110 using std::transform;
111 using std::back_inserter;
113 extern BufferList bufferlist;
114 extern LyXServer * lyxserver;
115 extern bool selection_possible;
116 extern void MenuSendto();
118 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
120 extern void show_symbols_form(LyXFunc *);
122 extern LyXAction lyxaction;
124 extern tex_accent_struct get_accent(kb_action action);
126 extern void ShowLatexLog();
132 class MiniBufferController : public SigC::Object {
135 MiniBufferController() {
139 &MiniBufferController::receiveCommand));
143 &MiniBufferController::receiveArg));
146 void receiveCmd(string const & cmd) {}
148 void receiveArg(string const & arg) {}
156 MiniBufferController mb_ctrl;
162 /* === globals =========================================================== */
165 LyXFunc::LyXFunc(LyXView * o)
167 keyseq(toplevel_keymap.get(), toplevel_keymap.get()),
168 cancel_meta_seq(toplevel_keymap.get(), toplevel_keymap.get())
171 lyx_dead_action = LFUN_NOACTION;
172 lyx_calling_dead_action = LFUN_NOACTION;
177 LyXText * LyXFunc::TEXT(bool flag = true) const
180 return owner->view()->text;
181 return owner->view()->getLyXText();
185 // I changed this func slightly. I commented out the ...FinishUndo(),
186 // this means that all places that used to have a moveCursorUpdate, now
187 // have a ...FinishUndo() as the preceeding statement. I have also added
188 // a moveCursorUpdate to some of the functions that updated the cursor, but
189 // that did not show its new position.
191 void LyXFunc::moveCursorUpdate(bool flag, bool selecting)
193 if (selecting || TEXT(flag)->selection.mark()) {
194 TEXT(flag)->setSelection(owner->view());
195 if (TEXT(flag)->bv_owner)
196 owner->view()->toggleToggle();
198 owner->view()->update(TEXT(flag), BufferView::SELECT|BufferView::FITCUR);
199 owner->view()->showCursor();
201 /* ---> Everytime the cursor is moved, show the current font state. */
202 // should this too me moved out of this func?
203 owner->view()->setState();
207 void LyXFunc::handleKeyFunc(kb_action action)
209 char c = keyseq.getiso();
211 if (keyseq.length() > 1) {
215 owner->getIntl()->getTrans()
216 .deadkey(c, get_accent(action).accent, TEXT(false));
217 // Need to clear, in case the minibuffer calls these
220 // copied verbatim from do_accent_char
221 owner->view()->update(TEXT(false),
222 BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
223 TEXT(false)->selection.cursor = TEXT(false)->cursor;
227 void LyXFunc::processKeySym(KeySym keysym, unsigned int state)
231 if (lyxerr.debugging(Debug::KEY)) {
232 char const * tmp = XKeysymToString(keysym);
233 string const stm = (tmp ? tmp : "");
234 lyxerr << "KeySym is "
237 << keysym << "] State is ["
241 // Do nothing if we have nothing (JMarc)
242 if (keysym == NoSymbol) {
243 lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
248 // Can we be sure that this will work for all X Window
249 // implementations? (Lgb)
250 // This code snippet makes lyx ignore some keys. Perhaps
251 // all of them should be explictly mentioned?
252 if ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
253 || keysym == XK_Mode_switch || keysym == 0x0) {
257 // Do a one-deep top-level lookup for
258 // cancel and meta-fake keys. RVDK_PATCH_5
259 cancel_meta_seq.reset();
261 int action = cancel_meta_seq.addkey(keysym, state
262 &(ShiftMask|ControlMask
264 if (lyxerr.debugging(Debug::KEY)) {
265 lyxerr << "action first set to [" << action << "]" << endl;
268 // When not cancel or meta-fake, do the normal lookup.
269 // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
270 // Mostly, meta_fake_bit = 0. RVDK_PATCH_5.
271 if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
272 if (lyxerr.debugging(Debug::KEY)) {
273 lyxerr << "meta_fake_bit is ["
274 << meta_fake_bit << "]" << endl;
276 // remove Caps Lock and Mod2 as a modifiers
277 action = keyseq.addkey(keysym,
278 (state | meta_fake_bit)
279 &(ShiftMask|ControlMask
281 if (lyxerr.debugging(Debug::KEY)) {
282 lyxerr << "action now set to ["
283 << action << "]" << endl;
286 // Dont remove this unless you know what you are doing.
289 // can this happen now ?
290 if (action == LFUN_NOACTION) {
291 action = LFUN_PREFIX;
294 if (lyxerr.debugging(Debug::KEY)) {
295 lyxerr << "Key [action="
297 << keyseq.print() << "]"
301 // already here we know if it any point in going further
302 // why not return already here if action == -1 and
303 // num_bytes == 0? (Lgb)
305 if (keyseq.length() > 1) {
306 owner->message(keyseq.print());
309 if (action == LFUN_UNKNOWN_ACTION) {
310 // It is unknown, but what if we remove all
311 // the modifiers? (Lgb)
312 action = keyseq.addkey(keysym, 0);
314 if (lyxerr.debugging(Debug::KEY)) {
315 lyxerr << "Removing modifiers...\n"
316 << "Action now set to ["
317 << action << "]" << endl;
319 if (action == LFUN_UNKNOWN_ACTION) {
320 owner->message(_("Unknown function."));
325 if (action == LFUN_SELFINSERT) {
326 // This is very X dependent.
327 unsigned int c = keysym;
330 c = kb_keymap::getiso(c);
333 argument = static_cast<char>(c);
335 dispatch(LFUN_SELFINSERT, argument);
336 lyxerr[Debug::KEY] << "SelfInsert arg[`"
337 << argument << "']" << endl;
340 verboseDispatch(action, false);
344 FuncStatus LyXFunc::getStatus(int ac) const
348 action = lyxaction.retrieveActionArg(ac, argument);
349 return getStatus(action, argument);
353 FuncStatus LyXFunc::getStatus(kb_action action,
354 string const & argument) const
357 Buffer * buf = owner->buffer();
359 if (action == LFUN_UNKNOWN_ACTION) {
360 setStatusMessage(N_("Unknown action"));
361 return flag.unknown(true);
364 // the default error message if we disable the command
365 setStatusMessage(N_("Command disabled"));
367 // Check whether we need a buffer
368 if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) {
369 // Yes we need a buffer, do we have one?
372 // Can we use a readonly buffer?
373 if (buf->isReadonly() &&
374 !lyxaction.funcHasFlag(action,
375 LyXAction::ReadOnly)) {
377 setStatusMessage(N_("Document is read-only"));
382 setStatusMessage(N_("Command not allowed with"
383 "out any document open"));
384 return flag.disabled(true);
388 UpdatableInset * tli = owner->view()->theLockingInset();
390 // I would really like to avoid having this switch and rather try to
391 // encode this in the function itself.
392 bool disable = false;
395 disable = !Exporter::IsExportable(buf, "dvi")
396 || lyxrc.print_command == "none";
399 disable = argument == "fax" &&
400 !Exporter::IsExportable(buf, argument);
403 disable = buf->undostack.empty();
406 disable = buf->redostack.empty();
408 case LFUN_SPELLCHECK:
409 disable = lyxrc.isp_command == "none";
411 #ifndef HAVE_LIBAIKSAURUS
412 case LFUN_THESAURUS_ENTRY:
417 disable = lyxrc.chktex_command == "none";
420 disable = !Exporter::IsExportable(buf, "program");
423 case LFUN_LAYOUT_TABULAR:
425 || (tli->lyxCode() != Inset::TABULAR_CODE
426 && !tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
430 case LFUN_LAYOUT_PARAGRAPH: {
431 Inset * inset = TEXT(false)->cursor.par()->inInset();
432 disable = inset && inset->forceDefaultParagraphs(inset);
436 case LFUN_TABULAR_FEATURE:
440 //ret.disabled(true);
441 if (tli->lyxCode() == Inset::TABULAR_CODE) {
442 ret = static_cast<InsetTabular *>(tli)
443 ->getStatus(argument);
444 } else if (tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
445 ret = static_cast<InsetTabular *>
446 (tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE))
447 ->getStatus(argument);
452 static InsetTabular inset(*owner->buffer(), 1, 1);
456 ret = inset.getStatus(argument);
457 if (ret.onoff(true) || ret.onoff(false))
458 flag.setOnOff(false);
462 case LFUN_VC_REGISTER:
463 disable = buf->lyxvc.inUse();
465 case LFUN_VC_CHECKIN:
466 disable = !buf->lyxvc.inUse() || buf->isReadonly();
468 case LFUN_VC_CHECKOUT:
469 disable = !buf->lyxvc.inUse() || !buf->isReadonly();
473 case LFUN_VC_HISTORY:
474 disable = !buf->lyxvc.inUse();
476 case LFUN_BOOKMARK_GOTO:
477 disable = !owner->view()->
478 isSavedPosition(strToUnsignedInt(argument));
482 case LFUN_INSET_TOGGLE: {
483 LyXText * lt = owner->view()->getLyXText();
484 disable = !(isEditableInset(lt->getInset())
486 && lt->inset_owner->owner()
487 && lt->inset_owner->owner()->isOpen()));
490 case LFUN_MATH_VALIGN:
492 char align = mathcursor->valign();
497 if (argument.empty()) {
501 if (!contains("tcb", argument[0])) {
505 flag.setOnOff(argument[0] == align);
510 case LFUN_MATH_HALIGN:
512 char align = mathcursor->halign();
517 if (argument.empty()) {
521 if (!contains("lcr", argument[0])) {
525 flag.setOnOff(argument[0] == align);
530 case LFUN_MATH_MUTATE:
531 if (tli && (tli->lyxCode() == Inset::MATH_CODE)) {
532 MathInsetTypes type = mathcursor->formula()->getType();
533 if (argument == "inline") {
534 flag.setOnOff(type == LM_OT_SIMPLE);
535 } else if (argument == "display") {
536 flag.setOnOff(type == LM_OT_EQUATION);
537 } else if (argument == "eqnarray") {
538 flag.setOnOff(type == LM_OT_EQNARRAY);
539 } else if (argument == "align") {
540 flag.setOnOff(type == LM_OT_ALIGN);
548 // we just need to be in math mode to enable that
550 case LFUN_MATH_SPACE:
551 case LFUN_MATH_LIMITS:
552 case LFUN_MATH_NONUMBER:
553 case LFUN_MATH_NUMBER:
554 disable = !mathcursor;
557 // we need to be math mode and a math array for that
558 // Hack: halign produces non-zero result iff we are in a math array
559 case LFUN_MATH_ROW_INSERT:
560 case LFUN_MATH_ROW_DELETE:
561 case LFUN_MATH_COLUMN_INSERT:
562 case LFUN_MATH_COLUMN_DELETE:
563 disable = !mathcursor || !mathcursor->halign();
570 // the functions which insert insets
571 Inset::Code code = Inset::NO_CODE;
573 case LFUN_INSET_TEXT:
574 code = Inset::TEXT_CODE;
577 code = Inset::ERT_CODE;
579 case LFUN_INSET_GRAPHICS:
580 code = Inset::GRAPHICS_CODE;
582 case LFUN_INSET_FOOTNOTE:
583 code = Inset::FOOT_CODE;
585 case LFUN_DIALOG_TABULAR_INSERT:
586 case LFUN_INSET_TABULAR:
587 code = Inset::TABULAR_CODE;
589 case LFUN_INSET_EXTERNAL:
590 code = Inset::EXTERNAL_CODE;
592 case LFUN_INSET_MARGINAL:
593 code = Inset::MARGIN_CODE;
595 case LFUN_INSET_MINIPAGE:
596 code = Inset::MINIPAGE_CODE;
598 case LFUN_INSET_FLOAT:
599 case LFUN_INSET_WIDE_FLOAT:
600 code = Inset::FLOAT_CODE;
602 case LFUN_FLOAT_LIST:
603 code = Inset::FLOAT_LIST_CODE;
606 case LFUN_INSET_LIST:
607 code = Inset::LIST_CODE;
609 case LFUN_INSET_THEOREM:
610 code = Inset::THEOREM_CODE;
613 case LFUN_INSET_CAPTION:
614 code = Inset::CAPTION_CODE;
616 case LFUN_INSERT_NOTE:
617 code = Inset::IGNORE_CODE;
619 case LFUN_INSERT_LABEL:
620 code = Inset::LABEL_CODE;
622 case LFUN_REF_INSERT:
623 code = Inset::REF_CODE;
625 case LFUN_CITATION_CREATE:
626 case LFUN_CITATION_INSERT:
627 code = Inset::CITE_CODE;
629 case LFUN_INSERT_BIBTEX:
630 code = Inset::BIBTEX_CODE;
632 case LFUN_INDEX_INSERT:
633 case LFUN_INDEX_INSERT_LAST:
634 case LFUN_INDEX_CREATE:
635 code = Inset::INDEX_CODE;
637 case LFUN_INDEX_PRINT:
638 code = Inset::INDEX_PRINT_CODE;
640 case LFUN_CHILD_INSERT:
641 code = Inset::INCLUDE_CODE;
643 case LFUN_TOC_INSERT:
644 code = Inset::TOC_CODE;
646 case LFUN_PARENTINSERT:
647 code = Inset::PARENT_CODE;
651 case LFUN_INSERT_URL:
652 code = Inset::URL_CODE;
655 // always allow this, since we will inset a raw quote
656 // if an inset is not allowed.
658 case LFUN_HYPHENATION:
659 case LFUN_LIGATURE_BREAK:
661 case LFUN_MENU_SEPARATOR:
663 case LFUN_END_OF_SENTENCE:
664 case LFUN_PROTECTEDSPACE:
665 code = Inset::SPECIALCHAR_CODE;
670 if (code != Inset::NO_CODE && tli && !tli->insetAllowed(code)) {
677 // A few general toggles
679 case LFUN_READ_ONLY_TOGGLE:
680 flag.setOnOff(buf->isReadonly());
683 flag.setOnOff(TEXT(false)->cursor.par()->params().startOfAppendix());
685 case LFUN_SWITCHBUFFER:
686 // toggle on the current buffer, but do not toggle off
687 // the other ones (is that a good idea?)
688 if (argument == buf->fileName())
695 // the font related toggles
697 LyXFont const & font = TEXT(false)->real_current_font;
700 flag.setOnOff(font.emph() == LyXFont::ON);
703 flag.setOnOff(font.noun() == LyXFont::ON);
706 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
709 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
712 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
715 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
722 MathTextCodes tc = mathcursor->getLastCode();
725 flag.setOnOff(tc == LM_TC_BF);
728 flag.setOnOff(tc == LM_TC_SF);
731 flag.setOnOff(tc == LM_TC_CAL);
734 flag.setOnOff(tc == LM_TC_RM);
737 flag.setOnOff(tc == LM_TC_TT);
740 flag.setOnOff(tc == LM_TC_BB);
743 flag.setOnOff(tc == LM_TC_VAR);
754 // temporary dispatch method
755 void LyXFunc::miniDispatch(string const & s)
757 string s2(frontStrip(strip(s)));
760 verboseDispatch(s2, true);
765 void LyXFunc::verboseDispatch(string const & s, bool show_sc)
767 int action = lyxaction.LookupFunc(frontStrip(s));
769 if (action == LFUN_UNKNOWN_ACTION) {
770 string const msg = string(_("Unknown function ("))
774 verboseDispatch(action, show_sc);
779 void LyXFunc::verboseDispatch(int ac, bool show_sc)
784 // get the real action and argument
785 action = lyxaction.retrieveActionArg(ac, argument);
787 verboseDispatch(action, argument, show_sc);
792 void LyXFunc::verboseDispatch(kb_action action,
793 string const & argument, bool show_sc)
795 string res = dispatch(action, argument);
797 commandshortcut.erase();
799 if (lyxrc.display_shortcuts && show_sc) {
800 if (action != LFUN_SELFINSERT) {
801 // Put name of command and list of shortcuts
802 // for it in minibuffer
803 string comname = lyxaction.getActionName(action);
805 int pseudoaction = action;
806 bool argsadded = false;
808 if (!argument.empty()) {
809 // the pseudoaction is useful for the bindings
811 lyxaction.searchActionArg(action,
814 if (pseudoaction == LFUN_UNKNOWN_ACTION) {
815 pseudoaction = action;
817 comname += " " + argument;
822 string const shortcuts =
823 toplevel_keymap->findbinding(pseudoaction);
825 if (!shortcuts.empty()) {
826 comname += ": " + shortcuts;
827 } else if (!argsadded && !argument.empty()) {
828 comname += " " + argument;
831 if (!comname.empty()) {
832 comname = strip(comname);
833 commandshortcut = "(" + comname + ')';
839 if (!commandshortcut.empty()) {
840 owner->getMiniBuffer()->addSet(commandshortcut);
843 owner->getMiniBuffer()->addSet(' ' + commandshortcut);
848 string const LyXFunc::dispatch(kb_action action, string argument)
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 if (owner->view()->available())
867 owner->view()->hideCursor();
869 // We cannot use this function here
870 if (getStatus(action, argument).disabled()) {
871 lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: "
872 << lyxaction.getActionName(action)
873 << " [" << action << "] is disabled at this location"
875 setErrorMessage(getStatusMessage());
876 goto exit_with_message;
879 if (owner->view()->available() && owner->view()->theLockingInset()) {
880 UpdatableInset::RESULT result;
881 if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
882 (!keyseq.deleted())))
884 if ((action == LFUN_UNKNOWN_ACTION)
885 && argument.empty()) {
886 argument = keyseq.getiso();
888 // Undo/Redo is a bit tricky for insets.
889 if (action == LFUN_UNDO) {
890 owner->view()->menuUndo();
891 goto exit_with_message;
892 } else if (action == LFUN_REDO) {
893 owner->view()->menuRedo();
894 goto exit_with_message;
895 } else if (((result=owner->view()->theLockingInset()->
896 // Hand-over to inset's own dispatch:
897 localDispatch(owner->view(), action, argument)) ==
898 UpdatableInset::DISPATCHED) ||
899 (result == UpdatableInset::DISPATCHED_NOUPDATE))
900 goto exit_with_message;
901 // If UNDISPATCHED, just soldier on
902 else if (result == UpdatableInset::FINISHED) {
903 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
904 TEXT()->cursorRight(owner->view());
905 moveCursorUpdate(true, false);
908 goto exit_with_message;
909 } else if (result == UpdatableInset::FINISHED_RIGHT) {
910 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
911 TEXT()->cursorRight(owner->view());
912 moveCursorUpdate(true, false);
915 goto exit_with_message;
916 } else if (result == UpdatableInset::FINISHED_UP) {
917 if (TEXT()->cursor.row()->previous()) {
918 TEXT()->cursorUp(owner->view());
919 moveCursorUpdate(true, false);
922 goto exit_with_message;
923 } else if (result == UpdatableInset::FINISHED_DOWN) {
924 if (TEXT()->cursor.row()->next())
925 TEXT()->cursorDown(owner->view());
927 TEXT()->cursorRight(owner->view());
928 moveCursorUpdate(true, false);
930 goto exit_with_message;
932 //setMessage(N_("Text mode"));
934 case LFUN_UNKNOWN_ACTION:
935 case LFUN_BREAKPARAGRAPH:
937 TEXT()->cursorRight(owner->view());
938 owner->view()->setState();
942 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
943 TEXT()->cursorRight(owner->view());
944 moveCursorUpdate(true, false);
947 goto exit_with_message;
949 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
950 TEXT()->cursorRight(owner->view());
951 moveCursorUpdate(true, false);
954 goto exit_with_message;
956 if (TEXT()->cursor.row()->next())
957 TEXT()->cursorDown(owner->view());
959 TEXT()->cursorRight(owner->view());
960 moveCursorUpdate(true, false);
962 goto exit_with_message;
974 if (!owner->view()->available()) break;
975 // this function should be used always [asierra060396]
976 UpdatableInset * tli =
977 owner->view()->theLockingInset();
979 UpdatableInset * lock = tli->getLockingInset();
982 owner->view()->unlockInset(tli);
983 TEXT()->cursorRight(owner->view());
984 moveCursorUpdate(true, false);
987 tli->unlockInsetInInset(owner->view(),
996 // --- Misc -------------------------------------------
997 case LFUN_WORDFINDFORWARD :
998 case LFUN_WORDFINDBACKWARD : {
999 static string last_search;
1000 string searched_string;
1002 if (!argument.empty()) {
1003 last_search = argument;
1004 searched_string = argument;
1006 searched_string = last_search;
1008 bool fw = (action == LFUN_WORDFINDBACKWARD);
1009 if (!searched_string.empty()) {
1010 LyXFind(owner->view(), searched_string, fw);
1012 // owner->view()->showCursor();
1018 if (owner->view()->available() && !owner->view()->theLockingInset()) {
1019 owner->view()->update(TEXT(),
1020 BufferView::SELECT|BufferView::FITCUR);
1022 owner->message(keyseq.printOptions());
1026 // --- Misc -------------------------------------------
1027 case LFUN_EXEC_COMMAND:
1029 vector<string> allCmds;
1030 transform(lyxaction.func_begin(), lyxaction.func_end(),
1031 back_inserter(allCmds), lyx::firster());
1032 static vector<string> hist;
1033 owner->getMiniBuffer()->getString(MiniBuffer::spaces,
1038 case LFUN_CANCEL: // RVDK_PATCH_5
1041 if (owner->view()->available())
1042 // cancel any selection
1043 dispatch(LFUN_MARK_OFF);
1044 setMessage(N_("Cancel"));
1047 case LFUN_META_FAKE: // RVDK_PATCH_5
1049 meta_fake_bit = Mod1Mask;
1050 setMessage(keyseq.print());
1054 case LFUN_READ_ONLY_TOGGLE:
1055 if (owner->buffer()->lyxvc.inUse()) {
1056 owner->buffer()->lyxvc.toggleReadOnly();
1058 owner->buffer()->setReadonly(
1059 !owner->buffer()->isReadonly());
1063 case LFUN_CENTER: // this is center and redraw.
1064 owner->view()->center();
1067 // --- Menus -----------------------------------------------
1072 case LFUN_MENUNEWTMPLT:
1076 case LFUN_CLOSEBUFFER:
1080 case LFUN_MENUWRITE:
1081 if (!owner->buffer()->isUnnamed()) {
1083 s1 << _("Saving document") << ' '
1084 << MakeDisplayPath(owner->buffer()->fileName() + "...");
1085 owner->message(s1.str().c_str());
1086 MenuWrite(owner->view(), owner->buffer());
1088 WriteAs(owner->view(), owner->buffer());
1092 WriteAs(owner->view(), owner->buffer(), argument);
1095 case LFUN_MENURELOAD:
1100 Exporter::Export(owner->buffer(), argument, true);
1104 Exporter::Preview(owner->buffer(), argument);
1107 case LFUN_BUILDPROG:
1108 Exporter::Export(owner->buffer(), "program", true);
1111 case LFUN_RUNCHKTEX:
1112 MenuRunChktex(owner->buffer());
1115 case LFUN_MENUPRINT:
1116 owner->getDialogs()->showPrint();
1120 if (argument == "custom")
1123 Exporter::Export(owner->buffer(), argument, false);
1141 InsetCommandParams p;
1144 if (action == LFUN_TOCVIEW)
1146 p.setCmdName("tableofcontents");
1148 else if (action == LFUN_LOAVIEW)
1149 p.setCmdName("listof{algorithm}{List of Algorithms}");
1150 else if (action == LFUN_LOFVIEW)
1151 p.setCmdName("listoffigures");
1153 p.setCmdName("listoftables");
1155 owner->getDialogs()->createTOC(p.getAsString());
1159 case LFUN_DIALOG_TABULAR_INSERT:
1160 owner->getDialogs()->showTabularCreate();
1164 AutoSave(owner->view());
1168 owner->view()->menuUndo();
1172 owner->view()->menuRedo();
1175 case LFUN_MENUSEARCH:
1176 owner->getDialogs()->showSearch();
1179 case LFUN_REMOVEERRORS:
1180 if (owner->view()->removeAutoInsets()) {
1181 owner->view()->redraw();
1182 owner->view()->fitCursor();
1187 changeDepth(owner->view(), TEXT(false), 0);
1190 case LFUN_DEPTH_MIN:
1191 changeDepth(owner->view(), TEXT(false), -1);
1194 case LFUN_DEPTH_PLUS:
1195 changeDepth(owner->view(), TEXT(false), 1);
1199 owner->getDialogs()->setUserFreeFont();
1202 case LFUN_RECONFIGURE:
1203 Reconfigure(owner->view());
1207 case LFUN_FLOATSOPERATE:
1208 if (argument == "openfoot")
1209 owner->view()->allFloats(1,0);
1210 else if (argument == "closefoot")
1211 owner->view()->allFloats(0,0);
1212 else if (argument == "openfig")
1213 owner->view()->allFloats(1,1);
1214 else if (argument == "closefig")
1215 owner->view()->allFloats(0,1);
1218 #ifdef WITH_WARNINGS
1219 //#warning Find another implementation here (or another lyxfunc)!
1222 case LFUN_HELP_ABOUTLYX:
1223 owner->getDialogs()->showAboutlyx();
1226 case LFUN_HELP_TEXINFO:
1227 owner->getDialogs()->showTexinfo();
1230 case LFUN_HELP_OPEN:
1232 string const arg = argument;
1234 setErrorMessage(N_("Missing argument"));
1237 owner->prohibitInput();
1238 string const fname = i18nLibFileSearch("doc", arg, "lyx");
1239 if (fname.empty()) {
1240 lyxerr << "LyX: unable to find documentation file `"
1241 << arg << "'. Bad installation?" << endl;
1242 owner->allowInput();
1246 str << _("Opening help file") << ' '
1247 << MakeDisplayPath(fname) << "...";
1248 owner->message(str.str().c_str());
1249 owner->view()->buffer(bufferlist.loadLyXFile(fname, false));
1250 owner->allowInput();
1254 // --- version control -------------------------------
1255 case LFUN_VC_REGISTER:
1257 if (!owner->buffer()->lyxvc.inUse())
1258 owner->buffer()->lyxvc.registrer();
1262 case LFUN_VC_CHECKIN:
1264 if (owner->buffer()->lyxvc.inUse()
1265 && !owner->buffer()->isReadonly())
1266 owner->buffer()->lyxvc.checkIn();
1270 case LFUN_VC_CHECKOUT:
1272 if (owner->buffer()->lyxvc.inUse()
1273 && owner->buffer()->isReadonly())
1274 owner->buffer()->lyxvc.checkOut();
1278 case LFUN_VC_REVERT:
1280 owner->buffer()->lyxvc.revert();
1286 owner->buffer()->lyxvc.undoLast();
1290 case LFUN_VC_HISTORY:
1292 owner->getDialogs()->showVCLogFile();
1296 // --- buffers ----------------------------------------
1298 case LFUN_SWITCHBUFFER:
1299 owner->view()->buffer(bufferlist.getBuffer(argument));
1304 // servercmd: argument must be <file>:<template>
1305 Buffer * tmpbuf = NewLyxFile(argument);
1307 owner->view()->buffer(tmpbuf);
1311 case LFUN_FILE_OPEN:
1315 case LFUN_LATEX_LOG:
1316 owner->getDialogs()->showLogFile();
1319 case LFUN_LAYOUT_DOCUMENT:
1320 owner->getDialogs()->showDocument();
1323 case LFUN_LAYOUT_PARAGRAPH:
1324 owner->getDialogs()->showParagraph();
1327 case LFUN_LAYOUT_CHARACTER:
1328 owner->getDialogs()->showCharacter();
1331 case LFUN_LAYOUT_TABULAR:
1332 if (owner->view()->theLockingInset()) {
1333 if (owner->view()->theLockingInset()->lyxCode()==Inset::TABULAR_CODE) {
1334 InsetTabular * inset = static_cast<InsetTabular *>
1335 (owner->view()->theLockingInset());
1336 inset->openLayoutDialog(owner->view());
1337 } else if (owner->view()->theLockingInset()->
1338 getFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
1339 InsetTabular * inset = static_cast<InsetTabular *>(
1340 owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
1341 inset->openLayoutDialog(owner->view());
1346 case LFUN_LAYOUT_PREAMBLE:
1347 owner->getDialogs()->showPreamble();
1350 case LFUN_DROP_LAYOUTS_CHOICE:
1351 owner->getToolbar()->openLayoutList();
1354 case LFUN_MENU_OPEN_BY_NAME:
1355 owner->getMenubar()->openByName(argument);
1356 break; // RVDK_PATCH_5
1358 case LFUN_SPELLCHECK:
1359 if (lyxrc.isp_command != "none")
1360 owner->getDialogs()->showSpellchecker();
1363 // --- lyxserver commands ----------------------------
1367 setMessage(owner->buffer()->fileName());
1368 lyxerr[Debug::INFO] << "FNAME["
1369 << owner->buffer()->fileName()
1375 dispatch_buffer = keyseq.print();
1376 lyxserver->notifyClient(dispatch_buffer);
1380 case LFUN_GOTOFILEROW:
1384 istringstream istr(argument.c_str());
1385 istr >> file_name >> row;
1386 // Must replace extension of the file to be .lyx and get full path
1387 string const s(ChangeExtension(file_name, ".lyx"));
1389 // Either change buffer or load the file
1390 if (bufferlist.exists(s)) {
1391 owner->view()->buffer(bufferlist.getBuffer(s));
1393 owner->view()->buffer(bufferlist.loadLyXFile(s));
1397 owner->view()->setCursorFromRow(row);
1400 owner->view()->center();
1404 case LFUN_GOTO_PARAGRAPH:
1406 istringstream istr(argument.c_str());
1410 Paragraph * par = owner->buffer()->getParFromID(id);
1412 lyxerr[Debug::INFO] << "No matching paragraph found! ["
1413 << id << "]" << endl;
1416 lyxerr << "Paragraph " << par->id()
1417 << " found." << endl;
1420 if (owner->view()->theLockingInset())
1421 owner->view()->unlockInset(owner->view()->theLockingInset());
1422 if (par->inInset()) {
1423 par->inInset()->edit(owner->view());
1426 owner->view()->getLyXText()->setCursor(owner->view(), par, 0);
1427 owner->view()->setState();
1431 owner->view()->center();
1438 int const qa = lyxaction.LookupFunc(argument);
1439 setMessage(lyxaction.helpText(static_cast<kb_action>(qa)));
1443 // --- toolbar ----------------------------------
1444 case LFUN_PUSH_TOOLBAR:
1446 int nth = strToInt(argument);
1448 setErrorMessage(N_("Push-toolbar needs argument > 0"));
1450 owner->getToolbar()->push(nth);
1455 case LFUN_ADD_TO_TOOLBAR:
1457 if (lyxerr.debugging(Debug::GUI)) {
1458 lyxerr << "LFUN_ADD_TO_TOOLBAR:"
1459 "argument = `" << argument << '\'' << endl;
1461 string tmp(argument);
1462 //lyxerr <<string("Argument: ") + argument);
1463 //lyxerr <<string("Tmp : ") + tmp);
1465 setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
1467 owner->getToolbar()->add(argument, false);
1468 owner->getToolbar()->set();
1473 // --- insert characters ----------------------------------------
1475 // --- Mathed stuff. If we are here, there is no locked inset yet.
1476 case LFUN_MATH_EXTERN:
1477 case LFUN_MATH_NUMBER:
1478 case LFUN_MATH_NONUMBER:
1479 case LFUN_MATH_LIMITS:
1481 setErrorMessage(N_("This is only allowed in math mode!"));
1485 // passthrough hat and underscore outside mathed:
1486 case LFUN_SUBSCRIPT:
1487 dispatch(LFUN_SELFINSERT, "_");
1489 case LFUN_SUPERSCRIPT:
1490 dispatch(LFUN_SELFINSERT, "^");
1493 case LFUN_MATH_PANEL:
1494 owner->getDialogs()->showMathPanel();
1497 case LFUN_CITATION_CREATE:
1499 InsetCommandParams p("cite");
1501 if (!argument.empty()) {
1502 // This should be set at source, ie when typing
1503 // "citation-insert foo" in the minibuffer.
1504 // Question: would pybibliographer also need to be
1505 // changed. Suspect so. Leave as-is therefore.
1506 if (contains(argument, "|")) {
1507 p.setContents(token(argument, '|', 0));
1508 p.setOptions( token(argument, '|', 1));
1510 p.setContents(argument);
1512 dispatch(LFUN_CITATION_INSERT, p.getAsString());
1514 owner->getDialogs()->createCitation(p.getAsString());
1518 case LFUN_CHILDOPEN:
1520 string const filename =
1521 MakeAbsPath(argument,
1522 owner->buffer()->filePath());
1523 setMessage(N_("Opening child document ") +
1524 MakeDisplayPath(filename) + "...");
1525 owner->view()->savePosition(0);
1526 if (bufferlist.exists(filename))
1527 owner->view()->buffer(bufferlist.getBuffer(filename));
1529 owner->view()->buffer(bufferlist.loadLyXFile(filename));
1533 case LFUN_TOGGLECURSORFOLLOW:
1534 lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
1537 case LFUN_KMAP_OFF: // keymap off
1538 owner->getIntl()->KeyMapOn(false);
1541 case LFUN_KMAP_PRIM: // primary keymap
1542 owner->getIntl()->KeyMapPrim();
1545 case LFUN_KMAP_SEC: // secondary keymap
1546 owner->getIntl()->KeyMapSec();
1549 case LFUN_KMAP_TOGGLE: // toggle keymap
1550 owner->getIntl()->ToggleKeyMap();
1555 // argument contains ';'-terminated commands
1556 while (argument.find(';') != string::npos) {
1558 argument = split(argument, first, ';');
1559 verboseDispatch(first, false);
1564 case LFUN_DIALOG_PREFERENCES:
1565 owner->getDialogs()->showPreferences();
1568 case LFUN_SAVEPREFERENCES:
1570 Path p(user_lyxdir);
1571 lyxrc.write("preferences");
1575 case LFUN_SCREEN_FONT_UPDATE:
1577 // handle the screen font changes.
1579 lyxrc.set_font_norm_type();
1580 fontloader.update();
1581 // Of course we should only do the resize and the textcache.clear
1582 // if values really changed...but not very important right now. (Lgb)
1583 // All visible buffers will need resize
1585 // We also need to empty the textcache so that
1586 // the buffer will be formatted correctly after
1592 case LFUN_SET_COLOR:
1595 string const x11_name = split(argument, lyx_name, ' ');
1596 if (lyx_name.empty() || x11_name.empty()) {
1597 setErrorMessage(N_("Syntax: set-color <lyx_name>"
1602 bool const graphicsbg_changed =
1603 (lyx_name == lcolor.getLyXName(LColor::graphicsbg) &&
1604 x11_name != lcolor.getX11Name(LColor::graphicsbg));
1606 if (!lcolor.setColor(lyx_name, x11_name)) {
1607 static string const err1 (N_("Set-color \""));
1608 static string const err2 (
1609 N_("\" failed - color is undefined "
1610 "or may not be redefined"));
1611 setErrorMessage(_(err1) + lyx_name + _(err2));
1615 lyxColorHandler->updateColor(lcolor.getFromLyXName(lyx_name));
1617 if (graphicsbg_changed) {
1618 grfx::GCache & gc = grfx::GCache::get();
1619 gc.changeDisplay(true);
1622 owner->view()->redraw();
1627 owner->message(argument);
1630 case LFUN_MESSAGE_PUSH:
1631 owner->messagePush(argument);
1634 case LFUN_MESSAGE_POP:
1635 owner->messagePop();
1638 case LFUN_FORKS_SHOW:
1639 owner->getDialogs()->showForks();
1642 case LFUN_FORKS_KILL:
1644 if (!isStrInt(argument))
1647 pid_t const pid = strToInt(argument);
1648 ForkedcallsController & fcc = ForkedcallsController::get();
1654 // Then if it was none of the above
1655 // Trying the BufferView::pimpl dispatch:
1656 if (!owner->view()->Dispatch(action, argument))
1657 lyxerr << "A truly unknown func ["
1658 << lyxaction.getActionName(action) << "]!"
1665 string const res = getMessage();
1668 owner->message(_(res));
1669 owner->updateMenubar();
1670 owner->updateToolbar();
1676 void LyXFunc::setupLocalKeymap()
1678 keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
1679 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap.get();
1683 void LyXFunc::menuNew(bool fromTemplate)
1685 string initpath = lyxrc.document_path;
1687 if (owner->view()->available()) {
1688 string const trypath = owner->buffer()->filePath();
1689 // If directory is writeable, use this as default.
1690 if (IsDirWriteable(trypath))
1694 static int newfile_number;
1697 if (lyxrc.new_ask_filename) {
1698 FileDialog fileDlg(owner, _("Enter filename for new document"),
1699 LFUN_SELECT_FILE_SYNC,
1700 make_pair(string(_("Documents|#o#O")),
1701 string(lyxrc.document_path)),
1702 make_pair(string(_("Templates|#T#t")),
1703 string(lyxrc.template_path)));
1705 FileDialog::Result result =
1706 fileDlg.Select(initpath,
1707 _("*.lyx|LyX Documents (*.lyx)"),
1710 if (result.second.empty()) {
1711 owner->message(_("Canceled."));
1712 lyxerr[Debug::INFO] << "New Document Cancelled." << endl;
1716 // get absolute path of file and make sure the filename ends
1718 s = MakeAbsPath(result.second);
1719 if (!IsLyXFilename(s))
1722 // Check if the document already is open
1723 if (bufferlist.exists(s)) {
1724 switch (Alert::askConfirmation(_("Document is already open:"),
1725 MakeDisplayPath(s, 50),
1726 _("Do you want to close that document now?\n"
1727 "('No' will just switch to the open version)")))
1729 case 1: // Yes: close the document
1730 if (!bufferlist.close(bufferlist.getBuffer(s)))
1731 // If close is canceled, we cancel here too.
1734 case 2: // No: switch to the open document
1735 owner->view()->buffer(bufferlist.getBuffer(s));
1737 case 3: // Cancel: Do nothing
1738 owner->message(_("Canceled."));
1742 // Check whether the file already exists
1744 if (fi.readable() &&
1745 Alert::askQuestion(_("File already exists:"),
1746 MakeDisplayPath(s, 50),
1747 _("Do you want to open the document?"))) {
1749 string const disp_fn(MakeDisplayPath(s));
1752 str << _("Opening document") << ' '
1753 << disp_fn << "...";
1755 owner->message(str.str().c_str());
1756 //XFlush(fl_get_display());
1757 owner->view()->buffer(bufferlist.loadLyXFile(s));
1759 str2 << _("Document") << ' '
1760 << disp_fn << ' ' << _("opened.");
1762 owner->message(str2.str().c_str());
1767 s = AddName(lyxrc.document_path,
1768 "newfile" + tostr(++newfile_number) + ".lyx");
1770 while (bufferlist.exists(s) || fi.readable()) {
1772 s = AddName(lyxrc.document_path,
1773 "newfile" + tostr(newfile_number) +
1779 // The template stuff
1782 FileDialog fileDlg(owner, _("Select template file"),
1783 LFUN_SELECT_FILE_SYNC,
1784 make_pair(string(_("Documents|#o#O")),
1785 string(lyxrc.document_path)),
1786 make_pair(string(_("Templates|#T#t")),
1787 string(lyxrc.template_path)));
1789 FileDialog::Result result =
1790 fileDlg.Select(lyxrc.template_path,
1791 _("*.lyx|LyX Documents (*.lyx)"));
1793 if (result.first == FileDialog::Later)
1796 string const fname = result.second;
1803 // find a free buffer
1804 lyxerr[Debug::INFO] << "Find a free buffer." << endl;
1805 owner->view()->buffer(bufferlist.newFile(s, templname));
1809 void LyXFunc::open(string const & fname)
1811 string initpath = lyxrc.document_path;
1813 if (owner->view()->available()) {
1814 string const trypath = owner->buffer()->filePath();
1815 // If directory is writeable, use this as default.
1816 if (IsDirWriteable(trypath))
1822 if (fname.empty()) {
1823 FileDialog fileDlg(owner, _("Select document to open"),
1825 make_pair(string(_("Documents|#o#O")),
1826 string(lyxrc.document_path)),
1827 make_pair(string(_("Examples|#E#e")),
1828 string(AddPath(system_lyxdir, "examples"))));
1830 FileDialog::Result result =
1831 fileDlg.Select(initpath,
1832 "*.lyx|LyX Documents (*.lyx)");
1834 if (result.first == FileDialog::Later)
1837 filename = result.second;
1839 // check selected filename
1840 if (filename.empty()) {
1841 owner->message(_("Canceled."));
1847 // get absolute path of file and add ".lyx" to the filename if
1849 string const fullpath = FileSearch(string(), filename, "lyx");
1850 if (fullpath.empty()) {
1851 Alert::alert(_("Error"), _("Could not find file"), filename);
1855 filename = fullpath;
1858 string const disp_fn(MakeDisplayPath(filename));
1861 str << _("Opening document") << ' ' << disp_fn << "...";
1863 owner->message(str.str().c_str());
1865 Buffer * openbuf = bufferlist.loadLyXFile(filename);
1867 owner->view()->buffer(openbuf);
1869 str << _("Document") << ' ' << disp_fn << ' ' << _("opened.");
1870 owner->message(str.str().c_str());
1873 str << _("Could not open document") << ' ' << disp_fn;
1874 owner->message(str.str().c_str());
1879 // checks for running without gui are missing.
1880 void LyXFunc::doImport(string const & argument)
1883 string filename = split(argument, format, ' ');
1884 lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format
1885 << " file: " << filename << endl;
1887 if (filename.empty()) { // need user interaction
1888 string initpath = lyxrc.document_path;
1890 if (owner->view()->available()) {
1891 string const trypath = owner->buffer()->filePath();
1892 // If directory is writeable, use this as default.
1893 if (IsDirWriteable(trypath))
1897 string const text = _("Select ") + formats.prettyName(format)
1898 + _(" file to import");
1900 FileDialog fileDlg(owner, text,
1902 make_pair(string(_("Documents|#o#O")),
1903 string(lyxrc.document_path)),
1904 make_pair(string(_("Examples|#E#e")),
1905 string(AddPath(system_lyxdir, "examples"))));
1907 string const extension = "*." + formats.extension(format)
1908 + "| " + formats.prettyName(format)
1909 + " (*." + formats.extension(format) + ")";
1911 FileDialog::Result result = fileDlg.Select(initpath,
1914 if (result.first == FileDialog::Later)
1917 filename = result.second;
1919 // check selected filename
1920 if (filename.empty())
1921 owner->message(_("Canceled."));
1924 // still no filename? abort
1925 if (filename.empty())
1928 // get absolute path of file
1929 filename = MakeAbsPath(filename);
1931 string const lyxfile = ChangeExtension(filename, ".lyx");
1933 // Check if the document already is open
1934 if (bufferlist.exists(lyxfile)) {
1935 switch (Alert::askConfirmation(_("Document is already open:"),
1936 MakeDisplayPath(lyxfile, 50),
1937 _("Do you want to close that document now?\n"
1938 "('No' will just switch to the open version)")))
1940 case 1: // Yes: close the document
1941 if (!bufferlist.close(bufferlist.getBuffer(lyxfile)))
1942 // If close is canceled, we cancel here too.
1945 case 2: // No: switch to the open document
1946 owner->view()->buffer(bufferlist.getBuffer(lyxfile));
1948 case 3: // Cancel: Do nothing
1949 owner->message(_("Canceled."));
1954 // Check if a LyX document by the same root exists in filesystem
1955 FileInfo const f(lyxfile, true);
1956 if (f.exist() && !Alert::askQuestion(_("A document by the name"),
1957 MakeDisplayPath(lyxfile),
1958 _("already exists. Overwrite?"))) {
1959 owner->message(_("Canceled"));
1962 // filename should be valid now
1964 Importer::Import(owner, filename, format);
1968 void LyXFunc::reloadBuffer()
1970 string const fn = owner->buffer()->fileName();
1971 if (bufferlist.close(owner->buffer()))
1972 owner->view()->buffer(bufferlist.loadLyXFile(fn));
1976 void LyXFunc::closeBuffer()
1978 if (bufferlist.close(owner->buffer()) && !quitting) {
1979 if (bufferlist.empty()) {
1980 // need this otherwise SEGV may occur while trying to
1981 // set variables that don't exist
1982 // since there's no current buffer
1983 owner->getDialogs()->hideBufferDependent();
1985 owner->view()->buffer(bufferlist.first());
1991 // Each "owner" should have it's own message method. lyxview and
1992 // the minibuffer would use the minibuffer, but lyxserver would
1993 // send an ERROR signal to its client. Alejandro 970603
1994 // This func is bit problematic when it comes to NLS, to make the
1995 // lyx servers client be language indepenent we must not translate
1996 // strings sent to this func.
1997 void LyXFunc::setErrorMessage(string const & m) const
1999 dispatch_buffer = m;
2004 void LyXFunc::setMessage(string const & m) const
2006 dispatch_buffer = m;
2010 void LyXFunc::setStatusMessage(string const & m) const
2016 void LyXFunc::initMiniBuffer()
2018 string text = _("Welcome to LyX!");
2020 // When meta-fake key is pressed, show the key sequence so far + "M-".
2022 text = keyseq.print();
2026 // Else, when a non-complete key sequence is pressed,
2027 // show the available options.
2028 if (keyseq.length() > 0 && !keyseq.deleted()) {
2029 text = keyseq.printOptions();
2032 // Else, show the buffer state.
2033 else if (owner->view()->available()) {
2034 Buffer * tmpbuf = owner->buffer();
2036 string const nicename =
2037 MakeDisplayPath(tmpbuf->fileName());
2038 // Should we do this instead? (kindo like emacs)
2039 // leaves more room for other information
2042 if (tmpbuf->lyxvc.inUse()) {
2044 text += tmpbuf->lyxvc.versionString();
2046 text += tmpbuf->lyxvc.locker();
2047 if (tmpbuf->isReadonly())
2050 } else if (tmpbuf->isReadonly())
2052 if (!tmpbuf->isLyxClean())
2053 text += _(" (Changed)");
2055 if (text != _("Welcome to LyX!")) // this is a hack
2056 text = _("* No document open *");
2059 owner->message(text);