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 * ====================================================== */
24 #pragma implementation
27 #include "support/lyxalgo.h"
31 #include "bufferlist.h"
32 #include "BufferView.h"
33 #include "ColorHandler.h"
34 #include "lyxserver.h"
38 #include "LyXAction.h"
39 #include "insets/inseturl.h"
40 #include "insets/insetlatexaccent.h"
41 #include "insets/insettoc.h"
42 #include "insets/insetref.h"
43 #include "insets/insetparent.h"
44 #include "insets/insetindex.h"
45 #include "insets/insetinclude.h"
46 #include "insets/insetbib.h"
47 #include "insets/insetcite.h"
48 #include "insets/insettext.h"
49 #include "insets/insetert.h"
50 #include "insets/insetexternal.h"
51 #include "insets/insetgraphics.h"
52 #include "insets/insetfoot.h"
53 #include "insets/insetmarginal.h"
54 #include "insets/insetminipage.h"
55 #include "insets/insetfloat.h"
56 #include "insets/insetlist.h"
57 #include "insets/insettabular.h"
58 #include "insets/insettheorem.h"
59 #include "insets/insetcaption.h"
60 #include "mathed/formulamacro.h"
61 #include "mathed/math_cursor.h"
62 #include "mathed/math_inset.h"
63 #include "minibuffer.h"
66 #include "lyx_gui_misc.h"
67 #include "support/filetools.h"
68 #include "support/FileInfo.h"
69 #include "support/syscall.h"
70 #include "support/lstrings.h"
71 #include "support/path.h"
72 #include "support/lyxfunctional.h"
77 #include "trans_mgr.h"
80 #include "bufferview_funcs.h"
81 #include "frontends/FileDialog.h"
82 #include "frontends/Dialogs.h"
83 #include "frontends/Toolbar.h"
84 #include "frontends/Menubar.h"
85 #include "FloatList.h"
86 #include "converter.h"
89 #include "FontLoader.h"
90 #include "TextCache.h"
92 #include "undo_funcs.h"
99 extern BufferList bufferlist;
100 extern LyXServer * lyxserver;
101 extern int greek_kb_flag;
102 extern bool selection_possible;
103 extern void MenuSendto();
105 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
107 extern void show_symbols_form(LyXFunc *);
109 extern LyXAction lyxaction;
111 extern tex_accent_struct get_accent(kb_action action);
113 extern LyXTextClass::size_type current_layout;
115 extern void ShowLatexLog();
121 class MiniBufferController : public SigC::Object {
124 MiniBufferController() {
128 &MiniBufferController::receiveCommand));
132 &MiniBufferController::receiveArg));
135 void receiveCmd(string const & cmd) {}
137 void receiveArg(string const & arg) {}
145 MiniBufferController mb_ctrl;
151 /* === globals =========================================================== */
153 // Initialization of static member var
154 bool LyXFunc::show_sc = true;
157 LyXFunc::LyXFunc(LyXView * o)
161 lyx_dead_action = LFUN_NOACTION;
162 lyx_calling_dead_action = LFUN_NOACTION;
168 LyXText * LyXFunc::TEXT(bool flag = true) const
171 return owner->view()->text;
172 return owner->view()->getLyXText();
176 // I changed this func slightly. I commented out the ...FinishUndo(),
177 // this means that all places that used to have a moveCursorUpdate, now
178 // have a ...FinishUndo() as the preceeding statement. I have also added
179 // a moveCursorUpdate to some of the functions that updated the cursor, but
180 // that did not show its new position.
182 void LyXFunc::moveCursorUpdate(bool flag, bool selecting)
184 if (selecting || TEXT(flag)->selection.mark()) {
185 TEXT(flag)->setSelection(owner->view());
186 if (TEXT(flag)->bv_owner)
187 owner->view()->toggleToggle();
189 owner->view()->update(TEXT(flag), BufferView::SELECT|BufferView::FITCUR);
190 owner->view()->showCursor();
192 /* ---> Everytime the cursor is moved, show the current font state. */
193 // should this too me moved out of this func?
194 owner->view()->setState();
198 void LyXFunc::handleKeyFunc(kb_action action)
200 char c = keyseq.getiso();
202 if (keyseq.length != -1) c = 0;
204 owner->getIntl()->getTrans()
205 .deadkey(c, get_accent(action).accent, TEXT(false));
206 // Need to reset, in case the minibuffer calls these
210 // copied verbatim from do_accent_char
211 owner->view()->update(TEXT(false),
212 BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
213 TEXT(false)->selection.cursor = TEXT(false)->cursor;
217 void LyXFunc::processKeySym(KeySym keysym, unsigned int state)
221 if (lyxerr.debugging(Debug::KEY)) {
222 char const * tmp = XKeysymToString(keysym);
223 string const stm = (tmp ? tmp : "");
224 lyxerr << "KeySym is "
227 << keysym << "] State is ["
231 // Do nothing if we have nothing (JMarc)
232 if (keysym == NoSymbol) {
233 lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
238 // Can we be sure that this will work for all X-Windows
239 // implementations? (Lgb)
240 // This code snippet makes lyx ignore some keys. Perhaps
241 // all of them should be explictly mentioned?
242 if ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
243 || keysym == XK_Mode_switch || keysym == 0x0) {
247 // Do a one-deep top-level lookup for
248 // cancel and meta-fake keys. RVDK_PATCH_5
249 cancel_meta_seq.reset();
251 int action = cancel_meta_seq.addkey(keysym, state
252 &(ShiftMask|ControlMask
254 if (lyxerr.debugging(Debug::KEY)) {
255 lyxerr << "action first set to [" << action << "]" << endl;
258 // When not cancel or meta-fake, do the normal lookup.
259 // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
260 // Mostly, meta_fake_bit = 0. RVDK_PATCH_5.
261 if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
262 if (lyxerr.debugging(Debug::KEY)) {
263 lyxerr << "meta_fake_bit is ["
264 << meta_fake_bit << "]" << endl;
266 // remove Caps Lock and Mod2 as a modifiers
267 action = keyseq.addkey(keysym,
268 (state | meta_fake_bit)
269 &(ShiftMask|ControlMask
271 if (lyxerr.debugging(Debug::KEY)) {
272 lyxerr << "action now set to ["
273 << action << "]" << endl;
276 // Dont remove this unless you know what you are doing.
279 if (action == 0) action = LFUN_PREFIX;
281 if (lyxerr.debugging(Debug::KEY)) {
284 lyxerr << "Key [action="
290 // already here we know if it any point in going further
291 // why not return already here if action == -1 and
292 // num_bytes == 0? (Lgb)
294 if (keyseq.length > 1 || keyseq.length < -1) {
301 // It is unknown, but what if we remove all
302 // the modifiers? (Lgb)
303 action = keyseq.addkey(keysym, 0);
305 if (lyxerr.debugging(Debug::KEY)) {
306 lyxerr << "Removing modifiers...\n"
307 << "Action now set to ["
308 << action << "]" << endl;
311 owner->message(_("Unknown function."));
316 if (action == LFUN_SELFINSERT) {
317 // This is very X dependant.
318 unsigned int c = keysym;
320 switch (c & 0x0000FF00) {
321 // latin 1 byte 3 = 0
322 case 0x00000000: break;
323 // latin 2 byte 3 = 1
325 // latin 3 byte 3 = 2
327 // latin 4 byte 3 = 3
329 // latin 8 byte 3 = 18 (0x12)
331 // latin 9 byte 3 = 19 (0x13)
340 argument = static_cast<char>(c);
341 lyxerr[Debug::KEY] << "SelfInsert arg[`"
342 << argument << "']" << endl;
345 bool tmp_sc = show_sc;
347 dispatch(action, argument);
354 func_status::value_type LyXFunc::getStatus(int ac) const
356 return getStatus(ac, string());
360 func_status::value_type LyXFunc::getStatus(int ac,
361 string const & not_to_use_arg) const
364 func_status::value_type flag = func_status::OK;
366 Buffer * buf = owner->buffer();
368 if (lyxaction.isPseudoAction(ac))
369 action = lyxaction.retrieveActionArg(ac, argument);
371 action = static_cast<kb_action>(ac);
372 if (!not_to_use_arg.empty())
373 argument = not_to_use_arg; // exept here
376 if (action == LFUN_UNKNOWN_ACTION) {
377 setErrorMessage(N_("Unknown action"));
378 return func_status::Unknown;
381 // Check whether we need a buffer
382 if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) {
383 // Yes we need a buffer, do we have one?
386 // Can we use a readonly buffer?
387 if (buf->isReadonly() &&
388 !lyxaction.funcHasFlag(action,
389 LyXAction::ReadOnly)) {
391 setErrorMessage(N_("Document is read-only"));
392 flag |= func_status::Disabled;
396 setErrorMessage(N_("Command not allowed with"
397 "out any document open"));
398 flag |= func_status::Disabled;
403 // I would really like to avoid having this switch and rather try to
404 // encode this in the function itself.
405 bool disable = false;
408 disable = !Exporter::IsExportable(buf, "dvi")
409 || lyxrc.print_command == "none";
412 disable = argument == "fax" &&
413 !Exporter::IsExportable(buf, argument);
416 disable = buf->undostack.empty();
419 disable = buf->redostack.empty();
421 case LFUN_SPELLCHECK:
422 disable = lyxrc.isp_command == "none";
425 disable = lyxrc.chktex_command == "none";
428 disable = !Exporter::IsExportable(buf, "program");
431 case LFUN_LAYOUT_TABULAR:
433 if (owner->view()->theLockingInset()) {
434 disable = (owner->view()->theLockingInset()->lyxCode() != Inset::TABULAR_CODE) &&
435 !owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE);
439 case LFUN_TABULAR_FEATURE:
441 if (owner->view()->theLockingInset()) {
442 func_status::value_type ret = func_status::Disabled;
443 if (owner->view()->theLockingInset()->lyxCode() == Inset::TABULAR_CODE) {
444 ret = static_cast<InsetTabular *>
445 (owner->view()->theLockingInset())->
447 } else if (owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
448 ret = static_cast<InsetTabular *>
449 (owner->view()->theLockingInset()->
450 getFirstLockingInsetOfType(Inset::TABULAR_CODE))->
456 static InsetTabular inset(*owner->buffer(), 1, 1);
457 func_status::value_type ret;
460 ret = inset.getStatus(argument);
461 if ((ret & func_status::ToggleOn) ||
462 (ret & func_status::ToggleOff))
463 flag |= func_status::ToggleOff;
467 case LFUN_VC_REGISTER:
468 disable = buf->lyxvc.inUse();
470 case LFUN_VC_CHECKIN:
471 disable = !buf->lyxvc.inUse() || buf->isReadonly();
473 case LFUN_VC_CHECKOUT:
474 disable = !buf->lyxvc.inUse() || !buf->isReadonly();
478 case LFUN_VC_HISTORY:
479 disable = !buf->lyxvc.inUse();
481 case LFUN_BOOKMARK_GOTO:
482 disable = !owner->view()->
483 isSavedPosition(strToUnsignedInt(argument));
487 case LFUN_INSET_TOGGLE:
488 disable = (TEXT(false)->getInset() == 0);
491 case LFUN_MATH_VALIGN: {
492 // I think this test can be simplified (Andre')
493 // mathcursor is != 0 iff we are in math mode
494 //Inset * tli = owner->view()->theLockingInset();
495 //if (tli && (tli->lyxCode() == Inset::MATH_CODE
496 // || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
499 char align = mathcursor->valign();
504 if (argument.empty()) {
505 flag = func_status::OK;
508 if (!contains("tcb", argument[0])) {
512 if (argument[0] == align)
513 flag |= func_status::ToggleOn;
515 flag |= func_status::ToggleOff;
520 case LFUN_MATH_HALIGN: {
521 //Inset * tli = owner->view()->theLockingInset();
522 //if (tli && (tli->lyxCode() == Inset::MATH_CODE
523 // || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
525 char align = mathcursor->halign();
530 if (argument.empty()) {
531 flag = func_status::OK;
534 if (!contains("lcr", argument[0])) {
538 if (argument[0] == align)
539 flag |= func_status::ToggleOn;
541 flag |= func_status::ToggleOff;
546 case LFUN_MATH_MUTATE: {
547 Inset * tli = owner->view()->theLockingInset();
548 if (tli && (tli->lyxCode() == Inset::MATH_CODE)) {
549 MathInsetTypes type = mathcursor->par()->GetType();
550 func_status::value_type box = func_status::ToggleOff;
551 if (argument == "inline") {
552 if (type == LM_OT_SIMPLE)
553 box = func_status::ToggleOn;
554 } else if (argument == "display") {
555 if (type == LM_OT_EQUATION)
556 box = func_status::ToggleOn;
557 } else if (argument == "eqnarray") {
558 if (type == LM_OT_EQNARRAY)
559 box = func_status::ToggleOn;
560 } else if (argument == "align") {
561 if (type == LM_OT_ALIGN)
562 box = func_status::ToggleOn;
564 box = func_status::OK;
573 // we just need to be in math mode to enable that
575 case LFUN_MATH_LIMITS:
576 case LFUN_MATH_NONUMBER:
577 case LFUN_MATH_NUMBER:
578 disable = !mathcursor;
581 // we need to be math mode and a math array for that
582 // Hack: halign produces non-zero result iff we are in a math array
583 case LFUN_MATH_ROW_INSERT:
584 case LFUN_MATH_ROW_DELETE:
585 case LFUN_MATH_COLUMN_INSERT:
586 case LFUN_MATH_COLUMN_DELETE:
587 disable = !mathcursor || !mathcursor->halign();
594 // the functions which insert insets
595 Inset::Code code = Inset::NO_CODE;
597 case LFUN_INSET_TEXT:
598 code = Inset::TEXT_CODE;
601 code = Inset::ERT_CODE;
604 case LFUN_INSET_GRAPHICS:
605 code = Inset::GRAPHICS_CODE;
607 case LFUN_INSET_FOOTNOTE:
608 code = Inset::FOOT_CODE;
610 case LFUN_DIALOG_TABULAR_INSERT:
611 case LFUN_INSET_TABULAR:
612 code = Inset::TABULAR_CODE;
614 case LFUN_INSET_EXTERNAL:
615 code = Inset::EXTERNAL_CODE;
617 case LFUN_INSET_MARGINAL:
618 code = Inset::MARGIN_CODE;
620 case LFUN_INSET_MINIPAGE:
621 code = Inset::MINIPAGE_CODE;
623 case LFUN_INSET_FLOAT:
624 case LFUN_INSET_WIDE_FLOAT:
625 code = Inset::FLOAT_CODE;
627 case LFUN_FLOAT_LIST:
628 code = Inset::FLOAT_LIST_CODE;
631 case LFUN_INSET_LIST:
632 code = Inset::LIST_CODE;
635 case LFUN_INSET_THEOREM:
636 code = Inset::THEOREM_CODE;
638 case LFUN_INSET_CAPTION:
639 code = Inset::CAPTION_CODE;
641 case LFUN_INSERT_NOTE:
642 code = Inset::IGNORE_CODE;
644 case LFUN_INSERT_LABEL:
645 code = Inset::LABEL_CODE;
647 case LFUN_REF_INSERT:
648 code = Inset::REF_CODE;
650 case LFUN_CITATION_CREATE:
651 case LFUN_CITATION_INSERT:
652 code = Inset::CITE_CODE;
654 case LFUN_INSERT_BIBTEX:
655 code = Inset::BIBTEX_CODE;
657 case LFUN_INDEX_INSERT:
658 case LFUN_INDEX_INSERT_LAST:
659 case LFUN_INDEX_CREATE:
660 code = Inset::INDEX_CODE;
662 case LFUN_INDEX_PRINT:
663 code = Inset::INDEX_PRINT_CODE;
665 case LFUN_CHILD_INSERT:
666 code = Inset::INCLUDE_CODE;
668 case LFUN_TOC_INSERT:
669 code = Inset::TOC_CODE;
671 case LFUN_PARENTINSERT:
672 code = Inset::PARENT_CODE;
676 case LFUN_INSERT_URL:
677 code = Inset::URL_CODE;
680 // always allow this, since we will inset a raw quote
681 // if an inset is not allowed.
683 case LFUN_HYPHENATION:
684 case LFUN_LIGATURE_BREAK:
686 case LFUN_MENU_SEPARATOR:
688 case LFUN_END_OF_SENTENCE:
689 case LFUN_PROTECTEDSPACE:
691 code = Inset::SPECIALCHAR_CODE;
696 if (code != Inset::NO_CODE
697 && owner->view()->theLockingInset()
698 && !owner->view()->theLockingInset()->insetAllowed(code)) {
703 flag |= func_status::Disabled;
705 // the font related functions
706 func_status::value_type box = func_status::ToggleOff;
707 LyXFont const & font =
708 TEXT(false)->real_current_font;
711 if (font.emph() == LyXFont::ON)
712 box = func_status::ToggleOn;
715 if (font.noun() == LyXFont::ON)
716 box = func_status::ToggleOn;
719 if (font.series() == LyXFont::BOLD_SERIES)
720 box = func_status::ToggleOn;
724 if (font.latex() == LyXFont::ON)
725 box = func_status::ToggleOn;
728 case LFUN_READ_ONLY_TOGGLE:
729 if (buf->isReadonly())
730 box = func_status::ToggleOn;
733 box = func_status::OK;
742 // temporary dispatch method
743 void LyXFunc::miniDispatch(string const & s)
751 string const LyXFunc::dispatch(string const & s)
753 // Split command string into command and argument
755 string line = frontStrip(s);
756 string const arg = strip(frontStrip(split(line, cmd, ' ')));
758 return dispatch(lyxaction.LookupFunc(cmd), arg);
762 string const LyXFunc::dispatch(int ac,
763 string const & do_not_use_this_arg)
765 lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << ac
766 <<"] arg[" << do_not_use_this_arg << "]" << endl;
771 // we have not done anything wrong yet.
773 dispatch_buffer.erase();
775 // if action is a pseudo-action, we need the real action
776 if (lyxaction.isPseudoAction(ac)) {
778 action = static_cast<kb_action>
779 (lyxaction.retrieveActionArg(ac, tmparg));
783 action = static_cast<kb_action>(ac);
784 if (!do_not_use_this_arg.empty())
785 argument = do_not_use_this_arg; // except here
788 #ifdef NEW_DISPATCHER
789 // We try do call the most specific dispatcher first:
790 // 1. the lockinginset's dispatch
791 // 2. the bufferview's dispatch
792 // 3. the lyxview's dispatch
795 selection_possible = false;
797 if (owner->view()->available())
798 owner->view()->hideCursor();
800 // We cannot use this function here
801 if (getStatus(ac, do_not_use_this_arg) & func_status::Disabled)
802 goto exit_with_message;
805 if (owner->view()->available() && owner->view()->theLockingInset()) {
806 UpdatableInset::RESULT result;
807 if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
808 (keyseq.length >= -1)))
810 if ((action==LFUN_UNKNOWN_ACTION) && argument.empty()){
811 argument = keyseq.getiso();
813 // Undo/Redo is a bit tricky for insets.
814 if (action == LFUN_UNDO) {
815 #ifdef RETHINK_THIS_FOR_NOW_WE_LEAVE_ALL_UNLOCKED
818 UpdatableInset * inset =
819 owner->view()->theLockingInset()->getLockingInset();
820 int inset_id = inset->id();
821 inset->getCursorPos(owner->view(), slx, sly);
822 owner->view()->unlockInset(inset);
824 owner->view()->unlockInset(owner->view()->theLockingInset());
826 owner->view()->menuUndo();
827 #ifdef RETHINK_THIS_FOR_NOW_WE_LEAVE_ALL_UNLOCKED
829 if (TEXT()->cursor.par()->
830 isInset(TEXT()->cursor.pos())) {
831 inset = static_cast<UpdatableInset*>(
832 TEXT()->cursor.par()->
839 inset = static_cast<UpdatableInset *>(owner->view()->buffer()->getInsetFromID(inset_id));
842 inset->edit(owner->view(),slx,sly,0);
845 } else if (action == LFUN_REDO) {
848 UpdatableInset * inset = owner->view()->
850 inset->getCursorPos(owner->view(), slx, sly);
851 owner->view()->unlockInset(inset);
852 owner->view()->menuRedo();
853 inset = static_cast<UpdatableInset*>(
854 TEXT()->cursor.par()->
858 inset->edit(owner->view(),slx,sly,0);
860 } else if (((result=owner->view()->theLockingInset()->
861 localDispatch(owner->view(), action,
863 UpdatableInset::DISPATCHED) ||
864 (result == UpdatableInset::DISPATCHED_NOUPDATE))
867 //setMessage(N_("Text mode"));
869 case LFUN_UNKNOWN_ACTION:
870 case LFUN_BREAKPARAGRAPH:
872 TEXT()->cursorRight(owner->view());
873 owner->view()->setState();
877 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
878 TEXT()->cursorRight(owner->view());
879 moveCursorUpdate(true, false);
884 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
885 TEXT()->cursorRight(owner->view());
886 moveCursorUpdate(true, false);
891 if (TEXT()->cursor.row()->next())
892 TEXT()->cursorDown(owner->view());
894 TEXT()->cursorRight(owner->view());
895 moveCursorUpdate(true, false);
905 lyx::Assert(action != LFUN_SELECT_FILE_SYNC);
911 if (!owner->view()->available()) break;
913 // this function should be used always [asierra060396]
914 UpdatableInset * tli =
915 owner->view()->theLockingInset();
917 UpdatableInset * lock = tli->getLockingInset();
920 owner->view()->unlockInset(tli);
921 TEXT()->cursorRight(owner->view());
922 moveCursorUpdate(true, false);
925 tli->unlockInsetInInset(owner->view(),
933 // --- Misc -------------------------------------------
934 case LFUN_WORDFINDFORWARD :
935 case LFUN_WORDFINDBACKWARD : {
936 static string last_search;
937 string searched_string;
939 if (!argument.empty()) {
940 last_search = argument;
941 searched_string = argument;
943 searched_string = last_search;
945 bool fw = (action == LFUN_WORDFINDBACKWARD);
946 if (!searched_string.empty()) {
947 LyXFind(owner->view(), searched_string, fw);
949 // owner->view()->showCursor();
955 if (owner->view()->available() && !owner->view()->theLockingInset()) {
956 owner->view()->update(TEXT(),
957 BufferView::SELECT|BufferView::FITCUR);
960 keyseq.print(buf, true);
965 // --- Misc -------------------------------------------
966 case LFUN_EXEC_COMMAND:
968 std::vector<string> allCmds;
969 std::transform(lyxaction.func_begin(), lyxaction.func_end(),
970 std::back_inserter(allCmds), lyx::firster());
971 static std::vector<string> hist;
972 owner->getMiniBuffer()->getString(MiniBuffer::spaces,
977 case LFUN_CANCEL: // RVDK_PATCH_5
980 if (owner->view()->available())
981 // cancel any selection
982 dispatch(LFUN_MARK_OFF);
983 setMessage(N_("Cancel"));
986 case LFUN_META_FAKE: // RVDK_PATCH_5
988 meta_fake_bit = Mod1Mask;
990 keyseq.print(buf, true);
991 setMessage(buf); // RVDK_PATCH_5
995 case LFUN_READ_ONLY_TOGGLE:
996 if (owner->buffer()->lyxvc.inUse()) {
997 owner->buffer()->lyxvc.toggleReadOnly();
999 owner->buffer()->setReadonly(
1000 !owner->buffer()->isReadonly());
1004 case LFUN_CENTER: // this is center and redraw.
1005 owner->view()->center();
1008 // --- Menus -----------------------------------------------
1013 case LFUN_MENUNEWTMPLT:
1017 case LFUN_CLOSEBUFFER:
1021 case LFUN_MENUWRITE:
1022 if (!owner->buffer()->isUnnamed()) {
1024 s1 << _("Saving document") << ' '
1025 << MakeDisplayPath(owner->buffer()->fileName() + "...");
1026 owner->message(s1.str().c_str());
1027 MenuWrite(owner->view(), owner->buffer());
1029 WriteAs(owner->view(), owner->buffer());
1033 WriteAs(owner->view(), owner->buffer(), argument);
1036 case LFUN_MENURELOAD:
1041 Exporter::Export(owner->buffer(), argument, true);
1045 Exporter::Preview(owner->buffer(), argument);
1048 case LFUN_BUILDPROG:
1049 Exporter::Export(owner->buffer(), "program", true);
1052 case LFUN_RUNCHKTEX:
1053 MenuRunChktex(owner->buffer());
1056 case LFUN_MENUPRINT:
1057 owner->getDialogs()->showPrint();
1061 if (argument == "custom")
1064 Exporter::Export(owner->buffer(), argument, false);
1082 InsetCommandParams p;
1085 if (action == LFUN_TOCVIEW)
1087 p.setCmdName("tableofcontents");
1089 else if (action == LFUN_LOAVIEW )
1090 p.setCmdName("listof{algorithm}{List of Algorithms}");
1091 else if (action == LFUN_LOFVIEW)
1092 p.setCmdName("listoffigures");
1094 p.setCmdName("listoftables");
1096 owner->getDialogs()->createTOC(p.getAsString());
1100 case LFUN_DIALOG_TABULAR_INSERT:
1101 owner->getDialogs()->showTabularCreate();
1109 AutoSave(owner->view());
1113 owner->view()->menuUndo();
1117 owner->view()->menuRedo();
1120 case LFUN_MENUSEARCH:
1121 owner->getDialogs()->showSearch();
1124 case LFUN_REMOVEERRORS:
1125 if (owner->view()->removeAutoInsets()) {
1126 owner->view()->redraw();
1127 owner->view()->fitCursor(TEXT());
1132 changeDepth(owner->view(), TEXT(false), 0);
1135 case LFUN_DEPTH_MIN:
1136 changeDepth(owner->view(), TEXT(false), -1);
1139 case LFUN_DEPTH_PLUS:
1140 changeDepth(owner->view(), TEXT(false), 1);
1144 owner->getDialogs()->setUserFreeFont();
1150 owner->view()->setState();
1155 case LFUN_RECONFIGURE:
1156 Reconfigure(owner->view());
1160 case LFUN_FLOATSOPERATE:
1161 if (argument == "openfoot")
1162 owner->view()->allFloats(1,0);
1163 else if (argument == "closefoot")
1164 owner->view()->allFloats(0,0);
1165 else if (argument == "openfig")
1166 owner->view()->allFloats(1,1);
1167 else if (argument == "closefig")
1168 owner->view()->allFloats(0,1);
1171 #ifdef WITH_WARNINGS
1172 #warning Find another implementation here (or another lyxfunc)!
1175 case LFUN_HELP_ABOUTLYX:
1176 owner->getDialogs()->showAboutlyx();
1179 case LFUN_HELP_COPYRIGHT:
1180 case LFUN_HELP_CREDITS:
1183 case LFUN_HELP_OPEN:
1185 string const arg = argument;
1187 setErrorMessage(N_("Missing argument"));
1190 owner->prohibitInput();
1191 string const fname = i18nLibFileSearch("doc", arg, "lyx");
1192 if (fname.empty()) {
1193 lyxerr << "LyX: unable to find documentation file `"
1194 << arg << "'. Bad installation?" << endl;
1195 owner->allowInput();
1199 str << _("Opening help file") << ' '
1200 << MakeDisplayPath(fname) << "...";
1201 owner->message(str.str().c_str());
1202 owner->view()->buffer(bufferlist.loadLyXFile(fname, false));
1203 owner->allowInput();
1207 case LFUN_HELP_VERSION:
1209 // --- version control -------------------------------
1210 case LFUN_VC_REGISTER:
1212 if (!owner->buffer()->lyxvc.inUse())
1213 owner->buffer()->lyxvc.registrer();
1217 case LFUN_VC_CHECKIN:
1219 if (owner->buffer()->lyxvc.inUse()
1220 && !owner->buffer()->isReadonly())
1221 owner->buffer()->lyxvc.checkIn();
1225 case LFUN_VC_CHECKOUT:
1227 if (owner->buffer()->lyxvc.inUse()
1228 && owner->buffer()->isReadonly())
1229 owner->buffer()->lyxvc.checkOut();
1233 case LFUN_VC_REVERT:
1235 owner->buffer()->lyxvc.revert();
1241 owner->buffer()->lyxvc.undoLast();
1245 case LFUN_VC_HISTORY:
1247 owner->getDialogs()->showVCLogFile();
1251 // --- buffers ----------------------------------------
1253 case LFUN_SWITCHBUFFER:
1254 owner->view()->buffer(bufferlist.getBuffer(argument));
1259 // servercmd: argument must be <file>:<template>
1260 Buffer * tmpbuf = NewLyxFile(argument);
1262 owner->view()->buffer(tmpbuf);
1266 case LFUN_FILE_OPEN:
1270 case LFUN_LATEX_LOG:
1271 owner->getDialogs()->showLogFile();
1276 lyxerr[Debug::INFO] << "LFUN_LAYOUTNO: (arg) " << argument << endl;
1277 int sel = strToInt(argument);
1278 lyxerr[Debug::INFO] << "LFUN_LAYOUTNO: (sel) "<< sel << endl;
1280 // Should this give a setMessage instead?
1282 return string(); // illegal argument
1284 --sel; // sel 1..., but layout 0...
1286 // Pretend we got the name instead.
1287 dispatch(int(LFUN_LAYOUT),
1288 textclasslist.NameOfLayout(owner->view()
1289 ->buffer()->params.textclass,
1294 case LFUN_LAYOUT_DOCUMENT:
1295 owner->getDialogs()->showDocument();
1298 case LFUN_LAYOUT_PARAGRAPH:
1299 owner->getDialogs()->showParagraph();
1302 case LFUN_LAYOUT_CHARACTER:
1303 owner->getDialogs()->showCharacter();
1306 case LFUN_LAYOUT_TABULAR:
1307 if (owner->view()->theLockingInset()) {
1308 if (owner->view()->theLockingInset()->lyxCode()==Inset::TABULAR_CODE) {
1309 InsetTabular * inset = static_cast<InsetTabular *>
1310 (owner->view()->theLockingInset());
1311 inset->openLayoutDialog(owner->view());
1312 } else if (owner->view()->theLockingInset()->
1313 getFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
1314 InsetTabular * inset = static_cast<InsetTabular *>(
1315 owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
1316 inset->openLayoutDialog(owner->view());
1321 case LFUN_LAYOUT_PREAMBLE:
1322 owner->getDialogs()->showPreamble();
1325 case LFUN_LAYOUT_SAVE_DEFAULT:
1326 MenuLayoutSave(owner->view());
1329 case LFUN_DROP_LAYOUTS_CHOICE:
1330 owner->getToolbar()->openLayoutList();
1333 case LFUN_MENU_OPEN_BY_NAME:
1334 owner->getMenubar()->openByName(argument);
1335 break; // RVDK_PATCH_5
1337 case LFUN_SPELLCHECK:
1338 if (lyxrc.isp_command != "none")
1339 owner->getDialogs()->showSpellchecker();
1342 // --- lyxserver commands ----------------------------
1346 setMessage(owner->buffer()->fileName());
1347 lyxerr[Debug::INFO] << "FNAME["
1348 << owner->buffer()->fileName()
1356 dispatch_buffer = buf;
1357 lyxserver->notifyClient(dispatch_buffer);
1361 case LFUN_GOTOFILEROW:
1364 char file_name[100];
1366 ::sscanf(argument.c_str(), " %s %d", file_name, &row);
1370 istringstream istr(argument.c_str());
1371 istr >> file_name >> row;
1373 // Must replace extension of the file to be .lyx and get full path
1374 string const s(ChangeExtension(file_name, ".lyx"));
1376 // Either change buffer or load the file
1377 if (bufferlist.exists(s)) {
1378 owner->view()->buffer(bufferlist.getBuffer(s));
1380 owner->view()->buffer(bufferlist.loadLyXFile(s));
1384 owner->view()->setCursorFromRow(row);
1387 owner->view()->center();
1391 case LFUN_GOTO_PARAGRAPH:
1393 istringstream istr(argument.c_str());
1397 Paragraph * par = owner->buffer()->getParFromID(id);
1399 lyxerr[Debug::INFO] << "No matching paragraph found! ["
1400 << id << "]" << std::endl;
1405 TEXT()->setCursor(owner->view(), par, 0);
1406 owner->view()->setState();
1410 owner->view()->center();
1417 int const qa = lyxaction.LookupFunc(argument);
1418 setMessage(lyxaction.helpText(static_cast<kb_action>(qa)));
1422 // --- toolbar ----------------------------------
1423 case LFUN_PUSH_TOOLBAR:
1425 int nth = strToInt(argument);
1427 setErrorMessage(N_("Push-toolbar needs argument > 0"));
1429 owner->getToolbar()->push(nth);
1434 case LFUN_ADD_TO_TOOLBAR:
1436 if (lyxerr.debugging(Debug::GUI)) {
1437 lyxerr << "LFUN_ADD_TO_TOOLBAR:"
1438 "argument = `" << argument << '\'' << endl;
1440 string tmp(argument);
1441 //lyxerr <<string("Argument: ") + argument);
1442 //lyxerr <<string("Tmp : ") + tmp);
1444 setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
1446 owner->getToolbar()->add(argument, false);
1447 owner->getToolbar()->set();
1452 // --- insert characters ----------------------------------------
1454 // --- Mathed stuff. If we are here, there is no locked inset yet.
1459 if (!greek_kb_flag) {
1461 setMessage(N_("Math greek mode on"));
1468 case LFUN_GREEK_TOGGLE:
1470 greek_kb_flag = greek_kb_flag ? 0 : 2;
1471 if (greek_kb_flag) {
1472 setMessage(N_("Math greek keyboard on"));
1474 setMessage(N_("Math greek keyboard off"));
1479 case LFUN_MATH_EXTERN:
1480 case LFUN_MATH_NUMBER:
1481 case LFUN_MATH_NONUMBER:
1482 case LFUN_MATH_LIMITS:
1484 setErrorMessage(N_("This is only allowed in math mode!"));
1488 case LFUN_MATH_PANEL:
1489 owner->getDialogs()->showMathPanel();
1492 case LFUN_CITATION_CREATE:
1494 InsetCommandParams p( "cite" );
1496 if (!argument.empty()) {
1497 // This should be set at source, ie when typing
1498 // "citation-insert foo" in the minibuffer.
1499 // Question: would pybibliographer also need to be
1500 // changed. Suspect so. Leave as-is therefore.
1501 if (contains(argument, "|")) {
1502 p.setContents( token(argument, '|', 0) );
1503 p.setOptions( token(argument, '|', 1) );
1505 p.setContents( argument );
1507 dispatch(LFUN_CITATION_INSERT, p.getAsString());
1509 owner->getDialogs()->createCitation( p.getAsString() );
1513 case LFUN_CHILDOPEN:
1515 string const filename =
1516 MakeAbsPath(argument,
1517 OnlyPath(owner->buffer()->fileName()));
1518 setMessage(N_("Opening child document ") +
1519 MakeDisplayPath(filename) + "...");
1520 owner->view()->savePosition(0);
1521 if (bufferlist.exists(filename))
1522 owner->view()->buffer(bufferlist.getBuffer(filename));
1524 owner->view()->buffer(bufferlist.loadLyXFile(filename));
1528 case LFUN_TOGGLECURSORFOLLOW:
1529 lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
1532 case LFUN_KMAP_OFF: // keymap off
1533 owner->getIntl()->KeyMapOn(false);
1536 case LFUN_KMAP_PRIM: // primary keymap
1537 owner->getIntl()->KeyMapPrim();
1540 case LFUN_KMAP_SEC: // secondary keymap
1541 owner->getIntl()->KeyMapSec();
1544 case LFUN_KMAP_TOGGLE: // toggle keymap
1545 owner->getIntl()->ToggleKeyMap();
1550 // argument contains ';'-terminated commands
1551 while (argument.find(';') != string::npos) {
1553 argument = split(argument, first, ';');
1559 case LFUN_DIALOG_PREFERENCES:
1560 owner->getDialogs()->showPreferences();
1563 case LFUN_SAVEPREFERENCES:
1565 Path p(user_lyxdir);
1566 lyxrc.write("preferences");
1570 case LFUN_SCREEN_FONT_UPDATE:
1572 // handle the screen font changes.
1574 lyxrc.set_font_norm_type();
1575 fontloader.update();
1576 // Of course we should only do the resize and the textcache.clear
1577 // if values really changed...but not very important right now. (Lgb)
1578 // All visible buffers will need resize
1580 // We also need to empty the textcache so that
1581 // the buffer will be formatted correctly after
1587 case LFUN_SET_COLOR:
1590 string const x11_name = split(argument, lyx_name, ' ');
1591 if (lyx_name.empty() || x11_name.empty()) {
1592 setErrorMessage(N_("Syntax: set-color <lyx_name>"
1597 if (!lcolor.setColor(lyx_name, x11_name)) {
1598 static string const err1 (N_("Set-color \""));
1599 static string const err2 (
1600 N_("\" failed - color is undefined "
1601 "or may not be redefined"));
1602 setErrorMessage(_(err1) + lyx_name + _(err2));
1605 lyxColorHandler->updateColor(lcolor.getFromLyXName(lyx_name));
1606 owner->view()->redraw();
1611 owner->message(argument);
1614 case LFUN_MESSAGE_PUSH:
1615 owner->messagePush(argument);
1618 case LFUN_MESSAGE_POP:
1619 owner->messagePop();
1623 // Then if it was none of the above
1624 if (!owner->view()->Dispatch(action, argument))
1625 lyxerr << "A truly unknown func ["
1626 << lyxaction.getActionName(action) << "]!"
1633 commandshortcut.erase();
1635 if (lyxrc.display_shortcuts && show_sc) {
1636 if (action != LFUN_SELFINSERT) {
1637 // Put name of command and list of shortcuts
1638 // for it in minibuffer
1639 string comname = lyxaction.getActionName(action);
1641 int pseudoaction = action;
1642 bool argsadded = false;
1644 if (!argument.empty()) {
1645 // If we have the command with argument,
1648 lyxaction.searchActionArg(action,
1651 if (pseudoaction == -1) {
1652 pseudoaction = action;
1654 comname += " " + argument;
1659 string const shortcuts =
1660 toplevel_keymap->findbinding(pseudoaction);
1662 if (!shortcuts.empty()) {
1663 comname += ": " + shortcuts;
1664 } else if (!argsadded) {
1665 comname += " " + argument;
1668 if (!comname.empty()) {
1669 comname = strip(comname);
1670 commandshortcut = "(" + comname + ')';
1672 // Here we could even add a small pause,
1673 // to annoy the user and make him learn
1675 // No! That will just annoy, not teach
1676 // anything. The user will read the messages
1677 // if they are interested. (Asger)
1682 string const res = getMessage();
1685 if (!commandshortcut.empty()) {
1686 owner->getMiniBuffer()->addSet(commandshortcut);
1689 string const msg(_(res) + ' ' + commandshortcut);
1690 owner->message(msg);
1697 void LyXFunc::setupLocalKeymap()
1699 keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
1700 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap.get();
1704 void LyXFunc::menuNew(bool fromTemplate)
1706 string initpath = lyxrc.document_path;
1708 if (owner->view()->available()) {
1709 string const trypath = owner->buffer()->filepath;
1710 // If directory is writeable, use this as default.
1711 if (IsDirWriteable(trypath) == 1)
1715 static int newfile_number;
1718 if (lyxrc.new_ask_filename) {
1719 FileDialog fileDlg(owner, _("Enter filename for new document"),
1720 LFUN_SELECT_FILE_SYNC,
1721 make_pair(string(_("Documents")),
1722 string(lyxrc.document_path)),
1723 make_pair(string(_("Templates")),
1724 string(lyxrc.template_path)));
1726 FileDialog::Result result =
1727 fileDlg.Select(initpath,
1728 _("*.lyx|LyX Documents (*.lyx)"),
1731 if (result.second.empty()) {
1732 owner->message(_("Canceled."));
1733 lyxerr[Debug::INFO] << "New Document Cancelled." << endl;
1737 // get absolute path of file and make sure the filename ends
1739 s = MakeAbsPath(result.second);
1740 if (!IsLyXFilename(s))
1743 // Check if the document already is open
1744 if (bufferlist.exists(s)) {
1745 switch (AskConfirmation(_("Document is already open:"),
1746 MakeDisplayPath(s, 50),
1747 _("Do you want to close that document now?\n"
1748 "('No' will just switch to the open version)")))
1750 case 1: // Yes: close the document
1751 if (!bufferlist.close(bufferlist.getBuffer(s)))
1752 // If close is canceled, we cancel here too.
1755 case 2: // No: switch to the open document
1756 owner->view()->buffer(bufferlist.getBuffer(s));
1758 case 3: // Cancel: Do nothing
1759 owner->message(_("Canceled."));
1763 // Check whether the file already exists
1765 if (fi.readable() &&
1766 AskQuestion(_("File already exists:"),
1767 MakeDisplayPath(s, 50),
1768 _("Do you want to open the document?"))) {
1770 string const disp_fn(MakeDisplayPath(s));
1773 str << _("Opening document") << ' '
1774 << disp_fn << "...";
1776 owner->message(str.str().c_str());
1777 //XFlush(fl_get_display());
1778 owner->view()->buffer(bufferlist.loadLyXFile(s));
1780 str2 << _("Document") << ' '
1781 << disp_fn << ' ' << _("opened.");
1783 owner->message(str2.str().c_str());
1788 s = AddName(lyxrc.document_path,
1789 "newfile" + tostr(++newfile_number) + ".lyx");
1791 while (bufferlist.exists(s) || fi.readable()) {
1793 s = AddName(lyxrc.document_path,
1794 "newfile" + tostr(newfile_number) +
1800 // The template stuff
1803 FileDialog fileDlg(owner, _("Select template file"),
1804 LFUN_SELECT_FILE_SYNC,
1805 make_pair(string(_("Documents")),
1806 string(lyxrc.document_path)),
1807 make_pair(string(_("Templates")),
1808 string(lyxrc.template_path)));
1810 FileDialog::Result result =
1811 fileDlg.Select(lyxrc.template_path,
1812 _("*.lyx|LyX Documents (*.lyx)"));
1814 if (result.first == FileDialog::Later)
1817 string const fname = result.second;
1824 // find a free buffer
1825 lyxerr[Debug::INFO] << "Find a free buffer." << endl;
1826 owner->view()->buffer(bufferlist.newFile(s, templname));
1830 void LyXFunc::open(string const & fname)
1832 string initpath = lyxrc.document_path;
1834 if (owner->view()->available()) {
1835 string const trypath = owner->buffer()->filepath;
1836 // If directory is writeable, use this as default.
1837 if (IsDirWriteable(trypath) == 1)
1843 if (fname.empty()) {
1844 FileDialog fileDlg(owner, _("Select document to open"),
1846 make_pair(string(_("Documents")),
1847 string(lyxrc.document_path)),
1848 make_pair(string(_("Examples")),
1849 string(AddPath(system_lyxdir, "examples"))));
1851 FileDialog::Result result =
1852 fileDlg.Select(initpath,
1853 "*.lyx|LyX Documents (*.lyx)");
1855 if (result.first == FileDialog::Later)
1858 filename = result.second;
1860 // check selected filename
1861 if (filename.empty()) {
1862 owner->message(_("Canceled."));
1868 // get absolute path of file and add ".lyx" to the filename if
1870 filename = FileSearch(string(), filename, "lyx");
1873 string const disp_fn(MakeDisplayPath(filename));
1876 str << _("Opening document") << ' ' << disp_fn << "...";
1878 owner->message(str.str().c_str());
1880 Buffer * openbuf = bufferlist.loadLyXFile(filename);
1882 owner->view()->buffer(openbuf);
1884 str << _("Document") << ' ' << disp_fn << ' ' << _("opened.");
1885 owner->message(str.str().c_str());
1888 str << _("Could not open docuent") << ' ' << disp_fn;
1889 owner->message(str.str().c_str());
1894 // checks for running without gui are missing.
1895 void LyXFunc::doImport(string const & argument)
1898 string filename = split(argument, format, ' ');
1899 lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format
1900 << " file: " << filename << endl;
1902 if (filename.empty()) { // need user interaction
1903 string initpath = lyxrc.document_path;
1905 if (owner->view()->available()) {
1906 string const trypath = owner->buffer()->filepath;
1907 // If directory is writeable, use this as default.
1908 if (IsDirWriteable(trypath) == 1)
1912 string const text = _("Select ") + formats.PrettyName(format)
1913 + _(" file to import");
1915 FileDialog fileDlg(owner, text,
1917 make_pair(string(_("Documents")),
1918 string(lyxrc.document_path)),
1919 make_pair(string(_("Examples")),
1920 string(AddPath(system_lyxdir, "examples"))));
1922 string const extension = "*." + formats.Extension(format)
1923 + "| " + formats.PrettyName(format)
1924 + " (*." + formats.Extension(format) + ")";
1926 FileDialog::Result result = fileDlg.Select(initpath,
1929 if (result.first == FileDialog::Later)
1932 filename = result.second;
1934 // check selected filename
1935 if (filename.empty())
1936 owner->message(_("Canceled."));
1939 // still no filename? abort
1940 if (filename.empty())
1943 // get absolute path of file
1944 filename = MakeAbsPath(filename);
1946 string const lyxfile = ChangeExtension(filename, ".lyx");
1948 // Check if the document already is open
1949 if (bufferlist.exists(lyxfile)) {
1950 switch (AskConfirmation(_("Document is already open:"),
1951 MakeDisplayPath(lyxfile, 50),
1952 _("Do you want to close that document now?\n"
1953 "('No' will just switch to the open version)")))
1955 case 1: // Yes: close the document
1956 if (!bufferlist.close(bufferlist.getBuffer(lyxfile)))
1957 // If close is canceled, we cancel here too.
1960 case 2: // No: switch to the open document
1961 owner->view()->buffer(bufferlist.getBuffer(lyxfile));
1963 case 3: // Cancel: Do nothing
1964 owner->message(_("Canceled."));
1969 // Check if a LyX document by the same root exists in filesystem
1970 FileInfo const f(lyxfile, true);
1971 if (f.exist() && !AskQuestion(_("A document by the name"),
1972 MakeDisplayPath(lyxfile),
1973 _("already exists. Overwrite?"))) {
1974 owner->message(_("Canceled"));
1977 // filename should be valid now
1979 Importer::Import(owner, filename, format);
1983 void LyXFunc::reloadBuffer()
1985 string const fn = owner->buffer()->fileName();
1986 if (bufferlist.close(owner->buffer()))
1987 owner->view()->buffer(bufferlist.loadLyXFile(fn));
1991 void LyXFunc::closeBuffer()
1993 if (bufferlist.close(owner->buffer()) && !quitting) {
1994 if (bufferlist.empty()) {
1995 // need this otherwise SEGV may occur while trying to
1996 // set variables that don't exist
1997 // since there's no current buffer
1998 owner->getDialogs()->hideBufferDependent();
2000 owner->view()->buffer(bufferlist.first());
2006 // Each "owner" should have it's own message method. lyxview and
2007 // the minibuffer would use the minibuffer, but lyxserver would
2008 // send an ERROR signal to its client. Alejandro 970603
2009 // This func is bit problematic when it comes to NLS, to make the
2010 // lyx servers client be language indepenent we must not translate
2011 // strings sent to this func.
2012 void LyXFunc::setErrorMessage(string const & m) const
2014 dispatch_buffer = m;
2019 void LyXFunc::setMessage(string const & m)
2021 dispatch_buffer = m;
2025 void LyXFunc::initMiniBuffer()
2027 string text = _("Welcome to LyX!");
2029 // When meta-fake key is pressed, show the key sequence so far + "M-".
2035 // Else, when a non-complete key sequence is pressed,
2036 // show the available options.
2037 else if (keyseqUncomplete())
2038 text = keyseqOptions();
2040 // Else, show the buffer state.
2041 else if (owner->view()->available()) {
2042 Buffer * tmpbuf = owner->buffer();
2044 string const nicename =
2045 MakeDisplayPath(tmpbuf->fileName());
2046 // Should we do this instead? (kindo like emacs)
2047 // leaves more room for other information
2050 if (tmpbuf->lyxvc.inUse()) {
2052 text += tmpbuf->lyxvc.version();
2054 text += tmpbuf->lyxvc.locker();
2055 if (tmpbuf->isReadonly())
2058 } else if (tmpbuf->isReadonly())
2060 if (!tmpbuf->isLyxClean())
2061 text += _(" (Changed)");
2063 if (text != _("Welcome to LyX!")) // this is a hack
2064 text = _("* No document open *");
2067 owner->message(text);