1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2001 The LyX Team.
9 * ====================================================== */
30 #pragma implementation
33 #include "support/lyxalgo.h"
37 #include "bufferlist.h"
38 #include "BufferView.h"
39 #include "ColorHandler.h"
40 #include "lyxserver.h"
44 #include "LyXAction.h"
45 #include "insets/inseturl.h"
46 #include "insets/insetlatexaccent.h"
47 #include "insets/insettoc.h"
48 #include "insets/insetref.h"
49 #include "insets/insetparent.h"
50 #include "insets/insetindex.h"
51 #include "insets/insetinclude.h"
52 #include "insets/insetbib.h"
53 #include "insets/insetcite.h"
54 #include "insets/insettext.h"
55 #include "insets/insetert.h"
56 #include "insets/insetexternal.h"
57 #include "insets/insetgraphics.h"
58 #include "insets/insetfoot.h"
59 #include "insets/insetmarginal.h"
60 #include "insets/insetminipage.h"
61 #include "insets/insetfloat.h"
63 #include "insets/insetlist.h"
64 #include "insets/insettheorem.h"
66 #include "insets/insettabular.h"
67 #include "insets/insetcaption.h"
68 #include "mathed/formulamacro.h"
69 #include "mathed/math_cursor.h"
70 #include "mathed/math_inset.h"
71 #include "minibuffer.h"
74 #include "lyx_gui_misc.h"
75 #include "support/filetools.h"
76 #include "support/FileInfo.h"
77 #include "support/syscall.h"
78 #include "support/lstrings.h"
79 #include "support/path.h"
80 #include "support/lyxfunctional.h"
85 #include "trans_mgr.h"
88 #include "bufferview_funcs.h"
89 #include "frontends/FileDialog.h"
90 #include "frontends/Dialogs.h"
91 #include "frontends/Toolbar.h"
92 #include "frontends/Menubar.h"
93 #include "FloatList.h"
94 #include "converter.h"
97 #include "FontLoader.h"
98 #include "TextCache.h"
100 #include "undo_funcs.h"
103 using std::make_pair;
107 extern BufferList bufferlist;
108 extern LyXServer * lyxserver;
109 extern int greek_kb_flag;
110 extern bool selection_possible;
111 extern void MenuSendto();
113 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
115 extern void show_symbols_form(LyXFunc *);
117 extern LyXAction lyxaction;
119 extern tex_accent_struct get_accent(kb_action action);
121 extern LyXTextClass::size_type current_layout;
123 extern void ShowLatexLog();
129 class MiniBufferController : public SigC::Object {
132 MiniBufferController() {
136 &MiniBufferController::receiveCommand));
140 &MiniBufferController::receiveArg));
143 void receiveCmd(string const & cmd) {}
145 void receiveArg(string const & arg) {}
153 MiniBufferController mb_ctrl;
159 /* === globals =========================================================== */
161 // Initialization of static member var
162 bool LyXFunc::show_sc = true;
165 LyXFunc::LyXFunc(LyXView * o)
169 lyx_dead_action = LFUN_NOACTION;
170 lyx_calling_dead_action = LFUN_NOACTION;
176 LyXText * LyXFunc::TEXT(bool flag = true) const
179 return owner->view()->text;
180 return owner->view()->getLyXText();
184 // I changed this func slightly. I commented out the ...FinishUndo(),
185 // this means that all places that used to have a moveCursorUpdate, now
186 // have a ...FinishUndo() as the preceeding statement. I have also added
187 // a moveCursorUpdate to some of the functions that updated the cursor, but
188 // that did not show its new position.
190 void LyXFunc::moveCursorUpdate(bool flag, bool selecting)
192 if (selecting || TEXT(flag)->selection.mark()) {
193 TEXT(flag)->setSelection(owner->view());
194 if (TEXT(flag)->bv_owner)
195 owner->view()->toggleToggle();
197 owner->view()->update(TEXT(flag), BufferView::SELECT|BufferView::FITCUR);
198 owner->view()->showCursor();
200 /* ---> Everytime the cursor is moved, show the current font state. */
201 // should this too me moved out of this func?
202 owner->view()->setState();
206 void LyXFunc::handleKeyFunc(kb_action action)
208 char c = keyseq.getiso();
210 if (keyseq.length != -1) c = 0;
212 owner->getIntl()->getTrans()
213 .deadkey(c, get_accent(action).accent, TEXT(false));
214 // Need to reset, in case the minibuffer calls these
218 // copied verbatim from do_accent_char
219 owner->view()->update(TEXT(false),
220 BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
221 TEXT(false)->selection.cursor = TEXT(false)->cursor;
225 void LyXFunc::processKeySym(KeySym keysym, unsigned int state)
229 if (lyxerr.debugging(Debug::KEY)) {
230 char const * tmp = XKeysymToString(keysym);
231 string const stm = (tmp ? tmp : "");
232 lyxerr << "KeySym is "
235 << keysym << "] State is ["
239 // Do nothing if we have nothing (JMarc)
240 if (keysym == NoSymbol) {
241 lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
246 // Can we be sure that this will work for all X-Windows
247 // implementations? (Lgb)
248 // This code snippet makes lyx ignore some keys. Perhaps
249 // all of them should be explictly mentioned?
250 if ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
251 || keysym == XK_Mode_switch || keysym == 0x0) {
255 // Do a one-deep top-level lookup for
256 // cancel and meta-fake keys. RVDK_PATCH_5
257 cancel_meta_seq.reset();
259 int action = cancel_meta_seq.addkey(keysym, state
260 &(ShiftMask|ControlMask
262 if (lyxerr.debugging(Debug::KEY)) {
263 lyxerr << "action first set to [" << action << "]" << endl;
266 // When not cancel or meta-fake, do the normal lookup.
267 // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
268 // Mostly, meta_fake_bit = 0. RVDK_PATCH_5.
269 if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
270 if (lyxerr.debugging(Debug::KEY)) {
271 lyxerr << "meta_fake_bit is ["
272 << meta_fake_bit << "]" << endl;
274 // remove Caps Lock and Mod2 as a modifiers
275 action = keyseq.addkey(keysym,
276 (state | meta_fake_bit)
277 &(ShiftMask|ControlMask
279 if (lyxerr.debugging(Debug::KEY)) {
280 lyxerr << "action now set to ["
281 << action << "]" << endl;
284 // Dont remove this unless you know what you are doing.
287 if (action == 0) action = LFUN_PREFIX;
289 if (lyxerr.debugging(Debug::KEY)) {
292 lyxerr << "Key [action="
298 // already here we know if it any point in going further
299 // why not return already here if action == -1 and
300 // num_bytes == 0? (Lgb)
302 if (keyseq.length > 1 || keyseq.length < -1) {
309 // It is unknown, but what if we remove all
310 // the modifiers? (Lgb)
311 action = keyseq.addkey(keysym, 0);
313 if (lyxerr.debugging(Debug::KEY)) {
314 lyxerr << "Removing modifiers...\n"
315 << "Action now set to ["
316 << action << "]" << endl;
319 owner->message(_("Unknown function."));
324 if (action == LFUN_SELFINSERT) {
325 // This is very X dependant.
326 unsigned int c = keysym;
328 switch (c & 0x0000FF00) {
329 // latin 1 byte 3 = 0
330 case 0x00000000: break;
331 // latin 2 byte 3 = 1
333 // latin 3 byte 3 = 2
335 // latin 4 byte 3 = 3
337 // latin 8 byte 3 = 18 (0x12)
339 // latin 9 byte 3 = 19 (0x13)
348 argument = static_cast<char>(c);
349 lyxerr[Debug::KEY] << "SelfInsert arg[`"
350 << argument << "']" << endl;
353 bool tmp_sc = show_sc;
355 dispatch(action, argument);
362 func_status::value_type LyXFunc::getStatus(int ac) const
364 return getStatus(ac, string());
368 func_status::value_type LyXFunc::getStatus(int ac,
369 string const & not_to_use_arg) const
372 func_status::value_type flag = func_status::OK;
374 Buffer * buf = owner->buffer();
376 if (lyxaction.isPseudoAction(ac))
377 action = lyxaction.retrieveActionArg(ac, argument);
379 action = static_cast<kb_action>(ac);
380 if (!not_to_use_arg.empty())
381 argument = not_to_use_arg; // exept here
384 if (action == LFUN_UNKNOWN_ACTION) {
385 setErrorMessage(N_("Unknown action"));
386 return func_status::Unknown;
389 // Check whether we need a buffer
390 if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) {
391 // Yes we need a buffer, do we have one?
394 // Can we use a readonly buffer?
395 if (buf->isReadonly() &&
396 !lyxaction.funcHasFlag(action,
397 LyXAction::ReadOnly)) {
399 setErrorMessage(N_("Document is read-only"));
400 flag |= func_status::Disabled;
404 setErrorMessage(N_("Command not allowed with"
405 "out any document open"));
406 flag |= func_status::Disabled;
411 // I would really like to avoid having this switch and rather try to
412 // encode this in the function itself.
413 bool disable = false;
416 disable = !Exporter::IsExportable(buf, "dvi")
417 || lyxrc.print_command == "none";
420 disable = argument == "fax" &&
421 !Exporter::IsExportable(buf, argument);
424 disable = buf->undostack.empty();
427 disable = buf->redostack.empty();
429 case LFUN_SPELLCHECK:
430 disable = lyxrc.isp_command == "none";
433 disable = lyxrc.chktex_command == "none";
436 disable = !Exporter::IsExportable(buf, "program");
439 case LFUN_LAYOUT_TABULAR:
441 if (owner->view()->theLockingInset()) {
442 disable = (owner->view()->theLockingInset()->lyxCode() != Inset::TABULAR_CODE) &&
443 !owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE);
447 case LFUN_TABULAR_FEATURE:
449 if (owner->view()->theLockingInset()) {
450 func_status::value_type ret = func_status::Disabled;
451 if (owner->view()->theLockingInset()->lyxCode() == Inset::TABULAR_CODE) {
452 ret = static_cast<InsetTabular *>
453 (owner->view()->theLockingInset())->
455 } else if (owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
456 ret = static_cast<InsetTabular *>
457 (owner->view()->theLockingInset()->
458 getFirstLockingInsetOfType(Inset::TABULAR_CODE))->
464 static InsetTabular inset(*owner->buffer(), 1, 1);
465 func_status::value_type ret;
468 ret = inset.getStatus(argument);
469 if ((ret & func_status::ToggleOn) ||
470 (ret & func_status::ToggleOff))
471 flag |= func_status::ToggleOff;
475 case LFUN_VC_REGISTER:
476 disable = buf->lyxvc.inUse();
478 case LFUN_VC_CHECKIN:
479 disable = !buf->lyxvc.inUse() || buf->isReadonly();
481 case LFUN_VC_CHECKOUT:
482 disable = !buf->lyxvc.inUse() || !buf->isReadonly();
486 case LFUN_VC_HISTORY:
487 disable = !buf->lyxvc.inUse();
489 case LFUN_BOOKMARK_GOTO:
490 disable = !owner->view()->
491 isSavedPosition(strToUnsignedInt(argument));
495 case LFUN_INSET_TOGGLE:
496 disable = (TEXT(false)->getInset() == 0);
499 case LFUN_MATH_VALIGN: {
500 // I think this test can be simplified (Andre')
501 // mathcursor is != 0 iff we are in math mode
502 //Inset * tli = owner->view()->theLockingInset();
503 //if (tli && (tli->lyxCode() == Inset::MATH_CODE
504 // || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
507 char align = mathcursor->valign();
512 if (argument.empty()) {
513 flag = func_status::OK;
516 if (!contains("tcb", argument[0])) {
520 if (argument[0] == align)
521 flag |= func_status::ToggleOn;
523 flag |= func_status::ToggleOff;
528 case LFUN_MATH_HALIGN: {
529 //Inset * tli = owner->view()->theLockingInset();
530 //if (tli && (tli->lyxCode() == Inset::MATH_CODE
531 // || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
533 char align = mathcursor->halign();
538 if (argument.empty()) {
539 flag = func_status::OK;
542 if (!contains("lcr", argument[0])) {
546 if (argument[0] == align)
547 flag |= func_status::ToggleOn;
549 flag |= func_status::ToggleOff;
554 case LFUN_MATH_MUTATE: {
555 Inset * tli = owner->view()->theLockingInset();
556 if (tli && (tli->lyxCode() == Inset::MATH_CODE)) {
557 MathInsetTypes type = mathcursor->par()->GetType();
558 func_status::value_type box = func_status::ToggleOff;
559 if (argument == "inline") {
560 if (type == LM_OT_SIMPLE)
561 box = func_status::ToggleOn;
562 } else if (argument == "display") {
563 if (type == LM_OT_EQUATION)
564 box = func_status::ToggleOn;
565 } else if (argument == "eqnarray") {
566 if (type == LM_OT_EQNARRAY)
567 box = func_status::ToggleOn;
568 } else if (argument == "align") {
569 if (type == LM_OT_ALIGN)
570 box = func_status::ToggleOn;
572 box = func_status::OK;
581 // we just need to be in math mode to enable that
583 case LFUN_MATH_SPACE:
584 case LFUN_MATH_LIMITS:
585 case LFUN_MATH_NONUMBER:
586 case LFUN_MATH_NUMBER:
587 disable = !mathcursor;
590 // we need to be math mode and a math array for that
591 // Hack: halign produces non-zero result iff we are in a math array
592 case LFUN_MATH_ROW_INSERT:
593 case LFUN_MATH_ROW_DELETE:
594 case LFUN_MATH_COLUMN_INSERT:
595 case LFUN_MATH_COLUMN_DELETE:
596 disable = !mathcursor || !mathcursor->halign();
603 // the functions which insert insets
604 Inset::Code code = Inset::NO_CODE;
606 case LFUN_INSET_TEXT:
607 code = Inset::TEXT_CODE;
610 code = Inset::ERT_CODE;
613 case LFUN_INSET_GRAPHICS:
614 code = Inset::GRAPHICS_CODE;
616 case LFUN_INSET_FOOTNOTE:
617 code = Inset::FOOT_CODE;
619 case LFUN_DIALOG_TABULAR_INSERT:
620 case LFUN_INSET_TABULAR:
621 code = Inset::TABULAR_CODE;
623 case LFUN_INSET_EXTERNAL:
624 code = Inset::EXTERNAL_CODE;
626 case LFUN_INSET_MARGINAL:
627 code = Inset::MARGIN_CODE;
629 case LFUN_INSET_MINIPAGE:
630 code = Inset::MINIPAGE_CODE;
632 case LFUN_INSET_FLOAT:
633 case LFUN_INSET_WIDE_FLOAT:
634 code = Inset::FLOAT_CODE;
636 case LFUN_FLOAT_LIST:
637 code = Inset::FLOAT_LIST_CODE;
640 case LFUN_INSET_LIST:
641 code = Inset::LIST_CODE;
643 case LFUN_INSET_THEOREM:
644 code = Inset::THEOREM_CODE;
647 case LFUN_INSET_CAPTION:
648 code = Inset::CAPTION_CODE;
650 case LFUN_INSERT_NOTE:
651 code = Inset::IGNORE_CODE;
653 case LFUN_INSERT_LABEL:
654 code = Inset::LABEL_CODE;
656 case LFUN_REF_INSERT:
657 code = Inset::REF_CODE;
659 case LFUN_CITATION_CREATE:
660 case LFUN_CITATION_INSERT:
661 code = Inset::CITE_CODE;
663 case LFUN_INSERT_BIBTEX:
664 code = Inset::BIBTEX_CODE;
666 case LFUN_INDEX_INSERT:
667 case LFUN_INDEX_INSERT_LAST:
668 case LFUN_INDEX_CREATE:
669 code = Inset::INDEX_CODE;
671 case LFUN_INDEX_PRINT:
672 code = Inset::INDEX_PRINT_CODE;
674 case LFUN_CHILD_INSERT:
675 code = Inset::INCLUDE_CODE;
677 case LFUN_TOC_INSERT:
678 code = Inset::TOC_CODE;
680 case LFUN_PARENTINSERT:
681 code = Inset::PARENT_CODE;
685 case LFUN_INSERT_URL:
686 code = Inset::URL_CODE;
689 // always allow this, since we will inset a raw quote
690 // if an inset is not allowed.
692 case LFUN_HYPHENATION:
693 case LFUN_LIGATURE_BREAK:
695 case LFUN_MENU_SEPARATOR:
697 case LFUN_END_OF_SENTENCE:
698 case LFUN_PROTECTEDSPACE:
699 code = Inset::SPECIALCHAR_CODE;
704 if (code != Inset::NO_CODE
705 && owner->view()->theLockingInset()
706 && !owner->view()->theLockingInset()->insetAllowed(code)) {
711 flag |= func_status::Disabled;
713 // the font related functions
714 func_status::value_type box = func_status::ToggleOff;
715 LyXFont const & font =
716 TEXT(false)->real_current_font;
719 if (font.emph() == LyXFont::ON)
720 box = func_status::ToggleOn;
723 if (font.noun() == LyXFont::ON)
724 box = func_status::ToggleOn;
727 if (font.series() == LyXFont::BOLD_SERIES)
728 box = func_status::ToggleOn;
732 if (font.latex() == LyXFont::ON)
733 box = func_status::ToggleOn;
736 case LFUN_READ_ONLY_TOGGLE:
737 if (buf->isReadonly())
738 box = func_status::ToggleOn;
741 box = func_status::OK;
750 // temporary dispatch method
751 void LyXFunc::miniDispatch(string const & s)
759 string const LyXFunc::dispatch(string const & s)
761 // Split command string into command and argument
763 string line = frontStrip(s);
764 string const arg = strip(frontStrip(split(line, cmd, ' ')));
766 return dispatch(lyxaction.LookupFunc(cmd), arg);
770 string const LyXFunc::dispatch(int ac,
771 string const & do_not_use_this_arg)
773 lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << ac
774 <<"] arg[" << do_not_use_this_arg << "]" << endl;
779 // we have not done anything wrong yet.
781 dispatch_buffer.erase();
783 // if action is a pseudo-action, we need the real action
784 if (lyxaction.isPseudoAction(ac)) {
786 action = static_cast<kb_action>
787 (lyxaction.retrieveActionArg(ac, tmparg));
791 action = static_cast<kb_action>(ac);
792 if (!do_not_use_this_arg.empty())
793 argument = do_not_use_this_arg; // except here
796 #ifdef NEW_DISPATCHER
797 // We try do call the most specific dispatcher first:
798 // 1. the lockinginset's dispatch
799 // 2. the bufferview's dispatch
800 // 3. the lyxview's dispatch
803 selection_possible = false;
805 if (owner->view()->available())
806 owner->view()->hideCursor();
808 // We cannot use this function here
809 if (getStatus(ac, do_not_use_this_arg) & func_status::Disabled) {
810 lyxerr << "LyXFunc::Dispatch: "
811 << lyxaction.getActionName(ac)
812 << " [" << ac << "] is disabled ad this location"
814 goto exit_with_message;
817 if (owner->view()->available() && owner->view()->theLockingInset()) {
818 UpdatableInset::RESULT result;
819 if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
820 (keyseq.length >= -1)))
822 if ((action==LFUN_UNKNOWN_ACTION) && argument.empty()){
823 argument = keyseq.getiso();
825 // Undo/Redo is a bit tricky for insets.
826 if (action == LFUN_UNDO) {
827 #ifdef RETHINK_THIS_FOR_NOW_WE_LEAVE_ALL_UNLOCKED
830 UpdatableInset * inset =
831 owner->view()->theLockingInset()->getLockingInset();
832 int inset_id = inset->id();
833 inset->getCursorPos(owner->view(), slx, sly);
834 owner->view()->unlockInset(inset);
836 owner->view()->unlockInset(owner->view()->theLockingInset());
838 owner->view()->menuUndo();
839 #ifdef RETHINK_THIS_FOR_NOW_WE_LEAVE_ALL_UNLOCKED
841 if (TEXT()->cursor.par()->
842 isInset(TEXT()->cursor.pos())) {
843 inset = static_cast<UpdatableInset*>(
844 TEXT()->cursor.par()->
851 inset = static_cast<UpdatableInset *>(owner->view()->buffer()->getInsetFromID(inset_id));
854 inset->edit(owner->view(),slx,sly,0);
857 } else if (action == LFUN_REDO) {
860 UpdatableInset * inset = owner->view()->
862 inset->getCursorPos(owner->view(), slx, sly);
863 owner->view()->unlockInset(inset);
864 owner->view()->menuRedo();
865 inset = static_cast<UpdatableInset*>(
866 TEXT()->cursor.par()->
870 inset->edit(owner->view(),slx,sly,0);
872 } else if (((result=owner->view()->theLockingInset()->
873 localDispatch(owner->view(), action,
875 UpdatableInset::DISPATCHED) ||
876 (result == UpdatableInset::DISPATCHED_NOUPDATE))
879 //setMessage(N_("Text mode"));
881 case LFUN_UNKNOWN_ACTION:
882 case LFUN_BREAKPARAGRAPH:
884 TEXT()->cursorRight(owner->view());
885 owner->view()->setState();
889 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
890 TEXT()->cursorRight(owner->view());
891 moveCursorUpdate(true, false);
896 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
897 TEXT()->cursorRight(owner->view());
898 moveCursorUpdate(true, false);
903 if (TEXT()->cursor.row()->next())
904 TEXT()->cursorDown(owner->view());
906 TEXT()->cursorRight(owner->view());
907 moveCursorUpdate(true, false);
917 lyx::Assert(action != LFUN_SELECT_FILE_SYNC);
923 if (!owner->view()->available()) break;
925 // this function should be used always [asierra060396]
926 UpdatableInset * tli =
927 owner->view()->theLockingInset();
929 UpdatableInset * lock = tli->getLockingInset();
932 owner->view()->unlockInset(tli);
933 TEXT()->cursorRight(owner->view());
934 moveCursorUpdate(true, false);
937 tli->unlockInsetInInset(owner->view(),
945 // --- Misc -------------------------------------------
946 case LFUN_WORDFINDFORWARD :
947 case LFUN_WORDFINDBACKWARD : {
948 static string last_search;
949 string searched_string;
951 if (!argument.empty()) {
952 last_search = argument;
953 searched_string = argument;
955 searched_string = last_search;
957 bool fw = (action == LFUN_WORDFINDBACKWARD);
958 if (!searched_string.empty()) {
959 LyXFind(owner->view(), searched_string, fw);
961 // owner->view()->showCursor();
967 if (owner->view()->available() && !owner->view()->theLockingInset()) {
968 owner->view()->update(TEXT(),
969 BufferView::SELECT|BufferView::FITCUR);
972 keyseq.print(buf, true);
977 // --- Misc -------------------------------------------
978 case LFUN_EXEC_COMMAND:
980 std::vector<string> allCmds;
981 std::transform(lyxaction.func_begin(), lyxaction.func_end(),
982 std::back_inserter(allCmds), lyx::firster());
983 static std::vector<string> hist;
984 owner->getMiniBuffer()->getString(MiniBuffer::spaces,
989 case LFUN_CANCEL: // RVDK_PATCH_5
992 if (owner->view()->available())
993 // cancel any selection
994 dispatch(LFUN_MARK_OFF);
995 setMessage(N_("Cancel"));
998 case LFUN_META_FAKE: // RVDK_PATCH_5
1000 meta_fake_bit = Mod1Mask;
1002 keyseq.print(buf, true);
1003 setMessage(buf); // RVDK_PATCH_5
1007 case LFUN_READ_ONLY_TOGGLE:
1008 if (owner->buffer()->lyxvc.inUse()) {
1009 owner->buffer()->lyxvc.toggleReadOnly();
1011 owner->buffer()->setReadonly(
1012 !owner->buffer()->isReadonly());
1016 case LFUN_CENTER: // this is center and redraw.
1017 owner->view()->center();
1020 // --- Menus -----------------------------------------------
1025 case LFUN_MENUNEWTMPLT:
1029 case LFUN_CLOSEBUFFER:
1033 case LFUN_MENUWRITE:
1034 if (!owner->buffer()->isUnnamed()) {
1036 s1 << _("Saving document") << ' '
1037 << MakeDisplayPath(owner->buffer()->fileName() + "...");
1038 owner->message(s1.str().c_str());
1039 MenuWrite(owner->view(), owner->buffer());
1041 WriteAs(owner->view(), owner->buffer());
1045 WriteAs(owner->view(), owner->buffer(), argument);
1048 case LFUN_MENURELOAD:
1053 Exporter::Export(owner->buffer(), argument, true);
1057 Exporter::Preview(owner->buffer(), argument);
1060 case LFUN_BUILDPROG:
1061 Exporter::Export(owner->buffer(), "program", true);
1064 case LFUN_RUNCHKTEX:
1065 MenuRunChktex(owner->buffer());
1068 case LFUN_MENUPRINT:
1069 owner->getDialogs()->showPrint();
1073 if (argument == "custom")
1076 Exporter::Export(owner->buffer(), argument, false);
1094 InsetCommandParams p;
1097 if (action == LFUN_TOCVIEW)
1099 p.setCmdName("tableofcontents");
1101 else if (action == LFUN_LOAVIEW )
1102 p.setCmdName("listof{algorithm}{List of Algorithms}");
1103 else if (action == LFUN_LOFVIEW)
1104 p.setCmdName("listoffigures");
1106 p.setCmdName("listoftables");
1108 owner->getDialogs()->createTOC(p.getAsString());
1112 case LFUN_DIALOG_TABULAR_INSERT:
1113 owner->getDialogs()->showTabularCreate();
1121 AutoSave(owner->view());
1125 owner->view()->menuUndo();
1129 owner->view()->menuRedo();
1132 case LFUN_MENUSEARCH:
1133 owner->getDialogs()->showSearch();
1136 case LFUN_REMOVEERRORS:
1137 if (owner->view()->removeAutoInsets()) {
1138 owner->view()->redraw();
1139 owner->view()->fitCursor(TEXT());
1144 changeDepth(owner->view(), TEXT(false), 0);
1147 case LFUN_DEPTH_MIN:
1148 changeDepth(owner->view(), TEXT(false), -1);
1151 case LFUN_DEPTH_PLUS:
1152 changeDepth(owner->view(), TEXT(false), 1);
1156 owner->getDialogs()->setUserFreeFont();
1162 owner->view()->setState();
1167 case LFUN_RECONFIGURE:
1168 Reconfigure(owner->view());
1172 case LFUN_FLOATSOPERATE:
1173 if (argument == "openfoot")
1174 owner->view()->allFloats(1,0);
1175 else if (argument == "closefoot")
1176 owner->view()->allFloats(0,0);
1177 else if (argument == "openfig")
1178 owner->view()->allFloats(1,1);
1179 else if (argument == "closefig")
1180 owner->view()->allFloats(0,1);
1183 #ifdef WITH_WARNINGS
1184 #warning Find another implementation here (or another lyxfunc)!
1187 case LFUN_HELP_ABOUTLYX:
1188 owner->getDialogs()->showAboutlyx();
1191 case LFUN_HELP_COPYRIGHT:
1192 case LFUN_HELP_CREDITS:
1195 case LFUN_HELP_OPEN:
1197 string const arg = argument;
1199 setErrorMessage(N_("Missing argument"));
1202 owner->prohibitInput();
1203 string const fname = i18nLibFileSearch("doc", arg, "lyx");
1204 if (fname.empty()) {
1205 lyxerr << "LyX: unable to find documentation file `"
1206 << arg << "'. Bad installation?" << endl;
1207 owner->allowInput();
1211 str << _("Opening help file") << ' '
1212 << MakeDisplayPath(fname) << "...";
1213 owner->message(str.str().c_str());
1214 owner->view()->buffer(bufferlist.loadLyXFile(fname, false));
1215 owner->allowInput();
1219 case LFUN_HELP_VERSION:
1221 // --- version control -------------------------------
1222 case LFUN_VC_REGISTER:
1224 if (!owner->buffer()->lyxvc.inUse())
1225 owner->buffer()->lyxvc.registrer();
1229 case LFUN_VC_CHECKIN:
1231 if (owner->buffer()->lyxvc.inUse()
1232 && !owner->buffer()->isReadonly())
1233 owner->buffer()->lyxvc.checkIn();
1237 case LFUN_VC_CHECKOUT:
1239 if (owner->buffer()->lyxvc.inUse()
1240 && owner->buffer()->isReadonly())
1241 owner->buffer()->lyxvc.checkOut();
1245 case LFUN_VC_REVERT:
1247 owner->buffer()->lyxvc.revert();
1253 owner->buffer()->lyxvc.undoLast();
1257 case LFUN_VC_HISTORY:
1259 owner->getDialogs()->showVCLogFile();
1263 // --- buffers ----------------------------------------
1265 case LFUN_SWITCHBUFFER:
1266 owner->view()->buffer(bufferlist.getBuffer(argument));
1271 // servercmd: argument must be <file>:<template>
1272 Buffer * tmpbuf = NewLyxFile(argument);
1274 owner->view()->buffer(tmpbuf);
1278 case LFUN_FILE_OPEN:
1282 case LFUN_LATEX_LOG:
1283 owner->getDialogs()->showLogFile();
1288 lyxerr[Debug::INFO] << "LFUN_LAYOUTNO: (arg) " << argument << endl;
1289 int sel = strToInt(argument);
1290 lyxerr[Debug::INFO] << "LFUN_LAYOUTNO: (sel) "<< sel << endl;
1292 // Should this give a setMessage instead?
1294 return string(); // illegal argument
1296 --sel; // sel 1..., but layout 0...
1298 // Pretend we got the name instead.
1299 dispatch(int(LFUN_LAYOUT),
1300 textclasslist.NameOfLayout(owner->view()
1301 ->buffer()->params.textclass,
1306 case LFUN_LAYOUT_DOCUMENT:
1307 owner->getDialogs()->showDocument();
1310 case LFUN_LAYOUT_PARAGRAPH:
1311 owner->getDialogs()->showParagraph();
1314 case LFUN_LAYOUT_CHARACTER:
1315 owner->getDialogs()->showCharacter();
1318 case LFUN_LAYOUT_TABULAR:
1319 if (owner->view()->theLockingInset()) {
1320 if (owner->view()->theLockingInset()->lyxCode()==Inset::TABULAR_CODE) {
1321 InsetTabular * inset = static_cast<InsetTabular *>
1322 (owner->view()->theLockingInset());
1323 inset->openLayoutDialog(owner->view());
1324 } else if (owner->view()->theLockingInset()->
1325 getFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
1326 InsetTabular * inset = static_cast<InsetTabular *>(
1327 owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
1328 inset->openLayoutDialog(owner->view());
1333 case LFUN_LAYOUT_PREAMBLE:
1334 owner->getDialogs()->showPreamble();
1337 case LFUN_LAYOUT_SAVE_DEFAULT:
1338 MenuLayoutSave(owner->view());
1341 case LFUN_DROP_LAYOUTS_CHOICE:
1342 owner->getToolbar()->openLayoutList();
1345 case LFUN_MENU_OPEN_BY_NAME:
1346 owner->getMenubar()->openByName(argument);
1347 break; // RVDK_PATCH_5
1349 case LFUN_SPELLCHECK:
1350 if (lyxrc.isp_command != "none")
1351 owner->getDialogs()->showSpellchecker();
1354 // --- lyxserver commands ----------------------------
1358 setMessage(owner->buffer()->fileName());
1359 lyxerr[Debug::INFO] << "FNAME["
1360 << owner->buffer()->fileName()
1368 dispatch_buffer = buf;
1369 lyxserver->notifyClient(dispatch_buffer);
1373 case LFUN_GOTOFILEROW:
1376 char file_name[100];
1378 ::sscanf(argument.c_str(), " %s %d", file_name, &row);
1382 istringstream istr(argument.c_str());
1383 istr >> file_name >> row;
1385 // Must replace extension of the file to be .lyx and get full path
1386 string const s(ChangeExtension(file_name, ".lyx"));
1388 // Either change buffer or load the file
1389 if (bufferlist.exists(s)) {
1390 owner->view()->buffer(bufferlist.getBuffer(s));
1392 owner->view()->buffer(bufferlist.loadLyXFile(s));
1396 owner->view()->setCursorFromRow(row);
1399 owner->view()->center();
1403 case LFUN_GOTO_PARAGRAPH:
1405 istringstream istr(argument.c_str());
1409 Paragraph * par = owner->buffer()->getParFromID(id);
1411 lyxerr[Debug::INFO] << "No matching paragraph found! ["
1412 << id << "]" << std::endl;
1417 TEXT()->setCursor(owner->view(), par, 0);
1418 owner->view()->setState();
1422 owner->view()->center();
1429 int const qa = lyxaction.LookupFunc(argument);
1430 setMessage(lyxaction.helpText(static_cast<kb_action>(qa)));
1434 // --- toolbar ----------------------------------
1435 case LFUN_PUSH_TOOLBAR:
1437 int nth = strToInt(argument);
1439 setErrorMessage(N_("Push-toolbar needs argument > 0"));
1441 owner->getToolbar()->push(nth);
1446 case LFUN_ADD_TO_TOOLBAR:
1448 if (lyxerr.debugging(Debug::GUI)) {
1449 lyxerr << "LFUN_ADD_TO_TOOLBAR:"
1450 "argument = `" << argument << '\'' << endl;
1452 string tmp(argument);
1453 //lyxerr <<string("Argument: ") + argument);
1454 //lyxerr <<string("Tmp : ") + tmp);
1456 setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
1458 owner->getToolbar()->add(argument, false);
1459 owner->getToolbar()->set();
1464 // --- insert characters ----------------------------------------
1466 // --- Mathed stuff. If we are here, there is no locked inset yet.
1471 if (!greek_kb_flag) {
1473 setMessage(N_("Math greek mode on"));
1480 case LFUN_GREEK_TOGGLE:
1482 greek_kb_flag = greek_kb_flag ? 0 : 2;
1483 if (greek_kb_flag) {
1484 setMessage(N_("Math greek keyboard on"));
1486 setMessage(N_("Math greek keyboard off"));
1491 case LFUN_MATH_EXTERN:
1492 case LFUN_MATH_NUMBER:
1493 case LFUN_MATH_NONUMBER:
1494 case LFUN_MATH_LIMITS:
1496 setErrorMessage(N_("This is only allowed in math mode!"));
1500 case LFUN_MATH_PANEL:
1501 owner->getDialogs()->showMathPanel();
1504 case LFUN_CITATION_CREATE:
1506 InsetCommandParams p( "cite" );
1508 if (!argument.empty()) {
1509 // This should be set at source, ie when typing
1510 // "citation-insert foo" in the minibuffer.
1511 // Question: would pybibliographer also need to be
1512 // changed. Suspect so. Leave as-is therefore.
1513 if (contains(argument, "|")) {
1514 p.setContents( token(argument, '|', 0) );
1515 p.setOptions( token(argument, '|', 1) );
1517 p.setContents( argument );
1519 dispatch(LFUN_CITATION_INSERT, p.getAsString());
1521 owner->getDialogs()->createCitation( p.getAsString() );
1525 case LFUN_CHILDOPEN:
1527 string const filename =
1528 MakeAbsPath(argument,
1529 OnlyPath(owner->buffer()->fileName()));
1530 setMessage(N_("Opening child document ") +
1531 MakeDisplayPath(filename) + "...");
1532 owner->view()->savePosition(0);
1533 if (bufferlist.exists(filename))
1534 owner->view()->buffer(bufferlist.getBuffer(filename));
1536 owner->view()->buffer(bufferlist.loadLyXFile(filename));
1540 case LFUN_TOGGLECURSORFOLLOW:
1541 lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
1544 case LFUN_KMAP_OFF: // keymap off
1545 owner->getIntl()->KeyMapOn(false);
1548 case LFUN_KMAP_PRIM: // primary keymap
1549 owner->getIntl()->KeyMapPrim();
1552 case LFUN_KMAP_SEC: // secondary keymap
1553 owner->getIntl()->KeyMapSec();
1556 case LFUN_KMAP_TOGGLE: // toggle keymap
1557 owner->getIntl()->ToggleKeyMap();
1562 // argument contains ';'-terminated commands
1563 while (argument.find(';') != string::npos) {
1565 argument = split(argument, first, ';');
1571 case LFUN_DIALOG_PREFERENCES:
1572 owner->getDialogs()->showPreferences();
1575 case LFUN_SAVEPREFERENCES:
1577 Path p(user_lyxdir);
1578 lyxrc.write("preferences");
1582 case LFUN_SCREEN_FONT_UPDATE:
1584 // handle the screen font changes.
1586 lyxrc.set_font_norm_type();
1587 fontloader.update();
1588 // Of course we should only do the resize and the textcache.clear
1589 // if values really changed...but not very important right now. (Lgb)
1590 // All visible buffers will need resize
1592 // We also need to empty the textcache so that
1593 // the buffer will be formatted correctly after
1599 case LFUN_SET_COLOR:
1602 string const x11_name = split(argument, lyx_name, ' ');
1603 if (lyx_name.empty() || x11_name.empty()) {
1604 setErrorMessage(N_("Syntax: set-color <lyx_name>"
1609 if (!lcolor.setColor(lyx_name, x11_name)) {
1610 static string const err1 (N_("Set-color \""));
1611 static string const err2 (
1612 N_("\" failed - color is undefined "
1613 "or may not be redefined"));
1614 setErrorMessage(_(err1) + lyx_name + _(err2));
1617 lyxColorHandler->updateColor(lcolor.getFromLyXName(lyx_name));
1618 owner->view()->redraw();
1623 owner->message(argument);
1626 case LFUN_MESSAGE_PUSH:
1627 owner->messagePush(argument);
1630 case LFUN_MESSAGE_POP:
1631 owner->messagePop();
1635 // Then if it was none of the above
1636 if (!owner->view()->Dispatch(action, argument))
1637 lyxerr << "A truly unknown func ["
1638 << lyxaction.getActionName(action) << "]!"
1645 commandshortcut.erase();
1647 if (lyxrc.display_shortcuts && show_sc) {
1648 if (action != LFUN_SELFINSERT) {
1649 // Put name of command and list of shortcuts
1650 // for it in minibuffer
1651 string comname = lyxaction.getActionName(action);
1653 int pseudoaction = action;
1654 bool argsadded = false;
1656 if (!argument.empty()) {
1657 // If we have the command with argument,
1660 lyxaction.searchActionArg(action,
1663 if (pseudoaction == -1) {
1664 pseudoaction = action;
1666 comname += " " + argument;
1671 string const shortcuts =
1672 toplevel_keymap->findbinding(pseudoaction);
1674 if (!shortcuts.empty()) {
1675 comname += ": " + shortcuts;
1676 } else if (!argsadded) {
1677 comname += " " + argument;
1680 if (!comname.empty()) {
1681 comname = strip(comname);
1682 commandshortcut = "(" + comname + ')';
1684 // Here we could even add a small pause,
1685 // to annoy the user and make him learn
1687 // No! That will just annoy, not teach
1688 // anything. The user will read the messages
1689 // if they are interested. (Asger)
1694 string const res = getMessage();
1697 if (!commandshortcut.empty()) {
1698 owner->getMiniBuffer()->addSet(commandshortcut);
1701 string const msg(_(res) + ' ' + commandshortcut);
1702 owner->message(msg);
1709 void LyXFunc::setupLocalKeymap()
1711 keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
1712 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap.get();
1716 void LyXFunc::menuNew(bool fromTemplate)
1718 string initpath = lyxrc.document_path;
1720 if (owner->view()->available()) {
1721 string const trypath = owner->buffer()->filepath;
1722 // If directory is writeable, use this as default.
1723 if (IsDirWriteable(trypath) == 1)
1727 static int newfile_number;
1730 if (lyxrc.new_ask_filename) {
1731 FileDialog fileDlg(owner, _("Enter filename for new document"),
1732 LFUN_SELECT_FILE_SYNC,
1733 make_pair(string(_("Documents")),
1734 string(lyxrc.document_path)),
1735 make_pair(string(_("Templates")),
1736 string(lyxrc.template_path)));
1738 FileDialog::Result result =
1739 fileDlg.Select(initpath,
1740 _("*.lyx|LyX Documents (*.lyx)"),
1743 if (result.second.empty()) {
1744 owner->message(_("Canceled."));
1745 lyxerr[Debug::INFO] << "New Document Cancelled." << endl;
1749 // get absolute path of file and make sure the filename ends
1751 s = MakeAbsPath(result.second);
1752 if (!IsLyXFilename(s))
1755 // Check if the document already is open
1756 if (bufferlist.exists(s)) {
1757 switch (AskConfirmation(_("Document is already open:"),
1758 MakeDisplayPath(s, 50),
1759 _("Do you want to close that document now?\n"
1760 "('No' will just switch to the open version)")))
1762 case 1: // Yes: close the document
1763 if (!bufferlist.close(bufferlist.getBuffer(s)))
1764 // If close is canceled, we cancel here too.
1767 case 2: // No: switch to the open document
1768 owner->view()->buffer(bufferlist.getBuffer(s));
1770 case 3: // Cancel: Do nothing
1771 owner->message(_("Canceled."));
1775 // Check whether the file already exists
1777 if (fi.readable() &&
1778 AskQuestion(_("File already exists:"),
1779 MakeDisplayPath(s, 50),
1780 _("Do you want to open the document?"))) {
1782 string const disp_fn(MakeDisplayPath(s));
1785 str << _("Opening document") << ' '
1786 << disp_fn << "...";
1788 owner->message(str.str().c_str());
1789 //XFlush(fl_get_display());
1790 owner->view()->buffer(bufferlist.loadLyXFile(s));
1792 str2 << _("Document") << ' '
1793 << disp_fn << ' ' << _("opened.");
1795 owner->message(str2.str().c_str());
1800 s = AddName(lyxrc.document_path,
1801 "newfile" + tostr(++newfile_number) + ".lyx");
1803 while (bufferlist.exists(s) || fi.readable()) {
1805 s = AddName(lyxrc.document_path,
1806 "newfile" + tostr(newfile_number) +
1812 // The template stuff
1815 FileDialog fileDlg(owner, _("Select template file"),
1816 LFUN_SELECT_FILE_SYNC,
1817 make_pair(string(_("Documents")),
1818 string(lyxrc.document_path)),
1819 make_pair(string(_("Templates")),
1820 string(lyxrc.template_path)));
1822 FileDialog::Result result =
1823 fileDlg.Select(lyxrc.template_path,
1824 _("*.lyx|LyX Documents (*.lyx)"));
1826 if (result.first == FileDialog::Later)
1829 string const fname = result.second;
1836 // find a free buffer
1837 lyxerr[Debug::INFO] << "Find a free buffer." << endl;
1838 owner->view()->buffer(bufferlist.newFile(s, templname));
1842 void LyXFunc::open(string const & fname)
1844 string initpath = lyxrc.document_path;
1846 if (owner->view()->available()) {
1847 string const trypath = owner->buffer()->filepath;
1848 // If directory is writeable, use this as default.
1849 if (IsDirWriteable(trypath) == 1)
1855 if (fname.empty()) {
1856 FileDialog fileDlg(owner, _("Select document to open"),
1858 make_pair(string(_("Documents")),
1859 string(lyxrc.document_path)),
1860 make_pair(string(_("Examples")),
1861 string(AddPath(system_lyxdir, "examples"))));
1863 FileDialog::Result result =
1864 fileDlg.Select(initpath,
1865 "*.lyx|LyX Documents (*.lyx)");
1867 if (result.first == FileDialog::Later)
1870 filename = result.second;
1872 // check selected filename
1873 if (filename.empty()) {
1874 owner->message(_("Canceled."));
1880 // get absolute path of file and add ".lyx" to the filename if
1882 filename = FileSearch(string(), filename, "lyx");
1885 string const disp_fn(MakeDisplayPath(filename));
1888 str << _("Opening document") << ' ' << disp_fn << "...";
1890 owner->message(str.str().c_str());
1892 Buffer * openbuf = bufferlist.loadLyXFile(filename);
1894 owner->view()->buffer(openbuf);
1896 str << _("Document") << ' ' << disp_fn << ' ' << _("opened.");
1897 owner->message(str.str().c_str());
1900 str << _("Could not open docuent") << ' ' << disp_fn;
1901 owner->message(str.str().c_str());
1906 // checks for running without gui are missing.
1907 void LyXFunc::doImport(string const & argument)
1910 string filename = split(argument, format, ' ');
1911 lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format
1912 << " file: " << filename << endl;
1914 if (filename.empty()) { // need user interaction
1915 string initpath = lyxrc.document_path;
1917 if (owner->view()->available()) {
1918 string const trypath = owner->buffer()->filepath;
1919 // If directory is writeable, use this as default.
1920 if (IsDirWriteable(trypath) == 1)
1924 string const text = _("Select ") + formats.PrettyName(format)
1925 + _(" file to import");
1927 FileDialog fileDlg(owner, text,
1929 make_pair(string(_("Documents")),
1930 string(lyxrc.document_path)),
1931 make_pair(string(_("Examples")),
1932 string(AddPath(system_lyxdir, "examples"))));
1934 string const extension = "*." + formats.Extension(format)
1935 + "| " + formats.PrettyName(format)
1936 + " (*." + formats.Extension(format) + ")";
1938 FileDialog::Result result = fileDlg.Select(initpath,
1941 if (result.first == FileDialog::Later)
1944 filename = result.second;
1946 // check selected filename
1947 if (filename.empty())
1948 owner->message(_("Canceled."));
1951 // still no filename? abort
1952 if (filename.empty())
1955 // get absolute path of file
1956 filename = MakeAbsPath(filename);
1958 string const lyxfile = ChangeExtension(filename, ".lyx");
1960 // Check if the document already is open
1961 if (bufferlist.exists(lyxfile)) {
1962 switch (AskConfirmation(_("Document is already open:"),
1963 MakeDisplayPath(lyxfile, 50),
1964 _("Do you want to close that document now?\n"
1965 "('No' will just switch to the open version)")))
1967 case 1: // Yes: close the document
1968 if (!bufferlist.close(bufferlist.getBuffer(lyxfile)))
1969 // If close is canceled, we cancel here too.
1972 case 2: // No: switch to the open document
1973 owner->view()->buffer(bufferlist.getBuffer(lyxfile));
1975 case 3: // Cancel: Do nothing
1976 owner->message(_("Canceled."));
1981 // Check if a LyX document by the same root exists in filesystem
1982 FileInfo const f(lyxfile, true);
1983 if (f.exist() && !AskQuestion(_("A document by the name"),
1984 MakeDisplayPath(lyxfile),
1985 _("already exists. Overwrite?"))) {
1986 owner->message(_("Canceled"));
1989 // filename should be valid now
1991 Importer::Import(owner, filename, format);
1995 void LyXFunc::reloadBuffer()
1997 string const fn = owner->buffer()->fileName();
1998 if (bufferlist.close(owner->buffer()))
1999 owner->view()->buffer(bufferlist.loadLyXFile(fn));
2003 void LyXFunc::closeBuffer()
2005 if (bufferlist.close(owner->buffer()) && !quitting) {
2006 if (bufferlist.empty()) {
2007 // need this otherwise SEGV may occur while trying to
2008 // set variables that don't exist
2009 // since there's no current buffer
2010 owner->getDialogs()->hideBufferDependent();
2012 owner->view()->buffer(bufferlist.first());
2018 // Each "owner" should have it's own message method. lyxview and
2019 // the minibuffer would use the minibuffer, but lyxserver would
2020 // send an ERROR signal to its client. Alejandro 970603
2021 // This func is bit problematic when it comes to NLS, to make the
2022 // lyx servers client be language indepenent we must not translate
2023 // strings sent to this func.
2024 void LyXFunc::setErrorMessage(string const & m) const
2026 dispatch_buffer = m;
2031 void LyXFunc::setMessage(string const & m)
2033 dispatch_buffer = m;
2037 void LyXFunc::initMiniBuffer()
2039 string text = _("Welcome to LyX!");
2041 // When meta-fake key is pressed, show the key sequence so far + "M-".
2047 // Else, when a non-complete key sequence is pressed,
2048 // show the available options.
2049 else if (keyseqUncomplete())
2050 text = keyseqOptions();
2052 // Else, show the buffer state.
2053 else if (owner->view()->available()) {
2054 Buffer * tmpbuf = owner->buffer();
2056 string const nicename =
2057 MakeDisplayPath(tmpbuf->fileName());
2058 // Should we do this instead? (kindo like emacs)
2059 // leaves more room for other information
2062 if (tmpbuf->lyxvc.inUse()) {
2064 text += tmpbuf->lyxvc.version();
2066 text += tmpbuf->lyxvc.locker();
2067 if (tmpbuf->isReadonly())
2070 } else if (tmpbuf->isReadonly())
2072 if (!tmpbuf->isLyxClean())
2073 text += _(" (Changed)");
2075 if (text != _("Welcome to LyX!")) // this is a hack
2076 text = _("* No document open *");
2079 owner->message(text);