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 =========================================================== */
162 LyXFunc::LyXFunc(LyXView * o)
164 keyseq(toplevel_keymap.get(), toplevel_keymap.get()),
165 cancel_meta_seq(toplevel_keymap.get(), toplevel_keymap.get())
168 lyx_dead_action = LFUN_NOACTION;
169 lyx_calling_dead_action = LFUN_NOACTION;
174 LyXText * LyXFunc::TEXT(bool flag = true) const
177 return owner->view()->text;
178 return owner->view()->getLyXText();
182 // I changed this func slightly. I commented out the ...FinishUndo(),
183 // this means that all places that used to have a moveCursorUpdate, now
184 // have a ...FinishUndo() as the preceeding statement. I have also added
185 // a moveCursorUpdate to some of the functions that updated the cursor, but
186 // that did not show its new position.
188 void LyXFunc::moveCursorUpdate(bool flag, bool selecting)
190 if (selecting || TEXT(flag)->selection.mark()) {
191 TEXT(flag)->setSelection(owner->view());
192 if (TEXT(flag)->bv_owner)
193 owner->view()->toggleToggle();
195 owner->view()->update(TEXT(flag), BufferView::SELECT|BufferView::FITCUR);
196 owner->view()->showCursor();
198 /* ---> Everytime the cursor is moved, show the current font state. */
199 // should this too me moved out of this func?
200 owner->view()->setState();
204 void LyXFunc::handleKeyFunc(kb_action action)
206 char c = keyseq.getiso();
208 if (keyseq.length() > 1) {
212 owner->getIntl()->getTrans()
213 .deadkey(c, get_accent(action).accent, TEXT(false));
214 // Need to clear, in case the minibuffer calls these
217 // copied verbatim from do_accent_char
218 owner->view()->update(TEXT(false),
219 BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
220 TEXT(false)->selection.cursor = TEXT(false)->cursor;
224 void LyXFunc::processKeySym(KeySym keysym, unsigned int state)
228 if (lyxerr.debugging(Debug::KEY)) {
229 char const * tmp = XKeysymToString(keysym);
230 string const stm = (tmp ? tmp : "");
231 lyxerr << "KeySym is "
234 << keysym << "] State is ["
238 // Do nothing if we have nothing (JMarc)
239 if (keysym == NoSymbol) {
240 lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
245 // Can we be sure that this will work for all X Window
246 // implementations? (Lgb)
247 // This code snippet makes lyx ignore some keys. Perhaps
248 // all of them should be explictly mentioned?
249 if ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
250 || keysym == XK_Mode_switch || keysym == 0x0) {
254 // Do a one-deep top-level lookup for
255 // cancel and meta-fake keys. RVDK_PATCH_5
256 cancel_meta_seq.reset();
258 int action = cancel_meta_seq.addkey(keysym, state
259 &(ShiftMask|ControlMask
261 if (lyxerr.debugging(Debug::KEY)) {
262 lyxerr << "action first set to [" << action << "]" << endl;
265 // When not cancel or meta-fake, do the normal lookup.
266 // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
267 // Mostly, meta_fake_bit = 0. RVDK_PATCH_5.
268 if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
269 if (lyxerr.debugging(Debug::KEY)) {
270 lyxerr << "meta_fake_bit is ["
271 << meta_fake_bit << "]" << endl;
273 // remove Caps Lock and Mod2 as a modifiers
274 action = keyseq.addkey(keysym,
275 (state | meta_fake_bit)
276 &(ShiftMask|ControlMask
278 if (lyxerr.debugging(Debug::KEY)) {
279 lyxerr << "action now set to ["
280 << action << "]" << endl;
283 // Dont remove this unless you know what you are doing.
286 // can this happen now ?
287 if (action == LFUN_NOACTION) {
288 action = LFUN_PREFIX;
291 if (lyxerr.debugging(Debug::KEY)) {
292 lyxerr << "Key [action="
294 << keyseq.print() << "]"
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.deleted()) {
303 owner->message(keyseq.print());
306 if (action == LFUN_UNKNOWN_ACTION) {
307 // It is unknown, but what if we remove all
308 // the modifiers? (Lgb)
309 action = keyseq.addkey(keysym, 0);
311 if (lyxerr.debugging(Debug::KEY)) {
312 lyxerr << "Removing modifiers...\n"
313 << "Action now set to ["
314 << action << "]" << endl;
316 if (action == LFUN_UNKNOWN_ACTION) {
317 owner->message(_("Unknown function."));
322 if (action == LFUN_SELFINSERT) {
323 // This is very X dependent.
324 unsigned int c = keysym;
327 c = kb_keymap::getiso(c);
330 argument = static_cast<char>(c);
332 dispatch(LFUN_SELFINSERT, argument);
333 lyxerr[Debug::KEY] << "SelfInsert arg[`"
334 << argument << "']" << endl;
337 verboseDispatch(action, false);
341 FuncStatus LyXFunc::getStatus(int ac) const
345 action = lyxaction.retrieveActionArg(ac, argument);
346 return getStatus(action, argument);
350 FuncStatus LyXFunc::getStatus(kb_action action,
351 string const & argument) const
354 Buffer * buf = owner->buffer();
356 if (action == LFUN_UNKNOWN_ACTION) {
357 setErrorMessage(N_("Unknown action"));
358 return flag.unknown(true);
361 // Check whether we need a buffer
362 if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) {
363 // Yes we need a buffer, do we have one?
366 // Can we use a readonly buffer?
367 if (buf->isReadonly() &&
368 !lyxaction.funcHasFlag(action,
369 LyXAction::ReadOnly)) {
371 setErrorMessage(N_("Document is read-only"));
376 setErrorMessage(N_("Command not allowed with"
377 "out any document open"));
378 return flag.disabled(true);
382 // I would really like to avoid having this switch and rather try to
383 // encode this in the function itself.
384 bool disable = false;
387 disable = !Exporter::IsExportable(buf, "dvi")
388 || lyxrc.print_command == "none";
391 disable = argument == "fax" &&
392 !Exporter::IsExportable(buf, argument);
395 disable = buf->undostack.empty();
398 disable = buf->redostack.empty();
400 case LFUN_SPELLCHECK:
401 disable = lyxrc.isp_command == "none";
403 #ifndef HAVE_LIBAIKSAURUS
404 case LFUN_THESAURUS_ENTRY:
409 disable = lyxrc.chktex_command == "none";
412 disable = !Exporter::IsExportable(buf, "program");
415 case LFUN_LAYOUT_TABULAR:
417 if (owner->view()->theLockingInset()) {
418 disable = (owner->view()->theLockingInset()->lyxCode() != Inset::TABULAR_CODE) &&
419 !owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE);
423 case LFUN_TABULAR_FEATURE:
425 if (owner->view()->theLockingInset()) {
427 //ret.disabled(true);
428 if (owner->view()->theLockingInset()->lyxCode() == Inset::TABULAR_CODE) {
429 ret = static_cast<InsetTabular *>
430 (owner->view()->theLockingInset())->
432 } else if (owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
433 ret = static_cast<InsetTabular *>
434 (owner->view()->theLockingInset()->
435 getFirstLockingInsetOfType(Inset::TABULAR_CODE))->
441 static InsetTabular inset(*owner->buffer(), 1, 1);
445 ret = inset.getStatus(argument);
446 if (ret.onoff(true) || ret.onoff(false)) flag.setOnOff(false);
450 case LFUN_VC_REGISTER:
451 disable = buf->lyxvc.inUse();
453 case LFUN_VC_CHECKIN:
454 disable = !buf->lyxvc.inUse() || buf->isReadonly();
456 case LFUN_VC_CHECKOUT:
457 disable = !buf->lyxvc.inUse() || !buf->isReadonly();
461 case LFUN_VC_HISTORY:
462 disable = !buf->lyxvc.inUse();
464 case LFUN_BOOKMARK_GOTO:
465 disable = !owner->view()->
466 isSavedPosition(strToUnsignedInt(argument));
470 case LFUN_INSET_TOGGLE:
471 disable = (TEXT(false)->getInset() == 0);
474 case LFUN_MATH_VALIGN: {
475 // I think this test can be simplified (Andre')
476 // mathcursor is != 0 iff we are in math mode
477 //Inset * tli = owner->view()->theLockingInset();
478 //if (tli && (tli->lyxCode() == Inset::MATH_CODE
479 // || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
482 char align = mathcursor->valign();
487 if (argument.empty()) {
491 if (!contains("tcb", argument[0])) {
495 flag.setOnOff(argument[0] == align);
500 case LFUN_MATH_HALIGN: {
501 //Inset * tli = owner->view()->theLockingInset();
502 //if (tli && (tli->lyxCode() == Inset::MATH_CODE
503 // || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
505 char align = mathcursor->halign();
510 if (argument.empty()) {
514 if (!contains("lcr", argument[0])) {
518 flag.setOnOff(argument[0] == align);
523 case LFUN_MATH_MUTATE: {
524 Inset * tli = owner->view()->theLockingInset();
525 if (tli && (tli->lyxCode() == Inset::MATH_CODE)) {
526 MathInsetTypes type = mathcursor->formula()->getType();
527 if (argument == "inline") {
528 flag.setOnOff(type == LM_OT_SIMPLE);
529 } else if (argument == "display") {
530 flag.setOnOff(type == LM_OT_EQUATION);
531 } else if (argument == "eqnarray") {
532 flag.setOnOff(type == LM_OT_EQNARRAY);
533 } else if (argument == "align") {
534 flag.setOnOff(type == LM_OT_ALIGN);
543 // we just need to be in math mode to enable that
545 case LFUN_MATH_SPACE:
546 case LFUN_MATH_LIMITS:
547 case LFUN_MATH_NONUMBER:
548 case LFUN_MATH_NUMBER:
549 disable = !mathcursor;
552 // we need to be math mode and a math array for that
553 // Hack: halign produces non-zero result iff we are in a math array
554 case LFUN_MATH_ROW_INSERT:
555 case LFUN_MATH_ROW_DELETE:
556 case LFUN_MATH_COLUMN_INSERT:
557 case LFUN_MATH_COLUMN_DELETE:
558 disable = !mathcursor || !mathcursor->halign();
565 // the functions which insert insets
566 Inset::Code code = Inset::NO_CODE;
568 case LFUN_INSET_TEXT:
569 code = Inset::TEXT_CODE;
572 code = Inset::ERT_CODE;
575 case LFUN_INSET_GRAPHICS:
576 code = Inset::GRAPHICS_CODE;
578 case LFUN_INSET_FOOTNOTE:
579 code = Inset::FOOT_CODE;
581 case LFUN_DIALOG_TABULAR_INSERT:
582 case LFUN_INSET_TABULAR:
583 code = Inset::TABULAR_CODE;
585 case LFUN_INSET_EXTERNAL:
586 code = Inset::EXTERNAL_CODE;
588 case LFUN_INSET_MARGINAL:
589 code = Inset::MARGIN_CODE;
591 case LFUN_INSET_MINIPAGE:
592 code = Inset::MINIPAGE_CODE;
594 case LFUN_INSET_FLOAT:
595 case LFUN_INSET_WIDE_FLOAT:
596 code = Inset::FLOAT_CODE;
598 case LFUN_FLOAT_LIST:
599 code = Inset::FLOAT_LIST_CODE;
602 case LFUN_INSET_LIST:
603 code = Inset::LIST_CODE;
605 case LFUN_INSET_THEOREM:
606 code = Inset::THEOREM_CODE;
609 case LFUN_INSET_CAPTION:
610 code = Inset::CAPTION_CODE;
612 case LFUN_INSERT_NOTE:
613 code = Inset::IGNORE_CODE;
615 case LFUN_INSERT_LABEL:
616 code = Inset::LABEL_CODE;
618 case LFUN_REF_INSERT:
619 code = Inset::REF_CODE;
621 case LFUN_CITATION_CREATE:
622 case LFUN_CITATION_INSERT:
623 code = Inset::CITE_CODE;
625 case LFUN_INSERT_BIBTEX:
626 code = Inset::BIBTEX_CODE;
628 case LFUN_INDEX_INSERT:
629 case LFUN_INDEX_INSERT_LAST:
630 case LFUN_INDEX_CREATE:
631 code = Inset::INDEX_CODE;
633 case LFUN_INDEX_PRINT:
634 code = Inset::INDEX_PRINT_CODE;
636 case LFUN_CHILD_INSERT:
637 code = Inset::INCLUDE_CODE;
639 case LFUN_TOC_INSERT:
640 code = Inset::TOC_CODE;
642 case LFUN_PARENTINSERT:
643 code = Inset::PARENT_CODE;
647 case LFUN_INSERT_URL:
648 code = Inset::URL_CODE;
651 // always allow this, since we will inset a raw quote
652 // if an inset is not allowed.
654 case LFUN_HYPHENATION:
655 case LFUN_LIGATURE_BREAK:
657 case LFUN_MENU_SEPARATOR:
659 case LFUN_END_OF_SENTENCE:
660 case LFUN_PROTECTEDSPACE:
661 code = Inset::SPECIALCHAR_CODE;
666 if (code != Inset::NO_CODE
667 && owner->view()->theLockingInset()
668 && !owner->view()->theLockingInset()->insetAllowed(code)) {
675 // A few general toggles
677 case LFUN_READ_ONLY_TOGGLE:
678 flag.setOnOff(buf->isReadonly());
681 flag.setOnOff(TEXT(false)->cursor.par()->params().startOfAppendix());
687 // the font related toggles
689 LyXFont const & font = TEXT(false)->real_current_font;
692 flag.setOnOff(font.emph() == LyXFont::ON);
695 flag.setOnOff(font.noun() == LyXFont::ON);
698 flag.setOnOff(font.series() == LyXFont::BOLD_SERIES);
701 flag.setOnOff(font.family() == LyXFont::SANS_FAMILY);
704 flag.setOnOff(font.family() == LyXFont::ROMAN_FAMILY);
707 flag.setOnOff(font.family() == LyXFont::TYPEWRITER_FAMILY);
714 MathTextCodes tc = mathcursor->getLastCode();
717 flag.setOnOff(tc == LM_TC_BF);
720 flag.setOnOff(tc == LM_TC_SF);
723 flag.setOnOff(tc == LM_TC_CAL);
726 flag.setOnOff(tc == LM_TC_RM);
729 flag.setOnOff(tc == LM_TC_TT);
732 flag.setOnOff(tc == LM_TC_BB);
735 flag.setOnOff(tc == LM_TC_VAR);
746 // temporary dispatch method
747 void LyXFunc::miniDispatch(string const & s)
749 string s2(frontStrip(strip(s)));
752 verboseDispatch(s2, true);
757 void const LyXFunc::verboseDispatch(string const & s, bool show_sc)
759 // Split command string into command and argument
761 string line = frontStrip(s);
762 string const arg = strip(frontStrip(split(line, cmd, ' ')));
764 int action = lyxaction.LookupFunc(cmd);
766 if (action == LFUN_UNKNOWN_ACTION) {
767 string const msg = string(_("Unknown function ("))
771 verboseDispatch(action, show_sc);
776 void const LyXFunc::verboseDispatch(int ac, bool show_sc)
781 // get the real action and argument
782 action = lyxaction.retrieveActionArg(ac, argument);
784 verboseDispatch(action, argument, show_sc);
789 void const LyXFunc::verboseDispatch(kb_action action,
790 string const & argument, bool show_sc)
792 string res = dispatch(action, argument);
794 commandshortcut.erase();
796 if (lyxrc.display_shortcuts && show_sc) {
797 if (action != LFUN_SELFINSERT) {
798 // Put name of command and list of shortcuts
799 // for it in minibuffer
800 string comname = lyxaction.getActionName(action);
802 int pseudoaction = action;
803 bool argsadded = false;
805 if (!argument.empty()) {
806 // the pseudoaction is useful for the bindings
808 lyxaction.searchActionArg(action,
811 if (pseudoaction == LFUN_UNKNOWN_ACTION) {
812 pseudoaction = action;
814 comname += " " + argument;
819 string const shortcuts =
820 toplevel_keymap->findbinding(pseudoaction);
822 if (!shortcuts.empty()) {
823 comname += ": " + shortcuts;
824 } else if (!argsadded && !argument.empty()) {
825 comname += " " + argument;
828 if (!comname.empty()) {
829 comname = strip(comname);
830 commandshortcut = "(" + comname + ')';
836 if (!commandshortcut.empty()) {
837 owner->getMiniBuffer()->addSet(commandshortcut);
840 owner->getMiniBuffer()->addSet(' ' + commandshortcut);
845 string const LyXFunc::dispatch(kb_action action, string argument)
847 lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << action
848 <<"] arg[" << argument << "]" << endl;
850 // we have not done anything wrong yet.
852 dispatch_buffer.erase();
854 #ifdef NEW_DISPATCHER
855 // We try do call the most specific dispatcher first:
856 // 1. the lockinginset's dispatch
857 // 2. the bufferview's dispatch
858 // 3. the lyxview's dispatch
861 selection_possible = false;
863 if (owner->view()->available())
864 owner->view()->hideCursor();
866 // We cannot use this function here
867 if (getStatus(action, argument).disabled()) {
868 lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: "
869 << lyxaction.getActionName(action)
870 << " [" << action << "] is disabled at this location"
872 goto exit_with_message;
875 if (owner->view()->available() && owner->view()->theLockingInset()) {
876 UpdatableInset::RESULT result;
877 if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
878 (!keyseq.deleted())))
880 if ((action == LFUN_UNKNOWN_ACTION)
881 && argument.empty()){
882 argument = keyseq.getiso();
884 // Undo/Redo is a bit tricky for insets.
885 if (action == LFUN_UNDO) {
886 owner->view()->menuUndo();
888 } else if (action == LFUN_REDO) {
889 owner->view()->menuRedo();
891 } else if (((result=owner->view()->theLockingInset()->
892 localDispatch(owner->view(), action, argument)) ==
893 UpdatableInset::DISPATCHED) ||
894 (result == UpdatableInset::DISPATCHED_NOUPDATE))
896 else if (result == UpdatableInset::FINISHED) {
897 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
898 TEXT()->cursorRight(owner->view());
899 moveCursorUpdate(true, false);
903 } else if (result == UpdatableInset::FINISHED_RIGHT) {
904 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
905 TEXT()->cursorRight(owner->view());
906 moveCursorUpdate(true, false);
910 } else if (result == UpdatableInset::FINISHED_UP) {
911 if (TEXT()->cursor.row()->previous()) {
912 TEXT()->cursorUp(owner->view());
913 moveCursorUpdate(true, false);
917 } else if (result == UpdatableInset::FINISHED_DOWN) {
918 if (TEXT()->cursor.row()->next())
919 TEXT()->cursorDown(owner->view());
921 TEXT()->cursorRight(owner->view());
922 moveCursorUpdate(true, false);
926 //setMessage(N_("Text mode"));
928 case LFUN_UNKNOWN_ACTION:
929 case LFUN_BREAKPARAGRAPH:
931 TEXT()->cursorRight(owner->view());
932 owner->view()->setState();
936 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
937 TEXT()->cursorRight(owner->view());
938 moveCursorUpdate(true, false);
943 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
944 TEXT()->cursorRight(owner->view());
945 moveCursorUpdate(true, false);
950 if (TEXT()->cursor.row()->next())
951 TEXT()->cursorDown(owner->view());
953 TEXT()->cursorRight(owner->view());
954 moveCursorUpdate(true, false);
968 if (!owner->view()->available()) break;
969 // this function should be used always [asierra060396]
970 UpdatableInset * tli =
971 owner->view()->theLockingInset();
973 UpdatableInset * lock = tli->getLockingInset();
976 owner->view()->unlockInset(tli);
977 TEXT()->cursorRight(owner->view());
978 moveCursorUpdate(true, false);
981 tli->unlockInsetInInset(owner->view(),
990 // --- Misc -------------------------------------------
991 case LFUN_WORDFINDFORWARD :
992 case LFUN_WORDFINDBACKWARD : {
993 static string last_search;
994 string searched_string;
996 if (!argument.empty()) {
997 last_search = argument;
998 searched_string = argument;
1000 searched_string = last_search;
1002 bool fw = (action == LFUN_WORDFINDBACKWARD);
1003 if (!searched_string.empty()) {
1004 LyXFind(owner->view(), searched_string, fw);
1006 // owner->view()->showCursor();
1012 if (owner->view()->available() && !owner->view()->theLockingInset()) {
1013 owner->view()->update(TEXT(),
1014 BufferView::SELECT|BufferView::FITCUR);
1016 owner->message(keyseq.print());
1020 // --- Misc -------------------------------------------
1021 case LFUN_EXEC_COMMAND:
1023 std::vector<string> allCmds;
1024 std::transform(lyxaction.func_begin(), lyxaction.func_end(),
1025 std::back_inserter(allCmds), lyx::firster());
1026 static std::vector<string> hist;
1027 owner->getMiniBuffer()->getString(MiniBuffer::spaces,
1032 case LFUN_CANCEL: // RVDK_PATCH_5
1035 if (owner->view()->available())
1036 // cancel any selection
1037 dispatch(LFUN_MARK_OFF);
1038 setMessage(N_("Cancel"));
1041 case LFUN_META_FAKE: // RVDK_PATCH_5
1043 meta_fake_bit = Mod1Mask;
1044 setMessage(keyseq.print());
1048 case LFUN_READ_ONLY_TOGGLE:
1049 if (owner->buffer()->lyxvc.inUse()) {
1050 owner->buffer()->lyxvc.toggleReadOnly();
1052 owner->buffer()->setReadonly(
1053 !owner->buffer()->isReadonly());
1057 case LFUN_CENTER: // this is center and redraw.
1058 owner->view()->center();
1061 // --- Menus -----------------------------------------------
1066 case LFUN_MENUNEWTMPLT:
1070 case LFUN_CLOSEBUFFER:
1074 case LFUN_MENUWRITE:
1075 if (!owner->buffer()->isUnnamed()) {
1077 s1 << _("Saving document") << ' '
1078 << MakeDisplayPath(owner->buffer()->fileName() + "...");
1079 owner->message(s1.str().c_str());
1080 MenuWrite(owner->view(), owner->buffer());
1082 WriteAs(owner->view(), owner->buffer());
1086 WriteAs(owner->view(), owner->buffer(), argument);
1089 case LFUN_MENURELOAD:
1094 Exporter::Export(owner->buffer(), argument, true);
1098 Exporter::Preview(owner->buffer(), argument);
1101 case LFUN_BUILDPROG:
1102 Exporter::Export(owner->buffer(), "program", true);
1105 case LFUN_RUNCHKTEX:
1106 MenuRunChktex(owner->buffer());
1109 case LFUN_MENUPRINT:
1110 owner->getDialogs()->showPrint();
1114 if (argument == "custom")
1117 Exporter::Export(owner->buffer(), argument, false);
1135 InsetCommandParams p;
1138 if (action == LFUN_TOCVIEW)
1140 p.setCmdName("tableofcontents");
1142 else if (action == LFUN_LOAVIEW )
1143 p.setCmdName("listof{algorithm}{List of Algorithms}");
1144 else if (action == LFUN_LOFVIEW)
1145 p.setCmdName("listoffigures");
1147 p.setCmdName("listoftables");
1149 owner->getDialogs()->createTOC(p.getAsString());
1153 case LFUN_DIALOG_TABULAR_INSERT:
1154 owner->getDialogs()->showTabularCreate();
1162 AutoSave(owner->view());
1166 owner->view()->menuUndo();
1170 owner->view()->menuRedo();
1173 case LFUN_MENUSEARCH:
1174 owner->getDialogs()->showSearch();
1177 case LFUN_REMOVEERRORS:
1178 if (owner->view()->removeAutoInsets()) {
1179 owner->view()->redraw();
1180 owner->view()->fitCursor();
1185 changeDepth(owner->view(), TEXT(false), 0);
1188 case LFUN_DEPTH_MIN:
1189 changeDepth(owner->view(), TEXT(false), -1);
1192 case LFUN_DEPTH_PLUS:
1193 changeDepth(owner->view(), TEXT(false), 1);
1197 owner->getDialogs()->setUserFreeFont();
1200 case LFUN_RECONFIGURE:
1201 Reconfigure(owner->view());
1205 case LFUN_FLOATSOPERATE:
1206 if (argument == "openfoot")
1207 owner->view()->allFloats(1,0);
1208 else if (argument == "closefoot")
1209 owner->view()->allFloats(0,0);
1210 else if (argument == "openfig")
1211 owner->view()->allFloats(1,1);
1212 else if (argument == "closefig")
1213 owner->view()->allFloats(0,1);
1216 #ifdef WITH_WARNINGS
1217 //#warning Find another implementation here (or another lyxfunc)!
1220 case LFUN_HELP_ABOUTLYX:
1221 owner->getDialogs()->showAboutlyx();
1224 case LFUN_HELP_TEXINFO:
1225 owner->getDialogs()->showTexinfo();
1228 case LFUN_HELP_OPEN:
1230 string const arg = argument;
1232 setErrorMessage(N_("Missing argument"));
1235 owner->prohibitInput();
1236 string const fname = i18nLibFileSearch("doc", arg, "lyx");
1237 if (fname.empty()) {
1238 lyxerr << "LyX: unable to find documentation file `"
1239 << arg << "'. Bad installation?" << endl;
1240 owner->allowInput();
1244 str << _("Opening help file") << ' '
1245 << MakeDisplayPath(fname) << "...";
1246 owner->message(str.str().c_str());
1247 owner->view()->buffer(bufferlist.loadLyXFile(fname, false));
1248 owner->allowInput();
1252 // --- version control -------------------------------
1253 case LFUN_VC_REGISTER:
1255 if (!owner->buffer()->lyxvc.inUse())
1256 owner->buffer()->lyxvc.registrer();
1260 case LFUN_VC_CHECKIN:
1262 if (owner->buffer()->lyxvc.inUse()
1263 && !owner->buffer()->isReadonly())
1264 owner->buffer()->lyxvc.checkIn();
1268 case LFUN_VC_CHECKOUT:
1270 if (owner->buffer()->lyxvc.inUse()
1271 && owner->buffer()->isReadonly())
1272 owner->buffer()->lyxvc.checkOut();
1276 case LFUN_VC_REVERT:
1278 owner->buffer()->lyxvc.revert();
1284 owner->buffer()->lyxvc.undoLast();
1288 case LFUN_VC_HISTORY:
1290 owner->getDialogs()->showVCLogFile();
1294 // --- buffers ----------------------------------------
1296 case LFUN_SWITCHBUFFER:
1297 owner->view()->buffer(bufferlist.getBuffer(argument));
1302 // servercmd: argument must be <file>:<template>
1303 Buffer * tmpbuf = NewLyxFile(argument);
1305 owner->view()->buffer(tmpbuf);
1309 case LFUN_FILE_OPEN:
1313 case LFUN_LATEX_LOG:
1314 owner->getDialogs()->showLogFile();
1317 case LFUN_LAYOUT_DOCUMENT:
1318 owner->getDialogs()->showDocument();
1321 case LFUN_LAYOUT_PARAGRAPH:
1322 owner->getDialogs()->showParagraph();
1325 case LFUN_LAYOUT_CHARACTER:
1326 owner->getDialogs()->showCharacter();
1329 case LFUN_LAYOUT_TABULAR:
1330 if (owner->view()->theLockingInset()) {
1331 if (owner->view()->theLockingInset()->lyxCode()==Inset::TABULAR_CODE) {
1332 InsetTabular * inset = static_cast<InsetTabular *>
1333 (owner->view()->theLockingInset());
1334 inset->openLayoutDialog(owner->view());
1335 } else if (owner->view()->theLockingInset()->
1336 getFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
1337 InsetTabular * inset = static_cast<InsetTabular *>(
1338 owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
1339 inset->openLayoutDialog(owner->view());
1344 case LFUN_LAYOUT_PREAMBLE:
1345 owner->getDialogs()->showPreamble();
1348 case LFUN_DROP_LAYOUTS_CHOICE:
1349 owner->getToolbar()->openLayoutList();
1352 case LFUN_MENU_OPEN_BY_NAME:
1353 owner->getMenubar()->openByName(argument);
1354 break; // RVDK_PATCH_5
1356 case LFUN_SPELLCHECK:
1357 if (lyxrc.isp_command != "none")
1358 owner->getDialogs()->showSpellchecker();
1361 // --- lyxserver commands ----------------------------
1365 setMessage(owner->buffer()->fileName());
1366 lyxerr[Debug::INFO] << "FNAME["
1367 << owner->buffer()->fileName()
1373 dispatch_buffer = keyseq.print();
1374 lyxserver->notifyClient(dispatch_buffer);
1378 case LFUN_GOTOFILEROW:
1382 istringstream istr(argument.c_str());
1383 istr >> file_name >> row;
1384 // Must replace extension of the file to be .lyx and get full path
1385 string const s(ChangeExtension(file_name, ".lyx"));
1387 // Either change buffer or load the file
1388 if (bufferlist.exists(s)) {
1389 owner->view()->buffer(bufferlist.getBuffer(s));
1391 owner->view()->buffer(bufferlist.loadLyXFile(s));
1395 owner->view()->setCursorFromRow(row);
1398 owner->view()->center();
1402 case LFUN_GOTO_PARAGRAPH:
1404 istringstream istr(argument.c_str());
1408 Paragraph * par = owner->buffer()->getParFromID(id);
1410 lyxerr[Debug::INFO] << "No matching paragraph found! ["
1411 << id << "]" << std::endl;
1414 lyxerr << "Paragraph " << par->id()
1415 << " found." << endl;
1419 owner->view()->text->setCursor(owner->view(), par, 0);
1420 owner->view()->setState();
1424 owner->view()->center();
1431 int const qa = lyxaction.LookupFunc(argument);
1432 setMessage(lyxaction.helpText(static_cast<kb_action>(qa)));
1436 // --- toolbar ----------------------------------
1437 case LFUN_PUSH_TOOLBAR:
1439 int nth = strToInt(argument);
1441 setErrorMessage(N_("Push-toolbar needs argument > 0"));
1443 owner->getToolbar()->push(nth);
1448 case LFUN_ADD_TO_TOOLBAR:
1450 if (lyxerr.debugging(Debug::GUI)) {
1451 lyxerr << "LFUN_ADD_TO_TOOLBAR:"
1452 "argument = `" << argument << '\'' << endl;
1454 string tmp(argument);
1455 //lyxerr <<string("Argument: ") + argument);
1456 //lyxerr <<string("Tmp : ") + tmp);
1458 setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
1460 owner->getToolbar()->add(argument, false);
1461 owner->getToolbar()->set();
1466 // --- insert characters ----------------------------------------
1468 // --- Mathed stuff. If we are here, there is no locked inset yet.
1469 case LFUN_MATH_EXTERN:
1470 case LFUN_MATH_NUMBER:
1471 case LFUN_MATH_NONUMBER:
1472 case LFUN_MATH_LIMITS:
1474 setErrorMessage(N_("This is only allowed in math mode!"));
1478 // passthrough hat and underscore outside mathed:
1479 case LFUN_SUBSCRIPT:
1480 dispatch(LFUN_SELFINSERT, "_");
1482 case LFUN_SUPERSCRIPT:
1483 dispatch(LFUN_SELFINSERT, "^");
1486 case LFUN_MATH_PANEL:
1487 owner->getDialogs()->showMathPanel();
1490 case LFUN_CITATION_CREATE:
1492 InsetCommandParams p( "cite" );
1494 if (!argument.empty()) {
1495 // This should be set at source, ie when typing
1496 // "citation-insert foo" in the minibuffer.
1497 // Question: would pybibliographer also need to be
1498 // changed. Suspect so. Leave as-is therefore.
1499 if (contains(argument, "|")) {
1500 p.setContents( token(argument, '|', 0) );
1501 p.setOptions( token(argument, '|', 1) );
1503 p.setContents( argument );
1505 dispatch(LFUN_CITATION_INSERT, p.getAsString());
1507 owner->getDialogs()->createCitation( p.getAsString() );
1511 case LFUN_CHILDOPEN:
1513 string const filename =
1514 MakeAbsPath(argument,
1515 OnlyPath(owner->buffer()->fileName()));
1516 setMessage(N_("Opening child document ") +
1517 MakeDisplayPath(filename) + "...");
1518 owner->view()->savePosition(0);
1519 if (bufferlist.exists(filename))
1520 owner->view()->buffer(bufferlist.getBuffer(filename));
1522 owner->view()->buffer(bufferlist.loadLyXFile(filename));
1526 case LFUN_TOGGLECURSORFOLLOW:
1527 lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
1530 case LFUN_KMAP_OFF: // keymap off
1531 owner->getIntl()->KeyMapOn(false);
1534 case LFUN_KMAP_PRIM: // primary keymap
1535 owner->getIntl()->KeyMapPrim();
1538 case LFUN_KMAP_SEC: // secondary keymap
1539 owner->getIntl()->KeyMapSec();
1542 case LFUN_KMAP_TOGGLE: // toggle keymap
1543 owner->getIntl()->ToggleKeyMap();
1548 // argument contains ';'-terminated commands
1549 while (argument.find(';') != string::npos) {
1551 argument = split(argument, first, ';');
1552 verboseDispatch(first, false);
1557 case LFUN_DIALOG_PREFERENCES:
1558 owner->getDialogs()->showPreferences();
1561 case LFUN_SAVEPREFERENCES:
1563 Path p(user_lyxdir);
1564 lyxrc.write("preferences");
1568 case LFUN_SCREEN_FONT_UPDATE:
1570 // handle the screen font changes.
1572 lyxrc.set_font_norm_type();
1573 fontloader.update();
1574 // Of course we should only do the resize and the textcache.clear
1575 // if values really changed...but not very important right now. (Lgb)
1576 // All visible buffers will need resize
1578 // We also need to empty the textcache so that
1579 // the buffer will be formatted correctly after
1585 case LFUN_SET_COLOR:
1588 string const x11_name = split(argument, lyx_name, ' ');
1589 if (lyx_name.empty() || x11_name.empty()) {
1590 setErrorMessage(N_("Syntax: set-color <lyx_name>"
1595 if (!lcolor.setColor(lyx_name, x11_name)) {
1596 static string const err1 (N_("Set-color \""));
1597 static string const err2 (
1598 N_("\" failed - color is undefined "
1599 "or may not be redefined"));
1600 setErrorMessage(_(err1) + lyx_name + _(err2));
1603 lyxColorHandler->updateColor(lcolor.getFromLyXName(lyx_name));
1604 owner->view()->redraw();
1609 owner->message(argument);
1612 case LFUN_MESSAGE_PUSH:
1613 owner->messagePush(argument);
1616 case LFUN_MESSAGE_POP:
1617 owner->messagePop();
1621 // Then if it was none of the above
1622 if (!owner->view()->Dispatch(action, argument))
1623 lyxerr << "A truly unknown func ["
1624 << lyxaction.getActionName(action) << "]!"
1631 string const res = getMessage();
1634 owner->message(_(res));
1640 void LyXFunc::setupLocalKeymap()
1642 keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
1643 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap.get();
1647 void LyXFunc::menuNew(bool fromTemplate)
1649 string initpath = lyxrc.document_path;
1651 if (owner->view()->available()) {
1652 string const trypath = owner->buffer()->filepath;
1653 // If directory is writeable, use this as default.
1654 if (IsDirWriteable(trypath))
1658 static int newfile_number;
1661 if (lyxrc.new_ask_filename) {
1662 FileDialog fileDlg(owner, _("Enter filename for new document"),
1663 LFUN_SELECT_FILE_SYNC,
1664 make_pair(string(_("Documents")),
1665 string(lyxrc.document_path)),
1666 make_pair(string(_("Templates")),
1667 string(lyxrc.template_path)));
1669 FileDialog::Result result =
1670 fileDlg.Select(initpath,
1671 _("*.lyx|LyX Documents (*.lyx)"),
1674 if (result.second.empty()) {
1675 owner->message(_("Canceled."));
1676 lyxerr[Debug::INFO] << "New Document Cancelled." << endl;
1680 // get absolute path of file and make sure the filename ends
1682 s = MakeAbsPath(result.second);
1683 if (!IsLyXFilename(s))
1686 // Check if the document already is open
1687 if (bufferlist.exists(s)) {
1688 switch (Alert::askConfirmation(_("Document is already open:"),
1689 MakeDisplayPath(s, 50),
1690 _("Do you want to close that document now?\n"
1691 "('No' will just switch to the open version)")))
1693 case 1: // Yes: close the document
1694 if (!bufferlist.close(bufferlist.getBuffer(s)))
1695 // If close is canceled, we cancel here too.
1698 case 2: // No: switch to the open document
1699 owner->view()->buffer(bufferlist.getBuffer(s));
1701 case 3: // Cancel: Do nothing
1702 owner->message(_("Canceled."));
1706 // Check whether the file already exists
1708 if (fi.readable() &&
1709 Alert::askQuestion(_("File already exists:"),
1710 MakeDisplayPath(s, 50),
1711 _("Do you want to open the document?"))) {
1713 string const disp_fn(MakeDisplayPath(s));
1716 str << _("Opening document") << ' '
1717 << disp_fn << "...";
1719 owner->message(str.str().c_str());
1720 //XFlush(fl_get_display());
1721 owner->view()->buffer(bufferlist.loadLyXFile(s));
1723 str2 << _("Document") << ' '
1724 << disp_fn << ' ' << _("opened.");
1726 owner->message(str2.str().c_str());
1731 s = AddName(lyxrc.document_path,
1732 "newfile" + tostr(++newfile_number) + ".lyx");
1734 while (bufferlist.exists(s) || fi.readable()) {
1736 s = AddName(lyxrc.document_path,
1737 "newfile" + tostr(newfile_number) +
1743 // The template stuff
1746 FileDialog fileDlg(owner, _("Select template file"),
1747 LFUN_SELECT_FILE_SYNC,
1748 make_pair(string(_("Documents")),
1749 string(lyxrc.document_path)),
1750 make_pair(string(_("Templates")),
1751 string(lyxrc.template_path)));
1753 FileDialog::Result result =
1754 fileDlg.Select(lyxrc.template_path,
1755 _("*.lyx|LyX Documents (*.lyx)"));
1757 if (result.first == FileDialog::Later)
1760 string const fname = result.second;
1767 // find a free buffer
1768 lyxerr[Debug::INFO] << "Find a free buffer." << endl;
1769 owner->view()->buffer(bufferlist.newFile(s, templname));
1773 void LyXFunc::open(string const & fname)
1775 string initpath = lyxrc.document_path;
1777 if (owner->view()->available()) {
1778 string const trypath = owner->buffer()->filepath;
1779 // If directory is writeable, use this as default.
1780 if (IsDirWriteable(trypath))
1786 if (fname.empty()) {
1787 FileDialog fileDlg(owner, _("Select document to open"),
1789 make_pair(string(_("Documents")),
1790 string(lyxrc.document_path)),
1791 make_pair(string(_("Examples")),
1792 string(AddPath(system_lyxdir, "examples"))));
1794 FileDialog::Result result =
1795 fileDlg.Select(initpath,
1796 "*.lyx|LyX Documents (*.lyx)");
1798 if (result.first == FileDialog::Later)
1801 filename = result.second;
1803 // check selected filename
1804 if (filename.empty()) {
1805 owner->message(_("Canceled."));
1811 // get absolute path of file and add ".lyx" to the filename if
1813 string const fullpath = FileSearch(string(), filename, "lyx");
1814 if (fullpath.empty()) {
1815 Alert::alert(_("Error"), _("Could not find file"), filename);
1819 filename = fullpath;
1822 string const disp_fn(MakeDisplayPath(filename));
1825 str << _("Opening document") << ' ' << disp_fn << "...";
1827 owner->message(str.str().c_str());
1829 Buffer * openbuf = bufferlist.loadLyXFile(filename);
1831 owner->view()->buffer(openbuf);
1833 str << _("Document") << ' ' << disp_fn << ' ' << _("opened.");
1834 owner->message(str.str().c_str());
1837 str << _("Could not open document") << ' ' << disp_fn;
1838 owner->message(str.str().c_str());
1843 // checks for running without gui are missing.
1844 void LyXFunc::doImport(string const & argument)
1847 string filename = split(argument, format, ' ');
1848 lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format
1849 << " file: " << filename << endl;
1851 if (filename.empty()) { // need user interaction
1852 string initpath = lyxrc.document_path;
1854 if (owner->view()->available()) {
1855 string const trypath = owner->buffer()->filepath;
1856 // If directory is writeable, use this as default.
1857 if (IsDirWriteable(trypath))
1861 string const text = _("Select ") + formats.prettyName(format)
1862 + _(" file to import");
1864 FileDialog fileDlg(owner, text,
1866 make_pair(string(_("Documents")),
1867 string(lyxrc.document_path)),
1868 make_pair(string(_("Examples")),
1869 string(AddPath(system_lyxdir, "examples"))));
1871 string const extension = "*." + formats.extension(format)
1872 + "| " + formats.prettyName(format)
1873 + " (*." + formats.extension(format) + ")";
1875 FileDialog::Result result = fileDlg.Select(initpath,
1878 if (result.first == FileDialog::Later)
1881 filename = result.second;
1883 // check selected filename
1884 if (filename.empty())
1885 owner->message(_("Canceled."));
1888 // still no filename? abort
1889 if (filename.empty())
1892 // get absolute path of file
1893 filename = MakeAbsPath(filename);
1895 string const lyxfile = ChangeExtension(filename, ".lyx");
1897 // Check if the document already is open
1898 if (bufferlist.exists(lyxfile)) {
1899 switch (Alert::askConfirmation(_("Document is already open:"),
1900 MakeDisplayPath(lyxfile, 50),
1901 _("Do you want to close that document now?\n"
1902 "('No' will just switch to the open version)")))
1904 case 1: // Yes: close the document
1905 if (!bufferlist.close(bufferlist.getBuffer(lyxfile)))
1906 // If close is canceled, we cancel here too.
1909 case 2: // No: switch to the open document
1910 owner->view()->buffer(bufferlist.getBuffer(lyxfile));
1912 case 3: // Cancel: Do nothing
1913 owner->message(_("Canceled."));
1918 // Check if a LyX document by the same root exists in filesystem
1919 FileInfo const f(lyxfile, true);
1920 if (f.exist() && !Alert::askQuestion(_("A document by the name"),
1921 MakeDisplayPath(lyxfile),
1922 _("already exists. Overwrite?"))) {
1923 owner->message(_("Canceled"));
1926 // filename should be valid now
1928 Importer::Import(owner, filename, format);
1932 void LyXFunc::reloadBuffer()
1934 string const fn = owner->buffer()->fileName();
1935 if (bufferlist.close(owner->buffer()))
1936 owner->view()->buffer(bufferlist.loadLyXFile(fn));
1940 void LyXFunc::closeBuffer()
1942 if (bufferlist.close(owner->buffer()) && !quitting) {
1943 if (bufferlist.empty()) {
1944 // need this otherwise SEGV may occur while trying to
1945 // set variables that don't exist
1946 // since there's no current buffer
1947 owner->getDialogs()->hideBufferDependent();
1949 owner->view()->buffer(bufferlist.first());
1955 // Each "owner" should have it's own message method. lyxview and
1956 // the minibuffer would use the minibuffer, but lyxserver would
1957 // send an ERROR signal to its client. Alejandro 970603
1958 // This func is bit problematic when it comes to NLS, to make the
1959 // lyx servers client be language indepenent we must not translate
1960 // strings sent to this func.
1961 void LyXFunc::setErrorMessage(string const & m) const
1963 dispatch_buffer = m;
1968 void LyXFunc::setMessage(string const & m)
1970 dispatch_buffer = m;
1974 void LyXFunc::initMiniBuffer()
1976 string text = _("Welcome to LyX!");
1978 // When meta-fake key is pressed, show the key sequence so far + "M-".
1980 text = keyseq.print();
1984 // Else, when a non-complete key sequence is pressed,
1985 // show the available options.
1986 if (keyseq.length() > 0 && !keyseq.deleted()) {
1987 text = keyseq.printOptions();
1990 // Else, show the buffer state.
1991 else if (owner->view()->available()) {
1992 Buffer * tmpbuf = owner->buffer();
1994 string const nicename =
1995 MakeDisplayPath(tmpbuf->fileName());
1996 // Should we do this instead? (kindo like emacs)
1997 // leaves more room for other information
2000 if (tmpbuf->lyxvc.inUse()) {
2002 text += tmpbuf->lyxvc.versionString();
2004 text += tmpbuf->lyxvc.locker();
2005 if (tmpbuf->isReadonly())
2008 } else if (tmpbuf->isReadonly())
2010 if (!tmpbuf->isLyxClean())
2011 text += _(" (Changed)");
2013 if (text != _("Welcome to LyX!")) // this is a hack
2014 text = _("* No document open *");
2017 owner->message(text);