Lars Gullik Bjønnes wrote:
> Looks good.
Updated patch below for if someone else wants to test it (would be nice).
Tell me when you want me to commit.
Regards, Alfredo
Index: BufferView.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.C,v
retrieving revision 1.160
diff -u -p -u -r1.160 BufferView.C
--- BufferView.C 16 Jun 2003 11:49:27 -0000 1.160
+++ BufferView.C 20 Jun 2003 12:14:34 -0000
@@ -104,11 +104,17 @@ void BufferView::buffer(Buffer * b)
}
+bool BufferView::loadLyXFile(string const & fn, bool tl)
+{
+ return pimpl_->loadLyXFile(fn, tl);
+}
+
+
void BufferView::reload()
{
string const fn = buffer()->fileName();
if (bufferlist.close(buffer(), false))
- buffer(bufferlist.loadLyXFile(fn));
+ loadLyXFile(fn);
}
Index: BufferView.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.h,v
retrieving revision 1.125
diff -u -p -u -r1.125 BufferView.h
--- BufferView.h 23 May 2003 07:44:06 -0000 1.125
+++ BufferView.h 20 Jun 2003 12:14:35 -0000
@@ -81,6 +81,8 @@ public:
/// reload the contained buffer
void reload();
+ /// load a buffer into the view
+ bool loadLyXFile(string const &, bool tolastfiles = true);
/// fit the user cursor within the visible view
bool fitCursor();
Index: BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.376
diff -u -p -u -r1.376 BufferView_pimpl.C
--- BufferView_pimpl.C 17 Jun 2003 15:33:45 -0000 1.376
+++ BufferView_pimpl.C 20 Jun 2003 12:14:37 -0000
@@ -11,6 +11,7 @@
#include "BufferView_pimpl.h"
#include "bufferlist.h"
#include "buffer.h"
+#include "buffer_funcs.h"
#include "bufferview_funcs.h"
#include "lfuns.h"
#include "debug.h"
@@ -28,6 +29,7 @@
#include "lyxtext.h"
#include "lyxrc.h"
#include "lyxrow.h"
+#include "lastfiles.h"
#include "paragraph.h"
#include "ParagraphParameters.h"
#include "TextCache.h"
@@ -128,6 +130,62 @@ BufferView::Pimpl::Pimpl(BufferView * bv
}
+
+bool BufferView::Pimpl::loadLyXFile(string const & filename, bool
tolastfiles)
+{
+ // get absolute path of file and add ".lyx" to the filename if
+ // necessary
+ string s = FileSearch(string(), filename, "lyx");
+ if (s.empty()) {
+ s = filename;
+ }
+
+ // file already open?
+ if (bufferlist.exists(s)) {
+ string const file = MakeDisplayPath(s, 20);
+ string text = bformat(_("The document %1$s is already "
+ "loaded.\n\nDo you want to revert "
+ "to the saved version?"), file);
+ int const ret = Alert::prompt(_("Revert to saved document?"),
+ text, 0, 1, _("&Revert"), _("&Switch to document"));
+
+ if (ret != 0) {
+ buffer(bufferlist.getBuffer(s));
+ return true;
+ } else {
+ // FIXME: should be LFUN_REVERT
+ if (!bufferlist.close(bufferlist.getBuffer(s), false))
+ return false;
+ // Fall through to new load. (Asger)
+ }
+ }
+ Buffer * b = bufferlist.newBuffer(s);
+
+ //this is the point to attach to the error signal in the buffer
+
+ if (!::loadLyXFile(b, s)) {
+ bufferlist.release(b);
+ string text = bformat(_("The document %1$s does "
+ "not yet exist.\n\n"
+ "Do you want to create "
+ "a new document?"), s);
+ int const ret = Alert::prompt(_("Create new document?"),
+ text, 0, 1, _("&Create"), _("Cancel"));
+
+ if (ret == 0) {
+ bufferlist.close(buffer_, false);
+ buffer(newFile(s, string(), true));
+ }
+ }
+
+ buffer(b);
+
+ if (tolastfiles)
+ lastfiles->newFile(b->fileName());
+
+ return true;
+}
+
WorkArea & BufferView::Pimpl::workarea() const
{
return *workarea_.get();
@@ -286,8 +344,8 @@ int BufferView::Pimpl::resizeCurrentBuff
mark_set = bv_->text->selection.mark();
the_locking_inset = bv_->theLockingInset();
buffer_->resizeInsets(bv_);
- // I don't think the delete and new are necessary here we just could
- // call only init! (Jug 20020419)
+ // I don't think the delete and new are necessary here we
+ // just could call only init! (Jug 20020419)
delete bv_->text;
bv_->text = new LyXText(bv_);
bv_->text->init(bv_);
@@ -641,10 +699,15 @@ void BufferView::Pimpl::restorePosition(
beforeChange(bv_->text);
if (fname != buffer_->fileName()) {
- Buffer * b = bufferlist.exists(fname) ?
- bufferlist.getBuffer(fname) :
- bufferlist.loadLyXFile(fname); // don't ask, just load it
- if (b != 0) buffer(b);
+ Buffer * b;
+ if (bufferlist.exists(fname))
+ b = bufferlist.getBuffer(fname);
+ else {
+ b = bufferlist.newBuffer(fname);
+ ::loadLyXFile(b, fname); // don't ask, just load it
+ }
+ if (b != 0)
+ buffer(b);
}
ParIterator par = buffer_->getParFromID(saved_positions[i].par_id);
Index: BufferView_pimpl.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.h,v
retrieving revision 1.88
diff -u -p -u -r1.88 BufferView_pimpl.h
--- BufferView_pimpl.h 20 May 2003 16:51:28 -0000 1.88
+++ BufferView_pimpl.h 20 Jun 2003 12:14:37 -0000
@@ -54,6 +54,9 @@ struct BufferView::Pimpl : public boost:
* Repaint pixmap. Used for when we've made a visible
* change but don't need the full update() logic
*/
+ ///
+ bool loadLyXFile(string const &, bool);
+ ///
void repaint();
///
void workAreaResize();
Index: ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.1386
diff -u -p -u -r1.1386 ChangeLog
--- ChangeLog 19 Jun 2003 16:49:43 -0000 1.1386
+++ ChangeLog 20 Jun 2003 12:14:53 -0000
@@ -1,3 +1,16 @@
+
+2003-06-19 Alfredo Braunstein <[EMAIL PROTECTED]>
+
+ * bufferlist.[Ch] (loadLyXFile, readFile, newFile): removed the
+ ability to create a buffer and to return an existing one from
+ the list. Moved these functions to...
+ * buffer_funcs.[Ch]: added
+ * BufferView.[Ch] (loadLyXFile): added
+ * BufferView_pimpl.[Ch] (loadLyXFile): Added. Does the guessing
+ job removed from bufferlist::loadLyXFile.
+ * buffer.C (setReadOnly): make it work without view
+ (i.e added an if (users))
+
2003-06-19 Angus Leeming <[EMAIL PROTECTED]>
* lfuns.h:
Index: Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/Makefile.am,v
retrieving revision 1.176
diff -u -p -u -r1.176 Makefile.am
--- Makefile.am 29 May 2003 11:19:50 -0000 1.176
+++ Makefile.am 20 Jun 2003 12:14:53 -0000
@@ -105,6 +105,8 @@ lyx_SOURCES = \
broken_headers.h \
buffer.C \
buffer.h \
+ buffer_funcs.C \
+ buffer_funcs.h \
bufferlist.C \
bufferlist.h \
bufferparams.C \
Index: buffer.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v
retrieving revision 1.483
diff -u -p -u -r1.483 buffer.C
--- buffer.C 16 Jun 2003 11:49:27 -0000 1.483
+++ buffer.C 20 Jun 2003 12:14:56 -0000
@@ -206,7 +206,8 @@ void Buffer::setReadonly(bool flag)
if (read_only != flag) {
read_only = flag;
updateTitles();
- users->owner()->getDialogs().updateBufferDependent(false);
+ if (users)
+ users->owner()->getDialogs().updateBufferDependent(false);
}
}
Index: buffer_funcs.C
===================================================================
RCS file: buffer_funcs.C
diff -N buffer_funcs.C
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ buffer_funcs.C 20 Jun 2003 12:14:56 -0000
@@ -0,0 +1,196 @@
+/**
+ * \file buffer_funcs.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Lars Gullik Bjønnes
+ * \author Alfredo Braunstein
+ *
+ * Full author contact details are available in file CREDITS
+ *
+ */
+
+#include <config.h>
+
+#include "buffer_funcs.h"
+#include "bufferlist.h"
+#include "buffer.h"
+#include "gettext.h"
+#include "vc-backend.h"
+#include "lyxlex.h"
+#include "ParagraphList.h"
+#include "paragraph.h"
+
+#include "frontends/Alert.h"
+
+#include "support/filetools.h"
+#include "support/FileInfo.h"
+#include "support/lyxlib.h"
+
+
+extern BufferList bufferlist;
+
+
+namespace {
+
+bool readFile(Buffer * b, string const & s)
+{
+ string ts(s);
+ string e = OnlyPath(s);
+ string a = e;
+ // File information about normal file
+ FileInfo fileInfo(s);
+
+ if (!fileInfo.exist()) {
+ string const file = MakeDisplayPath(s, 50);
+ string text = bformat(_("The specified document\n%1$s"
+ "\ncould not be read."), file);
+ Alert::error(_("Could not read document"), text);
+ return false;
+ }
+
+ // Check if emergency save file exists and is newer.
+ e += OnlyFilename(s) + ".emergency";
+ FileInfo fileInfoE(e);
+
+ bool use_emergency = false;
+
+ if (fileInfoE.exist() && fileInfo.exist()) {
+ if (fileInfoE.getModificationTime()
+ > fileInfo.getModificationTime()) {
+ string const file = MakeDisplayPath(s, 20);
+ string text = bformat(_("An emergency save of the document %1$s
exists.\n"
+ "\nRecover emergency save?"), file);
+ int const ret = Alert::prompt(_("Load emergency save?"),
+ text, 0, 1, _("&Recover"), _("&Load Original"));
+
+ if (ret == 0) {
+ ts = e;
+ // the file is not saved if we load the
+ // emergency file.
+ b->markDirty();
+ use_emergency = true;
+ }
+ }
+ }
+
+ if (!use_emergency) {
+ // Now check if autosave file is newer.
+ a += '#';
+ a += OnlyFilename(s);
+ a += '#';
+ FileInfo fileInfoA(a);
+ if (fileInfoA.exist() && fileInfo.exist()) {
+ if (fileInfoA.getModificationTime()
+ > fileInfo.getModificationTime()) {
+ string const file = MakeDisplayPath(s, 20);
+ string text = bformat(_("The backup of the document
%1$s is newer.\n\n"
+ "Load the backup instead?"), file);
+ int const ret = Alert::prompt(_("Load backup?"),
+ text, 0, 1, _("&Load backup"), _("Load
&original"));
+
+ if (ret == 0) {
+ ts = a;
+ // the file is not saved if we load the
+ // autosave file.
+ b->markDirty();
+ } else {
+ // Here, we should delete the autosave
+ lyx::unlink(a);
+ }
+ }
+ }
+ }
+ // not sure if this is the correct place to begin LyXLex
+ LyXLex lex(0, 0);
+ lex.setFile(ts);
+
+ return b->readFile(lex, ts);
+}
+
+
+} // namespace anon
+
+
+
+bool loadLyXFile(Buffer * b, string const & s)
+{
+ switch (IsFileWriteable(s)) {
+ case 0:
+ b->setReadonly(true);
+ // Fall through
+ case 1:
+ if (readFile(b, s)) {
+ b->lyxvc.file_found_hook(s);
+ return true;
+ }
+ break;
+ case -1:
+ string const file = MakeDisplayPath(s, 20);
+ // Here we probably should run
+ if (LyXVC::file_not_found_hook(s)) {
+ string text = bformat(_("Do you want to retrieve the document"
+ " %1$s from version control?"), file);
+ int const ret = Alert::prompt(_("Retrieve from version
control?"),
+ text, 0, 1, _("&Retrieve"), _("&Cancel"));
+
+ if (ret == 0) {
+ // How can we know _how_ to do the checkout?
+ // With the current VC support it has to be,
+ // a RCS file since CVS do not have special ,v files.
+ RCS::retrieve(s);
+ return loadLyXFile(b, s);
+ }
+ }
+ break;
+ }
+ return false;
+}
+
+
+Buffer * newFile(string const & filename, string const & templatename,
+ bool isNamed)
+{
+ // get a free buffer
+ Buffer * b = bufferlist.newBuffer(filename);
+
+ string tname;
+ // use defaults.lyx as a default template if it exists.
+ if (templatename.empty())
+ tname = LibFileSearch("templates", "defaults.lyx");
+ else
+ tname = templatename;
+
+ if (!tname.empty()) {
+ bool templateok = false;
+ LyXLex lex(0, 0);
+ lex.setFile(tname);
+ if (lex.isOK()) {
+ if (b->readFile(lex, tname)) {
+ templateok = true;
+ }
+ }
+ if (!templateok) {
+ string const file = MakeDisplayPath(tname, 50);
+ string text = bformat(_("The specified document
template\n%1$s\n"
+ "could not be read."), file);
+ Alert::error(_("Could not read template"), text);
+ // no template, start with empty buffer
+ b->paragraphs.push_back(Paragraph());
+
b->paragraphs.begin()->layout(b->params.getLyXTextClass().defaultLayout());
+ }
+ } else { // start with empty buffer
+ b->paragraphs.push_back(Paragraph());
+
b->paragraphs.begin()->layout(b->params.getLyXTextClass().defaultLayout());
+ }
+
+ if (!isNamed) {
+ b->setUnnamed();
+ b->setFileName(filename);
+ }
+
+ b->setReadonly(false);
+ b->updateDocLang(b->params.language);
+
+ return b;
+}
Index: buffer_funcs.h
===================================================================
RCS file: buffer_funcs.h
diff -N buffer_funcs.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ buffer_funcs.h 20 Jun 2003 12:14:56 -0000
@@ -0,0 +1,26 @@
+// -*- C++ -*-
+/* \file buffer_funcs.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Lars Gullik Bjønnes
+ * \author Alfredo Braunstein
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#include "LString.h"
+
+class Buffer;
+
+/**
+ * Loads a LyX file \c filename into \c Buffer
+ * and \return success status.
+ */
+bool loadLyXFile(Buffer *, string const & filename);
+
+/* Make a new file (buffer) with name \c filename based on a template
+ * named \c templatename
+ */
+Buffer * newFile(string const & filename, string const & templatename,
+ bool isNamed = false);
Index: bufferlist.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferlist.C,v
retrieving revision 1.117
diff -u -p -u -r1.117 bufferlist.C
--- bufferlist.C 10 Jun 2003 14:39:42 -0000 1.117
+++ bufferlist.C 20 Jun 2003 12:14:57 -0000
@@ -306,89 +306,6 @@ void BufferList::emergencyWrite(Buffer *
}
-
-Buffer * BufferList::readFile(string const & s, bool ronly)
-{
- string ts(s);
- string e = OnlyPath(s);
- string a = e;
- // File information about normal file
- FileInfo fileInfo2(s);
-
- if (!fileInfo2.exist()) {
- string const file = MakeDisplayPath(s, 50);
- string text = bformat(_("The specified document\n%1$s"
- "\ncould not be read."), file);
- Alert::error(_("Could not read document"), text);
- return 0;
- }
-
- Buffer * b = newBuffer(s, ronly);
-
- // Check if emergency save file exists and is newer.
- e += OnlyFilename(s) + ".emergency";
- FileInfo fileInfoE(e);
-
- bool use_emergency = false;
-
- if (fileInfoE.exist() && fileInfo2.exist()) {
- if (fileInfoE.getModificationTime()
- > fileInfo2.getModificationTime()) {
- string const file = MakeDisplayPath(s, 20);
- string text = bformat(_("An emergency save of the document %1$s
exists.\n"
- "\nRecover emergency save?"), file);
- int const ret = Alert::prompt(_("Load emergency save?"),
- text, 0, 1, _("&Recover"), _("&Load Original"));
-
- if (ret == 0) {
- ts = e;
- // the file is not saved if we load the
- // emergency file.
- b->markDirty();
- use_emergency = true;
- }
- }
- }
-
- if (!use_emergency) {
- // Now check if autosave file is newer.
- a += '#';
- a += OnlyFilename(s);
- a += '#';
- FileInfo fileInfoA(a);
- if (fileInfoA.exist() && fileInfo2.exist()) {
- if (fileInfoA.getModificationTime()
- > fileInfo2.getModificationTime()) {
- string const file = MakeDisplayPath(s, 20);
- string text = bformat(_("The backup of the document
%1$s is newer.\n\n"
- "Load the backup instead?"), file);
- int const ret = Alert::prompt(_("Load backup?"),
- text, 0, 1, _("&Load backup"), _("Load
&original"));
-
- if (ret == 0) {
- ts = a;
- // the file is not saved if we load the
- // autosave file.
- b->markDirty();
- } else {
- // Here, we should delete the autosave
- lyx::unlink(a);
- }
- }
- }
- }
- // not sure if this is the correct place to begin LyXLex
- LyXLex lex(0, 0);
- lex.setFile(ts);
- if (b->readFile(lex, ts))
- return b;
- else {
- release(b);
- return 0;
- }
-}
-
-
bool BufferList::exists(string const & s) const
{
return find_if(bstore.begin(), bstore.end(),
@@ -413,129 +330,6 @@ Buffer * BufferList::getBuffer(string co
find_if(bstore.begin(), bstore.end(),
lyx::compare_memfun(&Buffer::fileName, s));
return it != bstore.end() ? (*it) : 0;
-}
-
-
-Buffer * BufferList::newFile(string const & name, string tname, bool
isNamed)
-{
- // get a free buffer
- Buffer * b = newBuffer(name);
-
- // use defaults.lyx as a default template if it exists.
- if (tname.empty()) {
- tname = LibFileSearch("templates", "defaults.lyx");
- }
- if (!tname.empty()) {
- bool templateok = false;
- LyXLex lex(0, 0);
- lex.setFile(tname);
- if (lex.isOK()) {
- if (b->readFile(lex, tname)) {
- templateok = true;
- }
- }
- if (!templateok) {
- string const file = MakeDisplayPath(tname, 50);
- string text = bformat(_("The specified document
template\n%1$s\n"
- "could not be read."), file);
- Alert::error(_("Could not read template"), text);
- // no template, start with empty buffer
- b->paragraphs.push_back(Paragraph());
-
b->paragraphs.begin()->layout(b->params.getLyXTextClass().defaultLayout());
- }
- } else { // start with empty buffer
- b->paragraphs.push_back(Paragraph());
-
b->paragraphs.begin()->layout(b->params.getLyXTextClass().defaultLayout());
- }
-
- if (!isNamed) {
- b->setUnnamed();
- b->setFileName(name);
- }
-
- b->setReadonly(false);
- b->updateDocLang(b->params.language);
-
- return b;
-}
-
-
-Buffer * BufferList::loadLyXFile(string const & filename, bool tolastfiles)
-{
- // get absolute path of file and add ".lyx" to the filename if
- // necessary
- string s = FileSearch(string(), filename, "lyx");
- if (s.empty()) {
- s = filename;
- }
-
- // file already open?
- if (exists(s)) {
- string const file = MakeDisplayPath(s, 20);
- string text = bformat(_("The document %1$s is already loaded.\n\n"
- "Do you want to revert to the saved version?"), file);
- int const ret = Alert::prompt(_("Revert to saved document?"),
- text, 0, 1, _("&Revert"), _("&Switch to document"));
-
- if (ret == 0) {
- // FIXME: should be LFUN_REVERT
- if (!close(getBuffer(s), false)) {
- return 0;
- }
- // Fall through to new load. (Asger)
- } else {
- // Here, we pretend that we just loaded the
- // open document
- return getBuffer(s);
- }
- }
-
- Buffer * b = 0;
- bool ro = false;
- switch (IsFileWriteable(s)) {
- case 0:
- ro = true;
- // Fall through
- case 1:
- b = readFile(s, ro);
- if (b) {
- b->lyxvc.file_found_hook(s);
- }
- break; //fine- it's r/w
- case -1: {
- string const file = MakeDisplayPath(s, 20);
- // Here we probably should run
- if (LyXVC::file_not_found_hook(s)) {
- string text = bformat(_("Do you want to retrieve the document"
- " %1$s from version control?"), file);
- int const ret = Alert::prompt(_("Retrieve from version
control?"),
- text, 0, 1, _("&Retrieve"), _("&Cancel"));
-
- if (ret == 0) {
- // How can we know _how_ to do the checkout?
- // With the current VC support it has to be,
- // a RCS file since CVS do not have special ,v files.
- RCS::retrieve(s);
- return loadLyXFile(filename, tolastfiles);
- }
- }
-
- string text = bformat(_("The document %1$s does not yet exist.\n\n"
- "Do you want to create a new document?"), file);
- int const ret = Alert::prompt(_("Create new document?"),
- text, 0, 1, _("&Create"), _("Cancel"));
-
- if (ret == 0)
- b = newFile(s, string(), true);
-
- break;
- }
- }
-
- if (b && tolastfiles)
- lastfiles->newFile(b->fileName());
-
- return b;
}
Index: bufferlist.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferlist.h,v
retrieving revision 1.39
diff -u -p -u -r1.39 bufferlist.h
--- bufferlist.h 22 May 2003 18:58:55 -0000 1.39
+++ bufferlist.h 20 Jun 2003 12:14:57 -0000
@@ -29,17 +29,6 @@ class BufferList : boost::noncopyable {
public:
BufferList();
- /**
- Loads a LyX file or...
-
- \param filename The filename to read from.
- \param tolastfiles Wether the file should be put in the
- last opened files list or not.
- \return The newly loaded LyX file.
- */
- Buffer * loadLyXFile(string const & filename,
- bool tolastfiles = true);
-
/// write all buffers, asking the user, returns false if cancelled
bool quitWriteAll();
@@ -52,11 +41,6 @@ public:
/// Close all open buffers.
void closeAll();
- /// read the given file
- Buffer * readFile(string const &, bool ro);
-
- /// Make a new file (buffer) using a template
- Buffer * newFile(string const &, string, bool isNamed = false);
/// returns a vector with all the buffers filenames
std::vector<string> const getFileNames() const;
Index: importer.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/importer.C,v
retrieving revision 1.27
diff -u -p -u -r1.27 importer.C
--- importer.C 13 May 2003 09:48:42 -0000 1.27
+++ importer.C 20 Jun 2003 12:14:57 -0000
@@ -18,6 +18,7 @@
#include "funcrequest.h"
#include "bufferlist.h"
+#include "buffer_funcs.h"
#include "support/filetools.h"
#include "frontends/Alert.h"
#include "gettext.h"
@@ -65,11 +66,9 @@ bool Importer::Import(LyXView * lv, stri
if (loader_format == "lyx") {
- Buffer * buffer = bufferlist.loadLyXFile(lyxfile);
- if (buffer)
- lv->view()->buffer(buffer);
+ lv->view()->loadLyXFile(lyxfile);
} else {
- lv->view()->buffer(bufferlist.newFile(lyxfile, string(), true));
+ lv->view()->buffer(newFile(lyxfile, string(), true));
bool as_paragraphs = loader_format == "textparagraph";
string filename2 = (loader_format == format) ? filename
: ChangeExtension(filename,
Index: lyx_cb.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_cb.C,v
retrieving revision 1.207
diff -u -p -u -r1.207 lyx_cb.C
--- lyx_cb.C 10 Jun 2003 14:39:42 -0000 1.207
+++ lyx_cb.C 20 Jun 2003 12:14:58 -0000
@@ -13,6 +13,7 @@
#include "lyx_cb.h"
#include "lyx_main.h"
#include "buffer.h"
+#include "buffer_funcs.h"
#include "bufferlist.h"
#include "bufferview_funcs.h"
#include "debug.h"
@@ -326,7 +327,7 @@ Buffer * NewFile(string const & filename
<< "\nTemplate is " << tmpname << endl;
// find a free buffer
- Buffer * tmpbuf = bufferlist.newFile(name, tmpname);
+ Buffer * tmpbuf = newFile(name, tmpname);
if (tmpbuf)
lastfiles->newFile(tmpbuf->fileName());
return tmpbuf;
Index: lyx_main.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_main.C,v
retrieving revision 1.148
diff -u -p -u -r1.148 lyx_main.C
--- lyx_main.C 11 Jun 2003 19:21:46 -0000 1.148
+++ lyx_main.C 20 Jun 2003 12:14:59 -0000
@@ -24,6 +24,7 @@
#include "bufferlist.h"
#include "buffer.h"
+#include "buffer_funcs.h"
#include "lyxserver.h"
#include "kbmap.h"
#include "lyxfunc.h"
@@ -142,14 +143,16 @@ LyX::LyX(int & argc, char * argv[])
vector<string>::iterator it = files.begin();
vector<string>::iterator end = files.end();
for (; it != end; ++it) {
- last_loaded = bufferlist.loadLyXFile(*it);
+ last_loaded = bufferlist.newBuffer(*it, false);
+ loadLyXFile(last_loaded, *it);
}
files.clear();
// no buffer loaded, create one
+ string const tmpfile = "tmpfile";
if (!last_loaded)
- last_loaded = bufferlist.newFile("tmpfile", string());
+ last_loaded = newFile(tmpfile, string());
bool success = false;
Index: lyxfunc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v
retrieving revision 1.455
diff -u -p -u -r1.455 lyxfunc.C
--- lyxfunc.C 19 Jun 2003 16:49:44 -0000 1.455
+++ lyxfunc.C 20 Jun 2003 12:15:01 -0000
@@ -16,6 +16,7 @@
#include "lyxrow.h"
#include "bufferlist.h"
#include "buffer.h"
+#include "buffer_funcs.h"
#include "BufferView.h"
#include "lyxserver.h"
#include "intl.h"
@@ -1195,7 +1196,7 @@ void LyXFunc::dispatch(FuncRequest const
}
owner->message(bformat(_("Opening help file %1$s..."),
MakeDisplayPath(fname)));
- view()->buffer(bufferlist.loadLyXFile(fname, false));
+ view()->loadLyXFile(fname, false);
break;
}
@@ -1307,7 +1308,7 @@ void LyXFunc::dispatch(FuncRequest const
if (bufferlist.exists(s)) {
view()->buffer(bufferlist.getBuffer(s));
} else {
- view()->buffer(bufferlist.loadLyXFile(s));
+ view()->loadLyXFile(s);
}
view()->setCursorFromRow(row);
@@ -1455,7 +1456,7 @@ void LyXFunc::dispatch(FuncRequest const
if (bufferlist.exists(filename))
view()->buffer(bufferlist.getBuffer(filename));
else
- view()->buffer(bufferlist.loadLyXFile(filename));
+ view()->loadLyXFile(filename);
}
break;
@@ -1714,7 +1715,7 @@ void LyXFunc::menuNew(string const & nam
templname = fname;
}
- view()->buffer(bufferlist.newFile(filename, templname, !name.empty()));
+ view()->buffer(newFile(filename, templname, !name.empty()));
}
@@ -1769,17 +1770,15 @@ void LyXFunc::open(string const & fname)
FileInfo const f(filename, true);
if (!f.exist()) {
// the user specifically chose this name. Believe them.
- Buffer * buffer = bufferlist.newFile(filename, "", true);
+ Buffer * buffer = newFile(filename, "", true);
view()->buffer(buffer);
return;
}
owner->message(bformat(_("Opening document %1$s..."), disp_fn));
- Buffer * openbuf = bufferlist.loadLyXFile(filename);
string str2;
- if (openbuf) {
- view()->buffer(openbuf);
+ if (view()->loadLyXFile(filename)) {
str2 = bformat(_("Document %1$s opened."), disp_fn);
} else {
str2 = bformat(_("Could not open document %1$s"), disp_fn);
Index: frontends/qt2/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/ChangeLog,v
retrieving revision 1.530
diff -u -p -u -r1.530 ChangeLog
--- frontends/qt2/ChangeLog 19 Jun 2003 17:16:11 -0000 1.530
+++ frontends/qt2/ChangeLog 20 Jun 2003 12:15:07 -0000
@@ -1,3 +1,9 @@
+
+2003-06-19 Alfredo Braunstein <[EMAIL PROTECTED]>
+
+ * lyx_gui.C (start): call ::loadLyXFile instead
+ of BufferList::loadLyXFile
+
2003-06-19 Angus Leeming <[EMAIL PROTECTED]>
* Dialogs.C:
Index: frontends/qt2/lyx_gui.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/lyx_gui.C,v
retrieving revision 1.41
diff -u -p -u -r1.41 lyx_gui.C
--- frontends/qt2/lyx_gui.C 19 Jun 2003 16:49:44 -0000 1.41
+++ frontends/qt2/lyx_gui.C 20 Jun 2003 12:15:07 -0000
@@ -28,6 +28,7 @@
// FIXME: move this stuff out again
#include "bufferlist.h"
+#include "buffer_funcs.h"
#include "lyxfunc.h"
#include "lyxserver.h"
#include "BufferView.h"
@@ -153,10 +154,9 @@ void start(string const & batch, vector<
vector<string>::const_iterator cit = files.begin();
vector<string>::const_iterator end = files.end();
for (; cit != end; ++cit) {
- Buffer * b = bufferlist.loadLyXFile(*cit);
- if (b) {
+ Buffer * b = bufferlist.newBuffer(*cit);
+ if (loadLyXFile(b, *cit))
last = b;
- }
}
// switch to the last buffer successfully loaded
Index: frontends/xforms/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/ChangeLog,v
retrieving revision 1.770
diff -u -p -u -r1.770 ChangeLog
--- frontends/xforms/ChangeLog 19 Jun 2003 17:16:12 -0000 1.770
+++ frontends/xforms/ChangeLog 20 Jun 2003 12:15:16 -0000
@@ -1,3 +1,8 @@
+2003-06-19 Alfredo Braunstein <[EMAIL PROTECTED]>
+
+ * lyx_gui.C (start): call ::loadLyXFile instead
+ of BufferList::loadLyXFile
+
2003-06-19 Angus Leeming <[EMAIL PROTECTED]>
* Dialogs.C:
Index: frontends/xforms/lyx_gui.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/lyx_gui.C,v
retrieving revision 1.36
diff -u -p -u -r1.36 lyx_gui.C
--- frontends/xforms/lyx_gui.C 3 Jun 2003 19:32:08 -0000 1.36
+++ frontends/xforms/lyx_gui.C 20 Jun 2003 12:15:17 -0000
@@ -27,6 +27,7 @@
// FIXME: move this stuff out again
#include "bufferlist.h"
+#include "buffer_funcs.h"
#include "lyxfunc.h"
#include "lyxserver.h"
#include "BufferView.h"
@@ -285,10 +286,9 @@ void start(string const & batch, vector<
vector<string>::const_iterator cit = files.begin();
vector<string>::const_iterator end = files.end();
for (; cit != end; ++cit) {
- Buffer * b = bufferlist.loadLyXFile(*cit);
- if (b) {
+ Buffer * b = bufferlist.newBuffer(*cit);
+ if (loadLyXFile(b, *cit))
last = b;
- }
}
// switch to the last buffer successfully loaded
Index: insets/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v
retrieving revision 1.723
diff -u -p -u -r1.723 ChangeLog
--- insets/ChangeLog 18 Jun 2003 17:43:48 -0000 1.723
+++ insets/ChangeLog 20 Jun 2003 12:15:25 -0000
@@ -1,3 +1,8 @@
+2003-06-19 Alfredo Braunstein <[EMAIL PROTECTED]>
+
+ * insetinclude.C (loadIfNeeded): call ::loadLyXFile instead
+ of BufferList::loadLyXFile
+
2003-06-18 Lars Gullik Bjnnes <[EMAIL PROTECTED]>
* insettext.C (update): simplify
Index: insets/insetinclude.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetinclude.C,v
retrieving revision 1.124
diff -u -p -u -r1.124 insetinclude.C
--- insets/insetinclude.C 16 Jun 2003 11:49:31 -0000 1.124
+++ insets/insetinclude.C 20 Jun 2003 12:15:26 -0000
@@ -12,6 +12,7 @@
#include "insetinclude.h"
#include "buffer.h"
+#include "buffer_funcs.h"
#include "bufferlist.h"
#include "BufferView.h"
#include "debug.h"
@@ -293,8 +294,8 @@ bool InsetInclude::loadIfNeeded() const
FileInfo finfo(getFileName());
if (!finfo.isOK())
return false;
-
- return bufferlist.loadLyXFile(getFileName(), false) != 0;
+ return loadLyXFile(bufferlist.newBuffer(getFileName()),
+ getFileName());
}