]> git.lyx.org Git - features.git/commitdiff
Merge Herbert's bibtex patch; it doesn't introduce any new bugs and
authorJohn Levon <levon@movementarian.org>
Thu, 20 Jun 2002 20:41:00 +0000 (20:41 +0000)
committerJohn Levon <levon@movementarian.org>
Thu, 20 Jun 2002 20:41:00 +0000 (20:41 +0000)
it's nice ...

Herbert please look at the bugs I reported concerning when there is no cls etc. list please.
For this and FormTexinfo

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4442 a592a061-630c-0410-9148-cb99ea01b6c8

14 files changed:
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlBibtex.C
src/frontends/controllers/ControlBibtex.h
src/frontends/controllers/ControlTexinfo.C
src/frontends/controllers/ControlTexinfo.h
src/frontends/controllers/Makefile.am
src/frontends/controllers/tex_helpers.C [new file with mode: 0644]
src/frontends/controllers/tex_helpers.h [new file with mode: 0644]
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormBibtex.C
src/frontends/xforms/forms/form_bibtex.fd
src/support/ChangeLog
src/support/lyxalgo.h
src/support/lyxfunctional.h

index 890addc7d8428e584770e0c44662c252486329fc..927b1d9d996aff77032f3a00f22b0f551a94a317 100644 (file)
@@ -1,3 +1,8 @@
+2002-06-18  Herbert Voss  <voss@perce.de>
+
+       * tex_helpers.[Ch]: move functions from ControlTexinfo into this
+       helperstuff. Now the bibtex gui can use some of these functions
+
 2002-06-18  John Levon  <moz@compsoc.man.ac.uk>
 
        * ControlGraphics.C: just make the mask *.*
index 43e7557cb372ab350440e2a529d879cf97ace00d..43bdfc13628f97c24e56341b2f597e2d0f02fefe 100644 (file)
@@ -23,6 +23,7 @@
 #include "BufferView.h"
 #include "lyxrc.h"
 #include "helper_funcs.h"
+#include "tex_helpers.h"
 #include "gettext.h"
 
 #include "frontends/LyXView.h"
@@ -35,6 +36,7 @@ ControlBibtex::ControlBibtex(LyXView & lv, Dialogs & d)
 {}
 
 
+
 void ControlBibtex::applyParamsToInset()
 {
        if (params().getContents() != inset()->params().getContents())
@@ -63,3 +65,15 @@ string const ControlBibtex::Browse(string const & in_name,
        return browseRelFile(&lv_, in_name, lv_.buffer()->filePath(),
                             title, pattern, dir1);
 }
+
+
+string const ControlBibtex::getBibStyles() const
+{
+       return getTexFileList("bstFiles.lst", false);
+}
+
+
+void ControlBibtex::rescanBibStyles() const
+{
+       rescanTexStyles();
+}
index 2778d6701b075be4024dd1ad4c10e2b184d3ac1e..b77d88a27cdb92d880c3e94fbbc6c51245f2b949 100644 (file)
@@ -31,7 +31,12 @@ public:
        ControlBibtex(LyXView &, Dialogs &);
        /// Browse for a file
        string const Browse(string const &, string const &, string const &);
-
+       /// get the list of bst files
+       string const getBibStyles() const;
+       /// build filelists of all availabe bst/cls/sty-files. done through
+       /// kpsewhich and an external script, saved in *Files.lst
+       void rescanBibStyles() const;
+        
 private:
        /// Dispatch the changed parameters to the kernel.
        virtual void applyParamsToInset();
index 7637bbdccf5058f9672eb3109f15cca96e54f72d..d11d082224e0fe33e229251089b489b996fa33d0 100644 (file)
 #include "BufferView.h"
 #include "gettext.h"
 #include "helper_funcs.h"
+#include "tex_helpers.h"
 
 #include "frontends/LyXView.h"
 
 #include "support/filetools.h" // FileSearch
-#include "support/systemcall.h"
 #include "support/path.h"
 #include "support/lstrings.h"
 
@@ -42,86 +42,41 @@ ControlTexinfo::ControlTexinfo(LyXView & lv, Dialogs & d)
 // kpsewhich and an external script, saved in *Files.lst
 void ControlTexinfo::rescanStyles() const
 {
-       // Run rescan in user lyx directory
-       Path p(user_lyxdir);
-       Systemcall one;
-       one.startscript(Systemcall::Wait,
-                       LibFileSearch("scripts", "TeXFiles.sh"));
-       p.pop();
+    rescanTexStyles();
 }
 
 
 void ControlTexinfo::runTexhash() const
 {
-       // Run texhash in user lyx directory
-       Path p(user_lyxdir);
-
-       //path to texhash through system
-       Systemcall one;
-       one.startscript(Systemcall::Wait, "texhash");
-
-       p.pop();
-//     Alert::alert(_("texhash run!"),
-//                _("rebuilding of the TeX-tree could only be successfull"),
-//                _("if you have had user-write-permissions to the tex-dir."));
-}
-
-
-namespace {
-
-string const sortEntries(string & str_in)
-{
-       std::vector<string> dbase = getVectorFromString(str_in,"\n");
-       std::sort(dbase.begin(), dbase.end());          // sort entries
-       std::vector<string>::iterator p =
-           std::unique(dbase.begin(), dbase.end());    // compact
-       dbase.erase(p, dbase.end());                    // shrink
-       return getStringFromVector(dbase,"\n");
+    texhash();
 }
 
-} //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;
+           case bst: 
+               return getTexFileList("bstFiles.lst", withFullPath);
                break;
-       case cls:
-               filename = clsFilename;
+           case cls:
+               return getTexFileList("clsFiles.lst", withFullPath);
                break;
-       case sty:
-               filename = styFilename;
+           case sty:
+               return getTexFileList("styFiles.lst", withFullPath);
                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");
+       return string();
 }
 
+
 void ControlTexinfo::viewFile(string const filename) const
 {
        lv_.getDialogs()->showFile(filename);
 }
+
+
+string const ControlTexinfo::getClassOptions(string const & filename) const
+{
+       return getListOfOptions(filename, "cls");
+}
index d11df12191f230f11cf740a7adc839a64411d75c..07c9208b3541f03b0baa180f07908bf17930663b 100644 (file)
@@ -30,13 +30,15 @@ public:
        enum texFileSuffix {cls, sty, bst};
        ///
        ControlTexinfo(LyXView &, Dialogs &);
-       ///
+       /// show contents af a file
        void viewFile(string const filename) const;
-       ///
+       /// show all classoptions
+       string const getClassOptions(string const & filename) const;
+       /// build new cls bst sty - lists
        void rescanStyles() const;
-       ///
+       /// build new bst sty cls lists
        void runTexhash() const;
-       ///
+       /// read filecontents
        string const getContents(texFileSuffix type, bool withPath) const;
 
 
index efd413023914138c4bf711ab7eebb573b35083a8..0310f37bab6c43f2634ccf71b62e56abaa633f5a 100644 (file)
@@ -15,6 +15,8 @@ libcontrollers_la_SOURCES= \
        character.h \
        frnt_lang.C \
        frnt_lang.h \
+       tex_helpers.C \
+       tex_helpers.h \
        ButtonController.h \
        ButtonControllerBase.C \
        ButtonControllerBase.h \
diff --git a/src/frontends/controllers/tex_helpers.C b/src/frontends/controllers/tex_helpers.C
new file mode 100644 (file)
index 0000000..2c04a41
--- /dev/null
@@ -0,0 +1,125 @@
+/**
+ * \file tex_helpers.C
+ * Copyright 1995-2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author Herbert Voss <voss@lyx.org>
+ */
+
+#include <config.h>
+#include <vector.h>
+#include <fstream>
+#include <algorithm>
+
+#include "gettext.h"
+
+#include "tex_helpers.h"
+#include "support/filetools.h"
+#include "debug.h"
+#include "support/lstrings.h"
+#include "support/systemcall.h"
+#include "support/path.h"
+#include "support/lyxalgo.h"
+
+using std::vector;
+using std::sort;
+using std::unique;
+
+extern string user_lyxdir; // home of *Files.lst
+
+namespace {
+
+vector<string> listWithoutPath(vector<string> & dbase)
+{
+       vector<string>::iterator it = dbase.begin();
+       vector<string>::iterator end = dbase.end();
+       for (; it != end; ++it) 
+               *it = OnlyFilename(*it);
+       return dbase;
+}
+
+}
+
+// build filelists of all availabe bst/cls/sty-files. done through
+// kpsewhich and an external script, saved in *Files.lst
+void rescanTexStyles()
+{
+       // Run rescan in user lyx directory
+       Path p(user_lyxdir);
+       Systemcall one;
+       one.startscript(Systemcall::Wait,
+                       LibFileSearch("scripts", "TeXFiles.sh"));
+       p.pop();
+}
+
+
+void texhash()
+{
+       // Run texhash in user lyx directory
+       Path p(user_lyxdir);
+
+       //path to texhash through system
+       Systemcall one;
+       one.startscript(Systemcall::Wait,"texhash"); 
+       p.pop();
+}
+
+string const getTexFileList(string const & filename, bool withFullPath)
+{
+       vector<string> dbase = getVectorFromString(
+               GetFileContents(LibFileSearch(string(),filename)), "\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;
+}
+
+
+string const getListOfOptions(string const & classname,
+                           string const & type)
+{
+       string const filename = getTexFileFromList(classname,type);
+       string optionList = string();
+       std::ifstream is(filename.c_str());
+       while (is) {
+           string s;
+           is >> s;
+           if (contains(s,"DeclareOption")) {
+               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');
+           }
+       }
+       return optionList;
+}
+
+
+string const getTexFileFromList(string const & file, 
+                           string const & type)
+{
+       string const file_ = (type == "cls") ? file + ".cls" : file + ".sty";
+       lyxerr << "Search for classfile " << file_ << endl;
+       string const lstfile = (type == "cls") ? "clsFiles.lst" : "styFiles.lst";
+       string const allClasses = GetFileContents(LibFileSearch(string(), lstfile));
+       int entries = 0;
+       string classfile = token(allClasses, '\n', entries);
+       int count = 0;
+       while ((!contains(classfile, file) || 
+               (OnlyFilename(classfile) != file)) &&
+               (++count < 1000)) {
+               classfile = token(allClasses, '\n', ++entries);
+       }
+       // now we have filename with full path
+       lyxerr << "with full path: " << classfile << endl;
+       return classfile;
+}
diff --git a/src/frontends/controllers/tex_helpers.h b/src/frontends/controllers/tex_helpers.h
new file mode 100644 (file)
index 0000000..0294b46
--- /dev/null
@@ -0,0 +1,30 @@
+/**
+ * \file tex_helpers.h
+ * Copyright 1995-2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author Herbert Voss <voss@lyx.org>
+ */
+
+#ifndef TEX_HELPERS_H
+#define TEX_HELPERS_H
+
+// build filelists of all availabe bst/cls/sty-files. done through
+// kpsewhich and an external script, saved in *Files.lst
+void rescanTexStyles();
+
+/// rebuild the textree
+void texhash();
+
+/// return one of the three texfiles
+string const getTexFileList(string const & filename, bool withFullPath);
+
+/// get the options of stylefile
+string const getListOfOptions(string const & classname,
+                           string const & type);
+
+/// get a class with full path from the list
+string const getTexFileFromList(string const & classname,
+                           string const & type);
+
+#endif // TEX_HELPERS_H
index e15b34ba9cc23e5e1a5f796e377b03bcf874745c..0e5c1c9c049f752d45447afd1309d3cc24fabe68 100644 (file)
@@ -1,3 +1,15 @@
+2002-06-20  John Levon  <moz@compsoc.man.ac.uk>
+
+       * FormBibtex.C: use new lyx::eliminate_duplicates
+
+2002-06-20 Herbert Voss  <voss@perce.de>
+       * FormBibtex.C:
+       * forms/form_bibtex.fd: give better support for choosing the
+       bibstyle (new browserfield with the available bibstyles). 
+       move some code of ControlTexinfo into a helper
+       file support/tex-helpers to use some of the functions
 2002-06-20  John Levon  <moz@compsoc.man.ac.uk>
 
        * XWorkArea.h:
index 2694e4137366a25ffa8205e39da5a38433865050..8e968d38d11b9a3cb714f6ad60b2d13622b0398e 100644 (file)
@@ -27,6 +27,7 @@
 #include "support/LAssert.h"
 #include "support/lstrings.h"
 #include "support/filetools.h"
+#include "support/lyxalgo.h"
 
 
 using std::vector;
@@ -57,6 +58,8 @@ void FormBibtex::build()
        bc().addReadOnly(dialog_->button_database_browse);
        bc().addReadOnly(dialog_->input_database);
        bc().addReadOnly(dialog_->button_style_browse);
+       bc().addReadOnly(dialog_->button_style_choose);
+       bc().addReadOnly(dialog_->button_rescan);
        bc().addReadOnly(dialog_->input_style);
        bc().addReadOnly(dialog_->check_bibtotoc);
 
@@ -64,14 +67,21 @@ void FormBibtex::build()
        string str = _("The database you want to cite from. Insert it without the default extension \".bib\". If you insert it with the browser, LyX strips the extension. Several databases must be separated by a comma: \"natbib, books\".");
        tooltips().init(dialog_->button_database_browse, str);
 
-       str = _("Browse your directory for BibTeX stylefiles.");
+       str = _("Browse your directory for BibTeX stylefiles");
        tooltips().init(dialog_->button_style_browse, str);
 
-       str = _("The BibTeX style to use (only one allowed). Insert it without the default extension \".bst\" and without path. Most of the bibstyles are stored in $TEXMF/bibtex/bst. $TEXMF is the root dir of the local TeX tree. In \"View->TeX Information\" you can list all installed styles.");
+       str = _("The BibTeX style to use (only one allowed). Insert it without the default extension \".bst\" and without path or choose one from the browsers list. Most of the bibstyles are stored in $TEXMF/bibtex/bst. $TEXMF is the root dir of the local TeX tree.");
        tooltips().init(dialog_->input_style, str);
 
-       str = _("Activate this option if you want the bibliography to appear in the Table of Contents (which doesn't happen by default).");
+       str = _("Activate this option if you want the bibliography to appear in the Table of Contents (which doesn't happen by default)");
        tooltips().init(dialog_->check_bibtotoc, str);
+       
+       str = _("Choose a BibTeX style from the browsers list");
+       tooltips().init(dialog_->button_style_choose, str);
+       
+       str = _("Updates your TeX system for a new bibstyle list. Only the styles which are in directories where TeX finds them are listed!");
+       tooltips().init(dialog_->button_rescan, str);
+       
 }
 
 
@@ -82,8 +92,8 @@ ButtonPolicy::SMInput FormBibtex::input(FL_OBJECT * ob, long)
                string const in_name = fl_get_input(dialog_->input_database);
                string out_name =
                        controller().Browse("",
-                                           _("Select Database"),
-                                           _("*.bib| BibTeX Databases (*.bib)"));
+                               _("Select Database"),
+                               _("*.bib| BibTeX Databases (*.bib)"));
                if (!out_name.empty()) {
                        // add the database to any existing ones
                        if (!in_name.empty())
@@ -93,22 +103,28 @@ ButtonPolicy::SMInput FormBibtex::input(FL_OBJECT * ob, long)
                        fl_set_input(dialog_->input_database, out_name.c_str());
                        fl_unfreeze_form(form());
                }
-       }
-
-       if (ob == dialog_->button_style_browse) {
+       } else if (ob == dialog_->button_style_browse) {
                string const in_name = fl_get_input(dialog_->input_style);
                string out_name =
                        controller().Browse(in_name,
-                                           _("Select BibTeX-Style"),
-                                           _("*.bst| BibTeX Styles (*.bst)"));
+                               _("Select BibTeX-Style"),
+                               _("*.bst| BibTeX Styles (*.bst)"));
                if (!out_name.empty()) {
                        fl_freeze_form(form());
                        fl_set_input(dialog_->input_style, out_name.c_str());
                        fl_unfreeze_form(form());
                }
-       }
-
-       if (!compare(fl_get_input(dialog_->input_database),"")) {
+       } else if (ob == dialog_->button_style_choose) {
+               unsigned int selection = fl_get_browser(dialog_->browser_styles);
+               string const out_name = 
+                       fl_get_browser_line(dialog_->browser_styles, selection);
+               fl_set_input(dialog_->input_style, 
+                       ChangeExtension(out_name, string()).c_str());
+       } else if (ob == dialog_->button_rescan)
+               controller().rescanBibStyles();
+
+       // with an empty database nothing makes sense ...
+       if (!compare(fl_get_input(dialog_->input_database), "")) {
                return ButtonPolicy::SMI_NOOP;
        }
 
@@ -122,43 +138,35 @@ void FormBibtex::update()
                     controller().params().getContents().c_str());
        string bibtotoc = "bibtotoc";
        string bibstyle (controller().params().getOptions().c_str());
-       if (prefixIs(bibstyle,bibtotoc)) { // bibtotoc exists?
+       if (prefixIs(bibstyle, bibtotoc)) { // bibtotoc exists?
                fl_set_button(dialog_->check_bibtotoc,1);
-               if (contains(bibstyle,',')) { // bibstyle exists?
-                       bibstyle = split(bibstyle,bibtotoc,',');
+               if (contains(bibstyle, ',')) { // bibstyle exists?
+                       bibstyle = split(bibstyle, bibtotoc, ',');
                } else {
-                       bibstyle = "";
+                       bibstyle = string();
                }
 
-               fl_set_input(dialog_->input_style,bibstyle.c_str());
+               fl_set_input(dialog_->input_style, bibstyle.c_str());
 
        } else {
                fl_set_button(dialog_->check_bibtotoc,0);
-               fl_set_input(dialog_->input_style,bibstyle.c_str());
+               fl_set_input(dialog_->input_style, bibstyle.c_str());
        }
+       string const str =
+               controller().getBibStyles();
+       fl_add_browser_line(dialog_->browser_styles, str.c_str());
 }
 
 namespace {
 
-// Remove all duplicate entries in c.
-// Taken stright out of Stroustrup
-template<class C>
-void eliminate_duplicates(C & c)
-{
-       sort(c.begin(), c.end());
-       typename C::iterator p = std::unique(c.begin(), c.end());
-       c.erase(p, c.end());
-}
-
-
 string const unique_and_no_extensions(string const & str_in)
 {
        vector<string> dbase = getVectorFromString(str_in);
        for (vector<string>::iterator it = dbase.begin();
             it != dbase.end(); ++it) {
-               *it = ChangeExtension(*it, "");
+               *it = ChangeExtension(*it, string());
        }
-       eliminate_duplicates(dbase);
+       lyx::eliminate_duplicates(dbase);
        return getStringFromVector(dbase);
 }
 
@@ -188,7 +196,7 @@ void FormBibtex::apply()
 
        if (bibtotoc && (!bibstyle.empty())) {
                // both bibtotoc and style
-               controller().params().setOptions("bibtotoc,"+bibstyle);
+               controller().params().setOptions("bibtotoc," + bibstyle);
 
        } else if (bibtotoc) {
                // bibtotoc and no style
index f9d0406f243a9d39d89c928ef2530443294da621..f805327101f16063981f272e98f838581321db12 100644 (file)
@@ -9,14 +9,14 @@ SnapGrid: 1
 
 =============== FORM ===============
 Name: form_bibtex
-Width: 450
-Height: 160
-Number of Objects: 8
+Width: 312
+Height: 358
+Number of Objects: 11
 
 --------------------
 class: FL_BOX
 type: UP_BOX
-box: 0 0 450 160
+box: 0 0 312 358
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -34,10 +34,10 @@ argument:
 --------------------
 class: FL_INPUT
 type: NORMAL_INPUT
-box: 90 10 245 30
+box: 15 29 164 28
 boxtype: FL_DOWN_BOX
 colors: FL_COL1 FL_MCOL
-alignment: FL_ALIGN_LEFT
+alignment: FL_ALIGN_TOP_LEFT
 style: FL_NORMAL_STYLE
 size: FL_NORMAL_SIZE
 lcol: FL_BLACK
@@ -52,7 +52,7 @@ argument: 0
 --------------------
 class: FL_BUTTON
 type: RETURN_BUTTON
-box: 250 120 90 30
+box: 12 316 90 30
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -70,7 +70,7 @@ argument: 3
 --------------------
 class: FL_BUTTON
 type: NORMAL_BUTTON
-box: 350 120 90 30
+box: 112 316 90 30
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -88,10 +88,10 @@ argument: 2
 --------------------
 class: FL_INPUT
 type: NORMAL_INPUT
-box: 90 45 245 30
+box: 14 80 166 26
 boxtype: FL_DOWN_BOX
 colors: FL_COL1 FL_MCOL
-alignment: FL_ALIGN_LEFT
+alignment: FL_ALIGN_TOP_LEFT
 style: FL_NORMAL_STYLE
 size: FL_NORMAL_SIZE
 lcol: FL_BLACK
@@ -106,7 +106,7 @@ argument: 0
 --------------------
 class: FL_BUTTON
 type: NORMAL_BUTTON
-box: 340 10 100 29
+box: 192 29 100 29
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -124,25 +124,25 @@ argument: 0
 --------------------
 class: FL_BUTTON
 type: NORMAL_BUTTON
-box: 340 45 100 30
+box: 195 167 100 30
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
 style: FL_NORMAL_STYLE
 size: FL_DEFAULT_SIZE
 lcol: FL_BLACK
-label: Browse...|#r
+label: Choose|#C
 shortcut: 
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
-name: button_style_browse
+name: button_style_choose
 callback: C_FormBaseInputCB
 argument: 0
 
 --------------------
 class: FL_CHECKBUTTON
 type: PUSH_BUTTON
-box: 90 80 30 30
+box: 12 258 30 30
 boxtype: FL_NO_BOX
 colors: FL_COL1 FL_YELLOW
 alignment: FL_ALIGN_CENTER
@@ -157,5 +157,59 @@ name: check_bibtotoc
 callback: C_FormBaseInputCB
 argument: 0
 
+--------------------
+class: FL_BROWSER
+type: HOLD_BROWSER
+box: 14 129 168 111
+boxtype: FL_DOWN_BOX
+colors: FL_COL1 FL_YELLOW
+alignment: FL_ALIGN_TOP_LEFT
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Available Styles|#v
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: browser_styles
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 192 79 100 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: Browse...|#r
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: button_style_browse
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 196 208 100 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: Update List|#U
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: button_rescan
+callback: C_FormBaseInputCB
+argument: 0
+
 ==============================
 create_the_forms
index 6344f6e3f5f968d22ac10d7da7327a13ac050b50..a6694dc862ab097aba03469fa066bfc6414de34a 100644 (file)
@@ -1,3 +1,7 @@
+2002-06-19  John Levon  <moz@compsoc.man.ac.uk>
+
+       * lyxalgo.h: add eliminate_duplicates
+
 2002-06-17  Herbert Voss  <voss@perce.de>
 
        * filetools.[C]: (readBB_from_PSFile) add a helperfunc
index dcbfd6d5d3bc4e195e7064e6bbf51097cc049748..60aaff7b2b6ddfda9a790e63393cf9265b4b8f02 100644 (file)
@@ -9,8 +9,6 @@
  * \author unknown
  */
 
-
 #ifndef LYX_ALGO_H
 #define LYX_ALGO_H
 
@@ -87,6 +85,15 @@ count (Iterator first, Iterator last, T const & value)
 #endif
 }
 
+/// Remove all duplicate entries in c.
+template<class C>
+void eliminate_duplicates(C & c)
+{
+       std::sort(c.begin(), c.end());
+       typename C::iterator p = std::unique(c.begin(), c.end());
+       c.erase(p, c.end());
+}
+
 } // namespace lyx
 
 #endif // LYX_ALGO_H
index 2e52337a26a39a59d9f31ef7bfc00105113471b7..0d129c6c63aea22be32fa614a9b9176f37724cb5 100644 (file)
@@ -14,7 +14,6 @@
 
 namespace lyx {
 
-
 template<class R, class C, class A>
 class class_fun_t {
 public: