1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2001 The LyX Team.
9 * ====================================================== */
25 #pragma implementation
28 #include "support/lyxalgo.h"
29 #include "support/LAssert.h"
33 #include "bufferlist.h"
34 #include "BufferView.h"
35 #include "ColorHandler.h"
36 #include "lyxserver.h"
40 #include "LyXAction.h"
41 #include "insets/inseturl.h"
42 #include "insets/insetlatexaccent.h"
43 #include "insets/insettoc.h"
44 #include "insets/insetref.h"
45 #include "insets/insetparent.h"
46 #include "insets/insetindex.h"
47 #include "insets/insetinclude.h"
48 #include "insets/insetbib.h"
49 #include "insets/insetcite.h"
50 #include "insets/insettext.h"
51 #include "insets/insetert.h"
52 #include "insets/insetexternal.h"
53 #include "insets/insetgraphics.h"
54 #include "insets/insetfoot.h"
55 #include "insets/insetmarginal.h"
56 #include "insets/insetminipage.h"
57 #include "insets/insetfloat.h"
59 #include "insets/insetlist.h"
60 #include "insets/insettheorem.h"
62 #include "insets/insettabular.h"
63 #include "insets/insetcaption.h"
64 #include "mathed/formulamacro.h"
65 #include "mathed/math_cursor.h"
66 #include "mathed/math_inset.h"
67 #include "minibuffer.h"
70 #include "lyx_gui_misc.h"
71 #include "support/filetools.h"
72 #include "support/FileInfo.h"
73 #include "support/syscall.h"
74 #include "support/lstrings.h"
75 #include "support/path.h"
76 #include "support/lyxfunctional.h"
81 #include "trans_mgr.h"
84 #include "bufferview_funcs.h"
85 #include "frontends/FileDialog.h"
86 #include "frontends/Dialogs.h"
87 #include "frontends/Toolbar.h"
88 #include "frontends/Menubar.h"
89 #include "FloatList.h"
90 #include "converter.h"
93 #include "FontLoader.h"
94 #include "TextCache.h"
96 #include "undo_funcs.h"
97 #include "ParagraphParameters.h"
98 #include "figureForm.h"
101 using std::make_pair;
105 extern BufferList bufferlist;
106 extern LyXServer * lyxserver;
107 extern bool selection_possible;
108 extern void MenuSendto();
110 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
112 extern void show_symbols_form(LyXFunc *);
114 extern LyXAction lyxaction;
116 extern tex_accent_struct get_accent(kb_action action);
118 extern LyXTextClass::size_type current_layout;
120 extern void ShowLatexLog();
126 class MiniBufferController : public SigC::Object {
129 MiniBufferController() {
133 &MiniBufferController::receiveCommand));
137 &MiniBufferController::receiveArg));
140 void receiveCmd(string const & cmd) {}
142 void receiveArg(string const & arg) {}
150 MiniBufferController mb_ctrl;
156 /* === globals =========================================================== */
158 // Initialization of static member var
159 bool LyXFunc::show_sc = true;
162 LyXFunc::LyXFunc(LyXView * o)
166 lyx_dead_action = LFUN_NOACTION;
167 lyx_calling_dead_action = LFUN_NOACTION;
173 LyXText * LyXFunc::TEXT(bool flag = true) const
176 return owner->view()->text;
177 return owner->view()->getLyXText();
181 // I changed this func slightly. I commented out the ...FinishUndo(),
182 // this means that all places that used to have a moveCursorUpdate, now
183 // have a ...FinishUndo() as the preceeding statement. I have also added
184 // a moveCursorUpdate to some of the functions that updated the cursor, but
185 // that did not show its new position.
187 void LyXFunc::moveCursorUpdate(bool flag, bool selecting)
189 if (selecting || TEXT(flag)->selection.mark()) {
190 TEXT(flag)->setSelection(owner->view());
191 if (TEXT(flag)->bv_owner)
192 owner->view()->toggleToggle();
194 owner->view()->update(TEXT(flag), BufferView::SELECT|BufferView::FITCUR);
195 owner->view()->showCursor();
197 /* ---> Everytime the cursor is moved, show the current font state. */
198 // should this too me moved out of this func?
199 owner->view()->setState();
203 void LyXFunc::handleKeyFunc(kb_action action)
205 char c = keyseq.getiso();
207 if (keyseq.length != -1) c = 0;
209 owner->getIntl()->getTrans()
210 .deadkey(c, get_accent(action).accent, TEXT(false));
211 // Need to reset, in case the minibuffer calls these
215 // copied verbatim from do_accent_char
216 owner->view()->update(TEXT(false),
217 BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
218 TEXT(false)->selection.cursor = TEXT(false)->cursor;
222 void LyXFunc::processKeySym(KeySym keysym, unsigned int state)
226 if (lyxerr.debugging(Debug::KEY)) {
227 char const * tmp = XKeysymToString(keysym);
228 string const stm = (tmp ? tmp : "");
229 lyxerr << "KeySym is "
232 << keysym << "] State is ["
236 // Do nothing if we have nothing (JMarc)
237 if (keysym == NoSymbol) {
238 lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
243 // Can we be sure that this will work for all X Window
244 // implementations? (Lgb)
245 // This code snippet makes lyx ignore some keys. Perhaps
246 // all of them should be explictly mentioned?
247 if ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
248 || keysym == XK_Mode_switch || keysym == 0x0) {
252 // Do a one-deep top-level lookup for
253 // cancel and meta-fake keys. RVDK_PATCH_5
254 cancel_meta_seq.reset();
256 int action = cancel_meta_seq.addkey(keysym, state
257 &(ShiftMask|ControlMask
259 if (lyxerr.debugging(Debug::KEY)) {
260 lyxerr << "action first set to [" << action << "]" << endl;
263 // When not cancel or meta-fake, do the normal lookup.
264 // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
265 // Mostly, meta_fake_bit = 0. RVDK_PATCH_5.
266 if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
267 if (lyxerr.debugging(Debug::KEY)) {
268 lyxerr << "meta_fake_bit is ["
269 << meta_fake_bit << "]" << endl;
271 // remove Caps Lock and Mod2 as a modifiers
272 action = keyseq.addkey(keysym,
273 (state | meta_fake_bit)
274 &(ShiftMask|ControlMask
276 if (lyxerr.debugging(Debug::KEY)) {
277 lyxerr << "action now set to ["
278 << action << "]" << endl;
281 // Dont remove this unless you know what you are doing.
284 if (action == 0) action = LFUN_PREFIX;
286 if (lyxerr.debugging(Debug::KEY)) {
289 lyxerr << "Key [action="
295 // already here we know if it any point in going further
296 // why not return already here if action == -1 and
297 // num_bytes == 0? (Lgb)
299 if (keyseq.length > 1 || keyseq.length < -1) {
306 // It is unknown, but what if we remove all
307 // the modifiers? (Lgb)
308 action = keyseq.addkey(keysym, 0);
310 if (lyxerr.debugging(Debug::KEY)) {
311 lyxerr << "Removing modifiers...\n"
312 << "Action now set to ["
313 << action << "]" << endl;
316 owner->message(_("Unknown function."));
321 if (action == LFUN_SELFINSERT) {
322 // This is very X dependant.
323 unsigned int c = keysym;
325 switch (c & 0x0000FF00) {
326 // latin 1 byte 3 = 0
327 case 0x00000000: break;
328 // latin 2 byte 3 = 1
330 // latin 3 byte 3 = 2
332 // latin 4 byte 3 = 3
334 // latin 8 byte 3 = 18 (0x12)
336 // latin 9 byte 3 = 19 (0x13)
345 argument = static_cast<char>(c);
346 lyxerr[Debug::KEY] << "SelfInsert arg[`"
347 << argument << "']" << endl;
350 bool tmp_sc = show_sc;
352 dispatch(action, argument);
359 func_status::value_type LyXFunc::getStatus(int ac) const
361 return getStatus(ac, string());
365 func_status::value_type LyXFunc::getStatus(int ac,
366 string const & not_to_use_arg) const
369 func_status::value_type flag = func_status::OK;
371 Buffer * buf = owner->buffer();
373 if (lyxaction.isPseudoAction(ac))
374 action = lyxaction.retrieveActionArg(ac, argument);
376 action = static_cast<kb_action>(ac);
377 if (!not_to_use_arg.empty())
378 argument = not_to_use_arg; // exept here
381 if (action == LFUN_UNKNOWN_ACTION) {
382 setErrorMessage(N_("Unknown action"));
383 return func_status::Unknown;
386 // Check whether we need a buffer
387 if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) {
388 // Yes we need a buffer, do we have one?
391 // Can we use a readonly buffer?
392 if (buf->isReadonly() &&
393 !lyxaction.funcHasFlag(action,
394 LyXAction::ReadOnly)) {
396 setErrorMessage(N_("Document is read-only"));
397 flag |= func_status::Disabled;
401 setErrorMessage(N_("Command not allowed with"
402 "out any document open"));
403 flag |= func_status::Disabled;
408 // I would really like to avoid having this switch and rather try to
409 // encode this in the function itself.
410 bool disable = false;
413 disable = !Exporter::IsExportable(buf, "dvi")
414 || lyxrc.print_command == "none";
417 disable = argument == "fax" &&
418 !Exporter::IsExportable(buf, argument);
421 disable = buf->undostack.empty();
424 disable = buf->redostack.empty();
426 case LFUN_SPELLCHECK:
427 disable = lyxrc.isp_command == "none";
429 #ifndef HAVE_LIBAIKSAURUS
430 case LFUN_THESAURUS_ENTRY:
435 disable = lyxrc.chktex_command == "none";
438 disable = !Exporter::IsExportable(buf, "program");
441 case LFUN_LAYOUT_TABULAR:
443 if (owner->view()->theLockingInset()) {
444 disable = (owner->view()->theLockingInset()->lyxCode() != Inset::TABULAR_CODE) &&
445 !owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE);
449 case LFUN_TABULAR_FEATURE:
451 if (owner->view()->theLockingInset()) {
452 func_status::value_type ret = func_status::Disabled;
453 if (owner->view()->theLockingInset()->lyxCode() == Inset::TABULAR_CODE) {
454 ret = static_cast<InsetTabular *>
455 (owner->view()->theLockingInset())->
457 } else if (owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
458 ret = static_cast<InsetTabular *>
459 (owner->view()->theLockingInset()->
460 getFirstLockingInsetOfType(Inset::TABULAR_CODE))->
466 static InsetTabular inset(*owner->buffer(), 1, 1);
467 func_status::value_type ret;
470 ret = inset.getStatus(argument);
471 if ((ret & func_status::ToggleOn) ||
472 (ret & func_status::ToggleOff))
473 flag |= func_status::ToggleOff;
477 case LFUN_VC_REGISTER:
478 disable = buf->lyxvc.inUse();
480 case LFUN_VC_CHECKIN:
481 disable = !buf->lyxvc.inUse() || buf->isReadonly();
483 case LFUN_VC_CHECKOUT:
484 disable = !buf->lyxvc.inUse() || !buf->isReadonly();
488 case LFUN_VC_HISTORY:
489 disable = !buf->lyxvc.inUse();
491 case LFUN_BOOKMARK_GOTO:
492 disable = !owner->view()->
493 isSavedPosition(strToUnsignedInt(argument));
497 case LFUN_INSET_TOGGLE:
498 disable = (TEXT(false)->getInset() == 0);
501 case LFUN_MATH_VALIGN: {
502 // I think this test can be simplified (Andre')
503 // mathcursor is != 0 iff we are in math mode
504 //Inset * tli = owner->view()->theLockingInset();
505 //if (tli && (tli->lyxCode() == Inset::MATH_CODE
506 // || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
509 char align = mathcursor->valign();
514 if (argument.empty()) {
515 flag = func_status::OK;
518 if (!contains("tcb", argument[0])) {
522 if (argument[0] == align)
523 flag |= func_status::ToggleOn;
525 flag |= func_status::ToggleOff;
530 case LFUN_MATH_HALIGN: {
531 //Inset * tli = owner->view()->theLockingInset();
532 //if (tli && (tli->lyxCode() == Inset::MATH_CODE
533 // || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
535 char align = mathcursor->halign();
540 if (argument.empty()) {
541 flag = func_status::OK;
544 if (!contains("lcr", argument[0])) {
548 if (argument[0] == align)
549 flag |= func_status::ToggleOn;
551 flag |= func_status::ToggleOff;
556 case LFUN_MATH_MUTATE: {
557 Inset * tli = owner->view()->theLockingInset();
558 if (tli && (tli->lyxCode() == Inset::MATH_CODE)) {
559 MathInsetTypes type = mathcursor->formula()->getType();
560 func_status::value_type box = func_status::ToggleOff;
561 if (argument == "inline") {
562 if (type == LM_OT_SIMPLE)
563 box = func_status::ToggleOn;
564 } else if (argument == "display") {
565 if (type == LM_OT_EQUATION)
566 box = func_status::ToggleOn;
567 } else if (argument == "eqnarray") {
568 if (type == LM_OT_EQNARRAY)
569 box = func_status::ToggleOn;
570 } else if (argument == "align") {
571 if (type == LM_OT_ALIGN)
572 box = func_status::ToggleOn;
574 box = func_status::OK;
583 // we just need to be in math mode to enable that
585 case LFUN_MATH_SPACE:
586 case LFUN_MATH_LIMITS:
587 case LFUN_MATH_NONUMBER:
588 case LFUN_MATH_NUMBER:
589 disable = !mathcursor;
592 // we need to be math mode and a math array for that
593 // Hack: halign produces non-zero result iff we are in a math array
594 case LFUN_MATH_ROW_INSERT:
595 case LFUN_MATH_ROW_DELETE:
596 case LFUN_MATH_COLUMN_INSERT:
597 case LFUN_MATH_COLUMN_DELETE:
598 disable = !mathcursor || !mathcursor->halign();
605 // the functions which insert insets
606 Inset::Code code = Inset::NO_CODE;
608 case LFUN_INSET_TEXT:
609 code = Inset::TEXT_CODE;
612 code = Inset::ERT_CODE;
615 case LFUN_INSET_GRAPHICS:
616 code = Inset::GRAPHICS_CODE;
618 case LFUN_INSET_FOOTNOTE:
619 code = Inset::FOOT_CODE;
621 case LFUN_DIALOG_TABULAR_INSERT:
622 case LFUN_INSET_TABULAR:
623 code = Inset::TABULAR_CODE;
625 case LFUN_INSET_EXTERNAL:
626 code = Inset::EXTERNAL_CODE;
628 case LFUN_INSET_MARGINAL:
629 code = Inset::MARGIN_CODE;
631 case LFUN_INSET_MINIPAGE:
632 code = Inset::MINIPAGE_CODE;
634 case LFUN_INSET_FLOAT:
635 case LFUN_INSET_WIDE_FLOAT:
636 code = Inset::FLOAT_CODE;
638 case LFUN_FLOAT_LIST:
639 code = Inset::FLOAT_LIST_CODE;
642 case LFUN_INSET_LIST:
643 code = Inset::LIST_CODE;
645 case LFUN_INSET_THEOREM:
646 code = Inset::THEOREM_CODE;
649 case LFUN_INSET_CAPTION:
650 code = Inset::CAPTION_CODE;
652 case LFUN_INSERT_NOTE:
653 code = Inset::IGNORE_CODE;
655 case LFUN_INSERT_LABEL:
656 code = Inset::LABEL_CODE;
658 case LFUN_REF_INSERT:
659 code = Inset::REF_CODE;
661 case LFUN_CITATION_CREATE:
662 case LFUN_CITATION_INSERT:
663 code = Inset::CITE_CODE;
665 case LFUN_INSERT_BIBTEX:
666 code = Inset::BIBTEX_CODE;
668 case LFUN_INDEX_INSERT:
669 case LFUN_INDEX_INSERT_LAST:
670 case LFUN_INDEX_CREATE:
671 code = Inset::INDEX_CODE;
673 case LFUN_INDEX_PRINT:
674 code = Inset::INDEX_PRINT_CODE;
676 case LFUN_CHILD_INSERT:
677 code = Inset::INCLUDE_CODE;
679 case LFUN_TOC_INSERT:
680 code = Inset::TOC_CODE;
682 case LFUN_PARENTINSERT:
683 code = Inset::PARENT_CODE;
687 case LFUN_INSERT_URL:
688 code = Inset::URL_CODE;
691 // always allow this, since we will inset a raw quote
692 // if an inset is not allowed.
694 case LFUN_HYPHENATION:
695 case LFUN_LIGATURE_BREAK:
697 case LFUN_MENU_SEPARATOR:
699 case LFUN_END_OF_SENTENCE:
700 case LFUN_PROTECTEDSPACE:
701 code = Inset::SPECIALCHAR_CODE;
706 if (code != Inset::NO_CODE
707 && owner->view()->theLockingInset()
708 && !owner->view()->theLockingInset()->insetAllowed(code)) {
713 flag |= func_status::Disabled;
715 // the font related functions (and a few others)
716 func_status::value_type box = func_status::ToggleOff;
717 LyXFont const & font =
718 TEXT(false)->real_current_font;
721 if (font.emph() == LyXFont::ON)
722 box = func_status::ToggleOn;
725 if (font.noun() == LyXFont::ON)
726 box = func_status::ToggleOn;
729 if (font.series() == LyXFont::BOLD_SERIES)
730 box = func_status::ToggleOn;
732 case LFUN_READ_ONLY_TOGGLE:
733 if (buf->isReadonly())
734 box = func_status::ToggleOn;
737 if (TEXT(false)->cursor.par()->params().startOfAppendix())
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[Debug::ACTION] << "LyXFunc::Dispatch: "
811 << lyxaction.getActionName(ac)
812 << " [" << ac << "] is disabled at 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, argument)) ==
874 UpdatableInset::DISPATCHED) ||
875 (result == UpdatableInset::DISPATCHED_NOUPDATE))
877 else if (result == UpdatableInset::FINISHED) {
878 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
879 TEXT()->cursorRight(owner->view());
880 moveCursorUpdate(true, false);
884 } else if (result == UpdatableInset::FINISHED_RIGHT) {
885 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
886 TEXT()->cursorRight(owner->view());
887 moveCursorUpdate(true, false);
891 } else if (result == UpdatableInset::FINISHED_UP) {
892 if (TEXT()->cursor.row()->previous()) {
893 TEXT()->cursorUp(owner->view());
894 moveCursorUpdate(true, false);
898 } else if (result == UpdatableInset::FINISHED_DOWN) {
899 if (TEXT()->cursor.row()->next())
900 TEXT()->cursorDown(owner->view());
902 TEXT()->cursorRight(owner->view());
903 moveCursorUpdate(true, false);
907 //setMessage(N_("Text mode"));
909 case LFUN_UNKNOWN_ACTION:
910 case LFUN_BREAKPARAGRAPH:
912 TEXT()->cursorRight(owner->view());
913 owner->view()->setState();
917 if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
918 TEXT()->cursorRight(owner->view());
919 moveCursorUpdate(true, false);
924 if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
925 TEXT()->cursorRight(owner->view());
926 moveCursorUpdate(true, false);
931 if (TEXT()->cursor.row()->next())
932 TEXT()->cursorDown(owner->view());
934 TEXT()->cursorRight(owner->view());
935 moveCursorUpdate(true, false);
949 if (!owner->view()->available()) break;
951 // this function should be used always [asierra060396]
952 UpdatableInset * tli =
953 owner->view()->theLockingInset();
955 UpdatableInset * lock = tli->getLockingInset();
958 owner->view()->unlockInset(tli);
959 TEXT()->cursorRight(owner->view());
960 moveCursorUpdate(true, false);
963 tli->unlockInsetInInset(owner->view(),
971 // --- Misc -------------------------------------------
972 case LFUN_WORDFINDFORWARD :
973 case LFUN_WORDFINDBACKWARD : {
974 static string last_search;
975 string searched_string;
977 if (!argument.empty()) {
978 last_search = argument;
979 searched_string = argument;
981 searched_string = last_search;
983 bool fw = (action == LFUN_WORDFINDBACKWARD);
984 if (!searched_string.empty()) {
985 LyXFind(owner->view(), searched_string, fw);
987 // owner->view()->showCursor();
993 if (owner->view()->available() && !owner->view()->theLockingInset()) {
994 owner->view()->update(TEXT(),
995 BufferView::SELECT|BufferView::FITCUR);
998 keyseq.print(buf, true);
1003 // --- Misc -------------------------------------------
1004 case LFUN_EXEC_COMMAND:
1006 std::vector<string> allCmds;
1007 std::transform(lyxaction.func_begin(), lyxaction.func_end(),
1008 std::back_inserter(allCmds), lyx::firster());
1009 static std::vector<string> hist;
1010 owner->getMiniBuffer()->getString(MiniBuffer::spaces,
1015 case LFUN_CANCEL: // RVDK_PATCH_5
1018 if (owner->view()->available())
1019 // cancel any selection
1020 dispatch(LFUN_MARK_OFF);
1021 setMessage(N_("Cancel"));
1024 case LFUN_META_FAKE: // RVDK_PATCH_5
1026 meta_fake_bit = Mod1Mask;
1028 keyseq.print(buf, true);
1029 setMessage(buf); // RVDK_PATCH_5
1033 case LFUN_READ_ONLY_TOGGLE:
1034 if (owner->buffer()->lyxvc.inUse()) {
1035 owner->buffer()->lyxvc.toggleReadOnly();
1037 owner->buffer()->setReadonly(
1038 !owner->buffer()->isReadonly());
1042 case LFUN_CENTER: // this is center and redraw.
1043 owner->view()->center();
1046 // --- Menus -----------------------------------------------
1051 case LFUN_MENUNEWTMPLT:
1055 case LFUN_CLOSEBUFFER:
1059 case LFUN_MENUWRITE:
1060 if (!owner->buffer()->isUnnamed()) {
1062 s1 << _("Saving document") << ' '
1063 << MakeDisplayPath(owner->buffer()->fileName() + "...");
1064 owner->message(s1.str().c_str());
1065 MenuWrite(owner->view(), owner->buffer());
1067 WriteAs(owner->view(), owner->buffer());
1071 WriteAs(owner->view(), owner->buffer(), argument);
1074 case LFUN_MENURELOAD:
1079 Exporter::Export(owner->buffer(), argument, true);
1083 Exporter::Preview(owner->buffer(), argument);
1086 case LFUN_BUILDPROG:
1087 Exporter::Export(owner->buffer(), "program", true);
1090 case LFUN_RUNCHKTEX:
1091 MenuRunChktex(owner->buffer());
1094 case LFUN_MENUPRINT:
1095 owner->getDialogs()->showPrint();
1099 if (argument == "custom")
1102 Exporter::Export(owner->buffer(), argument, false);
1120 InsetCommandParams p;
1123 if (action == LFUN_TOCVIEW)
1125 p.setCmdName("tableofcontents");
1127 else if (action == LFUN_LOAVIEW )
1128 p.setCmdName("listof{algorithm}{List of Algorithms}");
1129 else if (action == LFUN_LOFVIEW)
1130 p.setCmdName("listoffigures");
1132 p.setCmdName("listoftables");
1134 owner->getDialogs()->createTOC(p.getAsString());
1138 case LFUN_DIALOG_TABULAR_INSERT:
1139 owner->getDialogs()->showTabularCreate();
1147 AutoSave(owner->view());
1151 owner->view()->menuUndo();
1155 owner->view()->menuRedo();
1158 case LFUN_MENUSEARCH:
1159 owner->getDialogs()->showSearch();
1162 case LFUN_REMOVEERRORS:
1163 if (owner->view()->removeAutoInsets()) {
1164 owner->view()->redraw();
1165 owner->view()->fitCursor();
1170 changeDepth(owner->view(), TEXT(false), 0);
1173 case LFUN_DEPTH_MIN:
1174 changeDepth(owner->view(), TEXT(false), -1);
1177 case LFUN_DEPTH_PLUS:
1178 changeDepth(owner->view(), TEXT(false), 1);
1182 owner->getDialogs()->setUserFreeFont();
1185 case LFUN_RECONFIGURE:
1186 Reconfigure(owner->view());
1190 case LFUN_FLOATSOPERATE:
1191 if (argument == "openfoot")
1192 owner->view()->allFloats(1,0);
1193 else if (argument == "closefoot")
1194 owner->view()->allFloats(0,0);
1195 else if (argument == "openfig")
1196 owner->view()->allFloats(1,1);
1197 else if (argument == "closefig")
1198 owner->view()->allFloats(0,1);
1201 #ifdef WITH_WARNINGS
1202 //#warning Find another implementation here (or another lyxfunc)!
1205 case LFUN_HELP_ABOUTLYX:
1206 owner->getDialogs()->showAboutlyx();
1209 case LFUN_HELP_TEXINFO:
1210 owner->getDialogs()->showTexinfo();
1213 case LFUN_HELP_OPEN:
1215 string const arg = argument;
1217 setErrorMessage(N_("Missing argument"));
1220 owner->prohibitInput();
1221 string const fname = i18nLibFileSearch("doc", arg, "lyx");
1222 if (fname.empty()) {
1223 lyxerr << "LyX: unable to find documentation file `"
1224 << arg << "'. Bad installation?" << endl;
1225 owner->allowInput();
1229 str << _("Opening help file") << ' '
1230 << MakeDisplayPath(fname) << "...";
1231 owner->message(str.str().c_str());
1232 owner->view()->buffer(bufferlist.loadLyXFile(fname, false));
1233 owner->allowInput();
1237 // --- version control -------------------------------
1238 case LFUN_VC_REGISTER:
1240 if (!owner->buffer()->lyxvc.inUse())
1241 owner->buffer()->lyxvc.registrer();
1245 case LFUN_VC_CHECKIN:
1247 if (owner->buffer()->lyxvc.inUse()
1248 && !owner->buffer()->isReadonly())
1249 owner->buffer()->lyxvc.checkIn();
1253 case LFUN_VC_CHECKOUT:
1255 if (owner->buffer()->lyxvc.inUse()
1256 && owner->buffer()->isReadonly())
1257 owner->buffer()->lyxvc.checkOut();
1261 case LFUN_VC_REVERT:
1263 owner->buffer()->lyxvc.revert();
1269 owner->buffer()->lyxvc.undoLast();
1273 case LFUN_VC_HISTORY:
1275 owner->getDialogs()->showVCLogFile();
1279 // --- buffers ----------------------------------------
1281 case LFUN_SWITCHBUFFER:
1282 owner->view()->buffer(bufferlist.getBuffer(argument));
1287 // servercmd: argument must be <file>:<template>
1288 Buffer * tmpbuf = NewLyxFile(argument);
1290 owner->view()->buffer(tmpbuf);
1294 case LFUN_FILE_OPEN:
1298 case LFUN_LATEX_LOG:
1299 owner->getDialogs()->showLogFile();
1304 lyxerr[Debug::INFO] << "LFUN_LAYOUTNO: (arg) " << argument << endl;
1305 int sel = strToInt(argument);
1306 lyxerr[Debug::INFO] << "LFUN_LAYOUTNO: (sel) "<< sel << endl;
1308 // Should this give a setMessage instead?
1310 return string(); // illegal argument
1312 --sel; // sel 1..., but layout 0...
1314 // Pretend we got the name instead.
1315 dispatch(int(LFUN_LAYOUT),
1316 textclasslist.NameOfLayout(owner->view()
1317 ->buffer()->params.textclass,
1322 case LFUN_LAYOUT_DOCUMENT:
1323 owner->getDialogs()->showDocument();
1326 case LFUN_LAYOUT_PARAGRAPH:
1327 owner->getDialogs()->showParagraph();
1330 case LFUN_LAYOUT_CHARACTER:
1331 owner->getDialogs()->showCharacter();
1334 case LFUN_LAYOUT_TABULAR:
1335 if (owner->view()->theLockingInset()) {
1336 if (owner->view()->theLockingInset()->lyxCode()==Inset::TABULAR_CODE) {
1337 InsetTabular * inset = static_cast<InsetTabular *>
1338 (owner->view()->theLockingInset());
1339 inset->openLayoutDialog(owner->view());
1340 } else if (owner->view()->theLockingInset()->
1341 getFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
1342 InsetTabular * inset = static_cast<InsetTabular *>(
1343 owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
1344 inset->openLayoutDialog(owner->view());
1349 case LFUN_LAYOUT_PREAMBLE:
1350 owner->getDialogs()->showPreamble();
1353 case LFUN_DROP_LAYOUTS_CHOICE:
1354 owner->getToolbar()->openLayoutList();
1357 case LFUN_MENU_OPEN_BY_NAME:
1358 owner->getMenubar()->openByName(argument);
1359 break; // RVDK_PATCH_5
1361 case LFUN_SPELLCHECK:
1362 if (lyxrc.isp_command != "none")
1363 owner->getDialogs()->showSpellchecker();
1366 // --- lyxserver commands ----------------------------
1370 setMessage(owner->buffer()->fileName());
1371 lyxerr[Debug::INFO] << "FNAME["
1372 << owner->buffer()->fileName()
1380 dispatch_buffer = buf;
1381 lyxserver->notifyClient(dispatch_buffer);
1385 case LFUN_GOTOFILEROW:
1389 istringstream istr(argument.c_str());
1390 istr >> file_name >> row;
1391 // Must replace extension of the file to be .lyx and get full path
1392 string const s(ChangeExtension(file_name, ".lyx"));
1394 // Either change buffer or load the file
1395 if (bufferlist.exists(s)) {
1396 owner->view()->buffer(bufferlist.getBuffer(s));
1398 owner->view()->buffer(bufferlist.loadLyXFile(s));
1402 owner->view()->setCursorFromRow(row);
1405 owner->view()->center();
1409 case LFUN_GOTO_PARAGRAPH:
1411 istringstream istr(argument.c_str());
1415 Paragraph * par = owner->buffer()->getParFromID(id);
1417 lyxerr[Debug::INFO] << "No matching paragraph found! ["
1418 << id << "]" << std::endl;
1421 lyxerr << "Paragraph " << par->id()
1422 << " found." << endl;
1426 owner->view()->text->setCursor(owner->view(), par, 0);
1427 owner->view()->setState();
1431 owner->view()->center();
1438 int const qa = lyxaction.LookupFunc(argument);
1439 setMessage(lyxaction.helpText(static_cast<kb_action>(qa)));
1443 // --- toolbar ----------------------------------
1444 case LFUN_PUSH_TOOLBAR:
1446 int nth = strToInt(argument);
1448 setErrorMessage(N_("Push-toolbar needs argument > 0"));
1450 owner->getToolbar()->push(nth);
1455 case LFUN_ADD_TO_TOOLBAR:
1457 if (lyxerr.debugging(Debug::GUI)) {
1458 lyxerr << "LFUN_ADD_TO_TOOLBAR:"
1459 "argument = `" << argument << '\'' << endl;
1461 string tmp(argument);
1462 //lyxerr <<string("Argument: ") + argument);
1463 //lyxerr <<string("Tmp : ") + tmp);
1465 setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
1467 owner->getToolbar()->add(argument, false);
1468 owner->getToolbar()->set();
1473 // --- insert characters ----------------------------------------
1475 // --- Mathed stuff. If we are here, there is no locked inset yet.
1476 case LFUN_MATH_EXTERN:
1477 case LFUN_MATH_NUMBER:
1478 case LFUN_MATH_NONUMBER:
1479 case LFUN_MATH_LIMITS:
1481 setErrorMessage(N_("This is only allowed in math mode!"));
1485 case LFUN_MATH_PANEL:
1486 owner->getDialogs()->showMathPanel();
1489 case LFUN_CITATION_CREATE:
1491 InsetCommandParams p( "cite" );
1493 if (!argument.empty()) {
1494 // This should be set at source, ie when typing
1495 // "citation-insert foo" in the minibuffer.
1496 // Question: would pybibliographer also need to be
1497 // changed. Suspect so. Leave as-is therefore.
1498 if (contains(argument, "|")) {
1499 p.setContents( token(argument, '|', 0) );
1500 p.setOptions( token(argument, '|', 1) );
1502 p.setContents( argument );
1504 dispatch(LFUN_CITATION_INSERT, p.getAsString());
1506 owner->getDialogs()->createCitation( p.getAsString() );
1510 case LFUN_CHILDOPEN:
1512 string const filename =
1513 MakeAbsPath(argument,
1514 OnlyPath(owner->buffer()->fileName()));
1515 setMessage(N_("Opening child document ") +
1516 MakeDisplayPath(filename) + "...");
1517 owner->view()->savePosition(0);
1518 if (bufferlist.exists(filename))
1519 owner->view()->buffer(bufferlist.getBuffer(filename));
1521 owner->view()->buffer(bufferlist.loadLyXFile(filename));
1525 case LFUN_TOGGLECURSORFOLLOW:
1526 lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
1529 case LFUN_KMAP_OFF: // keymap off
1530 owner->getIntl()->KeyMapOn(false);
1533 case LFUN_KMAP_PRIM: // primary keymap
1534 owner->getIntl()->KeyMapPrim();
1537 case LFUN_KMAP_SEC: // secondary keymap
1538 owner->getIntl()->KeyMapSec();
1541 case LFUN_KMAP_TOGGLE: // toggle keymap
1542 owner->getIntl()->ToggleKeyMap();
1547 // argument contains ';'-terminated commands
1548 while (argument.find(';') != string::npos) {
1550 argument = split(argument, first, ';');
1556 case LFUN_DIALOG_PREFERENCES:
1557 owner->getDialogs()->showPreferences();
1560 case LFUN_SAVEPREFERENCES:
1562 Path p(user_lyxdir);
1563 lyxrc.write("preferences");
1567 case LFUN_SCREEN_FONT_UPDATE:
1569 // handle the screen font changes.
1571 lyxrc.set_font_norm_type();
1572 fontloader.update();
1573 // Of course we should only do the resize and the textcache.clear
1574 // if values really changed...but not very important right now. (Lgb)
1575 // All visible buffers will need resize
1577 // We also need to empty the textcache so that
1578 // the buffer will be formatted correctly after
1584 case LFUN_SET_COLOR:
1587 string const x11_name = split(argument, lyx_name, ' ');
1588 if (lyx_name.empty() || x11_name.empty()) {
1589 setErrorMessage(N_("Syntax: set-color <lyx_name>"
1594 if (!lcolor.setColor(lyx_name, x11_name)) {
1595 static string const err1 (N_("Set-color \""));
1596 static string const err2 (
1597 N_("\" failed - color is undefined "
1598 "or may not be redefined"));
1599 setErrorMessage(_(err1) + lyx_name + _(err2));
1602 lyxColorHandler->updateColor(lcolor.getFromLyXName(lyx_name));
1603 owner->view()->redraw();
1608 owner->message(argument);
1611 case LFUN_MESSAGE_PUSH:
1612 owner->messagePush(argument);
1615 case LFUN_MESSAGE_POP:
1616 owner->messagePop();
1620 // Then if it was none of the above
1621 if (!owner->view()->Dispatch(action, argument))
1622 lyxerr << "A truly unknown func ["
1623 << lyxaction.getActionName(action) << "]!"
1630 commandshortcut.erase();
1632 if (lyxrc.display_shortcuts && show_sc) {
1633 if (action != LFUN_SELFINSERT) {
1634 // Put name of command and list of shortcuts
1635 // for it in minibuffer
1636 string comname = lyxaction.getActionName(action);
1638 int pseudoaction = action;
1639 bool argsadded = false;
1641 if (!argument.empty()) {
1642 // If we have the command with argument,
1645 lyxaction.searchActionArg(action,
1648 if (pseudoaction == -1) {
1649 pseudoaction = action;
1651 comname += " " + argument;
1656 string const shortcuts =
1657 toplevel_keymap->findbinding(pseudoaction);
1659 if (!shortcuts.empty()) {
1660 comname += ": " + shortcuts;
1661 } else if (!argsadded) {
1662 comname += " " + argument;
1665 if (!comname.empty()) {
1666 comname = strip(comname);
1667 commandshortcut = "(" + comname + ')';
1669 // Here we could even add a small pause,
1670 // to annoy the user and make him learn
1672 // No! That will just annoy, not teach
1673 // anything. The user will read the messages
1674 // if they are interested. (Asger)
1679 string const res = getMessage();
1682 if (!commandshortcut.empty()) {
1683 owner->getMiniBuffer()->addSet(commandshortcut);
1686 string const msg(_(res) + ' ' + commandshortcut);
1687 owner->message(msg);
1694 void LyXFunc::setupLocalKeymap()
1696 keyseq.stdmap = keyseq.curmap = toplevel_keymap.get();
1697 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap.get();
1701 void LyXFunc::menuNew(bool fromTemplate)
1703 string initpath = lyxrc.document_path;
1705 if (owner->view()->available()) {
1706 string const trypath = owner->buffer()->filepath;
1707 // If directory is writeable, use this as default.
1708 if (IsDirWriteable(trypath))
1712 static int newfile_number;
1715 if (lyxrc.new_ask_filename) {
1716 FileDialog fileDlg(owner, _("Enter filename for new document"),
1717 LFUN_SELECT_FILE_SYNC,
1718 make_pair(string(_("Documents")),
1719 string(lyxrc.document_path)),
1720 make_pair(string(_("Templates")),
1721 string(lyxrc.template_path)));
1723 FileDialog::Result result =
1724 fileDlg.Select(initpath,
1725 _("*.lyx|LyX Documents (*.lyx)"),
1728 if (result.second.empty()) {
1729 owner->message(_("Canceled."));
1730 lyxerr[Debug::INFO] << "New Document Cancelled." << endl;
1734 // get absolute path of file and make sure the filename ends
1736 s = MakeAbsPath(result.second);
1737 if (!IsLyXFilename(s))
1740 // Check if the document already is open
1741 if (bufferlist.exists(s)) {
1742 switch (AskConfirmation(_("Document is already open:"),
1743 MakeDisplayPath(s, 50),
1744 _("Do you want to close that document now?\n"
1745 "('No' will just switch to the open version)")))
1747 case 1: // Yes: close the document
1748 if (!bufferlist.close(bufferlist.getBuffer(s)))
1749 // If close is canceled, we cancel here too.
1752 case 2: // No: switch to the open document
1753 owner->view()->buffer(bufferlist.getBuffer(s));
1755 case 3: // Cancel: Do nothing
1756 owner->message(_("Canceled."));
1760 // Check whether the file already exists
1762 if (fi.readable() &&
1763 AskQuestion(_("File already exists:"),
1764 MakeDisplayPath(s, 50),
1765 _("Do you want to open the document?"))) {
1767 string const disp_fn(MakeDisplayPath(s));
1770 str << _("Opening document") << ' '
1771 << disp_fn << "...";
1773 owner->message(str.str().c_str());
1774 //XFlush(fl_get_display());
1775 owner->view()->buffer(bufferlist.loadLyXFile(s));
1777 str2 << _("Document") << ' '
1778 << disp_fn << ' ' << _("opened.");
1780 owner->message(str2.str().c_str());
1785 s = AddName(lyxrc.document_path,
1786 "newfile" + tostr(++newfile_number) + ".lyx");
1788 while (bufferlist.exists(s) || fi.readable()) {
1790 s = AddName(lyxrc.document_path,
1791 "newfile" + tostr(newfile_number) +
1797 // The template stuff
1800 FileDialog fileDlg(owner, _("Select template file"),
1801 LFUN_SELECT_FILE_SYNC,
1802 make_pair(string(_("Documents")),
1803 string(lyxrc.document_path)),
1804 make_pair(string(_("Templates")),
1805 string(lyxrc.template_path)));
1807 FileDialog::Result result =
1808 fileDlg.Select(lyxrc.template_path,
1809 _("*.lyx|LyX Documents (*.lyx)"));
1811 if (result.first == FileDialog::Later)
1814 string const fname = result.second;
1821 // find a free buffer
1822 lyxerr[Debug::INFO] << "Find a free buffer." << endl;
1823 owner->view()->buffer(bufferlist.newFile(s, templname));
1827 void LyXFunc::open(string const & fname)
1829 string initpath = lyxrc.document_path;
1831 if (owner->view()->available()) {
1832 string const trypath = owner->buffer()->filepath;
1833 // If directory is writeable, use this as default.
1834 if (IsDirWriteable(trypath))
1840 if (fname.empty()) {
1841 FileDialog fileDlg(owner, _("Select document to open"),
1843 make_pair(string(_("Documents")),
1844 string(lyxrc.document_path)),
1845 make_pair(string(_("Examples")),
1846 string(AddPath(system_lyxdir, "examples"))));
1848 FileDialog::Result result =
1849 fileDlg.Select(initpath,
1850 "*.lyx|LyX Documents (*.lyx)");
1852 if (result.first == FileDialog::Later)
1855 filename = result.second;
1857 // check selected filename
1858 if (filename.empty()) {
1859 owner->message(_("Canceled."));
1865 // get absolute path of file and add ".lyx" to the filename if
1867 string const fullpath = FileSearch(string(), filename, "lyx");
1868 if (fullpath.empty()) {
1869 WriteAlert(_("Error"), _("Could not find file"), filename);
1873 filename = fullpath;
1876 string const disp_fn(MakeDisplayPath(filename));
1879 str << _("Opening document") << ' ' << disp_fn << "...";
1881 owner->message(str.str().c_str());
1883 Buffer * openbuf = bufferlist.loadLyXFile(filename);
1885 owner->view()->buffer(openbuf);
1887 str << _("Document") << ' ' << disp_fn << ' ' << _("opened.");
1888 owner->message(str.str().c_str());
1891 str << _("Could not open document") << ' ' << disp_fn;
1892 owner->message(str.str().c_str());
1897 // checks for running without gui are missing.
1898 void LyXFunc::doImport(string const & argument)
1901 string filename = split(argument, format, ' ');
1902 lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format
1903 << " file: " << filename << endl;
1905 if (filename.empty()) { // need user interaction
1906 string initpath = lyxrc.document_path;
1908 if (owner->view()->available()) {
1909 string const trypath = owner->buffer()->filepath;
1910 // If directory is writeable, use this as default.
1911 if (IsDirWriteable(trypath))
1915 string const text = _("Select ") + formats.prettyName(format)
1916 + _(" file to import");
1918 FileDialog fileDlg(owner, text,
1920 make_pair(string(_("Documents")),
1921 string(lyxrc.document_path)),
1922 make_pair(string(_("Examples")),
1923 string(AddPath(system_lyxdir, "examples"))));
1925 string const extension = "*." + formats.extension(format)
1926 + "| " + formats.prettyName(format)
1927 + " (*." + formats.extension(format) + ")";
1929 FileDialog::Result result = fileDlg.Select(initpath,
1932 if (result.first == FileDialog::Later)
1935 filename = result.second;
1937 // check selected filename
1938 if (filename.empty())
1939 owner->message(_("Canceled."));
1942 // still no filename? abort
1943 if (filename.empty())
1946 // get absolute path of file
1947 filename = MakeAbsPath(filename);
1949 string const lyxfile = ChangeExtension(filename, ".lyx");
1951 // Check if the document already is open
1952 if (bufferlist.exists(lyxfile)) {
1953 switch (AskConfirmation(_("Document is already open:"),
1954 MakeDisplayPath(lyxfile, 50),
1955 _("Do you want to close that document now?\n"
1956 "('No' will just switch to the open version)")))
1958 case 1: // Yes: close the document
1959 if (!bufferlist.close(bufferlist.getBuffer(lyxfile)))
1960 // If close is canceled, we cancel here too.
1963 case 2: // No: switch to the open document
1964 owner->view()->buffer(bufferlist.getBuffer(lyxfile));
1966 case 3: // Cancel: Do nothing
1967 owner->message(_("Canceled."));
1972 // Check if a LyX document by the same root exists in filesystem
1973 FileInfo const f(lyxfile, true);
1974 if (f.exist() && !AskQuestion(_("A document by the name"),
1975 MakeDisplayPath(lyxfile),
1976 _("already exists. Overwrite?"))) {
1977 owner->message(_("Canceled"));
1980 // filename should be valid now
1982 Importer::Import(owner, filename, format);
1986 void LyXFunc::reloadBuffer()
1988 string const fn = owner->buffer()->fileName();
1989 if (bufferlist.close(owner->buffer()))
1990 owner->view()->buffer(bufferlist.loadLyXFile(fn));
1994 void LyXFunc::closeBuffer()
1996 if (bufferlist.close(owner->buffer()) && !quitting) {
1997 if (bufferlist.empty()) {
1998 // need this otherwise SEGV may occur while trying to
1999 // set variables that don't exist
2000 // since there's no current buffer
2001 owner->getDialogs()->hideBufferDependent();
2003 owner->view()->buffer(bufferlist.first());
2009 // Each "owner" should have it's own message method. lyxview and
2010 // the minibuffer would use the minibuffer, but lyxserver would
2011 // send an ERROR signal to its client. Alejandro 970603
2012 // This func is bit problematic when it comes to NLS, to make the
2013 // lyx servers client be language indepenent we must not translate
2014 // strings sent to this func.
2015 void LyXFunc::setErrorMessage(string const & m) const
2017 dispatch_buffer = m;
2022 void LyXFunc::setMessage(string const & m)
2024 dispatch_buffer = m;
2028 void LyXFunc::initMiniBuffer()
2030 string text = _("Welcome to LyX!");
2032 // When meta-fake key is pressed, show the key sequence so far + "M-".
2038 // Else, when a non-complete key sequence is pressed,
2039 // show the available options.
2040 else if (keyseqUncomplete())
2041 text = keyseqOptions();
2043 // Else, show the buffer state.
2044 else if (owner->view()->available()) {
2045 Buffer * tmpbuf = owner->buffer();
2047 string const nicename =
2048 MakeDisplayPath(tmpbuf->fileName());
2049 // Should we do this instead? (kindo like emacs)
2050 // leaves more room for other information
2053 if (tmpbuf->lyxvc.inUse()) {
2055 text += tmpbuf->lyxvc.versionString();
2057 text += tmpbuf->lyxvc.locker();
2058 if (tmpbuf->isReadonly())
2061 } else if (tmpbuf->isReadonly())
2063 if (!tmpbuf->isLyxClean())
2064 text += _(" (Changed)");
2066 if (text != _("Welcome to LyX!")) // this is a hack
2067 text = _("* No document open *");
2070 owner->message(text);