*
* 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
}
-Buffer* BufferStorage::newBuffer(LString const &s,
+Buffer* BufferStorage::newBuffer(string const &s,
LyXRC *lyxrc,
bool ronly)
{
&& 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];
}
bool BufferList::QwriteAll()
{
bool askMoreConfirmation = false;
- LString unsaved;
+ string unsaved;
BufferStorage_Iter biter(bstore);
Buffer *b=0;
while ((b=biter())) {
// 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:
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()) {
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;
}
MakeDisplayPath(buf->filename));
// now delete the autosavefile
- LString a = OnlyPath(buf->filename);
+ string a = OnlyPath(buf->filename);
a += '#';
a += OnlyFilename(buf->filename);
a += '#';
} 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!"));
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++;
}
}
-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);
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.
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/"),
}
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;
}
}
}
}
-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);
}
}
// 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;
}
-bool BufferList::exists(LString const & s)
+bool BufferList::exists(string const & s)
{
BufferStorage_Iter biter(bstore);
Buffer *b=0;
}
-Buffer* BufferList::getBuffer(LString const &s)
+Buffer* BufferList::getBuffer(string const &s)
{
BufferStorage_Iter biter(bstore);
Buffer *b=0;
}
-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);
}
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)) {
}
-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?
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;
}