Added new lyxrc tag new_ask_filename for New... behaviour and fixed errors

with automatically assigned filename.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@959 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2000-08-08 11:08:07 +00:00
parent c39bf82c2f
commit e8c2cd02e3
6 changed files with 81 additions and 59 deletions

View File

@ -1,3 +1,10 @@
2000-08-08 Juergen Vigna <jug@sad.it>
* src/bufferlist.C (newFile):
* src/lyxfunc.C (MenuNew): use the new_ask_filename tag from lyxrc.
* src/lyxrc.C: added new_ask_filename tag
2000-08-07 Baruch Even <baruch.even@writeme.com>
* src/graphics/Renderer.h:

View File

@ -83,6 +83,11 @@
# We recommend to keep the confirmation, though.
#\exit_confirmation false
# This sets the behaviour if you want to be asked for a filename when
# creating a new document or wait until you save it and be asked then.
# The default for now is ask on save.
# \new_ask_filename false
# LyX continously displays names of last command executed, along with a list
# of defined short-cuts for it in the minibuffer.
# It requires some horsepower to function, so you can turn it off, if LyX

View File

@ -453,12 +453,11 @@ Buffer * BufferList::newFile(string const & name, string tname)
b->paragraph = new LyXParagraph;
}
#ifdef NEW_WITH_FILENAME
b->markDirty();
#else
#warning Why mark a new document dirty? I deactivate this for unnamed docs! (Jug)
b->setUnnamed();
#endif
#warning Why mark a new document dirty? I deactivate this (Jug)
if (!lyxrc.new_ask_filename) {
// b->markDirty();
b->setUnnamed();
}
b->setReadonly(false);
return b;

View File

@ -2962,32 +2962,35 @@ void LyXFunc::MenuNew(bool fromTemplate)
initpath = trypath;
}
#ifdef NEW_WITH_FILENAME
ProhibitInput(owner->view());
fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
fileDlg.SetButton(1, _("Templates"), lyxrc.template_path);
fname = fileDlg.Select(_("Enter Filename for new document"),
initpath, "*.lyx", _("newfile"));
AllowInput(owner->view());
if (fname.empty()) {
owner->getMiniBuffer()->Set(_("Canceled."));
lyxerr.debug() << "New Document Cancelled." << endl;
return;
}
// get absolute path of file and make sure the filename ends
// with .lyx
string s = MakeAbsPath(fname);
if (!IsLyXFilename(s))
s += ".lyx";
static int newfile_number = 0;
string s = "newfile"+tostr(++newfile_number);
// Check if the document already is open
if (bufferlist.exists(s)) {
switch(AskConfirmation(_("Document is already open:"),
MakeDisplayPath(s, 50),
_("Do you want to close that document now?\n"
"('No' will just switch to the open version)")))
if (lyxrc.new_ask_filename) {
ProhibitInput(owner->view());
fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
fileDlg.SetButton(1, _("Templates"), lyxrc.template_path);
fname = fileDlg.Select(_("Enter Filename for new document"),
initpath, "*.lyx", _("newfile"));
AllowInput(owner->view());
if (fname.empty()) {
owner->getMiniBuffer()->Set(_("Canceled."));
lyxerr.debug() << "New Document Cancelled." << endl;
return;
}
// get absolute path of file and make sure the filename ends
// with .lyx
string s = MakeAbsPath(fname);
if (!IsLyXFilename(s))
s += ".lyx";
// Check if the document already is open
if (bufferlist.exists(s)) {
switch(AskConfirmation(_("Document is already open:"),
MakeDisplayPath(s, 50),
_("Do you want to close that document now?\n"
"('No' will just switch to the open version)")))
{
case 1: // Yes: close the document
if (!bufferlist.close(bufferlist.getBuffer(s)))
@ -3001,37 +3004,34 @@ void LyXFunc::MenuNew(bool fromTemplate)
owner->getMiniBuffer()->Set(_("Canceled."));
return;
}
}
// Check whether the file already exists
if (IsLyXFilename(s)) {
}
// Check whether the file already exists
if (IsLyXFilename(s)) {
FileInfo fi(s);
if (fi.readable() &&
AskQuestion(_("File already exists:"),
MakeDisplayPath(s, 50),
_("Do you want to open the document?"))) {
// loads document
owner->getMiniBuffer()->Set(_("Opening document"),
MakeDisplayPath(s), "...");
XFlush(fl_display);
owner->view()->buffer(
bufferlist.loadLyXFile(s));
owner->getMiniBuffer()->Set(_("Document"),
MakeDisplayPath(s),
_("opened."));
return;
}
}
} else {
FileInfo fi(s);
if (fi.readable() &&
AskQuestion(_("File already exists:"),
MakeDisplayPath(s, 50),
_("Do you want to open the document?"))) {
// loads document
owner->getMiniBuffer()->Set(_("Opening document"),
MakeDisplayPath(s), "...");
XFlush(fl_display);
owner->view()->buffer(
bufferlist.loadLyXFile(s));
owner->getMiniBuffer()->Set(_("Document"),
MakeDisplayPath(s),
_("opened."));
return;
while (bufferlist.exists(s) || fi.readable()) {
++newfile_number;
s = "newfile"+tostr(newfile_number);
fi.newFile(s);
}
}
#else
static int newfile_number = 0;
string s = "/lyx/dummy/dirname/newfile ["+tostr(++newfile_number)+"]";
FileInfo fi(s);
while (bufferlist.exists(s) || fi.readable()) {
++newfile_number;
s = "/lyx/dummy/dirname/newfile ["+tostr(newfile_number)+"]";
fi.newFile(s);
}
#endif
// The template stuff
string templname;

View File

@ -155,6 +155,7 @@ enum LyXRCTags {
RC_DOCBOOK_TO_HTML_COMMAND,
RC_DOCBOOK_TO_PDF_COMMAND,
RC_WHEEL_JUMP,
RC_NEW_ASK_FILENAME,
RC_LAST
};
@ -211,6 +212,7 @@ keyword_item lyxrcTags[] = {
{ "\\literate_extension", RC_LITERATE_EXTENSION },
{ "\\make_backup", RC_MAKE_BACKUP },
{ "\\mark_foreign_language", RC_MARK_FOREIGN_LANGUAGE },
{ "\\new_ask_filename", RC_NEW_ASK_FILENAME },
{ "\\num_lastfiles", RC_NUMLASTFILES },
{ "\\override_x_deadkeys", RC_OVERRIDE_X_DEADKEYS },
{ "\\pdf_mode", RC_PDF_MODE },
@ -376,6 +378,8 @@ void LyXRC::setDefaults() {
language_auto_end = true;
language_command_begin = "\\selectlanguage{$$lang}";
language_command_end = "\\selectlanguage{$$lang}";
///
new_ask_filename = false;
///
date_insert_format = "%A, %e %B %Y";
@ -1097,6 +1101,11 @@ int LyXRC::read(string const & filename)
if ( lexrc.next())
docbook_to_pdf_command = lexrc.GetString();
break;
case RC_NEW_ASK_FILENAME:
if ( lexrc.next())
new_ask_filename = lexrc.GetBool();
break;
case RC_LAST: break; // this is just a dummy
}

View File

@ -259,6 +259,8 @@ public:
string docbook_to_html_command;
///
string docbook_to_pdf_command;
///
bool new_ask_filename;
};
///