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 =========================================================== */
161 // Initialization of static member var
162 bool LyXFunc::show_sc = true;
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;
329 c = kb_keymap::getiso(c);
332 argument = static_cast<char>(c);
333 lyxerr[Debug::KEY] << "SelfInsert arg[`"
334 << argument << "']" << endl;
337 bool tmp_sc = show_sc;
339 dispatch(action, argument);
346 FuncStatus LyXFunc::getStatus(int ac) const
348 return getStatus(ac, string());
351 FuncStatus LyXFunc::getStatus(int ac,
352 string const & not_to_use_arg) const
357 Buffer * buf = owner->buffer();
359 if (lyxaction.isPseudoAction(ac))
360 action = lyxaction.retrieveActionArg(ac, argument);
362 action = static_cast<kb_action>(ac);
363 if (!not_to_use_arg.empty())
364 argument = not_to_use_arg; // except here
367 if (action == LFUN_UNKNOWN_ACTION) {
368 setErrorMessage(N_("Unknown action"));
369 return flag.unknown(true);
372 // Check whether we need a buffer
373 if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) {
374 // Yes we need a buffer, do we have one?
377 // Can we use a readonly buffer?
378 if (buf->isReadonly() &&
379 !lyxaction.funcHasFlag(action,
380 LyXAction::ReadOnly)) {
382 setErrorMessage(N_("Document is read-only"));
387 setErrorMessage(N_("Command not allowed with"
388 "out any document open"));
389 return flag.disabled(true);
393 // I would really like to avoid having this switch and rather try to
394 // encode this in the function itself.
395 bool disable = false;
398 disable = !Exporter::IsExportable(buf, "dvi")
399 || lyxrc.print_command == "none";
402 disable = argument == "fax" &&
403 !Exporter::IsExportable(buf, argument);
406 disable = buf->undostack.empty();
409 disable = buf->redostack.empty();
411 case LFUN_SPELLCHECK:
412 disable = lyxrc.isp_command == "none";
414 #ifndef HAVE_LIBAIKSAURUS
415 case LFUN_THESAURUS_ENTRY:
420 disable = lyxrc.chktex_command == "none";
423 disable = !Exporter::IsExportable(buf, "program");
426 case LFUN_LAYOUT_TABULAR:
428 if (owner->view()->theLockingInset()) {
429 disable = (owner->view()->theLockingInset()->lyxCode() != Inset::TABULAR_CODE) &&
430 !owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE);
434 case LFUN_TABULAR_FEATURE:
436 if (owner->view()->theLockingInset()) {
439 if (owner->view()->theLockingInset()->lyxCode() == Inset::TABULAR_CODE) {
440 ret = static_cast<InsetTabular *>
441 (owner->view()->theLockingInset())->
443 } else if (owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
444 ret = static_cast<InsetTabular *>
445 (owner->view()->theLockingInset()->
446 getFirstLockingInsetOfType(Inset::TABULAR_CODE))->
452 static InsetTabular inset(*owner->buffer(), 1, 1);
456 ret = inset.getStatus(argument);
457 if (ret.onoff(true) || ret.onoff(false)) flag.setOnOff(false);
461 case LFUN_VC_REGISTER:
462 disable = buf->lyxvc.inUse();
464 case LFUN_VC_CHECKIN:
465 disable = !buf->lyxvc.inUse() || buf->isReadonly();
467 case LFUN_VC_CHECKOUT:
468 disable = !buf->lyxvc.inUse() || !buf->isReadonly();
472 case LFUN_VC_HISTORY:
473 disable = !buf->lyxvc.inUse();
475 case LFUN_BOOKMARK_GOTO:
476 disable = !owner->view()->
477 isSavedPosition(strToUnsignedInt(argument));
481 case LFUN_INSET_TOGGLE:
482 disable = (TEXT(false)->getInset() == 0);
485 case LFUN_MATH_VALIGN: {
486 // I think this test can be simplified (Andre')
487 // mathcursor is != 0 iff we are in math mode
488 //Inset * tli = owner->view()->theLockingInset();
489 //if (tli && (tli->lyxCode() == Inset::MATH_CODE
490 // || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
493 char align = mathcursor->valign();
498 if (argument.empty()) {
502 if (!contains("tcb", argument[0])) {
506 flag.setOnOff(argument[0] == align);
511 case LFUN_MATH_HALIGN: {
512 //Inset * tli = owner->view()->theLockingInset();
513 //if (tli && (tli->lyxCode() == Inset::MATH_CODE
514 // || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
516 char align = mathcursor->halign();
521 if (argument.empty()) {
525 if (!contains("lcr", argument[0])) {
529 flag.setOnOff(argument[0] == align);
534 case LFUN_MATH_MUTATE: {
535 Inset * tli = owner->view()->theLockingInset();
536 if (tli && (tli->lyxCode() == Inset::MATH_CODE)) {
537 MathInsetTypes type = mathcursor->formula()->getType();
538 if (argument == "inline") {
539 flag.setOnOff(type == LM_OT_SIMPLE);
540 } else if (argument == "display") {
541 flag.setOnOff(type == LM_OT_EQUATION);
542 } else if (argument == "eqnarray") {
543 flag.setOnOff(type == LM_OT_EQNARRAY);
544 } else if (argument == "align") {
545 flag.setOnOff(type == LM_OT_ALIGN);
554 // we just need to be in math mode to enable that
556 case LFUN_MATH_SPACE:
557 case LFUN_MATH_LIMITS:
558 case LFUN_MATH_NONUMBER:
559 case LFUN_MATH_NUMBER:
560 disable = !mathcursor;
563 // we need to be math mode and a math array for that
564 // Hack: halign produces non-zero result iff we are in a math array
565 case LFUN_MATH_ROW_INSERT:
566 case LFUN_MATH_ROW_DELETE:
567 case LFUN_MATH_COLUMN_INSERT:
568 case LFUN_MATH_COLUMN_DELETE:
569 disable = !mathcursor || !mathcursor->halign();
576 // the functions which insert insets
577 Inset::Code code = Inset::NO_CODE;
579 case LFUN_INSET_TEXT:
580 code = Inset::TEXT_CODE;
583 code = Inset::ERT_CODE;
586 case LFUN_INSET_GRAPHICS:
587 code = Inset::GRAPHICS_CODE;
589 case LFUN_INSET_FOOTNOTE:
590 code = Inset::FOOT_CODE;
592 case LFUN_DIALOG_TABULAR_INSERT:
593 case LFUN_INSET_TABULAR:
594 code = Inset::TABULAR_CODE;
596 case LFUN_INSET_EXTERNAL:
597 code = Inset::EXTERNAL_CODE;
599 case LFUN_INSET_MARGINAL:
600 code = Inset::MARGIN_CODE;
602 case LFUN_INSET_MINIPAGE:
603 code = Inset::MINIPAGE_CODE;
605 case LFUN_INSET_FLOAT:
606 case LFUN_INSET_WIDE_FLOAT:
607 code = Inset::FLOAT_CODE;
609 case LFUN_FLOAT_LIST:
610 code = Inset::FLOAT_LIST_CODE;
613 case LFUN_INSET_LIST:
614 code = Inset::LIST_CODE;
616 case LFUN_INSET_THEOREM:
617 code = Inset::THEOREM_CODE;
620 case LFUN_INSET_CAPTION:
621 code = Inset::CAPTION_CODE;
623 case LFUN_INSERT_NOTE:
624 code = Inset::IGNORE_CODE;
626 case LFUN_INSERT_LABEL:
627 code = Inset::LABEL_CODE;
629 case LFUN_REF_INSERT:
630 code = Inset::REF_CODE;
632 case LFUN_CITATION_CREATE:
633 case LFUN_CITATION_INSERT:
634 code = Inset::CITE_CODE;
636 case LFUN_INSERT_BIBTEX:
637 code = Inset::BIBTEX_CODE;
639 case LFUN_INDEX_INSERT:
640 case LFUN_INDEX_INSERT_LAST:
641 case LFUN_INDEX_CREATE:
642 code = Inset::INDEX_CODE;
644 case LFUN_INDEX_PRINT:
645 code = Inset::INDEX_PRINT_CODE;
647 case LFUN_CHILD_INSERT:
648 code = Inset::INCLUDE_CODE;
650 case LFUN_TOC_INSERT:
651 code = Inset::TOC_CODE;
653 case LFUN_PARENTINSERT:
654 code = Inset::PARENT_CODE;
658 case LFUN_INSERT_URL:
659 code = Inset::URL_CODE;
662 // always allow this, since we will inset a raw quote
663 // if an inset is not allowed.
665 case LFUN_HYPHENATION:
666 case LFUN_LIGATURE_BREAK:
668 case LFUN_MENU_SEPARATOR:
670 case LFUN_END_OF_SENTENCE:
671 case LFUN_PROTECTEDSPACE:
672 code = Inset::SPECIALCHAR_CODE;
677 if (code != Inset::NO_CODE
678 && owner->view()->theLockingInset()
679 && !owner->view()->theLockingInset()->insetAllowed(code)) {
686 // A few general toggles
688 case LFUN_READ_ONLY_TOGGLE:
689 flag.setOnOff(buf->isReadonly());
692 flag.setOnOff(TEXT(false)->cursor.par()->params().startOfAppendix());
698 // the font related toggles
700 LyXFont const & font = TEXT(false)->real_current_font;
703 flag.setOnOff(font.emph() == LyXFont::ON);
706 flag.setOnOff(font.noun() == LyXFont::ON);
709 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
712 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
715 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
718 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
725 MathTextCodes tc = mathcursor->getLastCode();
728 flag.setOnOff(tc == LM_TC_BF);
731 flag.setOnOff(tc == LM_TC_SF);
734 flag.setOnOff(tc == LM_TC_CAL);
737 flag.setOnOff(tc == LM_TC_RM);
740 flag.setOnOff(tc == LM_TC_TT);
743 flag.setOnOff(tc == LM_TC_BB);
746 flag.setOnOff(tc == LM_TC_VAR);
757 // temporary dispatch method
758 void LyXFunc::miniDispatch(string const & s)
760 string s2(frontStrip(strip(s)));
768 string const LyXFunc::dispatch(string const & s)
770 // Split command string into command and argument
772 string line = frontStrip(s);
773 string const arg = strip(frontStrip(split(line, cmd, ' ')));
775 int action = lyxaction.LookupFunc(cmd);
777 if (action == LFUN_UNKNOWN_ACTION) {
778 string const msg = string(_("Unknown function ("))
783 return dispatch(action, arg);
788 string const LyXFunc::dispatch(int ac,
789 string const & do_not_use_this_arg)
791 lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << ac
792 <<"] arg[" << do_not_use_this_arg << "]" << endl;
797 // we have not done anything wrong yet.
799 dispatch_buffer.erase();
801 // if action is a pseudo-action, we need the real action
802 if (lyxaction.isPseudoAction(ac)) {
804 action = static_cast<kb_action>
805 (lyxaction.retrieveActionArg(ac, tmparg));
809 action = static_cast<kb_action>(ac);
810 if (!do_not_use_this_arg.empty())
811 argument = do_not_use_this_arg; // except here
815 #ifdef NEW_DISPATCHER
816 // We try do call the most specific dispatcher first:
817 // 1. the lockinginset's dispatch
818 // 2. the bufferview's dispatch
819 // 3. the lyxview's dispatch
822 selection_possible = false;
824 if (owner->view()->available())
825 owner->view()->hideCursor();
827 // We cannot use this function here
828 if (getStatus(ac, do_not_use_this_arg).disabled()) {
829 lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: "
830 << lyxaction.getActionName(ac)
831 << " [" << ac << "] is disabled at this location"
833 goto exit_with_message;
836 if (owner->view()->available() && owner->view()->theLockingInset()) {
837 UpdatableInset::RESULT result;
838 if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
839 (!keyseq.deleted())))
841 if ((action==LFUN_UNKNOWN_ACTION) && argument.empty()){
842 argument = keyseq.getiso();
844 // Undo/Redo is a bit tricky for insets.
845 if (action == LFUN_UNDO) {
846 owner->view()->menuUndo();
848 } else if (action == LFUN_REDO) {
849 owner->view()->menuRedo();
851 } else if (((result=owner->view()->theLockingInset()->
852 localDispatch(owner->view(), action, argument)) ==
853 UpdatableInset::DISPATCHED) ||
854 (result == UpdatableInset::DISPATCHED_NOUPDATE))
856 else if (result == UpdatableInset::FINISHED) {
857 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
858 TEXT()->cursorRight(owner->view());
859 moveCursorUpdate(true, false);
863 } else if (result == UpdatableInset::FINISHED_RIGHT) {
864 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
865 TEXT()->cursorRight(owner->view());
866 moveCursorUpdate(true, false);
870 } else if (result == UpdatableInset::FINISHED_UP) {
871 if (TEXT()->cursor.row()->previous()) {
872 TEXT()->cursorUp(owner->view());
873 moveCursorUpdate(true, false);
877 } else if (result == UpdatableInset::FINISHED_DOWN) {
878 if (TEXT()->cursor.row()->next())
879 TEXT()->cursorDown(owner->view());
881 TEXT()->cursorRight(owner->view());
882 moveCursorUpdate(true, false);
886 //setMessage(N_("Text mode"));
888 case LFUN_UNKNOWN_ACTION:
889 case LFUN_BREAKPARAGRAPH:
891 TEXT()->cursorRight(owner->view());
892 owner->view()->setState();
896 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
897 TEXT()->cursorRight(owner->view());
898 moveCursorUpdate(true, false);
903 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
904 TEXT()->cursorRight(owner->view());
905 moveCursorUpdate(true, false);
910 if (TEXT()->cursor.row()->next())
911 TEXT()->cursorDown(owner->view());
913 TEXT()->cursorRight(owner->view());
914 moveCursorUpdate(true, false);
928 if (!owner->view()->available()) break;
929 // this function should be used always [asierra060396]
930 UpdatableInset * tli =
931 owner->view()->theLockingInset();
933 UpdatableInset * lock = tli->getLockingInset();
936 owner->view()->unlockInset(tli);
937 TEXT()->cursorRight(owner->view());
938 moveCursorUpdate(true, false);
941 tli->unlockInsetInInset(owner->view(),
950 // --- Misc -------------------------------------------
951 case LFUN_WORDFINDFORWARD :
952 case LFUN_WORDFINDBACKWARD : {
953 static string last_search;
954 string searched_string;
956 if (!argument.empty()) {
957 last_search = argument;
958 searched_string = argument;
960 searched_string = last_search;
962 bool fw = (action == LFUN_WORDFINDBACKWARD);
963 if (!searched_string.empty()) {
964 LyXFind(owner->view(), searched_string, fw);
966 // owner->view()->showCursor();
972 if (owner->view()->available() && !owner->view()->theLockingInset()) {
973 owner->view()->update(TEXT(),
974 BufferView::SELECT|BufferView::FITCUR);
976 owner->message(keyseq.print());
980 // --- Misc -------------------------------------------
981 case LFUN_EXEC_COMMAND:
983 std::vector<string> allCmds;
984 std::transform(lyxaction.func_begin(), lyxaction.func_end(),
985 std::back_inserter(allCmds), lyx::firster());
986 static std::vector<string> hist;
987 owner->getMiniBuffer()->getString(MiniBuffer::spaces,
992 case LFUN_CANCEL: // RVDK_PATCH_5
995 if (owner->view()->available())
996 // cancel any selection
997 dispatch(LFUN_MARK_OFF);
998 setMessage(N_("Cancel"));
1001 case LFUN_META_FAKE: // RVDK_PATCH_5
1003 meta_fake_bit = Mod1Mask;
1004 setMessage(keyseq.print());
1008 case LFUN_READ_ONLY_TOGGLE:
1009 if (owner->buffer()->lyxvc.inUse()) {
1010 owner->buffer()->lyxvc.toggleReadOnly();
1012 owner->buffer()->setReadonly(
1013 !owner->buffer()->isReadonly());
1017 case LFUN_CENTER: // this is center and redraw.
1018 owner->view()->center();
1021 // --- Menus -----------------------------------------------
1026 case LFUN_MENUNEWTMPLT:
1030 case LFUN_CLOSEBUFFER:
1034 case LFUN_MENUWRITE:
1035 if (!owner->buffer()->isUnnamed()) {
1037 s1 << _("Saving document") << ' '
1038 << MakeDisplayPath(owner->buffer()->fileName() + "...");
1039 owner->message(s1.str().c_str());
1040 MenuWrite(owner->view(), owner->buffer());
1042 WriteAs(owner->view(), owner->buffer());
1046 WriteAs(owner->view(), owner->buffer(), argument);
1049 case LFUN_MENURELOAD:
1054 Exporter::Export(owner->buffer(), argument, true);
1058 Exporter::Preview(owner->buffer(), argument);
1061 case LFUN_BUILDPROG:
1062 Exporter::Export(owner->buffer(), "program", true);
1065 case LFUN_RUNCHKTEX:
1066 MenuRunChktex(owner->buffer());
1069 case LFUN_MENUPRINT:
1070 owner->getDialogs()->showPrint();
1074 if (argument == "custom")
1077 Exporter::Export(owner->buffer(), argument, false);
1095 InsetCommandParams p;
1098 if (action == LFUN_TOCVIEW)
1100 p.setCmdName("tableofcontents");
1102 else if (action == LFUN_LOAVIEW )
1103 p.setCmdName("listof{algorithm}{List of Algorithms}");
1104 else if (action == LFUN_LOFVIEW)
1105 p.setCmdName("listoffigures");
1107 p.setCmdName("listoftables");
1109 owner->getDialogs()->createTOC(p.getAsString());
1113 case LFUN_DIALOG_TABULAR_INSERT:
1114 owner->getDialogs()->showTabularCreate();
1122 AutoSave(owner->view());
1126 owner->view()->menuUndo();
1130 owner->view()->menuRedo();
1133 case LFUN_MENUSEARCH:
1134 owner->getDialogs()->showSearch();
1137 case LFUN_REMOVEERRORS:
1138 if (owner->view()->removeAutoInsets()) {
1139 owner->view()->redraw();
1140 owner->view()->fitCursor();
1145 changeDepth(owner->view(), TEXT(false), 0);
1148 case LFUN_DEPTH_MIN:
1149 changeDepth(owner->view(), TEXT(false), -1);
1152 case LFUN_DEPTH_PLUS:
1153 changeDepth(owner->view(), TEXT(false), 1);
1157 owner->getDialogs()->setUserFreeFont();
1160 case LFUN_RECONFIGURE:
1161 Reconfigure(owner->view());
1165 case LFUN_FLOATSOPERATE:
1166 if (argument == "openfoot")
1167 owner->view()->allFloats(1,0);
1168 else if (argument == "closefoot")
1169 owner->view()->allFloats(0,0);
1170 else if (argument == "openfig")
1171 owner->view()->allFloats(1,1);
1172 else if (argument == "closefig")
1173 owner->view()->allFloats(0,1);
1176 #ifdef WITH_WARNINGS
1177 //#warning Find another implementation here (or another lyxfunc)!
1180 case LFUN_HELP_ABOUTLYX:
1181 owner->getDialogs()->showAboutlyx();
1184 case LFUN_HELP_TEXINFO:
1185 owner->getDialogs()->showTexinfo();
1188 case LFUN_HELP_OPEN:
1190 string const arg = argument;
1192 setErrorMessage(N_("Missing argument"));
1195 owner->prohibitInput();
1196 string const fname = i18nLibFileSearch("doc", arg, "lyx");
1197 if (fname.empty()) {
1198 lyxerr << "LyX: unable to find documentation file `"
1199 << arg << "'. Bad installation?" << endl;
1200 owner->allowInput();
1204 str << _("Opening help file") << ' '
1205 << MakeDisplayPath(fname) << "...";
1206 owner->message(str.str().c_str());
1207 owner->view()->buffer(bufferlist.loadLyXFile(fname, false));
1208 owner->allowInput();
1212 // --- version control -------------------------------
1213 case LFUN_VC_REGISTER:
1215 if (!owner->buffer()->lyxvc.inUse())
1216 owner->buffer()->lyxvc.registrer();
1220 case LFUN_VC_CHECKIN:
1222 if (owner->buffer()->lyxvc.inUse()
1223 && !owner->buffer()->isReadonly())
1224 owner->buffer()->lyxvc.checkIn();
1228 case LFUN_VC_CHECKOUT:
1230 if (owner->buffer()->lyxvc.inUse()
1231 && owner->buffer()->isReadonly())
1232 owner->buffer()->lyxvc.checkOut();
1236 case LFUN_VC_REVERT:
1238 owner->buffer()->lyxvc.revert();
1244 owner->buffer()->lyxvc.undoLast();
1248 case LFUN_VC_HISTORY:
1250 owner->getDialogs()->showVCLogFile();
1254 // --- buffers ----------------------------------------
1256 case LFUN_SWITCHBUFFER:
1257 owner->view()->buffer(bufferlist.getBuffer(argument));
1262 // servercmd: argument must be <file>:<template>
1263 Buffer * tmpbuf = NewLyxFile(argument);
1265 owner->view()->buffer(tmpbuf);
1269 case LFUN_FILE_OPEN:
1273 case LFUN_LATEX_LOG:
1274 owner->getDialogs()->showLogFile();
1277 case LFUN_LAYOUT_DOCUMENT:
1278 owner->getDialogs()->showDocument();
1281 case LFUN_LAYOUT_PARAGRAPH:
1282 owner->getDialogs()->showParagraph();
1285 case LFUN_LAYOUT_CHARACTER:
1286 owner->getDialogs()->showCharacter();
1289 case LFUN_LAYOUT_TABULAR:
1290 if (owner->view()->theLockingInset()) {
1291 if (owner->view()->theLockingInset()->lyxCode()==Inset::TABULAR_CODE) {
1292 InsetTabular * inset = static_cast<InsetTabular *>
1293 (owner->view()->theLockingInset());
1294 inset->openLayoutDialog(owner->view());
1295 } else if (owner->view()->theLockingInset()->
1296 getFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
1297 InsetTabular * inset = static_cast<InsetTabular *>(
1298 owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
1299 inset->openLayoutDialog(owner->view());
1304 case LFUN_LAYOUT_PREAMBLE:
1305 owner->getDialogs()->showPreamble();
1308 case LFUN_DROP_LAYOUTS_CHOICE:
1309 owner->getToolbar()->openLayoutList();
1312 case LFUN_MENU_OPEN_BY_NAME:
1313 owner->getMenubar()->openByName(argument);
1314 break; // RVDK_PATCH_5
1316 case LFUN_SPELLCHECK:
1317 if (lyxrc.isp_command != "none")
1318 owner->getDialogs()->showSpellchecker();
1321 // --- lyxserver commands ----------------------------
1325 setMessage(owner->buffer()->fileName());
1326 lyxerr[Debug::INFO] << "FNAME["
1327 << owner->buffer()->fileName()
1333 dispatch_buffer = keyseq.print();
1334 lyxserver->notifyClient(dispatch_buffer);
1338 case LFUN_GOTOFILEROW:
1342 istringstream istr(argument.c_str());
1343 istr >> file_name >> row;
1344 // Must replace extension of the file to be .lyx and get full path
1345 string const s(ChangeExtension(file_name, ".lyx"));
1347 // Either change buffer or load the file
1348 if (bufferlist.exists(s)) {
1349 owner->view()->buffer(bufferlist.getBuffer(s));
1351 owner->view()->buffer(bufferlist.loadLyXFile(s));
1355 owner->view()->setCursorFromRow(row);
1358 owner->view()->center();
1362 case LFUN_GOTO_PARAGRAPH:
1364 istringstream istr(argument.c_str());
1368 Paragraph * par = owner->buffer()->getParFromID(id);
1370 lyxerr[Debug::INFO] << "No matching paragraph found! ["
1371 << id << "]" << std::endl;
1374 lyxerr << "Paragraph " << par->id()
1375 << " found." << endl;
1379 owner->view()->text->setCursor(owner->view(), par, 0);
1380 owner->view()->setState();
1384 owner->view()->center();
1391 int const qa = lyxaction.LookupFunc(argument);
1392 setMessage(lyxaction.helpText(static_cast<kb_action>(qa)));
1396 // --- toolbar ----------------------------------
1397 case LFUN_PUSH_TOOLBAR:
1399 int nth = strToInt(argument);
1401 setErrorMessage(N_("Push-toolbar needs argument > 0"));
1403 owner->getToolbar()->push(nth);
1408 case LFUN_ADD_TO_TOOLBAR:
1410 if (lyxerr.debugging(Debug::GUI)) {
1411 lyxerr << "LFUN_ADD_TO_TOOLBAR:"
1412 "argument = `" << argument << '\'' << endl;
1414 string tmp(argument);
1415 //lyxerr <<string("Argument: ") + argument);
1416 //lyxerr <<string("Tmp : ") + tmp);
1418 setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
1420 owner->getToolbar()->add(argument, false);
1421 owner->getToolbar()->set();
1426 // --- insert characters ----------------------------------------
1428 // --- Mathed stuff. If we are here, there is no locked inset yet.
1429 case LFUN_MATH_EXTERN:
1430 case LFUN_MATH_NUMBER:
1431 case LFUN_MATH_NONUMBER:
1432 case LFUN_MATH_LIMITS:
1434 setErrorMessage(N_("This is only allowed in math mode!"));
1438 // passthrough hat and underscore outside mathed:
1439 case LFUN_SUBSCRIPT:
1440 dispatch(LFUN_SELFINSERT, "_");
1442 case LFUN_SUPERSCRIPT:
1443 dispatch(LFUN_SELFINSERT, "^");
1446 case LFUN_MATH_PANEL:
1447 owner->getDialogs()->showMathPanel();
1450 case LFUN_CITATION_CREATE:
1452 InsetCommandParams p( "cite" );
1454 if (!argument.empty()) {
1455 // This should be set at source, ie when typing
1456 // "citation-insert foo" in the minibuffer.
1457 // Question: would pybibliographer also need to be
1458 // changed. Suspect so. Leave as-is therefore.
1459 if (contains(argument, "|")) {
1460 p.setContents( token(argument, '|', 0) );
1461 p.setOptions( token(argument, '|', 1) );
1463 p.setContents( argument );
1465 dispatch(LFUN_CITATION_INSERT, p.getAsString());
1467 owner->getDialogs()->createCitation( p.getAsString() );
1471 case LFUN_CHILDOPEN:
1473 string const filename =
1474 MakeAbsPath(argument,
1475 OnlyPath(owner->buffer()->fileName()));
1476 setMessage(N_("Opening child document ") +
1477 MakeDisplayPath(filename) + "...");
1478 owner->view()->savePosition(0);
1479 if (bufferlist.exists(filename))
1480 owner->view()->buffer(bufferlist.getBuffer(filename));
1482 owner->view()->buffer(bufferlist.loadLyXFile(filename));
1486 case LFUN_TOGGLECURSORFOLLOW:
1487 lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
1490 case LFUN_KMAP_OFF: // keymap off
1491 owner->getIntl()->KeyMapOn(false);
1494 case LFUN_KMAP_PRIM: // primary keymap
1495 owner->getIntl()->KeyMapPrim();
1498 case LFUN_KMAP_SEC: // secondary keymap
1499 owner->getIntl()->KeyMapSec();
1502 case LFUN_KMAP_TOGGLE: // toggle keymap
1503 owner->getIntl()->ToggleKeyMap();
1508 // argument contains ';'-terminated commands
1509 while (argument.find(';') != string::npos) {
1511 argument = split(argument, first, ';');
1517 case LFUN_DIALOG_PREFERENCES:
1518 owner->getDialogs()->showPreferences();
1521 case LFUN_SAVEPREFERENCES:
1523 Path p(user_lyxdir);
1524 lyxrc.write("preferences");
1528 case LFUN_SCREEN_FONT_UPDATE:
1530 // handle the screen font changes.
1532 lyxrc.set_font_norm_type();
1533 fontloader.update();
1534 // Of course we should only do the resize and the textcache.clear
1535 // if values really changed...but not very important right now. (Lgb)
1536 // All visible buffers will need resize
1538 // We also need to empty the textcache so that
1539 // the buffer will be formatted correctly after
1545 case LFUN_SET_COLOR:
1548 string const x11_name = split(argument, lyx_name, ' ');
1549 if (lyx_name.empty() || x11_name.empty()) {
1550 setErrorMessage(N_("Syntax: set-color <lyx_name>"
1555 if (!lcolor.setColor(lyx_name, x11_name)) {
1556 static string const err1 (N_("Set-color \""));
1557 static string const err2 (
1558 N_("\" failed - color is undefined "
1559 "or may not be redefined"));
1560 setErrorMessage(_(err1) + lyx_name + _(err2));
1563 lyxColorHandler->updateColor(lcolor.getFromLyXName(lyx_name));
1564 owner->view()->redraw();
1569 owner->message(argument);
1572 case LFUN_MESSAGE_PUSH:
1573 owner->messagePush(argument);
1576 case LFUN_MESSAGE_POP:
1577 owner->messagePop();
1581 // Then if it was none of the above
1582 if (!owner->view()->Dispatch(action, argument))
1583 lyxerr << "A truly unknown func ["
1584 << lyxaction.getActionName(action) << "]!"
1591 commandshortcut.erase();
1593 if (lyxrc.display_shortcuts && show_sc) {
1594 if (action != LFUN_SELFINSERT) {
1595 // Put name of command and list of shortcuts
1596 // for it in minibuffer
1597 string comname = lyxaction.getActionName(action);
1599 kb_action pseudoaction = action;
1600 bool argsadded = false;
1602 if (!argument.empty()) {
1603 // If we have the command with argument,
1606 lyxaction.searchActionArg(action,
1609 if (pseudoaction == -1) {
1610 pseudoaction = action;
1612 comname += " " + argument;
1617 string const shortcuts =
1618 toplevel_keymap->findbinding(pseudoaction);
1620 if (!shortcuts.empty()) {
1621 comname += ": " + shortcuts;
1622 } else if (!argsadded && !argument.empty()) {
1623 comname += " " + argument;
1626 if (!comname.empty()) {
1627 comname = strip(comname);
1628 commandshortcut = "(" + comname + ')';
1630 // Here we could even add a small pause,
1631 // to annoy the user and make him learn
1633 // No! That will just annoy, not teach
1634 // anything. The user will read the messages
1635 // if they are interested. (Asger)
1640 string const res = getMessage();
1643 if (!commandshortcut.empty()) {
1644 owner->getMiniBuffer()->addSet(commandshortcut);
1647 string const msg(_(res) + ' ' + commandshortcut);
1648 owner->message(msg);
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")),
1680 string(lyxrc.document_path)),
1681 make_pair(string(_("Templates")),
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")),
1764 string(lyxrc.document_path)),
1765 make_pair(string(_("Templates")),
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")),
1805 string(lyxrc.document_path)),
1806 make_pair(string(_("Examples")),
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")),
1882 string(lyxrc.document_path)),
1883 make_pair(string(_("Examples")),
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)
1985 dispatch_buffer = m;
1989 void LyXFunc::initMiniBuffer()
1991 string text = _("Welcome to LyX!");
1993 // When meta-fake key is pressed, show the key sequence so far + "M-".
1995 text = keyseq.print();
1999 // Else, when a non-complete key sequence is pressed,
2000 // show the available options.
2001 if (keyseq.length() > 0 && !keyseq.deleted()) {
2002 text = keyseq.printOptions();
2005 // Else, show the buffer state.
2006 else if (owner->view()->available()) {
2007 Buffer * tmpbuf = owner->buffer();
2009 string const nicename =
2010 MakeDisplayPath(tmpbuf->fileName());
2011 // Should we do this instead? (kindo like emacs)
2012 // leaves more room for other information
2015 if (tmpbuf->lyxvc.inUse()) {
2017 text += tmpbuf->lyxvc.versionString();
2019 text += tmpbuf->lyxvc.locker();
2020 if (tmpbuf->isReadonly())
2023 } else if (tmpbuf->isReadonly())
2025 if (!tmpbuf->isLyxClean())
2026 text += _(" (Changed)");
2028 if (text != _("Welcome to LyX!")) // this is a hack
2029 text = _("* No document open *");
2032 owner->message(text);