X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLyXFunc.cpp;h=27f558a5fbb4cfff95810d829d61f6356ced4813;hb=608603a31d6ae4e3d08ae4e9c18a11d9e705dcf4;hp=cc3bae867eee18c7ddd8f95618545c34dcc007ff;hpb=36481c274467f5e64cdef6f735592c13da649a41;p=lyx.git diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index cc3bae867e..27f558a5fb 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -1073,10 +1073,10 @@ void LyXFunc::dispatch(FuncRequest const & cmd) if (fs::exists(filename.toFilesystemEncoding())) { docstring text = bformat( _("The file %1$s already exists.\n\n" - "Do you want to over-write that file?"), + "Do you want to overwrite that file?"), makeDisplayPath(filename.absFilename())); - if (Alert::prompt(_("Over-write file?"), - text, 0, 1, _("&Over-write"), _("&Cancel")) != 0) + if (Alert::prompt(_("Overwrite file?"), + text, 0, 1, _("&Overwrite"), _("&Cancel")) != 0) break; } command += lyxrc.print_to_file @@ -1410,23 +1410,34 @@ void LyXFunc::dispatch(FuncRequest const & cmd) } case LFUN_BUFFER_CHILD_OPEN: { + // takes an optional argument, "|bool", at the end + // indicating whether this file is being opened automatically + // by LyX itself, in which case we will not want to switch + // buffers after opening. The default is false, so in practice + // it is used only when true. BOOST_ASSERT(lyx_view_); - FileName const filename = + int const arglength = argument.length(); + FileName filename; + bool autoOpen = false; + if (argument.substr(arglength - 5, 5) == "|true") { + autoOpen = true; + filename = makeAbsPath(argument.substr(0, arglength - 5), + lyx_view_->buffer()->filePath()); + } else if (argument.substr(arglength - 6, 6) == "|false") { + filename = makeAbsPath(argument.substr(0, arglength - 6), + lyx_view_->buffer()->filePath()); + } else filename = makeAbsPath(argument, lyx_view_->buffer()->filePath()); view()->saveBookmark(false); - string const parentfilename = lyx_view_->buffer()->fileName(); - if (theBufferList().exists(filename.absFilename())) - lyx_view_->setBuffer(theBufferList().getBuffer(filename.absFilename())); - else - if (lyx_view_->loadLyXFile(filename)) { - // Set the parent name of the child document. - // This makes insertion of citations and references in the child work, - // when the target is in the parent or another child document. - lyx_view_->buffer()->setParentName(parentfilename); - setMessage(bformat(_("Opening child document %1$s..."), - makeDisplayPath(filename.absFilename()))); - } else - setMessage(_("Document not loaded.")); + if (theBufferList().exists(filename.absFilename())) { + Buffer * buf = theBufferList().getBuffer(filename.absFilename()); + if (!autoOpen) + lyx_view_->setBuffer(buf, true); + else + buf->setParentName(lyx_view_->buffer()->fileName()); + } else + lyx_view_->loadLyXFile(filename, true, true, autoOpen); + break; } @@ -2057,9 +2068,9 @@ void LyXFunc::doImport(string const & argument) docstring const file = makeDisplayPath(lyxfile.absFilename(), 30); docstring text = bformat(_("The document %1$s already exists.\n\n" - "Do you want to over-write that document?"), file); - int const ret = Alert::prompt(_("Over-write document?"), - text, 0, 1, _("&Over-write"), _("&Cancel")); + "Do you want to overwrite that document?"), file); + int const ret = Alert::prompt(_("Overwrite document?"), + text, 0, 1, _("&Overwrite"), _("&Cancel")); if (ret == 1) { lyx_view_->message(_("Canceled.")); @@ -2078,16 +2089,8 @@ void LyXFunc::closeBuffer() // goto bookmark to update bookmark pit. for (size_t i = 0; i < LyX::ref().session().bookmarks().size(); ++i) gotoBookmark(i+1, false, false); - if (theBufferList().close(lyx_view_->buffer(), true) && !quitting) { - if (theBufferList().empty()) { - // need this otherwise SEGV may occur while - // trying to set variables that don't exist - // since there's no current buffer - lyx_view_->getDialogs().hideBufferDependent(); - } else { - lyx_view_->setBuffer(theBufferList().first()); - } - } + + theBufferList().close(lyx_view_->buffer(), true); }