From ba61c3aa4cbb168b8c70a6393b3d8d79aea8d131 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Wed, 10 Oct 2001 16:45:05 +0000 Subject: [PATCH] Clean-up of Herbert's Texinfo dialog. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2859 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/ChangeLog | 4 + lib/Makefile.am | 11 +-- lib/configure | 2 +- lib/configure.m4 | 2 +- lib/help/Bibtex.hlp | 12 ++- lib/help/Texinfo.hlp | 36 +++++---- lib/{ => scripts}/TeXFiles.sh | 0 src/ChangeLog | 4 + src/frontends/controllers/ChangeLog | 7 ++ src/frontends/controllers/ControlTexinfo.C | 76 +++++++++++++++---- src/frontends/controllers/ControlTexinfo.h | 13 +++- src/frontends/xforms/ChangeLog | 4 + src/frontends/xforms/FormShowFile.C | 1 + src/frontends/xforms/FormTexinfo.C | 87 +++------------------- src/frontends/xforms/FormTexinfo.h | 8 +- src/lyx_main.C | 2 - 16 files changed, 140 insertions(+), 129 deletions(-) rename lib/{ => scripts}/TeXFiles.sh (100%) diff --git a/lib/ChangeLog b/lib/ChangeLog index 4f30cdabc9..fd70bc9d65 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,7 @@ +2001-10-10 Herbert Voss + + * scripts/TeXFiles.sh: new script for [cls,sty,bst]Files.lst + 2001-10-09 Herbert Voss * default.ui: help-Texinfo diff --git a/lib/Makefile.am b/lib/Makefile.am index 899af1b926..a92389139e 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -13,6 +13,7 @@ CLIPART = clipart/*.eps DOCDIST = doc/LyXConfig.lyx* DOCINST = doc/*.lyx doc/*.eps doc/*.lyx.in EXAMPLES = examples/*.lyx +HELP = help/*.hlp IMAGES = images/*.xpm KBD = kbd/*.kmap kbd/*.cdef LAYOUT = layouts/*.layout layouts/*.inc @@ -25,17 +26,17 @@ configure: configure.m4 $(M4) $< > $@ $(CHMOD) 755 $@ -LIBINSTFILES = $(BIND) $(CLIPART) $(DOCINST) $(EXAMPLES) $(IMAGES) $(KBD) \ - $(LAYOUT) $(TEMPL) $(TEXSUPPORT) $(UI) +LIBINSTFILES = $(BIND) $(CLIPART) $(DOCINST) $(EXAMPLES) $(HELP) $(IMAGES) \ + $(KBD) $(LAYOUT) $(TEMPL) $(TEXSUPPORT) $(UI) -LIBDISTFILES = $(BIND) $(CLIPART) $(DOCDIST) $(EXAMPLES) $(IMAGES) $(KBD) \ - $(LAYOUT) $(TEMPL) $(UI) $(TEXSUPPORT) $(LYXSCRIPTS) +LIBDISTFILES = $(BIND) $(CLIPART) $(DOCDIST) $(EXAMPLES) $(HELP) $(IMAGES) \ + $(KBD) $(LAYOUT) $(TEMPL) $(UI) $(TEXSUPPORT) $(LYXSCRIPTS) pkgdata_DATA = lyxrc.example CREDITS chkconfig.ltx lyxrc.defaults \ textclass.lst packages.lst external_templates \ encodings languages symbols -LYXLIBDIRS = bind clipart doc examples images kbd layouts scripts \ +LYXLIBDIRS = bind clipart doc examples help images kbd layouts scripts \ templates tex ui EXTRA_DIST = CREDITS chkconfig.ltx configure.cmd lyxrc.example \ diff --git a/lib/configure b/lib/configure index 1c3155f9a7..9d404ef20e 100755 --- a/lib/configure +++ b/lib/configure @@ -80,7 +80,7 @@ if test "x$OSTYPE" = xcygwin; then fi #### Create the build directories if necessary -for dir in bind clipart doc examples images kbd layouts reLyX \ +for dir in bind clipart doc examples help images kbd layouts reLyX \ scripts templates ui ; do test ! -d $dir && mkdir $dir done diff --git a/lib/configure.m4 b/lib/configure.m4 index 4ea80cde0a..d167639af4 100644 --- a/lib/configure.m4 +++ b/lib/configure.m4 @@ -156,7 +156,7 @@ if test "x$OSTYPE" = xcygwin; then fi #### Create the build directories if necessary -for dir in bind clipart doc examples images kbd layouts reLyX \ +for dir in bind clipart doc examples help images kbd layouts reLyX \ scripts templates ui ; do test ! -d $dir && mkdir $dir done diff --git a/lib/help/Bibtex.hlp b/lib/help/Bibtex.hlp index c15278eb60..827557ea03 100644 --- a/lib/help/Bibtex.hlp +++ b/lib/help/Bibtex.hlp @@ -1,14 +1,12 @@ -** This file is part of LyX, The Document Processor -** Copyright 2001 The LyX Team. Bibtex.hlp ---------------------------------------------------- + Bibtex.hlp -Database: +@bDatabase: Insert the Bibtex-database without the default extension ".bib". If you insert it with the browser, LyX strips the extension. More than one databases must be separated by a comma: natbib, books -Bibstyle: +@bBibstyle: Insert the Bibstyle without the default extension ".bst". Most of the bibstyles are stored in $TEXMF/bibtex/bst. $TEXMF is the root dir of the local TeX-tree. @@ -19,7 +17,7 @@ Bibstyle: available styles on your local TeX-System. It's available at http://www.perce.de/lyx/bstFiles.sh -Option bibtotoc: +@bOption bibtotoc: By default the Bibliography doesn't appears in the table of contents. Activate this option if you want an entry like @@ -29,4 +27,4 @@ Option bibtotoc: right name Bibliography/References, which depends to your chosen document-class. -2001-08-27 / Herbert Voss \ No newline at end of file +2001-08-27 / Herbert Voss diff --git a/lib/help/Texinfo.hlp b/lib/help/Texinfo.hlp index 82049e6c32..7c74f8e774 100644 --- a/lib/help/Texinfo.hlp +++ b/lib/help/Texinfo.hlp @@ -1,35 +1,41 @@ -** This file is part of LyX, The Document Processor -** Copyright 2001 The LyX Team. Texinfo.hlp ---------------------------------------------------- + Texinfo.hlp -Class Files: shows the installed TeX Document classes. +@bClass Files: + shows the installed TeX Document classes. Remember, that these classes are only available in LyX if a corresponding LyX-Layout file exists! -Style Files: shows the installed TeX Style files, which are +@bStyle Files: + shows the installed TeX Style files, which are available in LyX by default, like "babel" or through - "\usepackage{} +@i \usepackage{} in LaTeX-preamble (Layout->preamble) -BibTeX Stylefiles: shows the installed stylefiles for BibTeX. +@bBibTeX Stylefiles: + shows the installed stylefiles for BibTeX. They can be load through - insert->Lists&Toc->BibTeX Reference->Style +@i insert->Lists&Toc->BibTeX Reference->Style -Rescan: Runs the script TexFiles.sh to build new file lists. +@bRescan: + Runs the script TexFiles.sh to build new file lists. -Path yes/no: toggles view of the file lists +@bwith full Path: + toggles view of the file lists -View: shows the contents of the marked file. Only +@bView: + shows the contents of the marked file. Only possible when the files are shown with path. -Run TeXhash: runs the script texhash which builds the a new LaTeX tree. +@bRun TeXhash: + runs the script texhash which builds the a new LaTeX tree. Needed if you install a new TeX class or style! It runs only - with user-rights! Therefore you need the right-permissions + with user-rights! Therefore you need the write-permissions for the tex-dirs, often /var/lib/texmf and other. -Help: shows this file +@bHelp: + shows this file -2001-10-01 / Herbert Voss \ No newline at end of file +2001-10-01 / Herbert Voss diff --git a/lib/TeXFiles.sh b/lib/scripts/TeXFiles.sh similarity index 100% rename from lib/TeXFiles.sh rename to lib/scripts/TeXFiles.sh diff --git a/src/ChangeLog b/src/ChangeLog index ab6223b509..adbe12a687 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -2,6 +2,10 @@ * lyxfunc.C: removed greek_kb_flag. +2001-10-10 Herbert Voss + + * lyx_main.C: delete global string help_lyxdir. + 2001-10-09 Herbert Voss * commandtags.h (kb_action): added LFUN_HELP_TEXINFO. diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index dc34ae4326..d2bbf49391 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,10 @@ +2001-10-10 Herbert Voss + + * ControlTexinfo.C: new path for the shellscript TeXFiles.sh + and some more stuff from FormTexinfo.C + + * ControlShowFile.C: hiding the update-button + 2001-10-09 Herbert Voss * ControlTexinfo.[Ch]: new files. Display information about the diff --git a/src/frontends/controllers/ControlTexinfo.C b/src/frontends/controllers/ControlTexinfo.C index 959b874c36..7ebdbb4b71 100644 --- a/src/frontends/controllers/ControlTexinfo.C +++ b/src/frontends/controllers/ControlTexinfo.C @@ -22,20 +22,15 @@ #include "ControlTexinfo.h" #include "Dialogs.h" #include "LyXView.h" -#include "Lsstream.h" #include "BufferView.h" #include "gettext.h" #include "support/filetools.h" // FileSearch -#include "version.h" #include "support/syscall.h" #include "support/path.h" -#include "lyx_gui_misc.h" +#include "helper_funcs.h" +#include "support/lstrings.h" -extern string system_lyxdir; -extern string user_lyxdir; -extern string help_lyxdir; - -using SigC::slot; +extern string user_lyxdir; // home of *Files.lst ControlTexinfo::ControlTexinfo(LyXView & lv, Dialogs & d) : ControlDialog(lv, d) @@ -45,16 +40,17 @@ ControlTexinfo::ControlTexinfo(LyXView & lv, Dialogs & d) // build filelists of all availabe bst/cls/sty-files. done through // kpsewhich and an external script, saved in *Files.lst -void ControlTexinfo::rescanStyles() +void ControlTexinfo::rescanStyles() const { // Run rescan in user lyx directory Path p(user_lyxdir); Systemcalls one(Systemcalls::System, - AddName(system_lyxdir,"TeXFiles.sh")); + LibFileSearch("scripts", "TeXFiles.sh")); p.pop(); } -void ControlTexinfo::runTexhash() + +void ControlTexinfo::runTexhash() const { // Run texhash in user lyx directory Path p(user_lyxdir); @@ -68,12 +64,64 @@ void ControlTexinfo::runTexhash() } -void ControlTexinfo::viewFile(string const filename) +namespace { + +string const sortEntries(string & str_in) +{ + std::vector dbase = getVectorFromString(str_in,"\n"); + std::sort(dbase.begin(), dbase.end()); // sort entries + return getStringFromVector(dbase,"\n"); +} + +} //namespace anon + + +string const +ControlTexinfo::getContents(texFileSuffix type, bool withFullPath) const +{ + static string const bstFilename("bstFiles.lst"); + static string const clsFilename("clsFiles.lst"); + static string const styFilename("styFiles.lst"); + + string filename; + switch (type) { + case bst: + filename = bstFilename; + break; + case cls: + filename = clsFilename; + break; + case sty: + filename = clsFilename; + break; + } + + string fileContents = GetFileContents(LibFileSearch(string(),filename)); + // everything ok? + if (!fileContents.empty()) { + if (withFullPath) + return(sortEntries(fileContents)); + else { + int Entries = 1; + string dummy = OnlyFilename(token(fileContents,'\n',1)); + string contents = dummy; + do { + dummy = OnlyFilename(token(fileContents,'\n',++Entries)); + contents += ("\n"+dummy); + } while (!dummy.empty()); + return(sortEntries(contents)); + } + } else + return _("Missing filelist. try Rescan"); +} + +void ControlTexinfo::viewFile(string const filename) const { lv_.getDialogs()->showFile(filename); } -void ControlTexinfo::help() + +void ControlTexinfo::help() const { - lv_.getDialogs()->showFile(help_lyxdir+"Texinfo.hlp"); + lv_.getDialogs()->showFile(i18nLibFileSearch("help","Texinfo.hlp")); } diff --git a/src/frontends/controllers/ControlTexinfo.h b/src/frontends/controllers/ControlTexinfo.h index ef2cf90336..24bd539fdf 100644 --- a/src/frontends/controllers/ControlTexinfo.h +++ b/src/frontends/controllers/ControlTexinfo.h @@ -25,16 +25,21 @@ class ControlTexinfo : public ControlDialog { public: + /// the file extensions + enum texFileSuffix {cls, sty, bst}; /// ControlTexinfo(LyXView &, Dialogs &); /// - void viewFile(string const filename); + void viewFile(string const filename) const; /// - void help(); + void help() const; /// - void rescanStyles(); + void rescanStyles() const; /// - void runTexhash(); + void runTexhash() const; + /// + string const getContents(texFileSuffix type, bool withPath) const; + private: /// diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 8f201d8293..6799d95726 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,7 @@ +2001-10-10 Herbert Voss + + * FormTexinfo.[Ch]: some changes to the code + 2001-10-10 André Pönitz * FormsMathMatrix.C: add missing space between v- and h-alignment diff --git a/src/frontends/xforms/FormShowFile.C b/src/frontends/xforms/FormShowFile.C index c45f263e4b..5e2d1b5a57 100644 --- a/src/frontends/xforms/FormShowFile.C +++ b/src/frontends/xforms/FormShowFile.C @@ -22,6 +22,7 @@ FormShowFile::FormShowFile(ControlShowFile & c) void FormShowFile::update() { + fl_hide_object(dialog_->button_update); fl_clear_browser(dialog_->browser); // courier medium fl_set_browser_fontstyle(dialog_->browser,FL_FIXED_STYLE); diff --git a/src/frontends/xforms/FormTexinfo.C b/src/frontends/xforms/FormTexinfo.C index a8357cd64d..8a3abec274 100644 --- a/src/frontends/xforms/FormTexinfo.C +++ b/src/frontends/xforms/FormTexinfo.C @@ -15,26 +15,15 @@ #endif #include "xformsBC.h" -#include "ControlTexinfo.h" #include "FormTexinfo.h" #include "form_texinfo.h" #include "gettext.h" #include "debug.h" -#include "helper_funcs.h" #include "xforms_helpers.h" -#include "support/lstrings.h" -#include "support/filetools.h" #include "support/LAssert.h" - -extern string user_lyxdir; // home of *Files.lst namespace { -string const bstFilename("bstFiles.lst"); -string const clsFilename("clsFiles.lst"); -string const styFilename("styFiles.lst"); -string const errorMessage =_("Missing filelist. try Rescan"); - // C function wrapper, required by xforms. extern "C" int C_FormTexinfoFeedbackCB(FL_OBJECT * ob, int event, @@ -67,7 +56,7 @@ void setPreHandler(FL_OBJECT * ob) typedef FormCB > base_class; FormTexinfo::FormTexinfo(ControlTexinfo & c) : base_class(c, _("TeX Infos")), - warningPosted(false), activeStyle(FormTexinfo::cls) + warningPosted(false), activeStyle(ControlTexinfo::cls) {} @@ -77,7 +66,7 @@ void FormTexinfo::build() { fl_set_browser_fontstyle(dialog_->browser,FL_FIXED_STYLE); // with Path is default fl_set_button(dialog_->button_fullPath, 1); - updateStyles(FormTexinfo::cls); + updateStyles(ControlTexinfo::cls); setPreHandler(dialog_->button_rescan); setPreHandler(dialog_->button_view); @@ -97,13 +86,13 @@ ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long) { controller().help(); } else if (ob == dialog_->radio_cls) { - updateStyles(FormTexinfo::cls); + updateStyles(ControlTexinfo::cls); } else if (ob == dialog_->radio_sty) { - updateStyles(FormTexinfo::sty); + updateStyles(ControlTexinfo::sty); } else if (ob == dialog_->radio_bst) { - updateStyles(FormTexinfo::bst); + updateStyles(ControlTexinfo::bst); } else if (ob == dialog_->button_rescan) { // build new *Files.lst @@ -135,67 +124,15 @@ ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long) { return ButtonPolicy::SMI_VALID; } - -namespace { - -string const sortEntries(string & str_in) -{ - std::vector dbase = getVectorFromString(str_in,"\n"); - std::sort(dbase.begin(), dbase.end()); // sort entries - return getStringFromVector(dbase,"\n"); -} - -string const getContents(string const filename, bool withFullPath) -{ - string fileContents = GetFileContents(AddName(user_lyxdir,filename)); - // everything ok? - if (!fileContents.empty()) { - if (withFullPath) - return(sortEntries(fileContents)); - else { - int Entries = 1; - string dummy = OnlyFilename(token(fileContents,'\n',1)); - string contents = dummy; - do { - dummy = OnlyFilename(token(fileContents,'\n',++Entries)); - contents += ("\n"+dummy); - } while (!dummy.empty()); - return(sortEntries(contents)); - } - } else - return errorMessage; -} - -} // namespace anon - - -void FormTexinfo::updateStyles(FormTexinfo::texFileSuffix whichStyle) +void FormTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle) { fl_clear_browser(dialog_->browser); bool const withFullPath = fl_get_button(dialog_->button_fullPath); - switch (whichStyle) { - case FormTexinfo::bst: - { - string const str = getContents(bstFilename, withFullPath); - fl_add_browser_line(dialog_->browser, str.c_str()); - break; - - } - case FormTexinfo::cls: - { - string const str = getContents(clsFilename, withFullPath); - fl_add_browser_line(dialog_->browser, str.c_str()); - break; - } - case FormTexinfo::sty: - { - string const str = getContents(styFilename, withFullPath); - fl_add_browser_line(dialog_->browser, str.c_str()); - break; - } - } + string const str = + controller().getContents(whichStyle, withFullPath); + fl_add_browser_line(dialog_->browser, str.c_str()); activeStyle = whichStyle; } @@ -232,16 +169,16 @@ void FormTexinfo::feedback(FL_OBJECT * ob) string str; if (ob == dialog_->button_rescan) { - str = _("run rescan ..."); + str = _("starts rescan ..."); } else if (ob == dialog_->button_fullPath) { str = _("View full path or only file name"); } else if (ob == dialog_->button_texhash) { - str = _("run texhash and rescan..."); + str = _("starts texhash and rescan..."); } else if (ob == dialog_->button_view) { - str = _("select a file to view"); + str = _("views a selected file"); } diff --git a/src/frontends/xforms/FormTexinfo.h b/src/frontends/xforms/FormTexinfo.h index e956b9a964..0dc8090694 100644 --- a/src/frontends/xforms/FormTexinfo.h +++ b/src/frontends/xforms/FormTexinfo.h @@ -15,16 +15,14 @@ #endif #include "FormBase.h" +#include "ControlTexinfo.h" -class ControlTexinfo; struct FD_form_texinfo; class FormTexinfo : public FormCB > { public: /// FormTexinfo(ControlTexinfo &); - /// the file extensions - enum texFileSuffix {cls, sty, bst}; /// preemptive handler for feedback messages void feedbackCB(FL_OBJECT *, int); @@ -41,13 +39,13 @@ private: /// void feedback(FL_OBJECT *); /// - void updateStyles(texFileSuffix); + void updateStyles(ControlTexinfo::texFileSuffix); /// Fdesign generated method FD_form_texinfo * build_texinfo(); /// bool warningPosted; /// - texFileSuffix activeStyle; + ControlTexinfo::texFileSuffix activeStyle; }; #endif // FORMTEXINFO_H diff --git a/src/lyx_main.C b/src/lyx_main.C index a4bbe16e6b..c07c19c064 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -57,7 +57,6 @@ string system_lyxdir; string build_lyxdir; string system_tempdir; string user_lyxdir; // Default $HOME/.lyx -string help_lyxdir; // Default system_lyxdir/help // Should this be kept global? Asger says Yes. DebugStream lyxerr; @@ -375,7 +374,6 @@ void LyX::init(bool gui) system_lyxdir = LYX_DIR; path_shown = true; } - help_lyxdir = system_lyxdir+"help/"; // Report the system directory if debugging is on if (!path_shown) lyxerr[Debug::INIT] << "System directory: '"