]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfunc.C
removed a warning from screen and added CFLAGS in lyx.spec.in.
[lyx.git] / src / lyxfunc.C
index 8ddc081638d991dfd862d3edc8ccbd4f796b5b9d..24a0a3406fdc1c701fa79d26ae19b236a6fa1249 100644 (file)
@@ -1,18 +1,18 @@
 /* This file is part of
-* ======================================================
-* 
-*           LyX, The Document Processor
-*       
-*          Copyright (C) 1995 Matthias Ettrich
-*           Copyright (C) 1995-1998 The LyX Team.
-*
-*======================================================*/
+ * ======================================================
+ 
+ *           LyX, The Document Processor
+ *      
+ *         Copyright 1995 Matthias Ettrich
+ *          Copyright 1995-1999 The LyX Team.
+ *
+ * ======================================================*/
 
 #include <config.h>
 
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
+#include <cstdlib>
+#include <cctype>
+#include <cstring>
 
 #ifdef __GNUG__
 #pragma implementation
 #include "insets/insetinclude.h"
 #include "filedlg.h"
 #include "lyx_gui_misc.h"
-#include "filetools.h"
-#include "FileInfo.h"
+#include "support/filetools.h"
+#include "support/FileInfo.h"
 #include "lyxscreen.h"
-#include "error.h"
+#include "debug.h"
 #include "lyxrc.h"
 #include "lyxtext.h"
 #include "gettext.h"
 #include "trans_mgr.h"
 #include "ImportLaTeX.h"
 #include "ImportNoweb.h"
-
-//     $Id: lyxfunc.C,v 1.1 1999/09/27 18:44:37 larsbj Exp $   
-
-#if !defined(lint) && !defined(WITH_WARNINGS)
-static char vcid[] = "$Id: lyxfunc.C,v 1.1 1999/09/27 18:44:37 larsbj Exp $";
-#endif /* lint */
+#include "support/syscall.h"
+#include "support/lstrings.h"
 
 extern bool cursor_follows_scrollbar;
 
-extern void InsertAsciiFile(LString const &, bool);
+extern void InsertAsciiFile(string const &, bool);
 extern void math_insert_symbol(char const*);
 extern Bool math_insert_greek(char const); // why "Bool"?
 extern BufferList bufferlist;
@@ -130,8 +126,8 @@ extern void MenuLayoutPreamble();
 extern void MenuLayoutSave();
 extern void bulletForm();
 
-extern Buffer * NewLyxFile(LString const &);
-extern void LoadLyXFile(LString const &);
+extern Buffer * NewLyxFile(string const &);
+extern void LoadLyXFile(string const &);
 extern void Reconfigure();
 
 extern int current_layout;
@@ -163,19 +159,6 @@ LyXFunc::~LyXFunc()
 }
 
 
-LString LyXFunc::argAsString(char const *const argument)
-{
-       LString tmp(argument);
-
-       if (tmp.empty()) {
-               // get the arg from somewhere else, a popup, or ask for
-               // it in the minibuffer.
-       }
-       lyxerr.debug("argAsString: <" + tmp + '>');
-       return tmp;
-}
-
-
 // I changed this func slightly. I commented out the ...FinishUndo(),
 // this means that all places that used to have a moveCursorUpdate, now
 // have a ...FinishUndo() as the preceeding statement. I have also added
@@ -206,26 +189,26 @@ int LyXFunc::processKeyEvent(XEvent *ev)
        s_r[9] = '\0';
        int num_bytes;
        int action; 
-       char *argument = 0;
+       string argument;
        XKeyEvent *keyevent = &ev->xkey;
        KeySym keysym_return;
 
        num_bytes = LyXLookupString(ev, s_r, 10, &keysym_return);
 
-       if (lyxerr.debugging(Error::KEY)) {
-               lyxerr.print(LString("KeySym is ")
-                            + XKeysymToString(keysym_return)
-                            + "["
-                            + int(keysym_return) + "]"
-                            + " and num_bytes is "
-                            + num_bytes
-                            + " the string returned is \""
-                            + LString(s_r) + '\"');
+       if (lyxerr.debugging(Debug::KEY)) {
+               lyxerr << "KeySym is "
+                      << XKeysymToString(keysym_return)
+                      << "["
+                      << keysym_return << "]"
+                      << " and num_bytes is "
+                      << num_bytes
+                      << " the string returned is \""
+                      << s_r << '\"' << endl;
        }
        // Do nothing if we have nothing (JMarc)
        if (num_bytes == 0 && keysym_return == NoSymbol) {
-               lyxerr.debug("Empty kbd action (probably composing)",
-                            Error::KEY);
+               lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
+                                  << endl;
                return 0;
        }
        
@@ -270,13 +253,13 @@ int LyXFunc::processKeyEvent(XEvent *ev)
                
        if (action == 0) action = LFUN_PREFIX;
 
-       if (lyxerr.debugging(Error::KEY)) {
+       if (lyxerr.debugging(Debug::KEY)) {
                char buf[100];
                keyseq.print(buf,100);
-               lyxerr.print(LString("Key [")
-                            + int(action) + "]["
-                            + buf + "]["
-                            + num_bytes +"]");
+               lyxerr << "Key ["
+                      << action << "]["
+                      << buf << "]["
+                      << num_bytes << "]" << endl;
        }
 
        // already here we know if it any point in going further
@@ -302,48 +285,39 @@ int LyXFunc::processKeyEvent(XEvent *ev)
                if (!(keyevent->state&ControlMask) &&
                    !(keyevent->state&Mod1Mask) &&
                    (isochar && keysym_return < 0xF000)) {
-                       argument = &s_r[0]; // shall this be here
-                       argument[0] = isochar;
-                       argument[1] = 0;
+                       argument += isochar;
                }
-               if (!argument) {
-                       lyxerr.debug("Empty argument!");
+               if (argument.empty()) {
+                       lyxerr.debug() << "Empty argument!" << endl;
                        // This can`t possibly be of any use
                        // so we`ll skip the dispatch.
                        return 0;
                }
        } else
                if (action==LFUN_SELFINSERT) {
-                       argument = &s_r[0];
-                       argument[1] = 0;
+                       argument = s_r[0];
                }
     
         bool tmp_sc = show_sc;
        show_sc = false;
-       Dispatch(action, argument);
+       Dispatch(action, argument.c_str());
        show_sc = tmp_sc;
        
-       // Need this for deadkeys (alkis)
-       //keyseq.length=0;
-       // ...but that breaks the minibuffer's display of "M-"...
-#ifdef WITH_WARNINGS
-#warning How does the deadkeys react to this?
-#endif
        return 0;
 } 
 
 
-LString LyXFunc::Dispatch(LString const &cmd, LString const &arg)
+string LyXFunc::Dispatch(string const &cmd, string const &arg)
 {
        return Dispatch(lyxaction.LookupFunc(cmd.c_str()),
                        arg.c_str());
 }
 
 
-LString LyXFunc::Dispatch(int ac,
+string LyXFunc::Dispatch(int ac,
                          char const *do_not_use_this_arg)
 {
-       char const * argument = 0;
+       string argument;
        kb_action action;
         
 
@@ -351,7 +325,7 @@ LString LyXFunc::Dispatch(int ac,
     
         // we have not done anything wrong yet.
         errorstat = false;
-       dispatch_buffer = LString();
+       dispatch_buffer = string();
        
        // if action is a pseudo-action, we need the real action
        if (lyxaction.isPseudoAction(ac)) {
@@ -361,7 +335,8 @@ LString LyXFunc::Dispatch(int ac,
                        argument = tmparg;
        } else {
                action = (kb_action)ac;
-               argument = do_not_use_this_arg; // except here
+               if (do_not_use_this_arg)
+                       argument = do_not_use_this_arg; // except here
        }
     
        selection_possible = false;
@@ -403,43 +378,42 @@ LString LyXFunc::Dispatch(int ac,
                }
        }
        
-       commandshortcut = LString();
+       commandshortcut = string();
        
        if (lyxrc->display_shortcuts && show_sc) {
                if (action != LFUN_SELFINSERT) {
                        // Put name of command and list of shortcuts
                        // for it in minibuffer
-                       LString comname = lyxaction.getActionName(action);
+                       string comname = lyxaction.getActionName(action);
 
                        int pseudoaction = action;
                        bool argsadded = false;
 
-                       LString argu = argument;
-                       if (!argu.empty()) {
+                       if (!argument.empty()) {
                                // If we have the command with argument, 
                                // this is better
                                pseudoaction = 
                                        lyxaction.searchActionArg(action,
-                                                                 argument);
+                                                                 argument.c_str());
 
                                if (pseudoaction == -1) {
                                        pseudoaction = action;
                                } else {
-                                       comname += " " + argu;
+                                       comname += " " + argument;
                                        argsadded = true;
                                }
                        }
 
-                       LString shortcuts = toplevel_keymap->findbinding(pseudoaction);
+                       string shortcuts = toplevel_keymap->findbinding(pseudoaction);
 
                        if (!shortcuts.empty()) {
                                comname += ": " + shortcuts;
                        } else if (!argsadded) {
-                               comname += " " + argu;
+                               comname += " " + argument;
                        }
 
                        if (!comname.empty()) {
-                               comname.strip();
+                               comname = strip(comname);
                                commandshortcut = "(" + comname + ')';
                                owner->getMiniBuffer()->Set(commandshortcut);
                                // Here we could even add a small pause,
@@ -458,7 +432,7 @@ LString LyXFunc::Dispatch(int ac,
             owner->currentBuffer()->isReadonly() && 
             lyxaction.isFuncRO(action)) {
                setErrorMessage(N_("Document is read-only"));
-               lyxerr.debug("Error: Document is read-only.");
+               lyxerr.debug() << "Error: Document is read-only." << endl;
                goto exit_with_message;
        }
 
@@ -467,10 +441,8 @@ LString LyXFunc::Dispatch(int ac,
        if (owner->currentView()->available() &&
            owner->currentBuffer()->the_locking_inset) {
                if (action>1 || (action==LFUN_UNKNOWN_ACTION && keyseq.length>=-1)) {
-                       char s[8]="";
-                       if (action==LFUN_UNKNOWN_ACTION && !argument) {
-                               sprintf(s, "%c", keyseq.getiso());
-                               argument = &s[0];
+                       if (action==LFUN_UNKNOWN_ACTION && argument.empty()) {
+                               argument = keyseq.getiso();
                        }
                        // Undo/Redo pre 0.13 is a bit tricky for insets.                   
                        if (action==LFUN_UNDO) {
@@ -483,7 +455,7 @@ LString LyXFunc::Dispatch(int ac,
                                inset = (UpdatableInset*)owner->currentBuffer()->text->cursor.par->GetInset(owner->currentBuffer()->text->cursor.pos);
                                if (inset) 
                                        inset->Edit(slx, sly);
-                               return LString();
+                               return string();
                        } else 
                                if (action==LFUN_REDO) {
                                        int slx, sly;
@@ -494,16 +466,16 @@ LString LyXFunc::Dispatch(int ac,
                                        inset = (UpdatableInset*)owner->currentBuffer()->text->cursor.par->GetInset(owner->currentBuffer()->text->cursor.pos);
                                        if (inset)
                                                inset->Edit(slx, sly);
-                                       return LString();
+                                       return string();
                                } else
-                                       if (owner->currentBuffer()->the_locking_inset->LocalDispatch(action, argument))
-                                               return LString();
+                                       if (owner->currentBuffer()->the_locking_inset->LocalDispatch(action, argument.c_str()))
+                                               return string();
                                        else {
                                                setMessage(N_("Text mode"));
                                                if (action==LFUN_RIGHT || action==-1)
                                                        owner->currentBuffer()->text->CursorRight();
                                                if (action==LFUN_LEFT || action==LFUN_RIGHT)
-                                                       return LString();
+                                                       return string();
                                        }
                }
        }
@@ -513,14 +485,12 @@ LString LyXFunc::Dispatch(int ac,
        case LFUN_WORDFINDFORWARD  : 
        case LFUN_WORDFINDBACKWARD : { 
                LyXText *ltCur;
-               static LString last_search;
-               LString searched_string;
+               static string last_search;
+               string searched_string;
            
-               LString arg = argAsString(argument);
-                       
-               if (!arg.empty()) {
-                       last_search = arg;
-                       searched_string = arg;
+               if (!argument.empty()) {
+                       last_search = argument;
+                       searched_string = argument;
                } else {
                        searched_string = last_search;
                }
@@ -567,7 +537,7 @@ LString LyXFunc::Dispatch(int ac,
                }
                char buf[100];
                keyseq.print(buf,100, true);
-               owner->getMiniBuffer()->Set(buf, LString(), LString(), 1);
+               owner->getMiniBuffer()->Set(buf, string(), string(), 1);
        }
        break;
 
@@ -581,7 +551,7 @@ LString LyXFunc::Dispatch(int ac,
                meta_fake_bit = 0;
                if(owner->currentView()->available())
                        // cancel any selection
-                       Dispatch(int(LFUN_MARK_OFF), NULL);
+                       Dispatch(int(LFUN_MARK_OFF), 0);
                setMessage(N_("Cancel"));
                break;
 
@@ -590,7 +560,7 @@ LString LyXFunc::Dispatch(int ac,
                meta_fake_bit = Mod1Mask;
                char buf[100];
                keyseq.print(buf, 98, true);
-               LString res = LString("M-") + buf;
+               string res = string("M-") + buf;
                setMessage(buf); // RVDK_PATCH_5
        }
        break;  
@@ -690,7 +660,7 @@ LString LyXFunc::Dispatch(int ac,
        case LFUN_EXPORT:
        {
                //needs argument as string
-               LString extyp=argAsString(argument);
+               string extyp=argument;
                
                // latex
                if (extyp == "latex") {
@@ -735,8 +705,29 @@ LString LyXFunc::Dispatch(int ac,
                        MenuSendto();
                        break;
                }
+               // HTML
+               else if (extyp == "html") {
+                       // First, create LaTeX file
+                       MenuMakeLaTeX(owner->currentBuffer());
+
+                       // And now, run tth
+                       string file = owner->currentBuffer()->getFileName();
+                       file = ChangeExtension(file, ".tex", false);
+                       string result = ChangeExtension(file, ".html", false);
+                       string tmp = lyxrc->tth_command + " < " + file 
+                           + " > " + result ;
+                       Systemcalls one;
+                       int res = one.startscript(Systemcalls::System, tmp);
+                       if (res == 0) {
+                               setMessage(string(
+                                 _("Document exported as HTML to file: ")) + result);
+                       } else {
+                               setErrorMessage(string(
+                                 _("An unexpected error occured while converting document to HTML in file:")) + result);
+                       }
+               }
                else {
-                       setErrorMessage(LString(N_("Unknown export type: "))
+                       setErrorMessage(string(_("Unknown export type: "))
                                        + extyp);
                }
        }
@@ -745,7 +736,7 @@ LString LyXFunc::Dispatch(int ac,
        case LFUN_IMPORT:
        {
                //needs argument as string
-               LString imtyp=argAsString(argument);
+               string imtyp=argument;
                
                // latex
                if (imtyp == "latex") {
@@ -760,7 +751,7 @@ LString LyXFunc::Dispatch(int ac,
                } else if (imtyp == "noweb") {
                        doImportLaTeX(true);
                } else {
-                       setErrorMessage(LString(N_("Unknown import type: "))
+                       setErrorMessage(string(N_("Unknown import type: "))
                                        + imtyp);
                }
                break;
@@ -775,10 +766,16 @@ LString LyXFunc::Dispatch(int ac,
                if (fd_form_toc->form_toc->visible) {
                        fl_raise_form(fd_form_toc->form_toc);
                } else {
+                       static int ow = -1, oh;
                        fl_show_form(fd_form_toc->form_toc,
                                     FL_PLACE_MOUSE |
                                     FL_FREE_SIZE, FL_FULLBORDER,
                                     _("Table of Contents"));
+                       if (ow < 0) {
+                               ow = fd_form_toc->form_toc->w;
+                               oh = fd_form_toc->form_toc->h;
+                       }
+                       fl_set_form_minsize(fd_form_toc->form_toc, ow, oh);
                }
                break;
                
@@ -849,7 +846,7 @@ LString LyXFunc::Dispatch(int ac,
        case LFUN_PASTESELECTION:
        {
                bool asPara = false;
-               if (LString(argument) == "paragraph") asPara = true;
+               if (string(argument) == "paragraph") asPara = true;
                MenuPasteSelection(asPara);
                break;
        }
@@ -1025,17 +1022,15 @@ LString LyXFunc::Dispatch(int ac,
                        
        case LFUN_FILE_INSERT:
        {
-               // needs argument as string
-               LString fil = argAsString(argument);
-               MenuInsertLyXFile(fil);
+               MenuInsertLyXFile(argument);
        }
        break;
        
        case LFUN_FILE_INSERT_ASCII:
        {
                bool asPara = false;
-               asPara = (LString(argument) == "paragraph");
-               InsertAsciiFile(LString(), asPara);
+               asPara = (string(argument) == "paragraph");
+               InsertAsciiFile(string(), asPara);
        }
        break;
        
@@ -1060,13 +1055,13 @@ LString LyXFunc::Dispatch(int ac,
                
        case LFUN_LAYOUTNO:
        {
-               lyxerr.debug("LFUN_LAYOUTNO: (arg) " + LString(argument));
-               int sel = atoi(argument);
-               lyxerr.debug(LString("LFUN_LAYOUTNO: (sel) ") + int(sel));
+               lyxerr.debug() << "LFUN_LAYOUTNO: (arg) " << argument << endl;
+               int sel = strToInt(argument);
+               lyxerr.debug() << "LFUN_LAYOUTNO: (sel) "<< sel << endl;
                
                // Should this give a setMessage instead?
                if (sel == 0) 
-                       return LString(); // illegal argument
+                       return string(); // illegal argument
 
                sel--; // sel 1..., but layout 0...
 
@@ -1076,13 +1071,13 @@ LString LyXFunc::Dispatch(int ac,
                                               text->parameters->
                                               textclass,
                                               sel).c_str());
-               return LString();
+               return string();
        }
                
        case LFUN_LAYOUT:
        {
-               lyxerr.debug("LFUN_LAYOUT: (arg) "
-                            + LString(argument));
+               lyxerr.debug() << "LFUN_LAYOUT: (arg) "
+                              << argument << endl;
                
                // Derive layout number from given argument (string)
                // and current buffer's textclass (number). */    
@@ -1096,7 +1091,7 @@ LString LyXFunc::Dispatch(int ac,
 
                // see if we found the layout number:
                if (layoutno == -1) {
-                       setErrorMessage(LString(N_("Layout ")) + argument + 
+                       setErrorMessage(string(N_("Layout ")) + argument + 
                                        N_(" not known"));
                        break;
                }
@@ -1131,7 +1126,7 @@ LString LyXFunc::Dispatch(int ac,
        case LFUN_LAYOUT_TABLE:
        {
                int flag = 0;
-               if (LString(argument) == "true") flag = 1;
+               if (string(argument) == "true") flag = 1;
                MenuLayoutTable(flag);
        }
        break;
@@ -1221,7 +1216,7 @@ LString LyXFunc::Dispatch(int ac,
                break;
                
        case LFUN_INSERT_LABEL:
-               MenuInsertLabel(argument);
+               MenuInsertLabel(argument.c_str());
                break;
                
        case LFUN_INSERT_REF:
@@ -1252,7 +1247,7 @@ LString LyXFunc::Dispatch(int ac,
 
        case LFUN_REFGOTO:
        {
-               LString label(argument);
+               string label(argument);
                if (label.empty()) {
                        InsetRef *inset =
                                (InsetRef*)getInsetByCode(Inset::REF_CODE);
@@ -1853,23 +1848,23 @@ LString LyXFunc::Dispatch(int ac,
        break;
        
        case LFUN_GETXY:
-               dispatch_buffer = LString()
-                       + owner->currentBuffer()->text->cursor.x + ' '
-                       + owner->currentBuffer()->text->cursor.y;
+               dispatch_buffer = 
+                        tostr(owner->currentBuffer()->text->cursor.x) + ' '
+                       + tostr(owner->currentBuffer()->text->cursor.y);
                break;
                
        case LFUN_SETXY:
        {
                int  x;
                long y;
-               sscanf(argument, " %d %ld", &x, &y);
+               sscanf(argument.c_str(), " %d %ld", &x, &y);
                owner->currentBuffer()->text->SetCursorFromCoordinates(x, y);
        }
        break;
        
        case LFUN_GETLAYOUT:
-               dispatch_buffer = LString() + 
-                       int(owner->currentBuffer()->text->cursor.par->layout);
+               dispatch_buffer =  
+                       tostr(owner->currentBuffer()->text->cursor.par->layout);
                break;
                        
        case LFUN_GETFONT:
@@ -1897,9 +1892,9 @@ LString LyXFunc::Dispatch(int ac,
 
        case LFUN_GETNAME:
                setMessage(owner->currentBuffer()->getFileName());
-               lyxerr.debug(LString("FNAME[") +
-                            owner->currentBuffer()->getFileName() +
-                            "] ");
+               lyxerr.debug() << "FNAME["
+                              << owner->currentBuffer()->getFileName()
+                              << "] " << endl;
                break;
                
        case LFUN_NOTIFY:
@@ -1915,10 +1910,10 @@ LString LyXFunc::Dispatch(int ac,
        {
                char file_name[100];
                int  row;
-               sscanf(argument, " %s %d", file_name, &row);
+               sscanf(argument.c_str(), " %s %d", file_name, &row);
 
                // Must replace extension of the file to be .lyx and get full path
-               LString s = ChangeExtension(LString(file_name), ".lyx", false);
+               string s = ChangeExtension(string(file_name), ".lyx", false);
 
                // Either change buffer or load the file
                if (bufferlist.exists(s))
@@ -1948,7 +1943,7 @@ LString LyXFunc::Dispatch(int ac,
        case LFUN_APROPOS:
        case LFUN_GETTIP:
        {
-               int qa = lyxaction.LookupFunc((const char*)argument);
+               int qa = lyxaction.LookupFunc(argument.c_str());
                setMessage(lyxaction.helpText((kb_action)qa));
        }
        break;
@@ -2000,12 +1995,12 @@ LString LyXFunc::Dispatch(int ac,
        // --- toolbar ----------------------------------
        case LFUN_PUSH_TOOLBAR:
        {
-               int nth = atoi(argument);
-               if (lyxerr.debugging(Error::TOOLBAR)) {
-                       lyxerr.print(LString("LFUN_PUSH_TOOLBAR: argument = `")
-                                    + argument + "'");
-                       lyxerr.print(LString("LFUN_PUSH_TOOLBAR: nth = `")
-                                    + nth + "'");
+               int nth = strToInt(argument);
+               if (lyxerr.debugging(Debug::TOOLBAR)) {
+                       lyxerr << "LFUN_PUSH_TOOLBAR: argument = `"
+                              << argument << "'\n"
+                              << "LFUN_PUSH_TOOLBAR: nth = `"
+                              << nth << "'" << endl;
                }
                
                if (nth <= 0) {
@@ -2019,13 +2014,13 @@ LString LyXFunc::Dispatch(int ac,
        
        case LFUN_ADD_TO_TOOLBAR:
        {
-               if (lyxerr.debugging(Error::TOOLBAR)) {
-                       lyxerr.print(LString("LFUN_ADD_TO_TOOLBAR:"
-                                            "argument = `")+ argument + '\'');
+               if (lyxerr.debugging(Debug::TOOLBAR)) {
+                       lyxerr << "LFUN_ADD_TO_TOOLBAR:"
+                               "argument = `" << argument << '\'' << endl;
                }
-               LString tmp(argument);
-               //lyxerr.print(LString("Argument: ") + argument);
-               //lyxerr.print(LString("Tmp     : ") + tmp);
+               string tmp(argument);
+               //lyxerr <<string("Argument: ") + argument);
+               //lyxerr <<string("Tmp     : ") + tmp);
                if (tmp.empty()) {
                        LyXBell();
                        setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
@@ -2077,14 +2072,14 @@ LString LyXFunc::Dispatch(int ac,
                        owner->currentBuffer()->
                                open_new_inset(new InsetFormula(false));
                        owner->currentBuffer()->
-                               the_locking_inset->LocalDispatch(action, argument);
+                               the_locking_inset->LocalDispatch(action, argument.c_str());
                }
        }          
        break;
               
        case LFUN_INSERT_MATH:
        {
-               math_insert_symbol(argument);
+               math_insert_symbol(argument.c_str());
        }
        break;
        
@@ -2098,14 +2093,14 @@ LString LyXFunc::Dispatch(int ac,
        case LFUN_MATH_MACRO:
        {
                if (owner->currentView()->available()) {
-                       LString s(argument);
+                       string s(argument);
                        if (s.empty())
                            setErrorMessage(N_("Missing argument"));
                        else {
-                           LString s1 = s.token(' ', 1);
+                           string s1 = token(s, ' ', 1);
                            int na = s1.empty() ? 0: atoi(s1.c_str());
                            owner->currentBuffer()->
-                             open_new_inset(new InsetFormulaMacro(s.token(' ', 0), na));
+                             open_new_inset(new InsetFormulaMacro(token(s, ' ', 0), na));
                        }
                }
        }
@@ -2133,11 +2128,11 @@ LString LyXFunc::Dispatch(int ac,
                // ale970405
                // The note, if any, must be after the key, delimited
                // by a | so both key and remark can have spaces.
-               if (argument) {
-                       LString lsarg(argument);
-                       if (lsarg.contains("|")) {
-                               new_inset->setContents(lsarg.token('|', 0));
-                               new_inset->setOptions(lsarg.token('|', 1));
+               if (!argument.empty()) {
+                       string lsarg(argument);
+                       if (contains(lsarg, "|")) {
+                               new_inset->setContents(token(lsarg, '|', 0));
+                               new_inset->setOptions(token(lsarg, '|', 1));
                        } else
                                new_inset->setContents(lsarg);
                        owner->currentBuffer()->insertInset(new_inset);
@@ -2153,12 +2148,12 @@ LString LyXFunc::Dispatch(int ac,
                // ale970405+lasgoutt970425
                // The argument can be up to two tokens separated 
                // by a space. The first one is the bibstyle.
-               LString lsarg(argument);
-               LString bibstyle = lsarg.token(' ', 1);
+               string lsarg(argument);
+               string bibstyle = token(lsarg, ' ', 1);
                if (bibstyle.empty())
                        bibstyle = "plain";
                InsetBibtex *new_inset 
-                       = new InsetBibtex(lsarg.token(' ', 0),
+                       = new InsetBibtex(token(lsarg, ' ', 0),
                                          bibstyle,
                                          owner->currentBuffer());
                
@@ -2204,8 +2199,8 @@ LString LyXFunc::Dispatch(int ac,
        case LFUN_INDEX_INSERT_LAST:
        {
                InsetIndex *new_inset = new InsetIndex();
-               if (argument) {
-                       LString lsarg(argument);
+               if (!argument.empty()) {
+                       string lsarg(argument);
                        new_inset->setContents(lsarg);
                        owner->currentBuffer()->insertInset(new_inset);
                } else {
@@ -2224,7 +2219,7 @@ LString LyXFunc::Dispatch(int ac,
                  // note that this must be done before 
                  // inserting the inset, or the inset will break
                  // the word
-                 LString curstring(owner->currentBuffer()->text->cursor.par->GetWord(lastpos));
+                 string curstring(owner->currentBuffer()->text->cursor.par->GetWord(lastpos));
 
                  //make the new inset and write the current word into it
                  InsetIndex *new_inset = new InsetIndex();
@@ -2260,7 +2255,7 @@ LString LyXFunc::Dispatch(int ac,
 
        case LFUN_PARENTINSERT:
        {
-               lyxerr.print(LString("arg ") + argument);
+               lyxerr << "arg " << argument << endl;
                Inset *new_inset = new InsetParent(argument, owner->currentBuffer());
                owner->currentBuffer()->insertInset(new_inset, "Standard", true);
        }
@@ -2276,7 +2271,7 @@ LString LyXFunc::Dispatch(int ac,
 
        case LFUN_CHILDOPEN:
        {
-               LString filename = MakeAbsPath(argument, 
+               string filename = MakeAbsPath(argument, 
                                               OnlyPath(owner->currentBuffer()->getFileName()));
                setMessage(N_("Opening child document ") +
                           MakeDisplayPath(filename) + "...");
@@ -2295,20 +2290,19 @@ LString LyXFunc::Dispatch(int ac,
        case LFUN_INSERTFOOTNOTE: 
        {
                LyXParagraph::footnote_kind kind;
-               LString arg = argument;
-               if (arg == "footnote")
+               if (argument == "footnote")
                        { kind = LyXParagraph::FOOTNOTE; }
-               else if (arg == "margin")
+               else if (argument == "margin")
                        { kind = LyXParagraph::MARGIN; }
-               else if (arg == "figure")
+               else if (argument == "figure")
                        { kind = LyXParagraph::FIG; }
-               else if (arg == "table")
+               else if (argument == "table")
                        { kind = LyXParagraph::TAB; }
-               else if (arg == "wide-fig")
+               else if (argument == "wide-fig")
                        { kind = LyXParagraph::WIDE_FIG; }
-               else if (arg == "wide-tab")
+               else if (argument == "wide-tab")
                        { kind = LyXParagraph::WIDE_TAB; }
-               else if (arg == "algorithm")
+               else if (argument == "algorithm")
                        { kind = LyXParagraph::ALGORITHM; }
                else {
                        setErrorMessage(N_("Unknown kind of footnote"));
@@ -2345,9 +2339,8 @@ LString LyXFunc::Dispatch(int ac,
 
        case LFUN_SELFINSERT:
        {
-               LString const text = argument;
-               for (int i=0; i<text.length(); i++) {
-                       owner->currentBuffer()->text->InsertChar(text[i]);
+               for (string::size_type i = 0; i < argument.length(); ++i) {
+                       owner->currentBuffer()->text->InsertChar(argument[i]);
                        // This needs to be in the loop, or else we
                        // won't break lines correctly. (Asger)
                        SmallUpdate(1);
@@ -2367,7 +2360,7 @@ LString LyXFunc::Dispatch(int ac,
                        break;
                }
                         
-               if (argument) {
+               if (!argument.empty()) {
                        
                        /* Automatically delete the currently selected
                         * text and replace it with what is being
@@ -2383,12 +2376,12 @@ LString LyXFunc::Dispatch(int ac,
                        }
                        
                        BeforeChange();
-                       for(char const *p = argument; *p; p++) {
+                       for (string::size_type i = 0; i < argument.length(); ++i) {
                                if (greek_kb_flag) {
-                                       if (!math_insert_greek(*p))
-                                               owner->getIntl()->getTrans()->TranslateAndInsert(*p, owner->currentBuffer()->text);
+                                       if (!math_insert_greek(argument[i]))
+                                               owner->getIntl()->getTrans()->TranslateAndInsert(argument[i], owner->currentBuffer()->text);
                                } else
-                                       owner->getIntl()->getTrans()->TranslateAndInsert(*p, owner->currentBuffer()->text);
+                                       owner->getIntl()->getTrans()->TranslateAndInsert(argument[i], owner->currentBuffer()->text);
                        }
                        
                        SmallUpdate(1);
@@ -2397,7 +2390,7 @@ LString LyXFunc::Dispatch(int ac,
                        owner->currentBuffer()->text->sel_cursor =
                                owner->currentBuffer()->text->cursor;
                        moveCursorUpdate(false);
-                       return LString();
+                       return string();
                } else {
                        // why is an "Unknown action" with empty
                        // argument even dispatched in the first
@@ -2407,17 +2400,17 @@ LString LyXFunc::Dispatch(int ac,
                }
                break;
        default:
-               lyxerr.print("A truly unknown func!");
+               lyxerr << "A truly unknown func!" << endl;
                break;
        }
        } // end of switch
   exit_with_message:
 
-       LString res=getMessage();
+       string res=getMessage();
 
        if (res.empty()) {
                if (!commandshortcut.empty()) {
-                       LString newbuf = owner->getMiniBuffer()->GetText();
+                       string newbuf = owner->getMiniBuffer()->GetText();
                        if (newbuf != commandshortcut) {
                                owner->getMiniBuffer()->Set(newbuf
                                                            + " " +
@@ -2425,7 +2418,7 @@ LString LyXFunc::Dispatch(int ac,
                        }
                }
        } else {
-               owner->getMiniBuffer()->Set(LString(_(res.c_str()))
+               owner->getMiniBuffer()->Set(string(_(res.c_str()))
                                            + " " + commandshortcut);
        }
 
@@ -2442,11 +2435,11 @@ void LyXFunc::setupLocalKeymap()
 
 void LyXFunc::MenuNew(bool fromTemplate)
 {
-       LString fname, initpath = lyxrc->document_path;
+       string fname, initpath = lyxrc->document_path;
        LyXFileDlg fileDlg;
 
        if (owner->currentView()->available()) {
-               LString trypath = owner->currentBuffer()->filepath;
+               string trypath = owner->currentBuffer()->filepath;
                // If directory is writeable, use this as default.
                if (IsDirWriteable(trypath) == 1)
                        initpath = trypath;
@@ -2461,13 +2454,13 @@ void LyXFunc::MenuNew(bool fromTemplate)
        
        if (fname.empty()) {
                owner->getMiniBuffer()->Set(_("Canceled."));
-               lyxerr.debug("New Document Cancelled.");
+               lyxerr.debug() << "New Document Cancelled." << endl;
                return;
        }
         
        // get absolute path of file and make sure the filename ends
        // with .lyx
-       LString s = MakeAbsPath(fname);
+       string s = MakeAbsPath(fname);
        if (!IsLyXFilename(s))
                s += ".lyx";
 
@@ -2513,7 +2506,7 @@ void LyXFunc::MenuNew(bool fromTemplate)
        }
 
        // The template stuff
-       LString templname;
+       string templname;
        if (fromTemplate) {
                ProhibitInput();
                fname = fileDlg.Select(_("Choose template"),
@@ -2524,18 +2517,18 @@ void LyXFunc::MenuNew(bool fromTemplate)
        }
   
        // find a free buffer
-       lyxerr.debug("Find a free buffer.");
+       lyxerr.debug() << "Find a free buffer." << endl;
        owner->currentView()->setBuffer(bufferlist.newFile(s,templname));
 }
 
 
 void LyXFunc::MenuOpen()
 {
-       LString initpath = lyxrc->document_path;
+       string initpath = lyxrc->document_path;
        LyXFileDlg fileDlg;
   
        if (owner->currentView()->available()) {
-               LString trypath = owner->currentBuffer()->filepath;
+               string trypath = owner->currentBuffer()->filepath;
                // If directory is writeable, use this as default.
                if (IsDirWriteable(trypath) == 1)
                        initpath = trypath;
@@ -2546,7 +2539,7 @@ void LyXFunc::MenuOpen()
        fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
        fileDlg.SetButton(1, _("Examples"), 
                          AddPath(system_lyxdir, "examples"));
-       LString filename = fileDlg.Select(_("Select Document to Open"),
+       string filename = fileDlg.Select(_("Select Document to Open"),
                                          initpath, "*.lyx");
        AllowInput();
  
@@ -2580,11 +2573,11 @@ void LyXFunc::MenuOpen()
 
 void LyXFunc::doImportASCII(bool linorpar)
 {
-       LString initpath = lyxrc->document_path;
+       string initpath = lyxrc->document_path;
        LyXFileDlg fileDlg;
   
        if (owner->currentView()->available()) {
-               LString trypath = owner->currentBuffer()->filepath;
+               string trypath = owner->currentBuffer()->filepath;
                // If directory is writeable, use this as default.
                if (IsDirWriteable(trypath) == 1)
                        initpath = trypath;
@@ -2595,7 +2588,7 @@ void LyXFunc::doImportASCII(bool linorpar)
        fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
        fileDlg.SetButton(1, _("Examples"), 
                          AddPath(system_lyxdir, "examples"));
-       LString filename = fileDlg.Select(_("Select ASCII file to Import"),
+       string filename = fileDlg.Select(_("Select ASCII file to Import"),
                                          initpath, "*.txt");
        AllowInput();
  
@@ -2608,7 +2601,7 @@ void LyXFunc::doImportASCII(bool linorpar)
        // get absolute path of file
        filename = MakeAbsPath(filename);
 
-       LString s = ChangeExtension(filename, ".lyx", false);
+       string s = ChangeExtension(filename, ".lyx", false);
 
        // Check if the document already is open
        if (bufferlist.exists(s)){
@@ -2640,7 +2633,7 @@ void LyXFunc::doImportASCII(bool linorpar)
                return;
        }
 
-       owner->currentView()->setBuffer(bufferlist.newFile(s,LString()));
+       owner->currentView()->setBuffer(bufferlist.newFile(s,string()));
        owner->getMiniBuffer()->Set(_("Importing ASCII file"),
                                    MakeDisplayPath(filename), "...");
        // Insert ASCII file
@@ -2653,11 +2646,11 @@ void LyXFunc::doImportASCII(bool linorpar)
 
 void LyXFunc::doImportLaTeX(bool isnoweb)
 {
-       LString initpath = lyxrc->document_path;
+       string initpath = lyxrc->document_path;
        LyXFileDlg fileDlg;
   
        if (owner->currentView()->available()) {
-               LString trypath = owner->currentBuffer()->filepath;
+               string trypath = owner->currentBuffer()->filepath;
                // If directory is writeable, use this as default.
                if (IsDirWriteable(trypath) == 1)
                        initpath = trypath;
@@ -2668,7 +2661,7 @@ void LyXFunc::doImportLaTeX(bool isnoweb)
        fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
        fileDlg.SetButton(1, _("Examples"), 
                          AddPath(system_lyxdir, "examples"));
-       LString filename;
+       string filename;
        if (isnoweb) {
                filename = fileDlg.Select(_("Select Noweb file to Import"),
                                          initpath, "*.nw");
@@ -2689,7 +2682,7 @@ void LyXFunc::doImportLaTeX(bool isnoweb)
        filename = MakeAbsPath(filename);
 
        // Check if the document already is open
-       LString LyXfilename = ChangeExtension(filename, ".lyx", false);
+       string LyXfilename = ChangeExtension(filename, ".lyx", false);
        if (bufferlist.exists(LyXfilename)){
                switch(AskConfirmation(_("Document is already open:"), 
                                       MakeDisplayPath(LyXfilename,50),
@@ -2748,17 +2741,17 @@ void LyXFunc::doImportLaTeX(bool isnoweb)
 }
 
 
-void LyXFunc::MenuInsertLyXFile(LString const & filen)
+void LyXFunc::MenuInsertLyXFile(string const & filen)
 {
-       LString filename = filen;
+       string filename = filen;
 
        if (filename.empty()) {
                // Launch a file browser
-               LString initpath = lyxrc->document_path;
+               string initpath = lyxrc->document_path;
                LyXFileDlg fileDlg;
 
                if (owner->currentView()->available()) {
-                       LString trypath = owner->currentBuffer()->filepath;
+                       string trypath = owner->currentBuffer()->filepath;
                        // If directory is writeable, use this as default.
                        if (IsDirWriteable(trypath) == 1)
                                initpath = trypath;
@@ -2803,7 +2796,7 @@ void LyXFunc::MenuInsertLyXFile(LString const & filen)
 
 void LyXFunc::reloadBuffer()
 {
-       LString fn = owner->currentBuffer()->getFileName();
+       string fn = owner->currentBuffer()->getFileName();
        if (bufferlist.close(owner->currentBuffer()))
                owner->currentView()->setBuffer(bufferlist.loadLyXFile(fn));
 }
@@ -2853,14 +2846,14 @@ Inset* LyXFunc::getInsetByCode(Inset::Code code)
 // This func is bit problematic when it comes to NLS, to make the
 // lyx servers client be language indepenent we must not translate
 // strings sent to this func.
-void LyXFunc::setErrorMessage(LString const &m) 
+void LyXFunc::setErrorMessage(string const &m) 
 {
        dispatch_buffer = m;
        errorstat = true;
 }
 
 
-void LyXFunc::setMessage(LString const & m)
+void LyXFunc::setMessage(string const & m)
 {
        dispatch_buffer = m;
 }