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 * ====================================================== */
30 #pragma implementation
33 #include "support/lyxalgo.h"
37 #include "bufferlist.h"
38 #include "BufferView.h"
39 #include "ColorHandler.h"
40 #include "lyxserver.h"
44 #include "LyXAction.h"
45 #include "insets/inseturl.h"
46 #include "insets/insetlatexaccent.h"
47 #include "insets/insettoc.h"
48 #include "insets/insetref.h"
49 #include "insets/insetparent.h"
50 #include "insets/insetindex.h"
51 #include "insets/insetinclude.h"
52 #include "insets/insetbib.h"
53 #include "insets/insetcite.h"
54 #include "insets/insettext.h"
55 #include "insets/insetert.h"
56 #include "insets/insetexternal.h"
57 #include "insets/insetgraphics.h"
58 #include "insets/insetfoot.h"
59 #include "insets/insetmarginal.h"
60 #include "insets/insetminipage.h"
61 #include "insets/insetfloat.h"
63 #include "insets/insetlist.h"
64 #include "insets/insettheorem.h"
66 #include "insets/insettabular.h"
67 #include "insets/insetcaption.h"
68 #include "mathed/formulamacro.h"
69 #include "mathed/math_cursor.h"
70 #include "mathed/math_inset.h"
71 #include "minibuffer.h"
74 #include "lyx_gui_misc.h"
75 #include "support/filetools.h"
76 #include "support/FileInfo.h"
77 #include "support/syscall.h"
78 #include "support/lstrings.h"
79 #include "support/path.h"
80 #include "support/lyxfunctional.h"
85 #include "trans_mgr.h"
88 #include "bufferview_funcs.h"
89 #include "frontends/FileDialog.h"
90 #include "frontends/Dialogs.h"
91 #include "frontends/Toolbar.h"
92 #include "frontends/Menubar.h"
93 #include "FloatList.h"
94 #include "converter.h"
97 #include "FontLoader.h"
98 #include "TextCache.h"
100 #include "undo_funcs.h"
103 using std::make_pair;
107 extern BufferList bufferlist;
108 extern LyXServer * lyxserver;
109 extern int greek_kb_flag;
110 extern bool selection_possible;
111 extern void MenuSendto();
113 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
115 extern void show_symbols_form(LyXFunc *);
117 extern LyXAction lyxaction;
119 extern tex_accent_struct get_accent(kb_action action);
121 extern LyXTextClass::size_type current_layout;
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)
169 lyx_dead_action = LFUN_NOACTION;
170 lyx_calling_dead_action = LFUN_NOACTION;
176 LyXText * LyXFunc::TEXT(bool flag = true) const
179 return owner->view()->text;
180 return owner->view()->getLyXText();
184 // I changed this func slightly. I commented out the ...FinishUndo(),
185 // this means that all places that used to have a moveCursorUpdate, now
186 // have a ...FinishUndo() as the preceeding statement. I have also added
187 // a moveCursorUpdate to some of the functions that updated the cursor, but
188 // that did not show its new position.
190 void LyXFunc::moveCursorUpdate(bool flag, bool selecting)
192 if (selecting || TEXT(flag)->selection.mark()) {
193 TEXT(flag)->setSelection(owner->view());
194 if (TEXT(flag)->bv_owner)
195 owner->view()->toggleToggle();
197 owner->view()->update(TEXT(flag), BufferView::SELECT|BufferView::FITCUR);
198 owner->view()->showCursor();
200 /* ---> Everytime the cursor is moved, show the current font state. */
201 // should this too me moved out of this func?
202 owner->view()->setState();
206 void LyXFunc::handleKeyFunc(kb_action action)
208 char c = keyseq.getiso();
210 if (keyseq.length != -1) c = 0;
212 owner->getIntl()->getTrans()
213 .deadkey(c, get_accent(action).accent, TEXT(false));
214 // Need to reset, in case the minibuffer calls these
218 // copied verbatim from do_accent_char
219 owner->view()->update(TEXT(false),
220 BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
221 TEXT(false)->selection.cursor = TEXT(false)->cursor;
225 void LyXFunc::processKeySym(KeySym keysym, unsigned int state)
229 if (lyxerr.debugging(Debug::KEY)) {
230 char const * tmp = XKeysymToString(keysym);
231 string const stm = (tmp ? tmp : "");
232 lyxerr << "KeySym is "
235 << keysym << "] State is ["
239 // Do nothing if we have nothing (JMarc)
240 if (keysym == NoSymbol) {
241 lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
246 // Can we be sure that this will work for all X-Windows
247 // implementations? (Lgb)
248 // This code snippet makes lyx ignore some keys. Perhaps
249 // all of them should be explictly mentioned?
250 if ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
251 || keysym == XK_Mode_switch || keysym == 0x0) {
255 // Do a one-deep top-level lookup for
256 // cancel and meta-fake keys. RVDK_PATCH_5
257 cancel_meta_seq.reset();
259 int action = cancel_meta_seq.addkey(keysym, state
260 &(ShiftMask|ControlMask
262 if (lyxerr.debugging(Debug::KEY)) {
263 lyxerr << "action first set to [" << action << "]" << endl;
266 // When not cancel or meta-fake, do the normal lookup.
267 // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
268 // Mostly, meta_fake_bit = 0. RVDK_PATCH_5.
269 if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
270 if (lyxerr.debugging(Debug::KEY)) {
271 lyxerr << "meta_fake_bit is ["
272 << meta_fake_bit << "]" << endl;
274 // remove Caps Lock and Mod2 as a modifiers
275 action = keyseq.addkey(keysym,
276 (state | meta_fake_bit)
277 &(ShiftMask|ControlMask
279 if (lyxerr.debugging(Debug::KEY)) {
280 lyxerr << "action now set to ["
281 << action << "]" << endl;
284 // Dont remove this unless you know what you are doing.
287 if (action == 0) action = LFUN_PREFIX;
289 if (lyxerr.debugging(Debug::KEY)) {
292 lyxerr << "Key [action="
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.length < -1) {
309 // It is unknown, but what if we remove all
310 // the modifiers? (Lgb)
311 action = keyseq.addkey(keysym, 0);
313 if (lyxerr.debugging(Debug::KEY)) {
314 lyxerr << "Removing modifiers...\n"
315 << "Action now set to ["
316 << action << "]" << endl;
319 owner->message(_("Unknown function."));
324 if (action == LFUN_SELFINSERT) {
325 // This is very X dependant.
326 unsigned int c = keysym;
328 switch (c & 0x0000FF00) {
329 // latin 1 byte 3 = 0
330 case 0x00000000: break;
331 // latin 2 byte 3 = 1
333 // latin 3 byte 3 = 2
335 // latin 4 byte 3 = 3
337 // latin 8 byte 3 = 18 (0x12)
339 // latin 9 byte 3 = 19 (0x13)
348 argument = static_cast<char>(c);
349 lyxerr[Debug::KEY] << "SelfInsert arg[`"
350 << argument << "']" << endl;
353 bool tmp_sc = show_sc;
355 dispatch(action, argument);
362 func_status::value_type LyXFunc::getStatus(int ac) const
364 return getStatus(ac, string());
368 func_status::value_type LyXFunc::getStatus(int ac,
369 string const & not_to_use_arg) const
372 func_status::value_type flag = func_status::OK;
374 Buffer * buf = owner->buffer();
376 if (lyxaction.isPseudoAction(ac))
377 action = lyxaction.retrieveActionArg(ac, argument);
379 action = static_cast<kb_action>(ac);
380 if (!not_to_use_arg.empty())
381 argument = not_to_use_arg; // exept here
384 if (action == LFUN_UNKNOWN_ACTION) {
385 setErrorMessage(N_("Unknown action"));
386 return func_status::Unknown;
389 // Check whether we need a buffer
390 if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) {
391 // Yes we need a buffer, do we have one?
394 // Can we use a readonly buffer?
395 if (buf->isReadonly() &&
396 !lyxaction.funcHasFlag(action,
397 LyXAction::ReadOnly)) {
399 setErrorMessage(N_("Document is read-only"));
400 flag |= func_status::Disabled;
404 setErrorMessage(N_("Command not allowed with"
405 "out any document open"));
406 flag |= func_status::Disabled;
411 // I would really like to avoid having this switch and rather try to
412 // encode this in the function itself.
413 bool disable = false;
416 disable = !Exporter::IsExportable(buf, "dvi")
417 || lyxrc.print_command == "none";
420 disable = argument == "fax" &&
421 !Exporter::IsExportable(buf, argument);
424 disable = buf->undostack.empty();
427 disable = buf->redostack.empty();
429 case LFUN_SPELLCHECK:
430 disable = lyxrc.isp_command == "none";
433 disable = lyxrc.chktex_command == "none";
436 disable = !Exporter::IsExportable(buf, "program");
439 case LFUN_LAYOUT_TABULAR:
441 if (owner->view()->theLockingInset()) {
442 disable = (owner->view()->theLockingInset()->lyxCode() != Inset::TABULAR_CODE) &&
443 !owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE);
447 case LFUN_TABULAR_FEATURE:
449 if (owner->view()->theLockingInset()) {
450 func_status::value_type ret = func_status::Disabled;
451 if (owner->view()->theLockingInset()->lyxCode() == Inset::TABULAR_CODE) {
452 ret = static_cast<InsetTabular *>
453 (owner->view()->theLockingInset())->
455 } else if (owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
456 ret = static_cast<InsetTabular *>
457 (owner->view()->theLockingInset()->
458 getFirstLockingInsetOfType(Inset::TABULAR_CODE))->
464 static InsetTabular inset(*owner->buffer(), 1, 1);
465 func_status::value_type ret;
468 ret = inset.getStatus(argument);
469 if ((ret & func_status::ToggleOn) ||
470 (ret & func_status::ToggleOff))
471 flag |= func_status::ToggleOff;
475 case LFUN_VC_REGISTER:
476 disable = buf->lyxvc.inUse();
478 case LFUN_VC_CHECKIN:
479 disable = !buf->lyxvc.inUse() || buf->isReadonly();
481 case LFUN_VC_CHECKOUT:
482 disable = !buf->lyxvc.inUse() || !buf->isReadonly();
486 case LFUN_VC_HISTORY:
487 disable = !buf->lyxvc.inUse();
489 case LFUN_BOOKMARK_GOTO:
490 disable = !owner->view()->
491 isSavedPosition(strToUnsignedInt(argument));
495 case LFUN_INSET_TOGGLE:
496 disable = (TEXT(false)->getInset() == 0);
499 case LFUN_MATH_VALIGN: {
500 // I think this test can be simplified (Andre')
501 // mathcursor is != 0 iff we are in math mode
502 //Inset * tli = owner->view()->theLockingInset();
503 //if (tli && (tli->lyxCode() == Inset::MATH_CODE
504 // || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
507 char align = mathcursor->valign();
512 if (argument.empty()) {
513 flag = func_status::OK;
516 if (!contains("tcb", argument[0])) {
520 if (argument[0] == align)
521 flag |= func_status::ToggleOn;
523 flag |= func_status::ToggleOff;
528 case LFUN_MATH_HALIGN: {
529 //Inset * tli = owner->view()->theLockingInset();
530 //if (tli && (tli->lyxCode() == Inset::MATH_CODE
531 // || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
533 char align = mathcursor->halign();
538 if (argument.empty()) {
539 flag = func_status::OK;
542 if (!contains("lcr", argument[0])) {
546 if (argument[0] == align)
547 flag |= func_status::ToggleOn;
549 flag |= func_status::ToggleOff;
554 case LFUN_MATH_MUTATE: {
555 Inset * tli = owner->view()->theLockingInset();
556 if (tli && (tli->lyxCode() == Inset::MATH_CODE)) {
557 MathInsetTypes type = mathcursor->par()->GetType();
558 func_status::value_type box = func_status::ToggleOff;
559 if (argument == "inline") {
560 if (type == LM_OT_SIMPLE)
561 box = func_status::ToggleOn;
562 } else if (argument == "display") {
563 if (type == LM_OT_EQUATION)
564 box = func_status::ToggleOn;
565 } else if (argument == "eqnarray") {
566 if (type == LM_OT_EQNARRAY)
567 box = func_status::ToggleOn;
568 } else if (argument == "align") {
569 if (type == LM_OT_ALIGN)
570 box = func_status::ToggleOn;
572 box = func_status::OK;
581 // we just need to be in math mode to enable that
583 case LFUN_MATH_LIMITS:
584 case LFUN_MATH_NONUMBER:
585 case LFUN_MATH_NUMBER:
586 disable = !mathcursor;
589 // we need to be math mode and a math array for that
590 // Hack: halign produces non-zero result iff we are in a math array
591 case LFUN_MATH_ROW_INSERT:
592 case LFUN_MATH_ROW_DELETE:
593 case LFUN_MATH_COLUMN_INSERT:
594 case LFUN_MATH_COLUMN_DELETE:
595 disable = !mathcursor || !mathcursor->halign();
602 // the functions which insert insets
603 Inset::Code code = Inset::NO_CODE;
605 case LFUN_INSET_TEXT:
606 code = Inset::TEXT_CODE;
609 code = Inset::ERT_CODE;
612 case LFUN_INSET_GRAPHICS:
613 code = Inset::GRAPHICS_CODE;
615 case LFUN_INSET_FOOTNOTE:
616 code = Inset::FOOT_CODE;
618 case LFUN_DIALOG_TABULAR_INSERT:
619 case LFUN_INSET_TABULAR:
620 code = Inset::TABULAR_CODE;
622 case LFUN_INSET_EXTERNAL:
623 code = Inset::EXTERNAL_CODE;
625 case LFUN_INSET_MARGINAL:
626 code = Inset::MARGIN_CODE;
628 case LFUN_INSET_MINIPAGE:
629 code = Inset::MINIPAGE_CODE;
631 case LFUN_INSET_FLOAT:
632 case LFUN_INSET_WIDE_FLOAT:
633 code = Inset::FLOAT_CODE;
635 case LFUN_FLOAT_LIST:
636 code = Inset::FLOAT_LIST_CODE;
639 case LFUN_INSET_LIST:
640 code = Inset::LIST_CODE;
642 case LFUN_INSET_THEOREM:
643 code = Inset::THEOREM_CODE;
646 case LFUN_INSET_CAPTION:
647 code = Inset::CAPTION_CODE;
649 case LFUN_INSERT_NOTE:
650 code = Inset::IGNORE_CODE;
652 case LFUN_INSERT_LABEL:
653 code = Inset::LABEL_CODE;
655 case LFUN_REF_INSERT:
656 code = Inset::REF_CODE;
658 case LFUN_CITATION_CREATE:
659 case LFUN_CITATION_INSERT:
660 code = Inset::CITE_CODE;
662 case LFUN_INSERT_BIBTEX:
663 code = Inset::BIBTEX_CODE;
665 case LFUN_INDEX_INSERT:
666 case LFUN_INDEX_INSERT_LAST:
667 case LFUN_INDEX_CREATE:
668 code = Inset::INDEX_CODE;
670 case LFUN_INDEX_PRINT:
671 code = Inset::INDEX_PRINT_CODE;
673 case LFUN_CHILD_INSERT:
674 code = Inset::INCLUDE_CODE;
676 case LFUN_TOC_INSERT:
677 code = Inset::TOC_CODE;
679 case LFUN_PARENTINSERT:
680 code = Inset::PARENT_CODE;
684 case LFUN_INSERT_URL:
685 code = Inset::URL_CODE;
688 // always allow this, since we will inset a raw quote
689 // if an inset is not allowed.
691 case LFUN_HYPHENATION:
692 case LFUN_LIGATURE_BREAK:
694 case LFUN_MENU_SEPARATOR:
696 case LFUN_END_OF_SENTENCE:
697 case LFUN_PROTECTEDSPACE:
698 code = Inset::SPECIALCHAR_CODE;
703 if (code != Inset::NO_CODE
704 && owner->view()->theLockingInset()
705 && !owner->view()->theLockingInset()->insetAllowed(code)) {
710 flag |= func_status::Disabled;
712 // the font related functions
713 func_status::value_type box = func_status::ToggleOff;
714 LyXFont const & font =
715 TEXT(false)->real_current_font;
718 if (font.emph() == LyXFont::ON)
719 box = func_status::ToggleOn;
722 if (font.noun() == LyXFont::ON)
723 box = func_status::ToggleOn;
726 if (font.series() == LyXFont::BOLD_SERIES)
727 box = func_status::ToggleOn;
731 if (font.latex() == LyXFont::ON)
732 box = func_status::ToggleOn;
735 case LFUN_READ_ONLY_TOGGLE:
736 if (buf->isReadonly())
737 box = func_status::ToggleOn;
740 box = func_status::OK;
749 // temporary dispatch method
750 void LyXFunc::miniDispatch(string const & s)
758 string const LyXFunc::dispatch(string const & s)
760 // Split command string into command and argument
762 string line = frontStrip(s);
763 string const arg = strip(frontStrip(split(line, cmd, ' ')));
765 return dispatch(lyxaction.LookupFunc(cmd), arg);
769 string const LyXFunc::dispatch(int ac,
770 string const & do_not_use_this_arg)
772 lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << ac
773 <<"] arg[" << do_not_use_this_arg << "]" << endl;
778 // we have not done anything wrong yet.
780 dispatch_buffer.erase();
782 // if action is a pseudo-action, we need the real action
783 if (lyxaction.isPseudoAction(ac)) {
785 action = static_cast<kb_action>
786 (lyxaction.retrieveActionArg(ac, tmparg));
790 action = static_cast<kb_action>(ac);
791 if (!do_not_use_this_arg.empty())
792 argument = do_not_use_this_arg; // except here
795 #ifdef NEW_DISPATCHER
796 // We try do call the most specific dispatcher first:
797 // 1. the lockinginset's dispatch
798 // 2. the bufferview's dispatch
799 // 3. the lyxview's dispatch
802 selection_possible = false;
804 if (owner->view()->available())
805 owner->view()->hideCursor();
807 // We cannot use this function here
808 if (getStatus(ac, do_not_use_this_arg) & func_status::Disabled) {
809 lyxerr << "LyXFunc::Dispatch: "
810 << lyxaction.getActionName(ac)
811 << " [" << ac << "] is disabled ad this location"
813 goto exit_with_message;
816 if (owner->view()->available() && owner->view()->theLockingInset()) {
817 UpdatableInset::RESULT result;
818 if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
819 (keyseq.length >= -1)))
821 if ((action==LFUN_UNKNOWN_ACTION) && argument.empty()){
822 argument = keyseq.getiso();
824 // Undo/Redo is a bit tricky for insets.
825 if (action == LFUN_UNDO) {
826 #ifdef RETHINK_THIS_FOR_NOW_WE_LEAVE_ALL_UNLOCKED
829 UpdatableInset * inset =
830 owner->view()->theLockingInset()->getLockingInset();
831 int inset_id = inset->id();
832 inset->getCursorPos(owner->view(), slx, sly);
833 owner->view()->unlockInset(inset);
835 owner->view()->unlockInset(owner->view()->theLockingInset());
837 owner->view()->menuUndo();
838 #ifdef RETHINK_THIS_FOR_NOW_WE_LEAVE_ALL_UNLOCKED
840 if (TEXT()->cursor.par()->
841 isInset(TEXT()->cursor.pos())) {
842 inset = static_cast<UpdatableInset*>(
843 TEXT()->cursor.par()->
850 inset = static_cast<UpdatableInset *>(owner->view()->buffer()->getInsetFromID(inset_id));
853 inset->edit(owner->view(),slx,sly,0);
856 } else if (action == LFUN_REDO) {
859 UpdatableInset * inset = owner->view()->
861 inset->getCursorPos(owner->view(), slx, sly);
862 owner->view()->unlockInset(inset);
863 owner->view()->menuRedo();
864 inset = static_cast<UpdatableInset*>(
865 TEXT()->cursor.par()->
869 inset->edit(owner->view(),slx,sly,0);
871 } else if (((result=owner->view()->theLockingInset()->
872 localDispatch(owner->view(), action,
874 UpdatableInset::DISPATCHED) ||
875 (result == UpdatableInset::DISPATCHED_NOUPDATE))
878 //setMessage(N_("Text mode"));
880 case LFUN_UNKNOWN_ACTION:
881 case LFUN_BREAKPARAGRAPH:
883 TEXT()->cursorRight(owner->view());
884 owner->view()->setState();
888 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
889 TEXT()->cursorRight(owner->view());
890 moveCursorUpdate(true, false);
895 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
896 TEXT()->cursorRight(owner->view());
897 moveCursorUpdate(true, false);
902 if (TEXT()->cursor.row()->next())
903 TEXT()->cursorDown(owner->view());
905 TEXT()->cursorRight(owner->view());
906 moveCursorUpdate(true, false);
916 lyx::Assert(action != LFUN_SELECT_FILE_SYNC);
922 if (!owner->view()->available()) break;
924 // this function should be used always [asierra060396]
925 UpdatableInset * tli =
926 owner->view()->theLockingInset();
928 UpdatableInset * lock = tli->getLockingInset();
931 owner->view()->unlockInset(tli);
932 TEXT()->cursorRight(owner->view());
933 moveCursorUpdate(true, false);
936 tli->unlockInsetInInset(owner->view(),
944 // --- Misc -------------------------------------------
945 case LFUN_WORDFINDFORWARD :
946 case LFUN_WORDFINDBACKWARD : {
947 static string last_search;
948 string searched_string;
950 if (!argument.empty()) {
951 last_search = argument;
952 searched_string = argument;
954 searched_string = last_search;
956 bool fw = (action == LFUN_WORDFINDBACKWARD);
957 if (!searched_string.empty()) {
958 LyXFind(owner->view(), searched_string, fw);
960 // owner->view()->showCursor();
966 if (owner->view()->available() && !owner->view()->theLockingInset()) {
967 owner->view()->update(TEXT(),
968 BufferView::SELECT|BufferView::FITCUR);
971 keyseq.print(buf, true);
976 // --- Misc -------------------------------------------
977 case LFUN_EXEC_COMMAND:
979 std::vector<string> allCmds;
980 std::transform(lyxaction.func_begin(), lyxaction.func_end(),
981 std::back_inserter(allCmds), lyx::firster());
982 static std::vector<string> hist;
983 owner->getMiniBuffer()->getString(MiniBuffer::spaces,
988 case LFUN_CANCEL: // RVDK_PATCH_5
991 if (owner->view()->available())
992 // cancel any selection
993 dispatch(LFUN_MARK_OFF);
994 setMessage(N_("Cancel"));
997 case LFUN_META_FAKE: // RVDK_PATCH_5
999 meta_fake_bit = Mod1Mask;
1001 keyseq.print(buf, true);
1002 setMessage(buf); // RVDK_PATCH_5
1006 case LFUN_READ_ONLY_TOGGLE:
1007 if (owner->buffer()->lyxvc.inUse()) {
1008 owner->buffer()->lyxvc.toggleReadOnly();
1010 owner->buffer()->setReadonly(
1011 !owner->buffer()->isReadonly());
1015 case LFUN_CENTER: // this is center and redraw.
1016 owner->view()->center();
1019 // --- Menus -----------------------------------------------
1024 case LFUN_MENUNEWTMPLT:
1028 case LFUN_CLOSEBUFFER:
1032 case LFUN_MENUWRITE:
1033 if (!owner->buffer()->isUnnamed()) {
1035 s1 << _("Saving document") << ' '
1036 << MakeDisplayPath(owner->buffer()->fileName() + "...");
1037 owner->message(s1.str().c_str());
1038 MenuWrite(owner->view(), owner->buffer());
1040 WriteAs(owner->view(), owner->buffer());
1044 WriteAs(owner->view(), owner->buffer(), argument);
1047 case LFUN_MENURELOAD:
1052 Exporter::Export(owner->buffer(), argument, true);
1056 Exporter::Preview(owner->buffer(), argument);
1059 case LFUN_BUILDPROG:
1060 Exporter::Export(owner->buffer(), "program", true);
1063 case LFUN_RUNCHKTEX:
1064 MenuRunChktex(owner->buffer());
1067 case LFUN_MENUPRINT:
1068 owner->getDialogs()->showPrint();
1072 if (argument == "custom")
1075 Exporter::Export(owner->buffer(), argument, false);
1093 InsetCommandParams p;
1096 if (action == LFUN_TOCVIEW)
1098 p.setCmdName("tableofcontents");
1100 else if (action == LFUN_LOAVIEW )
1101 p.setCmdName("listof{algorithm}{List of Algorithms}");
1102 else if (action == LFUN_LOFVIEW)
1103 p.setCmdName("listoffigures");
1105 p.setCmdName("listoftables");
1107 owner->getDialogs()->createTOC(p.getAsString());
1111 case LFUN_DIALOG_TABULAR_INSERT:
1112 owner->getDialogs()->showTabularCreate();
1120 AutoSave(owner->view());
1124 owner->view()->menuUndo();
1128 owner->view()->menuRedo();
1131 case LFUN_MENUSEARCH:
1132 owner->getDialogs()->showSearch();
1135 case LFUN_REMOVEERRORS:
1136 if (owner->view()->removeAutoInsets()) {
1137 owner->view()->redraw();
1138 owner->view()->fitCursor(TEXT());
1143 changeDepth(owner->view(), TEXT(false), 0);
1146 case LFUN_DEPTH_MIN:
1147 changeDepth(owner->view(), TEXT(false), -1);
1150 case LFUN_DEPTH_PLUS:
1151 changeDepth(owner->view(), TEXT(false), 1);
1155 owner->getDialogs()->setUserFreeFont();
1161 owner->view()->setState();
1166 case LFUN_RECONFIGURE:
1167 Reconfigure(owner->view());
1171 case LFUN_FLOATSOPERATE:
1172 if (argument == "openfoot")
1173 owner->view()->allFloats(1,0);
1174 else if (argument == "closefoot")
1175 owner->view()->allFloats(0,0);
1176 else if (argument == "openfig")
1177 owner->view()->allFloats(1,1);
1178 else if (argument == "closefig")
1179 owner->view()->allFloats(0,1);
1182 #ifdef WITH_WARNINGS
1183 #warning Find another implementation here (or another lyxfunc)!
1186 case LFUN_HELP_ABOUTLYX:
1187 owner->getDialogs()->showAboutlyx();
1190 case LFUN_HELP_COPYRIGHT:
1191 case LFUN_HELP_CREDITS:
1194 case LFUN_HELP_OPEN:
1196 string const arg = argument;
1198 setErrorMessage(N_("Missing argument"));
1201 owner->prohibitInput();
1202 string const fname = i18nLibFileSearch("doc", arg, "lyx");
1203 if (fname.empty()) {
1204 lyxerr << "LyX: unable to find documentation file `"
1205 << arg << "'. Bad installation?" << endl;
1206 owner->allowInput();
1210 str << _("Opening help file") << ' '
1211 << MakeDisplayPath(fname) << "...";
1212 owner->message(str.str().c_str());
1213 owner->view()->buffer(bufferlist.loadLyXFile(fname, false));
1214 owner->allowInput();
1218 case LFUN_HELP_VERSION:
1220 // --- version control -------------------------------
1221 case LFUN_VC_REGISTER:
1223 if (!owner->buffer()->lyxvc.inUse())
1224 owner->buffer()->lyxvc.registrer();
1228 case LFUN_VC_CHECKIN:
1230 if (owner->buffer()->lyxvc.inUse()
1231 && !owner->buffer()->isReadonly())
1232 owner->buffer()->lyxvc.checkIn();
1236 case LFUN_VC_CHECKOUT:
1238 if (owner->buffer()->lyxvc.inUse()
1239 && owner->buffer()->isReadonly())
1240 owner->buffer()->lyxvc.checkOut();
1244 case LFUN_VC_REVERT:
1246 owner->buffer()->lyxvc.revert();
1252 owner->buffer()->lyxvc.undoLast();
1256 case LFUN_VC_HISTORY:
1258 owner->getDialogs()->showVCLogFile();
1262 // --- buffers ----------------------------------------
1264 case LFUN_SWITCHBUFFER:
1265 owner->view()->buffer(bufferlist.getBuffer(argument));
1270 // servercmd: argument must be <file>:<template>
1271 Buffer * tmpbuf = NewLyxFile(argument);
1273 owner->view()->buffer(tmpbuf);
1277 case LFUN_FILE_OPEN:
1281 case LFUN_LATEX_LOG:
1282 owner->getDialogs()->showLogFile();
1287 lyxerr[Debug::INFO] << "LFUN_LAYOUTNO: (arg) " << argument << endl;
1288 int sel = strToInt(argument);
1289 lyxerr[Debug::INFO] << "LFUN_LAYOUTNO: (sel) "<< sel << endl;
1291 // Should this give a setMessage instead?
1293 return string(); // illegal argument
1295 --sel; // sel 1..., but layout 0...
1297 // Pretend we got the name instead.
1298 dispatch(int(LFUN_LAYOUT),
1299 textclasslist.NameOfLayout(owner->view()
1300 ->buffer()->params.textclass,
1305 case LFUN_LAYOUT_DOCUMENT:
1306 owner->getDialogs()->showDocument();
1309 case LFUN_LAYOUT_PARAGRAPH:
1310 owner->getDialogs()->showParagraph();
1313 case LFUN_LAYOUT_CHARACTER:
1314 owner->getDialogs()->showCharacter();
1317 case LFUN_LAYOUT_TABULAR:
1318 if (owner->view()->theLockingInset()) {
1319 if (owner->view()->theLockingInset()->lyxCode()==Inset::TABULAR_CODE) {
1320 InsetTabular * inset = static_cast<InsetTabular *>
1321 (owner->view()->theLockingInset());
1322 inset->openLayoutDialog(owner->view());
1323 } else if (owner->view()->theLockingInset()->
1324 getFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
1325 InsetTabular * inset = static_cast<InsetTabular *>(
1326 owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
1327 inset->openLayoutDialog(owner->view());
1332 case LFUN_LAYOUT_PREAMBLE:
1333 owner->getDialogs()->showPreamble();
1336 case LFUN_LAYOUT_SAVE_DEFAULT:
1337 MenuLayoutSave(owner->view());
1340 case LFUN_DROP_LAYOUTS_CHOICE:
1341 owner->getToolbar()->openLayoutList();
1344 case LFUN_MENU_OPEN_BY_NAME:
1345 owner->getMenubar()->openByName(argument);
1346 break; // RVDK_PATCH_5
1348 case LFUN_SPELLCHECK:
1349 if (lyxrc.isp_command != "none")
1350 owner->getDialogs()->showSpellchecker();
1353 // --- lyxserver commands ----------------------------
1357 setMessage(owner->buffer()->fileName());
1358 lyxerr[Debug::INFO] << "FNAME["
1359 << owner->buffer()->fileName()
1367 dispatch_buffer = buf;
1368 lyxserver->notifyClient(dispatch_buffer);
1372 case LFUN_GOTOFILEROW:
1375 char file_name[100];
1377 ::sscanf(argument.c_str(), " %s %d", file_name, &row);
1381 istringstream istr(argument.c_str());
1382 istr >> file_name >> row;
1384 // Must replace extension of the file to be .lyx and get full path
1385 string const s(ChangeExtension(file_name, ".lyx"));
1387 // Either change buffer or load the file
1388 if (bufferlist.exists(s)) {
1389 owner->view()->buffer(bufferlist.getBuffer(s));
1391 owner->view()->buffer(bufferlist.loadLyXFile(s));
1395 owner->view()->setCursorFromRow(row);
1398 owner->view()->center();
1402 case LFUN_GOTO_PARAGRAPH:
1404 istringstream istr(argument.c_str());
1408 Paragraph * par = owner->buffer()->getParFromID(id);
1410 lyxerr[Debug::INFO] << "No matching paragraph found! ["
1411 << id << "]" << std::endl;
1416 TEXT()->setCursor(owner->view(), par, 0);
1417 owner->view()->setState();
1421 owner->view()->center();
1428 int const qa = lyxaction.LookupFunc(argument);
1429 setMessage(lyxaction.helpText(static_cast<kb_action>(qa)));
1433 // --- toolbar ----------------------------------
1434 case LFUN_PUSH_TOOLBAR:
1436 int nth = strToInt(argument);
1438 setErrorMessage(N_("Push-toolbar needs argument > 0"));
1440 owner->getToolbar()->push(nth);
1445 case LFUN_ADD_TO_TOOLBAR:
1447 if (lyxerr.debugging(Debug::GUI)) {
1448 lyxerr << "LFUN_ADD_TO_TOOLBAR:"
1449 "argument = `" << argument << '\'' << endl;
1451 string tmp(argument);
1452 //lyxerr <<string("Argument: ") + argument);
1453 //lyxerr <<string("Tmp : ") + tmp);
1455 setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
1457 owner->getToolbar()->add(argument, false);
1458 owner->getToolbar()->set();
1463 // --- insert characters ----------------------------------------
1465 // --- Mathed stuff. If we are here, there is no locked inset yet.
1470 if (!greek_kb_flag) {
1472 setMessage(N_("Math greek mode on"));
1479 case LFUN_GREEK_TOGGLE:
1481 greek_kb_flag = greek_kb_flag ? 0 : 2;
1482 if (greek_kb_flag) {
1483 setMessage(N_("Math greek keyboard on"));
1485 setMessage(N_("Math greek keyboard off"));
1490 case LFUN_MATH_EXTERN:
1491 case LFUN_MATH_NUMBER:
1492 case LFUN_MATH_NONUMBER:
1493 case LFUN_MATH_LIMITS:
1495 setErrorMessage(N_("This is only allowed in math mode!"));
1499 case LFUN_MATH_PANEL:
1500 owner->getDialogs()->showMathPanel();
1503 case LFUN_CITATION_CREATE:
1505 InsetCommandParams p( "cite" );
1507 if (!argument.empty()) {
1508 // This should be set at source, ie when typing
1509 // "citation-insert foo" in the minibuffer.
1510 // Question: would pybibliographer also need to be
1511 // changed. Suspect so. Leave as-is therefore.
1512 if (contains(argument, "|")) {
1513 p.setContents( token(argument, '|', 0) );
1514 p.setOptions( token(argument, '|', 1) );
1516 p.setContents( argument );
1518 dispatch(LFUN_CITATION_INSERT, p.getAsString());
1520 owner->getDialogs()->createCitation( p.getAsString() );
1524 case LFUN_CHILDOPEN:
1526 string const filename =
1527 MakeAbsPath(argument,
1528 OnlyPath(owner->buffer()->fileName()));
1529 setMessage(N_("Opening child document ") +
1530 MakeDisplayPath(filename) + "...");
1531 owner->view()->savePosition(0);
1532 if (bufferlist.exists(filename))
1533 owner->view()->buffer(bufferlist.getBuffer(filename));
1535 owner->view()->buffer(bufferlist.loadLyXFile(filename));
1539 case LFUN_TOGGLECURSORFOLLOW:
1540 lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
1543 case LFUN_KMAP_OFF: // keymap off
1544 owner->getIntl()->KeyMapOn(false);
1547 case LFUN_KMAP_PRIM: // primary keymap
1548 owner->getIntl()->KeyMapPrim();
1551 case LFUN_KMAP_SEC: // secondary keymap
1552 owner->getIntl()->KeyMapSec();
1555 case LFUN_KMAP_TOGGLE: // toggle keymap
1556 owner->getIntl()->ToggleKeyMap();
1561 // argument contains ';'-terminated commands
1562 while (argument.find(';') != string::npos) {
1564 argument = split(argument, first, ';');
1570 case LFUN_DIALOG_PREFERENCES:
1571 owner->getDialogs()->showPreferences();
1574 case LFUN_SAVEPREFERENCES:
1576 Path p(user_lyxdir);
1577 lyxrc.write("preferences");
1581 case LFUN_SCREEN_FONT_UPDATE:
1583 // handle the screen font changes.
1585 lyxrc.set_font_norm_type();
1586 fontloader.update();
1587 // Of course we should only do the resize and the textcache.clear
1588 // if values really changed...but not very important right now. (Lgb)
1589 // All visible buffers will need resize
1591 // We also need to empty the textcache so that
1592 // the buffer will be formatted correctly after
1598 case LFUN_SET_COLOR:
1601 string const x11_name = split(argument, lyx_name, ' ');
1602 if (lyx_name.empty() || x11_name.empty()) {
1603 setErrorMessage(N_("Syntax: set-color <lyx_name>"
1608 if (!lcolor.setColor(lyx_name, x11_name)) {
1609 static string const err1 (N_("Set-color \""));
1610 static string const err2 (
1611 N_("\" failed - color is undefined "
1612 "or may not be redefined"));
1613 setErrorMessage(_(err1) + lyx_name + _(err2));
1616 lyxColorHandler->updateColor(lcolor.getFromLyXName(lyx_name));
1617 owner->view()->redraw();
1622 owner->message(argument);
1625 case LFUN_MESSAGE_PUSH:
1626 owner->messagePush(argument);
1629 case LFUN_MESSAGE_POP:
1630 owner->messagePop();
1634 // Then if it was none of the above
1635 if (!owner->view()->Dispatch(action, argument))
1636 lyxerr << "A truly unknown func ["
1637 << lyxaction.getActionName(action) << "]!"
1644 commandshortcut.erase();
1646 if (lyxrc.display_shortcuts && show_sc) {
1647 if (action != LFUN_SELFINSERT) {
1648 // Put name of command and list of shortcuts
1649 // for it in minibuffer
1650 string comname = lyxaction.getActionName(action);
1652 int pseudoaction = action;
1653 bool argsadded = false;
1655 if (!argument.empty()) {
1656 // If we have the command with argument,
1659 lyxaction.searchActionArg(action,
1662 if (pseudoaction == -1) {
1663 pseudoaction = action;
1665 comname += " " + argument;
1670 string const shortcuts =
1671 toplevel_keymap->findbinding(pseudoaction);
1673 if (!shortcuts.empty()) {
1674 comname += ": " + shortcuts;
1675 } else if (!argsadded) {
1676 comname += " " + argument;
1679 if (!comname.empty()) {
1680 comname = strip(comname);
1681 commandshortcut = "(" + comname + ')';
1683 // Here we could even add a small pause,
1684 // to annoy the user and make him learn
1686 // No! That will just annoy, not teach
1687 // anything. The user will read the messages
1688 // if they are interested. (Asger)
1693 string const res = getMessage();
1696 if (!commandshortcut.empty()) {
1697 owner->getMiniBuffer()->addSet(commandshortcut);
1700 string const msg(_(res) + ' ' + commandshortcut);
1701 owner->message(msg);
1708 void LyXFunc::setupLocalKeymap()
1710 keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
1711 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap.get();
1715 void LyXFunc::menuNew(bool fromTemplate)
1717 string initpath = lyxrc.document_path;
1719 if (owner->view()->available()) {
1720 string const trypath = owner->buffer()->filepath;
1721 // If directory is writeable, use this as default.
1722 if (IsDirWriteable(trypath) == 1)
1726 static int newfile_number;
1729 if (lyxrc.new_ask_filename) {
1730 FileDialog fileDlg(owner, _("Enter filename for new document"),
1731 LFUN_SELECT_FILE_SYNC,
1732 make_pair(string(_("Documents")),
1733 string(lyxrc.document_path)),
1734 make_pair(string(_("Templates")),
1735 string(lyxrc.template_path)));
1737 FileDialog::Result result =
1738 fileDlg.Select(initpath,
1739 _("*.lyx|LyX Documents (*.lyx)"),
1742 if (result.second.empty()) {
1743 owner->message(_("Canceled."));
1744 lyxerr[Debug::INFO] << "New Document Cancelled." << endl;
1748 // get absolute path of file and make sure the filename ends
1750 s = MakeAbsPath(result.second);
1751 if (!IsLyXFilename(s))
1754 // Check if the document already is open
1755 if (bufferlist.exists(s)) {
1756 switch (AskConfirmation(_("Document is already open:"),
1757 MakeDisplayPath(s, 50),
1758 _("Do you want to close that document now?\n"
1759 "('No' will just switch to the open version)")))
1761 case 1: // Yes: close the document
1762 if (!bufferlist.close(bufferlist.getBuffer(s)))
1763 // If close is canceled, we cancel here too.
1766 case 2: // No: switch to the open document
1767 owner->view()->buffer(bufferlist.getBuffer(s));
1769 case 3: // Cancel: Do nothing
1770 owner->message(_("Canceled."));
1774 // Check whether the file already exists
1776 if (fi.readable() &&
1777 AskQuestion(_("File already exists:"),
1778 MakeDisplayPath(s, 50),
1779 _("Do you want to open the document?"))) {
1781 string const disp_fn(MakeDisplayPath(s));
1784 str << _("Opening document") << ' '
1785 << disp_fn << "...";
1787 owner->message(str.str().c_str());
1788 //XFlush(fl_get_display());
1789 owner->view()->buffer(bufferlist.loadLyXFile(s));
1791 str2 << _("Document") << ' '
1792 << disp_fn << ' ' << _("opened.");
1794 owner->message(str2.str().c_str());
1799 s = AddName(lyxrc.document_path,
1800 "newfile" + tostr(++newfile_number) + ".lyx");
1802 while (bufferlist.exists(s) || fi.readable()) {
1804 s = AddName(lyxrc.document_path,
1805 "newfile" + tostr(newfile_number) +
1811 // The template stuff
1814 FileDialog fileDlg(owner, _("Select template file"),
1815 LFUN_SELECT_FILE_SYNC,
1816 make_pair(string(_("Documents")),
1817 string(lyxrc.document_path)),
1818 make_pair(string(_("Templates")),
1819 string(lyxrc.template_path)));
1821 FileDialog::Result result =
1822 fileDlg.Select(lyxrc.template_path,
1823 _("*.lyx|LyX Documents (*.lyx)"));
1825 if (result.first == FileDialog::Later)
1828 string const fname = result.second;
1835 // find a free buffer
1836 lyxerr[Debug::INFO] << "Find a free buffer." << endl;
1837 owner->view()->buffer(bufferlist.newFile(s, templname));
1841 void LyXFunc::open(string const & fname)
1843 string initpath = lyxrc.document_path;
1845 if (owner->view()->available()) {
1846 string const trypath = owner->buffer()->filepath;
1847 // If directory is writeable, use this as default.
1848 if (IsDirWriteable(trypath) == 1)
1854 if (fname.empty()) {
1855 FileDialog fileDlg(owner, _("Select document to open"),
1857 make_pair(string(_("Documents")),
1858 string(lyxrc.document_path)),
1859 make_pair(string(_("Examples")),
1860 string(AddPath(system_lyxdir, "examples"))));
1862 FileDialog::Result result =
1863 fileDlg.Select(initpath,
1864 "*.lyx|LyX Documents (*.lyx)");
1866 if (result.first == FileDialog::Later)
1869 filename = result.second;
1871 // check selected filename
1872 if (filename.empty()) {
1873 owner->message(_("Canceled."));
1879 // get absolute path of file and add ".lyx" to the filename if
1881 filename = FileSearch(string(), filename, "lyx");
1884 string const disp_fn(MakeDisplayPath(filename));
1887 str << _("Opening document") << ' ' << disp_fn << "...";
1889 owner->message(str.str().c_str());
1891 Buffer * openbuf = bufferlist.loadLyXFile(filename);
1893 owner->view()->buffer(openbuf);
1895 str << _("Document") << ' ' << disp_fn << ' ' << _("opened.");
1896 owner->message(str.str().c_str());
1899 str << _("Could not open docuent") << ' ' << disp_fn;
1900 owner->message(str.str().c_str());
1905 // checks for running without gui are missing.
1906 void LyXFunc::doImport(string const & argument)
1909 string filename = split(argument, format, ' ');
1910 lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format
1911 << " file: " << filename << endl;
1913 if (filename.empty()) { // need user interaction
1914 string initpath = lyxrc.document_path;
1916 if (owner->view()->available()) {
1917 string const trypath = owner->buffer()->filepath;
1918 // If directory is writeable, use this as default.
1919 if (IsDirWriteable(trypath) == 1)
1923 string const text = _("Select ") + formats.PrettyName(format)
1924 + _(" file to import");
1926 FileDialog fileDlg(owner, text,
1928 make_pair(string(_("Documents")),
1929 string(lyxrc.document_path)),
1930 make_pair(string(_("Examples")),
1931 string(AddPath(system_lyxdir, "examples"))));
1933 string const extension = "*." + formats.Extension(format)
1934 + "| " + formats.PrettyName(format)
1935 + " (*." + formats.Extension(format) + ")";
1937 FileDialog::Result result = fileDlg.Select(initpath,
1940 if (result.first == FileDialog::Later)
1943 filename = result.second;
1945 // check selected filename
1946 if (filename.empty())
1947 owner->message(_("Canceled."));
1950 // still no filename? abort
1951 if (filename.empty())
1954 // get absolute path of file
1955 filename = MakeAbsPath(filename);
1957 string const lyxfile = ChangeExtension(filename, ".lyx");
1959 // Check if the document already is open
1960 if (bufferlist.exists(lyxfile)) {
1961 switch (AskConfirmation(_("Document is already open:"),
1962 MakeDisplayPath(lyxfile, 50),
1963 _("Do you want to close that document now?\n"
1964 "('No' will just switch to the open version)")))
1966 case 1: // Yes: close the document
1967 if (!bufferlist.close(bufferlist.getBuffer(lyxfile)))
1968 // If close is canceled, we cancel here too.
1971 case 2: // No: switch to the open document
1972 owner->view()->buffer(bufferlist.getBuffer(lyxfile));
1974 case 3: // Cancel: Do nothing
1975 owner->message(_("Canceled."));
1980 // Check if a LyX document by the same root exists in filesystem
1981 FileInfo const f(lyxfile, true);
1982 if (f.exist() && !AskQuestion(_("A document by the name"),
1983 MakeDisplayPath(lyxfile),
1984 _("already exists. Overwrite?"))) {
1985 owner->message(_("Canceled"));
1988 // filename should be valid now
1990 Importer::Import(owner, filename, format);
1994 void LyXFunc::reloadBuffer()
1996 string const fn = owner->buffer()->fileName();
1997 if (bufferlist.close(owner->buffer()))
1998 owner->view()->buffer(bufferlist.loadLyXFile(fn));
2002 void LyXFunc::closeBuffer()
2004 if (bufferlist.close(owner->buffer()) && !quitting) {
2005 if (bufferlist.empty()) {
2006 // need this otherwise SEGV may occur while trying to
2007 // set variables that don't exist
2008 // since there's no current buffer
2009 owner->getDialogs()->hideBufferDependent();
2011 owner->view()->buffer(bufferlist.first());
2017 // Each "owner" should have it's own message method. lyxview and
2018 // the minibuffer would use the minibuffer, but lyxserver would
2019 // send an ERROR signal to its client. Alejandro 970603
2020 // This func is bit problematic when it comes to NLS, to make the
2021 // lyx servers client be language indepenent we must not translate
2022 // strings sent to this func.
2023 void LyXFunc::setErrorMessage(string const & m) const
2025 dispatch_buffer = m;
2030 void LyXFunc::setMessage(string const & m)
2032 dispatch_buffer = m;
2036 void LyXFunc::initMiniBuffer()
2038 string text = _("Welcome to LyX!");
2040 // When meta-fake key is pressed, show the key sequence so far + "M-".
2046 // Else, when a non-complete key sequence is pressed,
2047 // show the available options.
2048 else if (keyseqUncomplete())
2049 text = keyseqOptions();
2051 // Else, show the buffer state.
2052 else if (owner->view()->available()) {
2053 Buffer * tmpbuf = owner->buffer();
2055 string const nicename =
2056 MakeDisplayPath(tmpbuf->fileName());
2057 // Should we do this instead? (kindo like emacs)
2058 // leaves more room for other information
2061 if (tmpbuf->lyxvc.inUse()) {
2063 text += tmpbuf->lyxvc.version();
2065 text += tmpbuf->lyxvc.locker();
2066 if (tmpbuf->isReadonly())
2069 } else if (tmpbuf->isReadonly())
2071 if (!tmpbuf->isLyxClean())
2072 text += _(" (Changed)");
2074 if (text != _("Welcome to LyX!")) // this is a hack
2075 text = _("* No document open *");
2078 owner->message(text);