1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2000 The LyX Team.
9 * ====================================================== */
20 #pragma implementation
23 #include "lyxlookup.h"
26 #include "bufferlist.h"
27 #include "lyxserver.h"
32 #include "LyXAction.h"
33 #include "insets/inseturl.h"
34 #include "insets/insetlatexaccent.h"
35 #include "insets/insettoc.h"
36 #include "insets/insetlof.h"
37 #include "insets/insetloa.h"
38 #include "insets/insetlot.h"
39 #include "insets/insetref.h"
40 #include "insets/insetparent.h"
41 #include "insets/insetindex.h"
42 #include "insets/insetinclude.h"
43 #include "insets/insetbib.h"
44 #include "mathed/formulamacro.h"
46 #include "spellchecker.h" // RVDK_PATCH_5
47 #include "minibuffer.h"
51 #include "lyx_gui_misc.h"
52 #include "support/filetools.h"
53 #include "support/FileInfo.h"
54 #include "support/syscall.h"
55 #include "support/lstrings.h"
56 #include "support/path.h"
61 #include "trans_mgr.h"
62 #include "ImportLaTeX.h"
63 #include "ImportNoweb.h"
67 extern bool cursor_follows_scrollbar;
69 extern void InsertAsciiFile(string const &, bool);
70 extern void math_insert_symbol(char const *);
71 extern Bool math_insert_greek(char const); // why "Bool"?
72 extern BufferList bufferlist;
73 extern LyXServer * lyxserver;
74 extern short greek_kb_flag;
75 extern FD_form_toc * fd_form_toc;
76 extern bool selection_possible;
78 extern kb_keymap * toplevel_keymap;
80 extern void MenuWrite(Buffer *);
81 extern void MenuWriteAs(Buffer *);
82 extern int MenuRunLaTeX(Buffer *);
83 extern int MenuBuildProg(Buffer *);
84 extern int MenuRunChktex(Buffer *);
85 extern bool CreatePostscript(Buffer *, bool);
86 extern void MenuPrint(Buffer *);
87 extern void MenuSendto();
88 extern void QuitLyX();
89 extern void MenuFax(Buffer *);
90 extern void MenuExport(Buffer *, string const &);
91 extern void MenuPasteSelection(char at);
92 extern LyXAction lyxaction;
94 extern tex_accent_struct get_accent(kb_action action);
96 extern void AutoSave();
97 extern void MenuSearch();
98 extern void SetUpdateTimer(float timer = 0.3);
99 extern void FreeUpdateTimer();
100 extern bool PreviewDVI(Buffer *);
101 extern bool PreviewPostscript(Buffer *);
102 extern void MenuInsertLabel(char const *);
103 extern void MenuInsertRef();
104 extern void MenuLayoutCharacter();
105 extern void MenuLayoutParagraph();
106 extern void MenuLayoutDocument();
107 extern void MenuLayoutPaper();
108 extern void MenuLayoutTable(int flag);
109 extern void MenuLayoutQuotes();
110 extern void MenuLayoutPreamble();
111 extern void MenuLayoutSave();
112 extern void bulletForm();
114 extern Buffer * NewLyxFile(string const &);
115 extern void LoadLyXFile(string const &);
116 extern void Reconfigure(BufferView *);
118 extern int current_layout;
119 extern int getISOCodeFromLaTeX(char *);
121 extern void ShowLatexLog();
123 extern void UpdateInset(BufferView *, Inset * inset, bool mark_dirty = true);
125 /* === globals =========================================================== */
127 bool LyXFunc::show_sc = true;
130 LyXFunc::LyXFunc(LyXView * o)
134 lyx_dead_action = LFUN_NOACTION;
135 lyx_calling_dead_action = LFUN_NOACTION;
140 // I changed this func slightly. I commented out the ...FinishUndo(),
141 // this means that all places that used to have a moveCursorUpdate, now
142 // have a ...FinishUndo() as the preceeding statement. I have also added
143 // a moveCursorUpdate to some of the functions that updated the cursor, but
144 // that did not show its new position.
146 void LyXFunc::moveCursorUpdate(bool selecting)
148 if (selecting || owner->view()->text->mark_set) {
149 owner->view()->text->SetSelection();
150 owner->view()->toggleToggle();
151 owner->view()->update(0);
153 owner->view()->update(-2); // this IS necessary
157 owner->view()->showCursor();
159 /* ---> Everytime the cursor is moved, show the current font state. */
160 // should this too me moved out of this func?
161 //owner->getMiniBuffer()->Set(CurrentState());
162 owner->view()->setState();
166 int LyXFunc::processKeyEvent(XEvent * ev)
170 XKeyEvent * keyevent = &ev->xkey;
171 KeySym keysym_return;
173 int num_bytes = LyXLookupString(ev, s_r, 10, &keysym_return);
174 s_r[num_bytes] = '\0';
176 if (lyxerr.debugging(Debug::KEY)) {
177 char * tmp = XKeysymToString(keysym_return);
178 string stm = (tmp ? tmp : "");
179 lyxerr << "KeySym is "
182 << keysym_return << "]"
183 << " and num_bytes is "
185 << " the string returned is \""
186 << s_r << '\"' << endl;
188 // Do nothing if we have nothing (JMarc)
189 if (num_bytes == 0 && keysym_return == NoSymbol) {
190 lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
195 // this function should be used always [asierra060396]
196 if (owner->view()->available() &&
197 owner->view()->the_locking_inset &&
198 keysym_return == XK_Escape) {
199 owner->view()->unlockInset(owner->view()->the_locking_inset);
200 owner->view()->text->CursorRight();
201 moveCursorUpdate(false);
202 owner->getMiniBuffer()->Set(CurrentState());
206 // Can we be sure that this will work for all X-Windows
207 // implementations? (Lgb)
208 // This code snippet makes lyx ignore some keys. Perhaps
209 // all of them should be explictly mentioned?
210 if((keysym_return >= XK_Shift_L && keysym_return <= XK_Hyper_R)
211 || keysym_return == XK_Mode_switch || keysym_return == 0x0)
214 // Do a one-deep top-level lookup for
215 // cancel and meta-fake keys. RVDK_PATCH_5
216 cancel_meta_seq.reset();
218 int action = cancel_meta_seq.addkey(keysym_return, keyevent->state
219 &(ShiftMask|ControlMask
222 // When not cancel or meta-fake, do the normal lookup.
223 // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
224 // Mostly, meta_fake_bit = 0. RVDK_PATCH_5.
225 if ( (action != LFUN_CANCEL) && (action != LFUN_META_FAKE) ) {
227 // remove Caps Lock and Mod2 as a modifiers
228 action = keyseq.addkey(keysym_return,
229 (keyevent->state | meta_fake_bit)
230 &(ShiftMask|ControlMask
233 // Dont remove this unless you know what you are doing.
236 if (action == 0) action = LFUN_PREFIX;
238 if (lyxerr.debugging(Debug::KEY)) {
244 << num_bytes << "]" << endl;
247 // already here we know if it any point in going further
248 // why not return already here if action == -1 and
249 // num_bytes == 0? (Lgb)
251 if(keyseq.length > 1 || keyseq.length < -1) {
254 owner->getMiniBuffer()->Set(buf);
258 if (keyseq.length < -1) { // unknown key sequence...
262 owner->getMiniBuffer()->Set(_("Unknown sequence:"), buf);
266 char isochar = keyseq.getiso();
267 if (!(keyevent->state&ControlMask) &&
268 !(keyevent->state&Mod1Mask) &&
269 (isochar && keysym_return < 0xF000)) {
272 if (argument.empty()) {
273 lyxerr.debug() << "Empty argument!" << endl;
274 // This can`t possibly be of any use
275 // so we`ll skip the dispatch.
279 if (action == LFUN_SELFINSERT) {
283 bool tmp_sc = show_sc;
285 Dispatch(action, argument.c_str());
292 LyXFunc::func_status LyXFunc::getStatus(int ac) const
295 func_status flag = LyXFunc::OK;
297 Buffer * buf = owner->buffer();
299 if (lyxaction.isPseudoAction(ac))
300 action = lyxaction.retrieveActionArg(ac, argument);
302 action = static_cast<kb_action>(ac);
304 if (action == LFUN_UNKNOWN_ACTION) {
305 setErrorMessage(N_("Unknown action"));
306 return LyXFunc::Unknown;
309 // Check whether we need a buffer
310 if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) {
311 // Yes we need a buffer, do we have one?
314 // Can we use a readonly buffer?
315 if (buf->isReadonly() &&
316 !lyxaction.funcHasFlag(action,
317 LyXAction::ReadOnly)) {
319 setErrorMessage(N_("Document is read-only"));
320 flag |= LyXFunc::Disabled;
324 setErrorMessage(N_("Command not allowed with"
325 "out any document open"));
326 flag |= LyXFunc::Disabled;
330 if (flag & LyXFunc::Disabled)
333 // I would really like to avoid having this switch and rather try to
334 // encode this in the function itself.
335 static bool noLaTeX = lyxrc->latex_command == "none";
336 bool disable = false;
339 disable = noLaTeX || lyxrc->view_dvi_command == "none";
342 disable = noLaTeX || lyxrc->view_ps_command == "none";
349 disable = noLaTeX || lyxrc->print_command == "none";
352 disable = noLaTeX || lyxrc->fax_command == "none";
355 if (argument == "latex")
356 disable = lyxrc->relyx_command == "none";
359 if (argument == "dvi" || argument == "postscript")
361 if (argument == "html")
362 disable = lyxrc->html_command == "none";
365 disable = buf->undostack.empty();
368 disable = buf->redostack.empty();
370 case LFUN_SPELLCHECK:
371 disable = lyxrc->isp_command == "none";
374 disable = lyxrc->chktex_command == "none";
376 case LFUN_LAYOUT_TABLE:
377 disable = ! owner->view()->text->cursor.par->table;
383 flag |= LyXFunc::Disabled;
386 func_status box = LyXFunc::ToggleOff;
387 LyXFont font = owner->view()->text->real_current_font;
390 if (font.emph() == LyXFont::ON)
391 box = LyXFunc::ToggleOn;
394 if (font.noun() == LyXFont::ON)
395 box = LyXFunc::ToggleOn;
398 if (font.series() == LyXFont::BOLD_SERIES)
399 box = LyXFunc::ToggleOn;
402 if (font.latex() == LyXFont::ON)
403 box = LyXFunc::ToggleOn;
406 if (font.direction() == LyXFont::RTL_DIR)
407 box = LyXFunc::ToggleOn;
420 string LyXFunc::Dispatch(string const & s)
422 // Split command string into command and argument
423 string cmd, line = frontStrip(s);
424 string arg = strip(frontStrip(split(line, cmd, ' ')));
426 return Dispatch(lyxaction.LookupFunc(cmd.c_str()), arg.c_str());
430 string LyXFunc::Dispatch(int ac,
431 char const * do_not_use_this_arg)
436 // we have not done anything wrong yet.
438 dispatch_buffer.clear();
440 // if action is a pseudo-action, we need the real action
441 if (lyxaction.isPseudoAction(ac)) {
443 action = static_cast<kb_action>
444 (lyxaction.retrieveActionArg(ac, tmparg));
448 action = static_cast<kb_action>(ac);
449 if (do_not_use_this_arg)
450 argument = do_not_use_this_arg; // except here
453 selection_possible = false;
455 if (owner->view()->available())
456 owner->view()->hideCursor();
458 // We cannot use this function here
459 if (getStatus(action) & Disabled)
460 goto exit_with_message;
462 commandshortcut.clear();
464 if (lyxrc->display_shortcuts && show_sc) {
465 if (action != LFUN_SELFINSERT) {
466 // Put name of command and list of shortcuts
467 // for it in minibuffer
468 string comname = lyxaction.getActionName(action);
470 int pseudoaction = action;
471 bool argsadded = false;
473 if (!argument.empty()) {
474 // If we have the command with argument,
477 lyxaction.searchActionArg(action,
480 if (pseudoaction == -1) {
481 pseudoaction = action;
483 comname += " " + argument;
488 string shortcuts = toplevel_keymap->findbinding(pseudoaction);
490 if (!shortcuts.empty()) {
491 comname += ": " + shortcuts;
492 } else if (!argsadded) {
493 comname += " " + argument;
496 if (!comname.empty()) {
497 comname = strip(comname);
498 commandshortcut = "(" + comname + ')';
499 owner->getMiniBuffer()->Set(commandshortcut);
500 // Here we could even add a small pause,
501 // to annoy the user and make him learn
503 // No! That will just annoy, not teach
504 // anything. The user will read the messages
505 // if they are interested. (Asger)
510 // If in math mode pass the control to
511 // the math inset [asierra060396]
512 if (owner->view()->available() &&
513 owner->view()->the_locking_inset) {
515 || (action == LFUN_UNKNOWN_ACTION
516 && keyseq.length >= -1)) {
517 if (action == LFUN_UNKNOWN_ACTION
518 && argument.empty()) {
519 argument = keyseq.getiso();
521 // Undo/Redo pre 0.13 is a bit tricky for insets.
522 if (action == LFUN_UNDO) {
524 UpdatableInset * inset =
525 owner->view()->the_locking_inset;
526 inset->GetCursorPos(slx, sly);
527 owner->view()->unlockInset(inset);
528 owner->view()->menuUndo();
529 inset = static_cast<UpdatableInset*>(owner->view()->text->cursor.par->GetInset(owner->view()->text->cursor.pos));
531 inset->Edit(owner->view(), slx, sly);
534 if (action == LFUN_REDO) {
536 UpdatableInset * inset = owner->view()->the_locking_inset;
537 inset->GetCursorPos(slx, sly);
538 owner->view()->unlockInset(inset);
539 owner->view()->menuRedo();
540 inset = static_cast<UpdatableInset*>(owner->view()->text->cursor.par->GetInset(owner->view()->text->cursor.pos));
542 inset->Edit(owner->view(),
546 if (owner->view()->the_locking_inset->LocalDispatch(owner->view(), action, argument.c_str()))
549 setMessage(N_("Text mode"));
550 LyXDirection direction = owner->view()->text->cursor.par->getParDirection();
552 (action == LFUN_RIGHT
553 && direction == LYX_DIR_LEFT_TO_RIGHT)) {
554 owner->view()->text->CursorRight();
555 moveCursorUpdate(false);
556 owner->getMiniBuffer()->Set(CurrentState());
558 if ( action == LFUN_LEFT
559 && direction == LYX_DIR_RIGHT_TO_LEFT) {
560 owner->view()->text->CursorRight();
561 moveCursorUpdate(false);
562 owner->getMiniBuffer()->Set(CurrentState());
564 if (action == LFUN_LEFT || action == LFUN_RIGHT)
571 // --- Misc -------------------------------------------
572 case LFUN_WORDFINDFORWARD :
573 case LFUN_WORDFINDBACKWARD : {
574 static string last_search;
575 string searched_string;
577 if (!argument.empty()) {
578 last_search = argument;
579 searched_string = argument;
581 searched_string = last_search;
584 LyXText * ltCur = owner->view()->text ;
586 if (!searched_string.empty() &&
587 ((action == LFUN_WORDFINDBACKWARD) ?
588 ltCur->SearchBackward(searched_string.c_str()) :
589 ltCur->SearchForward(searched_string.c_str()))) {
591 // ??? What is that ???
592 owner->view()->update(-2);
595 // clear the selection (if there is any)
596 owner->view()->toggleSelection();
597 owner->view()->text->ClearSelection();
599 // Move cursor so that successive C-s 's will not stand in place.
600 if( action == LFUN_WORDFINDFORWARD )
601 owner->view()->text->CursorRightOneWord();
602 owner->view()->text->FinishUndo();
603 moveCursorUpdate(false);
606 // set the new selection
607 // SetSelectionOverLenChars(owner->view()->currentBuffer()->text, iLenSelected);
608 owner->view()->toggleSelection(false);
612 // REMOVED : if (owner->view()->getWorkArea()->focus)
613 owner->view()->showCursor();
619 if (owner->view()->available()) {
620 owner->view()->update(-2);
623 keyseq.print(buf, true);
624 owner->getMiniBuffer()->Set(buf, string(), string(), 1);
628 // --- Misc -------------------------------------------
629 case LFUN_EXEC_COMMAND:
630 owner->getMiniBuffer()->ExecCommand();
633 case LFUN_CANCEL: // RVDK_PATCH_5
636 if(owner->view()->available())
637 // cancel any selection
638 Dispatch(LFUN_MARK_OFF, 0);
639 setMessage(N_("Cancel"));
642 case LFUN_META_FAKE: // RVDK_PATCH_5
644 meta_fake_bit = Mod1Mask;
646 keyseq.print(buf, true);
647 string res = string("M-") + buf;
648 setMessage(buf); // RVDK_PATCH_5
652 case LFUN_READ_ONLY_TOGGLE:
653 if (owner->buffer()->lyxvc.inUse()) {
654 owner->buffer()->lyxvc.toggleReadOnly();
656 owner->buffer()->setReadonly(
657 !owner->buffer()->isReadonly());
661 case LFUN_CENTER: // this is center and redraw.
662 owner->view()->center();
664 owner->view()->beforeChange();
665 if (owner->view()->text->cursor.y >
666 owner->view()->getWorkArea()->height() / 2)
668 owner->view()->getScreen()->
669 Draw(owner->view()->text->cursor.y -
670 owner->view()->getWorkArea()->height() / 2
673 owner->view()->getScreen()->
676 owner->view()->update(0);
677 owner->view()->redraw();
682 if (owner->view()->available()) {
683 owner->view()->text->toggleAppendix();
684 owner->view()->update(1);
688 // --- Menus -----------------------------------------------
693 case LFUN_MENUNEWTMPLT:
701 case LFUN_CLOSEBUFFER:
706 owner->getMiniBuffer()->Set(_("Saving document"),
707 MakeDisplayPath(owner->buffer()->fileName()),
709 MenuWrite(owner->buffer());
710 //owner->getMiniBuffer()->
711 // Set(_("Document saved as"),
712 // MakeDisplayPath(owner->buffer()->fileName()));
714 //owner->getMiniBuffer()->Set(_("Save failed!"));
718 case LFUN_MENUWRITEAS:
719 MenuWriteAs(owner->buffer());
722 case LFUN_MENURELOAD:
727 PreviewDVI(owner->buffer());
731 PreviewPostscript(owner->buffer());
735 MenuRunLaTeX(owner->buffer());
739 MenuBuildProg(owner->buffer());
743 MenuRunChktex(owner->buffer());
747 CreatePostscript(owner->buffer(), false);
751 MenuPrint(owner->buffer());
755 MenuFax(owner->buffer());
759 MenuExport(owner->buffer(), argument);
764 //needs argument as string
765 string imtyp = argument;
768 if (imtyp == "latex") {
769 doImportLaTeX(false);
772 else if (imtyp == "ascii") {
773 doImportASCII(false);
774 } else if (imtyp == "asciiparagraph") {
777 } else if (imtyp == "noweb") {
780 setErrorMessage(string(N_("Unknown import type: "))
792 if (fd_form_toc->form_toc->visible) {
793 fl_raise_form(fd_form_toc->form_toc);
795 static int ow = -1, oh;
796 fl_show_form(fd_form_toc->form_toc,
798 FL_FREE_SIZE, FL_FULLBORDER,
799 _("Table of Contents"));
801 ow = fd_form_toc->form_toc->w;
802 oh = fd_form_toc->form_toc->h;
804 fl_set_form_minsize(fd_form_toc->form_toc, ow, oh);
808 case LFUN_TOC_INSERT:
810 Inset * new_inset = new InsetTOC(owner->buffer());
811 owner->view()->insertInset(new_inset, "Standard", true);
815 case LFUN_LOF_INSERT:
817 Inset * new_inset = new InsetLOF(owner->buffer());
818 owner->view()->insertInset(new_inset, "Standard", true);
822 case LFUN_LOA_INSERT:
824 Inset * new_inset = new InsetLOA(owner->buffer());
825 owner->view()->insertInset(new_inset, "Standard", true);
829 case LFUN_LOT_INSERT:
831 Inset * new_inset = new InsetLOT(owner->buffer());
832 owner->view()->insertInset(new_inset, "Standard", true);
849 owner->view()->menuUndo();
853 owner->view()->menuRedo();
856 case LFUN_MENUSEARCH:
861 owner->view()->paste();
864 case LFUN_PASTESELECTION:
867 if (argument == "paragraph") asPara = true;
868 MenuPasteSelection(asPara);
873 owner->view()->cut();
877 owner->view()->copy();
880 case LFUN_LAYOUT_COPY:
881 owner->view()->copyEnvironment();
884 case LFUN_LAYOUT_PASTE:
885 owner->view()->pasteEnvironment();
889 owner->view()->gotoError();
892 case LFUN_REMOVEERRORS:
893 if (owner->view()->removeAutoInsets()) {
894 owner->view()->redraw();
895 owner->view()->fitCursor();
896 owner->view()->updateScrollbar();
901 owner->view()->gotoNote();
905 owner->view()->openStuff();
908 case LFUN_HYPHENATION:
909 owner->view()->hyphenationPoint();
913 owner->view()->ldots();
916 case LFUN_END_OF_SENTENCE:
917 owner->view()->endOfSentenceDot();
920 case LFUN_MENU_SEPARATOR:
921 owner->view()->menuSeparator();
925 owner->view()->hfill();
929 changeDepth(owner->view(), 0);
933 changeDepth(owner->view(), -1);
936 case LFUN_DEPTH_PLUS:
937 changeDepth(owner->view(), 1);
946 owner->view()->setState();
947 owner->getMiniBuffer()->Set(CurrentState());
954 case LFUN_RECONFIGURE:
955 Reconfigure(owner->view());
959 if (owner->view()->available()
960 && !owner->view()->text->selection
961 && owner->view()->text->cursor.par->footnoteflag
962 != LyXParagraph::NO_FOOTNOTE)
963 { // only melt footnotes with FOOTMELT, not margins etc
964 if(owner->view()->text->cursor.par->footnotekind == LyXParagraph::FOOTNOTE)
969 owner->view()->setState();
972 case LFUN_MARGINMELT:
973 if (owner->view()->available()
974 && !owner->view()->text->selection
975 && owner->view()->text->cursor.par->footnoteflag
976 != LyXParagraph::NO_FOOTNOTE) {
978 if(owner->view()->text->cursor.par->footnotekind == LyXParagraph::MARGIN)
981 Margin(owner->view());
982 owner->view()->setState();
985 // --- version control -------------------------------
986 case LFUN_VC_REGISTER:
988 if (!owner->buffer()->lyxvc.inUse())
989 owner->buffer()->lyxvc.registrer();
993 case LFUN_VC_CHECKIN:
995 if (owner->buffer()->lyxvc.inUse()
996 && !owner->buffer()->isReadonly())
997 owner->buffer()->lyxvc.checkIn();
1001 case LFUN_VC_CHECKOUT:
1003 if (owner->buffer()->lyxvc.inUse()
1004 && owner->buffer()->isReadonly())
1005 owner->buffer()->lyxvc.checkOut();
1009 case LFUN_VC_REVERT:
1011 owner->buffer()->lyxvc.revert();
1017 owner->buffer()->lyxvc.undoLast();
1021 case LFUN_VC_HISTORY:
1023 owner->buffer()->lyxvc.showLog();
1027 // --- buffers ----------------------------------------
1029 case LFUN_FILE_INSERT:
1031 MenuInsertLyXFile(argument);
1035 case LFUN_FILE_INSERT_ASCII:
1037 bool asPara = (argument == "paragraph");
1038 InsertAsciiFile(string(), asPara);
1044 // servercmd: argument must be <file>:<template>
1045 Buffer * tmpbuf = NewLyxFile(argument);
1047 owner->view()->buffer(tmpbuf);
1051 case LFUN_FILE_OPEN:
1052 owner->view()->buffer(bufferlist.loadLyXFile(argument));
1055 case LFUN_LATEX_LOG:
1061 lyxerr.debug() << "LFUN_LAYOUTNO: (arg) " << argument << endl;
1062 int sel = strToInt(argument);
1063 lyxerr.debug() << "LFUN_LAYOUTNO: (sel) "<< sel << endl;
1065 // Should this give a setMessage instead?
1067 return string(); // illegal argument
1069 --sel; // sel 1..., but layout 0...
1071 // Pretend we got the name instead.
1072 Dispatch(int(LFUN_LAYOUT),
1073 textclasslist.NameOfLayout(owner->view()->
1082 lyxerr.debug() << "LFUN_LAYOUT: (arg) "
1083 << argument << endl;
1085 // Derive layout number from given argument (string)
1086 // and current buffer's textclass (number). */
1087 LyXTextClassList::ClassList::size_type tclass =
1088 owner->view()->text->parameters->textclass;
1089 pair <bool, int> layout =
1090 textclasslist.NumberOfLayout(tclass, argument);
1092 // If the entry is obsolete, use the new one instead.
1094 string obs = textclasslist.Style(tclass,layout.second)
1098 textclasslist.NumberOfLayout(tclass, obs);
1101 // see if we found the layout number:
1102 if (!layout.first) {
1103 setErrorMessage(string(N_("Layout ")) + argument +
1108 if (current_layout != layout.second) {
1109 owner->view()->hideCursor();
1110 current_layout = layout.second;
1111 owner->view()->update(-2);
1112 owner->view()->text->
1113 SetLayout(layout.second);
1114 owner->getToolbar()->combox->
1115 select(owner->view()->
1118 owner->view()->update(1);
1123 case LFUN_LAYOUT_DOCUMENT:
1124 MenuLayoutDocument();
1127 case LFUN_LAYOUT_PARAGRAPH:
1128 MenuLayoutParagraph();
1131 case LFUN_LAYOUT_CHARACTER:
1132 MenuLayoutCharacter();
1135 case LFUN_LAYOUT_TABLE:
1138 if (argument == "true") flag = 1;
1139 MenuLayoutTable(flag);
1143 case LFUN_LAYOUT_PAPER:
1147 case LFUN_LAYOUT_QUOTES:
1151 case LFUN_LAYOUT_PREAMBLE:
1152 MenuLayoutPreamble();
1155 case LFUN_LAYOUT_SAVE_DEFAULT:
1159 case LFUN_DROP_LAYOUTS_CHOICE:
1160 owner->getToolbar()->combox->Show();
1166 owner->view()->setState();
1167 owner->getMiniBuffer()->Set(CurrentState());
1199 case LFUN_UNDERLINE:
1203 case LFUN_FONT_SIZE:
1207 case LFUN_FONT_STATE:
1208 setMessage(CurrentState());
1211 case LFUN_UPCASE_WORD:
1212 owner->view()->update(-2);
1214 owner->view()->text->ChangeWordCase(LyXText::text_uppercase);
1215 owner->view()->update(1);
1219 case LFUN_LOWCASE_WORD:
1220 owner->view()->update(-2);
1222 owner->view()->text->ChangeWordCase(LyXText::text_lowercase);
1223 owner->view()->update(1);
1227 case LFUN_CAPITALIZE_WORD:
1228 owner->view()->update(-2);
1230 owner->view()->text->ChangeWordCase(LyXText::text_capitalization);
1231 owner->view()->update(1);
1235 case LFUN_INSERT_LABEL:
1236 MenuInsertLabel(argument.c_str());
1239 case LFUN_INSERT_REF:
1243 case LFUN_REFTOGGLE:
1246 static_cast<InsetRef*>(getInsetByCode(Inset::REF_CODE));
1248 if (inset->getFlag() == InsetRef::REF)
1249 inset->setFlag(InsetRef::PAGE_REF);
1251 inset->setFlag(InsetRef::REF);
1252 UpdateInset(owner->view(), inset);
1254 setErrorMessage(N_("No cross-reference to toggle"));
1261 owner->view()->restorePosition();
1267 string label(argument);
1268 if (label.empty()) {
1270 static_cast<InsetRef*>(getInsetByCode(Inset::REF_CODE));
1272 label = inset->getContents();
1275 if (!label.empty()) {
1276 owner->view()->savePosition();
1277 owner->view()->gotoLabel(label.c_str());
1282 case LFUN_MENU_OPEN_BY_NAME:
1283 owner->getMenus()->openByName(argument);
1284 break; // RVDK_PATCH_5
1286 case LFUN_SPELLCHECK:
1287 if (lyxrc->isp_command != "none")
1288 ShowSpellChecker(owner->view());
1289 break; // RVDK_PATCH_5
1291 // --- Cursor Movements -----------------------------
1294 LyXText * tmptext = owner->view()->text;
1295 LyXDirection direction =
1296 tmptext->cursor.par->getParDirection();
1297 if(!tmptext->mark_set)
1298 owner->view()->beforeChange();
1299 owner->view()->update(-2);
1300 if (direction == LYX_DIR_RIGHT_TO_LEFT)
1301 tmptext->CursorLeft();
1302 if (tmptext->cursor.pos < tmptext->cursor.par->Last()
1303 && tmptext->cursor.par->GetChar(tmptext->cursor.pos)
1304 == LyXParagraph::META_INSET
1305 && tmptext->cursor.par->GetInset(tmptext->cursor.pos)
1306 && tmptext->cursor.par->GetInset(tmptext->cursor.pos)->Editable() == 2){
1307 Inset * tmpinset = tmptext->cursor.par->GetInset(tmptext->cursor.pos);
1308 setMessage(tmpinset->EditMessage());
1309 tmpinset->Edit(owner->view(), 0, 0);
1312 if (direction == LYX_DIR_LEFT_TO_RIGHT)
1313 tmptext->CursorRight();
1314 owner->view()->text->FinishUndo();
1315 moveCursorUpdate(false);
1316 owner->getMiniBuffer()->Set(CurrentState());
1322 // This is soooo ugly. Isn`t it possible to make
1323 // it simpler? (Lgb)
1324 LyXText * txt = owner->view()->text;
1325 LyXDirection direction = txt->cursor.par->getParDirection();
1326 if(!txt->mark_set) owner->view()->beforeChange();
1327 owner->view()->update(-2);
1328 if (direction == LYX_DIR_LEFT_TO_RIGHT)
1330 if (txt->cursor.pos < txt->cursor.par->Last()
1331 && txt->cursor.par->GetChar(txt->cursor.pos)
1332 == LyXParagraph::META_INSET
1333 && txt->cursor.par->GetInset(txt->cursor.pos)
1334 && txt->cursor.par->GetInset(txt->cursor.pos)->Editable() == 2) {
1335 Inset * tmpinset = txt->cursor.par->GetInset(txt->cursor.pos);
1336 setMessage(tmpinset->EditMessage());
1337 tmpinset->Edit(owner->view(),
1338 tmpinset->width(owner->view()->painter(),
1339 txt->GetFont(txt->cursor.par,
1340 txt->cursor.pos)), 0);
1343 if (direction == LYX_DIR_RIGHT_TO_LEFT)
1346 owner->view()->text->FinishUndo();
1347 moveCursorUpdate(false);
1348 owner->getMiniBuffer()->Set(CurrentState());
1353 if(!owner->view()->text->mark_set) owner->view()->beforeChange();
1354 owner->view()->update(-3);
1355 owner->view()->text->CursorUp();
1356 owner->view()->text->FinishUndo();
1357 moveCursorUpdate(false);
1358 owner->getMiniBuffer()->Set(CurrentState());
1362 if(!owner->view()->text->mark_set)
1363 owner->view()->beforeChange();
1364 owner->view()->update(-3);
1365 owner->view()->text->CursorDown();
1366 owner->view()->text->FinishUndo();
1367 moveCursorUpdate(false);
1368 owner->getMiniBuffer()->Set(CurrentState());
1371 case LFUN_UP_PARAGRAPH:
1372 if(!owner->view()->text->mark_set)
1373 owner->view()->beforeChange();
1374 owner->view()->update(-3);
1375 owner->view()->text->CursorUpParagraph();
1376 owner->view()->text->FinishUndo();
1377 moveCursorUpdate(false);
1378 owner->getMiniBuffer()->Set(CurrentState());
1381 case LFUN_DOWN_PARAGRAPH:
1382 if(!owner->view()->text->mark_set)
1383 owner->view()->beforeChange();
1384 owner->view()->update(-3);
1385 owner->view()->text->CursorDownParagraph();
1386 owner->view()->text->FinishUndo();
1387 moveCursorUpdate(false);
1388 owner->getMiniBuffer()->Set(CurrentState());
1392 if(!owner->view()->text->mark_set)
1393 owner->view()->beforeChange();
1394 owner->view()->update(-3);
1395 owner->view()->cursorPrevious();
1396 owner->view()->text->FinishUndo();
1397 moveCursorUpdate(false);
1398 owner->getMiniBuffer()->Set(CurrentState());
1402 if(!owner->view()->text->mark_set)
1403 owner->view()->beforeChange();
1404 owner->view()->update(-3);
1405 owner->view()->cursorNext();
1406 owner->view()->text->FinishUndo();
1407 moveCursorUpdate(false);
1408 owner->getMiniBuffer()->Set(CurrentState());
1412 if(!owner->view()->text->mark_set)
1413 owner->view()->beforeChange();
1414 owner->view()->update(-2);
1415 owner->view()->text->CursorHome();
1416 owner->view()->text->FinishUndo();
1417 moveCursorUpdate(false);
1418 owner->getMiniBuffer()->Set(CurrentState());
1422 if(!owner->view()->text->mark_set)
1423 owner->view()->beforeChange();
1424 owner->view()->update(-2);
1425 owner->view()->text->CursorEnd();
1426 owner->view()->text->FinishUndo();
1427 moveCursorUpdate(false);
1428 owner->getMiniBuffer()->Set(CurrentState());
1432 if(!owner->view()->text->mark_set)
1433 owner->view()->beforeChange();
1434 owner->view()->update(-2);
1435 owner->view()->text->CursorTab();
1436 owner->view()->text->FinishUndo();
1437 moveCursorUpdate(false);
1438 owner->getMiniBuffer()->Set(CurrentState());
1441 case LFUN_WORDRIGHT:
1442 if(!owner->view()->text->mark_set)
1443 owner->view()->beforeChange();
1444 owner->view()->update(-2);
1445 if (owner->view()->text->cursor.par->getParDirection()
1446 == LYX_DIR_LEFT_TO_RIGHT)
1447 owner->view()->text->CursorRightOneWord();
1449 owner->view()->text->CursorLeftOneWord();
1450 owner->view()->text->FinishUndo();
1451 moveCursorUpdate(false);
1452 owner->getMiniBuffer()->Set(CurrentState());
1456 if(!owner->view()->text->mark_set)
1457 owner->view()->beforeChange();
1458 owner->view()->update(-2);
1459 if (owner->view()->text->cursor.par->getParDirection()
1460 == LYX_DIR_LEFT_TO_RIGHT)
1461 owner->view()->text->CursorLeftOneWord();
1463 owner->view()->text->CursorRightOneWord();
1464 owner->view()->text->FinishUndo();
1465 moveCursorUpdate(false);
1466 owner->getMiniBuffer()->Set(CurrentState());
1469 case LFUN_BEGINNINGBUF:
1470 if(!owner->view()->text->mark_set)
1471 owner->view()->beforeChange();
1472 owner->view()->update(-2);
1473 owner->view()->text->CursorTop();
1474 owner->view()->text->FinishUndo();
1475 moveCursorUpdate(false);
1476 owner->getMiniBuffer()->Set(CurrentState());
1480 if(!owner->view()->text->mark_set)
1481 owner->view()->beforeChange();
1482 owner->view()->update(-2);
1483 owner->view()->text->CursorBottom();
1484 owner->view()->text->FinishUndo();
1485 moveCursorUpdate(false);
1486 owner->getMiniBuffer()->Set(CurrentState());
1490 /* cursor selection ---------------------------- */
1492 owner->view()->update(-2);
1493 if (owner->view()->text->cursor.par->getParDirection()
1494 == LYX_DIR_LEFT_TO_RIGHT)
1495 owner->view()->text->CursorRight();
1497 owner->view()->text->CursorLeft();
1498 owner->view()->text->FinishUndo();
1499 moveCursorUpdate(true);
1500 owner->getMiniBuffer()->Set(CurrentState());
1504 owner->view()->update(-2);
1505 if (owner->view()->text->cursor.par->getParDirection()
1506 == LYX_DIR_LEFT_TO_RIGHT)
1507 owner->view()->text->CursorLeft();
1509 owner->view()->text->CursorRight();
1510 owner->view()->text->FinishUndo();
1511 moveCursorUpdate(true);
1512 owner->getMiniBuffer()->Set(CurrentState());
1516 owner->view()->update(-2);
1517 owner->view()->text->CursorUp();
1518 owner->view()->text->FinishUndo();
1519 moveCursorUpdate(true);
1520 owner->getMiniBuffer()->Set(CurrentState());
1524 owner->view()->update(-2);
1525 owner->view()->text->CursorDown();
1526 owner->view()->text->FinishUndo();
1527 moveCursorUpdate(true);
1528 owner->getMiniBuffer()->Set(CurrentState());
1531 case LFUN_UP_PARAGRAPHSEL:
1532 owner->view()->update(-2);
1533 owner->view()->text->CursorUpParagraph();
1534 owner->view()->text->FinishUndo();
1535 moveCursorUpdate(true);
1536 owner->getMiniBuffer()->Set(CurrentState());
1539 case LFUN_DOWN_PARAGRAPHSEL:
1540 owner->view()->update(-2);
1541 owner->view()->text->CursorDownParagraph();
1542 owner->view()->text->FinishUndo();
1543 moveCursorUpdate(true);
1544 owner->getMiniBuffer()->Set(CurrentState());
1548 owner->view()->update(-2);
1549 owner->view()->cursorPrevious();
1550 owner->view()->text->FinishUndo();
1551 moveCursorUpdate(true);
1552 owner->getMiniBuffer()->Set(CurrentState());
1556 owner->view()->update(-2);
1557 owner->view()->cursorNext();
1558 owner->view()->text->FinishUndo();
1559 moveCursorUpdate(true);
1560 owner->getMiniBuffer()->Set(CurrentState());
1564 owner->view()->update(-2);
1565 owner->view()->text->CursorHome();
1566 owner->view()->text->FinishUndo();
1567 moveCursorUpdate(true);
1568 owner->getMiniBuffer()->Set(CurrentState());
1572 owner->view()->update(-2);
1573 owner->view()->text->CursorEnd();
1574 owner->view()->text->FinishUndo();
1575 moveCursorUpdate(true);
1576 owner->getMiniBuffer()->Set(CurrentState());
1579 case LFUN_WORDRIGHTSEL:
1580 owner->view()->update(-2);
1581 if (owner->view()->text->cursor.par->getParDirection()
1582 == LYX_DIR_LEFT_TO_RIGHT)
1583 owner->view()->text->CursorRightOneWord();
1585 owner->view()->text->CursorLeftOneWord();
1586 owner->view()->text->FinishUndo();
1587 moveCursorUpdate(true);
1588 owner->getMiniBuffer()->Set(CurrentState());
1591 case LFUN_WORDLEFTSEL:
1592 owner->view()->update(-2);
1593 if (owner->view()->text->cursor.par->getParDirection()
1594 == LYX_DIR_LEFT_TO_RIGHT)
1595 owner->view()->text->CursorLeftOneWord();
1597 owner->view()->text->CursorRightOneWord();
1598 owner->view()->text->FinishUndo();
1599 moveCursorUpdate(true);
1600 owner->getMiniBuffer()->Set(CurrentState());
1603 case LFUN_BEGINNINGBUFSEL:
1604 owner->view()->update(-2);
1605 owner->view()->text->CursorTop();
1606 owner->view()->text->FinishUndo();
1607 moveCursorUpdate(true);
1608 owner->getMiniBuffer()->Set(CurrentState());
1611 case LFUN_ENDBUFSEL:
1612 owner->view()->update(-2);
1613 owner->view()->text->CursorBottom();
1614 owner->view()->text->FinishUndo();
1615 moveCursorUpdate(true);
1616 owner->getMiniBuffer()->Set(CurrentState());
1619 // --- text changing commands ------------------------
1620 case LFUN_BREAKLINE:
1621 owner->view()->beforeChange();
1622 owner->view()->text->InsertChar(LyXParagraph::META_NEWLINE);
1623 owner->view()->smallUpdate(1);
1624 SetUpdateTimer(0.01);
1625 moveCursorUpdate(false);
1628 case LFUN_PROTECTEDSPACE:
1629 owner->view()->beforeChange();
1630 owner->view()->text->
1631 InsertChar(LyXParagraph::META_PROTECTED_SEPARATOR);
1632 owner->view()->smallUpdate(1);
1634 moveCursorUpdate(false);
1638 if(owner->view()->text->mark_set) {
1639 owner->view()->beforeChange();
1640 owner->view()->update(0);
1641 setMessage(N_("Mark removed"));
1643 owner->view()->beforeChange();
1644 owner->view()->text->mark_set = 1;
1645 owner->view()->update(0);
1646 setMessage(N_("Mark set"));
1648 owner->view()->text->sel_cursor =
1649 owner->view()->text->cursor;
1654 if (!owner->view()->text->selection) {
1655 owner->view()->text->Delete();
1656 owner->view()->text->sel_cursor =
1657 owner->view()->text->cursor;
1658 owner->view()->smallUpdate(1);
1659 // It is possible to make it a lot faster still
1660 // just comment out the lone below...
1661 owner->view()->showCursor();
1663 owner->view()->cut();
1666 moveCursorUpdate(false);
1667 owner->getMiniBuffer()->Set(CurrentState());
1668 owner->view()->setState();
1671 case LFUN_DELETE_SKIP:
1673 // Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
1675 LyXCursor cursor = owner->view()->text->cursor;
1678 if (!owner->view()->text->selection) {
1679 if (cursor.pos == cursor.par->Last()) {
1680 owner->view()->text->CursorRight();
1681 cursor = owner->view()->text->cursor;
1683 && !(cursor.par->added_space_top
1684 == VSpace (VSpace::NONE))) {
1685 owner->view()->text->SetParagraph
1686 (cursor.par->line_top,
1687 cursor.par->line_bottom,
1688 cursor.par->pagebreak_top,
1689 cursor.par->pagebreak_bottom,
1690 VSpace(VSpace::NONE),
1691 cursor.par->added_space_bottom,
1693 cursor.par->labelwidthstring, 0);
1694 owner->view()->text->CursorLeft();
1695 owner->view()->update (1);
1697 owner->view()->text->CursorLeft();
1698 owner->view()->text->Delete();
1699 owner->view()->text->sel_cursor =
1700 owner->view()->text->cursor;
1701 owner->view()->smallUpdate(1);
1704 owner->view()->text->Delete();
1705 owner->view()->text->sel_cursor =
1706 owner->view()->text->cursor;
1707 owner->view()->smallUpdate(1);
1710 owner->view()->cut();
1716 /* -------> Delete word forward. */
1717 case LFUN_DELETE_WORD_FORWARD:
1718 owner->view()->update(-2);
1720 owner->view()->text->DeleteWordForward();
1721 owner->view()->update( 1 );
1723 moveCursorUpdate(false);
1724 owner->getMiniBuffer()->Set(CurrentState());
1727 /* -------> Delete word backward. */
1728 case LFUN_DELETE_WORD_BACKWARD:
1729 owner->view()->update(-2);
1731 owner->view()->text->DeleteWordBackward();
1732 owner->view()->update( 1 );
1734 moveCursorUpdate(false);
1735 owner->getMiniBuffer()->Set(CurrentState());
1738 /* -------> Kill to end of line. */
1739 case LFUN_DELETE_LINE_FORWARD:
1741 owner->view()->update(-2);
1742 owner->view()->text->DeleteLineForward();
1743 owner->view()->update( 1 );
1745 moveCursorUpdate(false);
1748 /* -------> Set mark off. */
1750 owner->view()->beforeChange();
1751 owner->view()->update(0);
1752 owner->view()->text->sel_cursor =
1753 owner->view()->text->cursor;
1754 setMessage(N_("Mark off"));
1757 /* -------> Set mark on. */
1759 owner->view()->beforeChange();
1760 owner->view()->text->mark_set = 1;
1761 owner->view()->update( 0 );
1762 owner->view()->text->sel_cursor =
1763 owner->view()->text->cursor;
1764 setMessage(N_("Mark on"));
1767 case LFUN_BACKSPACE:
1770 if (!owner->view()->text->selection) {
1771 if (owner->getIntl()->getTrans()->backspace()) {
1772 owner->view()->text->Backspace();
1773 owner->view()->text->sel_cursor =
1774 owner->view()->text->cursor;
1775 owner->view()->smallUpdate(1);
1776 // It is possible to make it a lot faster still
1777 // just comment out the lone below...
1778 owner->view()->showCursor();
1781 owner->view()->cut();
1784 owner->getMiniBuffer()->Set(CurrentState());
1785 owner->view()->setState();
1789 case LFUN_BACKSPACE_SKIP:
1791 // Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
1793 LyXCursor cursor = owner->view()->text->cursor;
1796 if (!owner->view()->text->selection) {
1798 && !(cursor.par->added_space_top
1799 == VSpace (VSpace::NONE))) {
1800 owner->view()->text->SetParagraph
1801 (cursor.par->line_top,
1802 cursor.par->line_bottom,
1803 cursor.par->pagebreak_top,
1804 cursor.par->pagebreak_bottom,
1805 VSpace(VSpace::NONE), cursor.par->added_space_bottom,
1807 cursor.par->labelwidthstring, 0);
1808 owner->view()->update (1);
1810 owner->view()->text->Backspace();
1811 owner->view()->text->sel_cursor
1813 owner->view()->smallUpdate (1);
1816 owner->view()->cut();
1821 case LFUN_BREAKPARAGRAPH:
1823 owner->view()->beforeChange();
1824 owner->view()->text->BreakParagraph(0);
1825 owner->view()->smallUpdate(1);
1826 SetUpdateTimer(0.01);
1827 owner->view()->text->sel_cursor =
1828 owner->view()->text->cursor;
1829 owner->view()->setState();
1830 owner->getMiniBuffer()->Set(CurrentState());
1834 case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
1836 owner->view()->beforeChange();
1837 owner->view()->text->BreakParagraph(1);
1838 owner->view()->smallUpdate(1);
1839 SetUpdateTimer(0.01);
1840 owner->view()->text->sel_cursor =
1841 owner->view()->text->cursor;
1842 owner->view()->setState();
1843 owner->getMiniBuffer()->Set(CurrentState());
1847 case LFUN_BREAKPARAGRAPH_SKIP:
1849 // When at the beginning of a paragraph, remove
1850 // indentation and add a "defskip" at the top.
1851 // Otherwise, do the same as LFUN_BREAKPARAGRAPH.
1853 LyXCursor cursor = owner->view()->text->cursor;
1855 owner->view()->beforeChange();
1856 if (cursor.pos == 0) {
1857 if (cursor.par->added_space_top == VSpace(VSpace::NONE)) {
1858 owner->view()->text->SetParagraph
1859 (cursor.par->line_top,
1860 cursor.par->line_bottom,
1861 cursor.par->pagebreak_top,
1862 cursor.par->pagebreak_bottom,
1863 VSpace(VSpace::DEFSKIP), cursor.par->added_space_bottom,
1865 cursor.par->labelwidthstring, 1);
1866 owner->view()->update(1);
1870 owner->view()->text->BreakParagraph(0);
1871 owner->view()->smallUpdate(1);
1873 SetUpdateTimer(0.01);
1874 owner->view()->text->sel_cursor = cursor;
1875 owner->view()->setState();
1876 owner->getMiniBuffer()->Set(CurrentState());
1881 owner->view()->beforeChange();
1882 owner->view()->text->InsertChar('\"'); // This " matches the single quote in the code
1883 owner->view()->smallUpdate(1);
1885 moveCursorUpdate(false);
1891 InsetCommand * new_inset;
1892 if (action == LFUN_HTMLURL)
1893 new_inset = new InsetUrl("htmlurl", "", "");
1895 new_inset = new InsetUrl("url", "", "");
1896 owner->view()->insertInset(new_inset);
1897 new_inset->Edit(owner->view(), 0, 0);
1901 // --- lyxserver commands ----------------------------
1903 case LFUN_CHARATCURSOR:
1905 LyXParagraph::size_type pos =
1906 owner->view()->text->cursor.pos;
1907 if(pos < owner->view()->text->cursor.par->size())
1908 dispatch_buffer = owner->view()->text->
1909 cursor.par->text[pos];
1911 dispatch_buffer = "EOF";
1917 tostr(owner->view()->text->cursor.x) + ' '
1918 + tostr(owner->view()->text->cursor.y);
1925 sscanf(argument.c_str(), " %d %ld", &x, &y);
1926 owner->view()->text->SetCursorFromCoordinates(x, y);
1930 case LFUN_GETLAYOUT:
1932 tostr(owner->view()->text->cursor.par->layout);
1937 LyXFont * font = &(owner->view()->text->current_font);
1938 if(font->shape() == LyXFont::ITALIC_SHAPE)
1939 dispatch_buffer = 'E';
1940 else if(font->shape() == LyXFont::SMALLCAPS_SHAPE)
1941 dispatch_buffer = 'N';
1943 dispatch_buffer = '0';
1950 LyXFont * font = &(owner->view()->text->current_font);
1951 if(font->latex() == LyXFont::ON)
1952 dispatch_buffer = 'L';
1954 dispatch_buffer = '0';
1959 setMessage(owner->buffer()->fileName());
1960 lyxerr.debug() << "FNAME["
1961 << owner->buffer()->fileName()
1969 dispatch_buffer = buf;
1970 lyxserver->notifyClient(dispatch_buffer);
1974 case LFUN_GOTOFILEROW:
1976 char file_name[100];
1978 sscanf(argument.c_str(), " %s %d", file_name, &row);
1980 // Must replace extension of the file to be .lyx and get full path
1981 string s = ChangeExtension(string(file_name), ".lyx", false);
1983 // Either change buffer or load the file
1984 if (bufferlist.exists(s))
1985 owner->view()->buffer(bufferlist.getBuffer(s));
1987 owner->view()->buffer(bufferlist.loadLyXFile(s));
1990 owner->view()->setCursorFromRow(row);
1993 owner->view()->center();
2000 int qa = lyxaction.LookupFunc(argument.c_str());
2001 setMessage(lyxaction.helpText(static_cast<kb_action>(qa)));
2005 // --- accented characters ---------------------------
2008 case LFUN_CIRCUMFLEX:
2018 case LFUN_SPECIAL_CARON:
2021 case LFUN_HUNG_UMLAUT:
2027 if (keyseq.length == -1 && keyseq.getiso() != 0)
2028 c = keyseq.getiso();
2032 owner->getIntl()->getTrans()->
2033 deadkey(c, get_accent(action).accent,
2034 owner->view()->text);
2036 // Need to reset, in case the minibuffer calls these
2041 // copied verbatim from do_accent_char
2042 owner->view()->smallUpdate(1);
2044 owner->view()->text->sel_cursor =
2045 owner->view()->text->cursor;
2049 // --- toolbar ----------------------------------
2050 case LFUN_PUSH_TOOLBAR:
2052 int nth = strToInt(argument);
2053 if (lyxerr.debugging(Debug::TOOLBAR)) {
2054 lyxerr << "LFUN_PUSH_TOOLBAR: argument = `"
2055 << argument << "'\n"
2056 << "LFUN_PUSH_TOOLBAR: nth = `"
2057 << nth << "'" << endl;
2062 setErrorMessage(N_("Push-toolbar needs argument > 0"));
2064 owner->getToolbar()->push(nth);
2069 case LFUN_ADD_TO_TOOLBAR:
2071 if (lyxerr.debugging(Debug::TOOLBAR)) {
2072 lyxerr << "LFUN_ADD_TO_TOOLBAR:"
2073 "argument = `" << argument << '\'' << endl;
2075 string tmp(argument);
2076 //lyxerr <<string("Argument: ") + argument);
2077 //lyxerr <<string("Tmp : ") + tmp);
2080 setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
2082 owner->getToolbar()->add(argument, false);
2083 owner->getToolbar()->set();
2088 // --- insert characters ----------------------------------------
2090 // --- Mathed stuff. If we are here, there is no locked inset yet.
2095 if (!greek_kb_flag) {
2097 setMessage(N_("Math greek mode on"));
2104 case LFUN_GREEK_TOGGLE:
2106 greek_kb_flag = greek_kb_flag ? 0 : 2;
2107 if (greek_kb_flag) {
2108 setMessage(N_("Math greek keyboard on"));
2110 setMessage(N_("Math greek keyboard off"));
2115 case LFUN_MATH_DELIM:
2116 case LFUN_INSERT_MATRIX:
2118 if (owner->view()->available()) {
2120 open_new_inset(new InsetFormula(false));
2122 the_locking_inset->LocalDispatch(owner->view(),
2129 case LFUN_INSERT_MATH:
2131 math_insert_symbol(argument.c_str());
2135 case LFUN_MATH_DISPLAY:
2137 if (owner->view()->available())
2138 owner->view()->open_new_inset(new InsetFormula(true));
2142 case LFUN_MATH_MACRO:
2144 if (owner->view()->available()) {
2147 setErrorMessage(N_("Missing argument"));
2149 string s1 = token(s, ' ', 1);
2150 int na = s1.empty() ? 0: atoi(s1.c_str());
2152 open_new_inset(new InsetFormulaMacro(token(s, ' ', 0), na));
2158 case LFUN_MATH_MODE: // Open or create a math inset
2161 if (owner->view()->available())
2162 owner->view()->open_new_inset(new InsetFormula);
2163 setMessage(N_("Math editor mode"));
2167 case LFUN_MATH_NUMBER:
2168 case LFUN_MATH_LIMITS:
2170 setErrorMessage(N_("This is only allowed in math mode!"));
2174 case LFUN_INSERT_CITATION:
2176 InsetCitation * new_inset = new InsetCitation();
2178 // The note, if any, must be after the key, delimited
2179 // by a | so both key and remark can have spaces.
2180 if (!argument.empty()) {
2181 string lsarg(argument);
2182 if (contains(lsarg, "|")) {
2183 new_inset->setContents(token(lsarg, '|', 0));
2184 new_inset->setOptions(token(lsarg, '|', 1));
2186 new_inset->setContents(lsarg);
2187 owner->view()->insertInset(new_inset);
2189 owner->view()->insertInset(new_inset);
2190 new_inset->Edit(owner->view(), 0, 0);
2195 case LFUN_INSERT_BIBTEX:
2197 // ale970405+lasgoutt970425
2198 // The argument can be up to two tokens separated
2199 // by a space. The first one is the bibstyle.
2200 string lsarg(argument);
2201 string bibstyle = token(lsarg, ' ', 1);
2202 if (bibstyle.empty())
2204 InsetBibtex * new_inset
2205 = new InsetBibtex(token(lsarg, ' ', 0),
2209 owner->view()->insertInset(new_inset);
2210 if (lsarg.empty()) {
2211 new_inset->Edit(owner->view(), 0, 0);
2216 // BibTeX data bases
2217 case LFUN_BIBDB_ADD:
2219 InsetBibtex * inset =
2220 static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
2222 inset->addDatabase(argument);
2227 case LFUN_BIBDB_DEL:
2229 InsetBibtex * inset =
2230 static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
2232 inset->delDatabase(argument);
2237 case LFUN_BIBTEX_STYLE:
2239 InsetBibtex * inset =
2240 static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
2242 inset->setOptions(argument);
2247 case LFUN_INDEX_INSERT:
2248 case LFUN_INDEX_INSERT_LAST:
2250 // Can't do that at the beginning of a paragraph.
2251 if (owner->view()->text->cursor.pos - 1 < 0)
2254 InsetIndex * new_inset = new InsetIndex();
2255 if (!argument.empty()) {
2256 string lsarg(argument);
2257 new_inset->setContents(lsarg);
2258 owner->view()->insertInset(new_inset);
2261 //get the current word for an argument
2262 LyXParagraph::size_type lastpos =
2263 owner->view()->text->cursor.pos - 1;
2264 // Get the current word. note that this must be done
2265 // before inserting the inset, or the inset will
2267 string curstring(owner->view()
2268 ->text->cursor.par->GetWord(lastpos));
2270 //make the new inset and write the current word into it
2271 InsetIndex * new_inset = new InsetIndex();
2273 new_inset->setContents(curstring);
2275 //don't edit it if the call was to INSERT_LAST
2276 if(action != LFUN_INDEX_INSERT_LAST) {
2277 new_inset->Edit(owner->view(), 0, 0);
2279 //it looks blank on the screen unless
2280 //we do something. put it here.
2282 // move the cursor to the returned value of lastpos
2283 // but only for the auto-insert
2284 owner->view()->text->cursor.pos = lastpos;
2287 //put the new inset into the buffer.
2288 // there should be some way of knowing the user
2289 //cancelled & avoiding this, but i don't know how
2290 owner->view()->insertInset(new_inset);
2295 case LFUN_INDEX_PRINT:
2297 Inset * new_inset = new InsetPrintIndex(owner->buffer());
2298 owner->view()->insertInset(new_inset, "Standard", true);
2302 case LFUN_PARENTINSERT:
2304 lyxerr << "arg " << argument << endl;
2305 Inset * new_inset = new InsetParent(argument, owner->buffer());
2306 owner->view()->insertInset(new_inset, "Standard", true);
2310 case LFUN_CHILDINSERT:
2312 Inset * new_inset = new InsetInclude(argument,
2314 owner->view()->insertInset(new_inset, "Standard", true);
2315 new_inset->Edit(owner->view(), 0, 0);
2319 case LFUN_CHILDOPEN:
2322 MakeAbsPath(argument,
2323 OnlyPath(owner->buffer()->fileName()));
2324 setMessage(N_("Opening child document ") +
2325 MakeDisplayPath(filename) + "...");
2326 owner->view()->savePosition();
2327 if (bufferlist.exists(filename))
2328 owner->view()->buffer(bufferlist.getBuffer(filename));
2330 owner->view()->buffer(bufferlist.loadLyXFile(filename));
2334 case LFUN_INSERT_NOTE:
2335 owner->view()->insertNote();
2338 case LFUN_INSERTFOOTNOTE:
2340 LyXParagraph::footnote_kind kind;
2341 if (argument == "footnote")
2342 { kind = LyXParagraph::FOOTNOTE; }
2343 else if (argument == "margin")
2344 { kind = LyXParagraph::MARGIN; }
2345 else if (argument == "figure")
2346 { kind = LyXParagraph::FIG; }
2347 else if (argument == "table")
2348 { kind = LyXParagraph::TAB; }
2349 else if (argument == "wide-fig")
2350 { kind = LyXParagraph::WIDE_FIG; }
2351 else if (argument == "wide-tab")
2352 { kind = LyXParagraph::WIDE_TAB; }
2353 else if (argument == "algorithm")
2354 { kind = LyXParagraph::ALGORITHM; }
2356 setErrorMessage(N_("Unknown kind of footnote"));
2359 owner->view()->text->InsertFootnoteEnvironment(kind);
2360 owner->view()->update(1);
2361 owner->view()->setState();
2365 case LFUN_BUFFERBULLETSSELECT:
2369 case LFUN_TOGGLECURSORFOLLOW:
2370 cursor_follows_scrollbar = !cursor_follows_scrollbar;
2373 case LFUN_KMAP_OFF: // keymap off
2374 owner->getIntl()->KeyMapOn(false);
2377 case LFUN_KMAP_PRIM: // primary keymap
2378 owner->getIntl()->KeyMapPrim();
2381 case LFUN_KMAP_SEC: // secondary keymap
2382 owner->getIntl()->KeyMapSec();
2385 case LFUN_KMAP_TOGGLE: // toggle keymap
2386 owner->getIntl()->ToggleKeyMap();
2389 case LFUN_SELFINSERT:
2391 for (string::size_type i = 0; i < argument.length(); ++i) {
2392 owner->view()->text->InsertChar(argument[i]);
2393 // This needs to be in the loop, or else we
2394 // won't break lines correctly. (Asger)
2395 owner->view()->smallUpdate(1);
2398 owner->view()->text->sel_cursor =
2399 owner->view()->text->cursor;
2400 moveCursorUpdate(false);
2406 // argument contains ';'-terminated commands
2407 while (argument.find(';') != string::npos) {
2409 argument = split(argument, first, ';');
2415 case LFUN_DATE_INSERT: // jdblair: date-insert cmd
2423 now_time_t = time(NULL);
2424 now_tm = localtime(&now_time_t);
2425 (void)setlocale(LC_TIME, "");
2426 if (!argument.empty())
2428 else if (arg.empty())
2429 arg = lyxrc->date_insert_format;
2430 datetmp_len = (int) strftime(datetmp, 32, arg.c_str(), now_tm);
2431 for (int i = 0; i < datetmp_len; i++) {
2432 owner->view()->text->InsertChar(datetmp[i]);
2433 owner->view()->smallUpdate(1);
2436 owner->view()->text->sel_cursor = owner->view()->text->cursor;
2437 moveCursorUpdate(false);
2441 case LFUN_SAVEPREFERENCES:
2443 Path p(user_lyxdir);
2444 lyxrc->write("preferences");
2448 case LFUN_UNKNOWN_ACTION:
2450 if(!owner->buffer()) {
2452 setErrorMessage(N_("No document open"));
2456 if (owner->buffer()->isReadonly()) {
2458 setErrorMessage(N_("Document is read only"));
2462 if (!argument.empty()) {
2464 /* Automatically delete the currently selected
2465 * text and replace it with what is being
2466 * typed in now. Depends on lyxrc settings
2467 * "auto_region_delete", which defaults to
2470 if ( lyxrc->auto_region_delete ) {
2471 if (owner->view()->text->selection){
2472 owner->view()->text->CutSelection(false);
2473 owner->view()->update(-1);
2477 owner->view()->beforeChange();
2478 for (string::size_type i = 0;
2479 i < argument.length(); ++i) {
2480 if (greek_kb_flag) {
2481 if (!math_insert_greek(argument[i]))
2482 owner->getIntl()->getTrans()->TranslateAndInsert(argument[i], owner->view()->text);
2484 owner->getIntl()->getTrans()->TranslateAndInsert(argument[i], owner->view()->text);
2487 owner->view()->smallUpdate(1);
2490 owner->view()->text->sel_cursor =
2491 owner->view()->text->cursor;
2492 moveCursorUpdate(false);
2495 // why is an "Unknown action" with empty
2496 // argument even dispatched in the first
2497 // place? I`ll probably change that. (Lgb)
2499 setErrorMessage(N_("Unknown action"));
2503 lyxerr << "A truly unknown func!" << endl;
2509 string res = getMessage();
2512 if (!commandshortcut.empty()) {
2513 string newbuf = owner->getMiniBuffer()->GetText();
2514 if (newbuf != commandshortcut) {
2515 owner->getMiniBuffer()->Set(newbuf
2521 owner->getMiniBuffer()->Set(string(_(res.c_str()))
2522 + " " + commandshortcut);
2529 void LyXFunc::setupLocalKeymap()
2531 keyseq.stdmap = keyseq.curmap = toplevel_keymap;
2532 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap;
2536 void LyXFunc::MenuNew(bool fromTemplate)
2538 string fname, initpath = lyxrc->document_path;
2541 if (owner->view()->available()) {
2542 string trypath = owner->buffer()->filepath;
2543 // If directory is writeable, use this as default.
2544 if (IsDirWriteable(trypath) == 1)
2549 fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
2550 fileDlg.SetButton(1, _("Templates"), lyxrc->template_path);
2551 fname = fileDlg.Select(_("Enter Filename for new document"),
2552 initpath, "*.lyx", _("newfile"));
2555 if (fname.empty()) {
2556 owner->getMiniBuffer()->Set(_("Canceled."));
2557 lyxerr.debug() << "New Document Cancelled." << endl;
2561 // get absolute path of file and make sure the filename ends
2563 string s = MakeAbsPath(fname);
2564 if (!IsLyXFilename(s))
2567 // Check if the document already is open
2568 if (bufferlist.exists(s)){
2569 switch(AskConfirmation(_("Document is already open:"),
2570 MakeDisplayPath(s, 50),
2571 _("Do you want to close that document now?\n"
2572 "('No' will just switch to the open version)")))
2574 case 1: // Yes: close the document
2575 if (!bufferlist.close(bufferlist.getBuffer(s)))
2576 // If close is canceled, we cancel here too.
2579 case 2: // No: switch to the open document
2580 owner->view()->buffer(bufferlist.getBuffer(s));
2582 case 3: // Cancel: Do nothing
2583 owner->getMiniBuffer()->Set(_("Canceled."));
2588 // Check whether the file already exists
2589 if (IsLyXFilename(s)) {
2591 if (fi.readable() &&
2592 AskQuestion(_("File already exists:"),
2593 MakeDisplayPath(s, 50),
2594 _("Do you want to open the document?"))) {
2596 owner->getMiniBuffer()->Set(_("Opening document"),
2597 MakeDisplayPath(s), "...");
2599 owner->view()->buffer(
2600 bufferlist.loadLyXFile(s));
2601 owner->getMiniBuffer()->Set(_("Document"),
2608 // The template stuff
2612 fname = fileDlg.Select(_("Choose template"),
2613 lyxrc->template_path,
2619 // find a free buffer
2620 lyxerr.debug() << "Find a free buffer." << endl;
2621 owner->view()->buffer(bufferlist.newFile(s, templname));
2625 void LyXFunc::MenuOpen()
2627 string initpath = lyxrc->document_path;
2630 if (owner->view()->available()) {
2631 string trypath = owner->buffer()->filepath;
2632 // If directory is writeable, use this as default.
2633 if (IsDirWriteable(trypath) == 1)
2639 fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
2640 fileDlg.SetButton(1, _("Examples"),
2641 AddPath(system_lyxdir, "examples"));
2642 string filename = fileDlg.Select(_("Select Document to Open"),
2646 // check selected filename
2647 if (filename.empty()) {
2648 owner->getMiniBuffer()->Set(_("Canceled."));
2652 // get absolute path of file and make sure the filename ends
2654 filename = MakeAbsPath(filename);
2655 if (!IsLyXFilename(filename))
2659 owner->getMiniBuffer()->Set(_("Opening document"),
2660 MakeDisplayPath(filename), "...");
2661 Buffer * openbuf = bufferlist.loadLyXFile(filename);
2663 owner->view()->buffer(openbuf);
2664 owner->getMiniBuffer()->Set(_("Document"),
2665 MakeDisplayPath(filename),
2668 owner->getMiniBuffer()->Set(_("Could not open document"),
2669 MakeDisplayPath(filename));
2674 void LyXFunc::doImportASCII(bool linorpar)
2676 string initpath = lyxrc->document_path;
2679 if (owner->view()->available()) {
2680 string trypath = owner->buffer()->filepath;
2681 // If directory is writeable, use this as default.
2682 if (IsDirWriteable(trypath) == 1)
2688 fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
2689 fileDlg.SetButton(1, _("Examples"),
2690 AddPath(system_lyxdir, "examples"));
2691 string filename = fileDlg.Select(_("Select ASCII file to Import"),
2695 // check selected filename
2696 if (filename.empty()) {
2697 owner->getMiniBuffer()->Set(_("Canceled."));
2701 // get absolute path of file
2702 filename = MakeAbsPath(filename);
2704 string s = ChangeExtension(filename, ".lyx", false);
2706 // Check if the document already is open
2707 if (bufferlist.exists(s)) {
2708 switch(AskConfirmation(_("Document is already open:"),
2709 MakeDisplayPath(s, 50),
2710 _("Do you want to close that document now?\n"
2711 "('No' will just switch to the open version)")))
2713 case 1: // Yes: close the document
2714 if (!bufferlist.close(bufferlist.getBuffer(s)))
2715 // If close is canceled, we cancel here too.
2718 case 2: // No: switch to the open document
2719 owner->view()->buffer(bufferlist.getBuffer(s));
2721 case 3: // Cancel: Do nothing
2722 owner->getMiniBuffer()->Set(_("Canceled."));
2727 // Check if a LyX document by the same root exists in filesystem
2728 FileInfo f(s, true);
2729 if (f.exist() && !AskQuestion(_("A document by the name"),
2731 _("already exists. Overwrite?"))) {
2732 owner->getMiniBuffer()->Set(_("Canceled."));
2736 owner->view()->buffer(bufferlist.newFile(s, string()));
2737 owner->getMiniBuffer()->Set(_("Importing ASCII file"),
2738 MakeDisplayPath(filename), "...");
2739 // Insert ASCII file
2740 InsertAsciiFile(filename, linorpar);
2741 owner->getMiniBuffer()->Set(_("ASCII file "),
2742 MakeDisplayPath(filename),
2747 void LyXFunc::doImportLaTeX(bool isnoweb)
2749 string initpath = lyxrc->document_path;
2752 if (owner->view()->available()) {
2753 string trypath = owner->buffer()->filepath;
2754 // If directory is writeable, use this as default.
2755 if (IsDirWriteable(trypath) == 1)
2761 fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
2762 fileDlg.SetButton(1, _("Examples"),
2763 AddPath(system_lyxdir, "examples"));
2766 filename = fileDlg.Select(_("Select Noweb file to Import"),
2769 filename = fileDlg.Select(_("Select LaTeX file to Import"),
2775 // check selected filename
2776 if (filename.empty()) {
2777 owner->getMiniBuffer()->Set(_("Canceled."));
2781 // get absolute path of file
2782 filename = MakeAbsPath(filename);
2784 // Check if the document already is open
2785 string LyXfilename = ChangeExtension(filename, ".lyx", false);
2786 if (bufferlist.exists(LyXfilename)){
2787 switch(AskConfirmation(_("Document is already open:"),
2788 MakeDisplayPath(LyXfilename, 50),
2789 _("Do you want to close that document now?\n"
2790 "('No' will just switch to the open version)")))
2792 case 1: // Yes: close the document
2793 if (!bufferlist.close(bufferlist.getBuffer(LyXfilename)))
2794 // If close is canceled, we cancel here too.
2797 case 2: // No: switch to the open document
2798 owner->view()->buffer(
2799 bufferlist.getBuffer(LyXfilename));
2801 case 3: // Cancel: Do nothing
2802 owner->getMiniBuffer()->Set(_("Canceled."));
2807 // Check if a LyX document by the same root exists in filesystem
2808 FileInfo f(LyXfilename, true);
2809 if (f.exist() && !AskQuestion(_("A document by the name"),
2810 MakeDisplayPath(LyXfilename),
2811 _("already exists. Overwrite?"))) {
2812 owner->getMiniBuffer()->Set(_("Canceled."));
2819 owner->getMiniBuffer()->Set(_("Importing LaTeX file"),
2820 MakeDisplayPath(filename), "...");
2821 ImportLaTeX myImport(filename);
2822 openbuf = myImport.run();
2824 owner->getMiniBuffer()->Set(_("Importing Noweb file"),
2825 MakeDisplayPath(filename), "...");
2826 ImportNoweb myImport(filename);
2827 openbuf = myImport.run();
2830 owner->view()->buffer(openbuf);
2831 owner->getMiniBuffer()->Set(isnoweb ?
2832 _("Noweb file ") : _("LateX file "),
2833 MakeDisplayPath(filename),
2836 owner->getMiniBuffer()->Set(isnoweb ?
2837 _("Could not import Noweb file") :
2838 _("Could not import LaTeX file"),
2839 MakeDisplayPath(filename));
2844 void LyXFunc::MenuInsertLyXFile(string const & filen)
2846 string filename = filen;
2848 if (filename.empty()) {
2849 // Launch a file browser
2850 string initpath = lyxrc->document_path;
2853 if (owner->view()->available()) {
2854 string trypath = owner->buffer()->filepath;
2855 // If directory is writeable, use this as default.
2856 if (IsDirWriteable(trypath) == 1)
2862 fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
2863 fileDlg.SetButton(1, _("Examples"),
2864 AddPath(system_lyxdir, "examples"));
2865 filename = fileDlg.Select(_("Select Document to Insert"),
2869 // check selected filename
2870 if (filename.empty()) {
2871 owner->getMiniBuffer()->Set(_("Canceled."));
2876 // get absolute path of file and make sure the filename ends
2878 filename = MakeAbsPath(filename);
2879 if (!IsLyXFilename(filename))
2883 owner->getMiniBuffer()->Set(_("Inserting document"),
2884 MakeDisplayPath(filename), "...");
2885 bool res = owner->view()->insertLyXFile(filename);
2887 owner->getMiniBuffer()->Set(_("Document"),
2888 MakeDisplayPath(filename),
2891 owner->getMiniBuffer()->Set(_("Could not insert document"),
2892 MakeDisplayPath(filename));
2897 void LyXFunc::reloadBuffer()
2899 string fn = owner->buffer()->fileName();
2900 if (bufferlist.close(owner->buffer()))
2901 owner->view()->buffer(bufferlist.loadLyXFile(fn));
2905 void LyXFunc::CloseBuffer()
2907 if (bufferlist.close(owner->buffer()) && !quitting) {
2908 if (bufferlist.empty()) {
2909 // need this otherwise SEGV may occur while trying to
2910 // set variables that don't exist
2911 // since there's no current buffer
2912 CloseAllBufferRelatedPopups();
2915 owner->view()->buffer(bufferlist.first());
2921 Inset * LyXFunc::getInsetByCode(Inset::Code code)
2925 LyXCursor cursor = owner->view()->text->cursor;
2926 LyXParagraph::size_type pos = cursor.pos;
2927 LyXParagraph * par = cursor.par;
2929 while (par && !found) {
2930 while ((inset = par->ReturnNextInsetPointer(pos))){
2931 if (inset->LyxCode() == code) {
2939 return found ? inset : 0;
2943 // Each "owner" should have it's own message method. lyxview and
2944 // the minibuffer would use the minibuffer, but lyxserver would
2945 // send an ERROR signal to its client. Alejandro 970603
2946 // This func is bit problematic when it comes to NLS, to make the
2947 // lyx servers client be language indepenent we must not translate
2948 // strings sent to this func.
2949 void LyXFunc::setErrorMessage(string const & m) const
2951 dispatch_buffer = m;
2956 void LyXFunc::setMessage(string const & m)
2958 dispatch_buffer = m;