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 "insets/insettext.h"
45 #include "insets/insetert.h"
46 #include "mathed/formulamacro.h"
48 #include "spellchecker.h" // RVDK_PATCH_5
49 #include "minibuffer.h"
53 #include "lyx_gui_misc.h"
54 #include "support/filetools.h"
55 #include "support/FileInfo.h"
56 #include "support/syscall.h"
57 #include "support/lstrings.h"
58 #include "support/path.h"
63 #include "trans_mgr.h"
64 #include "ImportLaTeX.h"
65 #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 MenuWrite(Buffer *);
83 extern void MenuWriteAs(Buffer *);
84 extern int MenuRunLaTeX(Buffer *);
85 extern int MenuBuildProg(Buffer *);
86 extern int MenuRunChktex(Buffer *);
87 extern bool CreatePostscript(Buffer *, bool);
88 extern void MenuPrint(Buffer *);
89 extern void MenuSendto();
90 extern void QuitLyX();
91 extern void MenuFax(Buffer *);
92 extern void MenuExport(Buffer *, string const &);
93 extern void MenuPasteSelection(char at);
94 extern LyXAction lyxaction;
96 extern tex_accent_struct get_accent(kb_action action);
98 extern void AutoSave();
99 extern void MenuSearch();
100 extern void SetUpdateTimer(float timer = 0.3);
101 extern void FreeUpdateTimer();
102 extern bool PreviewDVI(Buffer *);
103 extern bool PreviewPostscript(Buffer *);
104 extern void MenuInsertLabel(char const *);
105 extern void MenuInsertRef();
106 extern void MenuLayoutCharacter();
107 extern void MenuLayoutParagraph();
108 extern void MenuLayoutDocument();
109 extern void MenuLayoutPaper();
110 extern void MenuLayoutTable(int flag);
111 extern void MenuLayoutQuotes();
112 extern void MenuLayoutPreamble();
113 extern void MenuLayoutSave();
114 extern void bulletForm();
116 extern Buffer * NewLyxFile(string const &);
117 extern void LoadLyXFile(string const &);
118 extern void Reconfigure(BufferView *);
120 extern int current_layout;
121 extern int getISOCodeFromLaTeX(char *);
123 extern void ShowLatexLog();
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*>(
530 owner->view()->text->cursor.par->
531 GetInset(owner->view()->text->
534 inset->Edit(owner->view(),slx,sly,0);
536 } else if (action == LFUN_REDO) {
538 UpdatableInset * inset = owner->view()->
540 inset->GetCursorPos(slx, sly);
541 owner->view()->unlockInset(inset);
542 owner->view()->menuRedo();
543 inset = static_cast<UpdatableInset*>(
544 owner->view()->text->cursor.par->
545 GetInset(owner->view()->text->
548 inset->Edit(owner->view(),slx,sly,0);
550 } else if (owner->view()->the_locking_inset->
551 LocalDispatch(owner->view(), action,
553 UpdatableInset::DISPATCHED)
556 setMessage(N_("Text mode"));
557 LyXDirection direction = owner->view()->text->
558 cursor.par->getParDirection();
559 if ((action == -1) ||
560 ((action == LFUN_RIGHT) &&
561 (direction == LYX_DIR_LEFT_TO_RIGHT))) {
562 owner->view()->text->CursorRight();
563 moveCursorUpdate(false);
564 owner->getMiniBuffer()->
567 if ((action == LFUN_LEFT) &&
568 (direction == LYX_DIR_RIGHT_TO_LEFT)) {
569 owner->view()->text->CursorRight();
570 moveCursorUpdate(false);
571 owner->getMiniBuffer()->
574 if ((action == LFUN_LEFT) ||
575 (action == LFUN_RIGHT))
582 // --- Misc -------------------------------------------
583 case LFUN_WORDFINDFORWARD :
584 case LFUN_WORDFINDBACKWARD : {
585 static string last_search;
586 string searched_string;
588 if (!argument.empty()) {
589 last_search = argument;
590 searched_string = argument;
592 searched_string = last_search;
595 LyXText * ltCur = owner->view()->text ;
597 if (!searched_string.empty() &&
598 ((action == LFUN_WORDFINDBACKWARD) ?
599 ltCur->SearchBackward(searched_string.c_str()) :
600 ltCur->SearchForward(searched_string.c_str()))) {
602 // ??? What is that ???
603 owner->view()->update(-2);
606 // clear the selection (if there is any)
607 owner->view()->toggleSelection();
608 owner->view()->text->ClearSelection();
610 // Move cursor so that successive C-s 's will not stand in place.
611 if( action == LFUN_WORDFINDFORWARD )
612 owner->view()->text->CursorRightOneWord();
613 owner->view()->text->FinishUndo();
614 moveCursorUpdate(false);
617 // set the new selection
618 // SetSelectionOverLenChars(owner->view()->currentBuffer()->text, iLenSelected);
619 owner->view()->toggleSelection(false);
623 // REMOVED : if (owner->view()->getWorkArea()->focus)
624 owner->view()->showCursor();
630 if (owner->view()->available()) {
631 owner->view()->update(-2);
634 keyseq.print(buf, true);
635 owner->getMiniBuffer()->Set(buf, string(), string(), 1);
639 // --- Misc -------------------------------------------
640 case LFUN_EXEC_COMMAND:
641 owner->getMiniBuffer()->ExecCommand();
644 case LFUN_CANCEL: // RVDK_PATCH_5
647 if(owner->view()->available())
648 // cancel any selection
649 Dispatch(LFUN_MARK_OFF, 0);
650 setMessage(N_("Cancel"));
653 case LFUN_META_FAKE: // RVDK_PATCH_5
655 meta_fake_bit = Mod1Mask;
657 keyseq.print(buf, true);
658 string res = string("M-") + buf;
659 setMessage(buf); // RVDK_PATCH_5
663 case LFUN_READ_ONLY_TOGGLE:
664 if (owner->buffer()->lyxvc.inUse()) {
665 owner->buffer()->lyxvc.toggleReadOnly();
667 owner->buffer()->setReadonly(
668 !owner->buffer()->isReadonly());
672 case LFUN_CENTER: // this is center and redraw.
673 owner->view()->center();
677 if (owner->view()->available()) {
678 owner->view()->text->toggleAppendix();
679 owner->view()->update(1);
683 // --- Menus -----------------------------------------------
688 case LFUN_MENUNEWTMPLT:
696 case LFUN_CLOSEBUFFER:
701 owner->getMiniBuffer()->Set(_("Saving document"),
702 MakeDisplayPath(owner->buffer()->fileName()),
704 MenuWrite(owner->buffer());
705 //owner->getMiniBuffer()->
706 // Set(_("Document saved as"),
707 // MakeDisplayPath(owner->buffer()->fileName()));
709 //owner->getMiniBuffer()->Set(_("Save failed!"));
713 case LFUN_MENUWRITEAS:
714 MenuWriteAs(owner->buffer());
717 case LFUN_MENURELOAD:
722 PreviewDVI(owner->buffer());
726 PreviewPostscript(owner->buffer());
730 MenuRunLaTeX(owner->buffer());
734 MenuBuildProg(owner->buffer());
738 MenuRunChktex(owner->buffer());
742 CreatePostscript(owner->buffer(), false);
746 MenuPrint(owner->buffer());
750 MenuFax(owner->buffer());
754 MenuExport(owner->buffer(), argument);
759 //needs argument as string
760 string imtyp = argument;
763 if (imtyp == "latex") {
764 doImportLaTeX(false);
767 else if (imtyp == "ascii") {
768 doImportASCII(false);
769 } else if (imtyp == "asciiparagraph") {
772 } else if (imtyp == "noweb") {
775 setErrorMessage(string(N_("Unknown import type: "))
787 if (fd_form_toc->form_toc->visible) {
788 fl_raise_form(fd_form_toc->form_toc);
790 static int ow = -1, oh;
791 fl_show_form(fd_form_toc->form_toc,
793 FL_FREE_SIZE, FL_FULLBORDER,
794 _("Table of Contents"));
796 ow = fd_form_toc->form_toc->w;
797 oh = fd_form_toc->form_toc->h;
799 fl_set_form_minsize(fd_form_toc->form_toc, ow, oh);
803 case LFUN_TOC_INSERT:
805 Inset * new_inset = new InsetTOC(owner->buffer());
806 owner->view()->insertInset(new_inset, "Standard", true);
810 case LFUN_LOF_INSERT:
812 Inset * new_inset = new InsetLOF(owner->buffer());
813 owner->view()->insertInset(new_inset, "Standard", true);
817 case LFUN_LOA_INSERT:
819 Inset * new_inset = new InsetLOA(owner->buffer());
820 owner->view()->insertInset(new_inset, "Standard", true);
824 case LFUN_LOT_INSERT:
826 Inset * new_inset = new InsetLOT(owner->buffer());
827 owner->view()->insertInset(new_inset, "Standard", true);
844 owner->view()->menuUndo();
848 owner->view()->menuRedo();
851 case LFUN_MENUSEARCH:
856 owner->view()->paste();
859 case LFUN_PASTESELECTION:
862 if (argument == "paragraph") asPara = true;
863 MenuPasteSelection(asPara);
868 owner->view()->cut();
872 owner->view()->copy();
875 case LFUN_LAYOUT_COPY:
876 owner->view()->copyEnvironment();
879 case LFUN_LAYOUT_PASTE:
880 owner->view()->pasteEnvironment();
884 owner->view()->gotoError();
887 case LFUN_REMOVEERRORS:
888 if (owner->view()->removeAutoInsets()) {
889 owner->view()->redraw();
890 owner->view()->fitCursor();
891 owner->view()->updateScrollbar();
896 owner->view()->gotoNote();
900 owner->view()->openStuff();
903 case LFUN_HYPHENATION:
904 owner->view()->hyphenationPoint();
908 owner->view()->ldots();
911 case LFUN_END_OF_SENTENCE:
912 owner->view()->endOfSentenceDot();
915 case LFUN_MENU_SEPARATOR:
916 owner->view()->menuSeparator();
920 owner->view()->hfill();
924 changeDepth(owner->view(), 0);
928 changeDepth(owner->view(), -1);
931 case LFUN_DEPTH_PLUS:
932 changeDepth(owner->view(), 1);
941 owner->view()->setState();
942 owner->getMiniBuffer()->Set(CurrentState());
949 case LFUN_RECONFIGURE:
950 Reconfigure(owner->view());
954 if (owner->view()->available()
955 && !owner->view()->text->selection
956 && owner->view()->text->cursor.par->footnoteflag
957 != LyXParagraph::NO_FOOTNOTE)
958 { // only melt footnotes with FOOTMELT, not margins etc
959 if(owner->view()->text->cursor.par->footnotekind == LyXParagraph::FOOTNOTE)
964 owner->view()->setState();
967 case LFUN_MARGINMELT:
968 if (owner->view()->available()
969 && !owner->view()->text->selection
970 && owner->view()->text->cursor.par->footnoteflag
971 != LyXParagraph::NO_FOOTNOTE) {
973 if(owner->view()->text->cursor.par->footnotekind == LyXParagraph::MARGIN)
976 Margin(owner->view());
977 owner->view()->setState();
980 // --- version control -------------------------------
981 case LFUN_VC_REGISTER:
983 if (!owner->buffer()->lyxvc.inUse())
984 owner->buffer()->lyxvc.registrer();
988 case LFUN_VC_CHECKIN:
990 if (owner->buffer()->lyxvc.inUse()
991 && !owner->buffer()->isReadonly())
992 owner->buffer()->lyxvc.checkIn();
996 case LFUN_VC_CHECKOUT:
998 if (owner->buffer()->lyxvc.inUse()
999 && owner->buffer()->isReadonly())
1000 owner->buffer()->lyxvc.checkOut();
1004 case LFUN_VC_REVERT:
1006 owner->buffer()->lyxvc.revert();
1012 owner->buffer()->lyxvc.undoLast();
1016 case LFUN_VC_HISTORY:
1018 owner->buffer()->lyxvc.showLog();
1022 // --- buffers ----------------------------------------
1024 case LFUN_FILE_INSERT:
1026 MenuInsertLyXFile(argument);
1030 case LFUN_FILE_INSERT_ASCII:
1032 bool asPara = (argument == "paragraph");
1033 InsertAsciiFile(string(), asPara);
1039 // servercmd: argument must be <file>:<template>
1040 Buffer * tmpbuf = NewLyxFile(argument);
1042 owner->view()->buffer(tmpbuf);
1046 case LFUN_FILE_OPEN:
1047 owner->view()->buffer(bufferlist.loadLyXFile(argument));
1050 case LFUN_LATEX_LOG:
1056 lyxerr.debug() << "LFUN_LAYOUTNO: (arg) " << argument << endl;
1057 int sel = strToInt(argument);
1058 lyxerr.debug() << "LFUN_LAYOUTNO: (sel) "<< sel << endl;
1060 // Should this give a setMessage instead?
1062 return string(); // illegal argument
1064 --sel; // sel 1..., but layout 0...
1066 // Pretend we got the name instead.
1067 Dispatch(int(LFUN_LAYOUT),
1068 textclasslist.NameOfLayout(owner->view()->
1077 lyxerr.debug() << "LFUN_LAYOUT: (arg) "
1078 << argument << endl;
1080 // Derive layout number from given argument (string)
1081 // and current buffer's textclass (number). */
1082 LyXTextClassList::ClassList::size_type tclass =
1083 owner->view()->text->parameters->textclass;
1084 pair <bool, int> layout =
1085 textclasslist.NumberOfLayout(tclass, argument);
1087 // If the entry is obsolete, use the new one instead.
1089 string obs = textclasslist.Style(tclass,layout.second)
1093 textclasslist.NumberOfLayout(tclass, obs);
1096 // see if we found the layout number:
1097 if (!layout.first) {
1098 setErrorMessage(string(N_("Layout ")) + argument +
1103 if (current_layout != layout.second) {
1104 owner->view()->hideCursor();
1105 current_layout = layout.second;
1106 owner->view()->update(-2);
1107 owner->view()->text->
1108 SetLayout(layout.second);
1109 owner->getToolbar()->combox->
1110 select(owner->view()->
1113 owner->view()->update(1);
1118 case LFUN_LAYOUT_DOCUMENT:
1119 MenuLayoutDocument();
1122 case LFUN_LAYOUT_PARAGRAPH:
1123 MenuLayoutParagraph();
1126 case LFUN_LAYOUT_CHARACTER:
1127 MenuLayoutCharacter();
1130 case LFUN_LAYOUT_TABLE:
1133 if (argument == "true") flag = 1;
1134 MenuLayoutTable(flag);
1138 case LFUN_LAYOUT_PAPER:
1142 case LFUN_LAYOUT_QUOTES:
1146 case LFUN_LAYOUT_PREAMBLE:
1147 MenuLayoutPreamble();
1150 case LFUN_LAYOUT_SAVE_DEFAULT:
1154 case LFUN_DROP_LAYOUTS_CHOICE:
1155 owner->getToolbar()->combox->Show();
1161 owner->view()->setState();
1162 owner->getMiniBuffer()->Set(CurrentState());
1194 case LFUN_UNDERLINE:
1198 case LFUN_FONT_SIZE:
1202 case LFUN_FONT_STATE:
1203 setMessage(CurrentState());
1206 case LFUN_UPCASE_WORD:
1207 owner->view()->update(-2);
1209 owner->view()->text->ChangeWordCase(LyXText::text_uppercase);
1210 owner->view()->update(1);
1214 case LFUN_LOWCASE_WORD:
1215 owner->view()->update(-2);
1217 owner->view()->text->ChangeWordCase(LyXText::text_lowercase);
1218 owner->view()->update(1);
1222 case LFUN_CAPITALIZE_WORD:
1223 owner->view()->update(-2);
1225 owner->view()->text->ChangeWordCase(LyXText::text_capitalization);
1226 owner->view()->update(1);
1230 case LFUN_INSERT_LABEL:
1231 MenuInsertLabel(argument.c_str());
1234 case LFUN_INSERT_REF:
1238 case LFUN_REFTOGGLE:
1241 static_cast<InsetRef*>(getInsetByCode(Inset::REF_CODE));
1243 if (inset->getFlag() == InsetRef::REF)
1244 inset->setFlag(InsetRef::PAGE_REF);
1246 inset->setFlag(InsetRef::REF);
1247 owner->view()->updateInset(inset, true);
1249 setErrorMessage(N_("No cross-reference to toggle"));
1256 owner->view()->restorePosition();
1262 string label(argument);
1263 if (label.empty()) {
1265 static_cast<InsetRef*>(getInsetByCode(Inset::REF_CODE));
1267 label = inset->getContents();
1270 if (!label.empty()) {
1271 owner->view()->savePosition();
1272 owner->view()->gotoLabel(label.c_str());
1277 case LFUN_MENU_OPEN_BY_NAME:
1278 owner->getMenus()->openByName(argument);
1279 break; // RVDK_PATCH_5
1281 case LFUN_SPELLCHECK:
1282 if (lyxrc->isp_command != "none")
1283 ShowSpellChecker(owner->view());
1284 break; // RVDK_PATCH_5
1286 // --- Cursor Movements -----------------------------
1289 LyXText * tmptext = owner->view()->text;
1290 LyXDirection direction =
1291 tmptext->cursor.par->getParDirection();
1292 if(!tmptext->mark_set)
1293 owner->view()->beforeChange();
1294 owner->view()->update(-2);
1295 if (direction == LYX_DIR_RIGHT_TO_LEFT)
1296 tmptext->CursorLeft();
1297 if (tmptext->cursor.pos < tmptext->cursor.par->Last()
1298 && tmptext->cursor.par->GetChar(tmptext->cursor.pos)
1299 == LyXParagraph::META_INSET
1300 && tmptext->cursor.par->GetInset(tmptext->cursor.pos)
1301 && tmptext->cursor.par->GetInset(tmptext->cursor.pos)->Editable() == 2){
1302 Inset * tmpinset = tmptext->cursor.par->GetInset(tmptext->cursor.pos);
1303 setMessage(tmpinset->EditMessage());
1304 tmpinset->Edit(owner->view(), 0, 0, 0);
1307 if (direction == LYX_DIR_LEFT_TO_RIGHT)
1308 tmptext->CursorRight();
1309 owner->view()->text->FinishUndo();
1310 moveCursorUpdate(false);
1311 owner->getMiniBuffer()->Set(CurrentState());
1317 // This is soooo ugly. Isn`t it possible to make
1318 // it simpler? (Lgb)
1319 LyXText * txt = owner->view()->text;
1320 LyXDirection direction = txt->cursor.par->getParDirection();
1321 if(!txt->mark_set) owner->view()->beforeChange();
1322 owner->view()->update(-2);
1323 if (direction == LYX_DIR_LEFT_TO_RIGHT)
1325 if (txt->cursor.pos < txt->cursor.par->Last()
1326 && txt->cursor.par->GetChar(txt->cursor.pos)
1327 == LyXParagraph::META_INSET
1328 && txt->cursor.par->GetInset(txt->cursor.pos)
1329 && txt->cursor.par->GetInset(txt->cursor.pos)->Editable() == 2) {
1330 Inset * tmpinset = txt->cursor.par->GetInset(txt->cursor.pos);
1331 setMessage(tmpinset->EditMessage());
1332 tmpinset->Edit(owner->view(),
1333 tmpinset->width(owner->view()->painter(),
1334 txt->GetFont(txt->cursor.par,
1339 if (direction == LYX_DIR_RIGHT_TO_LEFT)
1342 owner->view()->text->FinishUndo();
1343 moveCursorUpdate(false);
1344 owner->getMiniBuffer()->Set(CurrentState());
1349 if(!owner->view()->text->mark_set) owner->view()->beforeChange();
1350 owner->view()->update(-3);
1351 owner->view()->text->CursorUp();
1352 owner->view()->text->FinishUndo();
1353 moveCursorUpdate(false);
1354 owner->getMiniBuffer()->Set(CurrentState());
1358 if(!owner->view()->text->mark_set)
1359 owner->view()->beforeChange();
1360 owner->view()->update(-3);
1361 owner->view()->text->CursorDown();
1362 owner->view()->text->FinishUndo();
1363 moveCursorUpdate(false);
1364 owner->getMiniBuffer()->Set(CurrentState());
1367 case LFUN_UP_PARAGRAPH:
1368 if(!owner->view()->text->mark_set)
1369 owner->view()->beforeChange();
1370 owner->view()->update(-3);
1371 owner->view()->text->CursorUpParagraph();
1372 owner->view()->text->FinishUndo();
1373 moveCursorUpdate(false);
1374 owner->getMiniBuffer()->Set(CurrentState());
1377 case LFUN_DOWN_PARAGRAPH:
1378 if(!owner->view()->text->mark_set)
1379 owner->view()->beforeChange();
1380 owner->view()->update(-3);
1381 owner->view()->text->CursorDownParagraph();
1382 owner->view()->text->FinishUndo();
1383 moveCursorUpdate(false);
1384 owner->getMiniBuffer()->Set(CurrentState());
1388 if(!owner->view()->text->mark_set)
1389 owner->view()->beforeChange();
1390 owner->view()->update(-3);
1391 owner->view()->cursorPrevious();
1392 owner->view()->text->FinishUndo();
1393 moveCursorUpdate(false);
1394 owner->getMiniBuffer()->Set(CurrentState());
1398 if(!owner->view()->text->mark_set)
1399 owner->view()->beforeChange();
1400 owner->view()->update(-3);
1401 owner->view()->cursorNext();
1402 owner->view()->text->FinishUndo();
1403 moveCursorUpdate(false);
1404 owner->getMiniBuffer()->Set(CurrentState());
1408 if(!owner->view()->text->mark_set)
1409 owner->view()->beforeChange();
1410 owner->view()->update(-2);
1411 owner->view()->text->CursorHome();
1412 owner->view()->text->FinishUndo();
1413 moveCursorUpdate(false);
1414 owner->getMiniBuffer()->Set(CurrentState());
1418 if(!owner->view()->text->mark_set)
1419 owner->view()->beforeChange();
1420 owner->view()->update(-2);
1421 owner->view()->text->CursorEnd();
1422 owner->view()->text->FinishUndo();
1423 moveCursorUpdate(false);
1424 owner->getMiniBuffer()->Set(CurrentState());
1428 if(!owner->view()->text->mark_set)
1429 owner->view()->beforeChange();
1430 owner->view()->update(-2);
1431 owner->view()->text->CursorTab();
1432 owner->view()->text->FinishUndo();
1433 moveCursorUpdate(false);
1434 owner->getMiniBuffer()->Set(CurrentState());
1437 case LFUN_WORDRIGHT:
1438 if(!owner->view()->text->mark_set)
1439 owner->view()->beforeChange();
1440 owner->view()->update(-2);
1441 if (owner->view()->text->cursor.par->getParDirection()
1442 == LYX_DIR_LEFT_TO_RIGHT)
1443 owner->view()->text->CursorRightOneWord();
1445 owner->view()->text->CursorLeftOneWord();
1446 owner->view()->text->FinishUndo();
1447 moveCursorUpdate(false);
1448 owner->getMiniBuffer()->Set(CurrentState());
1452 if(!owner->view()->text->mark_set)
1453 owner->view()->beforeChange();
1454 owner->view()->update(-2);
1455 if (owner->view()->text->cursor.par->getParDirection()
1456 == LYX_DIR_LEFT_TO_RIGHT)
1457 owner->view()->text->CursorLeftOneWord();
1459 owner->view()->text->CursorRightOneWord();
1460 owner->view()->text->FinishUndo();
1461 moveCursorUpdate(false);
1462 owner->getMiniBuffer()->Set(CurrentState());
1465 case LFUN_BEGINNINGBUF:
1466 if(!owner->view()->text->mark_set)
1467 owner->view()->beforeChange();
1468 owner->view()->update(-2);
1469 owner->view()->text->CursorTop();
1470 owner->view()->text->FinishUndo();
1471 moveCursorUpdate(false);
1472 owner->getMiniBuffer()->Set(CurrentState());
1476 if(!owner->view()->text->mark_set)
1477 owner->view()->beforeChange();
1478 owner->view()->update(-2);
1479 owner->view()->text->CursorBottom();
1480 owner->view()->text->FinishUndo();
1481 moveCursorUpdate(false);
1482 owner->getMiniBuffer()->Set(CurrentState());
1486 /* cursor selection ---------------------------- */
1488 owner->view()->update(-2);
1489 if (owner->view()->text->cursor.par->getParDirection()
1490 == LYX_DIR_LEFT_TO_RIGHT)
1491 owner->view()->text->CursorRight();
1493 owner->view()->text->CursorLeft();
1494 owner->view()->text->FinishUndo();
1495 moveCursorUpdate(true);
1496 owner->getMiniBuffer()->Set(CurrentState());
1500 owner->view()->update(-2);
1501 if (owner->view()->text->cursor.par->getParDirection()
1502 == LYX_DIR_LEFT_TO_RIGHT)
1503 owner->view()->text->CursorLeft();
1505 owner->view()->text->CursorRight();
1506 owner->view()->text->FinishUndo();
1507 moveCursorUpdate(true);
1508 owner->getMiniBuffer()->Set(CurrentState());
1512 owner->view()->update(-2);
1513 owner->view()->text->CursorUp();
1514 owner->view()->text->FinishUndo();
1515 moveCursorUpdate(true);
1516 owner->getMiniBuffer()->Set(CurrentState());
1520 owner->view()->update(-2);
1521 owner->view()->text->CursorDown();
1522 owner->view()->text->FinishUndo();
1523 moveCursorUpdate(true);
1524 owner->getMiniBuffer()->Set(CurrentState());
1527 case LFUN_UP_PARAGRAPHSEL:
1528 owner->view()->update(-2);
1529 owner->view()->text->CursorUpParagraph();
1530 owner->view()->text->FinishUndo();
1531 moveCursorUpdate(true);
1532 owner->getMiniBuffer()->Set(CurrentState());
1535 case LFUN_DOWN_PARAGRAPHSEL:
1536 owner->view()->update(-2);
1537 owner->view()->text->CursorDownParagraph();
1538 owner->view()->text->FinishUndo();
1539 moveCursorUpdate(true);
1540 owner->getMiniBuffer()->Set(CurrentState());
1544 owner->view()->update(-2);
1545 owner->view()->cursorPrevious();
1546 owner->view()->text->FinishUndo();
1547 moveCursorUpdate(true);
1548 owner->getMiniBuffer()->Set(CurrentState());
1552 owner->view()->update(-2);
1553 owner->view()->cursorNext();
1554 owner->view()->text->FinishUndo();
1555 moveCursorUpdate(true);
1556 owner->getMiniBuffer()->Set(CurrentState());
1560 owner->view()->update(-2);
1561 owner->view()->text->CursorHome();
1562 owner->view()->text->FinishUndo();
1563 moveCursorUpdate(true);
1564 owner->getMiniBuffer()->Set(CurrentState());
1568 owner->view()->update(-2);
1569 owner->view()->text->CursorEnd();
1570 owner->view()->text->FinishUndo();
1571 moveCursorUpdate(true);
1572 owner->getMiniBuffer()->Set(CurrentState());
1575 case LFUN_WORDRIGHTSEL:
1576 owner->view()->update(-2);
1577 if (owner->view()->text->cursor.par->getParDirection()
1578 == LYX_DIR_LEFT_TO_RIGHT)
1579 owner->view()->text->CursorRightOneWord();
1581 owner->view()->text->CursorLeftOneWord();
1582 owner->view()->text->FinishUndo();
1583 moveCursorUpdate(true);
1584 owner->getMiniBuffer()->Set(CurrentState());
1587 case LFUN_WORDLEFTSEL:
1588 owner->view()->update(-2);
1589 if (owner->view()->text->cursor.par->getParDirection()
1590 == LYX_DIR_LEFT_TO_RIGHT)
1591 owner->view()->text->CursorLeftOneWord();
1593 owner->view()->text->CursorRightOneWord();
1594 owner->view()->text->FinishUndo();
1595 moveCursorUpdate(true);
1596 owner->getMiniBuffer()->Set(CurrentState());
1599 case LFUN_BEGINNINGBUFSEL:
1600 owner->view()->update(-2);
1601 owner->view()->text->CursorTop();
1602 owner->view()->text->FinishUndo();
1603 moveCursorUpdate(true);
1604 owner->getMiniBuffer()->Set(CurrentState());
1607 case LFUN_ENDBUFSEL:
1608 owner->view()->update(-2);
1609 owner->view()->text->CursorBottom();
1610 owner->view()->text->FinishUndo();
1611 moveCursorUpdate(true);
1612 owner->getMiniBuffer()->Set(CurrentState());
1615 // --- text changing commands ------------------------
1616 case LFUN_BREAKLINE:
1617 owner->view()->beforeChange();
1618 owner->view()->text->InsertChar(LyXParagraph::META_NEWLINE);
1619 owner->view()->smallUpdate(1);
1620 SetUpdateTimer(0.01);
1621 moveCursorUpdate(false);
1624 case LFUN_PROTECTEDSPACE:
1625 owner->view()->beforeChange();
1626 owner->view()->text->
1627 InsertChar(LyXParagraph::META_PROTECTED_SEPARATOR);
1628 owner->view()->smallUpdate(1);
1630 moveCursorUpdate(false);
1634 if(owner->view()->text->mark_set) {
1635 owner->view()->beforeChange();
1636 owner->view()->update(0);
1637 setMessage(N_("Mark removed"));
1639 owner->view()->beforeChange();
1640 owner->view()->text->mark_set = 1;
1641 owner->view()->update(0);
1642 setMessage(N_("Mark set"));
1644 owner->view()->text->sel_cursor =
1645 owner->view()->text->cursor;
1650 if (!owner->view()->text->selection) {
1651 owner->view()->text->Delete();
1652 owner->view()->text->sel_cursor =
1653 owner->view()->text->cursor;
1654 owner->view()->smallUpdate(1);
1655 // It is possible to make it a lot faster still
1656 // just comment out the lone below...
1657 owner->view()->showCursor();
1659 owner->view()->cut();
1662 moveCursorUpdate(false);
1663 owner->getMiniBuffer()->Set(CurrentState());
1664 owner->view()->setState();
1667 case LFUN_DELETE_SKIP:
1669 // Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
1671 LyXCursor cursor = owner->view()->text->cursor;
1674 if (!owner->view()->text->selection) {
1675 if (cursor.pos == cursor.par->Last()) {
1676 owner->view()->text->CursorRight();
1677 cursor = owner->view()->text->cursor;
1679 && !(cursor.par->added_space_top
1680 == VSpace (VSpace::NONE))) {
1681 owner->view()->text->SetParagraph
1682 (cursor.par->line_top,
1683 cursor.par->line_bottom,
1684 cursor.par->pagebreak_top,
1685 cursor.par->pagebreak_bottom,
1686 VSpace(VSpace::NONE),
1687 cursor.par->added_space_bottom,
1689 cursor.par->labelwidthstring, 0);
1690 owner->view()->text->CursorLeft();
1691 owner->view()->update (1);
1693 owner->view()->text->CursorLeft();
1694 owner->view()->text->Delete();
1695 owner->view()->text->sel_cursor =
1696 owner->view()->text->cursor;
1697 owner->view()->smallUpdate(1);
1700 owner->view()->text->Delete();
1701 owner->view()->text->sel_cursor =
1702 owner->view()->text->cursor;
1703 owner->view()->smallUpdate(1);
1706 owner->view()->cut();
1712 /* -------> Delete word forward. */
1713 case LFUN_DELETE_WORD_FORWARD:
1714 owner->view()->update(-2);
1716 owner->view()->text->DeleteWordForward();
1717 owner->view()->update( 1 );
1719 moveCursorUpdate(false);
1720 owner->getMiniBuffer()->Set(CurrentState());
1723 /* -------> Delete word backward. */
1724 case LFUN_DELETE_WORD_BACKWARD:
1725 owner->view()->update(-2);
1727 owner->view()->text->DeleteWordBackward();
1728 owner->view()->update( 1 );
1730 moveCursorUpdate(false);
1731 owner->getMiniBuffer()->Set(CurrentState());
1734 /* -------> Kill to end of line. */
1735 case LFUN_DELETE_LINE_FORWARD:
1737 owner->view()->update(-2);
1738 owner->view()->text->DeleteLineForward();
1739 owner->view()->update( 1 );
1741 moveCursorUpdate(false);
1744 /* -------> Set mark off. */
1746 owner->view()->beforeChange();
1747 owner->view()->update(0);
1748 owner->view()->text->sel_cursor =
1749 owner->view()->text->cursor;
1750 setMessage(N_("Mark off"));
1753 /* -------> Set mark on. */
1755 owner->view()->beforeChange();
1756 owner->view()->text->mark_set = 1;
1757 owner->view()->update( 0 );
1758 owner->view()->text->sel_cursor =
1759 owner->view()->text->cursor;
1760 setMessage(N_("Mark on"));
1763 case LFUN_BACKSPACE:
1766 if (!owner->view()->text->selection) {
1767 if (owner->getIntl()->getTrans()->backspace()) {
1768 owner->view()->text->Backspace();
1769 owner->view()->text->sel_cursor =
1770 owner->view()->text->cursor;
1771 owner->view()->smallUpdate(1);
1772 // It is possible to make it a lot faster still
1773 // just comment out the lone below...
1774 owner->view()->showCursor();
1777 owner->view()->cut();
1780 owner->getMiniBuffer()->Set(CurrentState());
1781 owner->view()->setState();
1785 case LFUN_BACKSPACE_SKIP:
1787 // Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
1789 LyXCursor cursor = owner->view()->text->cursor;
1792 if (!owner->view()->text->selection) {
1794 && !(cursor.par->added_space_top
1795 == VSpace (VSpace::NONE))) {
1796 owner->view()->text->SetParagraph
1797 (cursor.par->line_top,
1798 cursor.par->line_bottom,
1799 cursor.par->pagebreak_top,
1800 cursor.par->pagebreak_bottom,
1801 VSpace(VSpace::NONE), cursor.par->added_space_bottom,
1803 cursor.par->labelwidthstring, 0);
1804 owner->view()->update (1);
1806 owner->view()->text->Backspace();
1807 owner->view()->text->sel_cursor
1809 owner->view()->smallUpdate (1);
1812 owner->view()->cut();
1817 case LFUN_BREAKPARAGRAPH:
1819 owner->view()->beforeChange();
1820 owner->view()->text->BreakParagraph(0);
1821 owner->view()->smallUpdate(1);
1822 SetUpdateTimer(0.01);
1823 owner->view()->text->sel_cursor =
1824 owner->view()->text->cursor;
1825 owner->view()->setState();
1826 owner->getMiniBuffer()->Set(CurrentState());
1830 case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
1832 owner->view()->beforeChange();
1833 owner->view()->text->BreakParagraph(1);
1834 owner->view()->smallUpdate(1);
1835 SetUpdateTimer(0.01);
1836 owner->view()->text->sel_cursor =
1837 owner->view()->text->cursor;
1838 owner->view()->setState();
1839 owner->getMiniBuffer()->Set(CurrentState());
1843 case LFUN_BREAKPARAGRAPH_SKIP:
1845 // When at the beginning of a paragraph, remove
1846 // indentation and add a "defskip" at the top.
1847 // Otherwise, do the same as LFUN_BREAKPARAGRAPH.
1849 LyXCursor cursor = owner->view()->text->cursor;
1851 owner->view()->beforeChange();
1852 if (cursor.pos == 0) {
1853 if (cursor.par->added_space_top == VSpace(VSpace::NONE)) {
1854 owner->view()->text->SetParagraph
1855 (cursor.par->line_top,
1856 cursor.par->line_bottom,
1857 cursor.par->pagebreak_top,
1858 cursor.par->pagebreak_bottom,
1859 VSpace(VSpace::DEFSKIP), cursor.par->added_space_bottom,
1861 cursor.par->labelwidthstring, 1);
1862 owner->view()->update(1);
1866 owner->view()->text->BreakParagraph(0);
1867 owner->view()->smallUpdate(1);
1869 SetUpdateTimer(0.01);
1870 owner->view()->text->sel_cursor = cursor;
1871 owner->view()->setState();
1872 owner->getMiniBuffer()->Set(CurrentState());
1877 owner->view()->beforeChange();
1878 owner->view()->text->InsertChar('\"'); // This " matches the single quote in the code
1879 owner->view()->smallUpdate(1);
1881 moveCursorUpdate(false);
1887 InsetCommand * new_inset;
1888 if (action == LFUN_HTMLURL)
1889 new_inset = new InsetUrl("htmlurl", "", "");
1891 new_inset = new InsetUrl("url", "", "");
1892 owner->view()->insertInset(new_inset);
1893 new_inset->Edit(owner->view(), 0, 0, 0);
1896 case LFUN_INSET_TEXT:
1898 InsetText * new_inset = new InsetText(owner->buffer());
1899 owner->view()->insertInset(new_inset);
1900 new_inset->Edit(owner->view(), 0, 0, 0);
1903 case LFUN_INSET_ERT:
1905 InsetERT * new_inset = new InsetERT(owner->buffer());
1906 owner->view()->insertInset(new_inset);
1907 new_inset->Edit(owner->view(), 0, 0, 0);
1911 // --- lyxserver commands ----------------------------
1913 case LFUN_CHARATCURSOR:
1915 LyXParagraph::size_type pos =
1916 owner->view()->text->cursor.pos;
1917 if(pos < owner->view()->text->cursor.par->size())
1918 dispatch_buffer = owner->view()->text->
1919 cursor.par->text[pos];
1921 dispatch_buffer = "EOF";
1927 tostr(owner->view()->text->cursor.x) + ' '
1928 + tostr(owner->view()->text->cursor.y);
1935 sscanf(argument.c_str(), " %d %ld", &x, &y);
1936 owner->view()->text->SetCursorFromCoordinates(x, y);
1940 case LFUN_GETLAYOUT:
1942 tostr(owner->view()->text->cursor.par->layout);
1947 LyXFont * font = &(owner->view()->text->current_font);
1948 if(font->shape() == LyXFont::ITALIC_SHAPE)
1949 dispatch_buffer = 'E';
1950 else if(font->shape() == LyXFont::SMALLCAPS_SHAPE)
1951 dispatch_buffer = 'N';
1953 dispatch_buffer = '0';
1960 LyXFont * font = &(owner->view()->text->current_font);
1961 if(font->latex() == LyXFont::ON)
1962 dispatch_buffer = 'L';
1964 dispatch_buffer = '0';
1969 setMessage(owner->buffer()->fileName());
1970 lyxerr.debug() << "FNAME["
1971 << owner->buffer()->fileName()
1979 dispatch_buffer = buf;
1980 lyxserver->notifyClient(dispatch_buffer);
1984 case LFUN_GOTOFILEROW:
1986 char file_name[100];
1988 sscanf(argument.c_str(), " %s %d", file_name, &row);
1990 // Must replace extension of the file to be .lyx and get full path
1991 string s = ChangeExtension(string(file_name), ".lyx", false);
1993 // Either change buffer or load the file
1994 if (bufferlist.exists(s))
1995 owner->view()->buffer(bufferlist.getBuffer(s));
1997 owner->view()->buffer(bufferlist.loadLyXFile(s));
2000 owner->view()->setCursorFromRow(row);
2003 owner->view()->center();
2010 int qa = lyxaction.LookupFunc(argument.c_str());
2011 setMessage(lyxaction.helpText(static_cast<kb_action>(qa)));
2015 // --- accented characters ---------------------------
2018 case LFUN_CIRCUMFLEX:
2028 case LFUN_SPECIAL_CARON:
2031 case LFUN_HUNG_UMLAUT:
2037 if (keyseq.length == -1 && keyseq.getiso() != 0)
2038 c = keyseq.getiso();
2042 owner->getIntl()->getTrans()->
2043 deadkey(c, get_accent(action).accent,
2044 owner->view()->text);
2046 // Need to reset, in case the minibuffer calls these
2051 // copied verbatim from do_accent_char
2052 owner->view()->smallUpdate(1);
2054 owner->view()->text->sel_cursor =
2055 owner->view()->text->cursor;
2059 // --- toolbar ----------------------------------
2060 case LFUN_PUSH_TOOLBAR:
2062 int nth = strToInt(argument);
2063 if (lyxerr.debugging(Debug::TOOLBAR)) {
2064 lyxerr << "LFUN_PUSH_TOOLBAR: argument = `"
2065 << argument << "'\n"
2066 << "LFUN_PUSH_TOOLBAR: nth = `"
2067 << nth << "'" << endl;
2072 setErrorMessage(N_("Push-toolbar needs argument > 0"));
2074 owner->getToolbar()->push(nth);
2079 case LFUN_ADD_TO_TOOLBAR:
2081 if (lyxerr.debugging(Debug::TOOLBAR)) {
2082 lyxerr << "LFUN_ADD_TO_TOOLBAR:"
2083 "argument = `" << argument << '\'' << endl;
2085 string tmp(argument);
2086 //lyxerr <<string("Argument: ") + argument);
2087 //lyxerr <<string("Tmp : ") + tmp);
2090 setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
2092 owner->getToolbar()->add(argument, false);
2093 owner->getToolbar()->set();
2098 // --- insert characters ----------------------------------------
2100 // --- Mathed stuff. If we are here, there is no locked inset yet.
2105 if (!greek_kb_flag) {
2107 setMessage(N_("Math greek mode on"));
2114 case LFUN_GREEK_TOGGLE:
2116 greek_kb_flag = greek_kb_flag ? 0 : 2;
2117 if (greek_kb_flag) {
2118 setMessage(N_("Math greek keyboard on"));
2120 setMessage(N_("Math greek keyboard off"));
2125 case LFUN_MATH_DELIM:
2126 case LFUN_INSERT_MATRIX:
2128 if (owner->view()->available()) {
2130 open_new_inset(new InsetFormula(false));
2133 ->LocalDispatch(owner->view(),
2140 case LFUN_INSERT_MATH:
2142 math_insert_symbol(argument.c_str());
2146 case LFUN_MATH_DISPLAY:
2148 if (owner->view()->available())
2149 owner->view()->open_new_inset(new InsetFormula(true));
2153 case LFUN_MATH_MACRO:
2155 if (owner->view()->available()) {
2158 setErrorMessage(N_("Missing argument"));
2160 string s1 = token(s, ' ', 1);
2161 int na = s1.empty() ? 0: atoi(s1.c_str());
2163 open_new_inset(new InsetFormulaMacro(token(s, ' ', 0), na));
2169 case LFUN_MATH_MODE: // Open or create a math inset
2172 if (owner->view()->available())
2173 owner->view()->open_new_inset(new InsetFormula);
2174 setMessage(N_("Math editor mode"));
2178 case LFUN_MATH_NUMBER:
2179 case LFUN_MATH_LIMITS:
2181 setErrorMessage(N_("This is only allowed in math mode!"));
2185 case LFUN_INSERT_CITATION:
2187 InsetCitation * new_inset = new InsetCitation();
2189 // The note, if any, must be after the key, delimited
2190 // by a | so both key and remark can have spaces.
2191 if (!argument.empty()) {
2192 string lsarg(argument);
2193 if (contains(lsarg, "|")) {
2194 new_inset->setContents(token(lsarg, '|', 0));
2195 new_inset->setOptions(token(lsarg, '|', 1));
2197 new_inset->setContents(lsarg);
2198 owner->view()->insertInset(new_inset);
2200 owner->view()->insertInset(new_inset);
2201 new_inset->Edit(owner->view(), 0, 0, 0);
2206 case LFUN_INSERT_BIBTEX:
2208 // ale970405+lasgoutt970425
2209 // The argument can be up to two tokens separated
2210 // by a space. The first one is the bibstyle.
2211 string lsarg(argument);
2212 string bibstyle = token(lsarg, ' ', 1);
2213 if (bibstyle.empty())
2215 InsetBibtex * new_inset
2216 = new InsetBibtex(token(lsarg, ' ', 0),
2220 owner->view()->insertInset(new_inset);
2221 if (lsarg.empty()) {
2222 new_inset->Edit(owner->view(), 0, 0, 0);
2227 // BibTeX data bases
2228 case LFUN_BIBDB_ADD:
2230 InsetBibtex * inset =
2231 static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
2233 inset->addDatabase(argument);
2238 case LFUN_BIBDB_DEL:
2240 InsetBibtex * inset =
2241 static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
2243 inset->delDatabase(argument);
2248 case LFUN_BIBTEX_STYLE:
2250 InsetBibtex * inset =
2251 static_cast<InsetBibtex*>(getInsetByCode(Inset::BIBTEX_CODE));
2253 inset->setOptions(argument);
2258 case LFUN_INDEX_INSERT:
2259 case LFUN_INDEX_INSERT_LAST:
2261 // Can't do that at the beginning of a paragraph.
2262 if (owner->view()->text->cursor.pos - 1 < 0)
2265 InsetIndex * new_inset = new InsetIndex();
2266 if (!argument.empty()) {
2267 string lsarg(argument);
2268 new_inset->setContents(lsarg);
2269 owner->view()->insertInset(new_inset);
2272 //get the current word for an argument
2273 LyXParagraph::size_type lastpos =
2274 owner->view()->text->cursor.pos - 1;
2275 // Get the current word. note that this must be done
2276 // before inserting the inset, or the inset will
2278 string curstring(owner->view()
2279 ->text->cursor.par->GetWord(lastpos));
2281 //make the new inset and write the current word into it
2282 InsetIndex * new_inset = new InsetIndex();
2284 new_inset->setContents(curstring);
2286 //don't edit it if the call was to INSERT_LAST
2287 if(action != LFUN_INDEX_INSERT_LAST) {
2288 new_inset->Edit(owner->view(), 0, 0, 0);
2290 //it looks blank on the screen unless
2291 //we do something. put it here.
2293 // move the cursor to the returned value of lastpos
2294 // but only for the auto-insert
2295 owner->view()->text->cursor.pos = lastpos;
2298 //put the new inset into the buffer.
2299 // there should be some way of knowing the user
2300 //cancelled & avoiding this, but i don't know how
2301 owner->view()->insertInset(new_inset);
2306 case LFUN_INDEX_PRINT:
2308 Inset * new_inset = new InsetPrintIndex(owner->buffer());
2309 owner->view()->insertInset(new_inset, "Standard", true);
2313 case LFUN_PARENTINSERT:
2315 lyxerr << "arg " << argument << endl;
2316 Inset * new_inset = new InsetParent(argument, owner->buffer());
2317 owner->view()->insertInset(new_inset, "Standard", true);
2321 case LFUN_CHILDINSERT:
2323 Inset * new_inset = new InsetInclude(argument,
2325 owner->view()->insertInset(new_inset, "Standard", true);
2326 new_inset->Edit(owner->view(), 0, 0, 0);
2330 case LFUN_CHILDOPEN:
2333 MakeAbsPath(argument,
2334 OnlyPath(owner->buffer()->fileName()));
2335 setMessage(N_("Opening child document ") +
2336 MakeDisplayPath(filename) + "...");
2337 owner->view()->savePosition();
2338 if (bufferlist.exists(filename))
2339 owner->view()->buffer(bufferlist.getBuffer(filename));
2341 owner->view()->buffer(bufferlist.loadLyXFile(filename));
2345 case LFUN_INSERT_NOTE:
2346 owner->view()->insertNote();
2349 case LFUN_INSERTFOOTNOTE:
2351 LyXParagraph::footnote_kind kind;
2352 if (argument == "footnote")
2353 { kind = LyXParagraph::FOOTNOTE; }
2354 else if (argument == "margin")
2355 { kind = LyXParagraph::MARGIN; }
2356 else if (argument == "figure")
2357 { kind = LyXParagraph::FIG; }
2358 else if (argument == "table")
2359 { kind = LyXParagraph::TAB; }
2360 else if (argument == "wide-fig")
2361 { kind = LyXParagraph::WIDE_FIG; }
2362 else if (argument == "wide-tab")
2363 { kind = LyXParagraph::WIDE_TAB; }
2364 else if (argument == "algorithm")
2365 { kind = LyXParagraph::ALGORITHM; }
2367 setErrorMessage(N_("Unknown kind of footnote"));
2370 owner->view()->text->InsertFootnoteEnvironment(kind);
2371 owner->view()->update(1);
2372 owner->view()->setState();
2376 case LFUN_BUFFERBULLETSSELECT:
2380 case LFUN_TOGGLECURSORFOLLOW:
2381 cursor_follows_scrollbar = !cursor_follows_scrollbar;
2384 case LFUN_KMAP_OFF: // keymap off
2385 owner->getIntl()->KeyMapOn(false);
2388 case LFUN_KMAP_PRIM: // primary keymap
2389 owner->getIntl()->KeyMapPrim();
2392 case LFUN_KMAP_SEC: // secondary keymap
2393 owner->getIntl()->KeyMapSec();
2396 case LFUN_KMAP_TOGGLE: // toggle keymap
2397 owner->getIntl()->ToggleKeyMap();
2400 case LFUN_SELFINSERT:
2402 for (string::size_type i = 0; i < argument.length(); ++i) {
2403 owner->view()->text->InsertChar(argument[i]);
2404 // This needs to be in the loop, or else we
2405 // won't break lines correctly. (Asger)
2406 owner->view()->smallUpdate(1);
2409 owner->view()->text->sel_cursor =
2410 owner->view()->text->cursor;
2411 moveCursorUpdate(false);
2417 // argument contains ';'-terminated commands
2418 while (argument.find(';') != string::npos) {
2420 argument = split(argument, first, ';');
2426 case LFUN_DATE_INSERT: // jdblair: date-insert cmd
2434 now_time_t = time(NULL);
2435 now_tm = localtime(&now_time_t);
2436 (void)setlocale(LC_TIME, "");
2437 if (!argument.empty())
2439 else if (arg.empty())
2440 arg = lyxrc->date_insert_format;
2441 datetmp_len = (int) strftime(datetmp, 32, arg.c_str(), now_tm);
2442 for (int i = 0; i < datetmp_len; i++) {
2443 owner->view()->text->InsertChar(datetmp[i]);
2444 owner->view()->smallUpdate(1);
2447 owner->view()->text->sel_cursor = owner->view()->text->cursor;
2448 moveCursorUpdate(false);
2452 case LFUN_SAVEPREFERENCES:
2454 Path p(user_lyxdir);
2455 lyxrc->write("preferences");
2459 case LFUN_UNKNOWN_ACTION:
2461 if(!owner->buffer()) {
2463 setErrorMessage(N_("No document open"));
2467 if (owner->buffer()->isReadonly()) {
2469 setErrorMessage(N_("Document is read only"));
2473 if (!argument.empty()) {
2475 /* Automatically delete the currently selected
2476 * text and replace it with what is being
2477 * typed in now. Depends on lyxrc settings
2478 * "auto_region_delete", which defaults to
2481 if ( lyxrc->auto_region_delete ) {
2482 if (owner->view()->text->selection){
2483 owner->view()->text->CutSelection(false);
2484 owner->view()->update(-1);
2488 owner->view()->beforeChange();
2489 for (string::size_type i = 0;
2490 i < argument.length(); ++i) {
2491 if (greek_kb_flag) {
2492 if (!math_insert_greek(argument[i]))
2493 owner->getIntl()->getTrans()->TranslateAndInsert(argument[i], owner->view()->text);
2495 owner->getIntl()->getTrans()->TranslateAndInsert(argument[i], owner->view()->text);
2498 owner->view()->smallUpdate(1);
2501 owner->view()->text->sel_cursor =
2502 owner->view()->text->cursor;
2503 moveCursorUpdate(false);
2506 // why is an "Unknown action" with empty
2507 // argument even dispatched in the first
2508 // place? I`ll probably change that. (Lgb)
2510 setErrorMessage(N_("Unknown action"));
2514 lyxerr << "A truly unknown func!" << endl;
2520 string res = getMessage();
2523 if (!commandshortcut.empty()) {
2524 string newbuf = owner->getMiniBuffer()->GetText();
2525 if (newbuf != commandshortcut) {
2526 owner->getMiniBuffer()->Set(newbuf
2532 owner->getMiniBuffer()->Set(string(_(res.c_str()))
2533 + " " + commandshortcut);
2540 void LyXFunc::setupLocalKeymap()
2542 keyseq.stdmap = keyseq.curmap = toplevel_keymap;
2543 cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap;
2547 void LyXFunc::MenuNew(bool fromTemplate)
2549 string fname, initpath = lyxrc->document_path;
2552 if (owner->view()->available()) {
2553 string trypath = owner->buffer()->filepath;
2554 // If directory is writeable, use this as default.
2555 if (IsDirWriteable(trypath) == 1)
2560 fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
2561 fileDlg.SetButton(1, _("Templates"), lyxrc->template_path);
2562 fname = fileDlg.Select(_("Enter Filename for new document"),
2563 initpath, "*.lyx", _("newfile"));
2566 if (fname.empty()) {
2567 owner->getMiniBuffer()->Set(_("Canceled."));
2568 lyxerr.debug() << "New Document Cancelled." << endl;
2572 // get absolute path of file and make sure the filename ends
2574 string s = MakeAbsPath(fname);
2575 if (!IsLyXFilename(s))
2578 // Check if the document already is open
2579 if (bufferlist.exists(s)){
2580 switch(AskConfirmation(_("Document is already open:"),
2581 MakeDisplayPath(s, 50),
2582 _("Do you want to close that document now?\n"
2583 "('No' will just switch to the open version)")))
2585 case 1: // Yes: close the document
2586 if (!bufferlist.close(bufferlist.getBuffer(s)))
2587 // If close is canceled, we cancel here too.
2590 case 2: // No: switch to the open document
2591 owner->view()->buffer(bufferlist.getBuffer(s));
2593 case 3: // Cancel: Do nothing
2594 owner->getMiniBuffer()->Set(_("Canceled."));
2599 // Check whether the file already exists
2600 if (IsLyXFilename(s)) {
2602 if (fi.readable() &&
2603 AskQuestion(_("File already exists:"),
2604 MakeDisplayPath(s, 50),
2605 _("Do you want to open the document?"))) {
2607 owner->getMiniBuffer()->Set(_("Opening document"),
2608 MakeDisplayPath(s), "...");
2610 owner->view()->buffer(
2611 bufferlist.loadLyXFile(s));
2612 owner->getMiniBuffer()->Set(_("Document"),
2619 // The template stuff
2623 fname = fileDlg.Select(_("Choose template"),
2624 lyxrc->template_path,
2630 // find a free buffer
2631 lyxerr.debug() << "Find a free buffer." << endl;
2632 owner->view()->buffer(bufferlist.newFile(s, templname));
2636 void LyXFunc::MenuOpen()
2638 string initpath = lyxrc->document_path;
2641 if (owner->view()->available()) {
2642 string trypath = owner->buffer()->filepath;
2643 // If directory is writeable, use this as default.
2644 if (IsDirWriteable(trypath) == 1)
2650 fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
2651 fileDlg.SetButton(1, _("Examples"),
2652 AddPath(system_lyxdir, "examples"));
2653 string filename = fileDlg.Select(_("Select Document to Open"),
2657 // check selected filename
2658 if (filename.empty()) {
2659 owner->getMiniBuffer()->Set(_("Canceled."));
2663 // get absolute path of file and make sure the filename ends
2665 filename = MakeAbsPath(filename);
2666 if (!IsLyXFilename(filename))
2670 owner->getMiniBuffer()->Set(_("Opening document"),
2671 MakeDisplayPath(filename), "...");
2672 Buffer * openbuf = bufferlist.loadLyXFile(filename);
2674 owner->view()->buffer(openbuf);
2675 owner->getMiniBuffer()->Set(_("Document"),
2676 MakeDisplayPath(filename),
2679 owner->getMiniBuffer()->Set(_("Could not open document"),
2680 MakeDisplayPath(filename));
2685 void LyXFunc::doImportASCII(bool linorpar)
2687 string initpath = lyxrc->document_path;
2690 if (owner->view()->available()) {
2691 string trypath = owner->buffer()->filepath;
2692 // If directory is writeable, use this as default.
2693 if (IsDirWriteable(trypath) == 1)
2699 fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
2700 fileDlg.SetButton(1, _("Examples"),
2701 AddPath(system_lyxdir, "examples"));
2702 string filename = fileDlg.Select(_("Select ASCII file to Import"),
2706 // check selected filename
2707 if (filename.empty()) {
2708 owner->getMiniBuffer()->Set(_("Canceled."));
2712 // get absolute path of file
2713 filename = MakeAbsPath(filename);
2715 string s = ChangeExtension(filename, ".lyx", false);
2717 // Check if the document already is open
2718 if (bufferlist.exists(s)) {
2719 switch(AskConfirmation(_("Document is already open:"),
2720 MakeDisplayPath(s, 50),
2721 _("Do you want to close that document now?\n"
2722 "('No' will just switch to the open version)")))
2724 case 1: // Yes: close the document
2725 if (!bufferlist.close(bufferlist.getBuffer(s)))
2726 // If close is canceled, we cancel here too.
2729 case 2: // No: switch to the open document
2730 owner->view()->buffer(bufferlist.getBuffer(s));
2732 case 3: // Cancel: Do nothing
2733 owner->getMiniBuffer()->Set(_("Canceled."));
2738 // Check if a LyX document by the same root exists in filesystem
2739 FileInfo f(s, true);
2740 if (f.exist() && !AskQuestion(_("A document by the name"),
2742 _("already exists. Overwrite?"))) {
2743 owner->getMiniBuffer()->Set(_("Canceled."));
2747 owner->view()->buffer(bufferlist.newFile(s, string()));
2748 owner->getMiniBuffer()->Set(_("Importing ASCII file"),
2749 MakeDisplayPath(filename), "...");
2750 // Insert ASCII file
2751 InsertAsciiFile(filename, linorpar);
2752 owner->getMiniBuffer()->Set(_("ASCII file "),
2753 MakeDisplayPath(filename),
2758 void LyXFunc::doImportLaTeX(bool isnoweb)
2760 string initpath = lyxrc->document_path;
2763 if (owner->view()->available()) {
2764 string trypath = owner->buffer()->filepath;
2765 // If directory is writeable, use this as default.
2766 if (IsDirWriteable(trypath) == 1)
2772 fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
2773 fileDlg.SetButton(1, _("Examples"),
2774 AddPath(system_lyxdir, "examples"));
2777 filename = fileDlg.Select(_("Select Noweb file to Import"),
2780 filename = fileDlg.Select(_("Select LaTeX file to Import"),
2786 // check selected filename
2787 if (filename.empty()) {
2788 owner->getMiniBuffer()->Set(_("Canceled."));
2792 // get absolute path of file
2793 filename = MakeAbsPath(filename);
2795 // Check if the document already is open
2796 string LyXfilename = ChangeExtension(filename, ".lyx", false);
2797 if (bufferlist.exists(LyXfilename)){
2798 switch(AskConfirmation(_("Document is already open:"),
2799 MakeDisplayPath(LyXfilename, 50),
2800 _("Do you want to close that document now?\n"
2801 "('No' will just switch to the open version)")))
2803 case 1: // Yes: close the document
2804 if (!bufferlist.close(bufferlist.getBuffer(LyXfilename)))
2805 // If close is canceled, we cancel here too.
2808 case 2: // No: switch to the open document
2809 owner->view()->buffer(
2810 bufferlist.getBuffer(LyXfilename));
2812 case 3: // Cancel: Do nothing
2813 owner->getMiniBuffer()->Set(_("Canceled."));
2818 // Check if a LyX document by the same root exists in filesystem
2819 FileInfo f(LyXfilename, true);
2820 if (f.exist() && !AskQuestion(_("A document by the name"),
2821 MakeDisplayPath(LyXfilename),
2822 _("already exists. Overwrite?"))) {
2823 owner->getMiniBuffer()->Set(_("Canceled."));
2830 owner->getMiniBuffer()->Set(_("Importing LaTeX file"),
2831 MakeDisplayPath(filename), "...");
2832 ImportLaTeX myImport(filename);
2833 openbuf = myImport.run();
2835 owner->getMiniBuffer()->Set(_("Importing Noweb file"),
2836 MakeDisplayPath(filename), "...");
2837 ImportNoweb myImport(filename);
2838 openbuf = myImport.run();
2841 owner->view()->buffer(openbuf);
2842 owner->getMiniBuffer()->Set(isnoweb ?
2843 _("Noweb file ") : _("LateX file "),
2844 MakeDisplayPath(filename),
2847 owner->getMiniBuffer()->Set(isnoweb ?
2848 _("Could not import Noweb file") :
2849 _("Could not import LaTeX file"),
2850 MakeDisplayPath(filename));
2855 void LyXFunc::MenuInsertLyXFile(string const & filen)
2857 string filename = filen;
2859 if (filename.empty()) {
2860 // Launch a file browser
2861 string initpath = lyxrc->document_path;
2864 if (owner->view()->available()) {
2865 string trypath = owner->buffer()->filepath;
2866 // If directory is writeable, use this as default.
2867 if (IsDirWriteable(trypath) == 1)
2873 fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
2874 fileDlg.SetButton(1, _("Examples"),
2875 AddPath(system_lyxdir, "examples"));
2876 filename = fileDlg.Select(_("Select Document to Insert"),
2880 // check selected filename
2881 if (filename.empty()) {
2882 owner->getMiniBuffer()->Set(_("Canceled."));
2887 // get absolute path of file and make sure the filename ends
2889 filename = MakeAbsPath(filename);
2890 if (!IsLyXFilename(filename))
2894 owner->getMiniBuffer()->Set(_("Inserting document"),
2895 MakeDisplayPath(filename), "...");
2896 bool res = owner->view()->insertLyXFile(filename);
2898 owner->getMiniBuffer()->Set(_("Document"),
2899 MakeDisplayPath(filename),
2902 owner->getMiniBuffer()->Set(_("Could not insert document"),
2903 MakeDisplayPath(filename));
2908 void LyXFunc::reloadBuffer()
2910 string fn = owner->buffer()->fileName();
2911 if (bufferlist.close(owner->buffer()))
2912 owner->view()->buffer(bufferlist.loadLyXFile(fn));
2916 void LyXFunc::CloseBuffer()
2918 if (bufferlist.close(owner->buffer()) && !quitting) {
2919 if (bufferlist.empty()) {
2920 // need this otherwise SEGV may occur while trying to
2921 // set variables that don't exist
2922 // since there's no current buffer
2923 CloseAllBufferRelatedPopups();
2926 owner->view()->buffer(bufferlist.first());
2932 Inset * LyXFunc::getInsetByCode(Inset::Code code)
2936 LyXCursor cursor = owner->view()->text->cursor;
2937 LyXParagraph::size_type pos = cursor.pos;
2938 LyXParagraph * par = cursor.par;
2940 while (par && !found) {
2941 while ((inset = par->ReturnNextInsetPointer(pos))){
2942 if (inset->LyxCode() == code) {
2950 return found ? inset : 0;
2954 // Each "owner" should have it's own message method. lyxview and
2955 // the minibuffer would use the minibuffer, but lyxserver would
2956 // send an ERROR signal to its client. Alejandro 970603
2957 // This func is bit problematic when it comes to NLS, to make the
2958 // lyx servers client be language indepenent we must not translate
2959 // strings sent to this func.
2960 void LyXFunc::setErrorMessage(string const & m) const
2962 dispatch_buffer = m;
2967 void LyXFunc::setMessage(string const & m)
2969 dispatch_buffer = m;