]> git.lyx.org Git - lyx.git/blobdiff - src/bufferlist.C
removed a warning from screen and added CFLAGS in lyx.spec.in.
[lyx.git] / src / bufferlist.C
index a38e4bdb8c9a4422b60ed57af7564a283c404021..1a5afbd6c6e538ca53b1394eb035fd619e1ea7b9 100644 (file)
@@ -3,13 +3,13 @@
  * 
  *           LyX, The Document Word Processor
  *
- *         Copyright (C) 1995 Matthias Ettrich
- *          Copyright (C) 1995-1998 The LyX Team. 
+ *         Copyright 1995 Matthias Ettrich
+ *          Copyright 1995-1999 The LyX Team. 
  *
- *           This file is Copyleft (C) 1996-1998
+ *           This file is Copyright 1996-1999
  *           Lars Gullik Bjønnes
  *
- *======================================================
+ * ======================================================
  */
 
 #ifdef __GNUG__
 #include "bufferlist.h"
 #include "lyx_main.h"
 #include "minibuffer.h"
-#include "FileInfo.h"
-#include "filetools.h"
+#include "support/FileInfo.h"
+#include "support/filetools.h"
 #include "lyx_gui_misc.h"
 #include "lastfiles.h"
-#include "error.h"
+#include "debug.h"
 #include "lyxrc.h"
 #include "lyxscreen.h"
 #include "lyxtext.h"
 #include "lyx_cb.h"
 #include "gettext.h"
 
-//     $Id: bufferlist.C,v 1.1 1999/09/27 18:44:37 larsbj Exp $        
-
-#if !defined(lint) && !defined(WITH_WARNINGS)
-static char vcid[] = "$Id: bufferlist.C,v 1.1 1999/09/27 18:44:37 larsbj Exp $";
-#endif /* lint */
-
 extern BufferView *current_view;
 extern MiniBuffer *minibuffer;
 extern void SmallUpdate(signed char);
 extern void BeforeChange();
-extern int RunLinuxDoc(int, LString const &);
+extern int RunLinuxDoc(int, string const &);
 
 //
 // Class BufferStorage
@@ -78,7 +72,7 @@ void BufferStorage::release(Buffer* buf)
 }
 
 
-Buffer* BufferStorage::newBuffer(LString const &s,
+Buffer* BufferStorage::newBuffer(string const &s,
                                 LyXRC *lyxrc,
                                 bool ronly)
 {
@@ -87,7 +81,7 @@ Buffer* BufferStorage::newBuffer(LString const &s,
               && buffer[i]) i++;
        buffer[i] = new Buffer(s, lyxrc, ronly);
        buffer[i]->params.useClassDefaults();
-       lyxerr.debug(LString("Assigning to buffer ") + i, Error::ANY);
+       lyxerr.debug() << "Assigning to buffer " << i << endl;
        return buffer[i];
 }
 
@@ -149,7 +143,7 @@ extern void MenuWrite(Buffer*);
 bool BufferList::QwriteAll()
 {
         bool askMoreConfirmation = false;
-        LString unsaved;
+        string unsaved;
        BufferStorage_Iter biter(bstore);
        Buffer *b=0;
        while ((b=biter())) {
@@ -192,7 +186,7 @@ bool BufferList::write(Buffer *buf, bool makeBackup)
 
        // make a backup
        if (makeBackup) {
-               LString s = buf->filename + '~';
+               string s = buf->filename + '~';
                // Rename is the wrong way of making a backup,
                // this is the correct way.
                /* truss cp fil fil2:
@@ -226,7 +220,7 @@ bool BufferList::write(Buffer *buf, bool makeBackup)
                        times->actime = finfo.getAccessTime();
                        times->modtime = finfo.getModificationTime();
                        long blksize = finfo.getBlockSize();
-                       lyxerr.debug(LString("BlockSize: ") + int(blksize));
+                       lyxerr.debug() << "BlockSize: " << blksize << endl;
                        FilePtr fin(buf->filename,FilePtr::read);
                        FilePtr fout(s,FilePtr::truncate);
                        if (fin() && fout()) {
@@ -244,11 +238,11 @@ bool BufferList::write(Buffer *buf, bool makeBackup)
                                chmod(s.c_str(), fmode);
                                
                                if (utime(s.c_str(), times)) {
-                                       lyxerr.print("utime error.");
+                                       lyxerr << "utime error." << endl;
                                }
                                delete [] cbuf;
                        } else {
-                               lyxerr.print("LyX was not able to make backupcopy. Beware.");
+                               lyxerr << "LyX was not able to make backupcopy. Beware." << endl;
                        }
                        delete[] times;
                }
@@ -261,7 +255,7 @@ bool BufferList::write(Buffer *buf, bool makeBackup)
                                MakeDisplayPath(buf->filename));
 
                // now delete the autosavefile
-               LString a = OnlyPath(buf->filename);
+               string a = OnlyPath(buf->filename);
                a += '#';
                a += OnlyFilename(buf->filename);
                a += '#';
@@ -275,7 +269,7 @@ bool BufferList::write(Buffer *buf, bool makeBackup)
        } else {
                // Saving failed, so backup is not backup
                if (makeBackup) {
-                       LString s = buf->filename + '~';
+                       string s = buf->filename + '~';
                        rename(s.c_str(), buf->filename.c_str());
                }
                minibuffer->Set(_("Save failed!"));
@@ -347,7 +341,7 @@ void BufferList::makePup(int pup)
        BufferStorage_Iter biter(bstore);
        Buffer *b=0;
        while ((b=biter())) {
-               LString relbuf = MakeDisplayPath(b->filename,30);
+               string relbuf = MakeDisplayPath(b->filename,30);
                fl_addtopup(pup, relbuf.c_str());
                ant++;
        }
@@ -403,13 +397,13 @@ int BufferList::unlockInset(UpdatableInset *inset)
 }
 
 
-void BufferList::updateIncludedTeXfiles(LString const & mastertmpdir)
+void BufferList::updateIncludedTeXfiles(string const & mastertmpdir)
 {
        BufferStorage_Iter biter(bstore);
        Buffer *b=0;
        while ((b=biter())) {
                if (!b->isDepClean(mastertmpdir)) {
-                       LString writefile = mastertmpdir;
+                       string writefile = mastertmpdir;
                        writefile += '/';
                        writefile += ChangeExtension(b->getFileName(), ".tex", true);
                        b->makeLaTeXFile(writefile,mastertmpdir,false,true);
@@ -427,13 +421,13 @@ void BufferList::emergencyWriteAll()
                if (!b->isLyxClean()) {
                        bool madeit=false;
                        
-                       lyxerr.print(_("lyx: Attempting to save"
+                       lyxerr <<_("lyx: Attempting to save"
                                      " document ")
-                                     + b->filename
-                                     + _(" as..."));
+                              << b->filename
+                              << _(" as...") << endl;
                        
                        for (int i=0; i<3 && !madeit; i++) {
-                               LString s;
+                               string s;
                                
                                // We try to save three places:
                                // 1) Same place as document.
@@ -442,7 +436,7 @@ void BufferList::emergencyWriteAll()
                                if (i==0) {
                                        s = b->filename;
                                } else if (i==1) {
-                                       s = AddName(getEnvPath("HOME"),
+                                       s = AddName(GetEnvPath("HOME"),
                                                    b->filename);
                                } else { // MakeAbsPath to prepend the current drive letter on OS/2
                                        s = AddName(MakeAbsPath("/tmp/"),
@@ -450,16 +444,17 @@ void BufferList::emergencyWriteAll()
                                }
                                s += ".emergency";
                                
-                               lyxerr.print(LString("  ") + (i+1) + ") " + s);
+                               lyxerr << "  " << i+1 << ") " << s << endl;
                                
                                if (b->writeFile(s,true)) {
                                        b->markLyxClean();
-                                       lyxerr.print(_("  Save seems successful. Phew."));
+                                       lyxerr << _("  Save seems successful. Phew.") << endl;
                                        madeit = true;
                                } else if (i != 2) {
-                                       lyxerr.print(_("  Save failed! Trying..."));
+                                       lyxerr << _("  Save failed! Trying...")
+                                              << endl;
                                } else {
-                                       lyxerr.print(_("  Save failed! Bummer. Document is lost."));
+                                       lyxerr << _("  Save failed! Bummer. Document is lost.") << endl;
                                }
                        }
                }
@@ -467,13 +462,13 @@ void BufferList::emergencyWriteAll()
 }
 
 
-Buffer* BufferList::readFile(LString const & s, bool ronly)
+Buffer* BufferList::readFile(string const & s, bool ronly)
 {
        Buffer *b = bstore.newBuffer(s, lyxrc, ronly);
 
-       LString ts = s;
-       LString e = OnlyPath(s);
-       LString a = e;
+       string ts = s;
+       string e = OnlyPath(s);
+       string a = e;
        // File information about normal file
        FileInfo fileInfo2(s);
 
@@ -525,7 +520,7 @@ Buffer* BufferList::readFile(LString const & s, bool ronly)
                }
        }
        // not sure if this is the correct place to begin LyXLex
-       LyXLex lex(NULL, 0);
+       LyXLex lex(0, 0);
        lex.setFile(ts);
        if (b->readFile(lex))
                return b;
@@ -536,7 +531,7 @@ Buffer* BufferList::readFile(LString const & s, bool ronly)
 }
 
 
-bool BufferList::exists(LString const & s)
+bool BufferList::exists(string const & s)
 {
        BufferStorage_Iter biter(bstore);
        Buffer *b=0;
@@ -548,7 +543,7 @@ bool BufferList::exists(LString const & s)
 }
 
 
-Buffer* BufferList::getBuffer(LString const &s)
+Buffer* BufferList::getBuffer(string const &s)
 {
        BufferStorage_Iter biter(bstore);
        Buffer *b=0;
@@ -560,7 +555,7 @@ Buffer* BufferList::getBuffer(LString const &s)
 }
 
 
-Buffer* BufferList::newFile(LString const & name, LString tname)
+Buffer* BufferList::newFile(string const & name, string tname)
 {
        /* get a free buffer */ 
        Buffer *b = bstore.newBuffer(name, lyxrc);
@@ -571,7 +566,7 @@ Buffer* BufferList::newFile(LString const & name, LString tname)
        }
        if (!tname.empty() && IsLyXFilename(tname)){
                bool templateok = false;
-               LyXLex lex(NULL,0);
+               LyXLex lex(0,0);
                lex.setFile(tname);
                if (lex.IsOK()) {
                        if (b->readFile(lex)) {
@@ -596,10 +591,10 @@ Buffer* BufferList::newFile(LString const & name, LString tname)
 }
 
 
-Buffer* BufferList::loadLyXFile(LString const & filename, bool tolastfiles)
+Buffer* BufferList::loadLyXFile(string const & filename, bool tolastfiles)
 {
        // make sure our path is absolute
-       LString s = MakeAbsPath(filename);
+       string s = MakeAbsPath(filename);
 
        // Is this done too early?
        // Is it LinuxDoc?
@@ -656,14 +651,14 @@ Buffer* BufferList::loadLyXFile(LString const & filename, bool tolastfiles)
                if (LyXVC::file_not_found_hook(s)) {
                        // Ask if the file should be checked out for
                        // viewing/editing, if so: load it.
-                       lyxerr.print("Do you want to checkout?");
+                       lyxerr << "Do you want to checkout?" << endl;
                }
                if (AskQuestion(_("Cannot open specified file:"), 
                                MakeDisplayPath(s,50),
                                _("Create new document with this name?")))
                {
                        // Find a free buffer
-                       b = newFile(s,LString());
+                       b = newFile(s,string());
                }
                break;
        }