1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-1999 The LyX Team.
9 * ====================================================== */
18 #pragma implementation
21 #include "lyxlookup.h"
24 #include "bufferlist.h"
25 #include "lyxserver.h"
30 #include "LyXAction.h"
32 #include "insets/insetlatex.h"
34 #include "insets/inseturl.h"
35 #include "insets/insetlatexaccent.h"
36 #include "insets/insettoc.h"
37 #include "insets/insetlof.h"
38 #include "insets/insetloa.h"
39 #include "insets/insetlot.h"
40 #include "insets/insetref.h"
41 #include "insets/insetparent.h"
42 #include "insets/insetindex.h"
43 #include "insets/insetinclude.h"
44 #include "insets/insetbib.h"
45 #include "mathed/formulamacro.h"
47 #include "spellchecker.h" // RVDK_PATCH_5
48 #include "minibuffer.h"
52 #include "lyx_gui_misc.h"
53 #include "support/filetools.h"
54 #include "support/FileInfo.h"
55 #include "support/LAssert.h"
56 #include "support/syscall.h"
57 #include "support/lstrings.h"
58 #include "support/path.h"
59 #include "lyxscreen.h"
64 #include "trans_mgr.h"
65 #include "ImportLaTeX.h"
66 #include "ImportNoweb.h"
69 extern bool cursor_follows_scrollbar;
71 extern void InsertAsciiFile(string const &, bool);
72 extern void math_insert_symbol(char const*);
73 extern Bool math_insert_greek(char const); // why "Bool"?
74 extern BufferList bufferlist;
75 extern LyXServer * lyxserver;
76 extern short greek_kb_flag;
77 extern FD_form_toc * fd_form_toc;
78 extern bool selection_possible;
80 extern kb_keymap * toplevel_keymap;
82 extern void BeforeChange();
83 extern void MenuWrite(Buffer*);
84 extern void MenuWriteAs(Buffer*);
85 extern int MenuRunLaTeX(Buffer*);
86 extern int MenuBuildProg(Buffer*);
87 extern int MenuRunChktex(Buffer*);
88 extern bool MenuRunDvips(Buffer *, bool);
89 extern void MenuPrint(Buffer*);
90 extern void MenuSendto();
91 extern void QuitLyX();
92 extern void MenuFax(Buffer *);
93 extern void MenuMakeLaTeX(Buffer *);
94 extern void MenuMakeLinuxDoc(Buffer *);
95 extern void MenuMakeDocBook(Buffer *);
96 extern void MenuMakeAscii(Buffer *);
97 extern void MenuPasteSelection(char at);
98 extern LyXAction lyxaction;
100 extern tex_accent_struct get_accent(kb_action action);
102 extern void AutoSave();
103 extern void MenuSearch();
104 extern void CopyCB();
105 extern void CopyEnvironmentCB();
106 extern void PasteEnvironmentCB();
107 extern void GotoNote();
108 extern void NoteCB();
109 extern void OpenStuff();
110 extern void HyphenationPoint();
112 extern void EndOfSentenceDot();
113 extern void MenuSeparator();
115 extern void MenuUndo();
116 extern void MenuRedo();
117 extern void SmallUpdate(signed char);
118 extern void SetUpdateTimer(float timer= 0.3);
119 extern void FreeUpdateTimer();
120 extern bool MenuPreview(Buffer*);
121 extern bool MenuPreviewPS(Buffer*);
122 extern void MenuInsertLabel(char const *);
123 extern void MenuInsertRef();
124 extern void MenuLayoutCharacter();
125 extern void MenuLayoutParagraph();
126 extern void MenuLayoutDocument();
127 extern void MenuLayoutPaper();
128 extern void MenuLayoutTable(int flag);
129 extern void MenuLayoutQuotes();
130 extern void MenuLayoutPreamble();
131 extern void MenuLayoutSave();
132 extern void bulletForm();
134 extern Buffer * NewLyxFile(string const &);
135 extern void LoadLyXFile(string const &);
136 extern void Reconfigure();
138 extern int current_layout;
139 extern int getISOCodeFromLaTeX(char *);
141 extern int UnlockInset(UpdatableInset *);
143 extern void ShowLatexLog();
145 extern void UpdateInset(Inset * inset, bool mark_dirty = true);
147 /* === globals =========================================================== */
149 bool LyXFunc::show_sc = true;
152 LyXFunc::LyXFunc(LyXView * o)
156 lyx_dead_action = LFUN_NOACTION;
157 lyx_calling_dead_action = LFUN_NOACTION;
162 // I changed this func slightly. I commented out the ...FinishUndo(),
163 // this means that all places that used to have a moveCursorUpdate, now
164 // have a ...FinishUndo() as the preceeding statement. I have also added
165 // a moveCursorUpdate to some of the functions that updated the cursor, but
166 // that did not show its new position.
168 void LyXFunc::moveCursorUpdate(bool selecting)
171 if (selecting || owner->view()->text->mark_set) {
172 owner->view()->text->SetSelection();
173 owner->view()->getScreen()->ToggleToggle();
174 owner->view()->update(0);
176 owner->view()->update(-2); // this IS necessary
180 if (selecting || owner->buffer()->text->mark_set) {
181 owner->buffer()->text->SetSelection();
182 owner->view()->getScreen()->ToggleToggle();
183 owner->buffer()->update(0);
185 owner->buffer()->update(-2); // this IS necessary
189 owner->view()->getScreen()->ShowCursor();
191 /* ---> Everytime the cursor is moved, show the current font state. */
192 // should this too me moved out of this func?
193 //owner->getMiniBuffer()->Set(CurrentState());
197 int LyXFunc::processKeyEvent(XEvent * ev)
204 XKeyEvent * keyevent = &ev->xkey;
205 KeySym keysym_return;
207 num_bytes = LyXLookupString(ev, s_r, 10, &keysym_return);
209 if (lyxerr.debugging(Debug::KEY)) {
210 lyxerr << "KeySym is "
211 << XKeysymToString(keysym_return)
213 << keysym_return << "]"
214 << " and num_bytes is "
216 << " the string returned is \""
217 << s_r << '\"' << endl;
219 // Do nothing if we have nothing (JMarc)
220 if (num_bytes == 0 && keysym_return == NoSymbol) {
221 lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
226 // this function should be used always [asierra060396]
227 if (owner->view()->available() &&
228 owner->buffer()->the_locking_inset &&
229 keysym_return == XK_Escape) {
230 UnlockInset(owner->buffer()->the_locking_inset);
232 owner->view()->text->CursorRight();
234 owner->buffer()->text->CursorRight();
239 // Can we be sure that this will work for all X-Windows
240 // implementations? (Lgb)
241 // This code snippet makes lyx ignore some keys. Perhaps
242 // all of them should be explictly mentioned?
243 if((keysym_return >= XK_Shift_L && keysym_return <= XK_Hyper_R)
244 || keysym_return == XK_Mode_switch || keysym_return == 0x0)
247 // Do a one-deep top-level lookup for
248 // cancel and meta-fake keys. RVDK_PATCH_5
249 cancel_meta_seq.reset();
251 action = cancel_meta_seq.addkey(keysym_return, keyevent->state
252 &(ShiftMask|ControlMask
255 // When not cancel or meta-fake, do the normal lookup.
256 // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
257 // Mostly, meta_fake_bit = 0. RVDK_PATCH_5.
258 if ( (action != LFUN_CANCEL) && (action != LFUN_META_FAKE) ) {
260 // remove Caps Lock and Mod2 as a modifiers
261 action = keyseq.addkey(keysym_return,
262 (keyevent->state | meta_fake_bit)
263 &(ShiftMask|ControlMask
266 // Dont remove this unless you know what you are doing.
269 if (action == 0) action = LFUN_PREFIX;
271 if (lyxerr.debugging(Debug::KEY)) {
273 keyseq.print(buf, 100);
277 << num_bytes << "]" << endl;
280 // already here we know if it any point in going further
281 // why not return already here if action == -1 and
282 // num_bytes == 0? (Lgb)
284 if(keyseq.length>1 || keyseq.length<-1){
286 keyseq.print(buf, 100);
287 owner->getMiniBuffer()->Set(buf);
291 if (keyseq.length<-1) { // unknown key sequence...
294 keyseq.print(buf, 100);
295 owner->getMiniBuffer()->Set(_("Unknown sequence:"), buf);
299 char isochar = keyseq.getiso();
300 if (!(keyevent->state&ControlMask) &&
301 !(keyevent->state&Mod1Mask) &&
302 (isochar && keysym_return < 0xF000)) {
305 if (argument.empty()) {
306 lyxerr.debug() << "Empty argument!" << endl;
307 // This can`t possibly be of any use
308 // so we`ll skip the dispatch.
312 if (action == LFUN_SELFINSERT) {
316 bool tmp_sc = show_sc;
318 Dispatch(action, argument.c_str());
325 LyXFunc::func_status LyXFunc::getStatus(int ac) const
328 func_status flag = LyXFunc::OK;
330 Buffer * buf = owner->buffer();
332 if (lyxaction.isPseudoAction(ac))
333 action = lyxaction.retrieveActionArg(ac, argument);
335 action = static_cast<kb_action>(ac);
337 if (action == LFUN_UNKNOWN_ACTION) {
338 setErrorMessage(N_("Unknown action"));
339 return LyXFunc::Unknown;
342 // Check whether we need a buffer
343 if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) {
344 // Yes we need a buffer, do we have one?
347 // Can we use a readonly buffer?
348 if (buf->isReadonly() &&
349 !lyxaction.funcHasFlag(action,
350 LyXAction::ReadOnly)) {
352 setErrorMessage(N_("Document is read-only"));
353 flag = func_status(flag | LyXFunc::Disabled);
357 setErrorMessage(N_("Command not allowed with"
358 "out any document open"));
359 flag = func_status(flag | LyXFunc::Disabled);
363 if (flag & LyXFunc::Disabled)
366 static bool noLaTeX = lyxrc->latex_command == "none";
367 bool disable = false;
370 disable = noLaTeX || lyxrc->view_dvi_command == "none";
373 disable = noLaTeX || lyxrc->view_ps_command == "none";
380 disable = noLaTeX || lyxrc->print_command == "none";
383 disable = noLaTeX || lyxrc->fax_command == "none";
386 if (argument == "latex")
387 disable = lyxrc->relyx_command == "none";
390 if (argument == "dvi" || argument == "postscript")
392 if (argument == "html")
393 disable = lyxrc->html_command == "none";
396 disable = buf->undostack.empty();
399 disable = buf->redostack.empty();
401 case LFUN_SPELLCHECK:
402 disable = lyxrc->isp_command == "none";
405 disable = lyxrc->chktex_command == "none";
407 case LFUN_LAYOUT_TABLE:
409 disable = ! owner->view()->text->cursor.par->table;
411 disable = ! buf->text->cursor.par->table;
418 flag |= LyXFunc::Disabled;
421 func_status box = LyXFunc::ToggleOff;
423 LyXFont font = owner->view()->text->real_current_font;
425 LyXFont font = buf->text->real_current_font;
429 if (font.emph() == LyXFont::ON)
430 box = LyXFunc::ToggleOn;
433 if (font.noun() == LyXFont::ON)
434 box = LyXFunc::ToggleOn;
437 if (font.series() == LyXFont::BOLD_SERIES)
438 box = LyXFunc::ToggleOn;
441 if (font.latex() == LyXFont::ON)
442 box = LyXFunc::ToggleOn;
456 string LyXFunc::Dispatch(string const & s)
458 // Split command string into command and argument
459 string cmd, line = frontStrip(s);
460 string arg = strip(frontStrip(split(line, cmd, ' ')));
462 return Dispatch(lyxaction.LookupFunc(cmd.c_str()), arg.c_str());
467 string LyXFunc::Dispatch(int ac,
468 char const * do_not_use_this_arg)
473 FL_OBJECT * ob = 0; // This will disapear soon
475 // we have not done anything wrong yet.
477 dispatch_buffer.clear();
479 // if action is a pseudo-action, we need the real action
480 if (lyxaction.isPseudoAction(ac)) {
482 action = static_cast<kb_action>
483 (lyxaction.retrieveActionArg(ac, tmparg));
487 action = static_cast<kb_action>(ac);
488 if (do_not_use_this_arg)
489 argument = do_not_use_this_arg; // except here
492 selection_possible = false;
494 if (owner->view()->available()
495 && owner->view()->getScreen())
496 owner->view()->getScreen()->HideCursor();
498 // We cannot use this function here
499 if (getStatus(action) & Disabled)
500 goto exit_with_message;
502 commandshortcut.clear();
504 if (lyxrc->display_shortcuts && show_sc) {
505 if (action != LFUN_SELFINSERT) {
506 // Put name of command and list of shortcuts
507 // for it in minibuffer
508 string comname = lyxaction.getActionName(action);
510 int pseudoaction = action;
511 bool argsadded = false;
513 if (!argument.empty()) {
514 // If we have the command with argument,
517 lyxaction.searchActionArg(action,
520 if (pseudoaction == -1) {
521 pseudoaction = action;
523 comname += " " + argument;
528 string shortcuts = toplevel_keymap->findbinding(pseudoaction);
530 if (!shortcuts.empty()) {
531 comname += ": " + shortcuts;
532 } else if (!argsadded) {
533 comname += " " + argument;
536 if (!comname.empty()) {
537 comname = strip(comname);
538 commandshortcut = "(" + comname + ')';
539 owner->getMiniBuffer()->Set(commandshortcut);
540 // Here we could even add a small pause,
541 // to annoy the user and make him learn
543 // No! That will just annoy, not teach
544 // anything. The user will read the messages
545 // if they are interested. (Asger)
550 // If in math mode pass the control to
551 // the math inset [asierra060396]
552 if (owner->view()->available() &&
553 owner->buffer()->the_locking_inset) {
555 || (action == LFUN_UNKNOWN_ACTION && keyseq.length>= -1)) {
556 if (action == LFUN_UNKNOWN_ACTION && argument.empty()) {
557 argument = keyseq.getiso();
559 // Undo/Redo pre 0.13 is a bit tricky for insets.
560 if (action == LFUN_UNDO) {
562 UpdatableInset * inset =
563 owner->buffer()->the_locking_inset;
564 inset->GetCursorPos(slx, sly);
567 inset = static_cast<UpdatableInset*>(owner->view()->text->cursor.par->GetInset(owner->view()->text->cursor.pos));
569 inset->Edit(slx, sly);
572 if (action == LFUN_REDO) {
574 UpdatableInset * inset = owner->buffer()->the_locking_inset;
575 inset->GetCursorPos(slx, sly);
578 inset = static_cast<UpdatableInset*>(owner->view()->text->cursor.par->GetInset(owner->view()->text->cursor.pos));
580 inset->Edit(slx, sly);
583 if (owner->buffer()->the_locking_inset->LocalDispatch(action, argument.c_str()))
586 setMessage(N_("Text mode"));
587 if (action == LFUN_RIGHT || action == -1)
588 owner->view()->text->CursorRight();
589 if (action == LFUN_LEFT || action == LFUN_RIGHT)
596 // --- Misc -------------------------------------------
597 case LFUN_WORDFINDFORWARD :
598 case LFUN_WORDFINDBACKWARD : {
599 static string last_search;
600 string searched_string;
602 if (!argument.empty()) {
603 last_search = argument;
604 searched_string = argument;
606 searched_string = last_search;
609 LyXText * ltCur = owner->view()->text ;
611 if (!searched_string.empty() &&
612 ((action == LFUN_WORDFINDBACKWARD) ?
613 ltCur->SearchBackward(searched_string.c_str()) :
614 ltCur->SearchForward(searched_string.c_str()))) {
616 // ??? What is that ???
617 owner->view()->update(-2);
620 // clear the selection (if there is any)
621 owner->view()->getScreen()->ToggleSelection();
622 owner->view()->text->ClearSelection();
624 // Move cursor so that successive C-s 's will not stand in place.
625 if( action == LFUN_WORDFINDFORWARD )
626 owner->view()->text->CursorRightOneWord();
627 owner->view()->text->FinishUndo();
628 moveCursorUpdate(false);
631 // set the new selection
632 // SetSelectionOverLenChars(owner->view()->currentBuffer()->text, iLenSelected);
633 owner->view()->getScreen()->ToggleSelection(false);
637 // REMOVED : if (owner->view()->getWorkArea()->focus)
638 owner->view()->getScreen()->ShowCursor();
644 if (owner->view()->available()
645 && owner->view()->getScreen()) {
646 owner->view()->update(-2);
649 keyseq.print(buf, 100, true);
650 owner->getMiniBuffer()->Set(buf, string(), string(), 1);
654 // --- Misc -------------------------------------------
655 case LFUN_EXEC_COMMAND:
656 owner->getMiniBuffer()->ExecCommand();
659 case LFUN_CANCEL: // RVDK_PATCH_5
662 if(owner->view()->available())
663 // cancel any selection
664 Dispatch(LFUN_MARK_OFF, 0);
665 setMessage(N_("Cancel"));
668 case LFUN_META_FAKE: // RVDK_PATCH_5
670 meta_fake_bit = Mod1Mask;
672 keyseq.print(buf, 98, true);
673 string res = string("M-") + buf;
674 setMessage(buf); // RVDK_PATCH_5
678 case LFUN_READ_ONLY_TOGGLE:
679 if (owner->buffer()->lyxvc.inUse()) {
680 owner->buffer()->lyxvc.toggleReadOnly();
682 owner->buffer()->setReadonly(
683 !owner->buffer()->isReadonly());
687 case LFUN_CENTER: // this is center and redraw.
689 if (owner->view()->text->cursor.y >
690 owner->view()->getWorkArea()->h / 2) {
691 owner->view()->getScreen()->
692 Draw(owner->view()->text->cursor.y -
693 owner->view()->getWorkArea()->h/2);
695 owner->view()->getScreen()->
698 owner->view()->update(0);
699 owner->view()->redraw();
703 if (owner->view()->available()) {
704 owner->view()->text->toggleAppendix();
705 owner->view()->update(1);
709 // --- Menus -----------------------------------------------
714 case LFUN_MENUNEWTMPLT:
722 case LFUN_CLOSEBUFFER:
727 MenuWrite(owner->buffer());
730 case LFUN_MENUWRITEAS:
731 MenuWriteAs(owner->buffer());
734 case LFUN_MENURELOAD:
739 MenuPreview(owner->buffer());
743 MenuPreviewPS(owner->buffer());
747 MenuRunLaTeX(owner->buffer());
751 MenuBuildProg(owner->buffer());
755 MenuRunChktex(owner->buffer());
759 MenuRunDvips(owner->buffer(), false);
763 MenuPrint(owner->buffer());
767 MenuFax(owner->buffer());
772 //needs argument as string
773 string extyp = argument;
776 if (extyp == "latex") {
777 // make sure that this buffer is not linuxdoc
778 MenuMakeLaTeX(owner->buffer());
781 else if (extyp == "linuxdoc") {
782 // make sure that this buffer is not latex
783 MenuMakeLinuxDoc(owner->buffer());
786 else if (extyp == "docbook") {
787 // make sure that this buffer is not latex or linuxdoc
788 MenuMakeDocBook(owner->buffer());
791 else if (extyp == "dvi") {
792 // Run LaTeX as "Update dvi..." Bernhard.
793 // We want the dvi in the current directory. This
794 // is achieved by temporarily disabling use of
795 // temp directory. As a side-effect, we get
796 // *.log and *.aux files also. (Asger)
797 bool flag = lyxrc->use_tempdir;
798 lyxrc->use_tempdir = false;
799 MenuRunLaTeX(owner->buffer());
800 lyxrc->use_tempdir = flag;
803 else if (extyp == "postscript") {
804 // Start Print-dialog. Not as good as dvi... Bernhard.
805 MenuPrint(owner->buffer());
806 // Since the MenuPrint is a pop-up, we can't use
807 // the same trick as above. (Asger)
808 // MISSING: Move of ps-file :-(
811 else if (extyp == "ascii") {
812 MenuMakeAscii(owner->buffer());
814 else if (extyp == "custom") {
819 else if (extyp == "html" && lyxrc->html_command != "none") {
820 // First, create LaTeX file
821 MenuMakeLaTeX(owner->buffer());
823 // And now, run the converter
824 string file = owner->buffer()->fileName();
825 Path path(OnlyPath(file));
826 // the tex file name has to be correct for
827 // latex, but the html file name can be
829 string result = ChangeExtension(file, ".html", false);
830 string infile = owner->buffer()->getLatexName();
831 string tmp = lyxrc->html_command;
832 tmp = subst(tmp, "$$FName", infile);
833 tmp = subst(tmp, "$$OutName", result);
835 int res = one.startscript(Systemcalls::System, tmp);
837 setMessage(N_("Document exported as HTML to file `")
838 + MakeDisplayPath(result) +'\'');
840 setErrorMessage(N_("Unable to convert to HTML the file `")
841 + MakeDisplayPath(infile)
846 setErrorMessage(N_("Unknown export type: ")
854 //needs argument as string
855 string imtyp = argument;
858 if (imtyp == "latex") {
859 doImportLaTeX(false);
862 else if (imtyp == "ascii") {
863 doImportASCII(false);
864 } else if (imtyp == "asciiparagraph") {
867 } else if (imtyp == "noweb") {
870 setErrorMessage(string(N_("Unknown import type: "))
882 if (fd_form_toc->form_toc->visible) {
883 fl_raise_form(fd_form_toc->form_toc);
885 static int ow = -1, oh;
886 fl_show_form(fd_form_toc->form_toc,
888 FL_FREE_SIZE, FL_FULLBORDER,
889 _("Table of Contents"));
891 ow = fd_form_toc->form_toc->w;
892 oh = fd_form_toc->form_toc->h;
894 fl_set_form_minsize(fd_form_toc->form_toc, ow, oh);
898 case LFUN_TOC_INSERT:
900 Inset * new_inset = new InsetTOC(owner->buffer());
901 owner->buffer()->insertInset(new_inset, "Standard", true);
905 case LFUN_LOF_INSERT:
907 Inset * new_inset = new InsetLOF(owner->buffer());
908 owner->buffer()->insertInset(new_inset, "Standard", true);
912 case LFUN_LOA_INSERT:
914 Inset * new_inset = new InsetLOA(owner->buffer());
915 owner->buffer()->insertInset(new_inset, "Standard", true);
919 case LFUN_LOT_INSERT:
921 Inset * new_inset = new InsetLOT(owner->buffer());
922 owner->buffer()->insertInset(new_inset, "Standard", true);
946 case LFUN_MENUSEARCH:
954 case LFUN_PASTESELECTION:
957 if (argument == "paragraph") asPara = true;
958 MenuPasteSelection(asPara);
970 case LFUN_LAYOUT_COPY:
974 case LFUN_LAYOUT_PASTE:
975 PasteEnvironmentCB();
979 owner->view()->gotoError();
982 case LFUN_REMOVEERRORS:
983 if (owner->buffer()->removeAutoInsets()) {
984 owner->view()->redraw();
985 owner->view()->fitCursor();
986 owner->view()->updateScrollbar();
998 case LFUN_HYPHENATION:
1006 case LFUN_END_OF_SENTENCE:
1010 case LFUN_MENU_SEPARATOR:
1022 case LFUN_DEPTH_MIN:
1026 case LFUN_DEPTH_PLUS:
1042 case LFUN_RECONFIGURE:
1047 if (owner->view()->available()
1048 && !owner->view()->text->selection
1049 && owner->view()->text->cursor.par->footnoteflag
1050 != LyXParagraph::NO_FOOTNOTE)
1051 { // only melt footnotes with FOOTMELT, not margins etc
1052 if(owner->view()->text->cursor.par->footnotekind == LyXParagraph::FOOTNOTE)
1059 case LFUN_MARGINMELT:
1060 if (owner->view()->available()
1061 && !owner->view()->text->selection
1062 && owner->view()->text->cursor.par->footnoteflag
1063 != LyXParagraph::NO_FOOTNOTE) {
1064 // only melt margins
1065 if(owner->view()->text->cursor.par->footnotekind == LyXParagraph::MARGIN)
1072 // --- version control -------------------------------
1073 case LFUN_VC_REGISTER:
1075 if (!owner->buffer()->lyxvc.inUse())
1076 owner->buffer()->lyxvc.registrer();
1080 case LFUN_VC_CHECKIN:
1082 if (owner->buffer()->lyxvc.inUse()
1083 && !owner->buffer()->isReadonly())
1084 owner->buffer()->lyxvc.checkIn();
1088 case LFUN_VC_CHECKOUT:
1090 if (owner->buffer()->lyxvc.inUse()
1091 && owner->buffer()->isReadonly())
1092 owner->buffer()->lyxvc.checkOut();
1096 case LFUN_VC_REVERT:
1098 owner->buffer()->lyxvc.revert();
1104 owner->buffer()->lyxvc.undoLast();
1108 case LFUN_VC_HISTORY:
1110 owner->buffer()->lyxvc.showLog();
1114 // --- buffers ----------------------------------------
1115 case LFUN_PREVBUFFER:
1116 #ifdef WITH_WARNINGS
1117 #warning fix this please
1119 // it is the LyXView or the BufferView that should
1120 // remember the previous buffer, not bufferlist.
1121 // if (owner->view()->available()){
1123 // owner->buffer()->update(-2);
1125 // owner->view()->setBuffer(bufferlist.prev());
1128 // resizeCurrentBufferPseudoExpose();
1131 case LFUN_FILE_INSERT:
1133 MenuInsertLyXFile(argument);
1137 case LFUN_FILE_INSERT_ASCII:
1139 bool asPara = (argument == "paragraph");
1140 InsertAsciiFile(string(), asPara);
1146 // servercmd: argument must be <file>:<template>
1147 Buffer * tmpbuf = NewLyxFile(argument);
1149 owner->view()->buffer(tmpbuf);
1153 case LFUN_FILE_OPEN:
1154 owner->view()->buffer(
1155 bufferlist.loadLyXFile(argument));
1158 case LFUN_LATEX_LOG:
1164 lyxerr.debug() << "LFUN_LAYOUTNO: (arg) " << argument << endl;
1165 int sel = strToInt(argument);
1166 lyxerr.debug() << "LFUN_LAYOUTNO: (sel) "<< sel << endl;
1168 // Should this give a setMessage instead?
1170 return string(); // illegal argument
1172 sel--; // sel 1..., but layout 0...
1174 // Pretend we got the name instead.
1175 Dispatch(int(LFUN_LAYOUT),
1176 textclasslist.NameOfLayout(owner->view()->
1185 lyxerr.debug() << "LFUN_LAYOUT: (arg) "
1186 << argument << endl;
1188 // Derive layout number from given argument (string)
1189 // and current buffer's textclass (number). */
1191 textclasslist.NumberOfLayout(owner->
1197 // see if we found the layout number:
1198 if (layoutno == -1) {
1199 setErrorMessage(string(N_("Layout ")) + argument +
1204 if (current_layout != layoutno) {
1205 owner->view()->getScreen()->HideCursor();
1206 current_layout = layoutno;
1207 owner->view()->update(-2);
1208 owner->view()->text->
1209 SetLayout(layoutno);
1210 owner->getToolbar()->combox->
1211 select(owner->view()->
1214 owner->view()->update(1);
1219 case LFUN_LAYOUT_DOCUMENT:
1220 MenuLayoutDocument();
1223 case LFUN_LAYOUT_PARAGRAPH:
1224 MenuLayoutParagraph();
1227 case LFUN_LAYOUT_CHARACTER:
1228 MenuLayoutCharacter();
1231 case LFUN_LAYOUT_TABLE:
1234 if (argument == "true") flag = 1;
1235 MenuLayoutTable(flag);
1239 case LFUN_LAYOUT_PAPER:
1243 case LFUN_LAYOUT_QUOTES:
1247 case LFUN_LAYOUT_PREAMBLE:
1248 MenuLayoutPreamble();
1251 case LFUN_LAYOUT_SAVE_DEFAULT:
1255 case LFUN_DROP_LAYOUTS_CHOICE:
1256 owner->getToolbar()->combox->Show();
1287 case LFUN_UNDERLINE:
1291 case LFUN_FONT_SIZE:
1292 FontSizeCB(argument);
1295 case LFUN_FONT_STATE:
1296 setMessage(CurrentState());
1299 case LFUN_UPCASE_WORD:
1300 owner->view()->update(-2);
1302 owner->view()->text->ChangeWordCase(LyXText::text_uppercase);
1303 owner->view()->update(1);
1307 case LFUN_LOWCASE_WORD:
1308 owner->view()->update(-2);
1310 owner->view()->text->ChangeWordCase(LyXText::text_lowercase);
1311 owner->view()->update(1);
1315 case LFUN_CAPITALIZE_WORD:
1316 owner->view()->update(-2);
1318 owner->view()->text->ChangeWordCase(LyXText::text_capitalization);
1319 owner->view()->update(1);
1323 case LFUN_INSERT_LABEL:
1324 MenuInsertLabel(argument.c_str());
1327 case LFUN_INSERT_REF:
1331 case LFUN_REFTOGGLE:
1334 static_cast<InsetRef*>(getInsetByCode(Inset::REF_CODE));
1336 if (inset->getFlag() == InsetRef::REF)
1337 inset->setFlag(InsetRef::PAGE_REF);
1339 inset->setFlag(InsetRef::REF);
1342 setErrorMessage(N_("No cross-reference to toggle"));
1349 owner->view()->restorePosition();
1355 string label(argument);
1356 if (label.empty()) {
1358 static_cast<InsetRef*>(getInsetByCode(Inset::REF_CODE));
1360 label = inset->getContents();
1363 if (!label.empty()) {
1364 owner->view()->savePosition();
1365 owner->buffer()->gotoLabel(label.c_str());
1370 case LFUN_MENU_OPEN_BY_NAME:
1371 owner->getMenus()->openByName(argument);
1372 break; // RVDK_PATCH_5
1374 case LFUN_SPELLCHECK:
1375 if (lyxrc->isp_command != "none")
1377 break; // RVDK_PATCH_5
1379 // --- Cursor Movements -----------------------------
1382 LyXText * tmptext = owner->view()->text;
1383 if(!tmptext->mark_set)
1385 owner->view()->update(-2);
1386 if (tmptext->cursor.pos < tmptext->cursor.par->Last()
1387 && tmptext->cursor.par->GetChar(tmptext->cursor.pos)
1388 == LyXParagraph::META_INSET
1389 && tmptext->cursor.par->GetInset(tmptext->cursor.pos)
1390 && tmptext->cursor.par->GetInset(tmptext->cursor.pos)->Editable() == 2){
1391 Inset * tmpinset = tmptext->cursor.par->GetInset(tmptext->cursor.pos);
1392 setMessage(tmpinset->EditMessage());
1393 tmpinset->Edit(0, 0);
1396 tmptext->CursorRight();
1397 owner->view()->text->FinishUndo();
1398 moveCursorUpdate(false);
1399 owner->getMiniBuffer()->Set(CurrentState());
1405 // This is soooo ugly. Isn`t it possible to make
1406 // it simpler? (Lgb)
1407 LyXText * txt = owner->view()->text;
1408 if(!txt->mark_set) BeforeChange();
1409 owner->view()->update(-2);
1411 if (txt->cursor.pos < txt->cursor.par->Last()
1412 && txt->cursor.par->GetChar(txt->cursor.pos)
1413 == LyXParagraph::META_INSET
1414 && txt->cursor.par->GetInset(txt->cursor.pos)
1415 && txt->cursor.par->GetInset(txt->cursor.pos)->Editable() == 2) {
1416 Inset * tmpinset = txt->cursor.par->GetInset(txt->cursor.pos);
1417 setMessage(tmpinset->EditMessage());
1418 tmpinset->Edit(tmpinset->Width(txt->GetFont(txt->cursor.par,
1419 txt->cursor.pos)), 0);
1422 owner->view()->text->FinishUndo();
1423 moveCursorUpdate(false);
1424 owner->getMiniBuffer()->Set(CurrentState());
1429 if(!owner->view()->text->mark_set) BeforeChange();
1430 owner->view()->update(-3);
1431 owner->view()->text->CursorUp();
1432 owner->view()->text->FinishUndo();
1433 moveCursorUpdate(false);
1434 owner->getMiniBuffer()->Set(CurrentState());
1438 if(!owner->view()->text->mark_set)
1440 owner->view()->update(-3);
1441 owner->view()->text->CursorDown();
1442 owner->view()->text->FinishUndo();
1443 moveCursorUpdate(false);
1444 owner->getMiniBuffer()->Set(CurrentState());
1447 case LFUN_UP_PARAGRAPH:
1448 if(!owner->view()->text->mark_set)
1450 owner->view()->update(-3);
1451 owner->view()->text->CursorUpParagraph();
1452 owner->view()->text->FinishUndo();
1453 moveCursorUpdate(false);
1454 owner->getMiniBuffer()->Set(CurrentState());
1457 case LFUN_DOWN_PARAGRAPH:
1458 if(!owner->view()->text->mark_set)
1460 owner->view()->update(-3);
1461 owner->view()->text->CursorDownParagraph();
1462 owner->view()->text->FinishUndo();
1463 moveCursorUpdate(false);
1464 owner->getMiniBuffer()->Set(CurrentState());
1468 if(!owner->view()->text->mark_set)
1470 owner->view()->update(-3);
1471 owner->view()->cursorPrevious();
1472 owner->view()->text->FinishUndo();
1473 moveCursorUpdate(false);
1474 owner->getMiniBuffer()->Set(CurrentState());
1478 if(!owner->view()->text->mark_set)
1480 owner->view()->update(-3);
1481 owner->view()->cursorNext();
1482 owner->view()->text->FinishUndo();
1483 moveCursorUpdate(false);
1484 owner->getMiniBuffer()->Set(CurrentState());
1488 if(!owner->view()->text->mark_set)
1490 owner->view()->update(-2);
1491 owner->view()->text->CursorHome();
1492 owner->view()->text->FinishUndo();
1493 moveCursorUpdate(false);
1494 owner->getMiniBuffer()->Set(CurrentState());
1498 if(!owner->view()->text->mark_set)
1500 owner->view()->update(-2);
1501 owner->view()->text->CursorEnd();
1502 owner->view()->text->FinishUndo();
1503 moveCursorUpdate(false);
1504 owner->getMiniBuffer()->Set(CurrentState());
1508 if(!owner->view()->text->mark_set)
1510 owner->view()->update(-2);
1511 owner->view()->text->CursorTab();
1512 owner->view()->text->FinishUndo();
1513 moveCursorUpdate(false);
1514 owner->getMiniBuffer()->Set(CurrentState());
1517 case LFUN_WORDRIGHT:
1518 if(!owner->view()->text->mark_set)
1520 owner->view()->update(-2);
1521 owner->view()->text->CursorRightOneWord();
1522 owner->view()->text->FinishUndo();
1523 moveCursorUpdate(false);
1524 owner->getMiniBuffer()->Set(CurrentState());
1528 if(!owner->view()->text->mark_set)
1530 owner->view()->update(-2);
1531 owner->view()->text->CursorLeftOneWord();
1532 owner->view()->text->FinishUndo();
1533 moveCursorUpdate(false);
1534 owner->getMiniBuffer()->Set(CurrentState());
1537 case LFUN_BEGINNINGBUF:
1538 if(!owner->view()->text->mark_set)
1540 owner->view()->update(-2);
1541 owner->view()->text->CursorTop();
1542 owner->view()->text->FinishUndo();
1543 moveCursorUpdate(false);
1544 owner->getMiniBuffer()->Set(CurrentState());
1548 if(!owner->view()->text->mark_set)
1550 owner->view()->update(-2);
1551 owner->view()->text->CursorBottom();
1552 owner->view()->text->FinishUndo();
1553 moveCursorUpdate(false);
1554 owner->getMiniBuffer()->Set(CurrentState());
1558 /* cursor selection ---------------------------- */
1560 owner->view()->update(-2);
1561 owner->view()->text->CursorRight();
1562 owner->view()->text->FinishUndo();
1563 moveCursorUpdate(true);
1564 owner->getMiniBuffer()->Set(CurrentState());
1568 owner->view()->update(-2);
1569 owner->view()->text->CursorLeft();
1570 owner->view()->text->FinishUndo();
1571 moveCursorUpdate(true);
1572 owner->getMiniBuffer()->Set(CurrentState());
1576 owner->view()->update(-2);
1577 owner->view()->text->CursorUp();
1578 owner->view()->text->FinishUndo();
1579 moveCursorUpdate(true);
1580 owner->getMiniBuffer()->Set(CurrentState());
1584 owner->view()->update(-2);
1585 owner->view()->text->CursorDown();
1586 owner->view()->text->FinishUndo();
1587 moveCursorUpdate(true);
1588 owner->getMiniBuffer()->Set(CurrentState());
1591 case LFUN_UP_PARAGRAPHSEL:
1592 owner->view()->update(-2);
1593 owner->view()->text->CursorUpParagraph();
1594 owner->view()->text->FinishUndo();
1595 moveCursorUpdate(true);
1596 owner->getMiniBuffer()->Set(CurrentState());
1599 case LFUN_DOWN_PARAGRAPHSEL:
1600 owner->view()->update(-2);
1601 owner->view()->text->CursorDownParagraph();
1602 owner->view()->text->FinishUndo();
1603 moveCursorUpdate(true);
1604 owner->getMiniBuffer()->Set(CurrentState());
1608 owner->view()->update(-2);
1609 owner->view()->cursorPrevious();
1610 owner->view()->text->FinishUndo();
1611 moveCursorUpdate(true);
1612 owner->getMiniBuffer()->Set(CurrentState());
1616 owner->view()->update(-2);
1617 owner->view()->cursorNext();
1618 owner->view()->text->FinishUndo();
1619 moveCursorUpdate(true);
1620 owner->getMiniBuffer()->Set(CurrentState());
1624 owner->view()->update(-2);
1625 owner->view()->text->CursorHome();
1626 owner->view()->text->FinishUndo();
1627 moveCursorUpdate(true);
1628 owner->getMiniBuffer()->Set(CurrentState());
1632 owner->view()->update(-2);
1633 owner->view()->text->CursorEnd();
1634 owner->view()->text->FinishUndo();
1635 moveCursorUpdate(true);
1636 owner->getMiniBuffer()->Set(CurrentState());
1639 case LFUN_WORDRIGHTSEL:
1640 owner->view()->update(-2);
1641 owner->view()->text->CursorRightOneWord();
1642 owner->view()->text->FinishUndo();
1643 moveCursorUpdate(true);
1644 owner->getMiniBuffer()->Set(CurrentState());
1647 case LFUN_WORDLEFTSEL:
1648 owner->view()->update(-2);
1649 owner->view()->text->CursorLeftOneWord();
1650 owner->view()->text->FinishUndo();
1651 moveCursorUpdate(true);
1652 owner->getMiniBuffer()->Set(CurrentState());
1655 case LFUN_BEGINNINGBUFSEL:
1656 owner->view()->update(-2);
1657 owner->view()->text->CursorTop();
1658 owner->view()->text->FinishUndo();
1659 moveCursorUpdate(true);
1660 owner->getMiniBuffer()->Set(CurrentState());
1663 case LFUN_ENDBUFSEL:
1664 owner->view()->update(-2);
1665 owner->view()->text->CursorBottom();
1666 owner->view()->text->FinishUndo();
1667 moveCursorUpdate(true);
1668 owner->getMiniBuffer()->Set(CurrentState());
1671 // --- text changing commands ------------------------
1672 case LFUN_BREAKLINE:
1674 owner->view()->text->InsertChar(LyXParagraph::META_NEWLINE);
1676 SetUpdateTimer(0.01);
1677 moveCursorUpdate(false);
1680 case LFUN_PROTECTEDSPACE:
1682 owner->view()->text->
1683 InsertChar(LyXParagraph::META_PROTECTED_SEPARATOR);
1686 moveCursorUpdate(false);
1690 if(owner->view()->text->mark_set) {
1692 owner->view()->update(0);
1693 setMessage(N_("Mark removed"));
1696 owner->view()->text->mark_set = 1;
1697 owner->view()->update(0);
1698 setMessage(N_("Mark set"));
1700 owner->view()->text->sel_cursor =
1701 owner->view()->text->cursor;
1706 if (!owner->view()->text->selection) {
1707 owner->view()->text->Delete();
1708 owner->view()->text->sel_cursor =
1709 owner->view()->text->cursor;
1711 // It is possible to make it a lot faster still
1712 // just comment out the lone below...
1713 owner->view()->getScreen()->ShowCursor();
1720 case LFUN_DELETE_SKIP:
1722 // Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
1724 LyXCursor cursor = owner->view()->text->cursor;
1727 if (!owner->view()->text->selection) {
1728 if (cursor.pos == cursor.par->Last()) {
1729 owner->view()->text->CursorRight();
1730 cursor = owner->view()->text->cursor;
1732 && !(cursor.par->added_space_top
1733 == VSpace (VSpace::NONE))) {
1734 owner->view()->text->SetParagraph
1735 (cursor.par->line_top,
1736 cursor.par->line_bottom,
1737 cursor.par->pagebreak_top,
1738 cursor.par->pagebreak_bottom,
1739 VSpace(VSpace::NONE),
1740 cursor.par->added_space_bottom,
1742 cursor.par->labelwidthstring, 0);
1743 owner->view()->text->CursorLeft();
1744 owner->view()->update (1);
1746 owner->view()->text->CursorLeft();
1747 owner->view()->text->Delete();
1748 owner->view()->text->sel_cursor =
1749 owner->view()->text->cursor;
1753 owner->view()->text->Delete();
1754 owner->view()->text->sel_cursor =
1755 owner->view()->text->cursor;
1765 /* -------> Delete word forward. */
1766 case LFUN_DELETE_WORD_FORWARD:
1767 owner->view()->update(-2);
1769 owner->view()->text->DeleteWordForward();
1770 owner->view()->update( 1 );
1772 moveCursorUpdate(false);
1775 /* -------> Delete word backward. */
1776 case LFUN_DELETE_WORD_BACKWARD:
1777 owner->view()->update(-2);
1779 owner->view()->text->DeleteWordBackward();
1780 owner->view()->update( 1 );
1782 moveCursorUpdate(false);
1785 /* -------> Kill to end of line. */
1786 case LFUN_DELETE_LINE_FORWARD:
1788 owner->view()->update(-2);
1789 owner->view()->text->DeleteLineForward();
1790 owner->view()->update( 1 );
1792 moveCursorUpdate(false);
1795 /* -------> Set mark off. */
1798 owner->view()->update(0);
1799 owner->view()->text->sel_cursor =
1800 owner->view()->text->cursor;
1801 setMessage(N_("Mark off"));
1804 /* -------> Set mark on. */
1807 owner->view()->text->mark_set = 1;
1808 owner->view()->update( 0 );
1809 owner->view()->text->sel_cursor =
1810 owner->view()->text->cursor;
1811 setMessage(N_("Mark on"));
1814 case LFUN_BACKSPACE:
1817 if (!owner->view()->text->selection) {
1818 if (owner->getIntl()->getTrans()->backspace()) {
1819 owner->view()->text->Backspace();
1820 owner->view()->text->sel_cursor =
1821 owner->view()->text->cursor;
1823 // It is possible to make it a lot faster still
1824 // just comment out the lone below...
1825 owner->view()->getScreen()->ShowCursor();
1834 case LFUN_BACKSPACE_SKIP:
1836 // Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
1838 LyXCursor cursor = owner->view()->text->cursor;
1841 if (!owner->view()->text->selection) {
1843 && !(cursor.par->added_space_top
1844 == VSpace (VSpace::NONE))) {
1845 owner->view()->text->SetParagraph
1846 (cursor.par->line_top,
1847 cursor.par->line_bottom,
1848 cursor.par->pagebreak_top,
1849 cursor.par->pagebreak_bottom,
1850 VSpace(VSpace::NONE), cursor.par->added_space_bottom,
1852 cursor.par->labelwidthstring, 0);
1853 owner->view()->update (1);
1855 owner->view()->text->Backspace();
1856 owner->view()->text->sel_cursor
1866 case LFUN_BREAKPARAGRAPH:
1869 owner->view()->text->BreakParagraph(0);
1871 SetUpdateTimer(0.01);
1872 owner->view()->text->sel_cursor =
1873 owner->view()->text->cursor;
1877 case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
1880 owner->view()->text->BreakParagraph(1);
1882 SetUpdateTimer(0.01);
1883 owner->view()->text->sel_cursor =
1884 owner->view()->text->cursor;
1888 case LFUN_BREAKPARAGRAPH_SKIP:
1890 // When at the beginning of a paragraph, remove
1891 // indentation and add a "defskip" at the top.
1892 // Otherwise, do the same as LFUN_BREAKPARAGRAPH.
1894 LyXCursor cursor = owner->view()->text->cursor;
1897 if (cursor.pos == 0) {
1898 if (cursor.par->added_space_top == VSpace(VSpace::NONE)) {
1899 owner->view()->text->SetParagraph
1900 (cursor.par->line_top,
1901 cursor.par->line_bottom,
1902 cursor.par->pagebreak_top,
1903 cursor.par->pagebreak_bottom,
1904 VSpace(VSpace::DEFSKIP), cursor.par->added_space_bottom,
1906 cursor.par->labelwidthstring, 1);
1907 owner->view()->update(1);
1911 owner->view()->text->BreakParagraph(0);
1914 SetUpdateTimer(0.01);
1915 owner->view()->text->sel_cursor = cursor;
1921 owner->view()->text->InsertChar('\"'); // This " matches the single quote in the code
1924 moveCursorUpdate(false);
1930 InsetCommand * new_inset;
1931 if (action == LFUN_HTMLURL)
1932 new_inset = new InsetUrl("htmlurl", "", "");
1934 new_inset = new InsetUrl("url", "", "");
1935 owner->buffer()->insertInset(new_inset);
1936 new_inset->Edit(0, 0);
1940 // --- lyxserver commands ----------------------------
1942 case LFUN_CHARATCURSOR:
1944 LyXParagraph::size_type pos =
1945 owner->view()->text->cursor.pos;
1946 if(pos < owner->view()->text->cursor.par->size())
1947 dispatch_buffer = owner->view()->text->
1948 cursor.par->text[pos];
1950 dispatch_buffer = "EOF";
1956 tostr(owner->view()->text->cursor.x) + ' '
1957 + tostr(owner->view()->text->cursor.y);
1964 sscanf(argument.c_str(), " %d %ld", &x, &y);
1965 owner->view()->text->SetCursorFromCoordinates(x, y);
1969 case LFUN_GETLAYOUT:
1971 tostr(owner->view()->text->cursor.par->layout);
1976 LyXFont *font = &(owner->view()->text->current_font);
1977 if(font->shape() == LyXFont::ITALIC_SHAPE)
1978 dispatch_buffer = 'E';
1979 else if(font->shape() == LyXFont::SMALLCAPS_SHAPE)
1980 dispatch_buffer = 'N';
1982 dispatch_buffer = '0';
1989 LyXFont *font = &(owner->view()->text->current_font);
1990 if(font->latex() == LyXFont::ON)
1991 dispatch_buffer = 'L';
1993 dispatch_buffer = '0';
1998 setMessage(owner->buffer()->fileName());
1999 lyxerr.debug() << "FNAME["
2000 << owner->buffer()->fileName()
2007 keyseq.print(buf, 100);
2008 dispatch_buffer = buf;
2009 lyxserver->notifyClient(dispatch_buffer);
2013 case LFUN_GOTOFILEROW:
2015 char file_name[100];
2017 sscanf(argument.c_str(), " %s %d", file_name, &row);
2019 // Must replace extension of the file to be .lyx and get full path
2020 string s = ChangeExtension(string(file_name), ".lyx", false);
2022 // Either change buffer or load the file
2023 if (bufferlist.exists(s))
2024 owner->view()->buffer(bufferlist.getBuffer(s));
2026 owner->view()->buffer(bufferlist.loadLyXFile(s));
2029 owner->buffer()->setCursorFromRow(row);
2033 if (owner->view()->text->cursor.y >
2034 owner->view()->getWorkArea()->h / 2) {
2035 owner->view()->getScreen()->
2036 Draw(owner->view()->text->cursor.y -
2037 owner->view()->getWorkArea()->h/2);
2039 owner->view()->getScreen()->
2042 owner->view()->update(0);
2043 owner->view()->redraw();
2050 int qa = lyxaction.LookupFunc(argument.c_str());
2051 setMessage(lyxaction.helpText(static_cast<kb_action>(qa)));
2055 // --- accented characters ---------------------------
2058 case LFUN_CIRCUMFLEX:
2068 case LFUN_SPECIAL_CARON:
2071 case LFUN_HUNG_UMLAUT:
2077 if (keyseq.length == -1 && keyseq.getiso()!= 0)
2082 owner->getIntl()->getTrans()->
2083 deadkey(c, get_accent(action).accent,
2084 owner->view()->text);
2086 // Need to reset, in case the minibuffer calls these
2091 // copied verbatim from do_accent_char
2094 owner->view()->text->sel_cursor =
2095 owner->view()->text->cursor;
2099 // --- toolbar ----------------------------------
2100 case LFUN_PUSH_TOOLBAR:
2102 int nth = strToInt(argument);
2103 if (lyxerr.debugging(Debug::TOOLBAR)) {
2104 lyxerr << "LFUN_PUSH_TOOLBAR: argument = `"
2105 << argument << "'\n"
2106 << "LFUN_PUSH_TOOLBAR: nth = `"
2107 << nth << "'" << endl;
2112 setErrorMessage(N_("Push-toolbar needs argument > 0"));
2114 owner->getToolbar()->push(nth);
2119 case LFUN_ADD_TO_TOOLBAR:
2121 if (lyxerr.debugging(Debug::TOOLBAR)) {
2122 lyxerr << "LFUN_ADD_TO_TOOLBAR:"
2123 "argument = `" << argument << '\'' << endl;
2125 string tmp(argument);
2126 //lyxerr <<string("Argument: ") + argument);
2127 //lyxerr <<string("Tmp : ") + tmp);
2130 setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
2132 owner->getToolbar()->add(argument, false);
2133 owner->getToolbar()->set();
2138 // --- insert characters ----------------------------------------
2140 case LFUN_INSERT_INSET_LATEX:
2142 Inset *new_inset = new InsetLatex(argument);
2143 owner->buffer()->insertInset(new_inset);
2147 // --- Mathed stuff. If we are here, there is no locked inset yet.
2152 if (!greek_kb_flag) {
2154 setMessage(N_("Math greek mode on"));
2161 case LFUN_GREEK_TOGGLE:
2163 greek_kb_flag = (greek_kb_flag) ? 0: 2;
2164 if (greek_kb_flag) {
2165 setMessage(N_("Math greek keyboard on"));
2167 setMessage(N_("Math greek keyboard off"));
2172 case LFUN_MATH_DELIM:
2173 case LFUN_INSERT_MATRIX:
2175 if (owner->view()->available()) {
2177 open_new_inset(new InsetFormula(false));
2179 the_locking_inset->LocalDispatch(action, argument.c_str());
2184 case LFUN_INSERT_MATH:
2186 math_insert_symbol(argument.c_str());
2190 case LFUN_MATH_DISPLAY:
2192 if (owner->view()->available())
2193 owner->buffer()->open_new_inset(new InsetFormula(true));
2197 case LFUN_MATH_MACRO:
2199 if (owner->view()->available()) {
2202 setErrorMessage(N_("Missing argument"));
2204 string s1 = token(s, ' ', 1);
2205 int na = s1.empty() ? 0: atoi(s1.c_str());
2207 open_new_inset(new InsetFormulaMacro(token(s, ' ', 0), na));
2213 case LFUN_MATH_MODE: // Open or create a math inset
2216 if (owner->view()->available())
2217 owner->buffer()->open_new_inset(new InsetFormula);
2218 setMessage(N_("Math editor mode"));
2222 case LFUN_MATH_NUMBER:
2223 case LFUN_MATH_LIMITS:
2225 setErrorMessage(N_("This is only allowed in math mode!"));
2229 case LFUN_INSERT_CITATION:
2231 InsetCitation * new_inset = new InsetCitation();
2233 // The note, if any, must be after the key, delimited
2234 // by a | so both key and remark can have spaces.
2235 if (!argument.empty()) {
2236 string lsarg(argument);
2237 if (contains(lsarg, "|")) {
2238 new_inset->setContents(token(lsarg, '|', 0));
2239 new_inset->setOptions(token(lsarg, '|', 1));
2241 new_inset->setContents(lsarg);
2242 owner->buffer()->insertInset(new_inset);
2244 owner->buffer()->insertInset(new_inset);
2245 new_inset->Edit(0, 0);
2250 case LFUN_INSERT_BIBTEX:
2252 // ale970405+lasgoutt970425
2253 // The argument can be up to two tokens separated
2254 // by a space. The first one is the bibstyle.
2255 string lsarg(argument);
2256 string bibstyle = token(lsarg, ' ', 1);
2257 if (bibstyle.empty())
2259 InsetBibtex * new_inset
2260 = new InsetBibtex(token(lsarg, ' ', 0),
2264 owner->buffer()->insertInset(new_inset);
2265 if (lsarg.empty()) {
2266 new_inset->Edit(0, 0);
2271 // BibTeX data bases
2272 case LFUN_BIBDB_ADD:
2274 InsetBibtex * inset =
2275 static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
2277 inset->addDatabase(argument);
2282 case LFUN_BIBDB_DEL:
2284 InsetBibtex * inset =
2285 static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
2287 inset->delDatabase(argument);
2292 case LFUN_BIBTEX_STYLE:
2294 InsetBibtex * inset =
2295 static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
2297 inset->setOptions(argument);
2302 case LFUN_INDEX_INSERT:
2303 case LFUN_INDEX_INSERT_LAST:
2305 // Can't do that at the beginning of a paragraph.
2306 if (owner->view()->text->cursor.pos - 1 <0)
2309 InsetIndex * new_inset = new InsetIndex();
2310 if (!argument.empty()) {
2311 string lsarg(argument);
2312 new_inset->setContents(lsarg);
2313 owner->buffer()->insertInset(new_inset);
2316 //get the current word for an argument
2317 LyXParagraph::size_type lastpos =
2318 owner->view()->text->cursor.pos - 1;
2319 // Get the current word. note that this must be done
2320 // before inserting the inset, or the inset will
2322 string curstring(owner->view()
2323 ->text->cursor.par->GetWord(lastpos));
2325 //make the new inset and write the current word into it
2326 InsetIndex * new_inset = new InsetIndex();
2328 new_inset->setContents(curstring);
2330 //don't edit it if the call was to INSERT_LAST
2331 if(action!= LFUN_INDEX_INSERT_LAST) {
2332 new_inset->Edit(0, 0);
2334 //it looks blank on the screen unless
2335 //we do something. put it here.
2337 // move the cursor to the returned value of lastpos
2338 // but only for the auto-insert
2339 owner->view()->text->cursor.pos= lastpos;
2342 //put the new inset into the buffer.
2343 // there should be some way of knowing the user
2344 //cancelled & avoiding this, but i don't know how
2345 owner->buffer()->insertInset(new_inset);
2350 case LFUN_INDEX_PRINT:
2352 Inset * new_inset = new InsetPrintIndex(owner->buffer());
2353 owner->buffer()->insertInset(new_inset, "Standard", true);
2357 case LFUN_PARENTINSERT:
2359 lyxerr << "arg " << argument << endl;
2360 Inset * new_inset = new InsetParent(argument, owner->buffer());
2361 owner->buffer()->insertInset(new_inset, "Standard", true);
2365 case LFUN_CHILDINSERT:
2367 Inset * new_inset = new InsetInclude(argument,
2369 owner->buffer()->insertInset(new_inset, "Standard", true);
2370 new_inset->Edit(0, 0);
2374 case LFUN_CHILDOPEN:
2377 MakeAbsPath(argument,
2378 OnlyPath(owner->buffer()->fileName()));
2379 setMessage(N_("Opening child document ") +
2380 MakeDisplayPath(filename) + "...");
2381 owner->view()->savePosition();
2382 if (bufferlist.exists(filename))
2383 owner->view()->buffer(bufferlist.getBuffer(filename));
2385 owner->view()->buffer(bufferlist.loadLyXFile(filename));
2389 case LFUN_INSERT_NOTE:
2393 case LFUN_INSERTFOOTNOTE:
2395 LyXParagraph::footnote_kind kind;
2396 if (argument == "footnote")
2397 { kind = LyXParagraph::FOOTNOTE; }
2398 else if (argument == "margin")
2399 { kind = LyXParagraph::MARGIN; }
2400 else if (argument == "figure")
2401 { kind = LyXParagraph::FIG; }
2402 else if (argument == "table")
2403 { kind = LyXParagraph::TAB; }
2404 else if (argument == "wide-fig")
2405 { kind = LyXParagraph::WIDE_FIG; }
2406 else if (argument == "wide-tab")
2407 { kind = LyXParagraph::WIDE_TAB; }
2408 else if (argument == "algorithm")
2409 { kind = LyXParagraph::ALGORITHM; }
2411 setErrorMessage(N_("Unknown kind of footnote"));
2414 owner->view()->text->InsertFootnoteEnvironment(kind);
2415 owner->view()->update(1);
2419 case LFUN_BUFFERBULLETSSELECT:
2423 case LFUN_TOGGLECURSORFOLLOW:
2424 cursor_follows_scrollbar = !cursor_follows_scrollbar;
2427 case LFUN_KMAP_OFF: // keymap off
2428 owner->getIntl()->KeyMapOn(false);
2431 case LFUN_KMAP_PRIM: // primary keymap
2432 owner->getIntl()->KeyMapPrim();
2435 case LFUN_KMAP_SEC: // secondary keymap
2436 owner->getIntl()->KeyMapSec();
2439 case LFUN_KMAP_TOGGLE: // toggle keymap
2440 owner->getIntl()->ToggleKeyMap();
2443 case LFUN_SELFINSERT:
2445 for (string::size_type i = 0; i < argument.length(); ++i) {
2446 owner->view()->text->InsertChar(argument[i]);
2447 // This needs to be in the loop, or else we
2448 // won't break lines correctly. (Asger)
2452 owner->view()->text->sel_cursor =
2453 owner->view()->text->cursor;
2454 moveCursorUpdate(false);
2460 // argument contains ';'-terminated commands
2461 while (argument.find(';') != string::npos) {
2463 argument = split(argument, first, ';');
2469 case LFUN_SAVEPREFERENCES:
2471 Path p(user_lyxdir);
2472 lyxrc->write("preferences");
2476 case LFUN_UNKNOWN_ACTION:
2478 if (owner->buffer()->isReadonly()) {
2480 setErrorMessage(N_("Document is read only"));
2484 if (!argument.empty()) {
2486 /* Automatically delete the currently selected
2487 * text and replace it with what is being
2488 * typed in now. Depends on lyxrc settings
2489 * "auto_region_delete", which defaults to
2492 if ( lyxrc->auto_region_delete ) {
2493 if (owner->view()->text->selection){
2494 owner->view()->text->CutSelection(false);
2495 owner->view()->update(-1);
2500 for (string::size_type i = 0;
2501 i < argument.length(); ++i) {
2502 if (greek_kb_flag) {
2503 if (!math_insert_greek(argument[i]))
2504 owner->getIntl()->getTrans()->TranslateAndInsert(argument[i], owner->view()->text);
2506 owner->getIntl()->getTrans()->TranslateAndInsert(argument[i], owner->view()->text);
2512 owner->view()->text->sel_cursor =
2513 owner->view()->text->cursor;
2514 moveCursorUpdate(false);
2517 // why is an "Unknown action" with empty
2518 // argument even dispatched in the first
2519 // place? I`ll probably change that. (Lgb)
2521 setErrorMessage(N_("Unknown action"));
2525 lyxerr << "A truly unknown func!" << endl;
2531 string res = getMessage();
2534 if (!commandshortcut.empty()) {
2535 string newbuf = owner->getMiniBuffer()->GetText();
2536 if (newbuf != commandshortcut) {
2537 owner->getMiniBuffer()->Set(newbuf
2543 owner->getMiniBuffer()->Set(string(_(res.c_str()))
2544 + " " + commandshortcut);
2550 string LyXFunc::Dispatch(int ac,
2551 char const * do_not_use_this_arg)
2556 FL_OBJECT * ob = 0; // This will disapear soon
2558 // we have not done anything wrong yet.
2560 dispatch_buffer.clear();
2562 // if action is a pseudo-action, we need the real action
2563 if (lyxaction.isPseudoAction(ac)) {
2565 action = static_cast<kb_action>
2566 (lyxaction.retrieveActionArg(ac, tmparg));
2567 if (!tmparg.empty())
2570 action = static_cast<kb_action>(ac);
2571 if (do_not_use_this_arg)
2572 argument = do_not_use_this_arg; // except here
2575 selection_possible = false;
2577 if (owner->view()->available()
2578 && owner->view()->getScreen())
2579 owner->view()->getScreen()->HideCursor();
2581 // We cannot use this function here
2582 if (getStatus(action) & Disabled)
2583 goto exit_with_message;
2585 commandshortcut.clear();
2587 if (lyxrc->display_shortcuts && show_sc) {
2588 if (action != LFUN_SELFINSERT) {
2589 // Put name of command and list of shortcuts
2590 // for it in minibuffer
2591 string comname = lyxaction.getActionName(action);
2593 int pseudoaction = action;
2594 bool argsadded = false;
2596 if (!argument.empty()) {
2597 // If we have the command with argument,
2600 lyxaction.searchActionArg(action,
2603 if (pseudoaction == -1) {
2604 pseudoaction = action;
2606 comname += " " + argument;
2611 string shortcuts = toplevel_keymap->findbinding(pseudoaction);
2613 if (!shortcuts.empty()) {
2614 comname += ": " + shortcuts;
2615 } else if (!argsadded) {
2616 comname += " " + argument;
2619 if (!comname.empty()) {
2620 comname = strip(comname);
2621 commandshortcut = "(" + comname + ')';
2622 owner->getMiniBuffer()->Set(commandshortcut);
2623 // Here we could even add a small pause,
2624 // to annoy the user and make him learn
2626 // No! That will just annoy, not teach
2627 // anything. The user will read the messages
2628 // if they are interested. (Asger)
2633 // If in math mode pass the control to
2634 // the math inset [asierra060396]
2635 if (owner->view()->available() &&
2636 owner->buffer()->the_locking_inset) {
2638 || (action == LFUN_UNKNOWN_ACTION && keyseq.length>= -1)) {
2639 if (action == LFUN_UNKNOWN_ACTION && argument.empty()) {
2640 argument = keyseq.getiso();
2642 // Undo/Redo pre 0.13 is a bit tricky for insets.
2643 if (action == LFUN_UNDO) {
2645 UpdatableInset * inset =
2646 owner->buffer()->the_locking_inset;
2647 inset->GetCursorPos(slx, sly);
2650 inset = static_cast<UpdatableInset*>(owner->buffer()->text->cursor.par->GetInset(owner->buffer()->text->cursor.pos));
2652 inset->Edit(slx, sly);
2655 if (action == LFUN_REDO) {
2657 UpdatableInset * inset = owner->buffer()->the_locking_inset;
2658 inset->GetCursorPos(slx, sly);
2661 inset = static_cast<UpdatableInset*>(owner->buffer()->text->cursor.par->GetInset(owner->buffer()->text->cursor.pos));
2663 inset->Edit(slx, sly);
2666 if (owner->buffer()->the_locking_inset->LocalDispatch(action, argument.c_str()))
2669 setMessage(N_("Text mode"));
2670 if (action == LFUN_RIGHT || action == -1)
2671 owner->buffer()->text->CursorRight();
2672 if (action == LFUN_LEFT || action == LFUN_RIGHT)
2679 // --- Misc -------------------------------------------
2680 case LFUN_WORDFINDFORWARD :
2681 case LFUN_WORDFINDBACKWARD : {
2682 static string last_search;
2683 string searched_string;
2685 if (!argument.empty()) {
2686 last_search = argument;
2687 searched_string = argument;
2689 searched_string = last_search;
2692 LyXText * ltCur = owner->view()->buffer()->text ;
2694 if (!searched_string.empty() &&
2695 ((action == LFUN_WORDFINDBACKWARD) ?
2696 ltCur->SearchBackward(searched_string.c_str()) :
2697 ltCur->SearchForward(searched_string.c_str()))) {
2699 // ??? What is that ???
2700 owner->view()->buffer()->update(-2);
2703 // clear the selection (if there is any)
2704 owner->view()->getScreen()->ToggleSelection();
2705 owner->view()->buffer()->text->ClearSelection();
2707 // Move cursor so that successive C-s 's will not stand in place.
2708 if( action == LFUN_WORDFINDFORWARD )
2709 owner->buffer()->text->CursorRightOneWord();
2710 owner->buffer()->text->FinishUndo();
2711 moveCursorUpdate(false);
2714 // set the new selection
2715 // SetSelectionOverLenChars(owner->view()->currentBuffer()->text, iLenSelected);
2716 owner->view()->getScreen()->ToggleSelection(false);
2720 // REMOVED : if (owner->view()->getWorkArea()->focus)
2721 owner->view()->getScreen()->ShowCursor();
2727 if (owner->view()->available()
2728 && owner->view()->getScreen()) {
2729 owner->buffer()->update(-2);
2732 keyseq.print(buf, 100, true);
2733 owner->getMiniBuffer()->Set(buf, string(), string(), 1);
2737 // --- Misc -------------------------------------------
2738 case LFUN_EXEC_COMMAND:
2739 owner->getMiniBuffer()->ExecCommand();
2742 case LFUN_CANCEL: // RVDK_PATCH_5
2745 if(owner->view()->available())
2746 // cancel any selection
2747 Dispatch(LFUN_MARK_OFF, 0);
2748 setMessage(N_("Cancel"));
2751 case LFUN_META_FAKE: // RVDK_PATCH_5
2753 meta_fake_bit = Mod1Mask;
2755 keyseq.print(buf, 98, true);
2756 string res = string("M-") + buf;
2757 setMessage(buf); // RVDK_PATCH_5
2761 case LFUN_READ_ONLY_TOGGLE:
2762 if (owner->buffer()->lyxvc.inUse()) {
2763 owner->buffer()->lyxvc.toggleReadOnly();
2765 owner->buffer()->setReadonly(
2766 !owner->buffer()->isReadonly());
2770 case LFUN_CENTER: // this is center and redraw.
2772 if (owner->buffer()->text->cursor.y >
2773 owner->view()->getWorkArea()->h / 2) {
2774 owner->view()->getScreen()->
2775 Draw(owner->buffer()->text->cursor.y -
2776 owner->view()->getWorkArea()->h/2);
2778 owner->view()->getScreen()->
2781 owner->buffer()->update(0);
2782 owner->view()->redraw();
2786 if (owner->view()->available()) {
2787 owner->buffer()->text->toggleAppendix();
2788 owner->buffer()->update(1);
2792 // --- Menus -----------------------------------------------
2797 case LFUN_MENUNEWTMPLT:
2805 case LFUN_CLOSEBUFFER:
2809 case LFUN_MENUWRITE:
2810 MenuWrite(owner->buffer());
2813 case LFUN_MENUWRITEAS:
2814 MenuWriteAs(owner->buffer());
2817 case LFUN_MENURELOAD:
2822 MenuPreview(owner->buffer());
2825 case LFUN_PREVIEWPS:
2826 MenuPreviewPS(owner->buffer());
2830 MenuRunLaTeX(owner->buffer());
2833 case LFUN_BUILDPROG:
2834 MenuBuildProg(owner->buffer());
2837 case LFUN_RUNCHKTEX:
2838 MenuRunChktex(owner->buffer());
2842 MenuRunDvips(owner->buffer(), false);
2845 case LFUN_MENUPRINT:
2846 MenuPrint(owner->buffer());
2850 MenuFax(owner->buffer());
2855 //needs argument as string
2856 string extyp = argument;
2859 if (extyp == "latex") {
2860 // make sure that this buffer is not linuxdoc
2861 MenuMakeLaTeX(owner->buffer());
2864 else if (extyp == "linuxdoc") {
2865 // make sure that this buffer is not latex
2866 MenuMakeLinuxDoc(owner->buffer());
2869 else if (extyp == "docbook") {
2870 // make sure that this buffer is not latex or linuxdoc
2871 MenuMakeDocBook(owner->buffer());
2874 else if (extyp == "dvi") {
2875 // Run LaTeX as "Update dvi..." Bernhard.
2876 // We want the dvi in the current directory. This
2877 // is achieved by temporarily disabling use of
2878 // temp directory. As a side-effect, we get
2879 // *.log and *.aux files also. (Asger)
2880 bool flag = lyxrc->use_tempdir;
2881 lyxrc->use_tempdir = false;
2882 MenuRunLaTeX(owner->buffer());
2883 lyxrc->use_tempdir = flag;
2886 else if (extyp == "postscript") {
2887 // Start Print-dialog. Not as good as dvi... Bernhard.
2888 MenuPrint(owner->buffer());
2889 // Since the MenuPrint is a pop-up, we can't use
2890 // the same trick as above. (Asger)
2891 // MISSING: Move of ps-file :-(
2894 else if (extyp == "ascii") {
2895 MenuMakeAscii(owner->buffer());
2897 else if (extyp == "custom") {
2902 else if (extyp == "html" && lyxrc->html_command != "none") {
2903 // First, create LaTeX file
2904 MenuMakeLaTeX(owner->buffer());
2906 // And now, run the converter
2907 string file = owner->buffer()->getFileName();
2908 Path path(OnlyPath(file));
2909 // the tex file name has to be correct for
2910 // latex, but the html file name can be
2912 string result = ChangeExtension(file, ".html", false);
2913 string infile = owner->buffer()->getLatexName();
2914 string tmp = lyxrc->html_command;
2915 tmp = subst(tmp, "$$FName", infile);
2916 tmp = subst(tmp, "$$OutName", result);
2918 int res = one.startscript(Systemcalls::System, tmp);
2920 setMessage(N_("Document exported as HTML to file `")
2921 + MakeDisplayPath(result) +'\'');
2923 setErrorMessage(N_("Unable to convert to HTML the file `")
2924 + MakeDisplayPath(infile)
2929 setErrorMessage(N_("Unknown export type: ")
2937 //needs argument as string
2938 string imtyp = argument;
2941 if (imtyp == "latex") {
2942 doImportLaTeX(false);
2945 else if (imtyp == "ascii") {
2946 doImportASCII(false);
2947 } else if (imtyp == "asciiparagraph") {
2948 doImportASCII(true);
2950 } else if (imtyp == "noweb") {
2951 doImportLaTeX(true);
2953 setErrorMessage(string(N_("Unknown import type: "))
2965 if (fd_form_toc->form_toc->visible) {
2966 fl_raise_form(fd_form_toc->form_toc);
2968 static int ow = -1, oh;
2969 fl_show_form(fd_form_toc->form_toc,
2971 FL_FREE_SIZE, FL_FULLBORDER,
2972 _("Table of Contents"));
2974 ow = fd_form_toc->form_toc->w;
2975 oh = fd_form_toc->form_toc->h;
2977 fl_set_form_minsize(fd_form_toc->form_toc, ow, oh);
2981 case LFUN_TOC_INSERT:
2983 Inset * new_inset = new InsetTOC(owner->buffer());
2984 owner->buffer()->insertInset(new_inset, "Standard", true);
2988 case LFUN_LOF_INSERT:
2990 Inset * new_inset = new InsetLOF(owner->buffer());
2991 owner->buffer()->insertInset(new_inset, "Standard", true);
2995 case LFUN_LOA_INSERT:
2997 Inset * new_inset = new InsetLOA(owner->buffer());
2998 owner->buffer()->insertInset(new_inset, "Standard", true);
3002 case LFUN_LOT_INSERT:
3004 Inset * new_inset = new InsetLOT(owner->buffer());
3005 owner->buffer()->insertInset(new_inset, "Standard", true);
3029 case LFUN_MENUSEARCH:
3037 case LFUN_PASTESELECTION:
3039 bool asPara = false;
3040 if (argument == "paragraph") asPara = true;
3041 MenuPasteSelection(asPara);
3053 case LFUN_LAYOUT_COPY:
3054 CopyEnvironmentCB();
3057 case LFUN_LAYOUT_PASTE:
3058 PasteEnvironmentCB();
3061 case LFUN_GOTOERROR:
3062 owner->view()->gotoError();
3065 case LFUN_REMOVEERRORS:
3066 if (owner->buffer()->removeAutoInsets()) {
3067 owner->view()->redraw();
3068 owner->view()->fitCursor();
3069 owner->view()->updateScrollbar();
3077 case LFUN_OPENSTUFF:
3081 case LFUN_HYPHENATION:
3089 case LFUN_END_OF_SENTENCE:
3093 case LFUN_MENU_SEPARATOR:
3105 case LFUN_DEPTH_MIN:
3109 case LFUN_DEPTH_PLUS:
3125 case LFUN_RECONFIGURE:
3130 if (owner->view()->available()
3131 && !owner->buffer()->text->selection
3132 && owner->buffer()->text->cursor.par->footnoteflag
3133 != LyXParagraph::NO_FOOTNOTE)
3134 { // only melt footnotes with FOOTMELT, not margins etc
3135 if(owner->buffer()->text->cursor.par->footnotekind == LyXParagraph::FOOTNOTE)
3142 case LFUN_MARGINMELT:
3143 if (owner->view()->available()
3144 && !owner->buffer()->text->selection
3145 && owner->buffer()->text->cursor.par->footnoteflag
3146 != LyXParagraph::NO_FOOTNOTE) {
3147 // only melt margins
3148 if(owner->buffer()->text->cursor.par->footnotekind == LyXParagraph::MARGIN)
3155 // --- version control -------------------------------
3156 case LFUN_VC_REGISTER:
3158 if (!owner->buffer()->lyxvc.inUse())
3159 owner->buffer()->lyxvc.registrer();
3163 case LFUN_VC_CHECKIN:
3165 if (owner->buffer()->lyxvc.inUse()
3166 && !owner->buffer()->isReadonly())
3167 owner->buffer()->lyxvc.checkIn();
3171 case LFUN_VC_CHECKOUT:
3173 if (owner->buffer()->lyxvc.inUse()
3174 && owner->buffer()->isReadonly())
3175 owner->buffer()->lyxvc.checkOut();
3179 case LFUN_VC_REVERT:
3181 owner->buffer()->lyxvc.revert();
3187 owner->buffer()->lyxvc.undoLast();
3191 case LFUN_VC_HISTORY:
3193 owner->buffer()->lyxvc.showLog();
3197 // --- buffers ----------------------------------------
3198 case LFUN_PREVBUFFER:
3199 #ifdef WITH_WARNINGS
3200 #warning fix this please
3202 // it is the LyXView or the BufferView that should
3203 // remember the previous buffer, not bufferlist.
3204 // if (owner->view()->available()){
3206 // owner->buffer()->update(-2);
3208 // owner->view()->setBuffer(bufferlist.prev());
3211 // resizeCurrentBufferPseudoExpose();
3214 case LFUN_FILE_INSERT:
3216 MenuInsertLyXFile(argument);
3220 case LFUN_FILE_INSERT_ASCII:
3222 bool asPara = (argument == "paragraph");
3223 InsertAsciiFile(string(), asPara);
3229 // servercmd: argument must be <file>:<template>
3230 Buffer * tmpbuf = NewLyxFile(argument);
3232 owner->view()->buffer(tmpbuf);
3236 case LFUN_FILE_OPEN:
3237 owner->view()->buffer(
3238 bufferlist.loadLyXFile(argument));
3241 case LFUN_LATEX_LOG:
3247 lyxerr.debug() << "LFUN_LAYOUTNO: (arg) " << argument << endl;
3248 int sel = strToInt(argument);
3249 lyxerr.debug() << "LFUN_LAYOUTNO: (sel) "<< sel << endl;
3251 // Should this give a setMessage instead?
3253 return string(); // illegal argument
3255 sel--; // sel 1..., but layout 0...
3257 // Pretend we got the name instead.
3258 Dispatch(int(LFUN_LAYOUT),
3259 textclasslist.NameOfLayout(owner->buffer()->
3268 lyxerr.debug() << "LFUN_LAYOUT: (arg) "
3269 << argument << endl;
3271 // Derive layout number from given argument (string)
3272 // and current buffer's textclass (number). */
3274 textclasslist.NumberOfLayout(owner->
3280 // see if we found the layout number:
3281 if (layoutno == -1) {
3282 setErrorMessage(string(N_("Layout ")) + argument +
3287 if (current_layout != layoutno) {
3288 owner->view()->getScreen()->HideCursor();
3289 current_layout = layoutno;
3290 owner->buffer()->update(-2);
3291 owner->buffer()->text->
3292 SetLayout(layoutno);
3293 owner->getToolbar()->combox->
3294 select(owner->buffer()->
3297 owner->buffer()->update(1);
3302 case LFUN_LAYOUT_DOCUMENT:
3303 MenuLayoutDocument();
3306 case LFUN_LAYOUT_PARAGRAPH:
3307 MenuLayoutParagraph();
3310 case LFUN_LAYOUT_CHARACTER:
3311 MenuLayoutCharacter();
3314 case LFUN_LAYOUT_TABLE:
3317 if (argument == "true") flag = 1;
3318 MenuLayoutTable(flag);
3322 case LFUN_LAYOUT_PAPER:
3326 case LFUN_LAYOUT_QUOTES:
3330 case LFUN_LAYOUT_PREAMBLE:
3331 MenuLayoutPreamble();
3334 case LFUN_LAYOUT_SAVE_DEFAULT:
3338 case LFUN_DROP_LAYOUTS_CHOICE:
3339 owner->getToolbar()->combox->Show();
3370 case LFUN_UNDERLINE:
3374 case LFUN_FONT_SIZE:
3375 FontSizeCB(argument);
3378 case LFUN_FONT_STATE:
3379 setMessage(CurrentState());
3382 case LFUN_UPCASE_WORD:
3383 owner->buffer()->update(-2);
3385 owner->buffer()->text->ChangeWordCase(LyXText::text_uppercase);
3386 owner->buffer()->update(1);
3390 case LFUN_LOWCASE_WORD:
3391 owner->buffer()->update(-2);
3393 owner->buffer()->text->ChangeWordCase(LyXText::text_lowercase);
3394 owner->buffer()->update(1);
3398 case LFUN_CAPITALIZE_WORD:
3399 owner->buffer()->update(-2);
3401 owner->buffer()->text->ChangeWordCase(LyXText::text_capitalization);
3402 owner->buffer()->update(1);
3406 case LFUN_INSERT_LABEL:
3407 MenuInsertLabel(argument.c_str());
3410 case LFUN_INSERT_REF:
3414 case LFUN_REFTOGGLE:
3417 static_cast<InsetRef*>(getInsetByCode(Inset::REF_CODE));
3419 if (inset->getFlag() == InsetRef::REF)
3420 inset->setFlag(InsetRef::PAGE_REF);
3422 inset->setFlag(InsetRef::REF);
3425 setErrorMessage(N_("No cross-reference to toggle"));
3432 owner->view()->restorePosition();
3438 string label(argument);
3439 if (label.empty()) {
3441 static_cast<InsetRef*>(getInsetByCode(Inset::REF_CODE));
3443 label = inset->getContents();
3446 if (!label.empty()) {
3447 owner->view()->savePosition();
3448 owner->buffer()->gotoLabel(label.c_str());
3453 case LFUN_MENU_OPEN_BY_NAME:
3454 owner->getMenus()->openByName(argument);
3455 break; // RVDK_PATCH_5
3457 case LFUN_SPELLCHECK:
3458 if (lyxrc->isp_command != "none")
3460 break; // RVDK_PATCH_5
3462 // --- Cursor Movements -----------------------------
3465 Buffer * tmpbuffer = owner->buffer();
3466 LyXText * tmptext = owner->buffer()->text;
3467 if(!tmptext->mark_set)
3469 tmpbuffer->update(-2);
3470 if (tmptext->cursor.pos < tmptext->cursor.par->Last()
3471 && tmptext->cursor.par->GetChar(tmptext->cursor.pos)
3472 == LyXParagraph::META_INSET
3473 && tmptext->cursor.par->GetInset(tmptext->cursor.pos)
3474 && tmptext->cursor.par->GetInset(tmptext->cursor.pos)->Editable() == 2){
3475 Inset * tmpinset = tmptext->cursor.par->GetInset(tmptext->cursor.pos);
3476 setMessage(tmpinset->EditMessage());
3477 tmpinset->Edit(0, 0);
3480 tmptext->CursorRight();
3481 owner->buffer()->text->FinishUndo();
3482 moveCursorUpdate(false);
3483 owner->getMiniBuffer()->Set(CurrentState());
3489 // This is soooo ugly. Isn`t it possible to make
3490 // it simpler? (Lgb)
3491 LyXText * txt = owner->buffer()->text;
3492 if(!txt->mark_set) BeforeChange();
3493 owner->buffer()->update(-2);
3495 if (txt->cursor.pos < txt->cursor.par->Last()
3496 && txt->cursor.par->GetChar(txt->cursor.pos)
3497 == LyXParagraph::META_INSET
3498 && txt->cursor.par->GetInset(txt->cursor.pos)
3499 && txt->cursor.par->GetInset(txt->cursor.pos)->Editable() == 2) {
3500 Inset * tmpinset = txt->cursor.par->GetInset(txt->cursor.pos);
3501 setMessage(tmpinset->EditMessage());
3502 tmpinset->Edit(tmpinset->Width(txt->GetFont(txt->cursor.par,
3503 txt->cursor.pos)), 0);
3506 owner->buffer()->text->FinishUndo();
3507 moveCursorUpdate(false);
3508 owner->getMiniBuffer()->Set(CurrentState());
3513 if(!owner->buffer()->text->mark_set) BeforeChange();
3514 owner->buffer()->update(-3);
3515 owner->buffer()->text->CursorUp();
3516 owner->buffer()->text->FinishUndo();
3517 moveCursorUpdate(false);
3518 owner->getMiniBuffer()->Set(CurrentState());
3522 if(!owner->buffer()->text->mark_set)
3524 owner->buffer()->update(-3);
3525 owner->buffer()->text->CursorDown();
3526 owner->buffer()->text->FinishUndo();
3527 moveCursorUpdate(false);
3528 owner->getMiniBuffer()->Set(CurrentState());
3531 case LFUN_UP_PARAGRAPH:
3532 if(!owner->buffer()->text->mark_set)
3534 owner->buffer()->update(-3);
3535 owner->buffer()->text->CursorUpParagraph();
3536 owner->buffer()->text->FinishUndo();
3537 moveCursorUpdate(false);
3538 owner->getMiniBuffer()->Set(CurrentState());
3541 case LFUN_DOWN_PARAGRAPH:
3542 if(!owner->buffer()->text->mark_set)
3544 owner->buffer()->update(-3);
3545 owner->buffer()->text->CursorDownParagraph();
3546 owner->buffer()->text->FinishUndo();
3547 moveCursorUpdate(false);
3548 owner->getMiniBuffer()->Set(CurrentState());
3552 if(!owner->buffer()->text->mark_set)
3554 owner->buffer()->update(-3);
3555 owner->view()->cursorPrevious();
3556 owner->buffer()->text->FinishUndo();
3557 moveCursorUpdate(false);
3558 owner->getMiniBuffer()->Set(CurrentState());
3562 if(!owner->buffer()->text->mark_set)
3564 owner->buffer()->update(-3);
3565 owner->view()->cursorNext();
3566 owner->buffer()->text->FinishUndo();
3567 moveCursorUpdate(false);
3568 owner->getMiniBuffer()->Set(CurrentState());
3572 if(!owner->buffer()->text->mark_set)
3574 owner->buffer()->update(-2);
3575 owner->buffer()->text->CursorHome();
3576 owner->buffer()->text->FinishUndo();
3577 moveCursorUpdate(false);
3578 owner->getMiniBuffer()->Set(CurrentState());
3582 if(!owner->buffer()->text->mark_set)
3584 owner->buffer()->update(-2);
3585 owner->buffer()->text->CursorEnd();
3586 owner->buffer()->text->FinishUndo();
3587 moveCursorUpdate(false);
3588 owner->getMiniBuffer()->Set(CurrentState());
3592 if(!owner->buffer()->text->mark_set)
3594 owner->buffer()->update(-2);
3595 owner->buffer()->text->CursorTab();
3596 owner->buffer()->text->FinishUndo();
3597 moveCursorUpdate(false);
3598 owner->getMiniBuffer()->Set(CurrentState());
3601 case LFUN_WORDRIGHT:
3602 if(!owner->buffer()->text->mark_set)
3604 owner->buffer()->update(-2);
3605 owner->buffer()->text->CursorRightOneWord();
3606 owner->buffer()->text->FinishUndo();
3607 moveCursorUpdate(false);
3608 owner->getMiniBuffer()->Set(CurrentState());
3612 if(!owner->buffer()->text->mark_set)
3614 owner->buffer()->update(-2);
3615 owner->buffer()->text->CursorLeftOneWord();
3616 owner->buffer()->text->FinishUndo();
3617 moveCursorUpdate(false);
3618 owner->getMiniBuffer()->Set(CurrentState());
3621 case LFUN_BEGINNINGBUF:
3622 if(!owner->buffer()->text->mark_set)
3624 owner->buffer()->update(-2);
3625 owner->buffer()->text->CursorTop();
3626 owner->buffer()->text->FinishUndo();
3627 moveCursorUpdate(false);
3628 owner->getMiniBuffer()->Set(CurrentState());
3632 if(!owner->buffer()->text->mark_set)
3634 owner->buffer()->update(-2);
3635 owner->buffer()->text->CursorBottom();
3636 owner->buffer()->text->FinishUndo();
3637 moveCursorUpdate(false);
3638 owner->getMiniBuffer()->Set(CurrentState());
3642 /* cursor selection ---------------------------- */
3644 owner->buffer()->update(-2);
3645 owner->buffer()->text->CursorRight();
3646 owner->buffer()->text->FinishUndo();
3647 moveCursorUpdate(true);
3648 owner->getMiniBuffer()->Set(CurrentState());
3652 owner->buffer()->update(-2);
3653 owner->buffer()->text->CursorLeft();
3654 owner->buffer()->text->FinishUndo();
3655 moveCursorUpdate(true);
3656 owner->getMiniBuffer()->Set(CurrentState());
3660 owner->buffer()->update(-2);
3661 owner->buffer()->text->CursorUp();
3662 owner->buffer()->text->FinishUndo();
3663 moveCursorUpdate(true);
3664 owner->getMiniBuffer()->Set(CurrentState());
3668 owner->buffer()->update(-2);
3669 owner->buffer()->text->CursorDown();
3670 owner->buffer()->text->FinishUndo();
3671 moveCursorUpdate(true);
3672 owner->getMiniBuffer()->Set(CurrentState());
3675 case LFUN_UP_PARAGRAPHSEL:
3676 owner->buffer()->update(-2);
3677 owner->buffer()->text->CursorUpParagraph();
3678 owner->buffer()->text->FinishUndo();
3679 moveCursorUpdate(true);
3680 owner->getMiniBuffer()->Set(CurrentState());
3683 case LFUN_DOWN_PARAGRAPHSEL:
3684 owner->buffer()->update(-2);
3685 owner->buffer()->text->CursorDownParagraph();
3686 owner->buffer()->text->FinishUndo();
3687 moveCursorUpdate(true);
3688 owner->getMiniBuffer()->Set(CurrentState());
3692 owner->buffer()->update(-2);
3693 owner->view()->cursorPrevious();
3694 owner->buffer()->text->FinishUndo();
3695 moveCursorUpdate(true);
3696 owner->getMiniBuffer()->Set(CurrentState());
3700 owner->buffer()->update(-2);
3701 owner->view()->cursorNext();
3702 owner->buffer()->text->FinishUndo();
3703 moveCursorUpdate(true);
3704 owner->getMiniBuffer()->Set(CurrentState());
3708 owner->buffer()->update(-2);
3709 owner->buffer()->text->CursorHome();
3710 owner->buffer()->text->FinishUndo();
3711 moveCursorUpdate(true);
3712 owner->getMiniBuffer()->Set(CurrentState());
3716 owner->buffer()->update(-2);
3717 owner->buffer()->text->CursorEnd();
3718 owner->buffer()->text->FinishUndo();
3719 moveCursorUpdate(true);
3720 owner->getMiniBuffer()->Set(CurrentState());
3723 case LFUN_WORDRIGHTSEL:
3724 owner->buffer()->update(-2);
3725 owner->buffer()->text->CursorRightOneWord();
3726 owner->buffer()->text->FinishUndo();
3727 moveCursorUpdate(true);
3728 owner->getMiniBuffer()->Set(CurrentState());
3731 case LFUN_WORDLEFTSEL:
3732 owner->buffer()->update(-2);
3733 owner->buffer()->text->CursorLeftOneWord();
3734 owner->buffer()->text->FinishUndo();
3735 moveCursorUpdate(true);
3736 owner->getMiniBuffer()->Set(CurrentState());
3739 case LFUN_BEGINNINGBUFSEL:
3740 owner->buffer()->update(-2);
3741 owner->buffer()->text->CursorTop();
3742 owner->buffer()->text->FinishUndo();
3743 moveCursorUpdate(true);
3744 owner->getMiniBuffer()->Set(CurrentState());
3747 case LFUN_ENDBUFSEL:
3748 owner->buffer()->update(-2);
3749 owner->buffer()->text->CursorBottom();
3750 owner->buffer()->text->FinishUndo();
3751 moveCursorUpdate(true);
3752 owner->getMiniBuffer()->Set(CurrentState());
3755 // --- text changing commands ------------------------
3756 case LFUN_BREAKLINE:
3758 owner->buffer()->text->InsertChar(LyXParagraph::META_NEWLINE);
3760 SetUpdateTimer(0.01);
3761 moveCursorUpdate(false);
3764 case LFUN_PROTECTEDSPACE:
3766 owner->buffer()->text->
3767 InsertChar(LyXParagraph::META_PROTECTED_SEPARATOR);
3770 moveCursorUpdate(false);
3774 if(owner->buffer()->text->mark_set) {
3776 owner->buffer()->update(0);
3777 setMessage(N_("Mark removed"));
3780 owner->buffer()->text->mark_set = 1;
3781 owner->buffer()->update(0);
3782 setMessage(N_("Mark set"));
3784 owner->buffer()->text->sel_cursor =
3785 owner->buffer()->text->cursor;
3790 if (!owner->buffer()->text->selection) {
3791 owner->buffer()->text->Delete();
3792 owner->buffer()->text->sel_cursor =
3793 owner->buffer()->text->cursor;
3795 // It is possible to make it a lot faster still
3796 // just comment out the lone below...
3797 owner->view()->getScreen()->ShowCursor();
3804 case LFUN_DELETE_SKIP:
3806 // Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
3808 LyXCursor cursor = owner->buffer()->text->cursor;
3811 if (!owner->buffer()->text->selection) {
3812 if (cursor.pos == cursor.par->Last()) {
3813 owner->buffer()->text->CursorRight();
3814 cursor = owner->buffer()->text->cursor;
3816 && !(cursor.par->added_space_top
3817 == VSpace (VSpace::NONE))) {
3818 owner->buffer()->text->SetParagraph
3819 (cursor.par->line_top,
3820 cursor.par->line_bottom,
3821 cursor.par->pagebreak_top,
3822 cursor.par->pagebreak_bottom,
3823 VSpace(VSpace::NONE),
3824 cursor.par->added_space_bottom,
3826 cursor.par->labelwidthstring, 0);
3827 owner->buffer()->text->CursorLeft();
3828 owner->buffer()->update (1);
3830 owner->buffer()->text->CursorLeft();
3831 owner->buffer()->text->Delete();
3832 owner->buffer()->text->sel_cursor =
3833 owner->buffer()->text->cursor;
3837 owner->buffer()->text->Delete();
3838 owner->buffer()->text->sel_cursor =
3839 owner->buffer()->text->cursor;
3849 /* -------> Delete word forward. */
3850 case LFUN_DELETE_WORD_FORWARD:
3851 owner->buffer()->update(-2);
3853 owner->buffer()->text->DeleteWordForward();
3854 owner->buffer()->update( 1 );
3856 moveCursorUpdate(false);
3859 /* -------> Delete word backward. */
3860 case LFUN_DELETE_WORD_BACKWARD:
3861 owner->buffer()->update(-2);
3863 owner->buffer()->text->DeleteWordBackward();
3864 owner->buffer()->update( 1 );
3866 moveCursorUpdate(false);
3869 /* -------> Kill to end of line. */
3870 case LFUN_DELETE_LINE_FORWARD:
3872 owner->buffer()->update(-2);
3873 owner->buffer()->text->DeleteLineForward();
3874 owner->buffer()->update( 1 );
3876 moveCursorUpdate(false);
3879 /* -------> Set mark off. */
3882 owner->buffer()->update(0);
3883 owner->buffer()->text->sel_cursor =
3884 owner->buffer()->text->cursor;
3885 setMessage(N_("Mark off"));
3888 /* -------> Set mark on. */
3891 owner->buffer()->text->mark_set = 1;
3892 owner->buffer()->update( 0 );
3893 owner->buffer()->text->sel_cursor =
3894 owner->buffer()->text->cursor;
3895 setMessage(N_("Mark on"));
3898 case LFUN_BACKSPACE:
3901 if (!owner->buffer()->text->selection) {
3902 if (owner->getIntl()->getTrans()->backspace()) {
3903 owner->buffer()->text->Backspace();
3904 owner->buffer()->text->sel_cursor =
3905 owner->buffer()->text->cursor;
3907 // It is possible to make it a lot faster still
3908 // just comment out the lone below...
3909 owner->view()->getScreen()->ShowCursor();
3918 case LFUN_BACKSPACE_SKIP:
3920 // Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
3922 LyXCursor cursor = owner->buffer()->text->cursor;
3925 if (!owner->buffer()->text->selection) {
3927 && !(cursor.par->added_space_top
3928 == VSpace (VSpace::NONE))) {
3929 owner->buffer()->text->SetParagraph
3930 (cursor.par->line_top,
3931 cursor.par->line_bottom,
3932 cursor.par->pagebreak_top,
3933 cursor.par->pagebreak_bottom,
3934 VSpace(VSpace::NONE), cursor.par->added_space_bottom,
3936 cursor.par->labelwidthstring, 0);
3937 owner->buffer()->update (1);
3939 owner->buffer()->text->Backspace();
3940 owner->buffer()->text->sel_cursor
3950 case LFUN_BREAKPARAGRAPH:
3953 owner->buffer()->text->BreakParagraph(0);
3955 SetUpdateTimer(0.01);
3956 owner->buffer()->text->sel_cursor =
3957 owner->buffer()->text->cursor;
3961 case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
3964 owner->buffer()->text->BreakParagraph(1);
3966 SetUpdateTimer(0.01);
3967 owner->buffer()->text->sel_cursor =
3968 owner->buffer()->text->cursor;
3972 case LFUN_BREAKPARAGRAPH_SKIP:
3974 // When at the beginning of a paragraph, remove
3975 // indentation and add a "defskip" at the top.
3976 // Otherwise, do the same as LFUN_BREAKPARAGRAPH.
3978 LyXCursor cursor = owner->buffer()->text->cursor;
3981 if (cursor.pos == 0) {
3982 if (cursor.par->added_space_top == VSpace(VSpace::NONE)) {
3983 owner->buffer()->text->SetParagraph
3984 (cursor.par->line_top,
3985 cursor.par->line_bottom,
3986 cursor.par->pagebreak_top,
3987 cursor.par->pagebreak_bottom,
3988 VSpace(VSpace::DEFSKIP), cursor.par->added_space_bottom,
3990 cursor.par->labelwidthstring, 1);
3991 owner->buffer()->update(1);
3995 owner->buffer()->text->BreakParagraph(0);
3998 SetUpdateTimer(0.01);
3999 owner->buffer()->text->sel_cursor = cursor;
4005 owner->buffer()->text->InsertChar('\"'); // This " matches the single quote in the code
4008 moveCursorUpdate(false);
4014 InsetCommand * new_inset;
4015 if (action == LFUN_HTMLURL)
4016 new_inset = new InsetUrl("htmlurl", "", "");
4018 new_inset = new InsetUrl("url", "", "");
4019 owner->buffer()->insertInset(new_inset);
4020 new_inset->Edit(0, 0);
4024 // --- lyxserver commands ----------------------------
4026 case LFUN_CHARATCURSOR:
4028 LyXParagraph::size_type pos =
4029 owner->buffer()->text->cursor.pos;
4030 if(pos < owner->buffer()->text->cursor.par->size())
4031 dispatch_buffer = owner->buffer()->text->
4032 cursor.par->text[pos];
4034 dispatch_buffer = "EOF";
4040 tostr(owner->buffer()->text->cursor.x) + ' '
4041 + tostr(owner->buffer()->text->cursor.y);
4048 sscanf(argument.c_str(), " %d %ld", &x, &y);
4049 owner->buffer()->text->SetCursorFromCoordinates(x, y);
4053 case LFUN_GETLAYOUT:
4055 tostr(owner->buffer()->text->cursor.par->layout);
4060 LyXFont *font = &(owner->buffer()->text->current_font);
4061 if(font->shape() == LyXFont::ITALIC_SHAPE)
4062 dispatch_buffer = 'E';
4063 else if(font->shape() == LyXFont::SMALLCAPS_SHAPE)
4064 dispatch_buffer = 'N';
4066 dispatch_buffer = '0';
4073 LyXFont *font = &(owner->buffer()->text->current_font);
4074 if(font->latex() == LyXFont::ON)
4075 dispatch_buffer = 'L';
4077 dispatch_buffer = '0';
4082 setMessage(owner->buffer()->getFileName());
4083 lyxerr.debug() << "FNAME["
4084 << owner->buffer()->getFileName()
4091 keyseq.print(buf, 100);
4092 dispatch_buffer = buf;
4093 lyxserver->notifyClient(dispatch_buffer);
4097 case LFUN_GOTOFILEROW:
4099 char file_name[100];
4101 sscanf(argument.c_str(), " %s %d", file_name, &row);
4103 // Must replace extension of the file to be .lyx and get full path
4104 string s = ChangeExtension(string(file_name), ".lyx", false);
4106 // Either change buffer or load the file
4107 if (bufferlist.exists(s))
4108 owner->view()->buffer(bufferlist.getBuffer(s));
4110 owner->view()->buffer(bufferlist.loadLyXFile(s));
4113 owner->buffer()->setCursorFromRow(row);
4117 if (owner->buffer()->text->cursor.y >
4118 owner->view()->getWorkArea()->h / 2) {
4119 owner->view()->getScreen()->
4120 Draw(owner->buffer()->text->cursor.y -
4121 owner->view()->getWorkArea()->h/2);
4123 owner->view()->getScreen()->
4126 owner->buffer()->update(0);
4127 owner->view()->redraw();
4134 int qa = lyxaction.LookupFunc(argument.c_str());
4135 setMessage(lyxaction.helpText((kb_action)qa));
4139 // --- accented characters ---------------------------
4142 case LFUN_CIRCUMFLEX:
4152 case LFUN_SPECIAL_CARON:
4155 case LFUN_HUNG_UMLAUT:
4161 if (keyseq.length == -1 && keyseq.getiso()!= 0)
4166 owner->getIntl()->getTrans()->
4167 deadkey(c, get_accent(action).accent,
4168 owner->buffer()->text);
4170 // Need to reset, in case the minibuffer calls these
4175 // copied verbatim from do_accent_char
4178 owner->buffer()->text->sel_cursor =
4179 owner->buffer()->text->cursor;
4183 // --- toolbar ----------------------------------
4184 case LFUN_PUSH_TOOLBAR:
4186 int nth = strToInt(argument);
4187 if (lyxerr.debugging(Debug::TOOLBAR)) {
4188 lyxerr << "LFUN_PUSH_TOOLBAR: argument = `"
4189 << argument << "'\n"
4190 << "LFUN_PUSH_TOOLBAR: nth = `"
4191 << nth << "'" << endl;
4196 setErrorMessage(N_("Push-toolbar needs argument > 0"));
4198 owner->getToolbar()->push(nth);
4203 case LFUN_ADD_TO_TOOLBAR:
4205 if (lyxerr.debugging(Debug::TOOLBAR)) {
4206 lyxerr << "LFUN_ADD_TO_TOOLBAR:"
4207 "argument = `" << argument << '\'' << endl;
4209 string tmp(argument);
4210 //lyxerr <<string("Argument: ") + argument);
4211 //lyxerr <<string("Tmp : ") + tmp);
4214 setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
4216 owner->getToolbar()->add(argument, false);
4217 owner->getToolbar()->set();
4222 // --- insert characters ----------------------------------------
4224 case LFUN_INSERT_INSET_LATEX:
4226 Inset *new_inset = new InsetLatex(argument);
4227 owner->buffer()->insertInset(new_inset);
4231 // --- Mathed stuff. If we are here, there is no locked inset yet.
4236 if (!greek_kb_flag) {
4238 setMessage(N_("Math greek mode on"));
4245 case LFUN_GREEK_TOGGLE:
4247 greek_kb_flag = (greek_kb_flag) ? 0: 2;
4248 if (greek_kb_flag) {
4249 setMessage(N_("Math greek keyboard on"));
4251 setMessage(N_("Math greek keyboard off"));
4256 case LFUN_MATH_DELIM:
4257 case LFUN_INSERT_MATRIX:
4259 if (owner->view()->available()) {
4261 open_new_inset(new InsetFormula(false));
4263 the_locking_inset->LocalDispatch(action, argument.c_str());
4268 case LFUN_INSERT_MATH:
4270 math_insert_symbol(argument.c_str());
4274 case LFUN_MATH_DISPLAY:
4276 if (owner->view()->available())
4277 owner->buffer()->open_new_inset(new InsetFormula(true));
4281 case LFUN_MATH_MACRO:
4283 if (owner->view()->available()) {
4286 setErrorMessage(N_("Missing argument"));
4288 string s1 = token(s, ' ', 1);
4289 int na = s1.empty() ? 0: atoi(s1.c_str());
4291 open_new_inset(new InsetFormulaMacro(token(s, ' ', 0), na));
4297 case LFUN_MATH_MODE: // Open or create a math inset
4300 if (owner->view()->available())
4301 owner->buffer()->open_new_inset(new InsetFormula);
4302 setMessage(N_("Math editor mode"));
4306 case LFUN_MATH_NUMBER:
4307 case LFUN_MATH_LIMITS:
4309 setErrorMessage(N_("This is only allowed in math mode!"));
4313 case LFUN_INSERT_CITATION:
4315 InsetCitation * new_inset = new InsetCitation();
4317 // The note, if any, must be after the key, delimited
4318 // by a | so both key and remark can have spaces.
4319 if (!argument.empty()) {
4320 string lsarg(argument);
4321 if (contains(lsarg, "|")) {
4322 new_inset->setContents(token(lsarg, '|', 0));
4323 new_inset->setOptions(token(lsarg, '|', 1));
4325 new_inset->setContents(lsarg);
4326 owner->buffer()->insertInset(new_inset);
4328 owner->buffer()->insertInset(new_inset);
4329 new_inset->Edit(0, 0);
4334 case LFUN_INSERT_BIBTEX:
4336 // ale970405+lasgoutt970425
4337 // The argument can be up to two tokens separated
4338 // by a space. The first one is the bibstyle.
4339 string lsarg(argument);
4340 string bibstyle = token(lsarg, ' ', 1);
4341 if (bibstyle.empty())
4343 InsetBibtex * new_inset
4344 = new InsetBibtex(token(lsarg, ' ', 0),
4348 owner->buffer()->insertInset(new_inset);
4349 if (lsarg.empty()) {
4350 new_inset->Edit(0, 0);
4355 // BibTeX data bases
4356 case LFUN_BIBDB_ADD:
4358 InsetBibtex * inset =
4359 static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
4361 inset->addDatabase(argument);
4366 case LFUN_BIBDB_DEL:
4368 InsetBibtex * inset =
4369 static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
4371 inset->delDatabase(argument);
4376 case LFUN_BIBTEX_STYLE:
4378 InsetBibtex * inset =
4379 static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
4381 inset->setOptions(argument);
4386 case LFUN_INDEX_INSERT:
4387 case LFUN_INDEX_INSERT_LAST:
4389 // Can't do that at the beginning of a paragraph.
4390 if (owner->buffer()->text->cursor.pos - 1 <0)
4393 InsetIndex * new_inset = new InsetIndex();
4394 if (!argument.empty()) {
4395 string lsarg(argument);
4396 new_inset->setContents(lsarg);
4397 owner->buffer()->insertInset(new_inset);
4400 //get the current word for an argument
4401 LyXParagraph::size_type lastpos =
4402 owner->buffer()->text->cursor.pos - 1;
4403 // Get the current word. note that this must be done
4404 // before inserting the inset, or the inset will
4406 string curstring(owner->buffer()
4407 ->text->cursor.par->GetWord(lastpos));
4409 //make the new inset and write the current word into it
4410 InsetIndex * new_inset = new InsetIndex();
4412 new_inset->setContents(curstring);
4414 //don't edit it if the call was to INSERT_LAST
4415 if(action!= LFUN_INDEX_INSERT_LAST) {
4416 new_inset->Edit(0, 0);
4418 //it looks blank on the screen unless
4419 //we do something. put it here.
4421 // move the cursor to the returned value of lastpos
4422 // but only for the auto-insert
4423 owner->buffer()->text->cursor.pos= lastpos;
4426 //put the new inset into the buffer.
4427 // there should be some way of knowing the user
4428 //cancelled & avoiding this, but i don't know how
4429 owner->buffer()->insertInset(new_inset);
4434 case LFUN_INDEX_PRINT:
4436 Inset * new_inset = new InsetPrintIndex(owner->buffer());
4437 owner->buffer()->insertInset(new_inset, "Standard", true);
4441 case LFUN_PARENTINSERT:
4443 lyxerr << "arg " << argument << endl;
4444 Inset * new_inset = new InsetParent(argument, owner->buffer());
4445 owner->buffer()->insertInset(new_inset, "Standard", true);
4449 case LFUN_CHILDINSERT:
4451 Inset * new_inset = new InsetInclude(argument,
4453 owner->buffer()->insertInset(new_inset, "Standard", true);
4454 new_inset->Edit(0, 0);
4458 case LFUN_CHILDOPEN:
4461 MakeAbsPath(argument,
4462 OnlyPath(owner->buffer()->getFileName()));
4463 setMessage(N_("Opening child document ") +
4464 MakeDisplayPath(filename) + "...");
4465 owner->view()->savePosition();
4466 if (bufferlist.exists(filename))
4467 owner->view()->buffer(bufferlist.getBuffer(filename));
4469 owner->view()->buffer(bufferlist.loadLyXFile(filename));
4473 case LFUN_INSERT_NOTE:
4477 case LFUN_INSERTFOOTNOTE:
4479 LyXParagraph::footnote_kind kind;
4480 if (argument == "footnote")
4481 { kind = LyXParagraph::FOOTNOTE; }
4482 else if (argument == "margin")
4483 { kind = LyXParagraph::MARGIN; }
4484 else if (argument == "figure")
4485 { kind = LyXParagraph::FIG; }
4486 else if (argument == "table")
4487 { kind = LyXParagraph::TAB; }
4488 else if (argument == "wide-fig")
4489 { kind = LyXParagraph::WIDE_FIG; }
4490 else if (argument == "wide-tab")
4491 { kind = LyXParagraph::WIDE_TAB; }
4492 else if (argument == "algorithm")
4493 { kind = LyXParagraph::ALGORITHM; }
4495 setErrorMessage(N_("Unknown kind of footnote"));
4498 owner->buffer()->text->InsertFootnoteEnvironment(kind);
4499 owner->buffer()->update(1);
4503 case LFUN_BUFFERBULLETSSELECT:
4507 case LFUN_TOGGLECURSORFOLLOW:
4508 cursor_follows_scrollbar = !cursor_follows_scrollbar;
4511 case LFUN_KMAP_OFF: // keymap off
4512 owner->getIntl()->KeyMapOn(false);
4515 case LFUN_KMAP_PRIM: // primary keymap
4516 owner->getIntl()->KeyMapPrim();
4519 case LFUN_KMAP_SEC: // secondary keymap
4520 owner->getIntl()->KeyMapSec();
4523 case LFUN_KMAP_TOGGLE: // toggle keymap
4524 owner->getIntl()->ToggleKeyMap();
4527 case LFUN_SELFINSERT:
4529 for (string::size_type i = 0; i < argument.length(); ++i) {
4530 owner->buffer()->text->InsertChar(argument[i]);
4531 // This needs to be in the loop, or else we
4532 // won't break lines correctly. (Asger)
4536 owner->buffer()->text->sel_cursor =
4537 owner->buffer()->text->cursor;
4538 moveCursorUpdate(false);
4544 // argument contains ';'-terminated commands
4545 while (argument.find(';') != string::npos) {
4547 argument = split(argument, first, ';');
4553 case LFUN_SAVEPREFERENCES:
4555 Path p(user_lyxdir);
4556 lyxrc->write("preferences");
4560 case LFUN_UNKNOWN_ACTION:
4562 if (owner->buffer()->isReadonly()) {
4564 setErrorMessage(N_("Document is read only"));
4568 if (!argument.empty()) {
4570 /* Automatically delete the currently selected
4571 * text and replace it with what is being
4572 * typed in now. Depends on lyxrc settings
4573 * "auto_region_delete", which defaults to
4576 if ( lyxrc->auto_region_delete ) {
4577 if (owner->buffer()->text->selection){
4578 owner->buffer()->text->CutSelection(false);
4579 owner->buffer()->update(-1);
4584 for (string::size_type i = 0;
4585 i < argument.length(); ++i) {
4586 if (greek_kb_flag) {
4587 if (!math_insert_greek(argument[i]))
4588 owner->getIntl()->getTrans()->TranslateAndInsert(argument[i], owner->buffer()->text);
4590 owner->getIntl()->getTrans()->TranslateAndInsert(argument[i], owner->buffer()->text);
4596 owner->buffer()->text->sel_cursor =
4597 owner->buffer()->text->cursor;
4598 moveCursorUpdate(false);
4601 // why is an "Unknown action" with empty
4602 // argument even dispatched in the first
4603 // place? I`ll probably change that. (Lgb)
4605 setErrorMessage(N_("Unknown action"));
4609 lyxerr << "A truly unknown func!" << endl;
4615 string res = getMessage();
4618 if (!commandshortcut.empty()) {
4619 string newbuf = owner->getMiniBuffer()->GetText();
4620 if (newbuf != commandshortcut) {
4621 owner->getMiniBuffer()->Set(newbuf
4627 owner->getMiniBuffer()->Set(string(_(res.c_str()))
4628 + " " + commandshortcut);
4635 void LyXFunc::setupLocalKeymap()
4637 keyseq.stdmap = keyseq.curmap = toplevel_keymap;
4638 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap;
4642 void LyXFunc::MenuNew(bool fromTemplate)
4644 string fname, initpath = lyxrc->document_path;
4647 if (owner->view()->available()) {
4648 string trypath = owner->buffer()->filepath;
4649 // If directory is writeable, use this as default.
4650 if (IsDirWriteable(trypath) == 1)
4655 fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
4656 fileDlg.SetButton(1, _("Templates"), lyxrc->template_path);
4657 fname = fileDlg.Select(_("Enter Filename for new document"),
4658 initpath, "*.lyx", _("newfile"));
4661 if (fname.empty()) {
4662 owner->getMiniBuffer()->Set(_("Canceled."));
4663 lyxerr.debug() << "New Document Cancelled." << endl;
4667 // get absolute path of file and make sure the filename ends
4669 string s = MakeAbsPath(fname);
4670 if (!IsLyXFilename(s))
4673 // Check if the document already is open
4674 if (bufferlist.exists(s)){
4675 switch(AskConfirmation(_("Document is already open:"),
4676 MakeDisplayPath(s, 50),
4677 _("Do you want to close that document now?\n"
4678 "('No' will just switch to the open version)")))
4680 case 1: // Yes: close the document
4681 if (!bufferlist.close(bufferlist.getBuffer(s)))
4682 // If close is canceled, we cancel here too.
4685 case 2: // No: switch to the open document
4686 owner->view()->buffer(bufferlist.getBuffer(s));
4688 case 3: // Cancel: Do nothing
4689 owner->getMiniBuffer()->Set(_("Canceled."));
4694 // Check whether the file already exists
4695 if (IsLyXFilename(s)) {
4697 if (fi.readable() &&
4698 AskQuestion(_("File already exists:"),
4699 MakeDisplayPath(s, 50),
4700 _("Do you want to open the document?"))) {
4702 owner->getMiniBuffer()->Set(_("Opening document"),
4703 MakeDisplayPath(s), "...");
4705 owner->view()->buffer(
4706 bufferlist.loadLyXFile(s));
4707 owner->getMiniBuffer()->Set(_("Document"),
4714 // The template stuff
4718 fname = fileDlg.Select(_("Choose template"),
4719 lyxrc->template_path,
4725 // find a free buffer
4726 lyxerr.debug() << "Find a free buffer." << endl;
4727 owner->view()->buffer(bufferlist.newFile(s, templname));
4731 void LyXFunc::MenuOpen()
4733 string initpath = lyxrc->document_path;
4736 if (owner->view()->available()) {
4737 string trypath = owner->buffer()->filepath;
4738 // If directory is writeable, use this as default.
4739 if (IsDirWriteable(trypath) == 1)
4745 fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
4746 fileDlg.SetButton(1, _("Examples"),
4747 AddPath(system_lyxdir, "examples"));
4748 string filename = fileDlg.Select(_("Select Document to Open"),
4752 // check selected filename
4753 if (filename.empty()) {
4754 owner->getMiniBuffer()->Set(_("Canceled."));
4758 // get absolute path of file and make sure the filename ends
4760 filename = MakeAbsPath(filename);
4761 if (!IsLyXFilename(filename))
4765 owner->getMiniBuffer()->Set(_("Opening document"),
4766 MakeDisplayPath(filename), "...");
4767 Buffer * openbuf = bufferlist.loadLyXFile(filename);
4769 owner->view()->buffer(openbuf);
4770 owner->getMiniBuffer()->Set(_("Document"),
4771 MakeDisplayPath(filename),
4774 owner->getMiniBuffer()->Set(_("Could not open document"),
4775 MakeDisplayPath(filename));
4780 void LyXFunc::doImportASCII(bool linorpar)
4782 string initpath = lyxrc->document_path;
4785 if (owner->view()->available()) {
4786 string trypath = owner->buffer()->filepath;
4787 // If directory is writeable, use this as default.
4788 if (IsDirWriteable(trypath) == 1)
4794 fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
4795 fileDlg.SetButton(1, _("Examples"),
4796 AddPath(system_lyxdir, "examples"));
4797 string filename = fileDlg.Select(_("Select ASCII file to Import"),
4801 // check selected filename
4802 if (filename.empty()) {
4803 owner->getMiniBuffer()->Set(_("Canceled."));
4807 // get absolute path of file
4808 filename = MakeAbsPath(filename);
4810 string s = ChangeExtension(filename, ".lyx", false);
4812 // Check if the document already is open
4813 if (bufferlist.exists(s)){
4814 switch(AskConfirmation(_("Document is already open:"),
4815 MakeDisplayPath(s, 50),
4816 _("Do you want to close that document now?\n"
4817 "('No' will just switch to the open version)")))
4819 case 1: // Yes: close the document
4820 if (!bufferlist.close(bufferlist.getBuffer(s)))
4821 // If close is canceled, we cancel here too.
4824 case 2: // No: switch to the open document
4825 owner->view()->buffer(bufferlist.getBuffer(s));
4827 case 3: // Cancel: Do nothing
4828 owner->getMiniBuffer()->Set(_("Canceled."));
4833 // Check if a LyX document by the same root exists in filesystem
4834 FileInfo f(s, true);
4835 if (f.exist() && !AskQuestion(_("A document by the name"),
4837 _("already exists. Overwrite?"))) {
4838 owner->getMiniBuffer()->Set(_("Canceled."));
4842 owner->view()->buffer(bufferlist.newFile(s, string()));
4843 owner->getMiniBuffer()->Set(_("Importing ASCII file"),
4844 MakeDisplayPath(filename), "...");
4845 // Insert ASCII file
4846 InsertAsciiFile(filename, linorpar);
4847 owner->getMiniBuffer()->Set(_("ASCII file "),
4848 MakeDisplayPath(filename),
4853 void LyXFunc::doImportLaTeX(bool isnoweb)
4855 string initpath = lyxrc->document_path;
4858 if (owner->view()->available()) {
4859 string trypath = owner->buffer()->filepath;
4860 // If directory is writeable, use this as default.
4861 if (IsDirWriteable(trypath) == 1)
4867 fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
4868 fileDlg.SetButton(1, _("Examples"),
4869 AddPath(system_lyxdir, "examples"));
4872 filename = fileDlg.Select(_("Select Noweb file to Import"),
4875 filename = fileDlg.Select(_("Select LaTeX file to Import"),
4881 // check selected filename
4882 if (filename.empty()) {
4883 owner->getMiniBuffer()->Set(_("Canceled."));
4887 // get absolute path of file
4888 filename = MakeAbsPath(filename);
4890 // Check if the document already is open
4891 string LyXfilename = ChangeExtension(filename, ".lyx", false);
4892 if (bufferlist.exists(LyXfilename)){
4893 switch(AskConfirmation(_("Document is already open:"),
4894 MakeDisplayPath(LyXfilename, 50),
4895 _("Do you want to close that document now?\n"
4896 "('No' will just switch to the open version)")))
4898 case 1: // Yes: close the document
4899 if (!bufferlist.close(bufferlist.getBuffer(LyXfilename)))
4900 // If close is canceled, we cancel here too.
4903 case 2: // No: switch to the open document
4904 owner->view()->buffer(
4905 bufferlist.getBuffer(LyXfilename));
4907 case 3: // Cancel: Do nothing
4908 owner->getMiniBuffer()->Set(_("Canceled."));
4913 // Check if a LyX document by the same root exists in filesystem
4914 FileInfo f(LyXfilename, true);
4915 if (f.exist() && !AskQuestion(_("A document by the name"),
4916 MakeDisplayPath(LyXfilename),
4917 _("already exists. Overwrite?"))) {
4918 owner->getMiniBuffer()->Set(_("Canceled."));
4925 owner->getMiniBuffer()->Set(_("Importing LaTeX file"),
4926 MakeDisplayPath(filename), "...");
4927 ImportLaTeX myImport(filename);
4928 openbuf = myImport.run();
4930 owner->getMiniBuffer()->Set(_("Importing Noweb file"),
4931 MakeDisplayPath(filename), "...");
4932 ImportNoweb myImport(filename);
4933 openbuf = myImport.run();
4936 owner->view()->buffer(openbuf);
4937 owner->getMiniBuffer()->Set(isnoweb ?
4938 _("Noweb file ") : _("LateX file "),
4939 MakeDisplayPath(filename),
4942 owner->getMiniBuffer()->Set(isnoweb ?
4943 _("Could not import Noweb file") :
4944 _("Could not import LaTeX file"),
4945 MakeDisplayPath(filename));
4950 void LyXFunc::MenuInsertLyXFile(string const & filen)
4952 string filename = filen;
4954 if (filename.empty()) {
4955 // Launch a file browser
4956 string initpath = lyxrc->document_path;
4959 if (owner->view()->available()) {
4960 string trypath = owner->buffer()->filepath;
4961 // If directory is writeable, use this as default.
4962 if (IsDirWriteable(trypath) == 1)
4968 fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
4969 fileDlg.SetButton(1, _("Examples"),
4970 AddPath(system_lyxdir, "examples"));
4971 filename = fileDlg.Select(_("Select Document to Insert"),
4975 // check selected filename
4976 if (filename.empty()) {
4977 owner->getMiniBuffer()->Set(_("Canceled."));
4982 // get absolute path of file and make sure the filename ends
4984 filename = MakeAbsPath(filename);
4985 if (!IsLyXFilename(filename))
4989 owner->getMiniBuffer()->Set(_("Inserting document"),
4990 MakeDisplayPath(filename), "...");
4991 bool res = owner->buffer()->insertLyXFile(filename);
4993 owner->getMiniBuffer()->Set(_("Document"),
4994 MakeDisplayPath(filename),
4997 owner->getMiniBuffer()->Set(_("Could not insert document"),
4998 MakeDisplayPath(filename));
5003 void LyXFunc::reloadBuffer()
5005 string fn = owner->buffer()->fileName();
5006 if (bufferlist.close(owner->buffer()))
5007 owner->view()->buffer(bufferlist.loadLyXFile(fn));
5011 void LyXFunc::CloseBuffer()
5013 if (bufferlist.close(owner->buffer()) && !quitting) {
5014 if (bufferlist.empty()) {
5015 // need this otherwise SEGV may occur while trying to
5016 // set variables that don't exist
5017 // since there's no current buffer
5018 CloseAllBufferRelatedPopups();
5021 owner->view()->buffer(bufferlist.first());
5027 Inset * LyXFunc::getInsetByCode(Inset::Code code)
5032 LyXCursor cursor = owner->view()->text->cursor;
5034 LyXCursor cursor = owner->buffer()->text->cursor;
5036 LyXParagraph::size_type pos = cursor.pos;
5037 LyXParagraph * par = cursor.par;
5039 while (par && !found) {
5040 while ((inset = par->ReturnNextInsetPointer(pos))){
5041 if (inset->LyxCode() == code) {
5049 return (found) ? inset: 0;
5053 // Each "owner" should have it's own message method. lyxview and
5054 // the minibuffer would use the minibuffer, but lyxserver would
5055 // send an ERROR signal to its client. Alejandro 970603
5056 // This func is bit problematic when it comes to NLS, to make the
5057 // lyx servers client be language indepenent we must not translate
5058 // strings sent to this func.
5059 void LyXFunc::setErrorMessage(string const & m) const
5061 dispatch_buffer = m;
5066 void LyXFunc::setMessage(string const & m)
5068 dispatch_buffer = m;