From 2f4db2b6ccf10dc188706b68c75accee751f7575 Mon Sep 17 00:00:00 2001 From: John Levon Date: Thu, 1 Aug 2002 19:28:57 +0000 Subject: [PATCH] allow user to open non-existent file again git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH-1_2_X@4831 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 4 ++++ src/lyxfunc.C | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 23d065ea4f..ef5444ca24 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2002-08-01 John Levon + + * lyxfunc.C: let user specify a non-existent file on open + 2002-07-26 Juergen Vigna * lyxfunc.C (dispatch):change LyXFind function call. diff --git a/src/lyxfunc.C b/src/lyxfunc.C index a3e99e030f..11bd016cd4 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -1887,16 +1887,26 @@ void LyXFunc::open(string const & fname) // get absolute path of file and add ".lyx" to the filename if // necessary string const fullpath = FileSearch(string(), filename, "lyx"); - if (fullpath.empty()) { - Alert::alert(_("Error"), _("Could not find file"), filename); - return; + if (!fullpath.empty()) { + filename = fullpath; } - filename = fullpath; - - // loads document string const disp_fn(MakeDisplayPath(filename)); + // if the file doesn't exist, let the user create one + FileInfo const f(filename, true); + if (!f.exist()) { + if (!Alert::askQuestion(_("No such file"), disp_fn, + _("Start a new document with this filename ?"))) { + owner->message(_("Canceled")); + return; + } + // the user specifically chose this name. Believe them. + Buffer * buffer = bufferlist.newFile(filename, "", true); + owner->view()->buffer(buffer); + return; + } + ostringstream str; str << _("Opening document") << ' ' << disp_fn << "...";