From 5b2f35382ef7445a9a366e29695448491adec63a Mon Sep 17 00:00:00 2001 From: John Levon Date: Thu, 20 Jun 2002 23:35:10 +0000 Subject: [PATCH] Auto-scan for texinfo and bibtex dialogs git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4446 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/controllers/ChangeLog | 11 +++++++ src/frontends/controllers/ControlBibtex.C | 9 +++++- src/frontends/controllers/ControlTexinfo.C | 37 +++++++++++++++------- src/frontends/controllers/tex_helpers.C | 14 ++++---- src/frontends/xforms/ChangeLog | 4 +++ src/frontends/xforms/forms/form_texinfo.fd | 2 +- 6 files changed, 57 insertions(+), 20 deletions(-) diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 1c5513137b..3d6c71e35d 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,14 @@ +2002-06-21 John Levon + + * ControlTexinfo.C: do the same for Texinfo + + * tex_helpers.C: don't try to read a file that isn't there + +2002-06-21 Herbert Voss + + * ControlBibtex.C: do an automatic update, when no bst-list + exists + 2002-06-20 John Levon * GUI.h: createIndex() changed diff --git a/src/frontends/controllers/ControlBibtex.C b/src/frontends/controllers/ControlBibtex.C index 43bdfc1362..d089ada704 100644 --- a/src/frontends/controllers/ControlBibtex.C +++ b/src/frontends/controllers/ControlBibtex.C @@ -25,6 +25,7 @@ #include "helper_funcs.h" #include "tex_helpers.h" #include "gettext.h" +#include "support/lstrings.h" #include "frontends/LyXView.h" @@ -69,7 +70,13 @@ string const ControlBibtex::Browse(string const & in_name, string const ControlBibtex::getBibStyles() const { - return getTexFileList("bstFiles.lst", false); + string list = getTexFileList("bstFiles.lst", false); + // test, if we have a valid list, otherwise run rescan + if (list.empty()) { + rescanBibStyles(); + list = getTexFileList("bstFiles.lst", false); + } + return list; } diff --git a/src/frontends/controllers/ControlTexinfo.C b/src/frontends/controllers/ControlTexinfo.C index d11d082224..b3d1d6c7c4 100644 --- a/src/frontends/controllers/ControlTexinfo.C +++ b/src/frontends/controllers/ControlTexinfo.C @@ -32,6 +32,25 @@ extern string user_lyxdir; // home of *Files.lst +namespace { + +string getFileList(ControlTexinfo::texFileSuffix type, bool withFullPath) +{ + switch (type) { + case ControlTexinfo::bst: + return getTexFileList("bstFiles.lst", withFullPath); + break; + case ControlTexinfo::cls: + return getTexFileList("clsFiles.lst", withFullPath); + break; + case ControlTexinfo::sty: + return getTexFileList("styFiles.lst", withFullPath); + break; + } + return string(); +} + +} ControlTexinfo::ControlTexinfo(LyXView & lv, Dialogs & d) : ControlDialogBI(lv, d) @@ -55,18 +74,14 @@ void ControlTexinfo::runTexhash() const string const ControlTexinfo::getContents(texFileSuffix type, bool withFullPath) const { - switch (type) { - case bst: - return getTexFileList("bstFiles.lst", withFullPath); - break; - case cls: - return getTexFileList("clsFiles.lst", withFullPath); - break; - case sty: - return getTexFileList("styFiles.lst", withFullPath); - break; + string list(getFileList(type, withFullPath)); + + // initial scan + if (list.empty()) { + rescanStyles(); + list = getFileList(type, withFullPath); } - return string(); + return list; } diff --git a/src/frontends/controllers/tex_helpers.C b/src/frontends/controllers/tex_helpers.C index 2c04a412a7..79a1a4a1de 100644 --- a/src/frontends/controllers/tex_helpers.C +++ b/src/frontends/controllers/tex_helpers.C @@ -66,15 +66,17 @@ void texhash() string const getTexFileList(string const & filename, bool withFullPath) { - vector dbase = getVectorFromString( - GetFileContents(LibFileSearch(string(),filename)), "\n"); + string const file = LibFileSearch("", filename); + if (file.empty()) + return string(); + + vector dbase = + getVectorFromString(GetFileContents(file), "\n"); + lyx::eliminate_duplicates(dbase); string const str_out = withFullPath ? getStringFromVector(dbase, "\n") : getStringFromVector(listWithoutPath(dbase), "\n"); - // everything ok? - if (str_out.empty()) - return _("Missing filelist. try Rescan"); return str_out; } @@ -92,8 +94,6 @@ string const getListOfOptions(string const & classname, s = s.substr(s.find("DeclareOption")); s = split(s,'{'); // cut front s = token(s,'}',0); // cut end -// FIXME: why is this commented out ? -// s = s.substr(0, s.find('}')+1); // format entry optionList += (s + '\n'); } } diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index e9ab31370b..ae14678a8e 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,7 @@ +2002-06-21 John Levon + + * forms/form_texinfo.fd: "Update List" not "Rescan" + 2002-06-20 John Levon * guiapi.C: createIndex() changed diff --git a/src/frontends/xforms/forms/form_texinfo.fd b/src/frontends/xforms/forms/form_texinfo.fd index 1d1b5b4455..dbd788f0aa 100644 --- a/src/frontends/xforms/forms/form_texinfo.fd +++ b/src/frontends/xforms/forms/form_texinfo.fd @@ -186,7 +186,7 @@ alignment: FL_ALIGN_CENTER style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: Rescan|#R +label: Update List|#U shortcut: resize: FL_RESIZE_NONE gravity: FL_NorthEast FL_NorthEast -- 2.39.5