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 << "...";