mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
Fix to Bug 1287 and Bug 1297
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7443 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
93ea6f14a0
commit
5fb7795b10
@ -188,9 +188,11 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
|
|||||||
// get absolute path of file and add ".lyx" to the filename if
|
// get absolute path of file and add ".lyx" to the filename if
|
||||||
// necessary
|
// necessary
|
||||||
string s = FileSearch(string(), filename, "lyx");
|
string s = FileSearch(string(), filename, "lyx");
|
||||||
if (s.empty()) {
|
|
||||||
|
bool const found = !s.empty();
|
||||||
|
|
||||||
|
if (!found)
|
||||||
s = filename;
|
s = filename;
|
||||||
}
|
|
||||||
|
|
||||||
// file already open?
|
// file already open?
|
||||||
if (bufferlist.exists(s)) {
|
if (bufferlist.exists(s)) {
|
||||||
@ -211,29 +213,35 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
|
|||||||
// Fall through to new load. (Asger)
|
// Fall through to new load. (Asger)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Buffer * b = bufferlist.newBuffer(s);
|
|
||||||
|
|
||||||
connectBuffer(*b);
|
Buffer * b;
|
||||||
|
|
||||||
if (! ::loadLyXFile(b, s)) {
|
if (found) {
|
||||||
bufferlist.release(b);
|
b = bufferlist.newBuffer(s);
|
||||||
|
connectBuffer(*b);
|
||||||
|
if (!::loadLyXFile(b, s)) {
|
||||||
|
bufferlist.release(b);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
string text = bformat(_("The document %1$s does not yet "
|
string text = bformat(_("The document %1$s does not yet "
|
||||||
"exist.\n\nDo you want to create "
|
"exist.\n\nDo you want to create "
|
||||||
"a new document?"), s);
|
"a new document?"), s);
|
||||||
int const ret = Alert::prompt(_("Create new document?"),
|
int const ret = Alert::prompt(_("Create new document?"),
|
||||||
text, 0, 1, _("&Create"), _("Cancel"));
|
text, 0, 1, _("&Create"), _("Cancel"));
|
||||||
|
|
||||||
if (ret != 0)
|
if (ret == 0)
|
||||||
|
b = ::newFile(s, string(), true);
|
||||||
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer(b);
|
buffer(b);
|
||||||
|
bv_->showErrorList(_("Parse"));
|
||||||
|
|
||||||
if (tolastfiles)
|
if (tolastfiles)
|
||||||
lastfiles->newFile(b->fileName());
|
lastfiles->newFile(b->fileName());
|
||||||
|
|
||||||
bv_->showErrorList(_("Parse"));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,18 +289,16 @@ void BufferView::Pimpl::buffer(Buffer * b)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// if we are closing the buffer, use the first buffer as current
|
// if we are closing the buffer, use the first buffer as current
|
||||||
if (!buffer_) {
|
if (!buffer_)
|
||||||
buffer_ = bufferlist.first();
|
buffer_ = bufferlist.first();
|
||||||
}
|
|
||||||
|
|
||||||
if (buffer_) {
|
if (buffer_) {
|
||||||
lyxerr[Debug::INFO] << "Buffer addr: " << buffer_ << endl;
|
lyxerr[Debug::INFO] << "Buffer addr: " << buffer_ << endl;
|
||||||
connectBuffer(*buffer_);
|
connectBuffer(*buffer_);
|
||||||
|
|
||||||
// If we don't have a text object for this, we make one
|
// If we don't have a text object for this, we make one
|
||||||
if (bv_->text == 0) {
|
if (bv_->text == 0)
|
||||||
resizeCurrentBuffer();
|
resizeCurrentBuffer();
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: needed when ?
|
// FIXME: needed when ?
|
||||||
bv_->text->top_y(screen().topCursorVisible(bv_->text));
|
bv_->text->top_y(screen().topCursorVisible(bv_->text));
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
2003-07-29 Alfredo Braunstein <abraunst@libero.it>
|
||||||
|
|
||||||
|
* lyx_main.C (LyX):
|
||||||
|
* BufferView_pimpl.C (loadLyXFile): fix to bugs 1287 and 1297 + ws
|
||||||
|
|
||||||
|
|
||||||
2003-07-29 Martin Vermeer <martin.vermeer@hut.fi>
|
2003-07-29 Martin Vermeer <martin.vermeer@hut.fi>
|
||||||
|
|
||||||
* LaTeXFeatures.C:
|
* LaTeXFeatures.C:
|
||||||
|
@ -163,8 +163,7 @@ Buffer * newFile(string const & filename, string const & templatename,
|
|||||||
if (!tname.empty()) {
|
if (!tname.empty()) {
|
||||||
if (!b->readFile(tname)) {
|
if (!b->readFile(tname)) {
|
||||||
string const file = MakeDisplayPath(tname, 50);
|
string const file = MakeDisplayPath(tname, 50);
|
||||||
string const text = bformat(_("The specified document template\n%1$s\n"
|
string const text = bformat(_("The specified document template\n%1$s\ncould not be read."), file);
|
||||||
"could not be read."), file);
|
|
||||||
Alert::error(_("Could not read template"), text);
|
Alert::error(_("Could not read template"), text);
|
||||||
// no template, start with empty buffer
|
// no template, start with empty buffer
|
||||||
b->paragraphs.push_back(Paragraph());
|
b->paragraphs.push_back(Paragraph());
|
||||||
|
@ -290,9 +290,8 @@ void start(string const & batch, vector<string> const & files)
|
|||||||
view.view()->loadLyXFile(*cit, true);
|
view.view()->loadLyXFile(*cit, true);
|
||||||
|
|
||||||
// handle the batch commands the user asked for
|
// handle the batch commands the user asked for
|
||||||
if (!batch.empty()) {
|
if (!batch.empty())
|
||||||
view.getLyXFunc().dispatch(batch);
|
view.getLyXFunc().dispatch(batch);
|
||||||
}
|
|
||||||
|
|
||||||
// enter the event loop
|
// enter the event loop
|
||||||
while (!finished) {
|
while (!finished) {
|
||||||
|
@ -59,7 +59,6 @@ using std::signal;
|
|||||||
using std::system;
|
using std::system;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void LoadLyXFile(string const &);
|
|
||||||
extern void QuitLyX();
|
extern void QuitLyX();
|
||||||
|
|
||||||
extern LyXServer * lyxserver;
|
extern LyXServer * lyxserver;
|
||||||
@ -97,9 +96,8 @@ LyX::LyX(int & argc, char * argv[])
|
|||||||
// #include "graphics/GraphicsTypes.h" at the top -- Rob Lahaye.
|
// #include "graphics/GraphicsTypes.h" at the top -- Rob Lahaye.
|
||||||
lyx::graphics::setDisplayTranslator();
|
lyx::graphics::setDisplayTranslator();
|
||||||
|
|
||||||
if (want_gui) {
|
if (want_gui)
|
||||||
lyx_gui::parse_init(argc, argv);
|
lyx_gui::parse_init(argc, argv);
|
||||||
}
|
|
||||||
|
|
||||||
// check for any spurious extra arguments
|
// check for any spurious extra arguments
|
||||||
// other than documents
|
// other than documents
|
||||||
@ -116,15 +114,13 @@ LyX::LyX(int & argc, char * argv[])
|
|||||||
init(want_gui);
|
init(want_gui);
|
||||||
lyxerr[Debug::INIT] << "Initializing LyX::init...done" << endl;
|
lyxerr[Debug::INIT] << "Initializing LyX::init...done" << endl;
|
||||||
|
|
||||||
if (want_gui) {
|
if (want_gui)
|
||||||
lyx_gui::parse_lyxrc();
|
lyx_gui::parse_lyxrc();
|
||||||
}
|
|
||||||
|
|
||||||
vector<string> files;
|
vector<string> files;
|
||||||
|
|
||||||
for (int argi = argc - 1; argi >= 1; --argi) {
|
for (int argi = argc - 1; argi >= 1; --argi)
|
||||||
files.push_back(argv[argi]);
|
files.push_back(argv[argi]);
|
||||||
}
|
|
||||||
|
|
||||||
if (first_start)
|
if (first_start)
|
||||||
files.push_back(i18nLibFileSearch("examples", "splash.lyx"));
|
files.push_back(i18nLibFileSearch("examples", "splash.lyx"));
|
||||||
@ -145,14 +141,14 @@ LyX::LyX(int & argc, char * argv[])
|
|||||||
// the filename if necessary
|
// the filename if necessary
|
||||||
string s = FileSearch(string(), *it, "lyx");
|
string s = FileSearch(string(), *it, "lyx");
|
||||||
if (s.empty()) {
|
if (s.empty()) {
|
||||||
last_loaded = newFile(*it, "");
|
last_loaded = newFile(*it, string(), true);
|
||||||
} else {
|
} else {
|
||||||
last_loaded = bufferlist.newBuffer(s, false);
|
Buffer * buf = bufferlist.newBuffer(s, false);
|
||||||
last_loaded->error.connect(boost::bind(&LyX::printError, this, _1));
|
buf->error.connect(boost::bind(&LyX::printError, this, _1));
|
||||||
if (!loadLyXFile(last_loaded, s)) {
|
if (loadLyXFile(buf, s))
|
||||||
bufferlist.release(last_loaded);
|
last_loaded = buf;
|
||||||
last_loaded = newFile(*it, string());
|
else
|
||||||
}
|
bufferlist.release(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user