1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2001 The LyX Team.
9 * ====================================================== */
14 #pragma implementation
21 #include "bufferlist.h"
22 #include "BufferView.h"
23 #include "ColorHandler.h"
24 #include "lyxserver.h"
28 #include "LyXAction.h"
34 #include "trans_mgr.h"
37 #include "bufferview_funcs.h"
38 #include "minibuffer.h"
41 #include "lyx_gui_misc.h"
42 #include "FloatList.h"
43 #include "converter.h"
46 #include "FontLoader.h"
47 #include "TextCache.h"
49 #include "undo_funcs.h"
50 #include "ParagraphParameters.h"
51 #include "figureForm.h"
53 #include "insets/inseturl.h"
54 #include "insets/insetlatexaccent.h"
55 #include "insets/insettoc.h"
56 #include "insets/insetref.h"
57 #include "insets/insetparent.h"
58 #include "insets/insetindex.h"
59 #include "insets/insetinclude.h"
60 #include "insets/insetbib.h"
61 #include "insets/insetcite.h"
62 #include "insets/insettext.h"
63 #include "insets/insetert.h"
64 #include "insets/insetexternal.h"
65 #include "insets/insetgraphics.h"
66 #include "insets/insetfoot.h"
67 #include "insets/insetmarginal.h"
68 #include "insets/insetminipage.h"
69 #include "insets/insetfloat.h"
71 #include "insets/insetlist.h"
72 #include "insets/insettheorem.h"
74 #include "insets/insettabular.h"
75 #include "insets/insetcaption.h"
77 #include "mathed/formulamacro.h"
78 #include "mathed/math_cursor.h"
79 #include "mathed/math_inset.h"
81 #include "frontends/FileDialog.h"
82 #include "frontends/Dialogs.h"
83 #include "frontends/Toolbar.h"
84 #include "frontends/Menubar.h"
85 #include "frontends/Alert.h"
87 #include "support/lyxalgo.h"
88 #include "support/LAssert.h"
89 #include "support/filetools.h"
90 #include "support/FileInfo.h"
91 #include "support/syscall.h"
92 #include "support/lstrings.h"
93 #include "support/path.h"
94 #include "support/lyxfunctional.h"
106 using std::make_pair;
110 extern BufferList bufferlist;
111 extern LyXServer * lyxserver;
112 extern bool selection_possible;
113 extern void MenuSendto();
115 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
117 extern void show_symbols_form(LyXFunc *);
119 extern LyXAction lyxaction;
121 extern tex_accent_struct get_accent(kb_action action);
123 extern void ShowLatexLog();
129 class MiniBufferController : public SigC::Object {
132 MiniBufferController() {
136 &MiniBufferController::receiveCommand));
140 &MiniBufferController::receiveArg));
143 void receiveCmd(string const & cmd) {}
145 void receiveArg(string const & arg) {}
153 MiniBufferController mb_ctrl;
159 /* === globals =========================================================== */
161 // Initialization of static member var
162 bool LyXFunc::show_sc = true;
165 LyXFunc::LyXFunc(LyXView * o)
167 keyseq(toplevel_keymap.get(), toplevel_keymap.get()),
168 cancel_meta_seq(toplevel_keymap.get(), toplevel_keymap.get())
171 lyx_dead_action = LFUN_NOACTION;
172 lyx_calling_dead_action = LFUN_NOACTION;
177 LyXText * LyXFunc::TEXT(bool flag = true) const
180 return owner->view()->text;
181 return owner->view()->getLyXText();
185 // I changed this func slightly. I commented out the ...FinishUndo(),
186 // this means that all places that used to have a moveCursorUpdate, now
187 // have a ...FinishUndo() as the preceeding statement. I have also added
188 // a moveCursorUpdate to some of the functions that updated the cursor, but
189 // that did not show its new position.
191 void LyXFunc::moveCursorUpdate(bool flag, bool selecting)
193 if (selecting || TEXT(flag)->selection.mark()) {
194 TEXT(flag)->setSelection(owner->view());
195 if (TEXT(flag)->bv_owner)
196 owner->view()->toggleToggle();
198 owner->view()->update(TEXT(flag), BufferView::SELECT|BufferView::FITCUR);
199 owner->view()->showCursor();
201 /* ---> Everytime the cursor is moved, show the current font state. */
202 // should this too me moved out of this func?
203 owner->view()->setState();
207 void LyXFunc::handleKeyFunc(kb_action action)
209 char c = keyseq.getiso();
211 if (keyseq.length() > 1) {
215 owner->getIntl()->getTrans()
216 .deadkey(c, get_accent(action).accent, TEXT(false));
217 // Need to clear, in case the minibuffer calls these
220 // copied verbatim from do_accent_char
221 owner->view()->update(TEXT(false),
222 BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
223 TEXT(false)->selection.cursor = TEXT(false)->cursor;
227 void LyXFunc::processKeySym(KeySym keysym, unsigned int state)
231 if (lyxerr.debugging(Debug::KEY)) {
232 char const * tmp = XKeysymToString(keysym);
233 string const stm = (tmp ? tmp : "");
234 lyxerr << "KeySym is "
237 << keysym << "] State is ["
241 // Do nothing if we have nothing (JMarc)
242 if (keysym == NoSymbol) {
243 lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
248 // Can we be sure that this will work for all X Window
249 // implementations? (Lgb)
250 // This code snippet makes lyx ignore some keys. Perhaps
251 // all of them should be explictly mentioned?
252 if ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
253 || keysym == XK_Mode_switch || keysym == 0x0) {
257 // Do a one-deep top-level lookup for
258 // cancel and meta-fake keys. RVDK_PATCH_5
259 cancel_meta_seq.reset();
261 int action = cancel_meta_seq.addkey(keysym, state
262 &(ShiftMask|ControlMask
264 if (lyxerr.debugging(Debug::KEY)) {
265 lyxerr << "action first set to [" << action << "]" << endl;
268 // When not cancel or meta-fake, do the normal lookup.
269 // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
270 // Mostly, meta_fake_bit = 0. RVDK_PATCH_5.
271 if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
272 if (lyxerr.debugging(Debug::KEY)) {
273 lyxerr << "meta_fake_bit is ["
274 << meta_fake_bit << "]" << endl;
276 // remove Caps Lock and Mod2 as a modifiers
277 action = keyseq.addkey(keysym,
278 (state | meta_fake_bit)
279 &(ShiftMask|ControlMask
281 if (lyxerr.debugging(Debug::KEY)) {
282 lyxerr << "action now set to ["
283 << action << "]" << endl;
286 // Dont remove this unless you know what you are doing.
289 // can this happen now ?
290 if (action == LFUN_NOACTION) {
291 action = LFUN_PREFIX;
294 if (lyxerr.debugging(Debug::KEY)) {
295 lyxerr << "Key [action="
297 << keyseq.print() << "]"
301 // already here we know if it any point in going further
302 // why not return already here if action == -1 and
303 // num_bytes == 0? (Lgb)
305 if (keyseq.length() > 1 && !keyseq.deleted()) {
306 owner->message(keyseq.print());
309 if (action == LFUN_UNKNOWN_ACTION) {
310 // It is unknown, but what if we remove all
311 // the modifiers? (Lgb)
312 action = keyseq.addkey(keysym, 0);
314 if (lyxerr.debugging(Debug::KEY)) {
315 lyxerr << "Removing modifiers...\n"
316 << "Action now set to ["
317 << action << "]" << endl;
319 if (action == LFUN_UNKNOWN_ACTION) {
320 owner->message(_("Unknown function."));
325 if (action == LFUN_SELFINSERT) {
326 // This is very X dependent.
327 unsigned int c = keysym;
329 c = kb_keymap::getiso(c);
332 argument = static_cast<char>(c);
333 lyxerr[Debug::KEY] << "SelfInsert arg[`"
334 << argument << "']" << endl;
337 bool tmp_sc = show_sc;
339 dispatch(action, argument);
346 func_status::value_type LyXFunc::getStatus(int ac) const
348 return getStatus(ac, string());
351 func_status::value_type LyXFunc::getStatus(int ac,
352 string const & not_to_use_arg) const
355 func_status::value_type flag = func_status::OK;
357 Buffer * buf = owner->buffer();
359 if (lyxaction.isPseudoAction(ac))
360 action = lyxaction.retrieveActionArg(ac, argument);
362 action = static_cast<kb_action>(ac);
363 if (!not_to_use_arg.empty())
364 argument = not_to_use_arg; // exept here
367 if (action == LFUN_UNKNOWN_ACTION) {
368 setErrorMessage(N_("Unknown action"));
369 return func_status::Unknown;
372 // Check whether we need a buffer
373 if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) {
374 // Yes we need a buffer, do we have one?
377 // Can we use a readonly buffer?
378 if (buf->isReadonly() &&
379 !lyxaction.funcHasFlag(action,
380 LyXAction::ReadOnly)) {
382 setErrorMessage(N_("Document is read-only"));
383 flag |= func_status::Disabled;
387 setErrorMessage(N_("Command not allowed with"
388 "out any document open"));
389 flag |= func_status::Disabled;
394 // I would really like to avoid having this switch and rather try to
395 // encode this in the function itself.
396 bool disable = false;
399 disable = !Exporter::IsExportable(buf, "dvi")
400 || lyxrc.print_command == "none";
403 disable = argument == "fax" &&
404 !Exporter::IsExportable(buf, argument);
407 disable = buf->undostack.empty();
410 disable = buf->redostack.empty();
412 case LFUN_SPELLCHECK:
413 disable = lyxrc.isp_command == "none";
415 #ifndef HAVE_LIBAIKSAURUS
416 case LFUN_THESAURUS_ENTRY:
421 disable = lyxrc.chktex_command == "none";
424 disable = !Exporter::IsExportable(buf, "program");
427 case LFUN_LAYOUT_TABULAR:
429 if (owner->view()->theLockingInset()) {
430 disable = (owner->view()->theLockingInset()->lyxCode() != Inset::TABULAR_CODE) &&
431 !owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE);
435 case LFUN_TABULAR_FEATURE:
437 if (owner->view()->theLockingInset()) {
438 func_status::value_type ret = func_status::Disabled;
439 if (owner->view()->theLockingInset()->lyxCode() == Inset::TABULAR_CODE) {
440 ret = static_cast<InsetTabular *>
441 (owner->view()->theLockingInset())->
443 } else if (owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
444 ret = static_cast<InsetTabular *>
445 (owner->view()->theLockingInset()->
446 getFirstLockingInsetOfType(Inset::TABULAR_CODE))->
452 static InsetTabular inset(*owner->buffer(), 1, 1);
453 func_status::value_type ret;
456 ret = inset.getStatus(argument);
457 if ((ret & func_status::ToggleOn) ||
458 (ret & func_status::ToggleOff))
459 flag |= func_status::ToggleOff;
463 case LFUN_VC_REGISTER:
464 disable = buf->lyxvc.inUse();
466 case LFUN_VC_CHECKIN:
467 disable = !buf->lyxvc.inUse() || buf->isReadonly();
469 case LFUN_VC_CHECKOUT:
470 disable = !buf->lyxvc.inUse() || !buf->isReadonly();
474 case LFUN_VC_HISTORY:
475 disable = !buf->lyxvc.inUse();
477 case LFUN_BOOKMARK_GOTO:
478 disable = !owner->view()->
479 isSavedPosition(strToUnsignedInt(argument));
483 case LFUN_INSET_TOGGLE:
484 disable = (TEXT(false)->getInset() == 0);
487 case LFUN_MATH_VALIGN: {
488 // I think this test can be simplified (Andre')
489 // mathcursor is != 0 iff we are in math mode
490 //Inset * tli = owner->view()->theLockingInset();
491 //if (tli && (tli->lyxCode() == Inset::MATH_CODE
492 // || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
495 char align = mathcursor->valign();
500 if (argument.empty()) {
501 flag = func_status::OK;
504 if (!contains("tcb", argument[0])) {
508 func_status::toggle(flag, argument[0] == align);
513 case LFUN_MATH_HALIGN: {
514 //Inset * tli = owner->view()->theLockingInset();
515 //if (tli && (tli->lyxCode() == Inset::MATH_CODE
516 // || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
518 char align = mathcursor->halign();
523 if (argument.empty()) {
524 flag = func_status::OK;
527 if (!contains("lcr", argument[0])) {
531 func_status::toggle(flag, argument[0] == align);
536 case LFUN_MATH_MUTATE: {
537 Inset * tli = owner->view()->theLockingInset();
538 if (tli && (tli->lyxCode() == Inset::MATH_CODE)) {
539 MathInsetTypes type = mathcursor->formula()->getType();
540 if (argument == "inline") {
541 func_status::toggle(flag, type == LM_OT_SIMPLE);
542 } else if (argument == "display") {
543 func_status::toggle(flag, type == LM_OT_EQUATION);
544 } else if (argument == "eqnarray") {
545 func_status::toggle(flag, type == LM_OT_EQNARRAY);
546 } else if (argument == "align") {
547 func_status::toggle(flag, type == LM_OT_ALIGN);
556 // we just need to be in math mode to enable that
558 case LFUN_MATH_SPACE:
559 case LFUN_MATH_LIMITS:
560 case LFUN_MATH_NONUMBER:
561 case LFUN_MATH_NUMBER:
562 disable = !mathcursor;
565 // we need to be math mode and a math array for that
566 // Hack: halign produces non-zero result iff we are in a math array
567 case LFUN_MATH_ROW_INSERT:
568 case LFUN_MATH_ROW_DELETE:
569 case LFUN_MATH_COLUMN_INSERT:
570 case LFUN_MATH_COLUMN_DELETE:
571 disable = !mathcursor || !mathcursor->halign();
578 // the functions which insert insets
579 Inset::Code code = Inset::NO_CODE;
581 case LFUN_INSET_TEXT:
582 code = Inset::TEXT_CODE;
585 code = Inset::ERT_CODE;
588 case LFUN_INSET_GRAPHICS:
589 code = Inset::GRAPHICS_CODE;
591 case LFUN_INSET_FOOTNOTE:
592 code = Inset::FOOT_CODE;
594 case LFUN_DIALOG_TABULAR_INSERT:
595 case LFUN_INSET_TABULAR:
596 code = Inset::TABULAR_CODE;
598 case LFUN_INSET_EXTERNAL:
599 code = Inset::EXTERNAL_CODE;
601 case LFUN_INSET_MARGINAL:
602 code = Inset::MARGIN_CODE;
604 case LFUN_INSET_MINIPAGE:
605 code = Inset::MINIPAGE_CODE;
607 case LFUN_INSET_FLOAT:
608 case LFUN_INSET_WIDE_FLOAT:
609 code = Inset::FLOAT_CODE;
611 case LFUN_FLOAT_LIST:
612 code = Inset::FLOAT_LIST_CODE;
615 case LFUN_INSET_LIST:
616 code = Inset::LIST_CODE;
618 case LFUN_INSET_THEOREM:
619 code = Inset::THEOREM_CODE;
622 case LFUN_INSET_CAPTION:
623 code = Inset::CAPTION_CODE;
625 case LFUN_INSERT_NOTE:
626 code = Inset::IGNORE_CODE;
628 case LFUN_INSERT_LABEL:
629 code = Inset::LABEL_CODE;
631 case LFUN_REF_INSERT:
632 code = Inset::REF_CODE;
634 case LFUN_CITATION_CREATE:
635 case LFUN_CITATION_INSERT:
636 code = Inset::CITE_CODE;
638 case LFUN_INSERT_BIBTEX:
639 code = Inset::BIBTEX_CODE;
641 case LFUN_INDEX_INSERT:
642 case LFUN_INDEX_INSERT_LAST:
643 case LFUN_INDEX_CREATE:
644 code = Inset::INDEX_CODE;
646 case LFUN_INDEX_PRINT:
647 code = Inset::INDEX_PRINT_CODE;
649 case LFUN_CHILD_INSERT:
650 code = Inset::INCLUDE_CODE;
652 case LFUN_TOC_INSERT:
653 code = Inset::TOC_CODE;
655 case LFUN_PARENTINSERT:
656 code = Inset::PARENT_CODE;
660 case LFUN_INSERT_URL:
661 code = Inset::URL_CODE;
664 // always allow this, since we will inset a raw quote
665 // if an inset is not allowed.
667 case LFUN_HYPHENATION:
668 case LFUN_LIGATURE_BREAK:
670 case LFUN_MENU_SEPARATOR:
672 case LFUN_END_OF_SENTENCE:
673 case LFUN_PROTECTEDSPACE:
674 code = Inset::SPECIALCHAR_CODE;
679 if (code != Inset::NO_CODE
680 && owner->view()->theLockingInset()
681 && !owner->view()->theLockingInset()->insetAllowed(code)) {
686 flag |= func_status::Disabled;
688 // A few general toggles
690 case LFUN_READ_ONLY_TOGGLE:
691 func_status::toggle(flag, buf->isReadonly());
694 func_status::toggle(flag, TEXT(false)->cursor.par()->params().startOfAppendix());
700 // the font related toggles
702 LyXFont const & font = TEXT(false)->real_current_font;
705 func_status::toggle(flag, font.emph() == LyXFont::ON);
708 func_status::toggle(flag, font.noun() == LyXFont::ON);
711 func_status::toggle(flag, font.series() == LyXFont::BOLD_SERIES);
714 func_status::toggle(flag, font.family() == LyXFont::SANS_FAMILY);
717 func_status::toggle(flag, font.family() == LyXFont::ROMAN_FAMILY);
720 func_status::toggle(flag, font.family() == LyXFont::TYPEWRITER_FAMILY);
727 MathTextCodes tc = mathcursor->getLastCode();
730 func_status::toggle(flag, tc == LM_TC_BF);
733 func_status::toggle(flag, tc == LM_TC_SF);
736 func_status::toggle(flag, tc == LM_TC_CAL);
739 func_status::toggle(flag, tc == LM_TC_RM);
742 func_status::toggle(flag, tc == LM_TC_TT);
745 func_status::toggle(flag, tc == LM_TC_BB);
748 func_status::toggle(flag, tc == LM_TC_VAR);
759 // temporary dispatch method
760 void LyXFunc::miniDispatch(string const & s)
762 string s2(frontStrip(strip(s)));
770 string const LyXFunc::dispatch(string const & s)
772 // Split command string into command and argument
774 string line = frontStrip(s);
775 string const arg = strip(frontStrip(split(line, cmd, ' ')));
777 int action = lyxaction.LookupFunc(cmd);
779 if (action == LFUN_UNKNOWN_ACTION) {
780 string const msg = string(_("Unknown function ("))
785 return dispatch(action, arg);
790 string const LyXFunc::dispatch(int ac,
791 string const & do_not_use_this_arg)
793 lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << ac
794 <<"] arg[" << do_not_use_this_arg << "]" << endl;
799 // we have not done anything wrong yet.
801 dispatch_buffer.erase();
803 // if action is a pseudo-action, we need the real action
804 if (lyxaction.isPseudoAction(ac)) {
806 action = static_cast<kb_action>
807 (lyxaction.retrieveActionArg(ac, tmparg));
811 action = static_cast<kb_action>(ac);
812 if (!do_not_use_this_arg.empty())
813 argument = do_not_use_this_arg; // except here
817 #ifdef NEW_DISPATCHER
818 // We try do call the most specific dispatcher first:
819 // 1. the lockinginset's dispatch
820 // 2. the bufferview's dispatch
821 // 3. the lyxview's dispatch
824 selection_possible = false;
826 if (owner->view()->available())
827 owner->view()->hideCursor();
829 // We cannot use this function here
830 if (getStatus(ac, do_not_use_this_arg) & func_status::Disabled) {
831 lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: "
832 << lyxaction.getActionName(ac)
833 << " [" << ac << "] is disabled at this location"
835 goto exit_with_message;
838 if (owner->view()->available() && owner->view()->theLockingInset()) {
839 UpdatableInset::RESULT result;
840 if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
841 (!keyseq.deleted())))
843 if ((action==LFUN_UNKNOWN_ACTION) && argument.empty()){
844 argument = keyseq.getiso();
846 // Undo/Redo is a bit tricky for insets.
847 if (action == LFUN_UNDO) {
848 owner->view()->menuUndo();
850 } else if (action == LFUN_REDO) {
851 owner->view()->menuRedo();
853 } else if (((result=owner->view()->theLockingInset()->
854 localDispatch(owner->view(), action, argument)) ==
855 UpdatableInset::DISPATCHED) ||
856 (result == UpdatableInset::DISPATCHED_NOUPDATE))
858 else if (result == UpdatableInset::FINISHED) {
859 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
860 TEXT()->cursorRight(owner->view());
861 moveCursorUpdate(true, false);
865 } else if (result == UpdatableInset::FINISHED_RIGHT) {
866 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
867 TEXT()->cursorRight(owner->view());
868 moveCursorUpdate(true, false);
872 } else if (result == UpdatableInset::FINISHED_UP) {
873 if (TEXT()->cursor.row()->previous()) {
874 TEXT()->cursorUp(owner->view());
875 moveCursorUpdate(true, false);
879 } else if (result == UpdatableInset::FINISHED_DOWN) {
880 if (TEXT()->cursor.row()->next())
881 TEXT()->cursorDown(owner->view());
883 TEXT()->cursorRight(owner->view());
884 moveCursorUpdate(true, false);
888 //setMessage(N_("Text mode"));
890 case LFUN_UNKNOWN_ACTION:
891 case LFUN_BREAKPARAGRAPH:
893 TEXT()->cursorRight(owner->view());
894 owner->view()->setState();
898 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
899 TEXT()->cursorRight(owner->view());
900 moveCursorUpdate(true, false);
905 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
906 TEXT()->cursorRight(owner->view());
907 moveCursorUpdate(true, false);
912 if (TEXT()->cursor.row()->next())
913 TEXT()->cursorDown(owner->view());
915 TEXT()->cursorRight(owner->view());
916 moveCursorUpdate(true, false);
930 if (!owner->view()->available()) break;
931 // this function should be used always [asierra060396]
932 UpdatableInset * tli =
933 owner->view()->theLockingInset();
935 UpdatableInset * lock = tli->getLockingInset();
938 owner->view()->unlockInset(tli);
939 TEXT()->cursorRight(owner->view());
940 moveCursorUpdate(true, false);
943 tli->unlockInsetInInset(owner->view(),
952 // --- Misc -------------------------------------------
953 case LFUN_WORDFINDFORWARD :
954 case LFUN_WORDFINDBACKWARD : {
955 static string last_search;
956 string searched_string;
958 if (!argument.empty()) {
959 last_search = argument;
960 searched_string = argument;
962 searched_string = last_search;
964 bool fw = (action == LFUN_WORDFINDBACKWARD);
965 if (!searched_string.empty()) {
966 LyXFind(owner->view(), searched_string, fw);
968 // owner->view()->showCursor();
974 if (owner->view()->available() && !owner->view()->theLockingInset()) {
975 owner->view()->update(TEXT(),
976 BufferView::SELECT|BufferView::FITCUR);
978 owner->message(keyseq.print());
982 // --- Misc -------------------------------------------
983 case LFUN_EXEC_COMMAND:
985 std::vector<string> allCmds;
986 std::transform(lyxaction.func_begin(), lyxaction.func_end(),
987 std::back_inserter(allCmds), lyx::firster());
988 static std::vector<string> hist;
989 owner->getMiniBuffer()->getString(MiniBuffer::spaces,
994 case LFUN_CANCEL: // RVDK_PATCH_5
997 if (owner->view()->available())
998 // cancel any selection
999 dispatch(LFUN_MARK_OFF);
1000 setMessage(N_("Cancel"));
1003 case LFUN_META_FAKE: // RVDK_PATCH_5
1005 meta_fake_bit = Mod1Mask;
1006 setMessage(keyseq.print());
1010 case LFUN_READ_ONLY_TOGGLE:
1011 if (owner->buffer()->lyxvc.inUse()) {
1012 owner->buffer()->lyxvc.toggleReadOnly();
1014 owner->buffer()->setReadonly(
1015 !owner->buffer()->isReadonly());
1019 case LFUN_CENTER: // this is center and redraw.
1020 owner->view()->center();
1023 // --- Menus -----------------------------------------------
1028 case LFUN_MENUNEWTMPLT:
1032 case LFUN_CLOSEBUFFER:
1036 case LFUN_MENUWRITE:
1037 if (!owner->buffer()->isUnnamed()) {
1039 s1 << _("Saving document") << ' '
1040 << MakeDisplayPath(owner->buffer()->fileName() + "...");
1041 owner->message(s1.str().c_str());
1042 MenuWrite(owner->view(), owner->buffer());
1044 WriteAs(owner->view(), owner->buffer());
1048 WriteAs(owner->view(), owner->buffer(), argument);
1051 case LFUN_MENURELOAD:
1056 Exporter::Export(owner->buffer(), argument, true);
1060 Exporter::Preview(owner->buffer(), argument);
1063 case LFUN_BUILDPROG:
1064 Exporter::Export(owner->buffer(), "program", true);
1067 case LFUN_RUNCHKTEX:
1068 MenuRunChktex(owner->buffer());
1071 case LFUN_MENUPRINT:
1072 owner->getDialogs()->showPrint();
1076 if (argument == "custom")
1079 Exporter::Export(owner->buffer(), argument, false);
1097 InsetCommandParams p;
1100 if (action == LFUN_TOCVIEW)
1102 p.setCmdName("tableofcontents");
1104 else if (action == LFUN_LOAVIEW )
1105 p.setCmdName("listof{algorithm}{List of Algorithms}");
1106 else if (action == LFUN_LOFVIEW)
1107 p.setCmdName("listoffigures");
1109 p.setCmdName("listoftables");
1111 owner->getDialogs()->createTOC(p.getAsString());
1115 case LFUN_DIALOG_TABULAR_INSERT:
1116 owner->getDialogs()->showTabularCreate();
1124 AutoSave(owner->view());
1128 owner->view()->menuUndo();
1132 owner->view()->menuRedo();
1135 case LFUN_MENUSEARCH:
1136 owner->getDialogs()->showSearch();
1139 case LFUN_REMOVEERRORS:
1140 if (owner->view()->removeAutoInsets()) {
1141 owner->view()->redraw();
1142 owner->view()->fitCursor();
1147 changeDepth(owner->view(), TEXT(false), 0);
1150 case LFUN_DEPTH_MIN:
1151 changeDepth(owner->view(), TEXT(false), -1);
1154 case LFUN_DEPTH_PLUS:
1155 changeDepth(owner->view(), TEXT(false), 1);
1159 owner->getDialogs()->setUserFreeFont();
1162 case LFUN_RECONFIGURE:
1163 Reconfigure(owner->view());
1167 case LFUN_FLOATSOPERATE:
1168 if (argument == "openfoot")
1169 owner->view()->allFloats(1,0);
1170 else if (argument == "closefoot")
1171 owner->view()->allFloats(0,0);
1172 else if (argument == "openfig")
1173 owner->view()->allFloats(1,1);
1174 else if (argument == "closefig")
1175 owner->view()->allFloats(0,1);
1178 #ifdef WITH_WARNINGS
1179 //#warning Find another implementation here (or another lyxfunc)!
1182 case LFUN_HELP_ABOUTLYX:
1183 owner->getDialogs()->showAboutlyx();
1186 case LFUN_HELP_TEXINFO:
1187 owner->getDialogs()->showTexinfo();
1190 case LFUN_HELP_OPEN:
1192 string const arg = argument;
1194 setErrorMessage(N_("Missing argument"));
1197 owner->prohibitInput();
1198 string const fname = i18nLibFileSearch("doc", arg, "lyx");
1199 if (fname.empty()) {
1200 lyxerr << "LyX: unable to find documentation file `"
1201 << arg << "'. Bad installation?" << endl;
1202 owner->allowInput();
1206 str << _("Opening help file") << ' '
1207 << MakeDisplayPath(fname) << "...";
1208 owner->message(str.str().c_str());
1209 owner->view()->buffer(bufferlist.loadLyXFile(fname, false));
1210 owner->allowInput();
1214 // --- version control -------------------------------
1215 case LFUN_VC_REGISTER:
1217 if (!owner->buffer()->lyxvc.inUse())
1218 owner->buffer()->lyxvc.registrer();
1222 case LFUN_VC_CHECKIN:
1224 if (owner->buffer()->lyxvc.inUse()
1225 && !owner->buffer()->isReadonly())
1226 owner->buffer()->lyxvc.checkIn();
1230 case LFUN_VC_CHECKOUT:
1232 if (owner->buffer()->lyxvc.inUse()
1233 && owner->buffer()->isReadonly())
1234 owner->buffer()->lyxvc.checkOut();
1238 case LFUN_VC_REVERT:
1240 owner->buffer()->lyxvc.revert();
1246 owner->buffer()->lyxvc.undoLast();
1250 case LFUN_VC_HISTORY:
1252 owner->getDialogs()->showVCLogFile();
1256 // --- buffers ----------------------------------------
1258 case LFUN_SWITCHBUFFER:
1259 owner->view()->buffer(bufferlist.getBuffer(argument));
1264 // servercmd: argument must be <file>:<template>
1265 Buffer * tmpbuf = NewLyxFile(argument);
1267 owner->view()->buffer(tmpbuf);
1271 case LFUN_FILE_OPEN:
1275 case LFUN_LATEX_LOG:
1276 owner->getDialogs()->showLogFile();
1279 case LFUN_LAYOUT_DOCUMENT:
1280 owner->getDialogs()->showDocument();
1283 case LFUN_LAYOUT_PARAGRAPH:
1284 owner->getDialogs()->showParagraph();
1287 case LFUN_LAYOUT_CHARACTER:
1288 owner->getDialogs()->showCharacter();
1291 case LFUN_LAYOUT_TABULAR:
1292 if (owner->view()->theLockingInset()) {
1293 if (owner->view()->theLockingInset()->lyxCode()==Inset::TABULAR_CODE) {
1294 InsetTabular * inset = static_cast<InsetTabular *>
1295 (owner->view()->theLockingInset());
1296 inset->openLayoutDialog(owner->view());
1297 } else if (owner->view()->theLockingInset()->
1298 getFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
1299 InsetTabular * inset = static_cast<InsetTabular *>(
1300 owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
1301 inset->openLayoutDialog(owner->view());
1306 case LFUN_LAYOUT_PREAMBLE:
1307 owner->getDialogs()->showPreamble();
1310 case LFUN_DROP_LAYOUTS_CHOICE:
1311 owner->getToolbar()->openLayoutList();
1314 case LFUN_MENU_OPEN_BY_NAME:
1315 owner->getMenubar()->openByName(argument);
1316 break; // RVDK_PATCH_5
1318 case LFUN_SPELLCHECK:
1319 if (lyxrc.isp_command != "none")
1320 owner->getDialogs()->showSpellchecker();
1323 // --- lyxserver commands ----------------------------
1327 setMessage(owner->buffer()->fileName());
1328 lyxerr[Debug::INFO] << "FNAME["
1329 << owner->buffer()->fileName()
1335 dispatch_buffer = keyseq.print();
1336 lyxserver->notifyClient(dispatch_buffer);
1340 case LFUN_GOTOFILEROW:
1344 istringstream istr(argument.c_str());
1345 istr >> file_name >> row;
1346 // Must replace extension of the file to be .lyx and get full path
1347 string const s(ChangeExtension(file_name, ".lyx"));
1349 // Either change buffer or load the file
1350 if (bufferlist.exists(s)) {
1351 owner->view()->buffer(bufferlist.getBuffer(s));
1353 owner->view()->buffer(bufferlist.loadLyXFile(s));
1357 owner->view()->setCursorFromRow(row);
1360 owner->view()->center();
1364 case LFUN_GOTO_PARAGRAPH:
1366 istringstream istr(argument.c_str());
1370 Paragraph * par = owner->buffer()->getParFromID(id);
1372 lyxerr[Debug::INFO] << "No matching paragraph found! ["
1373 << id << "]" << std::endl;
1376 lyxerr << "Paragraph " << par->id()
1377 << " found." << endl;
1381 owner->view()->text->setCursor(owner->view(), par, 0);
1382 owner->view()->setState();
1386 owner->view()->center();
1393 int const qa = lyxaction.LookupFunc(argument);
1394 setMessage(lyxaction.helpText(static_cast<kb_action>(qa)));
1398 // --- toolbar ----------------------------------
1399 case LFUN_PUSH_TOOLBAR:
1401 int nth = strToInt(argument);
1403 setErrorMessage(N_("Push-toolbar needs argument > 0"));
1405 owner->getToolbar()->push(nth);
1410 case LFUN_ADD_TO_TOOLBAR:
1412 if (lyxerr.debugging(Debug::GUI)) {
1413 lyxerr << "LFUN_ADD_TO_TOOLBAR:"
1414 "argument = `" << argument << '\'' << endl;
1416 string tmp(argument);
1417 //lyxerr <<string("Argument: ") + argument);
1418 //lyxerr <<string("Tmp : ") + tmp);
1420 setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
1422 owner->getToolbar()->add(argument, false);
1423 owner->getToolbar()->set();
1428 // --- insert characters ----------------------------------------
1430 // --- Mathed stuff. If we are here, there is no locked inset yet.
1431 case LFUN_MATH_EXTERN:
1432 case LFUN_MATH_NUMBER:
1433 case LFUN_MATH_NONUMBER:
1434 case LFUN_MATH_LIMITS:
1436 setErrorMessage(N_("This is only allowed in math mode!"));
1440 // passthrough hat and underscore outside mathed:
1441 case LFUN_SUBSCRIPT:
1442 dispatch(LFUN_SELFINSERT, "_");
1444 case LFUN_SUPERSCRIPT:
1445 dispatch(LFUN_SELFINSERT, "^");
1448 case LFUN_MATH_PANEL:
1449 owner->getDialogs()->showMathPanel();
1452 case LFUN_CITATION_CREATE:
1454 InsetCommandParams p( "cite" );
1456 if (!argument.empty()) {
1457 // This should be set at source, ie when typing
1458 // "citation-insert foo" in the minibuffer.
1459 // Question: would pybibliographer also need to be
1460 // changed. Suspect so. Leave as-is therefore.
1461 if (contains(argument, "|")) {
1462 p.setContents( token(argument, '|', 0) );
1463 p.setOptions( token(argument, '|', 1) );
1465 p.setContents( argument );
1467 dispatch(LFUN_CITATION_INSERT, p.getAsString());
1469 owner->getDialogs()->createCitation( p.getAsString() );
1473 case LFUN_CHILDOPEN:
1475 string const filename =
1476 MakeAbsPath(argument,
1477 OnlyPath(owner->buffer()->fileName()));
1478 setMessage(N_("Opening child document ") +
1479 MakeDisplayPath(filename) + "...");
1480 owner->view()->savePosition(0);
1481 if (bufferlist.exists(filename))
1482 owner->view()->buffer(bufferlist.getBuffer(filename));
1484 owner->view()->buffer(bufferlist.loadLyXFile(filename));
1488 case LFUN_TOGGLECURSORFOLLOW:
1489 lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
1492 case LFUN_KMAP_OFF: // keymap off
1493 owner->getIntl()->KeyMapOn(false);
1496 case LFUN_KMAP_PRIM: // primary keymap
1497 owner->getIntl()->KeyMapPrim();
1500 case LFUN_KMAP_SEC: // secondary keymap
1501 owner->getIntl()->KeyMapSec();
1504 case LFUN_KMAP_TOGGLE: // toggle keymap
1505 owner->getIntl()->ToggleKeyMap();
1510 // argument contains ';'-terminated commands
1511 while (argument.find(';') != string::npos) {
1513 argument = split(argument, first, ';');
1519 case LFUN_DIALOG_PREFERENCES:
1520 owner->getDialogs()->showPreferences();
1523 case LFUN_SAVEPREFERENCES:
1525 Path p(user_lyxdir);
1526 lyxrc.write("preferences");
1530 case LFUN_SCREEN_FONT_UPDATE:
1532 // handle the screen font changes.
1534 lyxrc.set_font_norm_type();
1535 fontloader.update();
1536 // Of course we should only do the resize and the textcache.clear
1537 // if values really changed...but not very important right now. (Lgb)
1538 // All visible buffers will need resize
1540 // We also need to empty the textcache so that
1541 // the buffer will be formatted correctly after
1547 case LFUN_SET_COLOR:
1550 string const x11_name = split(argument, lyx_name, ' ');
1551 if (lyx_name.empty() || x11_name.empty()) {
1552 setErrorMessage(N_("Syntax: set-color <lyx_name>"
1557 if (!lcolor.setColor(lyx_name, x11_name)) {
1558 static string const err1 (N_("Set-color \""));
1559 static string const err2 (
1560 N_("\" failed - color is undefined "
1561 "or may not be redefined"));
1562 setErrorMessage(_(err1) + lyx_name + _(err2));
1565 lyxColorHandler->updateColor(lcolor.getFromLyXName(lyx_name));
1566 owner->view()->redraw();
1571 owner->message(argument);
1574 case LFUN_MESSAGE_PUSH:
1575 owner->messagePush(argument);
1578 case LFUN_MESSAGE_POP:
1579 owner->messagePop();
1583 // Then if it was none of the above
1584 if (!owner->view()->Dispatch(action, argument))
1585 lyxerr << "A truly unknown func ["
1586 << lyxaction.getActionName(action) << "]!"
1593 commandshortcut.erase();
1595 if (lyxrc.display_shortcuts && show_sc) {
1596 if (action != LFUN_SELFINSERT) {
1597 // Put name of command and list of shortcuts
1598 // for it in minibuffer
1599 string comname = lyxaction.getActionName(action);
1601 kb_action pseudoaction = action;
1602 bool argsadded = false;
1604 if (!argument.empty()) {
1605 // If we have the command with argument,
1608 lyxaction.searchActionArg(action,
1611 if (pseudoaction == -1) {
1612 pseudoaction = action;
1614 comname += " " + argument;
1619 string const shortcuts =
1620 toplevel_keymap->findbinding(pseudoaction);
1622 if (!shortcuts.empty()) {
1623 comname += ": " + shortcuts;
1624 } else if (!argsadded && !argument.empty()) {
1625 comname += " " + argument;
1628 if (!comname.empty()) {
1629 comname = strip(comname);
1630 commandshortcut = "(" + comname + ')';
1632 // Here we could even add a small pause,
1633 // to annoy the user and make him learn
1635 // No! That will just annoy, not teach
1636 // anything. The user will read the messages
1637 // if they are interested. (Asger)
1642 string const res = getMessage();
1645 if (!commandshortcut.empty()) {
1646 owner->getMiniBuffer()->addSet(commandshortcut);
1649 string const msg(_(res) + ' ' + commandshortcut);
1650 owner->message(msg);
1657 void LyXFunc::setupLocalKeymap()
1659 keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
1660 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap.get();
1664 void LyXFunc::menuNew(bool fromTemplate)
1666 string initpath = lyxrc.document_path;
1668 if (owner->view()->available()) {
1669 string const trypath = owner->buffer()->filepath;
1670 // If directory is writeable, use this as default.
1671 if (IsDirWriteable(trypath))
1675 static int newfile_number;
1678 if (lyxrc.new_ask_filename) {
1679 FileDialog fileDlg(owner, _("Enter filename for new document"),
1680 LFUN_SELECT_FILE_SYNC,
1681 make_pair(string(_("Documents")),
1682 string(lyxrc.document_path)),
1683 make_pair(string(_("Templates")),
1684 string(lyxrc.template_path)));
1686 FileDialog::Result result =
1687 fileDlg.Select(initpath,
1688 _("*.lyx|LyX Documents (*.lyx)"),
1691 if (result.second.empty()) {
1692 owner->message(_("Canceled."));
1693 lyxerr[Debug::INFO] << "New Document Cancelled." << endl;
1697 // get absolute path of file and make sure the filename ends
1699 s = MakeAbsPath(result.second);
1700 if (!IsLyXFilename(s))
1703 // Check if the document already is open
1704 if (bufferlist.exists(s)) {
1705 switch (Alert::askConfirmation(_("Document is already open:"),
1706 MakeDisplayPath(s, 50),
1707 _("Do you want to close that document now?\n"
1708 "('No' will just switch to the open version)")))
1710 case 1: // Yes: close the document
1711 if (!bufferlist.close(bufferlist.getBuffer(s)))
1712 // If close is canceled, we cancel here too.
1715 case 2: // No: switch to the open document
1716 owner->view()->buffer(bufferlist.getBuffer(s));
1718 case 3: // Cancel: Do nothing
1719 owner->message(_("Canceled."));
1723 // Check whether the file already exists
1725 if (fi.readable() &&
1726 Alert::askQuestion(_("File already exists:"),
1727 MakeDisplayPath(s, 50),
1728 _("Do you want to open the document?"))) {
1730 string const disp_fn(MakeDisplayPath(s));
1733 str << _("Opening document") << ' '
1734 << disp_fn << "...";
1736 owner->message(str.str().c_str());
1737 //XFlush(fl_get_display());
1738 owner->view()->buffer(bufferlist.loadLyXFile(s));
1740 str2 << _("Document") << ' '
1741 << disp_fn << ' ' << _("opened.");
1743 owner->message(str2.str().c_str());
1748 s = AddName(lyxrc.document_path,
1749 "newfile" + tostr(++newfile_number) + ".lyx");
1751 while (bufferlist.exists(s) || fi.readable()) {
1753 s = AddName(lyxrc.document_path,
1754 "newfile" + tostr(newfile_number) +
1760 // The template stuff
1763 FileDialog fileDlg(owner, _("Select template file"),
1764 LFUN_SELECT_FILE_SYNC,
1765 make_pair(string(_("Documents")),
1766 string(lyxrc.document_path)),
1767 make_pair(string(_("Templates")),
1768 string(lyxrc.template_path)));
1770 FileDialog::Result result =
1771 fileDlg.Select(lyxrc.template_path,
1772 _("*.lyx|LyX Documents (*.lyx)"));
1774 if (result.first == FileDialog::Later)
1777 string const fname = result.second;
1784 // find a free buffer
1785 lyxerr[Debug::INFO] << "Find a free buffer." << endl;
1786 owner->view()->buffer(bufferlist.newFile(s, templname));
1790 void LyXFunc::open(string const & fname)
1792 string initpath = lyxrc.document_path;
1794 if (owner->view()->available()) {
1795 string const trypath = owner->buffer()->filepath;
1796 // If directory is writeable, use this as default.
1797 if (IsDirWriteable(trypath))
1803 if (fname.empty()) {
1804 FileDialog fileDlg(owner, _("Select document to open"),
1806 make_pair(string(_("Documents")),
1807 string(lyxrc.document_path)),
1808 make_pair(string(_("Examples")),
1809 string(AddPath(system_lyxdir, "examples"))));
1811 FileDialog::Result result =
1812 fileDlg.Select(initpath,
1813 "*.lyx|LyX Documents (*.lyx)");
1815 if (result.first == FileDialog::Later)
1818 filename = result.second;
1820 // check selected filename
1821 if (filename.empty()) {
1822 owner->message(_("Canceled."));
1828 // get absolute path of file and add ".lyx" to the filename if
1830 string const fullpath = FileSearch(string(), filename, "lyx");
1831 if (fullpath.empty()) {
1832 Alert::alert(_("Error"), _("Could not find file"), filename);
1836 filename = fullpath;
1839 string const disp_fn(MakeDisplayPath(filename));
1842 str << _("Opening document") << ' ' << disp_fn << "...";
1844 owner->message(str.str().c_str());
1846 Buffer * openbuf = bufferlist.loadLyXFile(filename);
1848 owner->view()->buffer(openbuf);
1850 str << _("Document") << ' ' << disp_fn << ' ' << _("opened.");
1851 owner->message(str.str().c_str());
1854 str << _("Could not open document") << ' ' << disp_fn;
1855 owner->message(str.str().c_str());
1860 // checks for running without gui are missing.
1861 void LyXFunc::doImport(string const & argument)
1864 string filename = split(argument, format, ' ');
1865 lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format
1866 << " file: " << filename << endl;
1868 if (filename.empty()) { // need user interaction
1869 string initpath = lyxrc.document_path;
1871 if (owner->view()->available()) {
1872 string const trypath = owner->buffer()->filepath;
1873 // If directory is writeable, use this as default.
1874 if (IsDirWriteable(trypath))
1878 string const text = _("Select ") + formats.prettyName(format)
1879 + _(" file to import");
1881 FileDialog fileDlg(owner, text,
1883 make_pair(string(_("Documents")),
1884 string(lyxrc.document_path)),
1885 make_pair(string(_("Examples")),
1886 string(AddPath(system_lyxdir, "examples"))));
1888 string const extension = "*." + formats.extension(format)
1889 + "| " + formats.prettyName(format)
1890 + " (*." + formats.extension(format) + ")";
1892 FileDialog::Result result = fileDlg.Select(initpath,
1895 if (result.first == FileDialog::Later)
1898 filename = result.second;
1900 // check selected filename
1901 if (filename.empty())
1902 owner->message(_("Canceled."));
1905 // still no filename? abort
1906 if (filename.empty())
1909 // get absolute path of file
1910 filename = MakeAbsPath(filename);
1912 string const lyxfile = ChangeExtension(filename, ".lyx");
1914 // Check if the document already is open
1915 if (bufferlist.exists(lyxfile)) {
1916 switch (Alert::askConfirmation(_("Document is already open:"),
1917 MakeDisplayPath(lyxfile, 50),
1918 _("Do you want to close that document now?\n"
1919 "('No' will just switch to the open version)")))
1921 case 1: // Yes: close the document
1922 if (!bufferlist.close(bufferlist.getBuffer(lyxfile)))
1923 // If close is canceled, we cancel here too.
1926 case 2: // No: switch to the open document
1927 owner->view()->buffer(bufferlist.getBuffer(lyxfile));
1929 case 3: // Cancel: Do nothing
1930 owner->message(_("Canceled."));
1935 // Check if a LyX document by the same root exists in filesystem
1936 FileInfo const f(lyxfile, true);
1937 if (f.exist() && !Alert::askQuestion(_("A document by the name"),
1938 MakeDisplayPath(lyxfile),
1939 _("already exists. Overwrite?"))) {
1940 owner->message(_("Canceled"));
1943 // filename should be valid now
1945 Importer::Import(owner, filename, format);
1949 void LyXFunc::reloadBuffer()
1951 string const fn = owner->buffer()->fileName();
1952 if (bufferlist.close(owner->buffer()))
1953 owner->view()->buffer(bufferlist.loadLyXFile(fn));
1957 void LyXFunc::closeBuffer()
1959 if (bufferlist.close(owner->buffer()) && !quitting) {
1960 if (bufferlist.empty()) {
1961 // need this otherwise SEGV may occur while trying to
1962 // set variables that don't exist
1963 // since there's no current buffer
1964 owner->getDialogs()->hideBufferDependent();
1966 owner->view()->buffer(bufferlist.first());
1972 // Each "owner" should have it's own message method. lyxview and
1973 // the minibuffer would use the minibuffer, but lyxserver would
1974 // send an ERROR signal to its client. Alejandro 970603
1975 // This func is bit problematic when it comes to NLS, to make the
1976 // lyx servers client be language indepenent we must not translate
1977 // strings sent to this func.
1978 void LyXFunc::setErrorMessage(string const & m) const
1980 dispatch_buffer = m;
1985 void LyXFunc::setMessage(string const & m)
1987 dispatch_buffer = m;
1991 void LyXFunc::initMiniBuffer()
1993 string text = _("Welcome to LyX!");
1995 // When meta-fake key is pressed, show the key sequence so far + "M-".
1997 text = keyseq.print();
2001 // Else, when a non-complete key sequence is pressed,
2002 // show the available options.
2003 if (keyseq.length() > 0 && !keyseq.deleted()) {
2004 text = keyseq.printOptions();
2007 // Else, show the buffer state.
2008 else if (owner->view()->available()) {
2009 Buffer * tmpbuf = owner->buffer();
2011 string const nicename =
2012 MakeDisplayPath(tmpbuf->fileName());
2013 // Should we do this instead? (kindo like emacs)
2014 // leaves more room for other information
2017 if (tmpbuf->lyxvc.inUse()) {
2019 text += tmpbuf->lyxvc.versionString();
2021 text += tmpbuf->lyxvc.locker();
2022 if (tmpbuf->isReadonly())
2025 } else if (tmpbuf->isReadonly())
2027 if (!tmpbuf->isLyxClean())
2028 text += _(" (Changed)");
2030 if (text != _("Welcome to LyX!")) // this is a hack
2031 text = _("* No document open *");
2034 owner->message(text);