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 extern BufferList bufferlist;
111 extern LyXServer * lyxserver;
112 extern bool selection_possible;
113 extern void MenuSendto();
115 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
117 extern void show_symbols_form(LyXFunc *);
119 extern LyXAction lyxaction;
121 extern tex_accent_struct get_accent(kb_action action);
123 extern void ShowLatexLog();
129 class MiniBufferController : public SigC::Object {
132 MiniBufferController() {
136 &MiniBufferController::receiveCommand));
140 &MiniBufferController::receiveArg));
143 void receiveCmd(string const & cmd) {}
145 void receiveArg(string const & arg) {}
153 MiniBufferController mb_ctrl;
159 /* === globals =========================================================== */
162 LyXFunc::LyXFunc(LyXView * o)
164 keyseq(toplevel_keymap.get(), toplevel_keymap.get()),
165 cancel_meta_seq(toplevel_keymap.get(), toplevel_keymap.get())
168 lyx_dead_action = LFUN_NOACTION;
169 lyx_calling_dead_action = LFUN_NOACTION;
174 LyXText * LyXFunc::TEXT(bool flag = true) const
177 return owner->view()->text;
178 return owner->view()->getLyXText();
182 // I changed this func slightly. I commented out the ...FinishUndo(),
183 // this means that all places that used to have a moveCursorUpdate, now
184 // have a ...FinishUndo() as the preceeding statement. I have also added
185 // a moveCursorUpdate to some of the functions that updated the cursor, but
186 // that did not show its new position.
188 void LyXFunc::moveCursorUpdate(bool flag, bool selecting)
190 if (selecting || TEXT(flag)->selection.mark()) {
191 TEXT(flag)->setSelection(owner->view());
192 if (TEXT(flag)->bv_owner)
193 owner->view()->toggleToggle();
195 owner->view()->update(TEXT(flag), BufferView::SELECT|BufferView::FITCUR);
196 owner->view()->showCursor();
198 /* ---> Everytime the cursor is moved, show the current font state. */
199 // should this too me moved out of this func?
200 owner->view()->setState();
204 void LyXFunc::handleKeyFunc(kb_action action)
206 char c = keyseq.getiso();
208 if (keyseq.length() > 1) {
212 owner->getIntl()->getTrans()
213 .deadkey(c, get_accent(action).accent, TEXT(false));
214 // Need to clear, in case the minibuffer calls these
217 // copied verbatim from do_accent_char
218 owner->view()->update(TEXT(false),
219 BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
220 TEXT(false)->selection.cursor = TEXT(false)->cursor;
224 void LyXFunc::processKeySym(KeySym keysym, unsigned int state)
228 if (lyxerr.debugging(Debug::KEY)) {
229 char const * tmp = XKeysymToString(keysym);
230 string const stm = (tmp ? tmp : "");
231 lyxerr << "KeySym is "
234 << keysym << "] State is ["
238 // Do nothing if we have nothing (JMarc)
239 if (keysym == NoSymbol) {
240 lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
245 // Can we be sure that this will work for all X Window
246 // implementations? (Lgb)
247 // This code snippet makes lyx ignore some keys. Perhaps
248 // all of them should be explictly mentioned?
249 if ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
250 || keysym == XK_Mode_switch || keysym == 0x0) {
254 // Do a one-deep top-level lookup for
255 // cancel and meta-fake keys. RVDK_PATCH_5
256 cancel_meta_seq.reset();
258 int action = cancel_meta_seq.addkey(keysym, state
259 &(ShiftMask|ControlMask
261 if (lyxerr.debugging(Debug::KEY)) {
262 lyxerr << "action first set to [" << action << "]" << endl;
265 // When not cancel or meta-fake, do the normal lookup.
266 // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
267 // Mostly, meta_fake_bit = 0. RVDK_PATCH_5.
268 if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
269 if (lyxerr.debugging(Debug::KEY)) {
270 lyxerr << "meta_fake_bit is ["
271 << meta_fake_bit << "]" << endl;
273 // remove Caps Lock and Mod2 as a modifiers
274 action = keyseq.addkey(keysym,
275 (state | meta_fake_bit)
276 &(ShiftMask|ControlMask
278 if (lyxerr.debugging(Debug::KEY)) {
279 lyxerr << "action now set to ["
280 << action << "]" << endl;
283 // Dont remove this unless you know what you are doing.
286 // can this happen now ?
287 if (action == LFUN_NOACTION) {
288 action = LFUN_PREFIX;
291 if (lyxerr.debugging(Debug::KEY)) {
292 lyxerr << "Key [action="
294 << keyseq.print() << "]"
298 // already here we know if it any point in going further
299 // why not return already here if action == -1 and
300 // num_bytes == 0? (Lgb)
302 if (keyseq.length() > 1 && !keyseq.deleted()) {
303 owner->message(keyseq.print());
306 if (action == LFUN_UNKNOWN_ACTION) {
307 // It is unknown, but what if we remove all
308 // the modifiers? (Lgb)
309 action = keyseq.addkey(keysym, 0);
311 if (lyxerr.debugging(Debug::KEY)) {
312 lyxerr << "Removing modifiers...\n"
313 << "Action now set to ["
314 << action << "]" << endl;
316 if (action == LFUN_UNKNOWN_ACTION) {
317 owner->message(_("Unknown function."));
322 if (action == LFUN_SELFINSERT) {
323 // This is very X dependent.
324 unsigned int c = keysym;
327 c = kb_keymap::getiso(c);
330 argument = static_cast<char>(c);
332 dispatch(LFUN_SELFINSERT, argument);
333 lyxerr[Debug::KEY] << "SelfInsert arg[`"
334 << argument << "']" << endl;
337 verboseDispatch(action, false);
341 FuncStatus LyXFunc::getStatus(int ac) const
345 action = lyxaction.retrieveActionArg(ac, argument);
346 return getStatus(action, argument);
350 FuncStatus LyXFunc::getStatus(kb_action action,
351 string const & argument) const
354 Buffer * buf = owner->buffer();
356 if (action == LFUN_UNKNOWN_ACTION) {
357 setStatusMessage(N_("Unknown action"));
358 return flag.unknown(true);
361 // the default error message if we disable the command
362 setStatusMessage(N_("Command disabled"));
364 // Check whether we need a buffer
365 if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) {
366 // Yes we need a buffer, do we have one?
369 // Can we use a readonly buffer?
370 if (buf->isReadonly() &&
371 !lyxaction.funcHasFlag(action,
372 LyXAction::ReadOnly)) {
374 setStatusMessage(N_("Document is read-only"));
379 setStatusMessage(N_("Command not allowed with"
380 "out any document open"));
381 return flag.disabled(true);
385 UpdatableInset * tli = owner->view()->theLockingInset();
387 // I would really like to avoid having this switch and rather try to
388 // encode this in the function itself.
389 bool disable = false;
392 disable = !Exporter::IsExportable(buf, "dvi")
393 || lyxrc.print_command == "none";
396 disable = argument == "fax" &&
397 !Exporter::IsExportable(buf, argument);
400 disable = buf->undostack.empty();
403 disable = buf->redostack.empty();
405 case LFUN_SPELLCHECK:
406 disable = lyxrc.isp_command == "none";
408 #ifndef HAVE_LIBAIKSAURUS
409 case LFUN_THESAURUS_ENTRY:
414 disable = lyxrc.chktex_command == "none";
417 disable = !Exporter::IsExportable(buf, "program");
420 case LFUN_LAYOUT_TABULAR:
422 || (tli->lyxCode() != Inset::TABULAR_CODE
423 && !tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
427 case LFUN_LAYOUT_PARAGRAPH: {
428 Inset * inset = TEXT(false)->cursor.par()->inInset();
429 disable = inset && inset->forceDefaultParagraphs(inset);
433 case LFUN_TABULAR_FEATURE:
437 //ret.disabled(true);
438 if (tli->lyxCode() == Inset::TABULAR_CODE) {
439 ret = static_cast<InsetTabular *>(tli)
440 ->getStatus(argument);
441 } else if (tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
442 ret = static_cast<InsetTabular *>
443 (tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE))
444 ->getStatus(argument);
449 static InsetTabular inset(*owner->buffer(), 1, 1);
453 ret = inset.getStatus(argument);
454 if (ret.onoff(true) || ret.onoff(false))
455 flag.setOnOff(false);
459 case LFUN_VC_REGISTER:
460 disable = buf->lyxvc.inUse();
462 case LFUN_VC_CHECKIN:
463 disable = !buf->lyxvc.inUse() || buf->isReadonly();
465 case LFUN_VC_CHECKOUT:
466 disable = !buf->lyxvc.inUse() || !buf->isReadonly();
470 case LFUN_VC_HISTORY:
471 disable = !buf->lyxvc.inUse();
473 case LFUN_BOOKMARK_GOTO:
474 disable = !owner->view()->
475 isSavedPosition(strToUnsignedInt(argument));
479 case LFUN_INSET_TOGGLE: {
480 LyXText * lt = owner->view()->getLyXText();
481 disable = !(isEditableInset(lt->getInset())
483 && lt->inset_owner->owner()
484 && lt->inset_owner->owner()->isOpen()));
487 case LFUN_MATH_VALIGN:
489 char align = mathcursor->valign();
494 if (argument.empty()) {
498 if (!contains("tcb", argument[0])) {
502 flag.setOnOff(argument[0] == align);
507 case LFUN_MATH_HALIGN:
509 char align = mathcursor->halign();
514 if (argument.empty()) {
518 if (!contains("lcr", argument[0])) {
522 flag.setOnOff(argument[0] == align);
527 case LFUN_MATH_MUTATE:
528 if (tli && (tli->lyxCode() == Inset::MATH_CODE)) {
529 MathInsetTypes type = mathcursor->formula()->getType();
530 if (argument == "inline") {
531 flag.setOnOff(type == LM_OT_SIMPLE);
532 } else if (argument == "display") {
533 flag.setOnOff(type == LM_OT_EQUATION);
534 } else if (argument == "eqnarray") {
535 flag.setOnOff(type == LM_OT_EQNARRAY);
536 } else if (argument == "align") {
537 flag.setOnOff(type == LM_OT_ALIGN);
545 // we just need to be in math mode to enable that
547 case LFUN_MATH_SPACE:
548 case LFUN_MATH_LIMITS:
549 case LFUN_MATH_NONUMBER:
550 case LFUN_MATH_NUMBER:
551 disable = !mathcursor;
554 // we need to be math mode and a math array for that
555 // Hack: halign produces non-zero result iff we are in a math array
556 case LFUN_MATH_ROW_INSERT:
557 case LFUN_MATH_ROW_DELETE:
558 case LFUN_MATH_COLUMN_INSERT:
559 case LFUN_MATH_COLUMN_DELETE:
560 disable = !mathcursor || !mathcursor->halign();
567 // the functions which insert insets
568 Inset::Code code = Inset::NO_CODE;
570 case LFUN_INSET_TEXT:
571 code = Inset::TEXT_CODE;
574 code = Inset::ERT_CODE;
577 case LFUN_INSET_GRAPHICS:
578 code = Inset::GRAPHICS_CODE;
580 case LFUN_INSET_FOOTNOTE:
581 code = Inset::FOOT_CODE;
583 case LFUN_DIALOG_TABULAR_INSERT:
584 case LFUN_INSET_TABULAR:
585 code = Inset::TABULAR_CODE;
587 case LFUN_INSET_EXTERNAL:
588 code = Inset::EXTERNAL_CODE;
590 case LFUN_INSET_MARGINAL:
591 code = Inset::MARGIN_CODE;
593 case LFUN_INSET_MINIPAGE:
594 code = Inset::MINIPAGE_CODE;
596 case LFUN_INSET_FLOAT:
597 case LFUN_INSET_WIDE_FLOAT:
598 code = Inset::FLOAT_CODE;
600 case LFUN_FLOAT_LIST:
601 code = Inset::FLOAT_LIST_CODE;
604 case LFUN_INSET_LIST:
605 code = Inset::LIST_CODE;
607 case LFUN_INSET_THEOREM:
608 code = Inset::THEOREM_CODE;
611 case LFUN_INSET_CAPTION:
612 code = Inset::CAPTION_CODE;
614 case LFUN_INSERT_NOTE:
615 code = Inset::IGNORE_CODE;
617 case LFUN_INSERT_LABEL:
618 code = Inset::LABEL_CODE;
620 case LFUN_REF_INSERT:
621 code = Inset::REF_CODE;
623 case LFUN_CITATION_CREATE:
624 case LFUN_CITATION_INSERT:
625 code = Inset::CITE_CODE;
627 case LFUN_INSERT_BIBTEX:
628 code = Inset::BIBTEX_CODE;
630 case LFUN_INDEX_INSERT:
631 case LFUN_INDEX_INSERT_LAST:
632 case LFUN_INDEX_CREATE:
633 code = Inset::INDEX_CODE;
635 case LFUN_INDEX_PRINT:
636 code = Inset::INDEX_PRINT_CODE;
638 case LFUN_CHILD_INSERT:
639 code = Inset::INCLUDE_CODE;
641 case LFUN_TOC_INSERT:
642 code = Inset::TOC_CODE;
644 case LFUN_PARENTINSERT:
645 code = Inset::PARENT_CODE;
649 case LFUN_INSERT_URL:
650 code = Inset::URL_CODE;
653 // always allow this, since we will inset a raw quote
654 // if an inset is not allowed.
656 case LFUN_HYPHENATION:
657 case LFUN_LIGATURE_BREAK:
659 case LFUN_MENU_SEPARATOR:
661 case LFUN_END_OF_SENTENCE:
662 case LFUN_PROTECTEDSPACE:
663 code = Inset::SPECIALCHAR_CODE;
668 if (code != Inset::NO_CODE && tli && !tli->insetAllowed(code)) {
675 // A few general toggles
677 case LFUN_READ_ONLY_TOGGLE:
678 flag.setOnOff(buf->isReadonly());
681 flag.setOnOff(TEXT(false)->cursor.par()->params().startOfAppendix());
683 case LFUN_SWITCHBUFFER:
684 // toggle on the current buffer, but do not toggle off
685 // the other ones (is that a good idea?)
686 if (argument == buf->fileName())
693 // the font related toggles
695 LyXFont const & font = TEXT(false)->real_current_font;
698 flag.setOnOff(font.emph() == LyXFont::ON);
701 flag.setOnOff(font.noun() == LyXFont::ON);
704 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
707 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
710 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
713 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
720 MathTextCodes tc = mathcursor->getLastCode();
723 flag.setOnOff(tc == LM_TC_BF);
726 flag.setOnOff(tc == LM_TC_SF);
729 flag.setOnOff(tc == LM_TC_CAL);
732 flag.setOnOff(tc == LM_TC_RM);
735 flag.setOnOff(tc == LM_TC_TT);
738 flag.setOnOff(tc == LM_TC_BB);
741 flag.setOnOff(tc == LM_TC_VAR);
752 // temporary dispatch method
753 void LyXFunc::miniDispatch(string const & s)
755 string s2(frontStrip(strip(s)));
758 verboseDispatch(s2, true);
763 void LyXFunc::verboseDispatch(string const & s, bool show_sc)
765 int action = lyxaction.LookupFunc(frontStrip(s));
767 if (action == LFUN_UNKNOWN_ACTION) {
768 string const msg = string(_("Unknown function ("))
772 verboseDispatch(action, show_sc);
777 void LyXFunc::verboseDispatch(int ac, bool show_sc)
782 // get the real action and argument
783 action = lyxaction.retrieveActionArg(ac, argument);
785 verboseDispatch(action, argument, show_sc);
790 void LyXFunc::verboseDispatch(kb_action action,
791 string const & argument, bool show_sc)
793 string res = dispatch(action, argument);
795 commandshortcut.erase();
797 if (lyxrc.display_shortcuts && show_sc) {
798 if (action != LFUN_SELFINSERT) {
799 // Put name of command and list of shortcuts
800 // for it in minibuffer
801 string comname = lyxaction.getActionName(action);
803 int pseudoaction = action;
804 bool argsadded = false;
806 if (!argument.empty()) {
807 // the pseudoaction is useful for the bindings
809 lyxaction.searchActionArg(action,
812 if (pseudoaction == LFUN_UNKNOWN_ACTION) {
813 pseudoaction = action;
815 comname += " " + argument;
820 string const shortcuts =
821 toplevel_keymap->findbinding(pseudoaction);
823 if (!shortcuts.empty()) {
824 comname += ": " + shortcuts;
825 } else if (!argsadded && !argument.empty()) {
826 comname += " " + argument;
829 if (!comname.empty()) {
830 comname = strip(comname);
831 commandshortcut = "(" + comname + ')';
837 if (!commandshortcut.empty()) {
838 owner->getMiniBuffer()->addSet(commandshortcut);
841 owner->getMiniBuffer()->addSet(' ' + commandshortcut);
846 string const LyXFunc::dispatch(kb_action action, string argument)
848 lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << action
849 <<"] arg[" << argument << "]" << endl;
851 // we have not done anything wrong yet.
853 dispatch_buffer.erase();
855 #ifdef NEW_DISPATCHER
856 // We try do call the most specific dispatcher first:
857 // 1. the lockinginset's dispatch
858 // 2. the bufferview's dispatch
859 // 3. the lyxview's dispatch
862 selection_possible = false;
864 if (owner->view()->available())
865 owner->view()->hideCursor();
867 // We cannot use this function here
868 if (getStatus(action, argument).disabled()) {
869 lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: "
870 << lyxaction.getActionName(action)
871 << " [" << action << "] is disabled at this location"
873 setErrorMessage(getStatusMessage());
874 goto exit_with_message;
877 if (owner->view()->available() && owner->view()->theLockingInset()) {
878 UpdatableInset::RESULT result;
879 if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
880 (!keyseq.deleted())))
882 if ((action == LFUN_UNKNOWN_ACTION)
883 && argument.empty()){
884 argument = keyseq.getiso();
886 // Undo/Redo is a bit tricky for insets.
887 if (action == LFUN_UNDO) {
888 owner->view()->menuUndo();
889 goto exit_with_message;
890 } else if (action == LFUN_REDO) {
891 owner->view()->menuRedo();
892 goto exit_with_message;
893 } else if (((result=owner->view()->theLockingInset()->
894 // Hand-over to inset's own dispatch:
895 localDispatch(owner->view(), action, argument)) ==
896 UpdatableInset::DISPATCHED) ||
897 (result == UpdatableInset::DISPATCHED_NOUPDATE))
898 goto exit_with_message;
899 // If UNDISPATCHED, just soldier on
900 else if (result == UpdatableInset::FINISHED) {
901 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
902 TEXT()->cursorRight(owner->view());
903 moveCursorUpdate(true, false);
906 goto exit_with_message;
907 } else if (result == UpdatableInset::FINISHED_RIGHT) {
908 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
909 TEXT()->cursorRight(owner->view());
910 moveCursorUpdate(true, false);
913 goto exit_with_message;
914 } else if (result == UpdatableInset::FINISHED_UP) {
915 if (TEXT()->cursor.row()->previous()) {
916 TEXT()->cursorUp(owner->view());
917 moveCursorUpdate(true, false);
920 goto exit_with_message;
921 } else if (result == UpdatableInset::FINISHED_DOWN) {
922 if (TEXT()->cursor.row()->next())
923 TEXT()->cursorDown(owner->view());
925 TEXT()->cursorRight(owner->view());
926 moveCursorUpdate(true, false);
928 goto exit_with_message;
930 //setMessage(N_("Text mode"));
932 case LFUN_UNKNOWN_ACTION:
933 case LFUN_BREAKPARAGRAPH:
935 TEXT()->cursorRight(owner->view());
936 owner->view()->setState();
940 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
941 TEXT()->cursorRight(owner->view());
942 moveCursorUpdate(true, false);
945 goto exit_with_message;
947 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
948 TEXT()->cursorRight(owner->view());
949 moveCursorUpdate(true, false);
952 goto exit_with_message;
954 if (TEXT()->cursor.row()->next())
955 TEXT()->cursorDown(owner->view());
957 TEXT()->cursorRight(owner->view());
958 moveCursorUpdate(true, false);
960 goto exit_with_message;
972 if (!owner->view()->available()) break;
973 // this function should be used always [asierra060396]
974 UpdatableInset * tli =
975 owner->view()->theLockingInset();
977 UpdatableInset * lock = tli->getLockingInset();
980 owner->view()->unlockInset(tli);
981 TEXT()->cursorRight(owner->view());
982 moveCursorUpdate(true, false);
985 tli->unlockInsetInInset(owner->view(),
994 // --- Misc -------------------------------------------
995 case LFUN_WORDFINDFORWARD :
996 case LFUN_WORDFINDBACKWARD : {
997 static string last_search;
998 string searched_string;
1000 if (!argument.empty()) {
1001 last_search = argument;
1002 searched_string = argument;
1004 searched_string = last_search;
1006 bool fw = (action == LFUN_WORDFINDBACKWARD);
1007 if (!searched_string.empty()) {
1008 LyXFind(owner->view(), searched_string, fw);
1010 // owner->view()->showCursor();
1016 if (owner->view()->available() && !owner->view()->theLockingInset()) {
1017 owner->view()->update(TEXT(),
1018 BufferView::SELECT|BufferView::FITCUR);
1020 owner->message(keyseq.print());
1024 // --- Misc -------------------------------------------
1025 case LFUN_EXEC_COMMAND:
1027 std::vector<string> allCmds;
1028 std::transform(lyxaction.func_begin(), lyxaction.func_end(),
1029 std::back_inserter(allCmds), lyx::firster());
1030 static std::vector<string> hist;
1031 owner->getMiniBuffer()->getString(MiniBuffer::spaces,
1036 case LFUN_CANCEL: // RVDK_PATCH_5
1039 if (owner->view()->available())
1040 // cancel any selection
1041 dispatch(LFUN_MARK_OFF);
1042 setMessage(N_("Cancel"));
1045 case LFUN_META_FAKE: // RVDK_PATCH_5
1047 meta_fake_bit = Mod1Mask;
1048 setMessage(keyseq.print());
1052 case LFUN_READ_ONLY_TOGGLE:
1053 if (owner->buffer()->lyxvc.inUse()) {
1054 owner->buffer()->lyxvc.toggleReadOnly();
1056 owner->buffer()->setReadonly(
1057 !owner->buffer()->isReadonly());
1061 case LFUN_CENTER: // this is center and redraw.
1062 owner->view()->center();
1065 // --- Menus -----------------------------------------------
1070 case LFUN_MENUNEWTMPLT:
1074 case LFUN_CLOSEBUFFER:
1078 case LFUN_MENUWRITE:
1079 if (!owner->buffer()->isUnnamed()) {
1081 s1 << _("Saving document") << ' '
1082 << MakeDisplayPath(owner->buffer()->fileName() + "...");
1083 owner->message(s1.str().c_str());
1084 MenuWrite(owner->view(), owner->buffer());
1086 WriteAs(owner->view(), owner->buffer());
1090 WriteAs(owner->view(), owner->buffer(), argument);
1093 case LFUN_MENURELOAD:
1098 Exporter::Export(owner->buffer(), argument, true);
1102 Exporter::Preview(owner->buffer(), argument);
1105 case LFUN_BUILDPROG:
1106 Exporter::Export(owner->buffer(), "program", true);
1109 case LFUN_RUNCHKTEX:
1110 MenuRunChktex(owner->buffer());
1113 case LFUN_MENUPRINT:
1114 owner->getDialogs()->showPrint();
1118 if (argument == "custom")
1121 Exporter::Export(owner->buffer(), argument, false);
1139 InsetCommandParams p;
1142 if (action == LFUN_TOCVIEW)
1144 p.setCmdName("tableofcontents");
1146 else if (action == LFUN_LOAVIEW )
1147 p.setCmdName("listof{algorithm}{List of Algorithms}");
1148 else if (action == LFUN_LOFVIEW)
1149 p.setCmdName("listoffigures");
1151 p.setCmdName("listoftables");
1153 owner->getDialogs()->createTOC(p.getAsString());
1157 case LFUN_DIALOG_TABULAR_INSERT:
1158 owner->getDialogs()->showTabularCreate();
1166 AutoSave(owner->view());
1170 owner->view()->menuUndo();
1174 owner->view()->menuRedo();
1177 case LFUN_MENUSEARCH:
1178 owner->getDialogs()->showSearch();
1181 case LFUN_REMOVEERRORS:
1182 if (owner->view()->removeAutoInsets()) {
1183 owner->view()->redraw();
1184 owner->view()->fitCursor();
1189 changeDepth(owner->view(), TEXT(false), 0);
1192 case LFUN_DEPTH_MIN:
1193 changeDepth(owner->view(), TEXT(false), -1);
1196 case LFUN_DEPTH_PLUS:
1197 changeDepth(owner->view(), TEXT(false), 1);
1201 owner->getDialogs()->setUserFreeFont();
1204 case LFUN_RECONFIGURE:
1205 Reconfigure(owner->view());
1209 case LFUN_FLOATSOPERATE:
1210 if (argument == "openfoot")
1211 owner->view()->allFloats(1,0);
1212 else if (argument == "closefoot")
1213 owner->view()->allFloats(0,0);
1214 else if (argument == "openfig")
1215 owner->view()->allFloats(1,1);
1216 else if (argument == "closefig")
1217 owner->view()->allFloats(0,1);
1220 #ifdef WITH_WARNINGS
1221 //#warning Find another implementation here (or another lyxfunc)!
1224 case LFUN_HELP_ABOUTLYX:
1225 owner->getDialogs()->showAboutlyx();
1228 case LFUN_HELP_TEXINFO:
1229 owner->getDialogs()->showTexinfo();
1232 case LFUN_HELP_OPEN:
1234 string const arg = argument;
1236 setErrorMessage(N_("Missing argument"));
1239 owner->prohibitInput();
1240 string const fname = i18nLibFileSearch("doc", arg, "lyx");
1241 if (fname.empty()) {
1242 lyxerr << "LyX: unable to find documentation file `"
1243 << arg << "'. Bad installation?" << endl;
1244 owner->allowInput();
1248 str << _("Opening help file") << ' '
1249 << MakeDisplayPath(fname) << "...";
1250 owner->message(str.str().c_str());
1251 owner->view()->buffer(bufferlist.loadLyXFile(fname, false));
1252 owner->allowInput();
1256 // --- version control -------------------------------
1257 case LFUN_VC_REGISTER:
1259 if (!owner->buffer()->lyxvc.inUse())
1260 owner->buffer()->lyxvc.registrer();
1264 case LFUN_VC_CHECKIN:
1266 if (owner->buffer()->lyxvc.inUse()
1267 && !owner->buffer()->isReadonly())
1268 owner->buffer()->lyxvc.checkIn();
1272 case LFUN_VC_CHECKOUT:
1274 if (owner->buffer()->lyxvc.inUse()
1275 && owner->buffer()->isReadonly())
1276 owner->buffer()->lyxvc.checkOut();
1280 case LFUN_VC_REVERT:
1282 owner->buffer()->lyxvc.revert();
1288 owner->buffer()->lyxvc.undoLast();
1292 case LFUN_VC_HISTORY:
1294 owner->getDialogs()->showVCLogFile();
1298 // --- buffers ----------------------------------------
1300 case LFUN_SWITCHBUFFER:
1301 owner->view()->buffer(bufferlist.getBuffer(argument));
1306 // servercmd: argument must be <file>:<template>
1307 Buffer * tmpbuf = NewLyxFile(argument);
1309 owner->view()->buffer(tmpbuf);
1313 case LFUN_FILE_OPEN:
1317 case LFUN_LATEX_LOG:
1318 owner->getDialogs()->showLogFile();
1321 case LFUN_LAYOUT_DOCUMENT:
1322 owner->getDialogs()->showDocument();
1325 case LFUN_LAYOUT_PARAGRAPH:
1326 owner->getDialogs()->showParagraph();
1329 case LFUN_LAYOUT_CHARACTER:
1330 owner->getDialogs()->showCharacter();
1333 case LFUN_LAYOUT_TABULAR:
1334 if (owner->view()->theLockingInset()) {
1335 if (owner->view()->theLockingInset()->lyxCode()==Inset::TABULAR_CODE) {
1336 InsetTabular * inset = static_cast<InsetTabular *>
1337 (owner->view()->theLockingInset());
1338 inset->openLayoutDialog(owner->view());
1339 } else if (owner->view()->theLockingInset()->
1340 getFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
1341 InsetTabular * inset = static_cast<InsetTabular *>(
1342 owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
1343 inset->openLayoutDialog(owner->view());
1348 case LFUN_LAYOUT_PREAMBLE:
1349 owner->getDialogs()->showPreamble();
1352 case LFUN_DROP_LAYOUTS_CHOICE:
1353 owner->getToolbar()->openLayoutList();
1356 case LFUN_MENU_OPEN_BY_NAME:
1357 owner->getMenubar()->openByName(argument);
1358 break; // RVDK_PATCH_5
1360 case LFUN_SPELLCHECK:
1361 if (lyxrc.isp_command != "none")
1362 owner->getDialogs()->showSpellchecker();
1365 // --- lyxserver commands ----------------------------
1369 setMessage(owner->buffer()->fileName());
1370 lyxerr[Debug::INFO] << "FNAME["
1371 << owner->buffer()->fileName()
1377 dispatch_buffer = keyseq.print();
1378 lyxserver->notifyClient(dispatch_buffer);
1382 case LFUN_GOTOFILEROW:
1386 istringstream istr(argument.c_str());
1387 istr >> file_name >> row;
1388 // Must replace extension of the file to be .lyx and get full path
1389 string const s(ChangeExtension(file_name, ".lyx"));
1391 // Either change buffer or load the file
1392 if (bufferlist.exists(s)) {
1393 owner->view()->buffer(bufferlist.getBuffer(s));
1395 owner->view()->buffer(bufferlist.loadLyXFile(s));
1399 owner->view()->setCursorFromRow(row);
1402 owner->view()->center();
1406 case LFUN_GOTO_PARAGRAPH:
1408 istringstream istr(argument.c_str());
1412 Paragraph * par = owner->buffer()->getParFromID(id);
1414 lyxerr[Debug::INFO] << "No matching paragraph found! ["
1415 << id << "]" << std::endl;
1418 lyxerr << "Paragraph " << par->id()
1419 << " found." << endl;
1422 if (owner->view()->theLockingInset())
1423 owner->view()->unlockInset(owner->view()->theLockingInset());
1424 if (par->inInset()) {
1425 par->inInset()->edit(owner->view());
1428 owner->view()->getLyXText()->setCursor(owner->view(), par, 0);
1429 owner->view()->setState();
1433 owner->view()->center();
1440 int const qa = lyxaction.LookupFunc(argument);
1441 setMessage(lyxaction.helpText(static_cast<kb_action>(qa)));
1445 // --- toolbar ----------------------------------
1446 case LFUN_PUSH_TOOLBAR:
1448 int nth = strToInt(argument);
1450 setErrorMessage(N_("Push-toolbar needs argument > 0"));
1452 owner->getToolbar()->push(nth);
1457 case LFUN_ADD_TO_TOOLBAR:
1459 if (lyxerr.debugging(Debug::GUI)) {
1460 lyxerr << "LFUN_ADD_TO_TOOLBAR:"
1461 "argument = `" << argument << '\'' << endl;
1463 string tmp(argument);
1464 //lyxerr <<string("Argument: ") + argument);
1465 //lyxerr <<string("Tmp : ") + tmp);
1467 setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
1469 owner->getToolbar()->add(argument, false);
1470 owner->getToolbar()->set();
1475 // --- insert characters ----------------------------------------
1477 // --- Mathed stuff. If we are here, there is no locked inset yet.
1478 case LFUN_MATH_EXTERN:
1479 case LFUN_MATH_NUMBER:
1480 case LFUN_MATH_NONUMBER:
1481 case LFUN_MATH_LIMITS:
1483 setErrorMessage(N_("This is only allowed in math mode!"));
1487 // passthrough hat and underscore outside mathed:
1488 case LFUN_SUBSCRIPT:
1489 dispatch(LFUN_SELFINSERT, "_");
1491 case LFUN_SUPERSCRIPT:
1492 dispatch(LFUN_SELFINSERT, "^");
1495 case LFUN_MATH_PANEL:
1496 owner->getDialogs()->showMathPanel();
1499 case LFUN_CITATION_CREATE:
1501 InsetCommandParams p( "cite" );
1503 if (!argument.empty()) {
1504 // This should be set at source, ie when typing
1505 // "citation-insert foo" in the minibuffer.
1506 // Question: would pybibliographer also need to be
1507 // changed. Suspect so. Leave as-is therefore.
1508 if (contains(argument, "|")) {
1509 p.setContents( token(argument, '|', 0) );
1510 p.setOptions( token(argument, '|', 1) );
1512 p.setContents( argument );
1514 dispatch(LFUN_CITATION_INSERT, p.getAsString());
1516 owner->getDialogs()->createCitation( p.getAsString() );
1520 case LFUN_CHILDOPEN:
1522 string const filename =
1523 MakeAbsPath(argument,
1524 owner->buffer()->filePath());
1525 setMessage(N_("Opening child document ") +
1526 MakeDisplayPath(filename) + "...");
1527 owner->view()->savePosition(0);
1528 if (bufferlist.exists(filename))
1529 owner->view()->buffer(bufferlist.getBuffer(filename));
1531 owner->view()->buffer(bufferlist.loadLyXFile(filename));
1535 case LFUN_TOGGLECURSORFOLLOW:
1536 lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
1539 case LFUN_KMAP_OFF: // keymap off
1540 owner->getIntl()->KeyMapOn(false);
1543 case LFUN_KMAP_PRIM: // primary keymap
1544 owner->getIntl()->KeyMapPrim();
1547 case LFUN_KMAP_SEC: // secondary keymap
1548 owner->getIntl()->KeyMapSec();
1551 case LFUN_KMAP_TOGGLE: // toggle keymap
1552 owner->getIntl()->ToggleKeyMap();
1557 // argument contains ';'-terminated commands
1558 while (argument.find(';') != string::npos) {
1560 argument = split(argument, first, ';');
1561 verboseDispatch(first, false);
1566 case LFUN_DIALOG_PREFERENCES:
1567 owner->getDialogs()->showPreferences();
1570 case LFUN_SAVEPREFERENCES:
1572 Path p(user_lyxdir);
1573 lyxrc.write("preferences");
1577 case LFUN_SCREEN_FONT_UPDATE:
1579 // handle the screen font changes.
1581 lyxrc.set_font_norm_type();
1582 fontloader.update();
1583 // Of course we should only do the resize and the textcache.clear
1584 // if values really changed...but not very important right now. (Lgb)
1585 // All visible buffers will need resize
1587 // We also need to empty the textcache so that
1588 // the buffer will be formatted correctly after
1594 case LFUN_SET_COLOR:
1597 string const x11_name = split(argument, lyx_name, ' ');
1598 if (lyx_name.empty() || x11_name.empty()) {
1599 setErrorMessage(N_("Syntax: set-color <lyx_name>"
1604 if (!lcolor.setColor(lyx_name, x11_name)) {
1605 static string const err1 (N_("Set-color \""));
1606 static string const err2 (
1607 N_("\" failed - color is undefined "
1608 "or may not be redefined"));
1609 setErrorMessage(_(err1) + lyx_name + _(err2));
1612 lyxColorHandler->updateColor(lcolor.getFromLyXName(lyx_name));
1613 owner->view()->redraw();
1618 owner->message(argument);
1621 case LFUN_MESSAGE_PUSH:
1622 owner->messagePush(argument);
1625 case LFUN_MESSAGE_POP:
1626 owner->messagePop();
1630 // Then if it was none of the above
1631 // Trying the BufferView::pimpl dispatch:
1632 if (!owner->view()->Dispatch(action, argument))
1633 lyxerr << "A truly unknown func ["
1634 << lyxaction.getActionName(action) << "]!"
1641 string const res = getMessage();
1644 owner->message(_(res));
1645 owner->updateMenubar();
1646 owner->updateToolbar();
1652 void LyXFunc::setupLocalKeymap()
1654 keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
1655 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap.get();
1659 void LyXFunc::menuNew(bool fromTemplate)
1661 string initpath = lyxrc.document_path;
1663 if (owner->view()->available()) {
1664 string const trypath = owner->buffer()->filePath();
1665 // If directory is writeable, use this as default.
1666 if (IsDirWriteable(trypath))
1670 static int newfile_number;
1673 if (lyxrc.new_ask_filename) {
1674 FileDialog fileDlg(owner, _("Enter filename for new document"),
1675 LFUN_SELECT_FILE_SYNC,
1676 make_pair(string(_("Documents|#o#O")),
1677 string(lyxrc.document_path)),
1678 make_pair(string(_("Templates|#T#t")),
1679 string(lyxrc.template_path)));
1681 FileDialog::Result result =
1682 fileDlg.Select(initpath,
1683 _("*.lyx|LyX Documents (*.lyx)"),
1686 if (result.second.empty()) {
1687 owner->message(_("Canceled."));
1688 lyxerr[Debug::INFO] << "New Document Cancelled." << endl;
1692 // get absolute path of file and make sure the filename ends
1694 s = MakeAbsPath(result.second);
1695 if (!IsLyXFilename(s))
1698 // Check if the document already is open
1699 if (bufferlist.exists(s)) {
1700 switch (Alert::askConfirmation(_("Document is already open:"),
1701 MakeDisplayPath(s, 50),
1702 _("Do you want to close that document now?\n"
1703 "('No' will just switch to the open version)")))
1705 case 1: // Yes: close the document
1706 if (!bufferlist.close(bufferlist.getBuffer(s)))
1707 // If close is canceled, we cancel here too.
1710 case 2: // No: switch to the open document
1711 owner->view()->buffer(bufferlist.getBuffer(s));
1713 case 3: // Cancel: Do nothing
1714 owner->message(_("Canceled."));
1718 // Check whether the file already exists
1720 if (fi.readable() &&
1721 Alert::askQuestion(_("File already exists:"),
1722 MakeDisplayPath(s, 50),
1723 _("Do you want to open the document?"))) {
1725 string const disp_fn(MakeDisplayPath(s));
1728 str << _("Opening document") << ' '
1729 << disp_fn << "...";
1731 owner->message(str.str().c_str());
1732 //XFlush(fl_get_display());
1733 owner->view()->buffer(bufferlist.loadLyXFile(s));
1735 str2 << _("Document") << ' '
1736 << disp_fn << ' ' << _("opened.");
1738 owner->message(str2.str().c_str());
1743 s = AddName(lyxrc.document_path,
1744 "newfile" + tostr(++newfile_number) + ".lyx");
1746 while (bufferlist.exists(s) || fi.readable()) {
1748 s = AddName(lyxrc.document_path,
1749 "newfile" + tostr(newfile_number) +
1755 // The template stuff
1758 FileDialog fileDlg(owner, _("Select template file"),
1759 LFUN_SELECT_FILE_SYNC,
1760 make_pair(string(_("Documents|#o#O")),
1761 string(lyxrc.document_path)),
1762 make_pair(string(_("Templates|#T#t")),
1763 string(lyxrc.template_path)));
1765 FileDialog::Result result =
1766 fileDlg.Select(lyxrc.template_path,
1767 _("*.lyx|LyX Documents (*.lyx)"));
1769 if (result.first == FileDialog::Later)
1772 string const fname = result.second;
1779 // find a free buffer
1780 lyxerr[Debug::INFO] << "Find a free buffer." << endl;
1781 owner->view()->buffer(bufferlist.newFile(s, templname));
1785 void LyXFunc::open(string const & fname)
1787 string initpath = lyxrc.document_path;
1789 if (owner->view()->available()) {
1790 string const trypath = owner->buffer()->filePath();
1791 // If directory is writeable, use this as default.
1792 if (IsDirWriteable(trypath))
1798 if (fname.empty()) {
1799 FileDialog fileDlg(owner, _("Select document to open"),
1801 make_pair(string(_("Documents|#o#O")),
1802 string(lyxrc.document_path)),
1803 make_pair(string(_("Examples|#E#e")),
1804 string(AddPath(system_lyxdir, "examples"))));
1806 FileDialog::Result result =
1807 fileDlg.Select(initpath,
1808 "*.lyx|LyX Documents (*.lyx)");
1810 if (result.first == FileDialog::Later)
1813 filename = result.second;
1815 // check selected filename
1816 if (filename.empty()) {
1817 owner->message(_("Canceled."));
1823 // get absolute path of file and add ".lyx" to the filename if
1825 string const fullpath = FileSearch(string(), filename, "lyx");
1826 if (fullpath.empty()) {
1827 Alert::alert(_("Error"), _("Could not find file"), filename);
1831 filename = fullpath;
1834 string const disp_fn(MakeDisplayPath(filename));
1837 str << _("Opening document") << ' ' << disp_fn << "...";
1839 owner->message(str.str().c_str());
1841 Buffer * openbuf = bufferlist.loadLyXFile(filename);
1843 owner->view()->buffer(openbuf);
1845 str << _("Document") << ' ' << disp_fn << ' ' << _("opened.");
1846 owner->message(str.str().c_str());
1849 str << _("Could not open document") << ' ' << disp_fn;
1850 owner->message(str.str().c_str());
1855 // checks for running without gui are missing.
1856 void LyXFunc::doImport(string const & argument)
1859 string filename = split(argument, format, ' ');
1860 lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format
1861 << " file: " << filename << endl;
1863 if (filename.empty()) { // need user interaction
1864 string initpath = lyxrc.document_path;
1866 if (owner->view()->available()) {
1867 string const trypath = owner->buffer()->filePath();
1868 // If directory is writeable, use this as default.
1869 if (IsDirWriteable(trypath))
1873 string const text = _("Select ") + formats.prettyName(format)
1874 + _(" file to import");
1876 FileDialog fileDlg(owner, text,
1878 make_pair(string(_("Documents|#o#O")),
1879 string(lyxrc.document_path)),
1880 make_pair(string(_("Examples|#E#e")),
1881 string(AddPath(system_lyxdir, "examples"))));
1883 string const extension = "*." + formats.extension(format)
1884 + "| " + formats.prettyName(format)
1885 + " (*." + formats.extension(format) + ")";
1887 FileDialog::Result result = fileDlg.Select(initpath,
1890 if (result.first == FileDialog::Later)
1893 filename = result.second;
1895 // check selected filename
1896 if (filename.empty())
1897 owner->message(_("Canceled."));
1900 // still no filename? abort
1901 if (filename.empty())
1904 // get absolute path of file
1905 filename = MakeAbsPath(filename);
1907 string const lyxfile = ChangeExtension(filename, ".lyx");
1909 // Check if the document already is open
1910 if (bufferlist.exists(lyxfile)) {
1911 switch (Alert::askConfirmation(_("Document is already open:"),
1912 MakeDisplayPath(lyxfile, 50),
1913 _("Do you want to close that document now?\n"
1914 "('No' will just switch to the open version)")))
1916 case 1: // Yes: close the document
1917 if (!bufferlist.close(bufferlist.getBuffer(lyxfile)))
1918 // If close is canceled, we cancel here too.
1921 case 2: // No: switch to the open document
1922 owner->view()->buffer(bufferlist.getBuffer(lyxfile));
1924 case 3: // Cancel: Do nothing
1925 owner->message(_("Canceled."));
1930 // Check if a LyX document by the same root exists in filesystem
1931 FileInfo const f(lyxfile, true);
1932 if (f.exist() && !Alert::askQuestion(_("A document by the name"),
1933 MakeDisplayPath(lyxfile),
1934 _("already exists. Overwrite?"))) {
1935 owner->message(_("Canceled"));
1938 // filename should be valid now
1940 Importer::Import(owner, filename, format);
1944 void LyXFunc::reloadBuffer()
1946 string const fn = owner->buffer()->fileName();
1947 if (bufferlist.close(owner->buffer()))
1948 owner->view()->buffer(bufferlist.loadLyXFile(fn));
1952 void LyXFunc::closeBuffer()
1954 if (bufferlist.close(owner->buffer()) && !quitting) {
1955 if (bufferlist.empty()) {
1956 // need this otherwise SEGV may occur while trying to
1957 // set variables that don't exist
1958 // since there's no current buffer
1959 owner->getDialogs()->hideBufferDependent();
1961 owner->view()->buffer(bufferlist.first());
1967 // Each "owner" should have it's own message method. lyxview and
1968 // the minibuffer would use the minibuffer, but lyxserver would
1969 // send an ERROR signal to its client. Alejandro 970603
1970 // This func is bit problematic when it comes to NLS, to make the
1971 // lyx servers client be language indepenent we must not translate
1972 // strings sent to this func.
1973 void LyXFunc::setErrorMessage(string const & m) const
1975 dispatch_buffer = m;
1980 void LyXFunc::setMessage(string const & m) const
1982 dispatch_buffer = m;
1986 void LyXFunc::setStatusMessage(string const & m) const
1992 void LyXFunc::initMiniBuffer()
1994 string text = _("Welcome to LyX!");
1996 // When meta-fake key is pressed, show the key sequence so far + "M-".
1998 text = keyseq.print();
2002 // Else, when a non-complete key sequence is pressed,
2003 // show the available options.
2004 if (keyseq.length() > 0 && !keyseq.deleted()) {
2005 text = keyseq.printOptions();
2008 // Else, show the buffer state.
2009 else if (owner->view()->available()) {
2010 Buffer * tmpbuf = owner->buffer();
2012 string const nicename =
2013 MakeDisplayPath(tmpbuf->fileName());
2014 // Should we do this instead? (kindo like emacs)
2015 // leaves more room for other information
2018 if (tmpbuf->lyxvc.inUse()) {
2020 text += tmpbuf->lyxvc.versionString();
2022 text += tmpbuf->lyxvc.locker();
2023 if (tmpbuf->isReadonly())
2026 } else if (tmpbuf->isReadonly())
2028 if (!tmpbuf->isLyxClean())
2029 text += _(" (Changed)");
2031 if (text != _("Welcome to LyX!")) // this is a hack
2032 text = _("* No document open *");
2035 owner->message(text);