1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2000 The LyX Team.
9 * ====================================================== */
20 #pragma implementation
23 #include "lyxlookup.h"
26 #include "bufferlist.h"
27 #include "lyxserver.h"
32 #include "LyXAction.h"
33 #include "insets/inseturl.h"
34 #include "insets/insetlatexaccent.h"
35 #include "insets/insettoc.h"
36 #include "insets/insetlof.h"
37 #include "insets/insetloa.h"
38 #include "insets/insetlot.h"
39 #include "insets/insetref.h"
40 #include "insets/insetparent.h"
41 #include "insets/insetindex.h"
42 #include "insets/insetinclude.h"
43 #include "insets/insetbib.h"
44 #include "mathed/formulamacro.h"
46 #include "spellchecker.h" // RVDK_PATCH_5
47 #include "minibuffer.h"
51 #include "lyx_gui_misc.h"
52 #include "support/filetools.h"
53 #include "support/FileInfo.h"
54 #include "support/syscall.h"
55 #include "support/lstrings.h"
56 #include "support/path.h"
57 #include "lyxscreen.h"
62 #include "trans_mgr.h"
63 #include "ImportLaTeX.h"
64 #include "ImportNoweb.h"
67 extern bool cursor_follows_scrollbar;
69 extern void InsertAsciiFile(string const &, bool);
70 extern void math_insert_symbol(char const *);
71 extern Bool math_insert_greek(char const); // why "Bool"?
72 extern BufferList bufferlist;
73 extern LyXServer * lyxserver;
74 extern short greek_kb_flag;
75 extern FD_form_toc * fd_form_toc;
76 extern bool selection_possible;
78 extern kb_keymap * toplevel_keymap;
80 extern void MenuWrite(Buffer *);
81 extern void MenuWriteAs(Buffer *);
82 extern int MenuRunLaTeX(Buffer *);
83 extern int MenuBuildProg(Buffer *);
84 extern int MenuRunChktex(Buffer *);
85 extern bool CreatePostscript(Buffer *, bool);
86 extern void MenuPrint(Buffer *);
87 extern void MenuSendto();
88 extern void QuitLyX();
89 extern void MenuFax(Buffer *);
90 extern void MenuExport(Buffer *, string const &);
91 extern void MenuPasteSelection(char at);
92 extern LyXAction lyxaction;
94 extern tex_accent_struct get_accent(kb_action action);
96 extern void AutoSave();
97 extern void MenuSearch();
98 extern void SetUpdateTimer(float timer = 0.3);
99 extern void FreeUpdateTimer();
100 extern bool PreviewDVI(Buffer *);
101 extern bool PreviewPostscript(Buffer *);
102 extern void MenuInsertLabel(char const *);
103 extern void MenuInsertRef();
104 extern void MenuLayoutCharacter();
105 extern void MenuLayoutParagraph();
106 extern void MenuLayoutDocument();
107 extern void MenuLayoutPaper();
108 extern void MenuLayoutTable(int flag);
109 extern void MenuLayoutQuotes();
110 extern void MenuLayoutPreamble();
111 extern void MenuLayoutSave();
112 extern void bulletForm();
114 extern Buffer * NewLyxFile(string const &);
115 extern void LoadLyXFile(string const &);
116 extern void Reconfigure(BufferView *);
118 extern int current_layout;
119 extern int getISOCodeFromLaTeX(char *);
121 extern void ShowLatexLog();
123 extern void UpdateInset(BufferView *, Inset * inset, bool mark_dirty = true);
125 /* === globals =========================================================== */
127 bool LyXFunc::show_sc = true;
130 LyXFunc::LyXFunc(LyXView * o)
134 lyx_dead_action = LFUN_NOACTION;
135 lyx_calling_dead_action = LFUN_NOACTION;
140 // I changed this func slightly. I commented out the ...FinishUndo(),
141 // this means that all places that used to have a moveCursorUpdate, now
142 // have a ...FinishUndo() as the preceeding statement. I have also added
143 // a moveCursorUpdate to some of the functions that updated the cursor, but
144 // that did not show its new position.
146 void LyXFunc::moveCursorUpdate(bool selecting)
148 if (selecting || owner->view()->text->mark_set) {
149 owner->view()->text->SetSelection();
150 owner->view()->getScreen()->ToggleToggle();
151 owner->view()->update(0);
153 owner->view()->update(-2); // this IS necessary
157 owner->view()->getScreen()->ShowCursor();
159 /* ---> Everytime the cursor is moved, show the current font state. */
160 // should this too me moved out of this func?
161 //owner->getMiniBuffer()->Set(CurrentState());
162 owner->view()->SetState();
166 int LyXFunc::processKeyEvent(XEvent * ev)
170 XKeyEvent * keyevent = &ev->xkey;
171 KeySym keysym_return;
173 int num_bytes = LyXLookupString(ev, s_r, 10, &keysym_return);
174 s_r[num_bytes] = '\0';
176 if (lyxerr.debugging(Debug::KEY)) {
177 char * tmp = XKeysymToString(keysym_return);
178 string stm = (tmp ? tmp : "");
179 lyxerr << "KeySym is "
182 << keysym_return << "]"
183 << " and num_bytes is "
185 << " the string returned is \""
186 << s_r << '\"' << endl;
188 // Do nothing if we have nothing (JMarc)
189 if (num_bytes == 0 && keysym_return == NoSymbol) {
190 lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
195 // this function should be used always [asierra060396]
196 if (owner->view()->available() &&
197 owner->view()->the_locking_inset &&
198 keysym_return == XK_Escape) {
199 owner->view()->unlockInset(owner->view()->the_locking_inset);
200 owner->view()->text->CursorRight();
201 moveCursorUpdate(false);
202 owner->getMiniBuffer()->Set(CurrentState());
206 // Can we be sure that this will work for all X-Windows
207 // implementations? (Lgb)
208 // This code snippet makes lyx ignore some keys. Perhaps
209 // all of them should be explictly mentioned?
210 if((keysym_return >= XK_Shift_L && keysym_return <= XK_Hyper_R)
211 || keysym_return == XK_Mode_switch || keysym_return == 0x0)
214 // Do a one-deep top-level lookup for
215 // cancel and meta-fake keys. RVDK_PATCH_5
216 cancel_meta_seq.reset();
218 int action = cancel_meta_seq.addkey(keysym_return, keyevent->state
219 &(ShiftMask|ControlMask
222 // When not cancel or meta-fake, do the normal lookup.
223 // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
224 // Mostly, meta_fake_bit = 0. RVDK_PATCH_5.
225 if ( (action != LFUN_CANCEL) && (action != LFUN_META_FAKE) ) {
227 // remove Caps Lock and Mod2 as a modifiers
228 action = keyseq.addkey(keysym_return,
229 (keyevent->state | meta_fake_bit)
230 &(ShiftMask|ControlMask
233 // Dont remove this unless you know what you are doing.
236 if (action == 0) action = LFUN_PREFIX;
238 if (lyxerr.debugging(Debug::KEY)) {
244 << num_bytes << "]" << endl;
247 // already here we know if it any point in going further
248 // why not return already here if action == -1 and
249 // num_bytes == 0? (Lgb)
251 if(keyseq.length > 1 || keyseq.length < -1) {
254 owner->getMiniBuffer()->Set(buf);
258 if (keyseq.length < -1) { // unknown key sequence...
262 owner->getMiniBuffer()->Set(_("Unknown sequence:"), buf);
266 char isochar = keyseq.getiso();
267 if (!(keyevent->state&ControlMask) &&
268 !(keyevent->state&Mod1Mask) &&
269 (isochar && keysym_return < 0xF000)) {
272 if (argument.empty()) {
273 lyxerr.debug() << "Empty argument!" << endl;
274 // This can`t possibly be of any use
275 // so we`ll skip the dispatch.
279 if (action == LFUN_SELFINSERT) {
283 bool tmp_sc = show_sc;
285 Dispatch(action, argument.c_str());
292 LyXFunc::func_status LyXFunc::getStatus(int ac) const
295 func_status flag = LyXFunc::OK;
297 Buffer * buf = owner->buffer();
299 if (lyxaction.isPseudoAction(ac))
300 action = lyxaction.retrieveActionArg(ac, argument);
302 action = static_cast<kb_action>(ac);
304 if (action == LFUN_UNKNOWN_ACTION) {
305 setErrorMessage(N_("Unknown action"));
306 return LyXFunc::Unknown;
309 // Check whether we need a buffer
310 if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) {
311 // Yes we need a buffer, do we have one?
314 // Can we use a readonly buffer?
315 if (buf->isReadonly() &&
316 !lyxaction.funcHasFlag(action,
317 LyXAction::ReadOnly)) {
319 setErrorMessage(N_("Document is read-only"));
320 flag |= LyXFunc::Disabled;
324 setErrorMessage(N_("Command not allowed with"
325 "out any document open"));
326 flag |= LyXFunc::Disabled;
330 if (flag & LyXFunc::Disabled)
333 // I would really like to avoid having this switch and rather try to
334 // encode this in the function itself.
335 static bool noLaTeX = lyxrc->latex_command == "none";
336 bool disable = false;
339 disable = noLaTeX || lyxrc->view_dvi_command == "none";
342 disable = noLaTeX || lyxrc->view_ps_command == "none";
349 disable = noLaTeX || lyxrc->print_command == "none";
352 disable = noLaTeX || lyxrc->fax_command == "none";
355 if (argument == "latex")
356 disable = lyxrc->relyx_command == "none";
359 if (argument == "dvi" || argument == "postscript")
361 if (argument == "html")
362 disable = lyxrc->html_command == "none";
365 disable = buf->undostack.empty();
368 disable = buf->redostack.empty();
370 case LFUN_SPELLCHECK:
371 disable = lyxrc->isp_command == "none";
374 disable = lyxrc->chktex_command == "none";
376 case LFUN_LAYOUT_TABLE:
377 disable = ! owner->view()->text->cursor.par->table;
383 flag |= LyXFunc::Disabled;
386 func_status box = LyXFunc::ToggleOff;
387 LyXFont font = owner->view()->text->real_current_font;
390 if (font.emph() == LyXFont::ON)
391 box = LyXFunc::ToggleOn;
394 if (font.noun() == LyXFont::ON)
395 box = LyXFunc::ToggleOn;
398 if (font.series() == LyXFont::BOLD_SERIES)
399 box = LyXFunc::ToggleOn;
402 if (font.latex() == LyXFont::ON)
403 box = LyXFunc::ToggleOn;
406 if (font.direction() == LyXFont::RTL_DIR)
407 box = LyXFunc::ToggleOn;
420 string LyXFunc::Dispatch(string const & s)
422 // Split command string into command and argument
423 string cmd, line = frontStrip(s);
424 string arg = strip(frontStrip(split(line, cmd, ' ')));
426 return Dispatch(lyxaction.LookupFunc(cmd.c_str()), arg.c_str());
430 string LyXFunc::Dispatch(int ac,
431 char const * do_not_use_this_arg)
436 // we have not done anything wrong yet.
438 dispatch_buffer.clear();
440 // if action is a pseudo-action, we need the real action
441 if (lyxaction.isPseudoAction(ac)) {
443 action = static_cast<kb_action>
444 (lyxaction.retrieveActionArg(ac, tmparg));
448 action = static_cast<kb_action>(ac);
449 if (do_not_use_this_arg)
450 argument = do_not_use_this_arg; // except here
453 selection_possible = false;
455 if (owner->view()->available()
456 && owner->view()->getScreen())
457 owner->view()->getScreen()->HideCursor();
459 // We cannot use this function here
460 if (getStatus(action) & Disabled)
461 goto exit_with_message;
463 commandshortcut.clear();
465 if (lyxrc->display_shortcuts && show_sc) {
466 if (action != LFUN_SELFINSERT) {
467 // Put name of command and list of shortcuts
468 // for it in minibuffer
469 string comname = lyxaction.getActionName(action);
471 int pseudoaction = action;
472 bool argsadded = false;
474 if (!argument.empty()) {
475 // If we have the command with argument,
478 lyxaction.searchActionArg(action,
481 if (pseudoaction == -1) {
482 pseudoaction = action;
484 comname += " " + argument;
489 string shortcuts = toplevel_keymap->findbinding(pseudoaction);
491 if (!shortcuts.empty()) {
492 comname += ": " + shortcuts;
493 } else if (!argsadded) {
494 comname += " " + argument;
497 if (!comname.empty()) {
498 comname = strip(comname);
499 commandshortcut = "(" + comname + ')';
500 owner->getMiniBuffer()->Set(commandshortcut);
501 // Here we could even add a small pause,
502 // to annoy the user and make him learn
504 // No! That will just annoy, not teach
505 // anything. The user will read the messages
506 // if they are interested. (Asger)
511 // If in math mode pass the control to
512 // the math inset [asierra060396]
513 if (owner->view()->available() &&
514 owner->view()->the_locking_inset) {
516 || (action == LFUN_UNKNOWN_ACTION
517 && keyseq.length >= -1)) {
518 if (action == LFUN_UNKNOWN_ACTION
519 && argument.empty()) {
520 argument = keyseq.getiso();
522 // Undo/Redo pre 0.13 is a bit tricky for insets.
523 if (action == LFUN_UNDO) {
525 UpdatableInset * inset =
526 owner->view()->the_locking_inset;
527 inset->GetCursorPos(slx, sly);
528 owner->view()->unlockInset(inset);
529 owner->view()->menuUndo();
530 inset = static_cast<UpdatableInset*>(owner->view()->text->cursor.par->GetInset(owner->view()->text->cursor.pos));
532 inset->Edit(slx, sly);
535 if (action == LFUN_REDO) {
537 UpdatableInset * inset = owner->view()->the_locking_inset;
538 inset->GetCursorPos(slx, sly);
539 owner->view()->unlockInset(inset);
540 owner->view()->menuRedo();
541 inset = static_cast<UpdatableInset*>(owner->view()->text->cursor.par->GetInset(owner->view()->text->cursor.pos));
543 inset->Edit(slx, sly);
546 if (owner->view()->the_locking_inset->LocalDispatch(action, argument.c_str()))
549 setMessage(N_("Text mode"));
550 LyXDirection direction = owner->view()->text->cursor.par->getParDirection();
552 (action == LFUN_RIGHT
553 && direction == LYX_DIR_LEFT_TO_RIGHT)) {
554 owner->view()->text->CursorRight();
555 moveCursorUpdate(false);
556 owner->getMiniBuffer()->Set(CurrentState());
558 if ( action == LFUN_LEFT
559 && direction == LYX_DIR_RIGHT_TO_LEFT) {
560 owner->view()->text->CursorRight();
561 moveCursorUpdate(false);
562 owner->getMiniBuffer()->Set(CurrentState());
564 if (action == LFUN_LEFT || action == LFUN_RIGHT)
571 // --- Misc -------------------------------------------
572 case LFUN_WORDFINDFORWARD :
573 case LFUN_WORDFINDBACKWARD : {
574 static string last_search;
575 string searched_string;
577 if (!argument.empty()) {
578 last_search = argument;
579 searched_string = argument;
581 searched_string = last_search;
584 LyXText * ltCur = owner->view()->text ;
586 if (!searched_string.empty() &&
587 ((action == LFUN_WORDFINDBACKWARD) ?
588 ltCur->SearchBackward(searched_string.c_str()) :
589 ltCur->SearchForward(searched_string.c_str()))) {
591 // ??? What is that ???
592 owner->view()->update(-2);
595 // clear the selection (if there is any)
596 owner->view()->getScreen()->ToggleSelection();
597 owner->view()->text->ClearSelection();
599 // Move cursor so that successive C-s 's will not stand in place.
600 if( action == LFUN_WORDFINDFORWARD )
601 owner->view()->text->CursorRightOneWord();
602 owner->view()->text->FinishUndo();
603 moveCursorUpdate(false);
606 // set the new selection
607 // SetSelectionOverLenChars(owner->view()->currentBuffer()->text, iLenSelected);
608 owner->view()->getScreen()->ToggleSelection(false);
612 // REMOVED : if (owner->view()->getWorkArea()->focus)
613 owner->view()->getScreen()->ShowCursor();
619 if (owner->view()->available()
620 && owner->view()->getScreen()) {
621 owner->view()->update(-2);
624 keyseq.print(buf, true);
625 owner->getMiniBuffer()->Set(buf, string(), string(), 1);
629 // --- Misc -------------------------------------------
630 case LFUN_EXEC_COMMAND:
631 owner->getMiniBuffer()->ExecCommand();
634 case LFUN_CANCEL: // RVDK_PATCH_5
637 if(owner->view()->available())
638 // cancel any selection
639 Dispatch(LFUN_MARK_OFF, 0);
640 setMessage(N_("Cancel"));
643 case LFUN_META_FAKE: // RVDK_PATCH_5
645 meta_fake_bit = Mod1Mask;
647 keyseq.print(buf, true);
648 string res = string("M-") + buf;
649 setMessage(buf); // RVDK_PATCH_5
653 case LFUN_READ_ONLY_TOGGLE:
654 if (owner->buffer()->lyxvc.inUse()) {
655 owner->buffer()->lyxvc.toggleReadOnly();
657 owner->buffer()->setReadonly(
658 !owner->buffer()->isReadonly());
662 case LFUN_CENTER: // this is center and redraw.
663 owner->view()->beforeChange();
664 if (owner->view()->text->cursor.y >
665 owner->view()->getWorkArea()->h / 2) {
666 owner->view()->getScreen()->
667 Draw(owner->view()->text->cursor.y -
668 owner->view()->getWorkArea()->h / 2);
670 owner->view()->getScreen()->
673 owner->view()->update(0);
674 owner->view()->redraw();
678 if (owner->view()->available()) {
679 owner->view()->text->toggleAppendix();
680 owner->view()->update(1);
684 // --- Menus -----------------------------------------------
689 case LFUN_MENUNEWTMPLT:
697 case LFUN_CLOSEBUFFER:
702 MenuWrite(owner->buffer());
705 case LFUN_MENUWRITEAS:
706 MenuWriteAs(owner->buffer());
709 case LFUN_MENURELOAD:
714 PreviewDVI(owner->buffer());
718 PreviewPostscript(owner->buffer());
722 MenuRunLaTeX(owner->buffer());
726 MenuBuildProg(owner->buffer());
730 MenuRunChktex(owner->buffer());
734 CreatePostscript(owner->buffer(), false);
738 MenuPrint(owner->buffer());
742 MenuFax(owner->buffer());
746 MenuExport(owner->buffer(), argument);
751 //needs argument as string
752 string imtyp = argument;
755 if (imtyp == "latex") {
756 doImportLaTeX(false);
759 else if (imtyp == "ascii") {
760 doImportASCII(false);
761 } else if (imtyp == "asciiparagraph") {
764 } else if (imtyp == "noweb") {
767 setErrorMessage(string(N_("Unknown import type: "))
779 if (fd_form_toc->form_toc->visible) {
780 fl_raise_form(fd_form_toc->form_toc);
782 static int ow = -1, oh;
783 fl_show_form(fd_form_toc->form_toc,
785 FL_FREE_SIZE, FL_FULLBORDER,
786 _("Table of Contents"));
788 ow = fd_form_toc->form_toc->w;
789 oh = fd_form_toc->form_toc->h;
791 fl_set_form_minsize(fd_form_toc->form_toc, ow, oh);
795 case LFUN_TOC_INSERT:
797 Inset * new_inset = new InsetTOC(owner->buffer());
798 owner->view()->insertInset(new_inset, "Standard", true);
802 case LFUN_LOF_INSERT:
804 Inset * new_inset = new InsetLOF(owner->buffer());
805 owner->view()->insertInset(new_inset, "Standard", true);
809 case LFUN_LOA_INSERT:
811 Inset * new_inset = new InsetLOA(owner->buffer());
812 owner->view()->insertInset(new_inset, "Standard", true);
816 case LFUN_LOT_INSERT:
818 Inset * new_inset = new InsetLOT(owner->buffer());
819 owner->view()->insertInset(new_inset, "Standard", true);
836 owner->view()->menuUndo();
840 owner->view()->menuRedo();
843 case LFUN_MENUSEARCH:
848 owner->view()->paste();
851 case LFUN_PASTESELECTION:
854 if (argument == "paragraph") asPara = true;
855 MenuPasteSelection(asPara);
860 owner->view()->cut();
864 owner->view()->copy();
867 case LFUN_LAYOUT_COPY:
868 owner->view()->copyEnvironment();
871 case LFUN_LAYOUT_PASTE:
872 owner->view()->pasteEnvironment();
876 owner->view()->gotoError();
879 case LFUN_REMOVEERRORS:
880 if (owner->view()->removeAutoInsets()) {
881 owner->view()->redraw();
882 owner->view()->fitCursor();
883 owner->view()->updateScrollbar();
888 owner->view()->gotoNote();
892 owner->view()->openStuff();
895 case LFUN_HYPHENATION:
896 owner->view()->hyphenationPoint();
900 owner->view()->ldots();
903 case LFUN_END_OF_SENTENCE:
904 owner->view()->endOfSentenceDot();
907 case LFUN_MENU_SEPARATOR:
908 owner->view()->menuSeparator();
912 owner->view()->hfill();
916 changeDepth(owner->view(), 0);
920 changeDepth(owner->view(), -1);
923 case LFUN_DEPTH_PLUS:
924 changeDepth(owner->view(), 1);
933 owner->view()->SetState();
934 owner->getMiniBuffer()->Set(CurrentState());
941 case LFUN_RECONFIGURE:
942 Reconfigure(owner->view());
946 if (owner->view()->available()
947 && !owner->view()->text->selection
948 && owner->view()->text->cursor.par->footnoteflag
949 != LyXParagraph::NO_FOOTNOTE)
950 { // only melt footnotes with FOOTMELT, not margins etc
951 if(owner->view()->text->cursor.par->footnotekind == LyXParagraph::FOOTNOTE)
956 owner->view()->SetState();
959 case LFUN_MARGINMELT:
960 if (owner->view()->available()
961 && !owner->view()->text->selection
962 && owner->view()->text->cursor.par->footnoteflag
963 != LyXParagraph::NO_FOOTNOTE) {
965 if(owner->view()->text->cursor.par->footnotekind == LyXParagraph::MARGIN)
968 Margin(owner->view());
969 owner->view()->SetState();
972 // --- version control -------------------------------
973 case LFUN_VC_REGISTER:
975 if (!owner->buffer()->lyxvc.inUse())
976 owner->buffer()->lyxvc.registrer();
980 case LFUN_VC_CHECKIN:
982 if (owner->buffer()->lyxvc.inUse()
983 && !owner->buffer()->isReadonly())
984 owner->buffer()->lyxvc.checkIn();
988 case LFUN_VC_CHECKOUT:
990 if (owner->buffer()->lyxvc.inUse()
991 && owner->buffer()->isReadonly())
992 owner->buffer()->lyxvc.checkOut();
998 owner->buffer()->lyxvc.revert();
1004 owner->buffer()->lyxvc.undoLast();
1008 case LFUN_VC_HISTORY:
1010 owner->buffer()->lyxvc.showLog();
1014 // --- buffers ----------------------------------------
1016 case LFUN_FILE_INSERT:
1018 MenuInsertLyXFile(argument);
1022 case LFUN_FILE_INSERT_ASCII:
1024 bool asPara = (argument == "paragraph");
1025 InsertAsciiFile(string(), asPara);
1031 // servercmd: argument must be <file>:<template>
1032 Buffer * tmpbuf = NewLyxFile(argument);
1034 owner->view()->buffer(tmpbuf);
1038 case LFUN_FILE_OPEN:
1039 owner->view()->buffer(bufferlist.loadLyXFile(argument));
1042 case LFUN_LATEX_LOG:
1048 lyxerr.debug() << "LFUN_LAYOUTNO: (arg) " << argument << endl;
1049 int sel = strToInt(argument);
1050 lyxerr.debug() << "LFUN_LAYOUTNO: (sel) "<< sel << endl;
1052 // Should this give a setMessage instead?
1054 return string(); // illegal argument
1056 --sel; // sel 1..., but layout 0...
1058 // Pretend we got the name instead.
1059 Dispatch(int(LFUN_LAYOUT),
1060 textclasslist.NameOfLayout(owner->view()->
1069 lyxerr.debug() << "LFUN_LAYOUT: (arg) "
1070 << argument << endl;
1072 // Derive layout number from given argument (string)
1073 // and current buffer's textclass (number). */
1075 textclasslist.NumberOfLayout(owner->
1081 // see if we found the layout number:
1082 if (layoutno == -1) {
1083 setErrorMessage(string(N_("Layout ")) + argument +
1088 if (current_layout != layoutno) {
1089 owner->view()->getScreen()->HideCursor();
1090 current_layout = layoutno;
1091 owner->view()->update(-2);
1092 owner->view()->text->
1093 SetLayout(layoutno);
1094 owner->getToolbar()->combox->
1095 select(owner->view()->
1098 owner->view()->update(1);
1103 case LFUN_LAYOUT_DOCUMENT:
1104 MenuLayoutDocument();
1107 case LFUN_LAYOUT_PARAGRAPH:
1108 MenuLayoutParagraph();
1111 case LFUN_LAYOUT_CHARACTER:
1112 MenuLayoutCharacter();
1115 case LFUN_LAYOUT_TABLE:
1118 if (argument == "true") flag = 1;
1119 MenuLayoutTable(flag);
1123 case LFUN_LAYOUT_PAPER:
1127 case LFUN_LAYOUT_QUOTES:
1131 case LFUN_LAYOUT_PREAMBLE:
1132 MenuLayoutPreamble();
1135 case LFUN_LAYOUT_SAVE_DEFAULT:
1139 case LFUN_DROP_LAYOUTS_CHOICE:
1140 owner->getToolbar()->combox->Show();
1146 owner->view()->SetState();
1147 owner->getMiniBuffer()->Set(CurrentState());
1179 case LFUN_UNDERLINE:
1183 case LFUN_FONT_SIZE:
1187 case LFUN_FONT_STATE:
1188 setMessage(CurrentState());
1191 case LFUN_UPCASE_WORD:
1192 owner->view()->update(-2);
1194 owner->view()->text->ChangeWordCase(LyXText::text_uppercase);
1195 owner->view()->update(1);
1199 case LFUN_LOWCASE_WORD:
1200 owner->view()->update(-2);
1202 owner->view()->text->ChangeWordCase(LyXText::text_lowercase);
1203 owner->view()->update(1);
1207 case LFUN_CAPITALIZE_WORD:
1208 owner->view()->update(-2);
1210 owner->view()->text->ChangeWordCase(LyXText::text_capitalization);
1211 owner->view()->update(1);
1215 case LFUN_INSERT_LABEL:
1216 MenuInsertLabel(argument.c_str());
1219 case LFUN_INSERT_REF:
1223 case LFUN_REFTOGGLE:
1226 static_cast<InsetRef*>(getInsetByCode(Inset::REF_CODE));
1228 if (inset->getFlag() == InsetRef::REF)
1229 inset->setFlag(InsetRef::PAGE_REF);
1231 inset->setFlag(InsetRef::REF);
1232 UpdateInset(owner->view(), inset);
1234 setErrorMessage(N_("No cross-reference to toggle"));
1241 owner->view()->restorePosition();
1247 string label(argument);
1248 if (label.empty()) {
1250 static_cast<InsetRef*>(getInsetByCode(Inset::REF_CODE));
1252 label = inset->getContents();
1255 if (!label.empty()) {
1256 owner->view()->savePosition();
1257 owner->view()->gotoLabel(label.c_str());
1262 case LFUN_MENU_OPEN_BY_NAME:
1263 owner->getMenus()->openByName(argument);
1264 break; // RVDK_PATCH_5
1266 case LFUN_SPELLCHECK:
1267 if (lyxrc->isp_command != "none")
1269 break; // RVDK_PATCH_5
1271 // --- Cursor Movements -----------------------------
1274 LyXText * tmptext = owner->view()->text;
1275 LyXDirection direction =
1276 tmptext->cursor.par->getParDirection();
1277 if(!tmptext->mark_set)
1278 owner->view()->beforeChange();
1279 owner->view()->update(-2);
1280 if (direction == LYX_DIR_RIGHT_TO_LEFT)
1281 tmptext->CursorLeft();
1282 if (tmptext->cursor.pos < tmptext->cursor.par->Last()
1283 && tmptext->cursor.par->GetChar(tmptext->cursor.pos)
1284 == LyXParagraph::META_INSET
1285 && tmptext->cursor.par->GetInset(tmptext->cursor.pos)
1286 && tmptext->cursor.par->GetInset(tmptext->cursor.pos)->Editable() == 2){
1287 Inset * tmpinset = tmptext->cursor.par->GetInset(tmptext->cursor.pos);
1288 setMessage(tmpinset->EditMessage());
1289 tmpinset->Edit(0, 0);
1292 if (direction == LYX_DIR_LEFT_TO_RIGHT)
1293 tmptext->CursorRight();
1294 owner->view()->text->FinishUndo();
1295 moveCursorUpdate(false);
1296 owner->getMiniBuffer()->Set(CurrentState());
1302 // This is soooo ugly. Isn`t it possible to make
1303 // it simpler? (Lgb)
1304 LyXText * txt = owner->view()->text;
1305 LyXDirection direction = txt->cursor.par->getParDirection();
1306 if(!txt->mark_set) owner->view()->beforeChange();
1307 owner->view()->update(-2);
1308 if (direction == LYX_DIR_LEFT_TO_RIGHT)
1310 if (txt->cursor.pos < txt->cursor.par->Last()
1311 && txt->cursor.par->GetChar(txt->cursor.pos)
1312 == LyXParagraph::META_INSET
1313 && txt->cursor.par->GetInset(txt->cursor.pos)
1314 && txt->cursor.par->GetInset(txt->cursor.pos)->Editable() == 2) {
1315 Inset * tmpinset = txt->cursor.par->GetInset(txt->cursor.pos);
1316 setMessage(tmpinset->EditMessage());
1317 tmpinset->Edit(tmpinset->Width(txt->GetFont(txt->cursor.par,
1318 txt->cursor.pos)), 0);
1321 if (direction == LYX_DIR_RIGHT_TO_LEFT)
1324 owner->view()->text->FinishUndo();
1325 moveCursorUpdate(false);
1326 owner->getMiniBuffer()->Set(CurrentState());
1331 if(!owner->view()->text->mark_set) owner->view()->beforeChange();
1332 owner->view()->update(-3);
1333 owner->view()->text->CursorUp();
1334 owner->view()->text->FinishUndo();
1335 moveCursorUpdate(false);
1336 owner->getMiniBuffer()->Set(CurrentState());
1340 if(!owner->view()->text->mark_set)
1341 owner->view()->beforeChange();
1342 owner->view()->update(-3);
1343 owner->view()->text->CursorDown();
1344 owner->view()->text->FinishUndo();
1345 moveCursorUpdate(false);
1346 owner->getMiniBuffer()->Set(CurrentState());
1349 case LFUN_UP_PARAGRAPH:
1350 if(!owner->view()->text->mark_set)
1351 owner->view()->beforeChange();
1352 owner->view()->update(-3);
1353 owner->view()->text->CursorUpParagraph();
1354 owner->view()->text->FinishUndo();
1355 moveCursorUpdate(false);
1356 owner->getMiniBuffer()->Set(CurrentState());
1359 case LFUN_DOWN_PARAGRAPH:
1360 if(!owner->view()->text->mark_set)
1361 owner->view()->beforeChange();
1362 owner->view()->update(-3);
1363 owner->view()->text->CursorDownParagraph();
1364 owner->view()->text->FinishUndo();
1365 moveCursorUpdate(false);
1366 owner->getMiniBuffer()->Set(CurrentState());
1370 if(!owner->view()->text->mark_set)
1371 owner->view()->beforeChange();
1372 owner->view()->update(-3);
1373 owner->view()->cursorPrevious();
1374 owner->view()->text->FinishUndo();
1375 moveCursorUpdate(false);
1376 owner->getMiniBuffer()->Set(CurrentState());
1380 if(!owner->view()->text->mark_set)
1381 owner->view()->beforeChange();
1382 owner->view()->update(-3);
1383 owner->view()->cursorNext();
1384 owner->view()->text->FinishUndo();
1385 moveCursorUpdate(false);
1386 owner->getMiniBuffer()->Set(CurrentState());
1390 if(!owner->view()->text->mark_set)
1391 owner->view()->beforeChange();
1392 owner->view()->update(-2);
1393 owner->view()->text->CursorHome();
1394 owner->view()->text->FinishUndo();
1395 moveCursorUpdate(false);
1396 owner->getMiniBuffer()->Set(CurrentState());
1400 if(!owner->view()->text->mark_set)
1401 owner->view()->beforeChange();
1402 owner->view()->update(-2);
1403 owner->view()->text->CursorEnd();
1404 owner->view()->text->FinishUndo();
1405 moveCursorUpdate(false);
1406 owner->getMiniBuffer()->Set(CurrentState());
1410 if(!owner->view()->text->mark_set)
1411 owner->view()->beforeChange();
1412 owner->view()->update(-2);
1413 owner->view()->text->CursorTab();
1414 owner->view()->text->FinishUndo();
1415 moveCursorUpdate(false);
1416 owner->getMiniBuffer()->Set(CurrentState());
1419 case LFUN_WORDRIGHT:
1420 if(!owner->view()->text->mark_set)
1421 owner->view()->beforeChange();
1422 owner->view()->update(-2);
1423 if (owner->view()->text->cursor.par->getParDirection()
1424 == LYX_DIR_LEFT_TO_RIGHT)
1425 owner->view()->text->CursorRightOneWord();
1427 owner->view()->text->CursorLeftOneWord();
1428 owner->view()->text->FinishUndo();
1429 moveCursorUpdate(false);
1430 owner->getMiniBuffer()->Set(CurrentState());
1434 if(!owner->view()->text->mark_set)
1435 owner->view()->beforeChange();
1436 owner->view()->update(-2);
1437 if (owner->view()->text->cursor.par->getParDirection()
1438 == LYX_DIR_LEFT_TO_RIGHT)
1439 owner->view()->text->CursorLeftOneWord();
1441 owner->view()->text->CursorRightOneWord();
1442 owner->view()->text->FinishUndo();
1443 moveCursorUpdate(false);
1444 owner->getMiniBuffer()->Set(CurrentState());
1447 case LFUN_BEGINNINGBUF:
1448 if(!owner->view()->text->mark_set)
1449 owner->view()->beforeChange();
1450 owner->view()->update(-2);
1451 owner->view()->text->CursorTop();
1452 owner->view()->text->FinishUndo();
1453 moveCursorUpdate(false);
1454 owner->getMiniBuffer()->Set(CurrentState());
1458 if(!owner->view()->text->mark_set)
1459 owner->view()->beforeChange();
1460 owner->view()->update(-2);
1461 owner->view()->text->CursorBottom();
1462 owner->view()->text->FinishUndo();
1463 moveCursorUpdate(false);
1464 owner->getMiniBuffer()->Set(CurrentState());
1468 /* cursor selection ---------------------------- */
1470 owner->view()->update(-2);
1471 if (owner->view()->text->cursor.par->getParDirection()
1472 == LYX_DIR_LEFT_TO_RIGHT)
1473 owner->view()->text->CursorRight();
1475 owner->view()->text->CursorLeft();
1476 owner->view()->text->FinishUndo();
1477 moveCursorUpdate(true);
1478 owner->getMiniBuffer()->Set(CurrentState());
1482 owner->view()->update(-2);
1483 if (owner->view()->text->cursor.par->getParDirection()
1484 == LYX_DIR_LEFT_TO_RIGHT)
1485 owner->view()->text->CursorLeft();
1487 owner->view()->text->CursorRight();
1488 owner->view()->text->FinishUndo();
1489 moveCursorUpdate(true);
1490 owner->getMiniBuffer()->Set(CurrentState());
1494 owner->view()->update(-2);
1495 owner->view()->text->CursorUp();
1496 owner->view()->text->FinishUndo();
1497 moveCursorUpdate(true);
1498 owner->getMiniBuffer()->Set(CurrentState());
1502 owner->view()->update(-2);
1503 owner->view()->text->CursorDown();
1504 owner->view()->text->FinishUndo();
1505 moveCursorUpdate(true);
1506 owner->getMiniBuffer()->Set(CurrentState());
1509 case LFUN_UP_PARAGRAPHSEL:
1510 owner->view()->update(-2);
1511 owner->view()->text->CursorUpParagraph();
1512 owner->view()->text->FinishUndo();
1513 moveCursorUpdate(true);
1514 owner->getMiniBuffer()->Set(CurrentState());
1517 case LFUN_DOWN_PARAGRAPHSEL:
1518 owner->view()->update(-2);
1519 owner->view()->text->CursorDownParagraph();
1520 owner->view()->text->FinishUndo();
1521 moveCursorUpdate(true);
1522 owner->getMiniBuffer()->Set(CurrentState());
1526 owner->view()->update(-2);
1527 owner->view()->cursorPrevious();
1528 owner->view()->text->FinishUndo();
1529 moveCursorUpdate(true);
1530 owner->getMiniBuffer()->Set(CurrentState());
1534 owner->view()->update(-2);
1535 owner->view()->cursorNext();
1536 owner->view()->text->FinishUndo();
1537 moveCursorUpdate(true);
1538 owner->getMiniBuffer()->Set(CurrentState());
1542 owner->view()->update(-2);
1543 owner->view()->text->CursorHome();
1544 owner->view()->text->FinishUndo();
1545 moveCursorUpdate(true);
1546 owner->getMiniBuffer()->Set(CurrentState());
1550 owner->view()->update(-2);
1551 owner->view()->text->CursorEnd();
1552 owner->view()->text->FinishUndo();
1553 moveCursorUpdate(true);
1554 owner->getMiniBuffer()->Set(CurrentState());
1557 case LFUN_WORDRIGHTSEL:
1558 owner->view()->update(-2);
1559 if (owner->view()->text->cursor.par->getParDirection()
1560 == LYX_DIR_LEFT_TO_RIGHT)
1561 owner->view()->text->CursorRightOneWord();
1563 owner->view()->text->CursorLeftOneWord();
1564 owner->view()->text->FinishUndo();
1565 moveCursorUpdate(true);
1566 owner->getMiniBuffer()->Set(CurrentState());
1569 case LFUN_WORDLEFTSEL:
1570 owner->view()->update(-2);
1571 if (owner->view()->text->cursor.par->getParDirection()
1572 == LYX_DIR_LEFT_TO_RIGHT)
1573 owner->view()->text->CursorLeftOneWord();
1575 owner->view()->text->CursorRightOneWord();
1576 owner->view()->text->FinishUndo();
1577 moveCursorUpdate(true);
1578 owner->getMiniBuffer()->Set(CurrentState());
1581 case LFUN_BEGINNINGBUFSEL:
1582 owner->view()->update(-2);
1583 owner->view()->text->CursorTop();
1584 owner->view()->text->FinishUndo();
1585 moveCursorUpdate(true);
1586 owner->getMiniBuffer()->Set(CurrentState());
1589 case LFUN_ENDBUFSEL:
1590 owner->view()->update(-2);
1591 owner->view()->text->CursorBottom();
1592 owner->view()->text->FinishUndo();
1593 moveCursorUpdate(true);
1594 owner->getMiniBuffer()->Set(CurrentState());
1597 // --- text changing commands ------------------------
1598 case LFUN_BREAKLINE:
1599 owner->view()->beforeChange();
1600 owner->view()->text->InsertChar(LyXParagraph::META_NEWLINE);
1601 owner->view()->smallUpdate(1);
1602 SetUpdateTimer(0.01);
1603 moveCursorUpdate(false);
1606 case LFUN_PROTECTEDSPACE:
1607 owner->view()->beforeChange();
1608 owner->view()->text->
1609 InsertChar(LyXParagraph::META_PROTECTED_SEPARATOR);
1610 owner->view()->smallUpdate(1);
1612 moveCursorUpdate(false);
1616 if(owner->view()->text->mark_set) {
1617 owner->view()->beforeChange();
1618 owner->view()->update(0);
1619 setMessage(N_("Mark removed"));
1621 owner->view()->beforeChange();
1622 owner->view()->text->mark_set = 1;
1623 owner->view()->update(0);
1624 setMessage(N_("Mark set"));
1626 owner->view()->text->sel_cursor =
1627 owner->view()->text->cursor;
1632 if (!owner->view()->text->selection) {
1633 owner->view()->text->Delete();
1634 owner->view()->text->sel_cursor =
1635 owner->view()->text->cursor;
1636 owner->view()->smallUpdate(1);
1637 // It is possible to make it a lot faster still
1638 // just comment out the lone below...
1639 owner->view()->getScreen()->ShowCursor();
1641 owner->view()->cut();
1644 moveCursorUpdate(false);
1645 owner->getMiniBuffer()->Set(CurrentState());
1646 owner->view()->SetState();
1649 case LFUN_DELETE_SKIP:
1651 // Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
1653 LyXCursor cursor = owner->view()->text->cursor;
1656 if (!owner->view()->text->selection) {
1657 if (cursor.pos == cursor.par->Last()) {
1658 owner->view()->text->CursorRight();
1659 cursor = owner->view()->text->cursor;
1661 && !(cursor.par->added_space_top
1662 == VSpace (VSpace::NONE))) {
1663 owner->view()->text->SetParagraph
1664 (cursor.par->line_top,
1665 cursor.par->line_bottom,
1666 cursor.par->pagebreak_top,
1667 cursor.par->pagebreak_bottom,
1668 VSpace(VSpace::NONE),
1669 cursor.par->added_space_bottom,
1671 cursor.par->labelwidthstring, 0);
1672 owner->view()->text->CursorLeft();
1673 owner->view()->update (1);
1675 owner->view()->text->CursorLeft();
1676 owner->view()->text->Delete();
1677 owner->view()->text->sel_cursor =
1678 owner->view()->text->cursor;
1679 owner->view()->smallUpdate(1);
1682 owner->view()->text->Delete();
1683 owner->view()->text->sel_cursor =
1684 owner->view()->text->cursor;
1685 owner->view()->smallUpdate(1);
1688 owner->view()->cut();
1694 /* -------> Delete word forward. */
1695 case LFUN_DELETE_WORD_FORWARD:
1696 owner->view()->update(-2);
1698 owner->view()->text->DeleteWordForward();
1699 owner->view()->update( 1 );
1701 moveCursorUpdate(false);
1702 owner->getMiniBuffer()->Set(CurrentState());
1705 /* -------> Delete word backward. */
1706 case LFUN_DELETE_WORD_BACKWARD:
1707 owner->view()->update(-2);
1709 owner->view()->text->DeleteWordBackward();
1710 owner->view()->update( 1 );
1712 moveCursorUpdate(false);
1713 owner->getMiniBuffer()->Set(CurrentState());
1716 /* -------> Kill to end of line. */
1717 case LFUN_DELETE_LINE_FORWARD:
1719 owner->view()->update(-2);
1720 owner->view()->text->DeleteLineForward();
1721 owner->view()->update( 1 );
1723 moveCursorUpdate(false);
1726 /* -------> Set mark off. */
1728 owner->view()->beforeChange();
1729 owner->view()->update(0);
1730 owner->view()->text->sel_cursor =
1731 owner->view()->text->cursor;
1732 setMessage(N_("Mark off"));
1735 /* -------> Set mark on. */
1737 owner->view()->beforeChange();
1738 owner->view()->text->mark_set = 1;
1739 owner->view()->update( 0 );
1740 owner->view()->text->sel_cursor =
1741 owner->view()->text->cursor;
1742 setMessage(N_("Mark on"));
1745 case LFUN_BACKSPACE:
1748 if (!owner->view()->text->selection) {
1749 if (owner->getIntl()->getTrans()->backspace()) {
1750 owner->view()->text->Backspace();
1751 owner->view()->text->sel_cursor =
1752 owner->view()->text->cursor;
1753 owner->view()->smallUpdate(1);
1754 // It is possible to make it a lot faster still
1755 // just comment out the lone below...
1756 owner->view()->getScreen()->ShowCursor();
1759 owner->view()->cut();
1762 owner->getMiniBuffer()->Set(CurrentState());
1763 owner->view()->SetState();
1767 case LFUN_BACKSPACE_SKIP:
1769 // Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
1771 LyXCursor cursor = owner->view()->text->cursor;
1774 if (!owner->view()->text->selection) {
1776 && !(cursor.par->added_space_top
1777 == VSpace (VSpace::NONE))) {
1778 owner->view()->text->SetParagraph
1779 (cursor.par->line_top,
1780 cursor.par->line_bottom,
1781 cursor.par->pagebreak_top,
1782 cursor.par->pagebreak_bottom,
1783 VSpace(VSpace::NONE), cursor.par->added_space_bottom,
1785 cursor.par->labelwidthstring, 0);
1786 owner->view()->update (1);
1788 owner->view()->text->Backspace();
1789 owner->view()->text->sel_cursor
1791 owner->view()->smallUpdate (1);
1794 owner->view()->cut();
1799 case LFUN_BREAKPARAGRAPH:
1801 owner->view()->beforeChange();
1802 owner->view()->text->BreakParagraph(0);
1803 owner->view()->smallUpdate(1);
1804 SetUpdateTimer(0.01);
1805 owner->view()->text->sel_cursor =
1806 owner->view()->text->cursor;
1807 owner->view()->SetState();
1808 owner->getMiniBuffer()->Set(CurrentState());
1812 case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
1814 owner->view()->beforeChange();
1815 owner->view()->text->BreakParagraph(1);
1816 owner->view()->smallUpdate(1);
1817 SetUpdateTimer(0.01);
1818 owner->view()->text->sel_cursor =
1819 owner->view()->text->cursor;
1820 owner->view()->SetState();
1821 owner->getMiniBuffer()->Set(CurrentState());
1825 case LFUN_BREAKPARAGRAPH_SKIP:
1827 // When at the beginning of a paragraph, remove
1828 // indentation and add a "defskip" at the top.
1829 // Otherwise, do the same as LFUN_BREAKPARAGRAPH.
1831 LyXCursor cursor = owner->view()->text->cursor;
1833 owner->view()->beforeChange();
1834 if (cursor.pos == 0) {
1835 if (cursor.par->added_space_top == VSpace(VSpace::NONE)) {
1836 owner->view()->text->SetParagraph
1837 (cursor.par->line_top,
1838 cursor.par->line_bottom,
1839 cursor.par->pagebreak_top,
1840 cursor.par->pagebreak_bottom,
1841 VSpace(VSpace::DEFSKIP), cursor.par->added_space_bottom,
1843 cursor.par->labelwidthstring, 1);
1844 owner->view()->update(1);
1848 owner->view()->text->BreakParagraph(0);
1849 owner->view()->smallUpdate(1);
1851 SetUpdateTimer(0.01);
1852 owner->view()->text->sel_cursor = cursor;
1853 owner->view()->SetState();
1854 owner->getMiniBuffer()->Set(CurrentState());
1859 owner->view()->beforeChange();
1860 owner->view()->text->InsertChar('\"'); // This " matches the single quote in the code
1861 owner->view()->smallUpdate(1);
1863 moveCursorUpdate(false);
1869 InsetCommand * new_inset;
1870 if (action == LFUN_HTMLURL)
1871 new_inset = new InsetUrl("htmlurl", "", "");
1873 new_inset = new InsetUrl("url", "", "");
1874 owner->view()->insertInset(new_inset);
1875 new_inset->Edit(0, 0);
1879 // --- lyxserver commands ----------------------------
1881 case LFUN_CHARATCURSOR:
1883 LyXParagraph::size_type pos =
1884 owner->view()->text->cursor.pos;
1885 if(pos < owner->view()->text->cursor.par->size())
1886 dispatch_buffer = owner->view()->text->
1887 cursor.par->text[pos];
1889 dispatch_buffer = "EOF";
1895 tostr(owner->view()->text->cursor.x) + ' '
1896 + tostr(owner->view()->text->cursor.y);
1903 sscanf(argument.c_str(), " %d %ld", &x, &y);
1904 owner->view()->text->SetCursorFromCoordinates(x, y);
1908 case LFUN_GETLAYOUT:
1910 tostr(owner->view()->text->cursor.par->layout);
1915 LyXFont * font = &(owner->view()->text->current_font);
1916 if(font->shape() == LyXFont::ITALIC_SHAPE)
1917 dispatch_buffer = 'E';
1918 else if(font->shape() == LyXFont::SMALLCAPS_SHAPE)
1919 dispatch_buffer = 'N';
1921 dispatch_buffer = '0';
1928 LyXFont * font = &(owner->view()->text->current_font);
1929 if(font->latex() == LyXFont::ON)
1930 dispatch_buffer = 'L';
1932 dispatch_buffer = '0';
1937 setMessage(owner->buffer()->fileName());
1938 lyxerr.debug() << "FNAME["
1939 << owner->buffer()->fileName()
1947 dispatch_buffer = buf;
1948 lyxserver->notifyClient(dispatch_buffer);
1952 case LFUN_GOTOFILEROW:
1954 char file_name[100];
1956 sscanf(argument.c_str(), " %s %d", file_name, &row);
1958 // Must replace extension of the file to be .lyx and get full path
1959 string s = ChangeExtension(string(file_name), ".lyx", false);
1961 // Either change buffer or load the file
1962 if (bufferlist.exists(s))
1963 owner->view()->buffer(bufferlist.getBuffer(s));
1965 owner->view()->buffer(bufferlist.loadLyXFile(s));
1968 owner->view()->setCursorFromRow(row);
1971 owner->view()->beforeChange();
1972 if (owner->view()->text->cursor.y >
1973 owner->view()->getWorkArea()->h / 2) {
1974 owner->view()->getScreen()->
1975 Draw(owner->view()->text->cursor.y -
1976 owner->view()->getWorkArea()->h/2);
1978 owner->view()->getScreen()->
1981 owner->view()->update(0);
1982 owner->view()->redraw();
1989 int qa = lyxaction.LookupFunc(argument.c_str());
1990 setMessage(lyxaction.helpText(static_cast<kb_action>(qa)));
1994 // --- accented characters ---------------------------
1997 case LFUN_CIRCUMFLEX:
2007 case LFUN_SPECIAL_CARON:
2010 case LFUN_HUNG_UMLAUT:
2016 if (keyseq.length == -1 && keyseq.getiso() != 0)
2017 c = keyseq.getiso();
2021 owner->getIntl()->getTrans()->
2022 deadkey(c, get_accent(action).accent,
2023 owner->view()->text);
2025 // Need to reset, in case the minibuffer calls these
2030 // copied verbatim from do_accent_char
2031 owner->view()->smallUpdate(1);
2033 owner->view()->text->sel_cursor =
2034 owner->view()->text->cursor;
2038 // --- toolbar ----------------------------------
2039 case LFUN_PUSH_TOOLBAR:
2041 int nth = strToInt(argument);
2042 if (lyxerr.debugging(Debug::TOOLBAR)) {
2043 lyxerr << "LFUN_PUSH_TOOLBAR: argument = `"
2044 << argument << "'\n"
2045 << "LFUN_PUSH_TOOLBAR: nth = `"
2046 << nth << "'" << endl;
2051 setErrorMessage(N_("Push-toolbar needs argument > 0"));
2053 owner->getToolbar()->push(nth);
2058 case LFUN_ADD_TO_TOOLBAR:
2060 if (lyxerr.debugging(Debug::TOOLBAR)) {
2061 lyxerr << "LFUN_ADD_TO_TOOLBAR:"
2062 "argument = `" << argument << '\'' << endl;
2064 string tmp(argument);
2065 //lyxerr <<string("Argument: ") + argument);
2066 //lyxerr <<string("Tmp : ") + tmp);
2069 setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
2071 owner->getToolbar()->add(argument, false);
2072 owner->getToolbar()->set();
2077 // --- insert characters ----------------------------------------
2079 // --- Mathed stuff. If we are here, there is no locked inset yet.
2084 if (!greek_kb_flag) {
2086 setMessage(N_("Math greek mode on"));
2093 case LFUN_GREEK_TOGGLE:
2095 greek_kb_flag = greek_kb_flag ? 0 : 2;
2096 if (greek_kb_flag) {
2097 setMessage(N_("Math greek keyboard on"));
2099 setMessage(N_("Math greek keyboard off"));
2104 case LFUN_MATH_DELIM:
2105 case LFUN_INSERT_MATRIX:
2107 if (owner->view()->available()) {
2109 open_new_inset(new InsetFormula(false));
2111 the_locking_inset->LocalDispatch(action, argument.c_str());
2116 case LFUN_INSERT_MATH:
2118 math_insert_symbol(argument.c_str());
2122 case LFUN_MATH_DISPLAY:
2124 if (owner->view()->available())
2125 owner->view()->open_new_inset(new InsetFormula(true));
2129 case LFUN_MATH_MACRO:
2131 if (owner->view()->available()) {
2134 setErrorMessage(N_("Missing argument"));
2136 string s1 = token(s, ' ', 1);
2137 int na = s1.empty() ? 0: atoi(s1.c_str());
2139 open_new_inset(new InsetFormulaMacro(token(s, ' ', 0), na));
2145 case LFUN_MATH_MODE: // Open or create a math inset
2148 if (owner->view()->available())
2149 owner->view()->open_new_inset(new InsetFormula);
2150 setMessage(N_("Math editor mode"));
2154 case LFUN_MATH_NUMBER:
2155 case LFUN_MATH_LIMITS:
2157 setErrorMessage(N_("This is only allowed in math mode!"));
2161 case LFUN_INSERT_CITATION:
2163 InsetCitation * new_inset = new InsetCitation();
2165 // The note, if any, must be after the key, delimited
2166 // by a | so both key and remark can have spaces.
2167 if (!argument.empty()) {
2168 string lsarg(argument);
2169 if (contains(lsarg, "|")) {
2170 new_inset->setContents(token(lsarg, '|', 0));
2171 new_inset->setOptions(token(lsarg, '|', 1));
2173 new_inset->setContents(lsarg);
2174 owner->view()->insertInset(new_inset);
2176 owner->view()->insertInset(new_inset);
2177 new_inset->Edit(0, 0);
2182 case LFUN_INSERT_BIBTEX:
2184 // ale970405+lasgoutt970425
2185 // The argument can be up to two tokens separated
2186 // by a space. The first one is the bibstyle.
2187 string lsarg(argument);
2188 string bibstyle = token(lsarg, ' ', 1);
2189 if (bibstyle.empty())
2191 InsetBibtex * new_inset
2192 = new InsetBibtex(token(lsarg, ' ', 0),
2196 owner->view()->insertInset(new_inset);
2197 if (lsarg.empty()) {
2198 new_inset->Edit(0, 0);
2203 // BibTeX data bases
2204 case LFUN_BIBDB_ADD:
2206 InsetBibtex * inset =
2207 static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
2209 inset->addDatabase(argument);
2214 case LFUN_BIBDB_DEL:
2216 InsetBibtex * inset =
2217 static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
2219 inset->delDatabase(argument);
2224 case LFUN_BIBTEX_STYLE:
2226 InsetBibtex * inset =
2227 static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
2229 inset->setOptions(argument);
2234 case LFUN_INDEX_INSERT:
2235 case LFUN_INDEX_INSERT_LAST:
2237 // Can't do that at the beginning of a paragraph.
2238 if (owner->view()->text->cursor.pos - 1 < 0)
2241 InsetIndex * new_inset = new InsetIndex();
2242 if (!argument.empty()) {
2243 string lsarg(argument);
2244 new_inset->setContents(lsarg);
2245 owner->view()->insertInset(new_inset);
2248 //get the current word for an argument
2249 LyXParagraph::size_type lastpos =
2250 owner->view()->text->cursor.pos - 1;
2251 // Get the current word. note that this must be done
2252 // before inserting the inset, or the inset will
2254 string curstring(owner->view()
2255 ->text->cursor.par->GetWord(lastpos));
2257 //make the new inset and write the current word into it
2258 InsetIndex * new_inset = new InsetIndex();
2260 new_inset->setContents(curstring);
2262 //don't edit it if the call was to INSERT_LAST
2263 if(action != LFUN_INDEX_INSERT_LAST) {
2264 new_inset->Edit(0, 0);
2266 //it looks blank on the screen unless
2267 //we do something. put it here.
2269 // move the cursor to the returned value of lastpos
2270 // but only for the auto-insert
2271 owner->view()->text->cursor.pos = lastpos;
2274 //put the new inset into the buffer.
2275 // there should be some way of knowing the user
2276 //cancelled & avoiding this, but i don't know how
2277 owner->view()->insertInset(new_inset);
2282 case LFUN_INDEX_PRINT:
2284 Inset * new_inset = new InsetPrintIndex(owner->buffer());
2285 owner->view()->insertInset(new_inset, "Standard", true);
2289 case LFUN_PARENTINSERT:
2291 lyxerr << "arg " << argument << endl;
2292 Inset * new_inset = new InsetParent(argument, owner->buffer());
2293 owner->view()->insertInset(new_inset, "Standard", true);
2297 case LFUN_CHILDINSERT:
2299 Inset * new_inset = new InsetInclude(argument,
2301 owner->view()->insertInset(new_inset, "Standard", true);
2302 new_inset->Edit(0, 0);
2306 case LFUN_CHILDOPEN:
2309 MakeAbsPath(argument,
2310 OnlyPath(owner->buffer()->fileName()));
2311 setMessage(N_("Opening child document ") +
2312 MakeDisplayPath(filename) + "...");
2313 owner->view()->savePosition();
2314 if (bufferlist.exists(filename))
2315 owner->view()->buffer(bufferlist.getBuffer(filename));
2317 owner->view()->buffer(bufferlist.loadLyXFile(filename));
2321 case LFUN_INSERT_NOTE:
2322 owner->view()->insertNote();
2325 case LFUN_INSERTFOOTNOTE:
2327 LyXParagraph::footnote_kind kind;
2328 if (argument == "footnote")
2329 { kind = LyXParagraph::FOOTNOTE; }
2330 else if (argument == "margin")
2331 { kind = LyXParagraph::MARGIN; }
2332 else if (argument == "figure")
2333 { kind = LyXParagraph::FIG; }
2334 else if (argument == "table")
2335 { kind = LyXParagraph::TAB; }
2336 else if (argument == "wide-fig")
2337 { kind = LyXParagraph::WIDE_FIG; }
2338 else if (argument == "wide-tab")
2339 { kind = LyXParagraph::WIDE_TAB; }
2340 else if (argument == "algorithm")
2341 { kind = LyXParagraph::ALGORITHM; }
2343 setErrorMessage(N_("Unknown kind of footnote"));
2346 owner->view()->text->InsertFootnoteEnvironment(kind);
2347 owner->view()->update(1);
2348 owner->view()->SetState();
2352 case LFUN_BUFFERBULLETSSELECT:
2356 case LFUN_TOGGLECURSORFOLLOW:
2357 cursor_follows_scrollbar = !cursor_follows_scrollbar;
2360 case LFUN_KMAP_OFF: // keymap off
2361 owner->getIntl()->KeyMapOn(false);
2364 case LFUN_KMAP_PRIM: // primary keymap
2365 owner->getIntl()->KeyMapPrim();
2368 case LFUN_KMAP_SEC: // secondary keymap
2369 owner->getIntl()->KeyMapSec();
2372 case LFUN_KMAP_TOGGLE: // toggle keymap
2373 owner->getIntl()->ToggleKeyMap();
2376 case LFUN_SELFINSERT:
2378 for (string::size_type i = 0; i < argument.length(); ++i) {
2379 owner->view()->text->InsertChar(argument[i]);
2380 // This needs to be in the loop, or else we
2381 // won't break lines correctly. (Asger)
2382 owner->view()->smallUpdate(1);
2385 owner->view()->text->sel_cursor =
2386 owner->view()->text->cursor;
2387 moveCursorUpdate(false);
2393 // argument contains ';'-terminated commands
2394 while (argument.find(';') != string::npos) {
2396 argument = split(argument, first, ';');
2402 case LFUN_DATE_INSERT: // jdblair: date-insert cmd
2410 now_time_t = time(NULL);
2411 now_tm = localtime(&now_time_t);
2412 (void)setlocale(LC_TIME, "");
2413 if (!argument.empty())
2415 else if (arg.empty())
2416 arg = lyxrc->date_insert_format;
2417 datetmp_len = (int) strftime(datetmp, 32, arg.c_str(), now_tm);
2418 for (int i = 0; i < datetmp_len; i++) {
2419 owner->view()->text->InsertChar(datetmp[i]);
2420 owner->view()->smallUpdate(1);
2423 owner->view()->text->sel_cursor = owner->view()->text->cursor;
2424 moveCursorUpdate(false);
2428 case LFUN_SAVEPREFERENCES:
2430 Path p(user_lyxdir);
2431 lyxrc->write("preferences");
2435 case LFUN_UNKNOWN_ACTION:
2437 if(!owner->buffer()) {
2439 setErrorMessage(N_("No document open"));
2443 if (owner->buffer()->isReadonly()) {
2445 setErrorMessage(N_("Document is read only"));
2449 if (!argument.empty()) {
2451 /* Automatically delete the currently selected
2452 * text and replace it with what is being
2453 * typed in now. Depends on lyxrc settings
2454 * "auto_region_delete", which defaults to
2457 if ( lyxrc->auto_region_delete ) {
2458 if (owner->view()->text->selection){
2459 owner->view()->text->CutSelection(false);
2460 owner->view()->update(-1);
2464 owner->view()->beforeChange();
2465 for (string::size_type i = 0;
2466 i < argument.length(); ++i) {
2467 if (greek_kb_flag) {
2468 if (!math_insert_greek(argument[i]))
2469 owner->getIntl()->getTrans()->TranslateAndInsert(argument[i], owner->view()->text);
2471 owner->getIntl()->getTrans()->TranslateAndInsert(argument[i], owner->view()->text);
2474 owner->view()->smallUpdate(1);
2477 owner->view()->text->sel_cursor =
2478 owner->view()->text->cursor;
2479 moveCursorUpdate(false);
2482 // why is an "Unknown action" with empty
2483 // argument even dispatched in the first
2484 // place? I`ll probably change that. (Lgb)
2486 setErrorMessage(N_("Unknown action"));
2490 lyxerr << "A truly unknown func!" << endl;
2496 string res = getMessage();
2499 if (!commandshortcut.empty()) {
2500 string newbuf = owner->getMiniBuffer()->GetText();
2501 if (newbuf != commandshortcut) {
2502 owner->getMiniBuffer()->Set(newbuf
2508 owner->getMiniBuffer()->Set(string(_(res.c_str()))
2509 + " " + commandshortcut);
2516 void LyXFunc::setupLocalKeymap()
2518 keyseq.stdmap = keyseq.curmap = toplevel_keymap;
2519 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap;
2523 void LyXFunc::MenuNew(bool fromTemplate)
2525 string fname, initpath = lyxrc->document_path;
2528 if (owner->view()->available()) {
2529 string trypath = owner->buffer()->filepath;
2530 // If directory is writeable, use this as default.
2531 if (IsDirWriteable(trypath) == 1)
2536 fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
2537 fileDlg.SetButton(1, _("Templates"), lyxrc->template_path);
2538 fname = fileDlg.Select(_("Enter Filename for new document"),
2539 initpath, "*.lyx", _("newfile"));
2542 if (fname.empty()) {
2543 owner->getMiniBuffer()->Set(_("Canceled."));
2544 lyxerr.debug() << "New Document Cancelled." << endl;
2548 // get absolute path of file and make sure the filename ends
2550 string s = MakeAbsPath(fname);
2551 if (!IsLyXFilename(s))
2554 // Check if the document already is open
2555 if (bufferlist.exists(s)){
2556 switch(AskConfirmation(_("Document is already open:"),
2557 MakeDisplayPath(s, 50),
2558 _("Do you want to close that document now?\n"
2559 "('No' will just switch to the open version)")))
2561 case 1: // Yes: close the document
2562 if (!bufferlist.close(bufferlist.getBuffer(s)))
2563 // If close is canceled, we cancel here too.
2566 case 2: // No: switch to the open document
2567 owner->view()->buffer(bufferlist.getBuffer(s));
2569 case 3: // Cancel: Do nothing
2570 owner->getMiniBuffer()->Set(_("Canceled."));
2575 // Check whether the file already exists
2576 if (IsLyXFilename(s)) {
2578 if (fi.readable() &&
2579 AskQuestion(_("File already exists:"),
2580 MakeDisplayPath(s, 50),
2581 _("Do you want to open the document?"))) {
2583 owner->getMiniBuffer()->Set(_("Opening document"),
2584 MakeDisplayPath(s), "...");
2586 owner->view()->buffer(
2587 bufferlist.loadLyXFile(s));
2588 owner->getMiniBuffer()->Set(_("Document"),
2595 // The template stuff
2599 fname = fileDlg.Select(_("Choose template"),
2600 lyxrc->template_path,
2606 // find a free buffer
2607 lyxerr.debug() << "Find a free buffer." << endl;
2608 owner->view()->buffer(bufferlist.newFile(s, templname));
2612 void LyXFunc::MenuOpen()
2614 string initpath = lyxrc->document_path;
2617 if (owner->view()->available()) {
2618 string trypath = owner->buffer()->filepath;
2619 // If directory is writeable, use this as default.
2620 if (IsDirWriteable(trypath) == 1)
2626 fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
2627 fileDlg.SetButton(1, _("Examples"),
2628 AddPath(system_lyxdir, "examples"));
2629 string filename = fileDlg.Select(_("Select Document to Open"),
2633 // check selected filename
2634 if (filename.empty()) {
2635 owner->getMiniBuffer()->Set(_("Canceled."));
2639 // get absolute path of file and make sure the filename ends
2641 filename = MakeAbsPath(filename);
2642 if (!IsLyXFilename(filename))
2646 owner->getMiniBuffer()->Set(_("Opening document"),
2647 MakeDisplayPath(filename), "...");
2648 Buffer * openbuf = bufferlist.loadLyXFile(filename);
2650 owner->view()->buffer(openbuf);
2651 owner->getMiniBuffer()->Set(_("Document"),
2652 MakeDisplayPath(filename),
2655 owner->getMiniBuffer()->Set(_("Could not open document"),
2656 MakeDisplayPath(filename));
2661 void LyXFunc::doImportASCII(bool linorpar)
2663 string initpath = lyxrc->document_path;
2666 if (owner->view()->available()) {
2667 string trypath = owner->buffer()->filepath;
2668 // If directory is writeable, use this as default.
2669 if (IsDirWriteable(trypath) == 1)
2675 fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
2676 fileDlg.SetButton(1, _("Examples"),
2677 AddPath(system_lyxdir, "examples"));
2678 string filename = fileDlg.Select(_("Select ASCII file to Import"),
2682 // check selected filename
2683 if (filename.empty()) {
2684 owner->getMiniBuffer()->Set(_("Canceled."));
2688 // get absolute path of file
2689 filename = MakeAbsPath(filename);
2691 string s = ChangeExtension(filename, ".lyx", false);
2693 // Check if the document already is open
2694 if (bufferlist.exists(s)) {
2695 switch(AskConfirmation(_("Document is already open:"),
2696 MakeDisplayPath(s, 50),
2697 _("Do you want to close that document now?\n"
2698 "('No' will just switch to the open version)")))
2700 case 1: // Yes: close the document
2701 if (!bufferlist.close(bufferlist.getBuffer(s)))
2702 // If close is canceled, we cancel here too.
2705 case 2: // No: switch to the open document
2706 owner->view()->buffer(bufferlist.getBuffer(s));
2708 case 3: // Cancel: Do nothing
2709 owner->getMiniBuffer()->Set(_("Canceled."));
2714 // Check if a LyX document by the same root exists in filesystem
2715 FileInfo f(s, true);
2716 if (f.exist() && !AskQuestion(_("A document by the name"),
2718 _("already exists. Overwrite?"))) {
2719 owner->getMiniBuffer()->Set(_("Canceled."));
2723 owner->view()->buffer(bufferlist.newFile(s, string()));
2724 owner->getMiniBuffer()->Set(_("Importing ASCII file"),
2725 MakeDisplayPath(filename), "...");
2726 // Insert ASCII file
2727 InsertAsciiFile(filename, linorpar);
2728 owner->getMiniBuffer()->Set(_("ASCII file "),
2729 MakeDisplayPath(filename),
2734 void LyXFunc::doImportLaTeX(bool isnoweb)
2736 string initpath = lyxrc->document_path;
2739 if (owner->view()->available()) {
2740 string trypath = owner->buffer()->filepath;
2741 // If directory is writeable, use this as default.
2742 if (IsDirWriteable(trypath) == 1)
2748 fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
2749 fileDlg.SetButton(1, _("Examples"),
2750 AddPath(system_lyxdir, "examples"));
2753 filename = fileDlg.Select(_("Select Noweb file to Import"),
2756 filename = fileDlg.Select(_("Select LaTeX file to Import"),
2762 // check selected filename
2763 if (filename.empty()) {
2764 owner->getMiniBuffer()->Set(_("Canceled."));
2768 // get absolute path of file
2769 filename = MakeAbsPath(filename);
2771 // Check if the document already is open
2772 string LyXfilename = ChangeExtension(filename, ".lyx", false);
2773 if (bufferlist.exists(LyXfilename)){
2774 switch(AskConfirmation(_("Document is already open:"),
2775 MakeDisplayPath(LyXfilename, 50),
2776 _("Do you want to close that document now?\n"
2777 "('No' will just switch to the open version)")))
2779 case 1: // Yes: close the document
2780 if (!bufferlist.close(bufferlist.getBuffer(LyXfilename)))
2781 // If close is canceled, we cancel here too.
2784 case 2: // No: switch to the open document
2785 owner->view()->buffer(
2786 bufferlist.getBuffer(LyXfilename));
2788 case 3: // Cancel: Do nothing
2789 owner->getMiniBuffer()->Set(_("Canceled."));
2794 // Check if a LyX document by the same root exists in filesystem
2795 FileInfo f(LyXfilename, true);
2796 if (f.exist() && !AskQuestion(_("A document by the name"),
2797 MakeDisplayPath(LyXfilename),
2798 _("already exists. Overwrite?"))) {
2799 owner->getMiniBuffer()->Set(_("Canceled."));
2806 owner->getMiniBuffer()->Set(_("Importing LaTeX file"),
2807 MakeDisplayPath(filename), "...");
2808 ImportLaTeX myImport(filename);
2809 openbuf = myImport.run();
2811 owner->getMiniBuffer()->Set(_("Importing Noweb file"),
2812 MakeDisplayPath(filename), "...");
2813 ImportNoweb myImport(filename);
2814 openbuf = myImport.run();
2817 owner->view()->buffer(openbuf);
2818 owner->getMiniBuffer()->Set(isnoweb ?
2819 _("Noweb file ") : _("LateX file "),
2820 MakeDisplayPath(filename),
2823 owner->getMiniBuffer()->Set(isnoweb ?
2824 _("Could not import Noweb file") :
2825 _("Could not import LaTeX file"),
2826 MakeDisplayPath(filename));
2831 void LyXFunc::MenuInsertLyXFile(string const & filen)
2833 string filename = filen;
2835 if (filename.empty()) {
2836 // Launch a file browser
2837 string initpath = lyxrc->document_path;
2840 if (owner->view()->available()) {
2841 string trypath = owner->buffer()->filepath;
2842 // If directory is writeable, use this as default.
2843 if (IsDirWriteable(trypath) == 1)
2849 fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
2850 fileDlg.SetButton(1, _("Examples"),
2851 AddPath(system_lyxdir, "examples"));
2852 filename = fileDlg.Select(_("Select Document to Insert"),
2856 // check selected filename
2857 if (filename.empty()) {
2858 owner->getMiniBuffer()->Set(_("Canceled."));
2863 // get absolute path of file and make sure the filename ends
2865 filename = MakeAbsPath(filename);
2866 if (!IsLyXFilename(filename))
2870 owner->getMiniBuffer()->Set(_("Inserting document"),
2871 MakeDisplayPath(filename), "...");
2872 bool res = owner->view()->insertLyXFile(filename);
2874 owner->getMiniBuffer()->Set(_("Document"),
2875 MakeDisplayPath(filename),
2878 owner->getMiniBuffer()->Set(_("Could not insert document"),
2879 MakeDisplayPath(filename));
2884 void LyXFunc::reloadBuffer()
2886 string fn = owner->buffer()->fileName();
2887 if (bufferlist.close(owner->buffer()))
2888 owner->view()->buffer(bufferlist.loadLyXFile(fn));
2892 void LyXFunc::CloseBuffer()
2894 if (bufferlist.close(owner->buffer()) && !quitting) {
2895 if (bufferlist.empty()) {
2896 // need this otherwise SEGV may occur while trying to
2897 // set variables that don't exist
2898 // since there's no current buffer
2899 CloseAllBufferRelatedPopups();
2902 owner->view()->buffer(bufferlist.first());
2908 Inset * LyXFunc::getInsetByCode(Inset::Code code)
2912 LyXCursor cursor = owner->view()->text->cursor;
2913 LyXParagraph::size_type pos = cursor.pos;
2914 LyXParagraph * par = cursor.par;
2916 while (par && !found) {
2917 while ((inset = par->ReturnNextInsetPointer(pos))){
2918 if (inset->LyxCode() == code) {
2926 return found ? inset : 0;
2930 // Each "owner" should have it's own message method. lyxview and
2931 // the minibuffer would use the minibuffer, but lyxserver would
2932 // send an ERROR signal to its client. Alejandro 970603
2933 // This func is bit problematic when it comes to NLS, to make the
2934 // lyx servers client be language indepenent we must not translate
2935 // strings sent to this func.
2936 void LyXFunc::setErrorMessage(string const & m) const
2938 dispatch_buffer = m;
2943 void LyXFunc::setMessage(string const & m)
2945 dispatch_buffer = m;