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 * ====================================================== */
25 #pragma implementation
28 #include "support/lyxalgo.h"
29 #include "support/LAssert.h"
33 #include "bufferlist.h"
34 #include "BufferView.h"
35 #include "ColorHandler.h"
36 #include "lyxserver.h"
40 #include "LyXAction.h"
41 #include "insets/inseturl.h"
42 #include "insets/insetlatexaccent.h"
43 #include "insets/insettoc.h"
44 #include "insets/insetref.h"
45 #include "insets/insetparent.h"
46 #include "insets/insetindex.h"
47 #include "insets/insetinclude.h"
48 #include "insets/insetbib.h"
49 #include "insets/insetcite.h"
50 #include "insets/insettext.h"
51 #include "insets/insetert.h"
52 #include "insets/insetexternal.h"
53 #include "insets/insetgraphics.h"
54 #include "insets/insetfoot.h"
55 #include "insets/insetmarginal.h"
56 #include "insets/insetminipage.h"
57 #include "insets/insetfloat.h"
59 #include "insets/insetlist.h"
60 #include "insets/insettheorem.h"
62 #include "insets/insettabular.h"
63 #include "insets/insetcaption.h"
64 #include "mathed/formulamacro.h"
65 #include "mathed/math_cursor.h"
66 #include "mathed/math_inset.h"
67 #include "minibuffer.h"
70 #include "lyx_gui_misc.h"
71 #include "support/filetools.h"
72 #include "support/FileInfo.h"
73 #include "support/syscall.h"
74 #include "support/lstrings.h"
75 #include "support/path.h"
76 #include "support/lyxfunctional.h"
81 #include "trans_mgr.h"
84 #include "bufferview_funcs.h"
85 #include "frontends/FileDialog.h"
86 #include "frontends/Dialogs.h"
87 #include "frontends/Toolbar.h"
88 #include "frontends/Menubar.h"
89 #include "FloatList.h"
90 #include "converter.h"
93 #include "FontLoader.h"
94 #include "TextCache.h"
96 #include "undo_funcs.h"
103 extern BufferList bufferlist;
104 extern LyXServer * lyxserver;
105 extern int greek_kb_flag;
106 extern bool selection_possible;
107 extern void MenuSendto();
109 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
111 extern void show_symbols_form(LyXFunc *);
113 extern LyXAction lyxaction;
115 extern tex_accent_struct get_accent(kb_action action);
117 extern LyXTextClass::size_type current_layout;
119 extern void ShowLatexLog();
125 class MiniBufferController : public SigC::Object {
128 MiniBufferController() {
132 &MiniBufferController::receiveCommand));
136 &MiniBufferController::receiveArg));
139 void receiveCmd(string const & cmd) {}
141 void receiveArg(string const & arg) {}
149 MiniBufferController mb_ctrl;
155 /* === globals =========================================================== */
157 // Initialization of static member var
158 bool LyXFunc::show_sc = true;
161 LyXFunc::LyXFunc(LyXView * o)
165 lyx_dead_action = LFUN_NOACTION;
166 lyx_calling_dead_action = LFUN_NOACTION;
172 LyXText * LyXFunc::TEXT(bool flag = true) const
175 return owner->view()->text;
176 return owner->view()->getLyXText();
180 // I changed this func slightly. I commented out the ...FinishUndo(),
181 // this means that all places that used to have a moveCursorUpdate, now
182 // have a ...FinishUndo() as the preceeding statement. I have also added
183 // a moveCursorUpdate to some of the functions that updated the cursor, but
184 // that did not show its new position.
186 void LyXFunc::moveCursorUpdate(bool flag, bool selecting)
188 if (selecting || TEXT(flag)->selection.mark()) {
189 TEXT(flag)->setSelection(owner->view());
190 if (TEXT(flag)->bv_owner)
191 owner->view()->toggleToggle();
193 owner->view()->update(TEXT(flag), BufferView::SELECT|BufferView::FITCUR);
194 owner->view()->showCursor();
196 /* ---> Everytime the cursor is moved, show the current font state. */
197 // should this too me moved out of this func?
198 owner->view()->setState();
202 void LyXFunc::handleKeyFunc(kb_action action)
204 char c = keyseq.getiso();
206 if (keyseq.length != -1) c = 0;
208 owner->getIntl()->getTrans()
209 .deadkey(c, get_accent(action).accent, TEXT(false));
210 // Need to reset, in case the minibuffer calls these
214 // copied verbatim from do_accent_char
215 owner->view()->update(TEXT(false),
216 BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
217 TEXT(false)->selection.cursor = TEXT(false)->cursor;
221 void LyXFunc::processKeySym(KeySym keysym, unsigned int state)
225 if (lyxerr.debugging(Debug::KEY)) {
226 char const * tmp = XKeysymToString(keysym);
227 string const stm = (tmp ? tmp : "");
228 lyxerr << "KeySym is "
231 << keysym << "] State is ["
235 // Do nothing if we have nothing (JMarc)
236 if (keysym == NoSymbol) {
237 lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
242 // Can we be sure that this will work for all X-Windows
243 // implementations? (Lgb)
244 // This code snippet makes lyx ignore some keys. Perhaps
245 // all of them should be explictly mentioned?
246 if ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
247 || keysym == XK_Mode_switch || keysym == 0x0) {
251 // Do a one-deep top-level lookup for
252 // cancel and meta-fake keys. RVDK_PATCH_5
253 cancel_meta_seq.reset();
255 int action = cancel_meta_seq.addkey(keysym, state
256 &(ShiftMask|ControlMask
258 if (lyxerr.debugging(Debug::KEY)) {
259 lyxerr << "action first set to [" << action << "]" << endl;
262 // When not cancel or meta-fake, do the normal lookup.
263 // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
264 // Mostly, meta_fake_bit = 0. RVDK_PATCH_5.
265 if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
266 if (lyxerr.debugging(Debug::KEY)) {
267 lyxerr << "meta_fake_bit is ["
268 << meta_fake_bit << "]" << endl;
270 // remove Caps Lock and Mod2 as a modifiers
271 action = keyseq.addkey(keysym,
272 (state | meta_fake_bit)
273 &(ShiftMask|ControlMask
275 if (lyxerr.debugging(Debug::KEY)) {
276 lyxerr << "action now set to ["
277 << action << "]" << endl;
280 // Dont remove this unless you know what you are doing.
283 if (action == 0) action = LFUN_PREFIX;
285 if (lyxerr.debugging(Debug::KEY)) {
288 lyxerr << "Key [action="
294 // already here we know if it any point in going further
295 // why not return already here if action == -1 and
296 // num_bytes == 0? (Lgb)
298 if (keyseq.length > 1 || keyseq.length < -1) {
305 // It is unknown, but what if we remove all
306 // the modifiers? (Lgb)
307 action = keyseq.addkey(keysym, 0);
309 if (lyxerr.debugging(Debug::KEY)) {
310 lyxerr << "Removing modifiers...\n"
311 << "Action now set to ["
312 << action << "]" << endl;
315 owner->message(_("Unknown function."));
320 if (action == LFUN_SELFINSERT) {
321 // This is very X dependant.
322 unsigned int c = keysym;
324 switch (c & 0x0000FF00) {
325 // latin 1 byte 3 = 0
326 case 0x00000000: break;
327 // latin 2 byte 3 = 1
329 // latin 3 byte 3 = 2
331 // latin 4 byte 3 = 3
333 // latin 8 byte 3 = 18 (0x12)
335 // latin 9 byte 3 = 19 (0x13)
344 argument = static_cast<char>(c);
345 lyxerr[Debug::KEY] << "SelfInsert arg[`"
346 << argument << "']" << endl;
349 bool tmp_sc = show_sc;
351 dispatch(action, argument);
358 func_status::value_type LyXFunc::getStatus(int ac) const
360 return getStatus(ac, string());
364 func_status::value_type LyXFunc::getStatus(int ac,
365 string const & not_to_use_arg) const
368 func_status::value_type flag = func_status::OK;
370 Buffer * buf = owner->buffer();
372 if (lyxaction.isPseudoAction(ac))
373 action = lyxaction.retrieveActionArg(ac, argument);
375 action = static_cast<kb_action>(ac);
376 if (!not_to_use_arg.empty())
377 argument = not_to_use_arg; // exept here
380 if (action == LFUN_UNKNOWN_ACTION) {
381 setErrorMessage(N_("Unknown action"));
382 return func_status::Unknown;
385 // Check whether we need a buffer
386 if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) {
387 // Yes we need a buffer, do we have one?
390 // Can we use a readonly buffer?
391 if (buf->isReadonly() &&
392 !lyxaction.funcHasFlag(action,
393 LyXAction::ReadOnly)) {
395 setErrorMessage(N_("Document is read-only"));
396 flag |= func_status::Disabled;
400 setErrorMessage(N_("Command not allowed with"
401 "out any document open"));
402 flag |= func_status::Disabled;
407 // I would really like to avoid having this switch and rather try to
408 // encode this in the function itself.
409 bool disable = false;
412 disable = !Exporter::IsExportable(buf, "dvi")
413 || lyxrc.print_command == "none";
416 disable = argument == "fax" &&
417 !Exporter::IsExportable(buf, argument);
420 disable = buf->undostack.empty();
423 disable = buf->redostack.empty();
425 case LFUN_SPELLCHECK:
426 disable = lyxrc.isp_command == "none";
429 disable = lyxrc.chktex_command == "none";
432 disable = !Exporter::IsExportable(buf, "program");
435 case LFUN_LAYOUT_TABULAR:
437 if (owner->view()->theLockingInset()) {
438 disable = (owner->view()->theLockingInset()->lyxCode() != Inset::TABULAR_CODE) &&
439 !owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE);
443 case LFUN_TABULAR_FEATURE:
445 if (owner->view()->theLockingInset()) {
446 func_status::value_type ret = func_status::Disabled;
447 if (owner->view()->theLockingInset()->lyxCode() == Inset::TABULAR_CODE) {
448 ret = static_cast<InsetTabular *>
449 (owner->view()->theLockingInset())->
451 } else if (owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
452 ret = static_cast<InsetTabular *>
453 (owner->view()->theLockingInset()->
454 getFirstLockingInsetOfType(Inset::TABULAR_CODE))->
460 static InsetTabular inset(*owner->buffer(), 1, 1);
461 func_status::value_type ret;
464 ret = inset.getStatus(argument);
465 if ((ret & func_status::ToggleOn) ||
466 (ret & func_status::ToggleOff))
467 flag |= func_status::ToggleOff;
471 case LFUN_VC_REGISTER:
472 disable = buf->lyxvc.inUse();
474 case LFUN_VC_CHECKIN:
475 disable = !buf->lyxvc.inUse() || buf->isReadonly();
477 case LFUN_VC_CHECKOUT:
478 disable = !buf->lyxvc.inUse() || !buf->isReadonly();
482 case LFUN_VC_HISTORY:
483 disable = !buf->lyxvc.inUse();
485 case LFUN_BOOKMARK_GOTO:
486 disable = !owner->view()->
487 isSavedPosition(strToUnsignedInt(argument));
491 case LFUN_INSET_TOGGLE:
492 disable = (TEXT(false)->getInset() == 0);
495 case LFUN_MATH_VALIGN: {
496 // I think this test can be simplified (Andre')
497 // mathcursor is != 0 iff we are in math mode
498 //Inset * tli = owner->view()->theLockingInset();
499 //if (tli && (tli->lyxCode() == Inset::MATH_CODE
500 // || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
503 char align = mathcursor->valign();
508 if (argument.empty()) {
509 flag = func_status::OK;
512 if (!contains("tcb", argument[0])) {
516 if (argument[0] == align)
517 flag |= func_status::ToggleOn;
519 flag |= func_status::ToggleOff;
524 case LFUN_MATH_HALIGN: {
525 //Inset * tli = owner->view()->theLockingInset();
526 //if (tli && (tli->lyxCode() == Inset::MATH_CODE
527 // || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
529 char align = mathcursor->halign();
534 if (argument.empty()) {
535 flag = func_status::OK;
538 if (!contains("lcr", argument[0])) {
542 if (argument[0] == align)
543 flag |= func_status::ToggleOn;
545 flag |= func_status::ToggleOff;
550 case LFUN_MATH_MUTATE: {
551 Inset * tli = owner->view()->theLockingInset();
552 if (tli && (tli->lyxCode() == Inset::MATH_CODE)) {
553 MathInsetTypes type = mathcursor->formula()->getType();
554 func_status::value_type box = func_status::ToggleOff;
555 if (argument == "inline") {
556 if (type == LM_OT_SIMPLE)
557 box = func_status::ToggleOn;
558 } else if (argument == "display") {
559 if (type == LM_OT_EQUATION)
560 box = func_status::ToggleOn;
561 } else if (argument == "eqnarray") {
562 if (type == LM_OT_EQNARRAY)
563 box = func_status::ToggleOn;
564 } else if (argument == "align") {
565 if (type == LM_OT_ALIGN)
566 box = func_status::ToggleOn;
568 box = func_status::OK;
577 // we just need to be in math mode to enable that
579 case LFUN_MATH_SPACE:
580 case LFUN_MATH_LIMITS:
581 case LFUN_MATH_NONUMBER:
582 case LFUN_MATH_NUMBER:
583 disable = !mathcursor;
586 // we need to be math mode and a math array for that
587 // Hack: halign produces non-zero result iff we are in a math array
588 case LFUN_MATH_ROW_INSERT:
589 case LFUN_MATH_ROW_DELETE:
590 case LFUN_MATH_COLUMN_INSERT:
591 case LFUN_MATH_COLUMN_DELETE:
592 disable = !mathcursor || !mathcursor->halign();
599 // the functions which insert insets
600 Inset::Code code = Inset::NO_CODE;
602 case LFUN_INSET_TEXT:
603 code = Inset::TEXT_CODE;
606 code = Inset::ERT_CODE;
609 case LFUN_INSET_GRAPHICS:
610 code = Inset::GRAPHICS_CODE;
612 case LFUN_INSET_FOOTNOTE:
613 code = Inset::FOOT_CODE;
615 case LFUN_DIALOG_TABULAR_INSERT:
616 case LFUN_INSET_TABULAR:
617 code = Inset::TABULAR_CODE;
619 case LFUN_INSET_EXTERNAL:
620 code = Inset::EXTERNAL_CODE;
622 case LFUN_INSET_MARGINAL:
623 code = Inset::MARGIN_CODE;
625 case LFUN_INSET_MINIPAGE:
626 code = Inset::MINIPAGE_CODE;
628 case LFUN_INSET_FLOAT:
629 case LFUN_INSET_WIDE_FLOAT:
630 code = Inset::FLOAT_CODE;
632 case LFUN_FLOAT_LIST:
633 code = Inset::FLOAT_LIST_CODE;
636 case LFUN_INSET_LIST:
637 code = Inset::LIST_CODE;
639 case LFUN_INSET_THEOREM:
640 code = Inset::THEOREM_CODE;
643 case LFUN_INSET_CAPTION:
644 code = Inset::CAPTION_CODE;
646 case LFUN_INSERT_NOTE:
647 code = Inset::IGNORE_CODE;
649 case LFUN_INSERT_LABEL:
650 code = Inset::LABEL_CODE;
652 case LFUN_REF_INSERT:
653 code = Inset::REF_CODE;
655 case LFUN_CITATION_CREATE:
656 case LFUN_CITATION_INSERT:
657 code = Inset::CITE_CODE;
659 case LFUN_INSERT_BIBTEX:
660 code = Inset::BIBTEX_CODE;
662 case LFUN_INDEX_INSERT:
663 case LFUN_INDEX_INSERT_LAST:
664 case LFUN_INDEX_CREATE:
665 code = Inset::INDEX_CODE;
667 case LFUN_INDEX_PRINT:
668 code = Inset::INDEX_PRINT_CODE;
670 case LFUN_CHILD_INSERT:
671 code = Inset::INCLUDE_CODE;
673 case LFUN_TOC_INSERT:
674 code = Inset::TOC_CODE;
676 case LFUN_PARENTINSERT:
677 code = Inset::PARENT_CODE;
681 case LFUN_INSERT_URL:
682 code = Inset::URL_CODE;
685 // always allow this, since we will inset a raw quote
686 // if an inset is not allowed.
688 case LFUN_HYPHENATION:
689 case LFUN_LIGATURE_BREAK:
691 case LFUN_MENU_SEPARATOR:
693 case LFUN_END_OF_SENTENCE:
694 case LFUN_PROTECTEDSPACE:
695 code = Inset::SPECIALCHAR_CODE;
700 if (code != Inset::NO_CODE
701 && owner->view()->theLockingInset()
702 && !owner->view()->theLockingInset()->insetAllowed(code)) {
707 flag |= func_status::Disabled;
709 // the font related functions
710 func_status::value_type box = func_status::ToggleOff;
711 LyXFont const & font =
712 TEXT(false)->real_current_font;
715 if (font.emph() == LyXFont::ON)
716 box = func_status::ToggleOn;
719 if (font.noun() == LyXFont::ON)
720 box = func_status::ToggleOn;
723 if (font.series() == LyXFont::BOLD_SERIES)
724 box = func_status::ToggleOn;
728 if (font.latex() == LyXFont::ON)
729 box = func_status::ToggleOn;
732 case LFUN_READ_ONLY_TOGGLE:
733 if (buf->isReadonly())
734 box = func_status::ToggleOn;
737 box = func_status::OK;
746 // temporary dispatch method
747 void LyXFunc::miniDispatch(string const & s)
755 string const LyXFunc::dispatch(string const & s)
757 // Split command string into command and argument
759 string line = frontStrip(s);
760 string const arg = strip(frontStrip(split(line, cmd, ' ')));
762 return dispatch(lyxaction.LookupFunc(cmd), arg);
766 string const LyXFunc::dispatch(int ac,
767 string const & do_not_use_this_arg)
769 lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << ac
770 <<"] arg[" << do_not_use_this_arg << "]" << endl;
775 // we have not done anything wrong yet.
777 dispatch_buffer.erase();
779 // if action is a pseudo-action, we need the real action
780 if (lyxaction.isPseudoAction(ac)) {
782 action = static_cast<kb_action>
783 (lyxaction.retrieveActionArg(ac, tmparg));
787 action = static_cast<kb_action>(ac);
788 if (!do_not_use_this_arg.empty())
789 argument = do_not_use_this_arg; // except here
792 #ifdef NEW_DISPATCHER
793 // We try do call the most specific dispatcher first:
794 // 1. the lockinginset's dispatch
795 // 2. the bufferview's dispatch
796 // 3. the lyxview's dispatch
799 selection_possible = false;
801 if (owner->view()->available())
802 owner->view()->hideCursor();
804 // We cannot use this function here
805 if (getStatus(ac, do_not_use_this_arg) & func_status::Disabled) {
806 lyxerr << "LyXFunc::Dispatch: "
807 << lyxaction.getActionName(ac)
808 << " [" << ac << "] is disabled at this location"
810 goto exit_with_message;
813 if (owner->view()->available() && owner->view()->theLockingInset()) {
814 UpdatableInset::RESULT result;
815 if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
816 (keyseq.length >= -1)))
818 if ((action==LFUN_UNKNOWN_ACTION) && argument.empty()){
819 argument = keyseq.getiso();
821 // Undo/Redo is a bit tricky for insets.
822 if (action == LFUN_UNDO) {
823 #ifdef RETHINK_THIS_FOR_NOW_WE_LEAVE_ALL_UNLOCKED
826 UpdatableInset * inset =
827 owner->view()->theLockingInset()->getLockingInset();
828 int inset_id = inset->id();
829 inset->getCursorPos(owner->view(), slx, sly);
830 owner->view()->unlockInset(inset);
832 owner->view()->unlockInset(owner->view()->theLockingInset());
834 owner->view()->menuUndo();
835 #ifdef RETHINK_THIS_FOR_NOW_WE_LEAVE_ALL_UNLOCKED
837 if (TEXT()->cursor.par()->
838 isInset(TEXT()->cursor.pos())) {
839 inset = static_cast<UpdatableInset*>(
840 TEXT()->cursor.par()->
847 inset = static_cast<UpdatableInset *>(owner->view()->buffer()->getInsetFromID(inset_id));
850 inset->edit(owner->view(),slx,sly,0);
853 } else if (action == LFUN_REDO) {
856 UpdatableInset * inset = owner->view()->
858 inset->getCursorPos(owner->view(), slx, sly);
859 owner->view()->unlockInset(inset);
860 owner->view()->menuRedo();
861 inset = static_cast<UpdatableInset*>(
862 TEXT()->cursor.par()->
866 inset->edit(owner->view(),slx,sly,0);
868 } else if (((result=owner->view()->theLockingInset()->
869 localDispatch(owner->view(), action,
871 UpdatableInset::DISPATCHED) ||
872 (result == UpdatableInset::DISPATCHED_NOUPDATE))
875 //setMessage(N_("Text mode"));
877 case LFUN_UNKNOWN_ACTION:
878 case LFUN_BREAKPARAGRAPH:
880 TEXT()->cursorRight(owner->view());
881 owner->view()->setState();
885 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
886 TEXT()->cursorRight(owner->view());
887 moveCursorUpdate(true, false);
892 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
893 TEXT()->cursorRight(owner->view());
894 moveCursorUpdate(true, false);
899 if (TEXT()->cursor.row()->next())
900 TEXT()->cursorDown(owner->view());
902 TEXT()->cursorRight(owner->view());
903 moveCursorUpdate(true, false);
913 lyx::Assert(action != LFUN_SELECT_FILE_SYNC);
919 if (!owner->view()->available()) break;
921 // this function should be used always [asierra060396]
922 UpdatableInset * tli =
923 owner->view()->theLockingInset();
925 UpdatableInset * lock = tli->getLockingInset();
928 owner->view()->unlockInset(tli);
929 TEXT()->cursorRight(owner->view());
930 moveCursorUpdate(true, false);
933 tli->unlockInsetInInset(owner->view(),
941 // --- Misc -------------------------------------------
942 case LFUN_WORDFINDFORWARD :
943 case LFUN_WORDFINDBACKWARD : {
944 static string last_search;
945 string searched_string;
947 if (!argument.empty()) {
948 last_search = argument;
949 searched_string = argument;
951 searched_string = last_search;
953 bool fw = (action == LFUN_WORDFINDBACKWARD);
954 if (!searched_string.empty()) {
955 LyXFind(owner->view(), searched_string, fw);
957 // owner->view()->showCursor();
963 if (owner->view()->available() && !owner->view()->theLockingInset()) {
964 owner->view()->update(TEXT(),
965 BufferView::SELECT|BufferView::FITCUR);
968 keyseq.print(buf, true);
973 // --- Misc -------------------------------------------
974 case LFUN_EXEC_COMMAND:
976 std::vector<string> allCmds;
977 std::transform(lyxaction.func_begin(), lyxaction.func_end(),
978 std::back_inserter(allCmds), lyx::firster());
979 static std::vector<string> hist;
980 owner->getMiniBuffer()->getString(MiniBuffer::spaces,
985 case LFUN_CANCEL: // RVDK_PATCH_5
988 if (owner->view()->available())
989 // cancel any selection
990 dispatch(LFUN_MARK_OFF);
991 setMessage(N_("Cancel"));
994 case LFUN_META_FAKE: // RVDK_PATCH_5
996 meta_fake_bit = Mod1Mask;
998 keyseq.print(buf, true);
999 setMessage(buf); // RVDK_PATCH_5
1003 case LFUN_READ_ONLY_TOGGLE:
1004 if (owner->buffer()->lyxvc.inUse()) {
1005 owner->buffer()->lyxvc.toggleReadOnly();
1007 owner->buffer()->setReadonly(
1008 !owner->buffer()->isReadonly());
1012 case LFUN_CENTER: // this is center and redraw.
1013 owner->view()->center();
1016 // --- Menus -----------------------------------------------
1021 case LFUN_MENUNEWTMPLT:
1025 case LFUN_CLOSEBUFFER:
1029 case LFUN_MENUWRITE:
1030 if (!owner->buffer()->isUnnamed()) {
1032 s1 << _("Saving document") << ' '
1033 << MakeDisplayPath(owner->buffer()->fileName() + "...");
1034 owner->message(s1.str().c_str());
1035 MenuWrite(owner->view(), owner->buffer());
1037 WriteAs(owner->view(), owner->buffer());
1041 WriteAs(owner->view(), owner->buffer(), argument);
1044 case LFUN_MENURELOAD:
1049 Exporter::Export(owner->buffer(), argument, true);
1053 Exporter::Preview(owner->buffer(), argument);
1056 case LFUN_BUILDPROG:
1057 Exporter::Export(owner->buffer(), "program", true);
1060 case LFUN_RUNCHKTEX:
1061 MenuRunChktex(owner->buffer());
1064 case LFUN_MENUPRINT:
1065 owner->getDialogs()->showPrint();
1069 if (argument == "custom")
1072 Exporter::Export(owner->buffer(), argument, false);
1090 InsetCommandParams p;
1093 if (action == LFUN_TOCVIEW)
1095 p.setCmdName("tableofcontents");
1097 else if (action == LFUN_LOAVIEW )
1098 p.setCmdName("listof{algorithm}{List of Algorithms}");
1099 else if (action == LFUN_LOFVIEW)
1100 p.setCmdName("listoffigures");
1102 p.setCmdName("listoftables");
1104 owner->getDialogs()->createTOC(p.getAsString());
1108 case LFUN_DIALOG_TABULAR_INSERT:
1109 owner->getDialogs()->showTabularCreate();
1117 AutoSave(owner->view());
1121 owner->view()->menuUndo();
1125 owner->view()->menuRedo();
1128 case LFUN_MENUSEARCH:
1129 owner->getDialogs()->showSearch();
1132 case LFUN_REMOVEERRORS:
1133 if (owner->view()->removeAutoInsets()) {
1134 owner->view()->redraw();
1135 owner->view()->fitCursor();
1140 changeDepth(owner->view(), TEXT(false), 0);
1143 case LFUN_DEPTH_MIN:
1144 changeDepth(owner->view(), TEXT(false), -1);
1147 case LFUN_DEPTH_PLUS:
1148 changeDepth(owner->view(), TEXT(false), 1);
1152 owner->getDialogs()->setUserFreeFont();
1158 owner->view()->setState();
1163 case LFUN_RECONFIGURE:
1164 Reconfigure(owner->view());
1168 case LFUN_FLOATSOPERATE:
1169 if (argument == "openfoot")
1170 owner->view()->allFloats(1,0);
1171 else if (argument == "closefoot")
1172 owner->view()->allFloats(0,0);
1173 else if (argument == "openfig")
1174 owner->view()->allFloats(1,1);
1175 else if (argument == "closefig")
1176 owner->view()->allFloats(0,1);
1179 #ifdef WITH_WARNINGS
1180 #warning Find another implementation here (or another lyxfunc)!
1183 case LFUN_HELP_ABOUTLYX:
1184 owner->getDialogs()->showAboutlyx();
1187 case LFUN_HELP_COPYRIGHT:
1188 case LFUN_HELP_CREDITS:
1191 case LFUN_HELP_OPEN:
1193 string const arg = argument;
1195 setErrorMessage(N_("Missing argument"));
1198 owner->prohibitInput();
1199 string const fname = i18nLibFileSearch("doc", arg, "lyx");
1200 if (fname.empty()) {
1201 lyxerr << "LyX: unable to find documentation file `"
1202 << arg << "'. Bad installation?" << endl;
1203 owner->allowInput();
1207 str << _("Opening help file") << ' '
1208 << MakeDisplayPath(fname) << "...";
1209 owner->message(str.str().c_str());
1210 owner->view()->buffer(bufferlist.loadLyXFile(fname, false));
1211 owner->allowInput();
1215 case LFUN_HELP_VERSION:
1217 // --- version control -------------------------------
1218 case LFUN_VC_REGISTER:
1220 if (!owner->buffer()->lyxvc.inUse())
1221 owner->buffer()->lyxvc.registrer();
1225 case LFUN_VC_CHECKIN:
1227 if (owner->buffer()->lyxvc.inUse()
1228 && !owner->buffer()->isReadonly())
1229 owner->buffer()->lyxvc.checkIn();
1233 case LFUN_VC_CHECKOUT:
1235 if (owner->buffer()->lyxvc.inUse()
1236 && owner->buffer()->isReadonly())
1237 owner->buffer()->lyxvc.checkOut();
1241 case LFUN_VC_REVERT:
1243 owner->buffer()->lyxvc.revert();
1249 owner->buffer()->lyxvc.undoLast();
1253 case LFUN_VC_HISTORY:
1255 owner->getDialogs()->showVCLogFile();
1259 // --- buffers ----------------------------------------
1261 case LFUN_SWITCHBUFFER:
1262 owner->view()->buffer(bufferlist.getBuffer(argument));
1267 // servercmd: argument must be <file>:<template>
1268 Buffer * tmpbuf = NewLyxFile(argument);
1270 owner->view()->buffer(tmpbuf);
1274 case LFUN_FILE_OPEN:
1278 case LFUN_LATEX_LOG:
1279 owner->getDialogs()->showLogFile();
1284 lyxerr[Debug::INFO] << "LFUN_LAYOUTNO: (arg) " << argument << endl;
1285 int sel = strToInt(argument);
1286 lyxerr[Debug::INFO] << "LFUN_LAYOUTNO: (sel) "<< sel << endl;
1288 // Should this give a setMessage instead?
1290 return string(); // illegal argument
1292 --sel; // sel 1..., but layout 0...
1294 // Pretend we got the name instead.
1295 dispatch(int(LFUN_LAYOUT),
1296 textclasslist.NameOfLayout(owner->view()
1297 ->buffer()->params.textclass,
1302 case LFUN_LAYOUT_DOCUMENT:
1303 owner->getDialogs()->showDocument();
1306 case LFUN_LAYOUT_PARAGRAPH:
1307 owner->getDialogs()->showParagraph();
1310 case LFUN_LAYOUT_CHARACTER:
1311 owner->getDialogs()->showCharacter();
1314 case LFUN_LAYOUT_TABULAR:
1315 if (owner->view()->theLockingInset()) {
1316 if (owner->view()->theLockingInset()->lyxCode()==Inset::TABULAR_CODE) {
1317 InsetTabular * inset = static_cast<InsetTabular *>
1318 (owner->view()->theLockingInset());
1319 inset->openLayoutDialog(owner->view());
1320 } else if (owner->view()->theLockingInset()->
1321 getFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
1322 InsetTabular * inset = static_cast<InsetTabular *>(
1323 owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
1324 inset->openLayoutDialog(owner->view());
1329 case LFUN_LAYOUT_PREAMBLE:
1330 owner->getDialogs()->showPreamble();
1333 case LFUN_LAYOUT_SAVE_DEFAULT:
1334 MenuLayoutSave(owner->view());
1337 case LFUN_DROP_LAYOUTS_CHOICE:
1338 owner->getToolbar()->openLayoutList();
1341 case LFUN_MENU_OPEN_BY_NAME:
1342 owner->getMenubar()->openByName(argument);
1343 break; // RVDK_PATCH_5
1345 case LFUN_SPELLCHECK:
1346 if (lyxrc.isp_command != "none")
1347 owner->getDialogs()->showSpellchecker();
1350 // --- lyxserver commands ----------------------------
1354 setMessage(owner->buffer()->fileName());
1355 lyxerr[Debug::INFO] << "FNAME["
1356 << owner->buffer()->fileName()
1364 dispatch_buffer = buf;
1365 lyxserver->notifyClient(dispatch_buffer);
1369 case LFUN_GOTOFILEROW:
1373 istringstream istr(argument.c_str());
1374 istr >> file_name >> row;
1375 // Must replace extension of the file to be .lyx and get full path
1376 string const s(ChangeExtension(file_name, ".lyx"));
1378 // Either change buffer or load the file
1379 if (bufferlist.exists(s)) {
1380 owner->view()->buffer(bufferlist.getBuffer(s));
1382 owner->view()->buffer(bufferlist.loadLyXFile(s));
1386 owner->view()->setCursorFromRow(row);
1389 owner->view()->center();
1393 case LFUN_GOTO_PARAGRAPH:
1395 istringstream istr(argument.c_str());
1399 Paragraph * par = owner->buffer()->getParFromID(id);
1401 lyxerr[Debug::INFO] << "No matching paragraph found! ["
1402 << id << "]" << std::endl;
1407 TEXT()->setCursor(owner->view(), par, 0);
1408 owner->view()->setState();
1412 owner->view()->center();
1419 int const qa = lyxaction.LookupFunc(argument);
1420 setMessage(lyxaction.helpText(static_cast<kb_action>(qa)));
1424 // --- toolbar ----------------------------------
1425 case LFUN_PUSH_TOOLBAR:
1427 int nth = strToInt(argument);
1429 setErrorMessage(N_("Push-toolbar needs argument > 0"));
1431 owner->getToolbar()->push(nth);
1436 case LFUN_ADD_TO_TOOLBAR:
1438 if (lyxerr.debugging(Debug::GUI)) {
1439 lyxerr << "LFUN_ADD_TO_TOOLBAR:"
1440 "argument = `" << argument << '\'' << endl;
1442 string tmp(argument);
1443 //lyxerr <<string("Argument: ") + argument);
1444 //lyxerr <<string("Tmp : ") + tmp);
1446 setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
1448 owner->getToolbar()->add(argument, false);
1449 owner->getToolbar()->set();
1454 // --- insert characters ----------------------------------------
1456 // --- Mathed stuff. If we are here, there is no locked inset yet.
1461 if (!greek_kb_flag) {
1463 setMessage(N_("Math greek mode on"));
1470 case LFUN_GREEK_TOGGLE:
1472 greek_kb_flag = greek_kb_flag ? 0 : 2;
1473 if (greek_kb_flag) {
1474 setMessage(N_("Math greek keyboard on"));
1476 setMessage(N_("Math greek keyboard off"));
1481 case LFUN_MATH_EXTERN:
1482 case LFUN_MATH_NUMBER:
1483 case LFUN_MATH_NONUMBER:
1484 case LFUN_MATH_LIMITS:
1486 setErrorMessage(N_("This is only allowed in math mode!"));
1490 case LFUN_MATH_PANEL:
1491 owner->getDialogs()->showMathPanel();
1494 case LFUN_CITATION_CREATE:
1496 InsetCommandParams p( "cite" );
1498 if (!argument.empty()) {
1499 // This should be set at source, ie when typing
1500 // "citation-insert foo" in the minibuffer.
1501 // Question: would pybibliographer also need to be
1502 // changed. Suspect so. Leave as-is therefore.
1503 if (contains(argument, "|")) {
1504 p.setContents( token(argument, '|', 0) );
1505 p.setOptions( token(argument, '|', 1) );
1507 p.setContents( argument );
1509 dispatch(LFUN_CITATION_INSERT, p.getAsString());
1511 owner->getDialogs()->createCitation( p.getAsString() );
1515 case LFUN_CHILDOPEN:
1517 string const filename =
1518 MakeAbsPath(argument,
1519 OnlyPath(owner->buffer()->fileName()));
1520 setMessage(N_("Opening child document ") +
1521 MakeDisplayPath(filename) + "...");
1522 owner->view()->savePosition(0);
1523 if (bufferlist.exists(filename))
1524 owner->view()->buffer(bufferlist.getBuffer(filename));
1526 owner->view()->buffer(bufferlist.loadLyXFile(filename));
1530 case LFUN_TOGGLECURSORFOLLOW:
1531 lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
1534 case LFUN_KMAP_OFF: // keymap off
1535 owner->getIntl()->KeyMapOn(false);
1538 case LFUN_KMAP_PRIM: // primary keymap
1539 owner->getIntl()->KeyMapPrim();
1542 case LFUN_KMAP_SEC: // secondary keymap
1543 owner->getIntl()->KeyMapSec();
1546 case LFUN_KMAP_TOGGLE: // toggle keymap
1547 owner->getIntl()->ToggleKeyMap();
1552 // argument contains ';'-terminated commands
1553 while (argument.find(';') != string::npos) {
1555 argument = split(argument, first, ';');
1561 case LFUN_DIALOG_PREFERENCES:
1562 owner->getDialogs()->showPreferences();
1565 case LFUN_SAVEPREFERENCES:
1567 Path p(user_lyxdir);
1568 lyxrc.write("preferences");
1572 case LFUN_SCREEN_FONT_UPDATE:
1574 // handle the screen font changes.
1576 lyxrc.set_font_norm_type();
1577 fontloader.update();
1578 // Of course we should only do the resize and the textcache.clear
1579 // if values really changed...but not very important right now. (Lgb)
1580 // All visible buffers will need resize
1582 // We also need to empty the textcache so that
1583 // the buffer will be formatted correctly after
1589 case LFUN_SET_COLOR:
1592 string const x11_name = split(argument, lyx_name, ' ');
1593 if (lyx_name.empty() || x11_name.empty()) {
1594 setErrorMessage(N_("Syntax: set-color <lyx_name>"
1599 if (!lcolor.setColor(lyx_name, x11_name)) {
1600 static string const err1 (N_("Set-color \""));
1601 static string const err2 (
1602 N_("\" failed - color is undefined "
1603 "or may not be redefined"));
1604 setErrorMessage(_(err1) + lyx_name + _(err2));
1607 lyxColorHandler->updateColor(lcolor.getFromLyXName(lyx_name));
1608 owner->view()->redraw();
1613 owner->message(argument);
1616 case LFUN_MESSAGE_PUSH:
1617 owner->messagePush(argument);
1620 case LFUN_MESSAGE_POP:
1621 owner->messagePop();
1625 // Then if it was none of the above
1626 if (!owner->view()->Dispatch(action, argument))
1627 lyxerr << "A truly unknown func ["
1628 << lyxaction.getActionName(action) << "]!"
1635 commandshortcut.erase();
1637 if (lyxrc.display_shortcuts && show_sc) {
1638 if (action != LFUN_SELFINSERT) {
1639 // Put name of command and list of shortcuts
1640 // for it in minibuffer
1641 string comname = lyxaction.getActionName(action);
1643 int pseudoaction = action;
1644 bool argsadded = false;
1646 if (!argument.empty()) {
1647 // If we have the command with argument,
1650 lyxaction.searchActionArg(action,
1653 if (pseudoaction == -1) {
1654 pseudoaction = action;
1656 comname += " " + argument;
1661 string const shortcuts =
1662 toplevel_keymap->findbinding(pseudoaction);
1664 if (!shortcuts.empty()) {
1665 comname += ": " + shortcuts;
1666 } else if (!argsadded) {
1667 comname += " " + argument;
1670 if (!comname.empty()) {
1671 comname = strip(comname);
1672 commandshortcut = "(" + comname + ')';
1674 // Here we could even add a small pause,
1675 // to annoy the user and make him learn
1677 // No! That will just annoy, not teach
1678 // anything. The user will read the messages
1679 // if they are interested. (Asger)
1684 string const res = getMessage();
1687 if (!commandshortcut.empty()) {
1688 owner->getMiniBuffer()->addSet(commandshortcut);
1691 string const msg(_(res) + ' ' + commandshortcut);
1692 owner->message(msg);
1699 void LyXFunc::setupLocalKeymap()
1701 keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
1702 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap.get();
1706 void LyXFunc::menuNew(bool fromTemplate)
1708 string initpath = lyxrc.document_path;
1710 if (owner->view()->available()) {
1711 string const trypath = owner->buffer()->filepath;
1712 // If directory is writeable, use this as default.
1713 if (IsDirWriteable(trypath))
1717 static int newfile_number;
1720 if (lyxrc.new_ask_filename) {
1721 FileDialog fileDlg(owner, _("Enter filename for new document"),
1722 LFUN_SELECT_FILE_SYNC,
1723 make_pair(string(_("Documents")),
1724 string(lyxrc.document_path)),
1725 make_pair(string(_("Templates")),
1726 string(lyxrc.template_path)));
1728 FileDialog::Result result =
1729 fileDlg.Select(initpath,
1730 _("*.lyx|LyX Documents (*.lyx)"),
1733 if (result.second.empty()) {
1734 owner->message(_("Canceled."));
1735 lyxerr[Debug::INFO] << "New Document Cancelled." << endl;
1739 // get absolute path of file and make sure the filename ends
1741 s = MakeAbsPath(result.second);
1742 if (!IsLyXFilename(s))
1745 // Check if the document already is open
1746 if (bufferlist.exists(s)) {
1747 switch (AskConfirmation(_("Document is already open:"),
1748 MakeDisplayPath(s, 50),
1749 _("Do you want to close that document now?\n"
1750 "('No' will just switch to the open version)")))
1752 case 1: // Yes: close the document
1753 if (!bufferlist.close(bufferlist.getBuffer(s)))
1754 // If close is canceled, we cancel here too.
1757 case 2: // No: switch to the open document
1758 owner->view()->buffer(bufferlist.getBuffer(s));
1760 case 3: // Cancel: Do nothing
1761 owner->message(_("Canceled."));
1765 // Check whether the file already exists
1767 if (fi.readable() &&
1768 AskQuestion(_("File already exists:"),
1769 MakeDisplayPath(s, 50),
1770 _("Do you want to open the document?"))) {
1772 string const disp_fn(MakeDisplayPath(s));
1775 str << _("Opening document") << ' '
1776 << disp_fn << "...";
1778 owner->message(str.str().c_str());
1779 //XFlush(fl_get_display());
1780 owner->view()->buffer(bufferlist.loadLyXFile(s));
1782 str2 << _("Document") << ' '
1783 << disp_fn << ' ' << _("opened.");
1785 owner->message(str2.str().c_str());
1790 s = AddName(lyxrc.document_path,
1791 "newfile" + tostr(++newfile_number) + ".lyx");
1793 while (bufferlist.exists(s) || fi.readable()) {
1795 s = AddName(lyxrc.document_path,
1796 "newfile" + tostr(newfile_number) +
1802 // The template stuff
1805 FileDialog fileDlg(owner, _("Select template file"),
1806 LFUN_SELECT_FILE_SYNC,
1807 make_pair(string(_("Documents")),
1808 string(lyxrc.document_path)),
1809 make_pair(string(_("Templates")),
1810 string(lyxrc.template_path)));
1812 FileDialog::Result result =
1813 fileDlg.Select(lyxrc.template_path,
1814 _("*.lyx|LyX Documents (*.lyx)"));
1816 if (result.first == FileDialog::Later)
1819 string const fname = result.second;
1826 // find a free buffer
1827 lyxerr[Debug::INFO] << "Find a free buffer." << endl;
1828 owner->view()->buffer(bufferlist.newFile(s, templname));
1832 void LyXFunc::open(string const & fname)
1834 string initpath = lyxrc.document_path;
1836 if (owner->view()->available()) {
1837 string const trypath = owner->buffer()->filepath;
1838 // If directory is writeable, use this as default.
1839 if (IsDirWriteable(trypath))
1845 if (fname.empty()) {
1846 FileDialog fileDlg(owner, _("Select document to open"),
1848 make_pair(string(_("Documents")),
1849 string(lyxrc.document_path)),
1850 make_pair(string(_("Examples")),
1851 string(AddPath(system_lyxdir, "examples"))));
1853 FileDialog::Result result =
1854 fileDlg.Select(initpath,
1855 "*.lyx|LyX Documents (*.lyx)");
1857 if (result.first == FileDialog::Later)
1860 filename = result.second;
1862 // check selected filename
1863 if (filename.empty()) {
1864 owner->message(_("Canceled."));
1870 // get absolute path of file and add ".lyx" to the filename if
1872 string const fullpath = FileSearch(string(), filename, "lyx");
1873 if (fullpath.empty()) {
1874 WriteAlert(_("Error"), _("Could not find file"), filename);
1878 filename = fullpath;
1881 string const disp_fn(MakeDisplayPath(filename));
1884 str << _("Opening document") << ' ' << disp_fn << "...";
1886 owner->message(str.str().c_str());
1888 Buffer * openbuf = bufferlist.loadLyXFile(filename);
1890 owner->view()->buffer(openbuf);
1892 str << _("Document") << ' ' << disp_fn << ' ' << _("opened.");
1893 owner->message(str.str().c_str());
1896 str << _("Could not open docuent") << ' ' << disp_fn;
1897 owner->message(str.str().c_str());
1902 // checks for running without gui are missing.
1903 void LyXFunc::doImport(string const & argument)
1906 string filename = split(argument, format, ' ');
1907 lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format
1908 << " file: " << filename << endl;
1910 if (filename.empty()) { // need user interaction
1911 string initpath = lyxrc.document_path;
1913 if (owner->view()->available()) {
1914 string const trypath = owner->buffer()->filepath;
1915 // If directory is writeable, use this as default.
1916 if (IsDirWriteable(trypath))
1920 string const text = _("Select ") + formats.prettyName(format)
1921 + _(" file to import");
1923 FileDialog fileDlg(owner, text,
1925 make_pair(string(_("Documents")),
1926 string(lyxrc.document_path)),
1927 make_pair(string(_("Examples")),
1928 string(AddPath(system_lyxdir, "examples"))));
1930 string const extension = "*." + formats.extension(format)
1931 + "| " + formats.prettyName(format)
1932 + " (*." + formats.extension(format) + ")";
1934 FileDialog::Result result = fileDlg.Select(initpath,
1937 if (result.first == FileDialog::Later)
1940 filename = result.second;
1942 // check selected filename
1943 if (filename.empty())
1944 owner->message(_("Canceled."));
1947 // still no filename? abort
1948 if (filename.empty())
1951 // get absolute path of file
1952 filename = MakeAbsPath(filename);
1954 string const lyxfile = ChangeExtension(filename, ".lyx");
1956 // Check if the document already is open
1957 if (bufferlist.exists(lyxfile)) {
1958 switch (AskConfirmation(_("Document is already open:"),
1959 MakeDisplayPath(lyxfile, 50),
1960 _("Do you want to close that document now?\n"
1961 "('No' will just switch to the open version)")))
1963 case 1: // Yes: close the document
1964 if (!bufferlist.close(bufferlist.getBuffer(lyxfile)))
1965 // If close is canceled, we cancel here too.
1968 case 2: // No: switch to the open document
1969 owner->view()->buffer(bufferlist.getBuffer(lyxfile));
1971 case 3: // Cancel: Do nothing
1972 owner->message(_("Canceled."));
1977 // Check if a LyX document by the same root exists in filesystem
1978 FileInfo const f(lyxfile, true);
1979 if (f.exist() && !AskQuestion(_("A document by the name"),
1980 MakeDisplayPath(lyxfile),
1981 _("already exists. Overwrite?"))) {
1982 owner->message(_("Canceled"));
1985 // filename should be valid now
1987 Importer::Import(owner, filename, format);
1991 void LyXFunc::reloadBuffer()
1993 string const fn = owner->buffer()->fileName();
1994 if (bufferlist.close(owner->buffer()))
1995 owner->view()->buffer(bufferlist.loadLyXFile(fn));
1999 void LyXFunc::closeBuffer()
2001 if (bufferlist.close(owner->buffer()) && !quitting) {
2002 if (bufferlist.empty()) {
2003 // need this otherwise SEGV may occur while trying to
2004 // set variables that don't exist
2005 // since there's no current buffer
2006 owner->getDialogs()->hideBufferDependent();
2008 owner->view()->buffer(bufferlist.first());
2014 // Each "owner" should have it's own message method. lyxview and
2015 // the minibuffer would use the minibuffer, but lyxserver would
2016 // send an ERROR signal to its client. Alejandro 970603
2017 // This func is bit problematic when it comes to NLS, to make the
2018 // lyx servers client be language indepenent we must not translate
2019 // strings sent to this func.
2020 void LyXFunc::setErrorMessage(string const & m) const
2022 dispatch_buffer = m;
2027 void LyXFunc::setMessage(string const & m)
2029 dispatch_buffer = m;
2033 void LyXFunc::initMiniBuffer()
2035 string text = _("Welcome to LyX!");
2037 // When meta-fake key is pressed, show the key sequence so far + "M-".
2043 // Else, when a non-complete key sequence is pressed,
2044 // show the available options.
2045 else if (keyseqUncomplete())
2046 text = keyseqOptions();
2048 // Else, show the buffer state.
2049 else if (owner->view()->available()) {
2050 Buffer * tmpbuf = owner->buffer();
2052 string const nicename =
2053 MakeDisplayPath(tmpbuf->fileName());
2054 // Should we do this instead? (kindo like emacs)
2055 // leaves more room for other information
2058 if (tmpbuf->lyxvc.inUse()) {
2060 text += tmpbuf->lyxvc.version();
2062 text += tmpbuf->lyxvc.locker();
2063 if (tmpbuf->isReadonly())
2066 } else if (tmpbuf->isReadonly())
2068 if (!tmpbuf->isLyxClean())
2069 text += _(" (Changed)");
2071 if (text != _("Welcome to LyX!")) // this is a hack
2072 text = _("* No document open *");
2075 owner->message(text);