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"
34 #include "support/LAssert.h"
38 #include "bufferlist.h"
39 #include "BufferView.h"
40 #include "ColorHandler.h"
41 #include "lyxserver.h"
45 #include "LyXAction.h"
46 #include "insets/inseturl.h"
47 #include "insets/insetlatexaccent.h"
48 #include "insets/insettoc.h"
49 #include "insets/insetref.h"
50 #include "insets/insetparent.h"
51 #include "insets/insetindex.h"
52 #include "insets/insetinclude.h"
53 #include "insets/insetbib.h"
54 #include "insets/insetcite.h"
55 #include "insets/insettext.h"
56 #include "insets/insetert.h"
57 #include "insets/insetexternal.h"
58 #include "insets/insetgraphics.h"
59 #include "insets/insetfoot.h"
60 #include "insets/insetmarginal.h"
61 #include "insets/insetminipage.h"
62 #include "insets/insetfloat.h"
64 #include "insets/insetlist.h"
65 #include "insets/insettheorem.h"
67 #include "insets/insettabular.h"
68 #include "insets/insetcaption.h"
69 #include "mathed/formulamacro.h"
70 #include "mathed/math_cursor.h"
71 #include "mathed/math_inset.h"
72 #include "minibuffer.h"
75 #include "lyx_gui_misc.h"
76 #include "support/filetools.h"
77 #include "support/FileInfo.h"
78 #include "support/syscall.h"
79 #include "support/lstrings.h"
80 #include "support/path.h"
81 #include "support/lyxfunctional.h"
86 #include "trans_mgr.h"
89 #include "bufferview_funcs.h"
90 #include "frontends/FileDialog.h"
91 #include "frontends/Dialogs.h"
92 #include "frontends/Toolbar.h"
93 #include "frontends/Menubar.h"
94 #include "FloatList.h"
95 #include "converter.h"
98 #include "FontLoader.h"
99 #include "TextCache.h"
101 #include "undo_funcs.h"
104 using std::make_pair;
108 extern BufferList bufferlist;
109 extern LyXServer * lyxserver;
110 extern int greek_kb_flag;
111 extern bool selection_possible;
112 extern void MenuSendto();
114 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
116 extern void show_symbols_form(LyXFunc *);
118 extern LyXAction lyxaction;
120 extern tex_accent_struct get_accent(kb_action action);
122 extern LyXTextClass::size_type current_layout;
124 extern void ShowLatexLog();
130 class MiniBufferController : public SigC::Object {
133 MiniBufferController() {
137 &MiniBufferController::receiveCommand));
141 &MiniBufferController::receiveArg));
144 void receiveCmd(string const & cmd) {}
146 void receiveArg(string const & arg) {}
154 MiniBufferController mb_ctrl;
160 /* === globals =========================================================== */
162 // Initialization of static member var
163 bool LyXFunc::show_sc = true;
166 LyXFunc::LyXFunc(LyXView * o)
170 lyx_dead_action = LFUN_NOACTION;
171 lyx_calling_dead_action = LFUN_NOACTION;
177 LyXText * LyXFunc::TEXT(bool flag = true) const
180 return owner->view()->text;
181 return owner->view()->getLyXText();
185 // I changed this func slightly. I commented out the ...FinishUndo(),
186 // this means that all places that used to have a moveCursorUpdate, now
187 // have a ...FinishUndo() as the preceeding statement. I have also added
188 // a moveCursorUpdate to some of the functions that updated the cursor, but
189 // that did not show its new position.
191 void LyXFunc::moveCursorUpdate(bool flag, bool selecting)
193 if (selecting || TEXT(flag)->selection.mark()) {
194 TEXT(flag)->setSelection(owner->view());
195 if (TEXT(flag)->bv_owner)
196 owner->view()->toggleToggle();
198 owner->view()->update(TEXT(flag), BufferView::SELECT|BufferView::FITCUR);
199 owner->view()->showCursor();
201 /* ---> Everytime the cursor is moved, show the current font state. */
202 // should this too me moved out of this func?
203 owner->view()->setState();
207 void LyXFunc::handleKeyFunc(kb_action action)
209 char c = keyseq.getiso();
211 if (keyseq.length != -1) c = 0;
213 owner->getIntl()->getTrans()
214 .deadkey(c, get_accent(action).accent, TEXT(false));
215 // Need to reset, in case the minibuffer calls these
219 // copied verbatim from do_accent_char
220 owner->view()->update(TEXT(false),
221 BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
222 TEXT(false)->selection.cursor = TEXT(false)->cursor;
226 void LyXFunc::processKeySym(KeySym keysym, unsigned int state)
230 if (lyxerr.debugging(Debug::KEY)) {
231 char const * tmp = XKeysymToString(keysym);
232 string const stm = (tmp ? tmp : "");
233 lyxerr << "KeySym is "
236 << keysym << "] State is ["
240 // Do nothing if we have nothing (JMarc)
241 if (keysym == NoSymbol) {
242 lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
247 // Can we be sure that this will work for all X-Windows
248 // implementations? (Lgb)
249 // This code snippet makes lyx ignore some keys. Perhaps
250 // all of them should be explictly mentioned?
251 if ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
252 || keysym == XK_Mode_switch || keysym == 0x0) {
256 // Do a one-deep top-level lookup for
257 // cancel and meta-fake keys. RVDK_PATCH_5
258 cancel_meta_seq.reset();
260 int action = cancel_meta_seq.addkey(keysym, state
261 &(ShiftMask|ControlMask
263 if (lyxerr.debugging(Debug::KEY)) {
264 lyxerr << "action first set to [" << action << "]" << endl;
267 // When not cancel or meta-fake, do the normal lookup.
268 // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
269 // Mostly, meta_fake_bit = 0. RVDK_PATCH_5.
270 if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
271 if (lyxerr.debugging(Debug::KEY)) {
272 lyxerr << "meta_fake_bit is ["
273 << meta_fake_bit << "]" << endl;
275 // remove Caps Lock and Mod2 as a modifiers
276 action = keyseq.addkey(keysym,
277 (state | meta_fake_bit)
278 &(ShiftMask|ControlMask
280 if (lyxerr.debugging(Debug::KEY)) {
281 lyxerr << "action now set to ["
282 << action << "]" << endl;
285 // Dont remove this unless you know what you are doing.
288 if (action == 0) action = LFUN_PREFIX;
290 if (lyxerr.debugging(Debug::KEY)) {
293 lyxerr << "Key [action="
299 // already here we know if it any point in going further
300 // why not return already here if action == -1 and
301 // num_bytes == 0? (Lgb)
303 if (keyseq.length > 1 || keyseq.length < -1) {
310 // It is unknown, but what if we remove all
311 // the modifiers? (Lgb)
312 action = keyseq.addkey(keysym, 0);
314 if (lyxerr.debugging(Debug::KEY)) {
315 lyxerr << "Removing modifiers...\n"
316 << "Action now set to ["
317 << action << "]" << endl;
320 owner->message(_("Unknown function."));
325 if (action == LFUN_SELFINSERT) {
326 // This is very X dependant.
327 unsigned int c = keysym;
329 switch (c & 0x0000FF00) {
330 // latin 1 byte 3 = 0
331 case 0x00000000: break;
332 // latin 2 byte 3 = 1
334 // latin 3 byte 3 = 2
336 // latin 4 byte 3 = 3
338 // latin 8 byte 3 = 18 (0x12)
340 // latin 9 byte 3 = 19 (0x13)
349 argument = static_cast<char>(c);
350 lyxerr[Debug::KEY] << "SelfInsert arg[`"
351 << argument << "']" << endl;
354 bool tmp_sc = show_sc;
356 dispatch(action, argument);
363 func_status::value_type LyXFunc::getStatus(int ac) const
365 return getStatus(ac, string());
369 func_status::value_type LyXFunc::getStatus(int ac,
370 string const & not_to_use_arg) const
373 func_status::value_type flag = func_status::OK;
375 Buffer * buf = owner->buffer();
377 if (lyxaction.isPseudoAction(ac))
378 action = lyxaction.retrieveActionArg(ac, argument);
380 action = static_cast<kb_action>(ac);
381 if (!not_to_use_arg.empty())
382 argument = not_to_use_arg; // exept here
385 if (action == LFUN_UNKNOWN_ACTION) {
386 setErrorMessage(N_("Unknown action"));
387 return func_status::Unknown;
390 // Check whether we need a buffer
391 if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) {
392 // Yes we need a buffer, do we have one?
395 // Can we use a readonly buffer?
396 if (buf->isReadonly() &&
397 !lyxaction.funcHasFlag(action,
398 LyXAction::ReadOnly)) {
400 setErrorMessage(N_("Document is read-only"));
401 flag |= func_status::Disabled;
405 setErrorMessage(N_("Command not allowed with"
406 "out any document open"));
407 flag |= func_status::Disabled;
412 // I would really like to avoid having this switch and rather try to
413 // encode this in the function itself.
414 bool disable = false;
417 disable = !Exporter::IsExportable(buf, "dvi")
418 || lyxrc.print_command == "none";
421 disable = argument == "fax" &&
422 !Exporter::IsExportable(buf, argument);
425 disable = buf->undostack.empty();
428 disable = buf->redostack.empty();
430 case LFUN_SPELLCHECK:
431 disable = lyxrc.isp_command == "none";
434 disable = lyxrc.chktex_command == "none";
437 disable = !Exporter::IsExportable(buf, "program");
440 case LFUN_LAYOUT_TABULAR:
442 if (owner->view()->theLockingInset()) {
443 disable = (owner->view()->theLockingInset()->lyxCode() != Inset::TABULAR_CODE) &&
444 !owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE);
448 case LFUN_TABULAR_FEATURE:
450 if (owner->view()->theLockingInset()) {
451 func_status::value_type ret = func_status::Disabled;
452 if (owner->view()->theLockingInset()->lyxCode() == Inset::TABULAR_CODE) {
453 ret = static_cast<InsetTabular *>
454 (owner->view()->theLockingInset())->
456 } else if (owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
457 ret = static_cast<InsetTabular *>
458 (owner->view()->theLockingInset()->
459 getFirstLockingInsetOfType(Inset::TABULAR_CODE))->
465 static InsetTabular inset(*owner->buffer(), 1, 1);
466 func_status::value_type ret;
469 ret = inset.getStatus(argument);
470 if ((ret & func_status::ToggleOn) ||
471 (ret & func_status::ToggleOff))
472 flag |= func_status::ToggleOff;
476 case LFUN_VC_REGISTER:
477 disable = buf->lyxvc.inUse();
479 case LFUN_VC_CHECKIN:
480 disable = !buf->lyxvc.inUse() || buf->isReadonly();
482 case LFUN_VC_CHECKOUT:
483 disable = !buf->lyxvc.inUse() || !buf->isReadonly();
487 case LFUN_VC_HISTORY:
488 disable = !buf->lyxvc.inUse();
490 case LFUN_BOOKMARK_GOTO:
491 disable = !owner->view()->
492 isSavedPosition(strToUnsignedInt(argument));
496 case LFUN_INSET_TOGGLE:
497 disable = (TEXT(false)->getInset() == 0);
500 case LFUN_MATH_VALIGN: {
501 // I think this test can be simplified (Andre')
502 // mathcursor is != 0 iff we are in math mode
503 //Inset * tli = owner->view()->theLockingInset();
504 //if (tli && (tli->lyxCode() == Inset::MATH_CODE
505 // || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
508 char align = mathcursor->valign();
513 if (argument.empty()) {
514 flag = func_status::OK;
517 if (!contains("tcb", argument[0])) {
521 if (argument[0] == align)
522 flag |= func_status::ToggleOn;
524 flag |= func_status::ToggleOff;
529 case LFUN_MATH_HALIGN: {
530 //Inset * tli = owner->view()->theLockingInset();
531 //if (tli && (tli->lyxCode() == Inset::MATH_CODE
532 // || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
534 char align = mathcursor->halign();
539 if (argument.empty()) {
540 flag = func_status::OK;
543 if (!contains("lcr", argument[0])) {
547 if (argument[0] == align)
548 flag |= func_status::ToggleOn;
550 flag |= func_status::ToggleOff;
555 case LFUN_MATH_MUTATE: {
556 Inset * tli = owner->view()->theLockingInset();
557 if (tli && (tli->lyxCode() == Inset::MATH_CODE)) {
558 MathInsetTypes type = mathcursor->par()->GetType();
559 func_status::value_type box = func_status::ToggleOff;
560 if (argument == "inline") {
561 if (type == LM_OT_SIMPLE)
562 box = func_status::ToggleOn;
563 } else if (argument == "display") {
564 if (type == LM_OT_EQUATION)
565 box = func_status::ToggleOn;
566 } else if (argument == "eqnarray") {
567 if (type == LM_OT_EQNARRAY)
568 box = func_status::ToggleOn;
569 } else if (argument == "align") {
570 if (type == LM_OT_ALIGN)
571 box = func_status::ToggleOn;
573 box = func_status::OK;
582 // we just need to be in math mode to enable that
584 case LFUN_MATH_SPACE:
585 case LFUN_MATH_LIMITS:
586 case LFUN_MATH_NONUMBER:
587 case LFUN_MATH_NUMBER:
588 disable = !mathcursor;
591 // we need to be math mode and a math array for that
592 // Hack: halign produces non-zero result iff we are in a math array
593 case LFUN_MATH_ROW_INSERT:
594 case LFUN_MATH_ROW_DELETE:
595 case LFUN_MATH_COLUMN_INSERT:
596 case LFUN_MATH_COLUMN_DELETE:
597 disable = !mathcursor || !mathcursor->halign();
604 // the functions which insert insets
605 Inset::Code code = Inset::NO_CODE;
607 case LFUN_INSET_TEXT:
608 code = Inset::TEXT_CODE;
611 code = Inset::ERT_CODE;
614 case LFUN_INSET_GRAPHICS:
615 code = Inset::GRAPHICS_CODE;
617 case LFUN_INSET_FOOTNOTE:
618 code = Inset::FOOT_CODE;
620 case LFUN_DIALOG_TABULAR_INSERT:
621 case LFUN_INSET_TABULAR:
622 code = Inset::TABULAR_CODE;
624 case LFUN_INSET_EXTERNAL:
625 code = Inset::EXTERNAL_CODE;
627 case LFUN_INSET_MARGINAL:
628 code = Inset::MARGIN_CODE;
630 case LFUN_INSET_MINIPAGE:
631 code = Inset::MINIPAGE_CODE;
633 case LFUN_INSET_FLOAT:
634 case LFUN_INSET_WIDE_FLOAT:
635 code = Inset::FLOAT_CODE;
637 case LFUN_FLOAT_LIST:
638 code = Inset::FLOAT_LIST_CODE;
641 case LFUN_INSET_LIST:
642 code = Inset::LIST_CODE;
644 case LFUN_INSET_THEOREM:
645 code = Inset::THEOREM_CODE;
648 case LFUN_INSET_CAPTION:
649 code = Inset::CAPTION_CODE;
651 case LFUN_INSERT_NOTE:
652 code = Inset::IGNORE_CODE;
654 case LFUN_INSERT_LABEL:
655 code = Inset::LABEL_CODE;
657 case LFUN_REF_INSERT:
658 code = Inset::REF_CODE;
660 case LFUN_CITATION_CREATE:
661 case LFUN_CITATION_INSERT:
662 code = Inset::CITE_CODE;
664 case LFUN_INSERT_BIBTEX:
665 code = Inset::BIBTEX_CODE;
667 case LFUN_INDEX_INSERT:
668 case LFUN_INDEX_INSERT_LAST:
669 case LFUN_INDEX_CREATE:
670 code = Inset::INDEX_CODE;
672 case LFUN_INDEX_PRINT:
673 code = Inset::INDEX_PRINT_CODE;
675 case LFUN_CHILD_INSERT:
676 code = Inset::INCLUDE_CODE;
678 case LFUN_TOC_INSERT:
679 code = Inset::TOC_CODE;
681 case LFUN_PARENTINSERT:
682 code = Inset::PARENT_CODE;
686 case LFUN_INSERT_URL:
687 code = Inset::URL_CODE;
690 // always allow this, since we will inset a raw quote
691 // if an inset is not allowed.
693 case LFUN_HYPHENATION:
694 case LFUN_LIGATURE_BREAK:
696 case LFUN_MENU_SEPARATOR:
698 case LFUN_END_OF_SENTENCE:
699 case LFUN_PROTECTEDSPACE:
700 code = Inset::SPECIALCHAR_CODE;
705 if (code != Inset::NO_CODE
706 && owner->view()->theLockingInset()
707 && !owner->view()->theLockingInset()->insetAllowed(code)) {
712 flag |= func_status::Disabled;
714 // the font related functions
715 func_status::value_type box = func_status::ToggleOff;
716 LyXFont const & font =
717 TEXT(false)->real_current_font;
720 if (font.emph() == LyXFont::ON)
721 box = func_status::ToggleOn;
724 if (font.noun() == LyXFont::ON)
725 box = func_status::ToggleOn;
728 if (font.series() == LyXFont::BOLD_SERIES)
729 box = func_status::ToggleOn;
733 if (font.latex() == LyXFont::ON)
734 box = func_status::ToggleOn;
737 case LFUN_READ_ONLY_TOGGLE:
738 if (buf->isReadonly())
739 box = func_status::ToggleOn;
742 box = func_status::OK;
751 // temporary dispatch method
752 void LyXFunc::miniDispatch(string const & s)
760 string const LyXFunc::dispatch(string const & s)
762 // Split command string into command and argument
764 string line = frontStrip(s);
765 string const arg = strip(frontStrip(split(line, cmd, ' ')));
767 return dispatch(lyxaction.LookupFunc(cmd), arg);
771 string const LyXFunc::dispatch(int ac,
772 string const & do_not_use_this_arg)
774 lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << ac
775 <<"] arg[" << do_not_use_this_arg << "]" << endl;
780 // we have not done anything wrong yet.
782 dispatch_buffer.erase();
784 // if action is a pseudo-action, we need the real action
785 if (lyxaction.isPseudoAction(ac)) {
787 action = static_cast<kb_action>
788 (lyxaction.retrieveActionArg(ac, tmparg));
792 action = static_cast<kb_action>(ac);
793 if (!do_not_use_this_arg.empty())
794 argument = do_not_use_this_arg; // except here
797 #ifdef NEW_DISPATCHER
798 // We try do call the most specific dispatcher first:
799 // 1. the lockinginset's dispatch
800 // 2. the bufferview's dispatch
801 // 3. the lyxview's dispatch
804 selection_possible = false;
806 if (owner->view()->available())
807 owner->view()->hideCursor();
809 // We cannot use this function here
810 if (getStatus(ac, do_not_use_this_arg) & func_status::Disabled) {
811 lyxerr << "LyXFunc::Dispatch: "
812 << lyxaction.getActionName(ac)
813 << " [" << ac << "] is disabled ad this location"
815 goto exit_with_message;
818 if (owner->view()->available() && owner->view()->theLockingInset()) {
819 UpdatableInset::RESULT result;
820 if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
821 (keyseq.length >= -1)))
823 if ((action==LFUN_UNKNOWN_ACTION) && argument.empty()){
824 argument = keyseq.getiso();
826 // Undo/Redo is a bit tricky for insets.
827 if (action == LFUN_UNDO) {
828 #ifdef RETHINK_THIS_FOR_NOW_WE_LEAVE_ALL_UNLOCKED
831 UpdatableInset * inset =
832 owner->view()->theLockingInset()->getLockingInset();
833 int inset_id = inset->id();
834 inset->getCursorPos(owner->view(), slx, sly);
835 owner->view()->unlockInset(inset);
837 owner->view()->unlockInset(owner->view()->theLockingInset());
839 owner->view()->menuUndo();
840 #ifdef RETHINK_THIS_FOR_NOW_WE_LEAVE_ALL_UNLOCKED
842 if (TEXT()->cursor.par()->
843 isInset(TEXT()->cursor.pos())) {
844 inset = static_cast<UpdatableInset*>(
845 TEXT()->cursor.par()->
852 inset = static_cast<UpdatableInset *>(owner->view()->buffer()->getInsetFromID(inset_id));
855 inset->edit(owner->view(),slx,sly,0);
858 } else if (action == LFUN_REDO) {
861 UpdatableInset * inset = owner->view()->
863 inset->getCursorPos(owner->view(), slx, sly);
864 owner->view()->unlockInset(inset);
865 owner->view()->menuRedo();
866 inset = static_cast<UpdatableInset*>(
867 TEXT()->cursor.par()->
871 inset->edit(owner->view(),slx,sly,0);
873 } else if (((result=owner->view()->theLockingInset()->
874 localDispatch(owner->view(), action,
876 UpdatableInset::DISPATCHED) ||
877 (result == UpdatableInset::DISPATCHED_NOUPDATE))
880 //setMessage(N_("Text mode"));
882 case LFUN_UNKNOWN_ACTION:
883 case LFUN_BREAKPARAGRAPH:
885 TEXT()->cursorRight(owner->view());
886 owner->view()->setState();
890 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
891 TEXT()->cursorRight(owner->view());
892 moveCursorUpdate(true, false);
897 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
898 TEXT()->cursorRight(owner->view());
899 moveCursorUpdate(true, false);
904 if (TEXT()->cursor.row()->next())
905 TEXT()->cursorDown(owner->view());
907 TEXT()->cursorRight(owner->view());
908 moveCursorUpdate(true, false);
918 lyx::Assert(action != LFUN_SELECT_FILE_SYNC);
924 if (!owner->view()->available()) break;
926 // this function should be used always [asierra060396]
927 UpdatableInset * tli =
928 owner->view()->theLockingInset();
930 UpdatableInset * lock = tli->getLockingInset();
933 owner->view()->unlockInset(tli);
934 TEXT()->cursorRight(owner->view());
935 moveCursorUpdate(true, false);
938 tli->unlockInsetInInset(owner->view(),
946 // --- Misc -------------------------------------------
947 case LFUN_WORDFINDFORWARD :
948 case LFUN_WORDFINDBACKWARD : {
949 static string last_search;
950 string searched_string;
952 if (!argument.empty()) {
953 last_search = argument;
954 searched_string = argument;
956 searched_string = last_search;
958 bool fw = (action == LFUN_WORDFINDBACKWARD);
959 if (!searched_string.empty()) {
960 LyXFind(owner->view(), searched_string, fw);
962 // owner->view()->showCursor();
968 if (owner->view()->available() && !owner->view()->theLockingInset()) {
969 owner->view()->update(TEXT(),
970 BufferView::SELECT|BufferView::FITCUR);
973 keyseq.print(buf, true);
978 // --- Misc -------------------------------------------
979 case LFUN_EXEC_COMMAND:
981 std::vector<string> allCmds;
982 std::transform(lyxaction.func_begin(), lyxaction.func_end(),
983 std::back_inserter(allCmds), lyx::firster());
984 static std::vector<string> hist;
985 owner->getMiniBuffer()->getString(MiniBuffer::spaces,
990 case LFUN_CANCEL: // RVDK_PATCH_5
993 if (owner->view()->available())
994 // cancel any selection
995 dispatch(LFUN_MARK_OFF);
996 setMessage(N_("Cancel"));
999 case LFUN_META_FAKE: // RVDK_PATCH_5
1001 meta_fake_bit = Mod1Mask;
1003 keyseq.print(buf, true);
1004 setMessage(buf); // RVDK_PATCH_5
1008 case LFUN_READ_ONLY_TOGGLE:
1009 if (owner->buffer()->lyxvc.inUse()) {
1010 owner->buffer()->lyxvc.toggleReadOnly();
1012 owner->buffer()->setReadonly(
1013 !owner->buffer()->isReadonly());
1017 case LFUN_CENTER: // this is center and redraw.
1018 owner->view()->center();
1021 // --- Menus -----------------------------------------------
1026 case LFUN_MENUNEWTMPLT:
1030 case LFUN_CLOSEBUFFER:
1034 case LFUN_MENUWRITE:
1035 if (!owner->buffer()->isUnnamed()) {
1037 s1 << _("Saving document") << ' '
1038 << MakeDisplayPath(owner->buffer()->fileName() + "...");
1039 owner->message(s1.str().c_str());
1040 MenuWrite(owner->view(), owner->buffer());
1042 WriteAs(owner->view(), owner->buffer());
1046 WriteAs(owner->view(), owner->buffer(), argument);
1049 case LFUN_MENURELOAD:
1054 Exporter::Export(owner->buffer(), argument, true);
1058 Exporter::Preview(owner->buffer(), argument);
1061 case LFUN_BUILDPROG:
1062 Exporter::Export(owner->buffer(), "program", true);
1065 case LFUN_RUNCHKTEX:
1066 MenuRunChktex(owner->buffer());
1069 case LFUN_MENUPRINT:
1070 owner->getDialogs()->showPrint();
1074 if (argument == "custom")
1077 Exporter::Export(owner->buffer(), argument, false);
1095 InsetCommandParams p;
1098 if (action == LFUN_TOCVIEW)
1100 p.setCmdName("tableofcontents");
1102 else if (action == LFUN_LOAVIEW )
1103 p.setCmdName("listof{algorithm}{List of Algorithms}");
1104 else if (action == LFUN_LOFVIEW)
1105 p.setCmdName("listoffigures");
1107 p.setCmdName("listoftables");
1109 owner->getDialogs()->createTOC(p.getAsString());
1113 case LFUN_DIALOG_TABULAR_INSERT:
1114 owner->getDialogs()->showTabularCreate();
1122 AutoSave(owner->view());
1126 owner->view()->menuUndo();
1130 owner->view()->menuRedo();
1133 case LFUN_MENUSEARCH:
1134 owner->getDialogs()->showSearch();
1137 case LFUN_REMOVEERRORS:
1138 if (owner->view()->removeAutoInsets()) {
1139 owner->view()->redraw();
1140 owner->view()->fitCursor(TEXT());
1145 changeDepth(owner->view(), TEXT(false), 0);
1148 case LFUN_DEPTH_MIN:
1149 changeDepth(owner->view(), TEXT(false), -1);
1152 case LFUN_DEPTH_PLUS:
1153 changeDepth(owner->view(), TEXT(false), 1);
1157 owner->getDialogs()->setUserFreeFont();
1163 owner->view()->setState();
1168 case LFUN_RECONFIGURE:
1169 Reconfigure(owner->view());
1173 case LFUN_FLOATSOPERATE:
1174 if (argument == "openfoot")
1175 owner->view()->allFloats(1,0);
1176 else if (argument == "closefoot")
1177 owner->view()->allFloats(0,0);
1178 else if (argument == "openfig")
1179 owner->view()->allFloats(1,1);
1180 else if (argument == "closefig")
1181 owner->view()->allFloats(0,1);
1184 #ifdef WITH_WARNINGS
1185 #warning Find another implementation here (or another lyxfunc)!
1188 case LFUN_HELP_ABOUTLYX:
1189 owner->getDialogs()->showAboutlyx();
1192 case LFUN_HELP_COPYRIGHT:
1193 case LFUN_HELP_CREDITS:
1196 case LFUN_HELP_OPEN:
1198 string const arg = argument;
1200 setErrorMessage(N_("Missing argument"));
1203 owner->prohibitInput();
1204 string const fname = i18nLibFileSearch("doc", arg, "lyx");
1205 if (fname.empty()) {
1206 lyxerr << "LyX: unable to find documentation file `"
1207 << arg << "'. Bad installation?" << endl;
1208 owner->allowInput();
1212 str << _("Opening help file") << ' '
1213 << MakeDisplayPath(fname) << "...";
1214 owner->message(str.str().c_str());
1215 owner->view()->buffer(bufferlist.loadLyXFile(fname, false));
1216 owner->allowInput();
1220 case LFUN_HELP_VERSION:
1222 // --- version control -------------------------------
1223 case LFUN_VC_REGISTER:
1225 if (!owner->buffer()->lyxvc.inUse())
1226 owner->buffer()->lyxvc.registrer();
1230 case LFUN_VC_CHECKIN:
1232 if (owner->buffer()->lyxvc.inUse()
1233 && !owner->buffer()->isReadonly())
1234 owner->buffer()->lyxvc.checkIn();
1238 case LFUN_VC_CHECKOUT:
1240 if (owner->buffer()->lyxvc.inUse()
1241 && owner->buffer()->isReadonly())
1242 owner->buffer()->lyxvc.checkOut();
1246 case LFUN_VC_REVERT:
1248 owner->buffer()->lyxvc.revert();
1254 owner->buffer()->lyxvc.undoLast();
1258 case LFUN_VC_HISTORY:
1260 owner->getDialogs()->showVCLogFile();
1264 // --- buffers ----------------------------------------
1266 case LFUN_SWITCHBUFFER:
1267 owner->view()->buffer(bufferlist.getBuffer(argument));
1272 // servercmd: argument must be <file>:<template>
1273 Buffer * tmpbuf = NewLyxFile(argument);
1275 owner->view()->buffer(tmpbuf);
1279 case LFUN_FILE_OPEN:
1283 case LFUN_LATEX_LOG:
1284 owner->getDialogs()->showLogFile();
1289 lyxerr[Debug::INFO] << "LFUN_LAYOUTNO: (arg) " << argument << endl;
1290 int sel = strToInt(argument);
1291 lyxerr[Debug::INFO] << "LFUN_LAYOUTNO: (sel) "<< sel << endl;
1293 // Should this give a setMessage instead?
1295 return string(); // illegal argument
1297 --sel; // sel 1..., but layout 0...
1299 // Pretend we got the name instead.
1300 dispatch(int(LFUN_LAYOUT),
1301 textclasslist.NameOfLayout(owner->view()
1302 ->buffer()->params.textclass,
1307 case LFUN_LAYOUT_DOCUMENT:
1308 owner->getDialogs()->showDocument();
1311 case LFUN_LAYOUT_PARAGRAPH:
1312 owner->getDialogs()->showParagraph();
1315 case LFUN_LAYOUT_CHARACTER:
1316 owner->getDialogs()->showCharacter();
1319 case LFUN_LAYOUT_TABULAR:
1320 if (owner->view()->theLockingInset()) {
1321 if (owner->view()->theLockingInset()->lyxCode()==Inset::TABULAR_CODE) {
1322 InsetTabular * inset = static_cast<InsetTabular *>
1323 (owner->view()->theLockingInset());
1324 inset->openLayoutDialog(owner->view());
1325 } else if (owner->view()->theLockingInset()->
1326 getFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
1327 InsetTabular * inset = static_cast<InsetTabular *>(
1328 owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
1329 inset->openLayoutDialog(owner->view());
1334 case LFUN_LAYOUT_PREAMBLE:
1335 owner->getDialogs()->showPreamble();
1338 case LFUN_LAYOUT_SAVE_DEFAULT:
1339 MenuLayoutSave(owner->view());
1342 case LFUN_DROP_LAYOUTS_CHOICE:
1343 owner->getToolbar()->openLayoutList();
1346 case LFUN_MENU_OPEN_BY_NAME:
1347 owner->getMenubar()->openByName(argument);
1348 break; // RVDK_PATCH_5
1350 case LFUN_SPELLCHECK:
1351 if (lyxrc.isp_command != "none")
1352 owner->getDialogs()->showSpellchecker();
1355 // --- lyxserver commands ----------------------------
1359 setMessage(owner->buffer()->fileName());
1360 lyxerr[Debug::INFO] << "FNAME["
1361 << owner->buffer()->fileName()
1369 dispatch_buffer = buf;
1370 lyxserver->notifyClient(dispatch_buffer);
1374 case LFUN_GOTOFILEROW:
1377 char file_name[100];
1379 ::sscanf(argument.c_str(), " %s %d", file_name, &row);
1383 istringstream istr(argument.c_str());
1384 istr >> file_name >> row;
1386 // Must replace extension of the file to be .lyx and get full path
1387 string const s(ChangeExtension(file_name, ".lyx"));
1389 // Either change buffer or load the file
1390 if (bufferlist.exists(s)) {
1391 owner->view()->buffer(bufferlist.getBuffer(s));
1393 owner->view()->buffer(bufferlist.loadLyXFile(s));
1397 owner->view()->setCursorFromRow(row);
1400 owner->view()->center();
1404 case LFUN_GOTO_PARAGRAPH:
1406 istringstream istr(argument.c_str());
1410 Paragraph * par = owner->buffer()->getParFromID(id);
1412 lyxerr[Debug::INFO] << "No matching paragraph found! ["
1413 << id << "]" << std::endl;
1418 TEXT()->setCursor(owner->view(), par, 0);
1419 owner->view()->setState();
1423 owner->view()->center();
1430 int const qa = lyxaction.LookupFunc(argument);
1431 setMessage(lyxaction.helpText(static_cast<kb_action>(qa)));
1435 // --- toolbar ----------------------------------
1436 case LFUN_PUSH_TOOLBAR:
1438 int nth = strToInt(argument);
1440 setErrorMessage(N_("Push-toolbar needs argument > 0"));
1442 owner->getToolbar()->push(nth);
1447 case LFUN_ADD_TO_TOOLBAR:
1449 if (lyxerr.debugging(Debug::GUI)) {
1450 lyxerr << "LFUN_ADD_TO_TOOLBAR:"
1451 "argument = `" << argument << '\'' << endl;
1453 string tmp(argument);
1454 //lyxerr <<string("Argument: ") + argument);
1455 //lyxerr <<string("Tmp : ") + tmp);
1457 setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
1459 owner->getToolbar()->add(argument, false);
1460 owner->getToolbar()->set();
1465 // --- insert characters ----------------------------------------
1467 // --- Mathed stuff. If we are here, there is no locked inset yet.
1472 if (!greek_kb_flag) {
1474 setMessage(N_("Math greek mode on"));
1481 case LFUN_GREEK_TOGGLE:
1483 greek_kb_flag = greek_kb_flag ? 0 : 2;
1484 if (greek_kb_flag) {
1485 setMessage(N_("Math greek keyboard on"));
1487 setMessage(N_("Math greek keyboard off"));
1492 case LFUN_MATH_EXTERN:
1493 case LFUN_MATH_NUMBER:
1494 case LFUN_MATH_NONUMBER:
1495 case LFUN_MATH_LIMITS:
1497 setErrorMessage(N_("This is only allowed in math mode!"));
1501 case LFUN_MATH_PANEL:
1502 owner->getDialogs()->showMathPanel();
1505 case LFUN_CITATION_CREATE:
1507 InsetCommandParams p( "cite" );
1509 if (!argument.empty()) {
1510 // This should be set at source, ie when typing
1511 // "citation-insert foo" in the minibuffer.
1512 // Question: would pybibliographer also need to be
1513 // changed. Suspect so. Leave as-is therefore.
1514 if (contains(argument, "|")) {
1515 p.setContents( token(argument, '|', 0) );
1516 p.setOptions( token(argument, '|', 1) );
1518 p.setContents( argument );
1520 dispatch(LFUN_CITATION_INSERT, p.getAsString());
1522 owner->getDialogs()->createCitation( p.getAsString() );
1526 case LFUN_CHILDOPEN:
1528 string const filename =
1529 MakeAbsPath(argument,
1530 OnlyPath(owner->buffer()->fileName()));
1531 setMessage(N_("Opening child document ") +
1532 MakeDisplayPath(filename) + "...");
1533 owner->view()->savePosition(0);
1534 if (bufferlist.exists(filename))
1535 owner->view()->buffer(bufferlist.getBuffer(filename));
1537 owner->view()->buffer(bufferlist.loadLyXFile(filename));
1541 case LFUN_TOGGLECURSORFOLLOW:
1542 lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
1545 case LFUN_KMAP_OFF: // keymap off
1546 owner->getIntl()->KeyMapOn(false);
1549 case LFUN_KMAP_PRIM: // primary keymap
1550 owner->getIntl()->KeyMapPrim();
1553 case LFUN_KMAP_SEC: // secondary keymap
1554 owner->getIntl()->KeyMapSec();
1557 case LFUN_KMAP_TOGGLE: // toggle keymap
1558 owner->getIntl()->ToggleKeyMap();
1563 // argument contains ';'-terminated commands
1564 while (argument.find(';') != string::npos) {
1566 argument = split(argument, first, ';');
1572 case LFUN_DIALOG_PREFERENCES:
1573 owner->getDialogs()->showPreferences();
1576 case LFUN_SAVEPREFERENCES:
1578 Path p(user_lyxdir);
1579 lyxrc.write("preferences");
1583 case LFUN_SCREEN_FONT_UPDATE:
1585 // handle the screen font changes.
1587 lyxrc.set_font_norm_type();
1588 fontloader.update();
1589 // Of course we should only do the resize and the textcache.clear
1590 // if values really changed...but not very important right now. (Lgb)
1591 // All visible buffers will need resize
1593 // We also need to empty the textcache so that
1594 // the buffer will be formatted correctly after
1600 case LFUN_SET_COLOR:
1603 string const x11_name = split(argument, lyx_name, ' ');
1604 if (lyx_name.empty() || x11_name.empty()) {
1605 setErrorMessage(N_("Syntax: set-color <lyx_name>"
1610 if (!lcolor.setColor(lyx_name, x11_name)) {
1611 static string const err1 (N_("Set-color \""));
1612 static string const err2 (
1613 N_("\" failed - color is undefined "
1614 "or may not be redefined"));
1615 setErrorMessage(_(err1) + lyx_name + _(err2));
1618 lyxColorHandler->updateColor(lcolor.getFromLyXName(lyx_name));
1619 owner->view()->redraw();
1624 owner->message(argument);
1627 case LFUN_MESSAGE_PUSH:
1628 owner->messagePush(argument);
1631 case LFUN_MESSAGE_POP:
1632 owner->messagePop();
1636 // Then if it was none of the above
1637 if (!owner->view()->Dispatch(action, argument))
1638 lyxerr << "A truly unknown func ["
1639 << lyxaction.getActionName(action) << "]!"
1646 commandshortcut.erase();
1648 if (lyxrc.display_shortcuts && show_sc) {
1649 if (action != LFUN_SELFINSERT) {
1650 // Put name of command and list of shortcuts
1651 // for it in minibuffer
1652 string comname = lyxaction.getActionName(action);
1654 int pseudoaction = action;
1655 bool argsadded = false;
1657 if (!argument.empty()) {
1658 // If we have the command with argument,
1661 lyxaction.searchActionArg(action,
1664 if (pseudoaction == -1) {
1665 pseudoaction = action;
1667 comname += " " + argument;
1672 string const shortcuts =
1673 toplevel_keymap->findbinding(pseudoaction);
1675 if (!shortcuts.empty()) {
1676 comname += ": " + shortcuts;
1677 } else if (!argsadded) {
1678 comname += " " + argument;
1681 if (!comname.empty()) {
1682 comname = strip(comname);
1683 commandshortcut = "(" + comname + ')';
1685 // Here we could even add a small pause,
1686 // to annoy the user and make him learn
1688 // No! That will just annoy, not teach
1689 // anything. The user will read the messages
1690 // if they are interested. (Asger)
1695 string const res = getMessage();
1698 if (!commandshortcut.empty()) {
1699 owner->getMiniBuffer()->addSet(commandshortcut);
1702 string const msg(_(res) + ' ' + commandshortcut);
1703 owner->message(msg);
1710 void LyXFunc::setupLocalKeymap()
1712 keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
1713 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap.get();
1717 void LyXFunc::menuNew(bool fromTemplate)
1719 string initpath = lyxrc.document_path;
1721 if (owner->view()->available()) {
1722 string const trypath = owner->buffer()->filepath;
1723 // If directory is writeable, use this as default.
1724 if (IsDirWriteable(trypath) == 1)
1728 static int newfile_number;
1731 if (lyxrc.new_ask_filename) {
1732 FileDialog fileDlg(owner, _("Enter filename for new document"),
1733 LFUN_SELECT_FILE_SYNC,
1734 make_pair(string(_("Documents")),
1735 string(lyxrc.document_path)),
1736 make_pair(string(_("Templates")),
1737 string(lyxrc.template_path)));
1739 FileDialog::Result result =
1740 fileDlg.Select(initpath,
1741 _("*.lyx|LyX Documents (*.lyx)"),
1744 if (result.second.empty()) {
1745 owner->message(_("Canceled."));
1746 lyxerr[Debug::INFO] << "New Document Cancelled." << endl;
1750 // get absolute path of file and make sure the filename ends
1752 s = MakeAbsPath(result.second);
1753 if (!IsLyXFilename(s))
1756 // Check if the document already is open
1757 if (bufferlist.exists(s)) {
1758 switch (AskConfirmation(_("Document is already open:"),
1759 MakeDisplayPath(s, 50),
1760 _("Do you want to close that document now?\n"
1761 "('No' will just switch to the open version)")))
1763 case 1: // Yes: close the document
1764 if (!bufferlist.close(bufferlist.getBuffer(s)))
1765 // If close is canceled, we cancel here too.
1768 case 2: // No: switch to the open document
1769 owner->view()->buffer(bufferlist.getBuffer(s));
1771 case 3: // Cancel: Do nothing
1772 owner->message(_("Canceled."));
1776 // Check whether the file already exists
1778 if (fi.readable() &&
1779 AskQuestion(_("File already exists:"),
1780 MakeDisplayPath(s, 50),
1781 _("Do you want to open the document?"))) {
1783 string const disp_fn(MakeDisplayPath(s));
1786 str << _("Opening document") << ' '
1787 << disp_fn << "...";
1789 owner->message(str.str().c_str());
1790 //XFlush(fl_get_display());
1791 owner->view()->buffer(bufferlist.loadLyXFile(s));
1793 str2 << _("Document") << ' '
1794 << disp_fn << ' ' << _("opened.");
1796 owner->message(str2.str().c_str());
1801 s = AddName(lyxrc.document_path,
1802 "newfile" + tostr(++newfile_number) + ".lyx");
1804 while (bufferlist.exists(s) || fi.readable()) {
1806 s = AddName(lyxrc.document_path,
1807 "newfile" + tostr(newfile_number) +
1813 // The template stuff
1816 FileDialog fileDlg(owner, _("Select template file"),
1817 LFUN_SELECT_FILE_SYNC,
1818 make_pair(string(_("Documents")),
1819 string(lyxrc.document_path)),
1820 make_pair(string(_("Templates")),
1821 string(lyxrc.template_path)));
1823 FileDialog::Result result =
1824 fileDlg.Select(lyxrc.template_path,
1825 _("*.lyx|LyX Documents (*.lyx)"));
1827 if (result.first == FileDialog::Later)
1830 string const fname = result.second;
1837 // find a free buffer
1838 lyxerr[Debug::INFO] << "Find a free buffer." << endl;
1839 owner->view()->buffer(bufferlist.newFile(s, templname));
1843 void LyXFunc::open(string const & fname)
1845 string initpath = lyxrc.document_path;
1847 if (owner->view()->available()) {
1848 string const trypath = owner->buffer()->filepath;
1849 // If directory is writeable, use this as default.
1850 if (IsDirWriteable(trypath) == 1)
1856 if (fname.empty()) {
1857 FileDialog fileDlg(owner, _("Select document to open"),
1859 make_pair(string(_("Documents")),
1860 string(lyxrc.document_path)),
1861 make_pair(string(_("Examples")),
1862 string(AddPath(system_lyxdir, "examples"))));
1864 FileDialog::Result result =
1865 fileDlg.Select(initpath,
1866 "*.lyx|LyX Documents (*.lyx)");
1868 if (result.first == FileDialog::Later)
1871 filename = result.second;
1873 // check selected filename
1874 if (filename.empty()) {
1875 owner->message(_("Canceled."));
1881 // get absolute path of file and add ".lyx" to the filename if
1883 filename = FileSearch(string(), filename, "lyx");
1886 string const disp_fn(MakeDisplayPath(filename));
1889 str << _("Opening document") << ' ' << disp_fn << "...";
1891 owner->message(str.str().c_str());
1893 Buffer * openbuf = bufferlist.loadLyXFile(filename);
1895 owner->view()->buffer(openbuf);
1897 str << _("Document") << ' ' << disp_fn << ' ' << _("opened.");
1898 owner->message(str.str().c_str());
1901 str << _("Could not open docuent") << ' ' << disp_fn;
1902 owner->message(str.str().c_str());
1907 // checks for running without gui are missing.
1908 void LyXFunc::doImport(string const & argument)
1911 string filename = split(argument, format, ' ');
1912 lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format
1913 << " file: " << filename << endl;
1915 if (filename.empty()) { // need user interaction
1916 string initpath = lyxrc.document_path;
1918 if (owner->view()->available()) {
1919 string const trypath = owner->buffer()->filepath;
1920 // If directory is writeable, use this as default.
1921 if (IsDirWriteable(trypath) == 1)
1925 string const text = _("Select ") + formats.PrettyName(format)
1926 + _(" file to import");
1928 FileDialog fileDlg(owner, text,
1930 make_pair(string(_("Documents")),
1931 string(lyxrc.document_path)),
1932 make_pair(string(_("Examples")),
1933 string(AddPath(system_lyxdir, "examples"))));
1935 string const extension = "*." + formats.Extension(format)
1936 + "| " + formats.PrettyName(format)
1937 + " (*." + formats.Extension(format) + ")";
1939 FileDialog::Result result = fileDlg.Select(initpath,
1942 if (result.first == FileDialog::Later)
1945 filename = result.second;
1947 // check selected filename
1948 if (filename.empty())
1949 owner->message(_("Canceled."));
1952 // still no filename? abort
1953 if (filename.empty())
1956 // get absolute path of file
1957 filename = MakeAbsPath(filename);
1959 string const lyxfile = ChangeExtension(filename, ".lyx");
1961 // Check if the document already is open
1962 if (bufferlist.exists(lyxfile)) {
1963 switch (AskConfirmation(_("Document is already open:"),
1964 MakeDisplayPath(lyxfile, 50),
1965 _("Do you want to close that document now?\n"
1966 "('No' will just switch to the open version)")))
1968 case 1: // Yes: close the document
1969 if (!bufferlist.close(bufferlist.getBuffer(lyxfile)))
1970 // If close is canceled, we cancel here too.
1973 case 2: // No: switch to the open document
1974 owner->view()->buffer(bufferlist.getBuffer(lyxfile));
1976 case 3: // Cancel: Do nothing
1977 owner->message(_("Canceled."));
1982 // Check if a LyX document by the same root exists in filesystem
1983 FileInfo const f(lyxfile, true);
1984 if (f.exist() && !AskQuestion(_("A document by the name"),
1985 MakeDisplayPath(lyxfile),
1986 _("already exists. Overwrite?"))) {
1987 owner->message(_("Canceled"));
1990 // filename should be valid now
1992 Importer::Import(owner, filename, format);
1996 void LyXFunc::reloadBuffer()
1998 string const fn = owner->buffer()->fileName();
1999 if (bufferlist.close(owner->buffer()))
2000 owner->view()->buffer(bufferlist.loadLyXFile(fn));
2004 void LyXFunc::closeBuffer()
2006 if (bufferlist.close(owner->buffer()) && !quitting) {
2007 if (bufferlist.empty()) {
2008 // need this otherwise SEGV may occur while trying to
2009 // set variables that don't exist
2010 // since there's no current buffer
2011 owner->getDialogs()->hideBufferDependent();
2013 owner->view()->buffer(bufferlist.first());
2019 // Each "owner" should have it's own message method. lyxview and
2020 // the minibuffer would use the minibuffer, but lyxserver would
2021 // send an ERROR signal to its client. Alejandro 970603
2022 // This func is bit problematic when it comes to NLS, to make the
2023 // lyx servers client be language indepenent we must not translate
2024 // strings sent to this func.
2025 void LyXFunc::setErrorMessage(string const & m) const
2027 dispatch_buffer = m;
2032 void LyXFunc::setMessage(string const & m)
2034 dispatch_buffer = m;
2038 void LyXFunc::initMiniBuffer()
2040 string text = _("Welcome to LyX!");
2042 // When meta-fake key is pressed, show the key sequence so far + "M-".
2048 // Else, when a non-complete key sequence is pressed,
2049 // show the available options.
2050 else if (keyseqUncomplete())
2051 text = keyseqOptions();
2053 // Else, show the buffer state.
2054 else if (owner->view()->available()) {
2055 Buffer * tmpbuf = owner->buffer();
2057 string const nicename =
2058 MakeDisplayPath(tmpbuf->fileName());
2059 // Should we do this instead? (kindo like emacs)
2060 // leaves more room for other information
2063 if (tmpbuf->lyxvc.inUse()) {
2065 text += tmpbuf->lyxvc.version();
2067 text += tmpbuf->lyxvc.locker();
2068 if (tmpbuf->isReadonly())
2071 } else if (tmpbuf->isReadonly())
2073 if (!tmpbuf->isLyxClean())
2074 text += _(" (Changed)");
2076 if (text != _("Welcome to LyX!")) // this is a hack
2077 text = _("* No document open *");
2080 owner->message(text);