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"
51 #include "figureForm.h"
53 #include "insets/inseturl.h"
54 #include "insets/insetlatexaccent.h"
55 #include "insets/insettoc.h"
56 #include "insets/insetref.h"
57 #include "insets/insetparent.h"
58 #include "insets/insetindex.h"
59 #include "insets/insetinclude.h"
60 #include "insets/insetbib.h"
61 #include "insets/insetcite.h"
62 #include "insets/insettext.h"
63 #include "insets/insetert.h"
64 #include "insets/insetexternal.h"
65 #include "insets/insetgraphics.h"
66 #include "insets/insetfoot.h"
67 #include "insets/insetmarginal.h"
68 #include "insets/insetminipage.h"
69 #include "insets/insetfloat.h"
71 #include "insets/insetlist.h"
72 #include "insets/insettheorem.h"
74 #include "insets/insettabular.h"
75 #include "insets/insetcaption.h"
77 #include "mathed/formulamacro.h"
78 #include "mathed/math_cursor.h"
79 #include "mathed/math_inset.h"
81 #include "frontends/FileDialog.h"
82 #include "frontends/Dialogs.h"
83 #include "frontends/Toolbar.h"
84 #include "frontends/Menubar.h"
85 #include "frontends/Alert.h"
87 #include "support/lyxalgo.h"
88 #include "support/LAssert.h"
89 #include "support/filetools.h"
90 #include "support/FileInfo.h"
91 #include "support/syscall.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 && !keyseq.deleted()) {
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;
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();
1169 AutoSave(owner->view());
1173 owner->view()->menuUndo();
1177 owner->view()->menuRedo();
1180 case LFUN_MENUSEARCH:
1181 owner->getDialogs()->showSearch();
1184 case LFUN_REMOVEERRORS:
1185 if (owner->view()->removeAutoInsets()) {
1186 owner->view()->redraw();
1187 owner->view()->fitCursor();
1192 changeDepth(owner->view(), TEXT(false), 0);
1195 case LFUN_DEPTH_MIN:
1196 changeDepth(owner->view(), TEXT(false), -1);
1199 case LFUN_DEPTH_PLUS:
1200 changeDepth(owner->view(), TEXT(false), 1);
1204 owner->getDialogs()->setUserFreeFont();
1207 case LFUN_RECONFIGURE:
1208 Reconfigure(owner->view());
1212 case LFUN_FLOATSOPERATE:
1213 if (argument == "openfoot")
1214 owner->view()->allFloats(1,0);
1215 else if (argument == "closefoot")
1216 owner->view()->allFloats(0,0);
1217 else if (argument == "openfig")
1218 owner->view()->allFloats(1,1);
1219 else if (argument == "closefig")
1220 owner->view()->allFloats(0,1);
1223 #ifdef WITH_WARNINGS
1224 //#warning Find another implementation here (or another lyxfunc)!
1227 case LFUN_HELP_ABOUTLYX:
1228 owner->getDialogs()->showAboutlyx();
1231 case LFUN_HELP_TEXINFO:
1232 owner->getDialogs()->showTexinfo();
1235 case LFUN_HELP_OPEN:
1237 string const arg = argument;
1239 setErrorMessage(N_("Missing argument"));
1242 owner->prohibitInput();
1243 string const fname = i18nLibFileSearch("doc", arg, "lyx");
1244 if (fname.empty()) {
1245 lyxerr << "LyX: unable to find documentation file `"
1246 << arg << "'. Bad installation?" << endl;
1247 owner->allowInput();
1251 str << _("Opening help file") << ' '
1252 << MakeDisplayPath(fname) << "...";
1253 owner->message(str.str().c_str());
1254 owner->view()->buffer(bufferlist.loadLyXFile(fname, false));
1255 owner->allowInput();
1259 // --- version control -------------------------------
1260 case LFUN_VC_REGISTER:
1262 if (!owner->buffer()->lyxvc.inUse())
1263 owner->buffer()->lyxvc.registrer();
1267 case LFUN_VC_CHECKIN:
1269 if (owner->buffer()->lyxvc.inUse()
1270 && !owner->buffer()->isReadonly())
1271 owner->buffer()->lyxvc.checkIn();
1275 case LFUN_VC_CHECKOUT:
1277 if (owner->buffer()->lyxvc.inUse()
1278 && owner->buffer()->isReadonly())
1279 owner->buffer()->lyxvc.checkOut();
1283 case LFUN_VC_REVERT:
1285 owner->buffer()->lyxvc.revert();
1291 owner->buffer()->lyxvc.undoLast();
1295 case LFUN_VC_HISTORY:
1297 owner->getDialogs()->showVCLogFile();
1301 // --- buffers ----------------------------------------
1303 case LFUN_SWITCHBUFFER:
1304 owner->view()->buffer(bufferlist.getBuffer(argument));
1309 // servercmd: argument must be <file>:<template>
1310 Buffer * tmpbuf = NewLyxFile(argument);
1312 owner->view()->buffer(tmpbuf);
1316 case LFUN_FILE_OPEN:
1320 case LFUN_LATEX_LOG:
1321 owner->getDialogs()->showLogFile();
1324 case LFUN_LAYOUT_DOCUMENT:
1325 owner->getDialogs()->showDocument();
1328 case LFUN_LAYOUT_PARAGRAPH:
1329 owner->getDialogs()->showParagraph();
1332 case LFUN_LAYOUT_CHARACTER:
1333 owner->getDialogs()->showCharacter();
1336 case LFUN_LAYOUT_TABULAR:
1337 if (owner->view()->theLockingInset()) {
1338 if (owner->view()->theLockingInset()->lyxCode()==Inset::TABULAR_CODE) {
1339 InsetTabular * inset = static_cast<InsetTabular *>
1340 (owner->view()->theLockingInset());
1341 inset->openLayoutDialog(owner->view());
1342 } else if (owner->view()->theLockingInset()->
1343 getFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
1344 InsetTabular * inset = static_cast<InsetTabular *>(
1345 owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
1346 inset->openLayoutDialog(owner->view());
1351 case LFUN_LAYOUT_PREAMBLE:
1352 owner->getDialogs()->showPreamble();
1355 case LFUN_DROP_LAYOUTS_CHOICE:
1356 owner->getToolbar()->openLayoutList();
1359 case LFUN_MENU_OPEN_BY_NAME:
1360 owner->getMenubar()->openByName(argument);
1361 break; // RVDK_PATCH_5
1363 case LFUN_SPELLCHECK:
1364 if (lyxrc.isp_command != "none")
1365 owner->getDialogs()->showSpellchecker();
1368 // --- lyxserver commands ----------------------------
1372 setMessage(owner->buffer()->fileName());
1373 lyxerr[Debug::INFO] << "FNAME["
1374 << owner->buffer()->fileName()
1380 dispatch_buffer = keyseq.print();
1381 lyxserver->notifyClient(dispatch_buffer);
1385 case LFUN_GOTOFILEROW:
1389 istringstream istr(argument.c_str());
1390 istr >> file_name >> row;
1391 // Must replace extension of the file to be .lyx and get full path
1392 string const s(ChangeExtension(file_name, ".lyx"));
1394 // Either change buffer or load the file
1395 if (bufferlist.exists(s)) {
1396 owner->view()->buffer(bufferlist.getBuffer(s));
1398 owner->view()->buffer(bufferlist.loadLyXFile(s));
1402 owner->view()->setCursorFromRow(row);
1405 owner->view()->center();
1409 case LFUN_GOTO_PARAGRAPH:
1411 istringstream istr(argument.c_str());
1415 Paragraph * par = owner->buffer()->getParFromID(id);
1417 lyxerr[Debug::INFO] << "No matching paragraph found! ["
1418 << id << "]" << endl;
1421 lyxerr << "Paragraph " << par->id()
1422 << " found." << endl;
1425 if (owner->view()->theLockingInset())
1426 owner->view()->unlockInset(owner->view()->theLockingInset());
1427 if (par->inInset()) {
1428 par->inInset()->edit(owner->view());
1431 owner->view()->getLyXText()->setCursor(owner->view(), par, 0);
1432 owner->view()->setState();
1436 owner->view()->center();
1443 int const qa = lyxaction.LookupFunc(argument);
1444 setMessage(lyxaction.helpText(static_cast<kb_action>(qa)));
1448 // --- toolbar ----------------------------------
1449 case LFUN_PUSH_TOOLBAR:
1451 int nth = strToInt(argument);
1453 setErrorMessage(N_("Push-toolbar needs argument > 0"));
1455 owner->getToolbar()->push(nth);
1460 case LFUN_ADD_TO_TOOLBAR:
1462 if (lyxerr.debugging(Debug::GUI)) {
1463 lyxerr << "LFUN_ADD_TO_TOOLBAR:"
1464 "argument = `" << argument << '\'' << endl;
1466 string tmp(argument);
1467 //lyxerr <<string("Argument: ") + argument);
1468 //lyxerr <<string("Tmp : ") + tmp);
1470 setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
1472 owner->getToolbar()->add(argument, false);
1473 owner->getToolbar()->set();
1478 // --- insert characters ----------------------------------------
1480 // --- Mathed stuff. If we are here, there is no locked inset yet.
1481 case LFUN_MATH_EXTERN:
1482 case LFUN_MATH_NUMBER:
1483 case LFUN_MATH_NONUMBER:
1484 case LFUN_MATH_LIMITS:
1486 setErrorMessage(N_("This is only allowed in math mode!"));
1490 // passthrough hat and underscore outside mathed:
1491 case LFUN_SUBSCRIPT:
1492 dispatch(LFUN_SELFINSERT, "_");
1494 case LFUN_SUPERSCRIPT:
1495 dispatch(LFUN_SELFINSERT, "^");
1498 case LFUN_MATH_PANEL:
1499 owner->getDialogs()->showMathPanel();
1502 case LFUN_CITATION_CREATE:
1504 InsetCommandParams p("cite");
1506 if (!argument.empty()) {
1507 // This should be set at source, ie when typing
1508 // "citation-insert foo" in the minibuffer.
1509 // Question: would pybibliographer also need to be
1510 // changed. Suspect so. Leave as-is therefore.
1511 if (contains(argument, "|")) {
1512 p.setContents(token(argument, '|', 0));
1513 p.setOptions( token(argument, '|', 1));
1515 p.setContents(argument);
1517 dispatch(LFUN_CITATION_INSERT, p.getAsString());
1519 owner->getDialogs()->createCitation(p.getAsString());
1523 case LFUN_CHILDOPEN:
1525 string const filename =
1526 MakeAbsPath(argument,
1527 owner->buffer()->filePath());
1528 setMessage(N_("Opening child document ") +
1529 MakeDisplayPath(filename) + "...");
1530 owner->view()->savePosition(0);
1531 if (bufferlist.exists(filename))
1532 owner->view()->buffer(bufferlist.getBuffer(filename));
1534 owner->view()->buffer(bufferlist.loadLyXFile(filename));
1538 case LFUN_TOGGLECURSORFOLLOW:
1539 lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
1542 case LFUN_KMAP_OFF: // keymap off
1543 owner->getIntl()->KeyMapOn(false);
1546 case LFUN_KMAP_PRIM: // primary keymap
1547 owner->getIntl()->KeyMapPrim();
1550 case LFUN_KMAP_SEC: // secondary keymap
1551 owner->getIntl()->KeyMapSec();
1554 case LFUN_KMAP_TOGGLE: // toggle keymap
1555 owner->getIntl()->ToggleKeyMap();
1560 // argument contains ';'-terminated commands
1561 while (argument.find(';') != string::npos) {
1563 argument = split(argument, first, ';');
1564 verboseDispatch(first, false);
1569 case LFUN_DIALOG_PREFERENCES:
1570 owner->getDialogs()->showPreferences();
1573 case LFUN_SAVEPREFERENCES:
1575 Path p(user_lyxdir);
1576 lyxrc.write("preferences");
1580 case LFUN_SCREEN_FONT_UPDATE:
1582 // handle the screen font changes.
1584 lyxrc.set_font_norm_type();
1585 fontloader.update();
1586 // Of course we should only do the resize and the textcache.clear
1587 // if values really changed...but not very important right now. (Lgb)
1588 // All visible buffers will need resize
1590 // We also need to empty the textcache so that
1591 // the buffer will be formatted correctly after
1597 case LFUN_SET_COLOR:
1600 string const x11_name = split(argument, lyx_name, ' ');
1601 if (lyx_name.empty() || x11_name.empty()) {
1602 setErrorMessage(N_("Syntax: set-color <lyx_name>"
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));
1615 lyxColorHandler->updateColor(lcolor.getFromLyXName(lyx_name));
1616 owner->view()->redraw();
1621 owner->message(argument);
1624 case LFUN_MESSAGE_PUSH:
1625 owner->messagePush(argument);
1628 case LFUN_MESSAGE_POP:
1629 owner->messagePop();
1633 // Then if it was none of the above
1634 // Trying the BufferView::pimpl dispatch:
1635 if (!owner->view()->Dispatch(action, argument))
1636 lyxerr << "A truly unknown func ["
1637 << lyxaction.getActionName(action) << "]!"
1644 string const res = getMessage();
1647 owner->message(_(res));
1648 owner->updateMenubar();
1649 owner->updateToolbar();
1655 void LyXFunc::setupLocalKeymap()
1657 keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
1658 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap.get();
1662 void LyXFunc::menuNew(bool fromTemplate)
1664 string initpath = lyxrc.document_path;
1666 if (owner->view()->available()) {
1667 string const trypath = owner->buffer()->filePath();
1668 // If directory is writeable, use this as default.
1669 if (IsDirWriteable(trypath))
1673 static int newfile_number;
1676 if (lyxrc.new_ask_filename) {
1677 FileDialog fileDlg(owner, _("Enter filename for new document"),
1678 LFUN_SELECT_FILE_SYNC,
1679 make_pair(string(_("Documents|#o#O")),
1680 string(lyxrc.document_path)),
1681 make_pair(string(_("Templates|#T#t")),
1682 string(lyxrc.template_path)));
1684 FileDialog::Result result =
1685 fileDlg.Select(initpath,
1686 _("*.lyx|LyX Documents (*.lyx)"),
1689 if (result.second.empty()) {
1690 owner->message(_("Canceled."));
1691 lyxerr[Debug::INFO] << "New Document Cancelled." << endl;
1695 // get absolute path of file and make sure the filename ends
1697 s = MakeAbsPath(result.second);
1698 if (!IsLyXFilename(s))
1701 // Check if the document already is open
1702 if (bufferlist.exists(s)) {
1703 switch (Alert::askConfirmation(_("Document is already open:"),
1704 MakeDisplayPath(s, 50),
1705 _("Do you want to close that document now?\n"
1706 "('No' will just switch to the open version)")))
1708 case 1: // Yes: close the document
1709 if (!bufferlist.close(bufferlist.getBuffer(s)))
1710 // If close is canceled, we cancel here too.
1713 case 2: // No: switch to the open document
1714 owner->view()->buffer(bufferlist.getBuffer(s));
1716 case 3: // Cancel: Do nothing
1717 owner->message(_("Canceled."));
1721 // Check whether the file already exists
1723 if (fi.readable() &&
1724 Alert::askQuestion(_("File already exists:"),
1725 MakeDisplayPath(s, 50),
1726 _("Do you want to open the document?"))) {
1728 string const disp_fn(MakeDisplayPath(s));
1731 str << _("Opening document") << ' '
1732 << disp_fn << "...";
1734 owner->message(str.str().c_str());
1735 //XFlush(fl_get_display());
1736 owner->view()->buffer(bufferlist.loadLyXFile(s));
1738 str2 << _("Document") << ' '
1739 << disp_fn << ' ' << _("opened.");
1741 owner->message(str2.str().c_str());
1746 s = AddName(lyxrc.document_path,
1747 "newfile" + tostr(++newfile_number) + ".lyx");
1749 while (bufferlist.exists(s) || fi.readable()) {
1751 s = AddName(lyxrc.document_path,
1752 "newfile" + tostr(newfile_number) +
1758 // The template stuff
1761 FileDialog fileDlg(owner, _("Select template file"),
1762 LFUN_SELECT_FILE_SYNC,
1763 make_pair(string(_("Documents|#o#O")),
1764 string(lyxrc.document_path)),
1765 make_pair(string(_("Templates|#T#t")),
1766 string(lyxrc.template_path)));
1768 FileDialog::Result result =
1769 fileDlg.Select(lyxrc.template_path,
1770 _("*.lyx|LyX Documents (*.lyx)"));
1772 if (result.first == FileDialog::Later)
1775 string const fname = result.second;
1782 // find a free buffer
1783 lyxerr[Debug::INFO] << "Find a free buffer." << endl;
1784 owner->view()->buffer(bufferlist.newFile(s, templname));
1788 void LyXFunc::open(string const & fname)
1790 string initpath = lyxrc.document_path;
1792 if (owner->view()->available()) {
1793 string const trypath = owner->buffer()->filePath();
1794 // If directory is writeable, use this as default.
1795 if (IsDirWriteable(trypath))
1801 if (fname.empty()) {
1802 FileDialog fileDlg(owner, _("Select document to open"),
1804 make_pair(string(_("Documents|#o#O")),
1805 string(lyxrc.document_path)),
1806 make_pair(string(_("Examples|#E#e")),
1807 string(AddPath(system_lyxdir, "examples"))));
1809 FileDialog::Result result =
1810 fileDlg.Select(initpath,
1811 "*.lyx|LyX Documents (*.lyx)");
1813 if (result.first == FileDialog::Later)
1816 filename = result.second;
1818 // check selected filename
1819 if (filename.empty()) {
1820 owner->message(_("Canceled."));
1826 // get absolute path of file and add ".lyx" to the filename if
1828 string const fullpath = FileSearch(string(), filename, "lyx");
1829 if (fullpath.empty()) {
1830 Alert::alert(_("Error"), _("Could not find file"), filename);
1834 filename = fullpath;
1837 string const disp_fn(MakeDisplayPath(filename));
1840 str << _("Opening document") << ' ' << disp_fn << "...";
1842 owner->message(str.str().c_str());
1844 Buffer * openbuf = bufferlist.loadLyXFile(filename);
1846 owner->view()->buffer(openbuf);
1848 str << _("Document") << ' ' << disp_fn << ' ' << _("opened.");
1849 owner->message(str.str().c_str());
1852 str << _("Could not open document") << ' ' << disp_fn;
1853 owner->message(str.str().c_str());
1858 // checks for running without gui are missing.
1859 void LyXFunc::doImport(string const & argument)
1862 string filename = split(argument, format, ' ');
1863 lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format
1864 << " file: " << filename << endl;
1866 if (filename.empty()) { // need user interaction
1867 string initpath = lyxrc.document_path;
1869 if (owner->view()->available()) {
1870 string const trypath = owner->buffer()->filePath();
1871 // If directory is writeable, use this as default.
1872 if (IsDirWriteable(trypath))
1876 string const text = _("Select ") + formats.prettyName(format)
1877 + _(" file to import");
1879 FileDialog fileDlg(owner, text,
1881 make_pair(string(_("Documents|#o#O")),
1882 string(lyxrc.document_path)),
1883 make_pair(string(_("Examples|#E#e")),
1884 string(AddPath(system_lyxdir, "examples"))));
1886 string const extension = "*." + formats.extension(format)
1887 + "| " + formats.prettyName(format)
1888 + " (*." + formats.extension(format) + ")";
1890 FileDialog::Result result = fileDlg.Select(initpath,
1893 if (result.first == FileDialog::Later)
1896 filename = result.second;
1898 // check selected filename
1899 if (filename.empty())
1900 owner->message(_("Canceled."));
1903 // still no filename? abort
1904 if (filename.empty())
1907 // get absolute path of file
1908 filename = MakeAbsPath(filename);
1910 string const lyxfile = ChangeExtension(filename, ".lyx");
1912 // Check if the document already is open
1913 if (bufferlist.exists(lyxfile)) {
1914 switch (Alert::askConfirmation(_("Document is already open:"),
1915 MakeDisplayPath(lyxfile, 50),
1916 _("Do you want to close that document now?\n"
1917 "('No' will just switch to the open version)")))
1919 case 1: // Yes: close the document
1920 if (!bufferlist.close(bufferlist.getBuffer(lyxfile)))
1921 // If close is canceled, we cancel here too.
1924 case 2: // No: switch to the open document
1925 owner->view()->buffer(bufferlist.getBuffer(lyxfile));
1927 case 3: // Cancel: Do nothing
1928 owner->message(_("Canceled."));
1933 // Check if a LyX document by the same root exists in filesystem
1934 FileInfo const f(lyxfile, true);
1935 if (f.exist() && !Alert::askQuestion(_("A document by the name"),
1936 MakeDisplayPath(lyxfile),
1937 _("already exists. Overwrite?"))) {
1938 owner->message(_("Canceled"));
1941 // filename should be valid now
1943 Importer::Import(owner, filename, format);
1947 void LyXFunc::reloadBuffer()
1949 string const fn = owner->buffer()->fileName();
1950 if (bufferlist.close(owner->buffer()))
1951 owner->view()->buffer(bufferlist.loadLyXFile(fn));
1955 void LyXFunc::closeBuffer()
1957 if (bufferlist.close(owner->buffer()) && !quitting) {
1958 if (bufferlist.empty()) {
1959 // need this otherwise SEGV may occur while trying to
1960 // set variables that don't exist
1961 // since there's no current buffer
1962 owner->getDialogs()->hideBufferDependent();
1964 owner->view()->buffer(bufferlist.first());
1970 // Each "owner" should have it's own message method. lyxview and
1971 // the minibuffer would use the minibuffer, but lyxserver would
1972 // send an ERROR signal to its client. Alejandro 970603
1973 // This func is bit problematic when it comes to NLS, to make the
1974 // lyx servers client be language indepenent we must not translate
1975 // strings sent to this func.
1976 void LyXFunc::setErrorMessage(string const & m) const
1978 dispatch_buffer = m;
1983 void LyXFunc::setMessage(string const & m) const
1985 dispatch_buffer = m;
1989 void LyXFunc::setStatusMessage(string const & m) const
1995 void LyXFunc::initMiniBuffer()
1997 string text = _("Welcome to LyX!");
1999 // When meta-fake key is pressed, show the key sequence so far + "M-".
2001 text = keyseq.print();
2005 // Else, when a non-complete key sequence is pressed,
2006 // show the available options.
2007 if (keyseq.length() > 0 && !keyseq.deleted()) {
2008 text = keyseq.printOptions();
2011 // Else, show the buffer state.
2012 else if (owner->view()->available()) {
2013 Buffer * tmpbuf = owner->buffer();
2015 string const nicename =
2016 MakeDisplayPath(tmpbuf->fileName());
2017 // Should we do this instead? (kindo like emacs)
2018 // leaves more room for other information
2021 if (tmpbuf->lyxvc.inUse()) {
2023 text += tmpbuf->lyxvc.versionString();
2025 text += tmpbuf->lyxvc.locker();
2026 if (tmpbuf->isReadonly())
2029 } else if (tmpbuf->isReadonly())
2031 if (!tmpbuf->isLyxClean())
2032 text += _(" (Changed)");
2034 if (text != _("Welcome to LyX!")) // this is a hack
2035 text = _("* No document open *");
2038 owner->message(text);