mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-05 13:26:21 +00:00
take several functions out of BufferList, and split functionality
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7195 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
87f831b8ba
commit
2d8eb4b9d4
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -81,6 +81,8 @@ public:
|
||||
|
||||
/// reload the contained buffer
|
||||
void reload();
|
||||
/// load a buffer into the view
|
||||
bool loadLyXFile(string const & name, bool tolastfiles = true);
|
||||
|
||||
/// fit the user cursor within the visible view
|
||||
bool fitCursor();
|
||||
|
@ -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, LyXView * owner,
|
||||
}
|
||||
|
||||
|
||||
|
||||
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::resizeCurrentBuffer()
|
||||
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(unsigned int i)
|
||||
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);
|
||||
|
@ -54,6 +54,9 @@ struct BufferView::Pimpl : public boost::signals::trackable {
|
||||
* 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();
|
||||
|
@ -1,3 +1,16 @@
|
||||
|
||||
2003-06-19 Alfredo Braunstein <abraunst@libero.it>
|
||||
|
||||
* 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 <leeming@lyx.org>
|
||||
|
||||
* lfuns.h:
|
||||
|
@ -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 \
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
196
src/buffer_funcs.C
Normal file
196
src/buffer_funcs.C
Normal file
@ -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;
|
||||
}
|
26
src/buffer_funcs.h
Normal file
26
src/buffer_funcs.h
Normal file
@ -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);
|
206
src/bufferlist.C
206
src/bufferlist.C
@ -306,89 +306,6 @@ void BufferList::emergencyWrite(Buffer * buf)
|
||||
}
|
||||
|
||||
|
||||
|
||||
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(),
|
||||
@ -416,129 +333,6 @@ Buffer * BufferList::getBuffer(string const & s)
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
void BufferList::setCurrentAuthor(string const & name, string const & email)
|
||||
{
|
||||
BufferStorage::iterator it = bstore.begin();
|
||||
|
@ -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;
|
||||
|
||||
|
@ -1,3 +1,9 @@
|
||||
|
||||
2003-06-19 Alfredo Braunstein <abraunst@libero.it>
|
||||
|
||||
* lyx_gui.C (start): call ::loadLyXFile instead
|
||||
of BufferList::loadLyXFile
|
||||
|
||||
2003-06-19 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* Dialogs.C:
|
||||
|
@ -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<string> const & files)
|
||||
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
|
||||
|
@ -1,3 +1,8 @@
|
||||
2003-06-19 Alfredo Braunstein <abraunst@libero.it>
|
||||
|
||||
* lyx_gui.C (start): call ::loadLyXFile instead
|
||||
of BufferList::loadLyXFile
|
||||
|
||||
2003-06-19 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* Dialogs.C:
|
||||
|
@ -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<string> const & files)
|
||||
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
|
||||
|
@ -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, string const & filename,
|
||||
|
||||
|
||||
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,
|
||||
|
@ -1,3 +1,8 @@
|
||||
2003-06-19 Alfredo Braunstein <abraunst@libero.it>
|
||||
|
||||
* insetinclude.C (loadIfNeeded): call ::loadLyXFile instead
|
||||
of BufferList::loadLyXFile
|
||||
|
||||
2003-06-18 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||
|
||||
* insettext.C (update): simplify
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 & ev, bool verbose)
|
||||
}
|
||||
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 & ev, bool verbose)
|
||||
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 & ev, bool verbose)
|
||||
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 & name, bool fromTemplate)
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user