home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / lyx-0.13.2.tar.gz / lyx-0.13.2.tar / lyx-0.13.2 / src / lyxfunc.C < prev    next >
C/C++ Source or Header  |  1998-04-23  |  63KB  |  2,533 lines

  1. /* This file is part of
  2. * ======================================================
  3. *           LyX, The Document Processor
  4. *      
  5. *        Copyright (C) 1995 Matthias Ettrich
  6. *           Copyright (C) 1995-1998 The LyX Team.
  7. *
  8. *======================================================*/
  9.  
  10. #include <config.h>
  11.  
  12. #include <stdlib.h>
  13. #include <ctype.h>
  14. #include <string.h>
  15. #if defined(__sgi)
  16. #include <strings.h>
  17. #endif
  18.  
  19. #ifdef __GNUG__
  20. #pragma implementation
  21. #endif
  22.  
  23. #include "definitions.h"
  24. #include "lyxlookup.h"
  25. #include "kbmap.h"
  26. #include "lyxfunc.h"
  27. #include "bufferlist.h"
  28. #include "lyxserver.h"
  29. #include "lyx.h"
  30. #include "intl.h"
  31. #include "lyx_main.h"
  32. #include "lyx_cb.h"
  33. #include "insetlatexaccent.h"
  34. #include "insettoc.h"
  35. #include "insetlof.h"
  36. #include "insetloa.h"
  37. #include "insetlot.h"
  38. #include "insetref.h"
  39. #include "insetparent.h"
  40. #include "formulamacro.h"
  41. #include "toolbar.h"
  42. #include "spellchecker.h" // RVDK_PATCH_5
  43. #include "minibuffer.h"
  44. #include "vspace.h"
  45. #include "insetbib.h"
  46. #include "LyXView.h"
  47. #include "insetindex.h"
  48. #include "insetinclude.h"
  49. #include "filedlg.h"
  50. #include "lyx_gui_misc.h"
  51. #include "filetools.h"
  52. #include "lyxscreen.h"
  53. #include "error.h"
  54. #include "lyxrc.h"
  55. #include "lyxtext.h"
  56. #include "gettext.h"
  57. #include "trans_mgr.h"
  58.  
  59. //     $Id: lyxfunc.C,v 1.1.1.1 1998/04/23 16:02:53 larsbj Exp $    
  60.  
  61. #if !defined(lint) && !defined(WITH_WARNINGS)
  62. static char vcid[] = "$Id: lyxfunc.C,v 1.1.1.1 1998/04/23 16:02:53 larsbj Exp $";
  63. #endif /* lint */
  64.  
  65. extern bool cursor_follows_scrollbar;
  66.  
  67. extern void InsertAsciiFile(bool);
  68. extern void math_insert_symbol(char const*);
  69. extern Bool math_insert_greek(char const); // why "Bool"?
  70. extern BufferList bufferlist;
  71. extern LyXServer *lyxserver;
  72. extern short greek_kb_flag;
  73. extern FD_form_toc *fd_form_toc;
  74. extern bool selection_possible;
  75.  
  76. extern kb_keymap *toplevel_keymap;
  77.  
  78. extern void BeforeChange();
  79. extern void MenuWrite(Buffer*);
  80. extern void MenuWriteAs(Buffer*);
  81. extern void MenuRunLaTeX(Buffer*);
  82. extern void MenuRunChktex(Buffer*);
  83. extern bool MenuRunDvips(Buffer *,bool);
  84. extern void MenuPrint(Buffer*);
  85. extern void MenuSendto();
  86. extern void QuitLyX();
  87. extern void MenuFax(Buffer *);
  88. extern void MenuMakeLaTeX(Buffer *);
  89. extern void MenuMakeLinuxDoc(Buffer *);
  90. extern void MenuMakeAscii(Buffer *);
  91. extern void MenuPasteSelection(char at);
  92. extern LyXAction lyxaction;
  93. // (alkis)
  94. extern tex_accent_struct get_accent(kb_action action);
  95.  
  96. extern void AutoSave();
  97. extern void MenuSearch();
  98. extern void CopyCB();
  99. extern void CopyEnvironmentCB();
  100. extern void PasteEnvironmentCB();
  101. extern void GotoNote();
  102. extern void NoteCB();
  103. extern void OpenStuff();
  104. extern void HyphenationPoint();
  105. extern void Ldots();
  106. extern void EndOfSentenceDot();
  107. extern void HFill();
  108. extern void MenuUndo();
  109. extern void MenuRedo();
  110. extern void SmallUpdate(signed char);
  111. extern void SetUpdateTimer(float timer= 0.3);
  112. extern void FreeUpdateTimer();
  113. extern bool MenuPreview(Buffer*);
  114. extern bool MenuPreviewPS(Buffer*);
  115. extern void MenuInsertLabel();
  116. extern void MenuInsertRef();
  117. extern void MenuLayoutCharacter();
  118. extern void MenuLayoutParagraph();
  119. extern void MenuLayoutDocument();
  120. extern void MenuLayoutPaper();
  121. extern void MenuLayoutTable(int flag);
  122. extern void MenuLayoutQuotes();
  123. extern void MenuLayoutPreamble();
  124. extern void bulletForm();
  125.  
  126. extern Buffer * NewLyxFile(LString const &);
  127. extern void LoadLyXFile(LString const &);
  128. extern void Reconfigure();
  129.  
  130. extern int current_layout;
  131. extern int getISOCodeFromLaTeX(char *);
  132.  
  133. extern int UnlockInset(UpdatableInset*);
  134.  
  135. extern void ShowLatexLog();
  136.  
  137. extern void UpdateInset(Inset* inset, bool mark_dirty = true);
  138.  
  139. /* === globals =========================================================== */
  140.  
  141. bool LyXFunc::show_sc = true;
  142.  
  143.  
  144. LyXFunc::LyXFunc(LyXView *o)
  145.     :owner(o)
  146. {
  147.     meta_fake_bit = 0;
  148.     lyx_dead_action = LFUN_NOACTION;
  149.     lyx_calling_dead_action = LFUN_NOACTION;
  150.     setupLocalKeymap();
  151. }
  152.  
  153.  
  154. LyXFunc::~LyXFunc()
  155. {
  156. }
  157.  
  158.  
  159. LString LyXFunc::argAsString(char const *const argument)
  160. {
  161.     LString tmp(argument);
  162.  
  163.     if (tmp.empty()) {
  164.         // get the arg from somewhere else, a popup, or ask for
  165.         // it in the minibuffer.
  166.     }
  167.     lyxerr.debug("argAsString: <" + tmp + '>');
  168.     return tmp;
  169. }
  170.  
  171.  
  172. // I changed this func slightly. I commented out the ...FinishUndo(),
  173. // this means that all places that used to have a moveCursorUpdate, now
  174. // have a ...FinishUndo() as the preceeding statement. I have also added
  175. // a moveCursorUpdate to some of the functions that updated the cursor, but
  176. // that did not show its new position.
  177. inline
  178. void LyXFunc::moveCursorUpdate(bool selecting)
  179. {
  180.     if (selecting || owner->currentBuffer()->text->mark_set) {
  181.         owner->currentBuffer()->text->SetSelection();
  182.         owner->currentView()->getScreen()->ToggleToggle();
  183.         owner->currentBuffer()->update(0);
  184.     } else {
  185.         owner->currentBuffer()->update(-2); // this IS necessary
  186.         // (Matthias) 
  187.     }
  188.     owner->currentView()->getScreen()->ShowCursor();
  189.     
  190.     /* ---> Everytime the cursor is moved, show the current font state. */
  191.     // should this too me moved out of this func?
  192.     //owner->getMiniBuffer()->Set(CurrentState());
  193. }
  194.  
  195.  
  196. int LyXFunc::processKeyEvent(XEvent *ev)
  197. {
  198.     char s_r[10];
  199.     s_r[9] = '\0';
  200.     int num_bytes;
  201.     int action; 
  202.     char *argument = 0;
  203.     XKeyEvent *keyevent = &ev->xkey;
  204.     KeySym keysym_return;
  205.  
  206.     num_bytes = LyXLookupString(ev, s_r, 10, &keysym_return);
  207.  
  208.     if (lyxerr.debugging(Error::KEY)) {
  209.         lyxerr.print(LString("KeySym is ")
  210.                  + XKeysymToString(keysym_return)
  211.                  + "["
  212.                  + int(keysym_return) + "]"
  213.                  + " and num_bytes is "
  214.                  + num_bytes
  215.                  + " the string returned is \""
  216.                  + LString(s_r) + '\"');
  217.     }
  218.     // Do nothing if we have nothing (JMarc)
  219.     if (num_bytes == 0 && keysym_return == NoSymbol) {
  220.         lyxerr.debug("Empty kbd action (probably composing)",
  221.                  Error::KEY);
  222.         return 0;
  223.     }
  224.     
  225.     // this function should be used always [asierra060396]
  226.     if (owner->currentView()->available() &&
  227.         owner->currentBuffer()->the_locking_inset &&
  228.         keysym_return == XK_Escape) {
  229.         UnlockInset(owner->currentBuffer()->the_locking_inset);
  230.         owner->currentBuffer()->text->CursorRight();
  231.         return 0;
  232.     }
  233.  
  234.     // Can we be sure that this will work for all X-Windows
  235.     // implementations? (Lgb)
  236.     // This code snippet makes lyx ignore some keys. Perhaps
  237.     // all of them should me explictly mentioned?
  238.     if((keysym_return >= XK_Shift_L && keysym_return <= XK_Hyper_R)
  239.        || keysym_return == XK_Mode_switch || keysym_return == 0x0)
  240.         return 0;
  241.  
  242.     // Do a one-deep top-level lookup for
  243.     // cancel and meta-fake keys. RVDK_PATCH_5
  244.     cancel_meta_seq.reset();
  245.  
  246.     action = cancel_meta_seq.addkey(keysym_return, keyevent->state
  247.                     &(ShiftMask|ControlMask
  248.                       |Mod1Mask)); 
  249.  
  250.     // When not cancel or meta-fake, do the normal lookup. 
  251.     // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
  252.     // Mostly, meta_fake_bit = 0. RVDK_PATCH_5.
  253.     if ( (action != LFUN_CANCEL) && (action != LFUN_META_FAKE) ) {
  254.  
  255.         // remove Caps Lock and Mod2 as a modifiers
  256.         action = keyseq.addkey(keysym_return,
  257.                        (keyevent->state | meta_fake_bit)
  258.                        &(ShiftMask|ControlMask
  259.                      |Mod1Mask));      
  260.     }
  261.     // Dont remove this unless you know what you are doing.
  262.     meta_fake_bit = 0;
  263.         
  264.     if (action == 0) action = LFUN_PREFIX;
  265.  
  266.     if (lyxerr.debugging(Error::KEY)) {
  267.         lyxerr.print(LString("Key [")
  268.                  + int(action) + "]["
  269.                  + keyseq.print() + "]["
  270.                  + num_bytes +"]");
  271.     }
  272.  
  273.     // already here we know if it any point in going further
  274.     // why not return already here if action == -1 and
  275.     // num_bytes == 0? (Lgb)
  276.  
  277.     if(keyseq.length>1 || keyseq.length<-1){
  278.         owner->getMiniBuffer()->Set(keyseq.print());
  279.     }
  280.  
  281.     if (action==-1) {
  282.         if (keyseq.length<-1) { // unknown key sequence...
  283.             LyXBell();
  284.             owner->getMiniBuffer()->Set(_("Unknown sequence:"),
  285.                             keyseq.print());
  286.             return 0;
  287.         }
  288.     
  289.         char isochar = keyseq.getiso();
  290.         if (!(keyevent->state&ControlMask) &&
  291.             !(keyevent->state&Mod1Mask) &&
  292.             (isochar && keysym_return < 0xF000)) {
  293.             argument = &s_r[0]; // shall this be here
  294.             argument[0] = isochar;
  295.             argument[1] = 0;
  296.         }
  297.         if (!argument) {
  298.             lyxerr.debug("Empty argument!");
  299.             // This can`t possibly be of any use
  300.             // so we`ll skip the dispatch.
  301.             return 0;
  302.         }
  303.     } else
  304.         if (action==LFUN_SELFINSERT) {
  305.             argument = &s_r[0];
  306.             argument[1] = 0;
  307.         }
  308.     
  309.         bool tmp_sc = show_sc;
  310.     show_sc = false;
  311.     Dispatch(action, argument);
  312.     show_sc = tmp_sc;
  313.     
  314.     // Need this for deadkeys (alkis)
  315.     //keyseq.length=0;
  316.     // ...but that breaks the minibuffer's display of "M-"...
  317. #ifdef WITH_WARNINGS
  318. #warning How does the deadkeys react to this?
  319. #endif
  320.     return 0;
  321.  
  322.  
  323. LString LyXFunc::Dispatch(LString const &cmd, LString const &arg)
  324. {
  325.     return Dispatch(lyxaction.LookupFunc(cmd.c_str()),
  326.             arg.c_str());
  327. }
  328.  
  329.  
  330. LString LyXFunc::Dispatch(int ac,
  331.               char const *do_not_use_this_arg)
  332. {
  333.     char const * argument = 0;
  334.     kb_action action;
  335.         
  336.  
  337.     FL_OBJECT *ob = 0;  // This will disapear soon
  338.     
  339.         // we have not done anything wrong yet.
  340.         errorstat = false;
  341.     dispatch_buffer = LString();
  342.     
  343.     // if action is a pseudo-action, we need the real action
  344.     if (lyxaction.isPseudoAction(ac)) {
  345.         char const *tmparg = 0;
  346.         action = (kb_action)lyxaction.retrieveActionArg(ac, &tmparg);
  347.         if (tmparg)
  348.             argument = tmparg;
  349.     } else {
  350.         action = (kb_action)ac;
  351.         argument = do_not_use_this_arg; // except here
  352.     }
  353.     
  354.     selection_possible = false;
  355.     
  356.     if (owner->currentView()->available() 
  357.         && owner->currentView()->getScreen())
  358.         owner->currentView()->getScreen()->HideCursor();
  359.  
  360.     if(!owner->currentView()->available()) {
  361.         // This lists the allowed funcs when we have no
  362.         // buffer loaded
  363.         switch(action){
  364.         case LFUN_MENU_OPEN_BY_NAME:
  365.         case LFUN_PREFIX:
  366.         case LFUN_MENUNEW:
  367.         case LFUN_MENUNEWTMPLT:
  368.         case LFUN_MENUOPEN:
  369.         case LFUN_QUIT:
  370.         case LFUN_PUSH_TOOLBAR:
  371.         case LFUN_ADD_TO_TOOLBAR:
  372.         case LFUN_EXEC_COMMAND:
  373.         case LFUN_DROP_LAYOUTS_CHOICE:
  374.         case LFUN_FILE_NEW:
  375.         case LFUN_FILE_OPEN:
  376.         case LFUN_RECONFIGURE:
  377.         case LFUN_CANCEL:
  378.         case LFUN_APROPOS:
  379.         case LFUN_META_FAKE:
  380.  
  381.             break;
  382.         case LFUN_UNKNOWN_ACTION:
  383.             setErrorMessage(N_("Unknown action"));
  384.             goto exit_with_message;
  385.         default:
  386.             setErrorMessage(N_("Command not allowed with"
  387.                     "out any document open"));
  388.             goto exit_with_message;  // action not allowed
  389.         }
  390.     }
  391.     
  392.     commandshortcut = LString();
  393.     
  394.     if (lyxrc->display_shortcuts && show_sc) {
  395.         if (action != LFUN_SELFINSERT) {
  396.             // Put name of command and list of shortcuts
  397.             // for it in minibuffer
  398.             LString comname = lyxaction.getActionName(action);
  399.  
  400.             int pseudoaction = action;
  401.             bool argsadded = false;
  402.  
  403.             LString argu = argument;
  404.             if (!argu.empty()) {
  405.                 // If we have the command with argument, 
  406.                 // this is better
  407.                 pseudoaction = 
  408.                     lyxaction.searchActionArg(action,
  409.                                     argument);
  410.  
  411.                 if (pseudoaction == -1) {
  412.                     pseudoaction = action;
  413.                 } else {
  414.                     comname += " " + argu;
  415.                     argsadded = true;
  416.                 }
  417.             }
  418.  
  419.             LString shortcuts = toplevel_keymap->findbinding(pseudoaction);
  420.  
  421.             if (!shortcuts.empty()) {
  422.                 comname += ": " + shortcuts;
  423.             } else if (!argsadded) {
  424.                 comname += " " + argu;
  425.             }
  426.  
  427.             if (!comname.empty()) {
  428.                 comname.strip();
  429.                 commandshortcut = "(" + comname + ')';
  430.                 owner->getMiniBuffer()->Set(commandshortcut);
  431.                 // Here we could even add a small pause,
  432.                 // to annoy the user and make him learn
  433.                 // the shortcuts.
  434.                 // No! That will just annoy, not teach
  435.                 // anything. The user will read the messages
  436.                 // if they are interested. (Asger)
  437.             }
  438.         }
  439.         }
  440.     
  441.         // Now that we know which action, if the buffer is RO let's check 
  442.     // whether the action is legal.  Alejandro 970603
  443.         if (owner->currentView()->available() && 
  444.             owner->currentBuffer()->isReadonly() && 
  445.             lyxaction.isFuncRO(action)) {
  446.         setErrorMessage(N_("Document is read-only"));
  447.         lyxerr.debug("Error: Document is read-only.");
  448.         goto exit_with_message;
  449.     }
  450.     
  451.     // If in math mode pass the control to
  452.     // the math inset [asierra060396]
  453.     if (owner->currentView()->available() &&
  454.         owner->currentBuffer()->the_locking_inset) {
  455.         if (action>1 
  456.             || (action==LFUN_UNKNOWN_ACTION && keyseq.length>=-1)) {
  457.                 char s[8]="";
  458.             if (action==LFUN_UNKNOWN_ACTION && !argument) {
  459.                 sprintf(s, "%c", keyseq.getiso());
  460.                 argument = &s[0];
  461.             }
  462.             // Undo/Redo pre 0.13 is a bit tricky for insets.            
  463.                 if (action==LFUN_UNDO) {
  464.                 int slx, sly;
  465.                 UpdatableInset* inset =
  466.                     owner->currentBuffer()->the_locking_inset;
  467.                 inset->GetCursorPos(slx, sly);
  468.                 UnlockInset(inset);
  469.                 MenuUndo();
  470.                 inset = (UpdatableInset*)owner->currentBuffer()->text->cursor.par->GetInset(owner->currentBuffer()->text->cursor.pos);
  471.                 if (inset) 
  472.                     inset->Edit(slx, sly);
  473.                 return LString();
  474.             } else 
  475.                 if (action==LFUN_REDO) {
  476.                     int slx, sly;
  477.                     UpdatableInset* inset = owner->currentBuffer()->the_locking_inset;
  478.                     inset->GetCursorPos(slx, sly);
  479.                     UnlockInset(inset);
  480.                     MenuRedo();
  481.                     inset = (UpdatableInset*)owner->currentBuffer()->text->cursor.par->GetInset(owner->currentBuffer()->text->cursor.pos);
  482.                     if (inset)
  483.                         inset->Edit(slx, sly);
  484.                     return LString();
  485.                 } else
  486.                     if (owner->currentBuffer()->the_locking_inset->LocalDispatch(action, argument))
  487.                         return LString();
  488.                     else {
  489.                         setMessage(N_("Text mode"));
  490.                         if (action==LFUN_RIGHT || action==-1)
  491.                             owner->currentBuffer()->text->CursorRight();
  492.                         if (action==LFUN_LEFT || action==LFUN_RIGHT)
  493.                             return LString();
  494.                     }
  495.         }
  496.     }
  497.  
  498.     switch(action) {
  499.         // --- Misc -------------------------------------------
  500.   case LFUN_WORDFINDFORWARD     : 
  501.   case LFUN_WORDFINDBACKWARD : 
  502.   { 
  503.       LyXText *ltCur;
  504.       static LString last_search;
  505.       LString searched_string;
  506.         
  507.       LString arg = argAsString(argument);
  508.             
  509.       if (!arg.empty()) {
  510.       last_search = arg;
  511.       searched_string = arg;
  512.       } else {
  513.       searched_string = last_search;
  514.       }
  515.  
  516.       ltCur =     owner->currentView()->currentBuffer()->text ;     
  517.  
  518.       if (!searched_string.empty() &&
  519.       (     (action == LFUN_WORDFINDBACKWARD) ? 
  520.          ltCur->SearchBackward( searched_string.c_str() ) :
  521.          ltCur->SearchForward(    searched_string.c_str() ) 
  522.           )){
  523.  
  524.       //    ??? What is that ???
  525.       owner->currentView()->currentBuffer()->update(-2);
  526.  
  527.       // ??? Needed ???
  528.       // clear the selection (if there is any) 
  529.       owner->currentView()->getScreen()->ToggleSelection();
  530.       owner->currentView()->currentBuffer()->text->ClearSelection();
  531.       // Move cursor so that successive C-s 's will not stand in place. 
  532.       if( action == LFUN_WORDFINDFORWARD ) 
  533.           owner->currentBuffer()->text->CursorRightOneWord();
  534.       owner->currentBuffer()->text->FinishUndo();
  535.       moveCursorUpdate(false);
  536.  
  537.       // ??? Needed ???
  538.       // set the new selection 
  539.       // SetSelectionOverLenChars(owner->currentView()->currentBuffer()->text, iLenSelected);
  540.       owner->currentView()->getScreen()->ToggleSelection(false);
  541.       } else 
  542.       LyXBell();    
  543.      
  544.       // REMOVED : if (owner->currentView()->getWorkArea()->focus)
  545.       owner->currentView()->getScreen()->ShowCursor();
  546.   }
  547.   break;
  548.     case LFUN_PREFIX:
  549.     {
  550.         if (owner->currentView()->available()
  551.             && owner->currentView()->getScreen()) {
  552.             owner->currentBuffer()->update(-2);
  553.         }
  554.         owner->getMiniBuffer()->Set(keyseq.print(true), 
  555.                         LString(), LString(), 1);
  556.     }
  557.     break;
  558.  
  559.     // --- Misc -------------------------------------------
  560.     case LFUN_EXEC_COMMAND:
  561.         owner->getMiniBuffer()->ExecCommand(); 
  562.         break;
  563.         
  564.     case LFUN_CANCEL:                   // RVDK_PATCH_5
  565.         keyseq.reset();
  566.         meta_fake_bit = 0;
  567.         if(owner->currentView()->available())
  568.             // cancel any selection
  569.             Dispatch(int(LFUN_MARK_OFF), NULL);
  570.         setMessage(N_("Cancel"));
  571.         break;
  572.  
  573.     case LFUN_META_FAKE:                                 // RVDK_PATCH_5
  574.     {
  575.         meta_fake_bit = Mod1Mask;
  576.         setMessage("M-"+keyseq.print(true)); // RVDK_PATCH_5
  577.     }
  578.     break;  
  579.  
  580.     case LFUN_READ_ONLY_TOGGLE:
  581.         if (owner->currentBuffer()->lyxvc.inUse()) {
  582.             owner->currentBuffer()->lyxvc.toggleReadOnly();
  583.         } else {
  584.             owner->currentBuffer()->setReadonly(
  585.                 !owner->currentBuffer()->isReadonly());
  586.         }
  587.         break;
  588.         
  589.     case LFUN_CENTER: // this is center and redraw.
  590.         BeforeChange();
  591.         if (owner->currentBuffer()->text->cursor.y >
  592.             owner->currentView()->getWorkArea()->h / 2)    {
  593.             owner->currentView()->getScreen()->
  594.                 Draw(owner->currentBuffer()->text->cursor.y -
  595.                      owner->currentView()->getWorkArea()->h/2);
  596.         } else { // <=
  597.             owner->currentView()->getScreen()->
  598.                 Draw(0);
  599.         }
  600.         owner->currentBuffer()->update(0);
  601.         owner->currentView()->redraw();
  602.         break;
  603.         
  604.         // --- Menus -----------------------------------------------
  605.     case LFUN_MENUNEW:
  606.         MenuNew(false);
  607.         break;
  608.         
  609.     case LFUN_MENUNEWTMPLT:
  610.         MenuNew(true);
  611.         break;
  612.         
  613.     case LFUN_MENUOPEN:
  614.         MenuOpen();
  615.         break;
  616.         
  617.     case LFUN_CLOSEBUFFER:
  618.         CloseBuffer();
  619.         break;
  620.         
  621.     case LFUN_MENUWRITE:
  622.         MenuWrite(owner->currentBuffer());
  623.         break;
  624.         
  625.     case LFUN_MENUWRITEAS:
  626.         MenuWriteAs(owner->currentBuffer());
  627.         break;
  628.         
  629.     case LFUN_MENURELOAD:
  630.         reloadBuffer();
  631.         break;
  632.         
  633.     case LFUN_PREVIEW:
  634.         MenuPreview(owner->currentBuffer());
  635.         break;
  636.             
  637.     case LFUN_PREVIEWPS:
  638.         MenuPreviewPS(owner->currentBuffer());
  639.         break;
  640.         
  641.     case LFUN_RUNLATEX:
  642.         MenuRunLaTeX(owner->currentBuffer());
  643.         break;
  644.         
  645.     case LFUN_RUNCHKTEX:
  646.         MenuRunChktex(owner->currentBuffer());
  647.         break;
  648.         
  649.     case LFUN_RUNDVIPS:
  650.         MenuRunDvips(owner->currentBuffer(), false);
  651.         break;
  652.         
  653.     case LFUN_MENUPRINT:
  654.         MenuPrint(owner->currentBuffer());
  655.         break;
  656.         
  657.     case LFUN_FAX:
  658.         MenuFax(owner->currentBuffer());
  659.         break;
  660.             
  661.     case LFUN_EXPORT:
  662.     {
  663.         //needs argument as string
  664.         LString extyp=argAsString(argument);
  665.         
  666.         // latex
  667.         if (extyp == "latex") {
  668.             // make sure that this buffer is not linuxdoc
  669.             MenuMakeLaTeX(owner->currentBuffer());
  670.         }
  671.         // linuxdoc
  672.         else if (extyp == "linuxdoc") {
  673.             // make sure that this buffer is not latex
  674.             MenuMakeLinuxDoc(owner->currentBuffer());
  675.         }
  676.         // dvi
  677.         else if (extyp == "dvi") {
  678.             // Run LaTeX as "Update dvi..." Bernhard.
  679.             // We want the dvi in the current directory. This
  680.             // is achieved by temporaily disabling use of
  681.             // temp directory. As a side-effect, we get
  682.             // *.log and *.aux files also. (Asger)
  683.             bool flag = lyxrc->use_tempdir;
  684.             lyxrc->use_tempdir = false;
  685.             MenuRunLaTeX(owner->currentBuffer());
  686.             lyxrc->use_tempdir = flag;
  687.         }
  688.         // postscript
  689.         else if (extyp == "postscript") {
  690.             // Start Print-dialog. Not as good as dvi... Bernhard.
  691.             MenuPrint(owner->currentBuffer());
  692.             // Since the MenuPrint is a pop-up, we can't use
  693.             // the same trick as above. (Asger)
  694.             // MISSING: Move of ps-file :-(
  695.         }
  696.         // ascii
  697.         else if (extyp == "ascii") {
  698.             MenuMakeAscii(owner->currentBuffer());
  699.         }
  700.         else if (extyp == "custom") {
  701.             MenuSendto();
  702.             break;
  703.         }
  704.         else {
  705.             setErrorMessage(LString(N_("Unknown export type: "))
  706.                     + extyp);
  707.         }
  708.     }
  709.     break;
  710.         
  711.     case LFUN_QUIT:
  712.         QuitLyX();
  713.         break;
  714.         
  715.     case LFUN_TOCVIEW:
  716.         TocUpdateCB(ob, 0);
  717.         if (fd_form_toc->form_toc->visible) {
  718.             fl_raise_form(fd_form_toc->form_toc);
  719.         } else {
  720.             fl_show_form(fd_form_toc->form_toc,
  721.                      FL_PLACE_MOUSE |
  722.                      FL_FREE_SIZE, FL_FULLBORDER,
  723.                      _("Table of Contents"));
  724.         }
  725.         break;
  726.         
  727.     case LFUN_TOC_INSERT:
  728.     {
  729.         Inset *new_inset =
  730.             new InsetTOC(owner->currentBuffer());
  731.         owner->currentBuffer()->insertInset(new_inset,
  732.                             "Standard", true);
  733.         break;
  734.     }
  735.     
  736.     case LFUN_LOF_INSERT:
  737.     {
  738.         Inset *new_inset =
  739.             new InsetLOF(owner->currentBuffer());
  740.         owner->currentBuffer()->insertInset(new_inset,
  741.                             "Standard", true);
  742.         break;
  743.     }
  744.     
  745.     case LFUN_LOA_INSERT:
  746.     {
  747.         Inset *new_inset =
  748.             new InsetLOA(owner->currentBuffer());
  749.         owner->currentBuffer()->insertInset(new_inset,
  750.                             "Standard", true);
  751.         break;
  752.     }
  753.  
  754.     case LFUN_LOT_INSERT:
  755.     {
  756.         Inset *new_inset =
  757.             new InsetLOT(owner->currentBuffer());
  758.         owner->currentBuffer()->insertInset(new_inset,
  759.                             "Standard", true);
  760.         break;
  761.     }
  762.         
  763.     case LFUN_TABLE:
  764.         TableCB(ob, 0);
  765.         break;
  766.         
  767.     case LFUN_FIGURE:
  768.         FigureCB(ob, 0);
  769.         break;
  770.         
  771.     case LFUN_AUTOSAVE:
  772.         AutoSave();
  773.         break;
  774.         
  775.     case LFUN_UNDO:
  776.         MenuUndo();
  777.         break;
  778.         
  779.     case LFUN_REDO:
  780.         MenuRedo();
  781.         break;
  782.         
  783.     case LFUN_MENUSEARCH:
  784.         MenuSearch();
  785.         break;
  786.         
  787.     case LFUN_PASTE:
  788.         PasteCB();
  789.         break;
  790.         
  791.     case LFUN_PASTESELECTION:
  792.     {
  793.             bool asPara = false;
  794.         if (LString(argument) == "paragraph") asPara = true;
  795.         MenuPasteSelection(asPara);
  796.         break;
  797.     }
  798.  
  799.     case LFUN_CUT:
  800.         CutCB();
  801.         break;
  802.         
  803.     case LFUN_COPY:
  804.         CopyCB();
  805.         break;
  806.         
  807.     case LFUN_LAYOUT_COPY:
  808.         CopyEnvironmentCB();
  809.         break;
  810.         
  811.     case LFUN_LAYOUT_PASTE:
  812.         PasteEnvironmentCB();
  813.         break;
  814.         
  815.     case LFUN_GOTOERROR:
  816.         owner->currentView()->gotoError();
  817.         break;
  818.         
  819.     case LFUN_REMOVEERRORS:
  820.         if (owner->currentBuffer()->removeAutoInsets()) {
  821.             owner->currentView()->redraw();
  822.             owner->currentView()->fitCursor();
  823.             owner->currentView()->updateScrollbar();
  824.         }
  825.         break;
  826.         
  827.     case LFUN_GOTONOTE:
  828.         GotoNote();
  829.         break;
  830.         
  831.     case LFUN_OPENSTUFF:
  832.         OpenStuff();
  833.         break;
  834.         
  835.     case LFUN_HYPHENATION:
  836.         HyphenationPoint();
  837.         break;
  838.         
  839.     case LFUN_LDOTS:
  840.         Ldots();
  841.         break;
  842.         
  843.     case LFUN_END_OF_SENTENCE:
  844.         EndOfSentenceDot();
  845.         break;
  846.         
  847.     case LFUN_HFILL:
  848.         HFill();
  849.         break;
  850.         
  851.     case LFUN_DEPTH:
  852.         DepthCB(ob, 0);
  853.         break;
  854.         
  855.     case LFUN_DEPTH_MIN:
  856.         DepthCB(ob, -1);
  857.         break;
  858.         
  859.     case LFUN_DEPTH_PLUS:
  860.         DepthCB(ob, 1);
  861.         break;
  862.         
  863.     case LFUN_FREE:
  864.         FreeCB();
  865.         break;
  866.         
  867.     case LFUN_TEX:
  868.         TexCB();
  869.         break;
  870.         
  871.     case LFUN_MELT:
  872.         MeltCB(ob, 0);
  873.         break;
  874.         
  875.     case LFUN_RECONFIGURE:
  876.         Reconfigure();
  877.         break;
  878.  
  879.     case LFUN_FOOTMELT:
  880.         if (owner->currentView()->available()
  881.             && !owner->currentBuffer()->text->selection
  882.             && owner->currentBuffer()->text->cursor.par->footnoteflag
  883.             != LyXParagraph::NO_FOOTNOTE)
  884.         { // only melt footnotes with FOOTMELT, not margins etc
  885.           if(owner->currentBuffer()->text->cursor.par->footnotekind == LyXParagraph::FOOTNOTE)
  886.             MeltCB(ob,0);
  887.         }
  888.         else
  889.             FootCB(ob, 0); 
  890.         break;
  891.  
  892.     case LFUN_MARGINMELT:
  893.         if (owner->currentView()->available()
  894.             && !owner->currentBuffer()->text->selection
  895.             && owner->currentBuffer()->text->cursor.par->footnoteflag
  896.             != LyXParagraph::NO_FOOTNOTE)
  897.         { // only melt margins
  898.           if(owner->currentBuffer()->text->cursor.par->footnotekind == LyXParagraph::MARGIN)
  899.             MeltCB(ob,0);
  900.         }
  901.         else
  902.             MarginCB(ob, 0); 
  903.         break;
  904.         
  905.         // --- version control -------------------------------
  906.     case LFUN_VC_REGISTER:
  907.     {
  908.         if (!owner->currentBuffer()->lyxvc.inUse())
  909.             owner->currentBuffer()->lyxvc.registrer();
  910.     }
  911.     break;
  912.         
  913.     case LFUN_VC_CHECKIN:
  914.     {
  915.         if (owner->currentBuffer()->lyxvc.inUse()
  916.             && !owner->currentBuffer()->isReadonly())
  917.             owner->currentBuffer()->lyxvc.checkIn();
  918.     }
  919.     break;
  920.         
  921.     case LFUN_VC_CHECKOUT:
  922.     {
  923.         if (owner->currentBuffer()->lyxvc.inUse()
  924.             && owner->currentBuffer()->isReadonly())
  925.             owner->currentBuffer()->lyxvc.checkOut();
  926.     }
  927.     break;
  928.     
  929.     case LFUN_VC_REVERT:
  930.     {
  931.         owner->currentBuffer()->lyxvc.revert();
  932.     }
  933.     break;
  934.         
  935.     case LFUN_VC_UNDO:
  936.     {
  937.         owner->currentBuffer()->lyxvc.undoLast();
  938.     }
  939.     break;
  940.         
  941.     case LFUN_VC_HISTORY:
  942.     {
  943.         owner->currentBuffer()->lyxvc.showLog();
  944.         break;
  945.     }
  946.     
  947.     // --- buffers ----------------------------------------
  948.     case LFUN_PREVBUFFER:
  949. #ifdef WITH_WARNINGS
  950. #warning fix this please
  951. #endif
  952.         break;
  953.             
  954.     case LFUN_FILE_INSERT:
  955.     {
  956.         // needs argument as string
  957.         LString fil = argAsString(argument);
  958.         MenuInsertLyXFile(fil);
  959.     }
  960.     break;
  961.     
  962.     case LFUN_FILE_INSERT_ASCII:
  963.     {
  964.             bool asPara = (LString(argument) == "paragraph");
  965.         InsertAsciiFile(asPara);
  966.     }
  967.     break;
  968.     
  969.     case LFUN_FILE_NEW:
  970.     {
  971.         // servercmd: argument must be <file>:<template>
  972.         Buffer *tmpbuf = NewLyxFile(argument);
  973.         if (tmpbuf)
  974.             owner->currentView()->setBuffer(tmpbuf);
  975.     }
  976.         break;
  977.             
  978.     case LFUN_FILE_OPEN:
  979.         owner->currentView()->setBuffer(
  980.             bufferlist.loadLyXFile(argument));
  981.         break;
  982.  
  983.     case LFUN_LATEX_LOG:
  984.         ShowLatexLog();
  985.         break;
  986.         
  987.     case LFUN_LAYOUTNO:
  988.     {
  989.         lyxerr.debug("LFUN_LAYOUTNO: (arg) " + LString(argument));
  990.         int sel = atoi(argument);
  991.         lyxerr.debug(LString("LFUN_LAYOUTNO: (sel) ") + int(sel));
  992.         
  993.         // Should this give a setMessage instead?
  994.         if (sel == 0) 
  995.             return LString(); // illegal argument
  996.  
  997.         sel--; // sel 1..., but layout 0...
  998.  
  999.         // Pretend we got the name instead.
  1000.         Dispatch(int(LFUN_LAYOUT), 
  1001.              lyxstyle.NameOfLayout(owner->currentBuffer()->
  1002.                            text->parameters->
  1003.                            textclass,
  1004.                            sel).c_str());
  1005.         return LString();
  1006.     }
  1007.         
  1008.     case LFUN_LAYOUT:
  1009.     {
  1010.         lyxerr.debug("LFUN_LAYOUT: (arg) "
  1011.                  + LString(argument));
  1012.         
  1013.         // Derive layout number from given argument (string)
  1014.         // and current buffer's textclass (number). */    
  1015.         int layoutno =
  1016.             lyxstyle.NumberOfLayout(owner->
  1017.                         currentBuffer()->
  1018.                         text->parameters->
  1019.                         textclass,
  1020.                         argument);
  1021.  
  1022.         // see if we found the layout number:
  1023.         if (layoutno == -1) {
  1024.             setErrorMessage(LString(N_("Layout ")) + argument + 
  1025.                     N_(" not known"));
  1026.             break;
  1027.         }
  1028.             
  1029.         if (current_layout != layoutno) {
  1030.             owner->currentView()->getScreen()->HideCursor();
  1031.             current_layout = layoutno;
  1032.             owner->currentBuffer()->update(-2);
  1033.             owner->currentBuffer()->text->
  1034.                 SetLayout(layoutno);
  1035.             owner->getToolbar()->combox->
  1036.                 select(owner->currentBuffer()->
  1037.                        text->cursor.par->
  1038.                        GetLayout() + 1);
  1039.             owner->currentBuffer()->update(1);
  1040.         }
  1041.     }
  1042.     break;
  1043.  
  1044.     case LFUN_LAYOUT_DOCUMENT:
  1045.         MenuLayoutDocument();
  1046.         break;
  1047.         
  1048.     case LFUN_LAYOUT_PARAGRAPH:
  1049.         MenuLayoutParagraph();
  1050.         break;
  1051.         
  1052.     case LFUN_LAYOUT_CHARACTER:
  1053.         MenuLayoutCharacter();
  1054.         break;
  1055.         
  1056.     case LFUN_LAYOUT_TABLE:
  1057.     {
  1058.             int flag = 0;
  1059.             if (LString(argument) == "true") flag = 1;
  1060.         MenuLayoutTable(flag);
  1061.     }
  1062.     break;
  1063.         
  1064.     case LFUN_LAYOUT_PAPER:
  1065.         MenuLayoutPaper();
  1066.         break;
  1067.         
  1068.     case LFUN_LAYOUT_QUOTES:
  1069.         MenuLayoutQuotes();
  1070.         break;
  1071.         
  1072.     case LFUN_LAYOUT_PREAMBLE:
  1073.         MenuLayoutPreamble();
  1074.         break;
  1075.         
  1076.     case LFUN_DROP_LAYOUTS_CHOICE:
  1077.         owner->getToolbar()->combox->Show();
  1078.         break;
  1079.  
  1080.     case LFUN_EMPH:
  1081.         EmphCB();
  1082.         break;
  1083.         
  1084.     case LFUN_BOLD:
  1085.         BoldCB();
  1086.         break;
  1087.         
  1088.     case LFUN_NOUN:
  1089.         NounCB();
  1090.         break;
  1091.         
  1092.     case LFUN_CODE:
  1093.         CodeCB();
  1094.         break;
  1095.         
  1096.     case LFUN_SANS:
  1097.         SansCB();
  1098.         break;
  1099.         
  1100.     case LFUN_ROMAN:
  1101.         RomanCB();
  1102.         break;
  1103.         
  1104.     case LFUN_DEFAULT:
  1105.         StyleResetCB();
  1106.         break;
  1107.         
  1108.     case LFUN_UNDERLINE:
  1109.         UnderlineCB();
  1110.         break;
  1111.         
  1112.     case LFUN_FONT_SIZE:
  1113.         FontSizeCB(argument);
  1114.         break;
  1115.         
  1116.     case LFUN_FONT_STATE:
  1117.         setMessage(CurrentState());
  1118.         break;
  1119.         
  1120.     case LFUN_UPCASE_WORD:
  1121.         owner->currentBuffer()->update(-2);
  1122.         FreeUpdateTimer();
  1123.         owner->currentBuffer()->text->UpcaseWord();
  1124.         owner->currentBuffer()->update(1);
  1125.         SetUpdateTimer();
  1126.         break;
  1127.         
  1128.     case LFUN_LOWCASE_WORD:
  1129.         owner->currentBuffer()->update(-2);
  1130.         FreeUpdateTimer();
  1131.         owner->currentBuffer()->text->LowcaseWord();
  1132.         owner->currentBuffer()->update(1);
  1133.         SetUpdateTimer();
  1134.         break;
  1135.         
  1136.     case LFUN_CAPITALIZE_WORD:
  1137.         owner->currentBuffer()->update(-2);
  1138.         FreeUpdateTimer();
  1139.         owner->currentBuffer()->text->CapitalizeWord();
  1140.         owner->currentBuffer()->update(1);
  1141.         SetUpdateTimer();
  1142.         break;
  1143.         
  1144.     case LFUN_INSERT_LABEL:
  1145.         MenuInsertLabel();
  1146.         break;
  1147.         
  1148.     case LFUN_INSERT_REF:
  1149.         MenuInsertRef();
  1150.         break;
  1151.         
  1152.     case LFUN_REFTOGGLE:
  1153.     {
  1154.         InsetRef *inset =
  1155.             (InsetRef*)getInsetByCode(Inset::REF_CODE);
  1156.         if (inset) {
  1157.             if (inset->getFlag()==InsetRef::REF)
  1158.                 inset->setFlag(InsetRef::PAGE_REF);
  1159.             else
  1160.                 inset->setFlag(InsetRef::REF);
  1161.             UpdateInset(inset);
  1162.         } else {
  1163.             setErrorMessage(N_("No cross-reference to toggle"));
  1164.         }
  1165.     }
  1166.     break;
  1167.     
  1168.     case LFUN_REFBACK:
  1169.     {
  1170.         owner->currentView()->restorePosition();
  1171.     }
  1172.     break;
  1173.  
  1174.     case LFUN_REFGOTO:
  1175.     {
  1176.         LString label(argument);
  1177.         if (label.empty()) {
  1178.             InsetRef *inset =
  1179.                 (InsetRef*)getInsetByCode(Inset::REF_CODE);
  1180.             if (inset)
  1181.                                 label = inset->getContents();
  1182.         }
  1183.         
  1184.         if (!label.empty()) {
  1185.             owner->currentView()->savePosition();
  1186.             owner->currentBuffer()->gotoLabel(label.c_str());
  1187.         }
  1188.     }
  1189.     break;
  1190.         
  1191.     case LFUN_MENU_OPEN_BY_NAME:
  1192.         owner->getMenus()->openByName(argument);
  1193.         break; // RVDK_PATCH_5
  1194.         
  1195.     case LFUN_SPELLCHECK:
  1196.         ShowSpellChecker();
  1197.         break; // RVDK_PATCH_5
  1198.         
  1199.         // --- Cursor Movements -----------------------------
  1200.     case LFUN_RIGHT:
  1201.     {
  1202.         Buffer *tmpbuffer = owner->currentBuffer();
  1203.         LyXText *tmptext = owner->currentBuffer()->text;
  1204.         if(!tmptext->mark_set)
  1205.             BeforeChange();
  1206.         tmpbuffer->update(-2);
  1207.         if (tmptext->cursor.pos < tmptext->cursor.par->Last()
  1208.             && tmptext->cursor.par->GetChar(tmptext->cursor.pos)
  1209.             == LYX_META_INSET
  1210.             && tmptext->cursor.par->GetInset(tmptext->cursor.pos)
  1211.             && tmptext->cursor.par->GetInset(tmptext->cursor.pos)->Editable()==2){
  1212.             Inset* tmpinset = tmptext->cursor.par->GetInset(tmptext->cursor.pos);
  1213.             setMessage(tmpinset->EditMessage());
  1214.             tmpinset->Edit(0,0);
  1215.             break;
  1216.         }
  1217.         tmptext->CursorRight();
  1218.         owner->currentBuffer()->text->FinishUndo();
  1219.         moveCursorUpdate(false);
  1220.         owner->getMiniBuffer()->Set(CurrentState());
  1221.     }
  1222.     break;
  1223.         
  1224.     case LFUN_LEFT:
  1225.     {
  1226.         // This is soooo ugly. Isn`t it possible to make
  1227.         // it simpler? (Lgb)
  1228.         LyXText *txt= owner->currentBuffer()->text;
  1229.         if(!txt->mark_set) BeforeChange();
  1230.         owner->currentBuffer()->update(-2);
  1231.         txt->CursorLeft();
  1232.         if (txt->cursor.pos < txt->cursor.par->Last()
  1233.             && txt->cursor.par->GetChar(txt->cursor.pos)
  1234.             == LYX_META_INSET
  1235.             && txt->cursor.par->GetInset(txt->cursor.pos)
  1236.             && txt->cursor.par->GetInset(txt->cursor.pos)->Editable()==2) {
  1237.             Inset* tmpinset = txt->cursor.par->GetInset(txt->cursor.pos);
  1238.             setMessage(tmpinset->EditMessage());
  1239.             tmpinset->Edit(tmpinset->Width(txt->GetFont(txt->cursor.par,
  1240.                                     txt->cursor.pos)),0);
  1241.             break;
  1242.         }
  1243.         owner->currentBuffer()->text->FinishUndo();
  1244.         moveCursorUpdate(false);
  1245.         owner->getMiniBuffer()->Set(CurrentState());
  1246.     }
  1247.     break;
  1248.         
  1249.     case LFUN_UP:
  1250.         if(!owner->currentBuffer()->text->mark_set) BeforeChange();
  1251.         owner->currentBuffer()->update(-3);
  1252.         owner->currentBuffer()->text->CursorUp();
  1253.         owner->currentBuffer()->text->FinishUndo();
  1254.         moveCursorUpdate(false);
  1255.         owner->getMiniBuffer()->Set(CurrentState());
  1256.         break;
  1257.         
  1258.     case LFUN_DOWN:
  1259.         if(!owner->currentBuffer()->text->mark_set)
  1260.             BeforeChange();
  1261.         owner->currentBuffer()->update(-3);
  1262.         owner->currentBuffer()->text->CursorDown();
  1263.         owner->currentBuffer()->text->FinishUndo();
  1264.         moveCursorUpdate(false);
  1265.         owner->getMiniBuffer()->Set(CurrentState());
  1266.         break;
  1267.  
  1268.     case LFUN_UP_PARAGRAPH:
  1269.         if(!owner->currentBuffer()->text->mark_set)
  1270.             BeforeChange();
  1271.         owner->currentBuffer()->update(-3);
  1272.         owner->currentBuffer()->text->CursorUpParagraph();
  1273.         owner->currentBuffer()->text->FinishUndo();
  1274.         moveCursorUpdate(false);
  1275.         owner->getMiniBuffer()->Set(CurrentState());
  1276.         break;
  1277.         
  1278.     case LFUN_DOWN_PARAGRAPH:
  1279.         if(!owner->currentBuffer()->text->mark_set)
  1280.             BeforeChange();
  1281.         owner->currentBuffer()->update(-3);
  1282.         owner->currentBuffer()->text->CursorDownParagraph();
  1283.         owner->currentBuffer()->text->FinishUndo();
  1284.         moveCursorUpdate(false);
  1285.         owner->getMiniBuffer()->Set(CurrentState());
  1286.         break;
  1287.         
  1288.     case LFUN_PRIOR:
  1289.         if(!owner->currentBuffer()->text->mark_set)
  1290.             BeforeChange();
  1291.         owner->currentBuffer()->update(-3);
  1292.         owner->currentView()->cursorPrevious();
  1293.         owner->currentBuffer()->text->FinishUndo();
  1294.         moveCursorUpdate(false);
  1295.         owner->getMiniBuffer()->Set(CurrentState());
  1296.         break;
  1297.         
  1298.     case LFUN_NEXT:
  1299.         if(!owner->currentBuffer()->text->mark_set)
  1300.             BeforeChange();
  1301.         owner->currentBuffer()->update(-3);
  1302.         owner->currentView()->cursorNext();
  1303.         owner->currentBuffer()->text->FinishUndo();
  1304.         moveCursorUpdate(false);
  1305.         owner->getMiniBuffer()->Set(CurrentState());
  1306.         break;
  1307.         
  1308.     case LFUN_HOME:
  1309.         if(!owner->currentBuffer()->text->mark_set)
  1310.             BeforeChange();
  1311.         owner->currentBuffer()->update(-2);
  1312.         owner->currentBuffer()->text->CursorHome();
  1313.         owner->currentBuffer()->text->FinishUndo();
  1314.         moveCursorUpdate(false);
  1315.         owner->getMiniBuffer()->Set(CurrentState());
  1316.         break;
  1317.         
  1318.     case LFUN_END:
  1319.         if(!owner->currentBuffer()->text->mark_set)
  1320.             BeforeChange();
  1321.         owner->currentBuffer()->update(-2);
  1322.         owner->currentBuffer()->text->CursorEnd();
  1323.         owner->currentBuffer()->text->FinishUndo();
  1324.         moveCursorUpdate(false);
  1325.         owner->getMiniBuffer()->Set(CurrentState());
  1326.         break;
  1327.         
  1328.     case LFUN_TAB:
  1329.         if(!owner->currentBuffer()->text->mark_set)
  1330.             BeforeChange();
  1331.         owner->currentBuffer()->update(-2);
  1332.         owner->currentBuffer()->text->CursorTab();
  1333.         owner->currentBuffer()->text->FinishUndo();
  1334.         moveCursorUpdate(false);
  1335.         owner->getMiniBuffer()->Set(CurrentState());
  1336.         break;
  1337.         
  1338.     case LFUN_WORDRIGHT:
  1339.         if(!owner->currentBuffer()->text->mark_set)
  1340.             BeforeChange();
  1341.         owner->currentBuffer()->update(-2);
  1342.         owner->currentBuffer()->text->CursorRightOneWord();
  1343.         owner->currentBuffer()->text->FinishUndo();
  1344.         moveCursorUpdate(false);
  1345.         owner->getMiniBuffer()->Set(CurrentState());
  1346.         break;
  1347.         
  1348.     case LFUN_WORDLEFT:
  1349.         if(!owner->currentBuffer()->text->mark_set)
  1350.             BeforeChange();
  1351.         owner->currentBuffer()->update(-2);
  1352.         owner->currentBuffer()->text->CursorLeftOneWord();
  1353.         owner->currentBuffer()->text->FinishUndo();
  1354.         moveCursorUpdate(false);
  1355.         owner->getMiniBuffer()->Set(CurrentState());
  1356.         break;
  1357.         
  1358.     case LFUN_BEGINNINGBUF:
  1359.         if(!owner->currentBuffer()->text->mark_set)
  1360.             BeforeChange();
  1361.         owner->currentBuffer()->update(-2);
  1362.         owner->currentBuffer()->text->CursorTop();
  1363.         owner->currentBuffer()->text->FinishUndo();
  1364.         moveCursorUpdate(false);
  1365.         owner->getMiniBuffer()->Set(CurrentState());
  1366.         break;
  1367.         
  1368.     case LFUN_ENDBUF:
  1369.         if(!owner->currentBuffer()->text->mark_set)
  1370.             BeforeChange();
  1371.         owner->currentBuffer()->update(-2);
  1372.         owner->currentBuffer()->text->CursorBottom();
  1373.         owner->currentBuffer()->text->FinishUndo();
  1374.         moveCursorUpdate(false);
  1375.         owner->getMiniBuffer()->Set(CurrentState());
  1376.         break;
  1377.  
  1378.       
  1379.         /* cursor selection ---------------------------- */
  1380.     case LFUN_RIGHTSEL:
  1381.         owner->currentBuffer()->update(-2);
  1382.         owner->currentBuffer()->text->CursorRight();
  1383.         owner->currentBuffer()->text->FinishUndo();
  1384.         moveCursorUpdate(true);
  1385.         owner->getMiniBuffer()->Set(CurrentState());
  1386.         break;
  1387.         
  1388.     case LFUN_LEFTSEL:
  1389.         owner->currentBuffer()->update(-2);
  1390.         owner->currentBuffer()->text->CursorLeft();
  1391.         owner->currentBuffer()->text->FinishUndo();
  1392.         moveCursorUpdate(true);
  1393.         owner->getMiniBuffer()->Set(CurrentState());
  1394.         break;
  1395.         
  1396.     case LFUN_UPSEL:
  1397.         owner->currentBuffer()->update(-2);
  1398.         owner->currentBuffer()->text->CursorUp();
  1399.         owner->currentBuffer()->text->FinishUndo();
  1400.         moveCursorUpdate(true);
  1401.         owner->getMiniBuffer()->Set(CurrentState());
  1402.         break;
  1403.         
  1404.     case LFUN_DOWNSEL:
  1405.         owner->currentBuffer()->update(-2);
  1406.         owner->currentBuffer()->text->CursorDown();
  1407.         owner->currentBuffer()->text->FinishUndo();
  1408.         moveCursorUpdate(true);
  1409.         owner->getMiniBuffer()->Set(CurrentState());
  1410.         break;
  1411.  
  1412.     case LFUN_UP_PARAGRAPHSEL:
  1413.         owner->currentBuffer()->update(-2);
  1414.         owner->currentBuffer()->text->CursorUpParagraph();
  1415.         owner->currentBuffer()->text->FinishUndo();
  1416.         moveCursorUpdate(true);
  1417.         owner->getMiniBuffer()->Set(CurrentState());
  1418.         break;
  1419.         
  1420.     case LFUN_DOWN_PARAGRAPHSEL:
  1421.         owner->currentBuffer()->update(-2);
  1422.         owner->currentBuffer()->text->CursorDownParagraph();
  1423.         owner->currentBuffer()->text->FinishUndo();
  1424.         moveCursorUpdate(true);
  1425.         owner->getMiniBuffer()->Set(CurrentState());
  1426.         break;
  1427.         
  1428.     case LFUN_PRIORSEL:
  1429.         owner->currentBuffer()->update(-2);
  1430.         owner->currentView()->cursorPrevious();
  1431.         owner->currentBuffer()->text->FinishUndo();
  1432.         moveCursorUpdate(true);
  1433.         owner->getMiniBuffer()->Set(CurrentState());
  1434.         break;
  1435.         
  1436.     case LFUN_NEXTSEL:
  1437.         owner->currentBuffer()->update(-2);
  1438.         owner->currentView()->cursorNext();
  1439.         owner->currentBuffer()->text->FinishUndo();
  1440.         moveCursorUpdate(true);
  1441.         owner->getMiniBuffer()->Set(CurrentState());
  1442.         break;
  1443.         
  1444.     case LFUN_HOMESEL:
  1445.         owner->currentBuffer()->update(-2);
  1446.         owner->currentBuffer()->text->CursorHome();
  1447.         owner->currentBuffer()->text->FinishUndo();
  1448.         moveCursorUpdate(true);
  1449.         owner->getMiniBuffer()->Set(CurrentState());
  1450.         break;
  1451.         
  1452.     case LFUN_ENDSEL:
  1453.         owner->currentBuffer()->update(-2);
  1454.         owner->currentBuffer()->text->CursorEnd();
  1455.         owner->currentBuffer()->text->FinishUndo();
  1456.         moveCursorUpdate(true);
  1457.         owner->getMiniBuffer()->Set(CurrentState());
  1458.         break;
  1459.         
  1460.     case LFUN_WORDRIGHTSEL:
  1461.         owner->currentBuffer()->update(-2);
  1462.         owner->currentBuffer()->text->CursorRightOneWord();
  1463.         owner->currentBuffer()->text->FinishUndo();
  1464.         moveCursorUpdate(true);
  1465.         owner->getMiniBuffer()->Set(CurrentState());
  1466.         break;
  1467.         
  1468.     case LFUN_WORDLEFTSEL:
  1469.         owner->currentBuffer()->update(-2);
  1470.         owner->currentBuffer()->text->CursorLeftOneWord();
  1471.         owner->currentBuffer()->text->FinishUndo();
  1472.         moveCursorUpdate(true);
  1473.         owner->getMiniBuffer()->Set(CurrentState());
  1474.         break;
  1475.         
  1476.     case LFUN_BEGINNINGBUFSEL:
  1477.         owner->currentBuffer()->update(-2);
  1478.         owner->currentBuffer()->text->CursorTop();
  1479.         owner->currentBuffer()->text->FinishUndo();
  1480.         moveCursorUpdate(true);
  1481.         owner->getMiniBuffer()->Set(CurrentState());
  1482.         break;
  1483.         
  1484.     case LFUN_ENDBUFSEL:
  1485.         owner->currentBuffer()->update(-2);
  1486.         owner->currentBuffer()->text->CursorBottom();
  1487.         owner->currentBuffer()->text->FinishUndo();
  1488.         moveCursorUpdate(true);
  1489.         owner->getMiniBuffer()->Set(CurrentState());
  1490.         break;
  1491.  
  1492.         // --- text changing commands ------------------------
  1493.     case LFUN_BREAKLINE:
  1494.         BeforeChange();
  1495.         owner->currentBuffer()->text->InsertChar(LYX_META_NEWLINE);
  1496.         SmallUpdate(1);
  1497.         SetUpdateTimer(0.01);
  1498.         moveCursorUpdate(false);
  1499.         break;
  1500.         
  1501.     case LFUN_PROTECTEDSPACE:
  1502.         BeforeChange();
  1503.         owner->currentBuffer()->text->
  1504.             InsertChar(LYX_META_PROTECTED_SEPARATOR);
  1505.         SmallUpdate(1);
  1506.         SetUpdateTimer();
  1507.                 moveCursorUpdate(false);
  1508.         break;
  1509.         
  1510.     case LFUN_SETMARK:
  1511.         if(owner->currentBuffer()->text->mark_set) {
  1512.             BeforeChange();
  1513.             owner->currentBuffer()->update(0);
  1514.             setMessage(N_("Mark removed"));
  1515.         } else {
  1516.             BeforeChange();
  1517.             owner->currentBuffer()->text->mark_set = 1;
  1518.             owner->currentBuffer()->update(0);
  1519.             setMessage(N_("Mark set"));
  1520.         }
  1521.         owner->currentBuffer()->text->sel_cursor =
  1522.             owner->currentBuffer()->text->cursor;
  1523.         break;
  1524.         
  1525.     case LFUN_DELETE:
  1526.         FreeUpdateTimer();
  1527.         if (!owner->currentBuffer()->text->selection) {
  1528.             owner->currentBuffer()->text->Delete();
  1529.             owner->currentBuffer()->text->sel_cursor =
  1530.                 owner->currentBuffer()->text->cursor;
  1531.             SmallUpdate(1);
  1532.             // It is possible to make it a lot faster still
  1533.             // just comment out the lone below...
  1534.             owner->currentView()->getScreen()->ShowCursor();
  1535.         } else {
  1536.             CutCB();
  1537.         }
  1538.         SetUpdateTimer();
  1539.         break;
  1540.  
  1541.     case LFUN_DELETE_SKIP:
  1542.     {
  1543.         // Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
  1544.         
  1545.         LyXCursor cursor = owner->currentBuffer()->text->cursor;
  1546.  
  1547.         FreeUpdateTimer();
  1548.         if (!owner->currentBuffer()->text->selection) {
  1549.             if (cursor.pos == cursor.par->Last()) {
  1550.                 owner->currentBuffer()->text->CursorRight();
  1551.                 cursor = owner->currentBuffer()->text->cursor;
  1552.                 if (cursor.pos == 0
  1553.                     && !(cursor.par->added_space_top 
  1554.                      == VSpace (VSpace::NONE))) {
  1555.                     owner->currentBuffer()->text->SetParagraph
  1556.                         (cursor.par->line_top,
  1557.                          cursor.par->line_bottom,
  1558.                          cursor.par->pagebreak_top, 
  1559.                          cursor.par->pagebreak_bottom,
  1560.                          VSpace(VSpace::NONE), 
  1561.                          cursor.par->added_space_bottom,
  1562.                          cursor.par->align, 
  1563.                          cursor.par->labelwidthstring, 0);
  1564.                     owner->currentBuffer()->text->CursorLeft();
  1565.                     owner->currentBuffer()->update (1);
  1566.                 } else {
  1567.                     owner->currentBuffer()->text->CursorLeft();
  1568.                     owner->currentBuffer()->text->Delete();
  1569.                     owner->currentBuffer()->text->sel_cursor =
  1570.                         owner->currentBuffer()->text->cursor;
  1571.                     SmallUpdate(1);
  1572.                 }
  1573.             } else {
  1574.                 owner->currentBuffer()->text->Delete();
  1575.                 owner->currentBuffer()->text->sel_cursor =
  1576.                     owner->currentBuffer()->text->cursor;
  1577.                 SmallUpdate(1);
  1578.             }
  1579.         } else {
  1580.             CutCB();
  1581.         }
  1582.         SetUpdateTimer();
  1583.     }
  1584.     break;
  1585.  
  1586.     /* -------> Delete word forward. */
  1587.     case LFUN_DELETE_WORD_FORWARD:
  1588.         owner->currentBuffer()->update(-2);
  1589.         FreeUpdateTimer();
  1590.         owner->currentBuffer()->text->DeleteWordForward();
  1591.         owner->currentBuffer()->update( 1 );
  1592.         SetUpdateTimer();
  1593.         moveCursorUpdate(false);
  1594.         break;
  1595.  
  1596.         /* -------> Delete word backward. */
  1597.     case LFUN_DELETE_WORD_BACKWARD:
  1598.         owner->currentBuffer()->update(-2);
  1599.         FreeUpdateTimer();
  1600.         owner->currentBuffer()->text->DeleteWordBackward();
  1601.         owner->currentBuffer()->update( 1 );
  1602.         SetUpdateTimer();
  1603.         moveCursorUpdate(false);
  1604.         break;
  1605.         
  1606.         /* -------> Kill to end of line. */
  1607.     case LFUN_DELETE_LINE_FORWARD:
  1608.         FreeUpdateTimer();
  1609.         owner->currentBuffer()->update(-2);
  1610.         owner->currentBuffer()->text->DeleteLineForward();
  1611.         owner->currentBuffer()->update( 1 );
  1612.         SetUpdateTimer();
  1613.         moveCursorUpdate(false);
  1614.         break;
  1615.         
  1616.         /* -------> Set mark off. */
  1617.     case LFUN_MARK_OFF:
  1618.         BeforeChange();
  1619.         owner->currentBuffer()->update(0);
  1620.         owner->currentBuffer()->text->sel_cursor =
  1621.             owner->currentBuffer()->text->cursor;
  1622.         setMessage(N_("Mark off"));
  1623.         break;
  1624.  
  1625.         /* -------> Set mark on. */
  1626.     case LFUN_MARK_ON:
  1627.         BeforeChange();
  1628.         owner->currentBuffer()->text->mark_set = 1;
  1629.         owner->currentBuffer()->update( 0 );
  1630.         owner->currentBuffer()->text->sel_cursor =
  1631.             owner->currentBuffer()->text->cursor;
  1632.         setMessage(N_("Mark on"));
  1633.         break;
  1634.         
  1635.     case LFUN_BACKSPACE:
  1636.     {
  1637.         FreeUpdateTimer();
  1638.         if (!owner->currentBuffer()->text->selection) {
  1639.             if (owner->getIntl()->getTrans()->backspace()) {
  1640.                 owner->currentBuffer()->text->Backspace();
  1641.                 owner->currentBuffer()->text->sel_cursor =
  1642.                     owner->currentBuffer()->text->cursor;
  1643.                 SmallUpdate(1);
  1644.                 // It is possible to make it a lot faster still
  1645.                 // just comment out the lone below...
  1646.                 owner->currentView()->getScreen()->ShowCursor();
  1647.             }
  1648.         } else {
  1649.             CutCB();
  1650.         }
  1651.         SetUpdateTimer();
  1652.     }
  1653.     break;
  1654.  
  1655.     case LFUN_BACKSPACE_SKIP:
  1656.     {
  1657.         // Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
  1658.         
  1659.         LyXCursor cursor = owner->currentBuffer()->text->cursor;
  1660.         
  1661.         FreeUpdateTimer();
  1662.         if (!owner->currentBuffer()->text->selection) {
  1663.             if (cursor.pos == 0 
  1664.                 && !(cursor.par->added_space_top 
  1665.                  == VSpace (VSpace::NONE))) {
  1666.                 owner->currentBuffer()->text->SetParagraph 
  1667.                     (cursor.par->line_top,      
  1668.                      cursor.par->line_bottom,
  1669.                      cursor.par->pagebreak_top, 
  1670.                      cursor.par->pagebreak_bottom,
  1671.                      VSpace(VSpace::NONE), cursor.par->added_space_bottom,
  1672.                      cursor.par->align, 
  1673.                      cursor.par->labelwidthstring, 0);
  1674.                 owner->currentBuffer()->update (1);
  1675.             } else {
  1676.                 owner->currentBuffer()->text->Backspace();
  1677.                 owner->currentBuffer()->text->sel_cursor 
  1678.                     = cursor;
  1679.                 SmallUpdate (1);
  1680.             }
  1681.         } else
  1682.             CutCB();
  1683.         SetUpdateTimer();
  1684.     }
  1685.     break;
  1686.  
  1687.     case LFUN_BREAKPARAGRAPH:
  1688.     {
  1689.         BeforeChange();
  1690.         owner->currentBuffer()->text->BreakParagraph(0);
  1691.         SmallUpdate(1);
  1692.         SetUpdateTimer(0.01);
  1693.         owner->currentBuffer()->text->sel_cursor =
  1694.             owner->currentBuffer()->text->cursor;
  1695.         break;
  1696.     }
  1697.  
  1698.     case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
  1699.     {
  1700.         BeforeChange();
  1701.         owner->currentBuffer()->text->BreakParagraph(1);
  1702.         SmallUpdate(1);
  1703.         SetUpdateTimer(0.01);
  1704.         owner->currentBuffer()->text->sel_cursor =
  1705.             owner->currentBuffer()->text->cursor;
  1706.         break;
  1707.     }
  1708.     
  1709.     case LFUN_BREAKPARAGRAPH_SKIP:
  1710.     {
  1711.         // When at the beginning of a paragraph, remove
  1712.         // indentation and add a "defskip" at the top.
  1713.         // Otherwise, do the same as LFUN_BREAKPARAGRAPH.
  1714.         
  1715.         LyXCursor cursor = owner->currentBuffer()->text->cursor;
  1716.         
  1717.         BeforeChange();
  1718.         if (cursor.pos == 0) {
  1719.             if (cursor.par->added_space_top == VSpace(VSpace::NONE)) {
  1720.                 owner->currentBuffer()->text->SetParagraph
  1721.                     (cursor.par->line_top,      
  1722.                      cursor.par->line_bottom,
  1723.                      cursor.par->pagebreak_top, 
  1724.                      cursor.par->pagebreak_bottom,
  1725.                      VSpace(VSpace::DEFSKIP), cursor.par->added_space_bottom,
  1726.                      cursor.par->align, 
  1727.                      cursor.par->labelwidthstring, 1);
  1728.                 owner->currentBuffer()->update(1);
  1729.             } 
  1730.         }
  1731.         else {
  1732.             owner->currentBuffer()->text->BreakParagraph(0);
  1733.             SmallUpdate(1);
  1734.         }
  1735.         SetUpdateTimer(0.01);
  1736.         owner->currentBuffer()->text->sel_cursor = cursor;
  1737.     }
  1738.     break;
  1739.     
  1740.     case LFUN_QUOTE:
  1741.         BeforeChange();
  1742.         owner->currentBuffer()->text->InsertChar('\"');
  1743.         SmallUpdate(1);
  1744.         SetUpdateTimer();
  1745.                 moveCursorUpdate(false);
  1746.         break;
  1747.  
  1748.     case LFUN_HTMLURL:
  1749.             HtmlUrlCB();
  1750.         break;
  1751.  
  1752.     case LFUN_URL:
  1753.             UrlCB();
  1754.         break;
  1755.         
  1756.         // --- lyxserver commands ----------------------------
  1757.  
  1758.     case LFUN_CHARATCURSOR:
  1759.     {
  1760.         int pos = owner->currentBuffer()->text->cursor.pos;
  1761.         if(pos < owner->currentBuffer()->text->cursor.par->last)
  1762.             dispatch_buffer = owner->currentBuffer()->text->
  1763.                 cursor.par->text[pos];
  1764.         else
  1765.             dispatch_buffer = "EOF";
  1766.     }
  1767.     break;
  1768.     
  1769.     case LFUN_GETXY:
  1770.         dispatch_buffer = LString()
  1771.             + owner->currentBuffer()->text->cursor.x + ' '
  1772.             + owner->currentBuffer()->text->cursor.y;
  1773.         break;
  1774.         
  1775.     case LFUN_SETXY:
  1776.     {
  1777.         int  x;
  1778.         long y;
  1779.         sscanf(argument, " %d %ld", &x, &y);
  1780.         owner->currentBuffer()->text->SetCursorFromCoordinates(x, y);
  1781.     }
  1782.     break;
  1783.     
  1784.     case LFUN_GETLAYOUT:
  1785.         dispatch_buffer = LString() + 
  1786.             int(owner->currentBuffer()->text->cursor.par->layout);
  1787.         break;
  1788.             
  1789.     case LFUN_GETFONT:
  1790.     {
  1791.         LyXFont *font = &(owner->currentBuffer()->text->current_font);
  1792.                 if(font->shape() == LyXFont::ITALIC_SHAPE)
  1793.             dispatch_buffer = 'E';
  1794.                 else if(font->shape() == LyXFont::SMALLCAPS_SHAPE)
  1795.             dispatch_buffer = 'N';
  1796.                 else
  1797.             dispatch_buffer = '0';
  1798.  
  1799.     }
  1800.     break;
  1801.  
  1802.     case LFUN_GETLATEX:
  1803.     {
  1804.         LyXFont *font = &(owner->currentBuffer()->text->current_font);
  1805.                 if(font->latex() == LyXFont::ON)
  1806.             dispatch_buffer = 'L';
  1807.                 else
  1808.             dispatch_buffer = '0';
  1809.     }
  1810.     break;
  1811.  
  1812.     case LFUN_GETNAME:
  1813.         setMessage(owner->currentBuffer()->getFileName());
  1814.         lyxerr.debug(LString("FNAME[") +
  1815.                  owner->currentBuffer()->getFileName() +
  1816.                  "] ");
  1817.         break;
  1818.         
  1819.     case LFUN_NOTIFY:
  1820.     {
  1821.         dispatch_buffer = keyseq.print();
  1822.         lyxserver->notifyClient(dispatch_buffer);
  1823.     }
  1824.     break;
  1825.  
  1826.     case LFUN_APROPOS:
  1827.     case LFUN_GETTIP:
  1828.     {
  1829.         int qa = lyxaction.LookupFunc((const char*)argument);
  1830.         setMessage(lyxaction.helpText((kb_action)qa));
  1831.     }
  1832.     break;
  1833.  
  1834.     // --- accented characters ---------------------------
  1835.         
  1836.     case LFUN_UMLAUT:
  1837.     case LFUN_CIRCUMFLEX:
  1838.     case LFUN_GRAVE:
  1839.     case LFUN_ACUTE:
  1840.     case LFUN_TILDE:
  1841.     case LFUN_CEDILLA:
  1842.     case LFUN_MACRON:
  1843.     case LFUN_DOT:
  1844.     case LFUN_UNDERDOT:
  1845.     case LFUN_UNDERBAR:
  1846.     case LFUN_CARON:
  1847.     case LFUN_SPECIAL_CARON:
  1848.     case LFUN_BREVE:
  1849.     case LFUN_TIE:
  1850.     case LFUN_HUNG_UMLAUT:
  1851.     case LFUN_CIRCLE:
  1852.     case LFUN_OGONEK:
  1853.     {
  1854.         char c;
  1855.         
  1856.         if (keyseq.length==-1 && keyseq.getiso()!=0) 
  1857.             c=keyseq.getiso();
  1858.         else
  1859.             c=0;
  1860.         
  1861.         owner->getIntl()->getTrans()->
  1862.             deadkey(c, get_accent(action).accent, 
  1863.                 owner->currentBuffer()->text);
  1864.         
  1865.         // Need to reset, in case the minibuffer calls these
  1866.         // actions
  1867.         keyseq.reset();
  1868.         keyseq.length=0;
  1869.         
  1870.         // copied verbatim from do_accent_char
  1871.         SmallUpdate(1);
  1872.         SetUpdateTimer();
  1873.         owner->currentBuffer()->text->sel_cursor = 
  1874.             owner->currentBuffer()->text->cursor;
  1875.     }   
  1876.     break;
  1877.     
  1878.     // --- toolbar ----------------------------------
  1879.     case LFUN_PUSH_TOOLBAR:
  1880.     {
  1881.         int nth = atoi(argument);
  1882.         if (lyxerr.debugging(Error::TOOLBAR)) {
  1883.             lyxerr.print(LString("LFUN_PUSH_TOOLBAR: argument = `")
  1884.                      + argument + "'");
  1885.             lyxerr.print(LString("LFUN_PUSH_TOOLBAR: nth = `")
  1886.                      + nth + "'");
  1887.         }
  1888.         
  1889.         if (nth <= 0) {
  1890.             LyXBell();
  1891.             setErrorMessage(N_("Push-toolbar needs argument > 0"));
  1892.         } else {
  1893.             owner->getToolbar()->push(nth);
  1894.         }
  1895.     }
  1896.     break;
  1897.     
  1898.     case LFUN_ADD_TO_TOOLBAR:
  1899.     {
  1900.         if (lyxerr.debugging(Error::TOOLBAR)) {
  1901.             lyxerr.print(LString("LFUN_ADD_TO_TOOLBAR:"
  1902.                          "argument = `")+ argument + '\'');
  1903.         }
  1904.         LString tmp(argument);
  1905.         //lyxerr.print(LString("Argument: ") + argument);
  1906.         //lyxerr.print(LString("Tmp     : ") + tmp);
  1907.         if (tmp.empty()) {
  1908.             LyXBell();
  1909.             setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
  1910.         } else {
  1911.             owner->getToolbar()->add(lyxaction
  1912.                          .LookupFunc(argument), false);
  1913.             owner->getToolbar()->set();
  1914.         }
  1915.     }
  1916.     break;
  1917.     
  1918.        
  1919.     // ---  Mathed stuff. If we are here, there is no locked inset yet.
  1920.     
  1921.     // Greek mode     
  1922.     case LFUN_GREEK:
  1923.     {
  1924.         if (!greek_kb_flag) {
  1925.             greek_kb_flag = 1;
  1926.             setMessage(N_("Math greek mode on"));
  1927.         } else
  1928.             greek_kb_flag = 0;
  1929.     }  
  1930.     break;
  1931.       
  1932.     // Greek keyboard      
  1933.     case LFUN_GREEK_TOGGLE:
  1934.     {
  1935.         greek_kb_flag = (greek_kb_flag) ? 0: 2;
  1936.         if (greek_kb_flag) {
  1937.             setMessage(N_("Math greek keyboard on"));
  1938.         } else {
  1939.             setMessage(N_("Math greek keyboard off"));
  1940.         }
  1941.     }
  1942.     break;
  1943.     
  1944.     case LFUN_MATH_DELIM:     
  1945.     case LFUN_INSERT_MATRIX:
  1946.     {        
  1947.         if (owner->currentView()->available()) { 
  1948.             owner->currentBuffer()->
  1949.                 open_new_inset(new InsetFormula(false));
  1950.             owner->currentBuffer()->
  1951.                 the_locking_inset->LocalDispatch(action, argument);
  1952.         }
  1953.     }       
  1954.     break;
  1955.            
  1956.     case LFUN_INSERT_MATH:
  1957.     {
  1958.         math_insert_symbol(argument);
  1959.     }
  1960.     break;
  1961.     
  1962.     case LFUN_MATH_DISPLAY:
  1963.     {
  1964.         if (owner->currentView()->available())
  1965.             owner->currentBuffer()->open_new_inset(new InsetFormula(true));
  1966.         break;
  1967.     }
  1968.             
  1969.     case LFUN_MATH_MACRO:
  1970.     {
  1971.         if (owner->currentView()->available()) {
  1972.             LString s(argument);
  1973.                 if (s.empty())
  1974.                     setErrorMessage(N_("Missing argument"));
  1975.                 else {
  1976.                 LString s1 = s.token(' ', 1);
  1977.                 int na = s1.empty() ? 0: atoi(s1.c_str());
  1978.                 owner->currentBuffer()->
  1979.                   open_new_inset(new InsetFormulaMacro(s.token(' ', 0), na));
  1980.             }
  1981.         }
  1982.     }
  1983.     break;
  1984.  
  1985.     case LFUN_MATH_MODE:   // Open or create a math inset
  1986.     {
  1987.         
  1988.         if (owner->currentView()->available())
  1989.             owner->currentBuffer()->open_new_inset(new InsetFormula);
  1990.         setMessage(N_("Math editor mode"));
  1991.     }
  1992.     break;
  1993.       
  1994.     case LFUN_MATH_NUMBER:
  1995.     case LFUN_MATH_LIMITS:
  1996.     {
  1997.         setErrorMessage(N_("This is only allowed in math mode!"));
  1998.     }
  1999.     break;
  2000.     
  2001.     case LFUN_INSERT_CITATION:
  2002.     {   
  2003.         InsetCitation *new_inset = new InsetCitation();
  2004.         // ale970405
  2005.         // The note, if any, must be after the key, delimited
  2006.         // by a | so both key and remark can have spaces.
  2007.         if (argument) {
  2008.             LString lsarg(argument);
  2009.             if (lsarg.contains("|")) {
  2010.                 new_inset->setContents(lsarg.token('|', 0));
  2011.                 new_inset->setOptions(lsarg.token('|', 1));
  2012.             } else
  2013.                 new_inset->setContents(lsarg);
  2014.             owner->currentBuffer()->insertInset(new_inset);
  2015.         } else {
  2016.             owner->currentBuffer()->insertInset(new_inset);
  2017.             new_inset->Edit(0,0);
  2018.         }
  2019.     }
  2020.     break;
  2021.             
  2022.     case LFUN_INSERT_BIBTEX:
  2023.     {   
  2024.         // ale970405+lasgoutt970425
  2025.         // The argument can be up to two tokens separated 
  2026.         // by a space. The first one is the bibstyle.
  2027.         LString lsarg(argument);
  2028.         LString bibstyle = lsarg.token(' ', 1);
  2029.         if (bibstyle.empty())
  2030.             bibstyle = "plain";
  2031.         InsetBibtex *new_inset 
  2032.             = new InsetBibtex(lsarg.token(' ', 0),
  2033.                       bibstyle,
  2034.                       owner->currentBuffer());
  2035.         
  2036.         owner->currentBuffer()->insertInset(new_inset);
  2037.         if (lsarg.empty()) {
  2038.             new_inset->Edit(0,0);
  2039.         }
  2040.     }
  2041.     break;
  2042.         
  2043.     // BibTeX data bases
  2044.     case LFUN_BIBDB_ADD:
  2045.     {
  2046.         InsetBibtex *inset =
  2047.             (InsetBibtex*)getInsetByCode(Inset::BIBTEX_CODE);
  2048.         if (inset) {
  2049.             inset->addDatabase(argument);
  2050.         }
  2051.     }
  2052.     break;
  2053.             
  2054.     case LFUN_BIBDB_DEL:
  2055.     {
  2056.         InsetBibtex *inset =
  2057.             (InsetBibtex*)getInsetByCode(Inset::BIBTEX_CODE);
  2058.         if (inset) {
  2059.             inset->delDatabase(argument);
  2060.         }
  2061.     }
  2062.     break;
  2063.     
  2064.     case LFUN_BIBTEX_STYLE:
  2065.     {
  2066.         InsetBibtex *inset =
  2067.             (InsetBibtex*)getInsetByCode(Inset::BIBTEX_CODE);
  2068.         if (inset) {
  2069.             inset->setOptions(argument);
  2070.         }
  2071.     }
  2072.     break;
  2073.         
  2074.     case LFUN_INDEX_INSERT:
  2075.     {
  2076.         InsetIndex *new_inset = new InsetIndex();
  2077.         if (argument) {
  2078.             LString lsarg(argument);
  2079.             new_inset->setContents(lsarg);
  2080.             owner->currentBuffer()->insertInset(new_inset);
  2081.         } else {
  2082.             owner->currentBuffer()->insertInset(new_inset);
  2083.             new_inset->Edit(0,0);
  2084.         }
  2085.     }
  2086.     break;
  2087.         
  2088.     case LFUN_INDEX_PRINT:
  2089.     {
  2090.         Inset *new_inset = new
  2091.             InsetPrintIndex(owner->currentBuffer());
  2092.         owner->currentBuffer()->insertInset(new_inset,
  2093.                             "Standard", true);
  2094.     }
  2095.     break;
  2096.  
  2097.     case LFUN_PARENTINSERT:
  2098.     {
  2099.         lyxerr.print(LString("arg ") + argument);
  2100.         Inset *new_inset = new InsetParent(argument, owner->currentBuffer());
  2101.         owner->currentBuffer()->insertInset(new_inset,
  2102.                             "Standard", true);
  2103.     }
  2104.     break;
  2105.  
  2106.     case LFUN_CHILDINSERT:
  2107.     {
  2108.         Inset *new_inset = new InsetInclude(argument,owner->currentBuffer());
  2109.         owner->currentBuffer()->insertInset(new_inset,
  2110.                             "Standard", true);
  2111.     }
  2112.     break;
  2113.  
  2114.     case LFUN_CHILDOPEN:
  2115.     {
  2116.         LString filename = MakeAbsPath(argument, 
  2117.                            OnlyPath(owner->currentBuffer()->getFileName()));
  2118.         setMessage(N_("Opening child document ") +
  2119.                MakeDisplayPath(filename) + "...");
  2120.         owner->currentView()->savePosition();
  2121.         owner->currentView()->setBuffer(
  2122.             bufferlist.loadLyXFile(filename));
  2123.     }
  2124.     break;
  2125.  
  2126.     case LFUN_INSERT_NOTE:
  2127.         NoteCB();
  2128.         break;
  2129.         
  2130.     case LFUN_INSERTFOOTNOTE: 
  2131.     {
  2132.         LyXParagraph::footnote_kind kind;
  2133.         LString arg = argument;
  2134.         if (arg == "footnote")
  2135.             { kind = LyXParagraph::FOOTNOTE; }
  2136.         else if (arg == "margin")
  2137.             { kind = LyXParagraph::MARGIN; }
  2138.         else if (arg == "figure")
  2139.             { kind = LyXParagraph::FIG; }
  2140.         else if (arg == "table")
  2141.             { kind = LyXParagraph::TAB; }
  2142.         else if (arg == "wide-fig")
  2143.             { kind = LyXParagraph::WIDE_FIG; }
  2144.         else if (arg == "wide-tab")
  2145.             { kind = LyXParagraph::WIDE_TAB; }
  2146.         else if (arg == "algorithm")
  2147.             { kind = LyXParagraph::ALGORITHM; }
  2148.         else {
  2149.             setErrorMessage(N_("Unknown kind of footnote"));
  2150.             break;
  2151.         }
  2152.         owner->currentBuffer()->text->InsertFootnoteEnvironment(kind);
  2153.         owner->currentBuffer()->update(1);
  2154.     }
  2155.     break;
  2156.     
  2157.     case LFUN_BUFFERBULLETSSELECT:
  2158.         bulletForm();
  2159.         break;
  2160.         
  2161.     case LFUN_TOGGLECURSORFOLLOW:
  2162.         cursor_follows_scrollbar = !cursor_follows_scrollbar;
  2163.         break;
  2164.         
  2165.     case LFUN_KMAP_OFF:        // keymap off
  2166.         owner->getIntl()->KeyMapOn(false);
  2167.         break;
  2168.         
  2169.     case LFUN_KMAP_PRIM:    // primary keymap
  2170.         owner->getIntl()->KeyMapPrim();
  2171.         break;
  2172.         
  2173.     case LFUN_KMAP_SEC:        // secondary keymap
  2174.         owner->getIntl()->KeyMapSec();
  2175.         break;
  2176.         
  2177.     case LFUN_KMAP_TOGGLE:    // toggle keymap
  2178.         owner->getIntl()->ToggleKeyMap();
  2179.         break;
  2180.  
  2181.     case LFUN_SELFINSERT:
  2182.     {
  2183.         LString const text = argument;
  2184.         for (int i=0; i<text.length(); i++) {
  2185.             owner->currentBuffer()->text->InsertChar(text[i]);
  2186.             // This needs to be in the loop, or else we
  2187.             // won't break lines correctly. (Asger)
  2188.             SmallUpdate(1);
  2189.         }
  2190.         SetUpdateTimer();
  2191.         owner->currentBuffer()->text->sel_cursor =
  2192.             owner->currentBuffer()->text->cursor;
  2193.         moveCursorUpdate(false);
  2194.     }
  2195.     break;
  2196.  
  2197.     case LFUN_UNKNOWN_ACTION:
  2198.     {
  2199.         if (owner->currentBuffer()->isReadonly()) {
  2200.             LyXBell();
  2201.             setErrorMessage(N_("Document is read only"));
  2202.             break;
  2203.         }
  2204.              
  2205.         if (argument) {
  2206.             
  2207.             /* Automatically delete the currently selected
  2208.              * text and replace it with what is being
  2209.              * typed in now. Depends on lyxrc settings
  2210.              * "auto_region_delete", which defaults to
  2211.              * true (on). */
  2212.         
  2213.             if ( lyxrc->auto_region_delete ) {
  2214.                 if (owner->currentBuffer()->text->selection){
  2215.                     owner->currentBuffer()->text->CutSelection(false);
  2216.                     owner->currentBuffer()->update(-1);
  2217.                 }
  2218.             }
  2219.             
  2220.             BeforeChange();
  2221.             for(char const *p = argument; *p; p++) {
  2222.                 if (greek_kb_flag) {
  2223.                     if (!math_insert_greek(*p))
  2224.                         owner->getIntl()->getTrans()->TranslateAndInsert(*p, owner->currentBuffer()->text);
  2225.                 } else
  2226.                     owner->getIntl()->getTrans()->TranslateAndInsert(*p, owner->currentBuffer()->text);
  2227.             }
  2228.             
  2229.             SmallUpdate(1);
  2230.             SetUpdateTimer();
  2231.  
  2232.             owner->currentBuffer()->text->sel_cursor =
  2233.                 owner->currentBuffer()->text->cursor;
  2234.             moveCursorUpdate(false);
  2235.             return LString();
  2236.         } else {
  2237.             // why is an "Unknown action" with empty
  2238.             // argument even dispatched in the first
  2239.             // place? I`ll probably change that. (Lgb)
  2240.             LyXBell();
  2241.             setErrorMessage(N_("Unknown action"));
  2242.         }
  2243.         break;
  2244.     default:
  2245.         lyxerr.print("A truly unknown func!");
  2246.         break;
  2247.     }
  2248.     } // end of switch
  2249.   exit_with_message:
  2250.  
  2251.     LString res=getMessage();
  2252.  
  2253.     if (res.empty()) {
  2254.         if (!commandshortcut.empty()) {
  2255.             LString newbuf = owner->getMiniBuffer()->GetText();
  2256.             if (newbuf != commandshortcut) {
  2257.                 owner->getMiniBuffer()->Set(newbuf
  2258.                                 + " " +
  2259.                                 commandshortcut);
  2260.             }
  2261.         }
  2262.     } else {
  2263.         owner->getMiniBuffer()->Set(LString(_(res.c_str()))
  2264.                         + " " + commandshortcut);
  2265.     }
  2266.  
  2267.     return getMessage();
  2268. }
  2269.         
  2270.  
  2271. void LyXFunc::setupLocalKeymap()
  2272. {
  2273.     keyseq.stdmap = keyseq.curmap = toplevel_keymap;
  2274.     cancel_meta_seq.stdmap = cancel_meta_seq.curmap = toplevel_keymap;
  2275. }
  2276.  
  2277.  
  2278. void LyXFunc::MenuNew(bool fromTemplate)
  2279. {
  2280.     LString fname, initpath = lyxrc->document_path;
  2281.     LyXFileDlg fileDlg;
  2282.  
  2283.     if (owner->currentView()->available()) {
  2284.         LString trypath = owner->currentBuffer()->filepath;
  2285.         // If directory is writeable, use this as default.
  2286.         if (IsDirWriteable(trypath) == 1)
  2287.             initpath = trypath;
  2288.     }
  2289.  
  2290.     ProhibitInput();
  2291.     fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
  2292.     fileDlg.SetButton(1, _("Templates"), lyxrc->template_path);
  2293.     fname = fileDlg.Select(_("Enter Filename for new document"), 
  2294.                    initpath, "*.lyx", _("newfile"));
  2295.      AllowInput();
  2296.     
  2297.     if (fname.empty()) {
  2298.         owner->getMiniBuffer()->Set(_("Canceled."));
  2299.         lyxerr.debug("New Document Cancelled.");
  2300.         return;
  2301.     }
  2302.         
  2303.     // get absolute path of file and make sure the filename ends
  2304.     // with .lyx
  2305.     LString s = MakeAbsPath(fname);
  2306.     if (!IsLyXFilename(s))
  2307.         s += ".lyx";
  2308.  
  2309.     // Check if the document already is open
  2310.     if (bufferlist.exists(s)){
  2311.         switch(AskConfirmation(_("Document is already open:"), 
  2312.                        MakeDisplayPath(s,50),
  2313.                        _("Do you want to close that document now?\n"
  2314.                      "('No' will just switch to the open version)")))
  2315.             {
  2316.             case 1: // Yes: close the document
  2317.                 if (!bufferlist.close(owner->currentBuffer()))
  2318.                     // If close is canceled, we cancel here too.
  2319.                     return;
  2320.                 break;
  2321.             case 2: // No: switch to the open document
  2322.                 owner->currentView()->setBuffer(bufferlist.getBuffer(s));
  2323.                 return;
  2324.             case 3: // Cancel: Do nothing
  2325.                 return;
  2326.             }
  2327.     }
  2328.         
  2329.     // Check whether the file already exists
  2330.     if (IsLyXFilename(s)) {
  2331.         FilePtr myfile(s, FilePtr::read);
  2332.         if (myfile() &&
  2333.             AskQuestion(_("File already exists:"), 
  2334.                 MakeDisplayPath(s,50),
  2335.                 _("Do you want to open the document?"))) {
  2336.             // loads document
  2337.             owner->getMiniBuffer()->Set(_("Opening document"), 
  2338.                             MakeDisplayPath(s), "...");
  2339.             XFlush(fl_display);
  2340.             owner->currentView()->setBuffer(
  2341.                 bufferlist.loadLyXFile(s));
  2342.             owner->getMiniBuffer()->Set(_("Document"),
  2343.                             MakeDisplayPath(s),
  2344.                             _("opened."));
  2345.             return;
  2346.         }
  2347.     }
  2348.  
  2349.     // The template stuff
  2350.     LString templname;
  2351.     if (fromTemplate) {
  2352.         ProhibitInput();
  2353.         fname = fileDlg.Select(_("Choose template"),
  2354.                        lyxrc->template_path,
  2355.                        "*.lyx");
  2356.                 templname = fname;
  2357.         AllowInput();
  2358.     }
  2359.   
  2360.     // find a free buffer
  2361.     lyxerr.debug("Find a free buffer.");
  2362.     owner->currentView()->setBuffer(bufferlist.newFile(s,templname));
  2363. }
  2364.  
  2365.  
  2366. void LyXFunc::MenuOpen()
  2367. {
  2368.     LString initpath = lyxrc->document_path;
  2369.     LyXFileDlg fileDlg;
  2370.   
  2371.     if (owner->currentView()->available()) {
  2372.         LString trypath = owner->currentBuffer()->filepath;
  2373.         // If directory is writeable, use this as default.
  2374.         if (IsDirWriteable(trypath) == 1)
  2375.             initpath = trypath;
  2376.     }
  2377.  
  2378.     // launches dialog
  2379.     ProhibitInput();
  2380.     fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
  2381.     fileDlg.SetButton(1, _("Examples"), 
  2382.               AddPath(system_lyxdir, "examples"));
  2383.     LString filename = fileDlg.Select(_("Select Document to Open"),
  2384.                       initpath, "*.lyx");
  2385.     AllowInput();
  2386.  
  2387.     // check selected filename
  2388.     if (filename.empty()) {
  2389.         owner->getMiniBuffer()->Set(_("Canceled."));
  2390.         return;
  2391.     }
  2392.  
  2393.     // get absolute path of file and make sure the filename ends
  2394.     // with .lyx
  2395.     filename = MakeAbsPath(filename);
  2396.     if (!IsLyXFilename(filename))
  2397.         filename += ".lyx";
  2398.  
  2399.     // loads document
  2400.     owner->getMiniBuffer()->Set(_("Opening document"),
  2401.                     MakeDisplayPath(filename), "...");
  2402.     Buffer * openbuf = bufferlist.loadLyXFile(filename);
  2403.     if (openbuf) {
  2404.         owner->currentView()->setBuffer(openbuf);
  2405.         owner->getMiniBuffer()->Set(_("Document"),
  2406.                         MakeDisplayPath(filename),
  2407.                         _("opened."));
  2408.     } else {
  2409.         owner->getMiniBuffer()->Set(_("Could not open document"),
  2410.                         MakeDisplayPath(filename));
  2411.     }
  2412. }
  2413.  
  2414.  
  2415. void LyXFunc::MenuInsertLyXFile(LString const & filen)
  2416. {
  2417.     LString filename = filen;
  2418.  
  2419.     if (filename.empty()) {
  2420.         // Launch a file browser
  2421.         LString initpath = lyxrc->document_path;
  2422.         LyXFileDlg fileDlg;
  2423.  
  2424.         if (owner->currentView()->available()) {
  2425.             LString trypath = owner->currentBuffer()->filepath;
  2426.             // If directory is writeable, use this as default.
  2427.             if (IsDirWriteable(trypath) == 1)
  2428.                 initpath = trypath;
  2429.         }
  2430.  
  2431.         // launches dialog
  2432.         ProhibitInput();
  2433.         fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
  2434.         fileDlg.SetButton(1, _("Examples"), 
  2435.                   AddPath(system_lyxdir, "examples"));
  2436.         filename = fileDlg.Select(_("Select Document to Insert"),
  2437.                       initpath, "*.lyx");
  2438.         AllowInput();
  2439.  
  2440.         // check selected filename
  2441.         if (filename.empty()) {
  2442.             owner->getMiniBuffer()->Set(_("Canceled."));
  2443.             return;
  2444.         }
  2445.     } 
  2446.  
  2447.     // get absolute path of file and make sure the filename ends
  2448.     // with .lyx
  2449.     filename = MakeAbsPath(filename);
  2450.     if (!IsLyXFilename(filename))
  2451.         filename += ".lyx";
  2452.  
  2453.     // Inserts document
  2454.     owner->getMiniBuffer()->Set(_("Inserting document"),
  2455.                     MakeDisplayPath(filename), "...");
  2456.     bool res = owner->currentBuffer()->insertLyXFile(filename);
  2457.     if (res) {
  2458.         owner->getMiniBuffer()->Set(_("Document"),
  2459.                         MakeDisplayPath(filename),
  2460.                         _("inserted."));
  2461.     } else {
  2462.         owner->getMiniBuffer()->Set(_("Could not insert document"),
  2463.                         MakeDisplayPath(filename));
  2464.     }
  2465. }
  2466.  
  2467.  
  2468. void LyXFunc::reloadBuffer()
  2469. {
  2470.     LString fn = owner->currentBuffer()->getFileName();
  2471.     if (bufferlist.close(owner->currentBuffer()))
  2472.         owner->currentView()->setBuffer(bufferlist.loadLyXFile(fn));
  2473. }
  2474.  
  2475.  
  2476. void LyXFunc::CloseBuffer()
  2477. {
  2478.     if (bufferlist.close(owner->currentBuffer()) && !quitting) {
  2479.         if (bufferlist.isEmpty()) {
  2480.             // need this otherwise SEGV may occur while trying to
  2481.             // set variables that don't exist
  2482.             // since there's no current buffer
  2483.             CloseAllBufferRelatedPopups();
  2484.         }
  2485.         else {
  2486.             owner->currentView()->setBuffer(bufferlist.first());
  2487.         }
  2488.     }
  2489. }
  2490.  
  2491.  
  2492. Inset* LyXFunc::getInsetByCode(Inset::Code code)
  2493. {
  2494.     bool found = false;
  2495.     Inset* inset = 0;
  2496.     LyXCursor cursor = owner->currentBuffer()->text->cursor;
  2497.     int pos = cursor.pos;
  2498.     LyXParagraph *par = cursor.par;
  2499.     
  2500.     while (par && !found) {
  2501.         while ((inset = par->ReturnNextInsetPointer(pos))){
  2502.             if (inset->LyxCode()==code) {
  2503.                 found = true;
  2504.                 break;
  2505.             }
  2506.             pos++;
  2507.         } 
  2508.         par = par->next;
  2509.     }
  2510.     return (found) ? inset: 0;
  2511. }
  2512.  
  2513.  
  2514. // Each "owner" should have it's own message method. lyxview and
  2515. // the minibuffer would use the minibuffer, but lyxserver would
  2516. // send an ERROR signal to its client.  Alejandro 970603
  2517. // This func is bit problematic when it comes to NLS, to make the
  2518. // lyx servers client be language indepenent we must not translate
  2519. // strings sent to this func.
  2520. void LyXFunc::setErrorMessage(LString const &m) 
  2521. {
  2522.     dispatch_buffer = m;
  2523.     errorstat = true;
  2524. }
  2525.  
  2526.  
  2527. void LyXFunc::setMessage(LString const & m)
  2528. {
  2529.     dispatch_buffer = m;
  2530. }
  2531.