]> git.lyx.org Git - features.git/commitdiff
updates to latexfeatures stuff; allow empty \document_path
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 10 Jan 2002 10:05:45 +0000 (10:05 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 10 Jan 2002 10:05:45 +0000 (10:05 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3324 a592a061-630c-0410-9148-cb99ea01b6c8

13 files changed:
po/POTFILES.in
src/ChangeLog
src/LaTeXFeatures.C
src/buffer.C
src/frontends/FileDialog.h
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormFiledialog.C
src/frontends/xforms/FormPreferences.C
src/insets/ChangeLog
src/insets/insetfloat.C
src/lyxrc.C
src/mathed/ChangeLog
src/mathed/math_hullinset.C

index 70e9cdc5419824a319fc621ab7c2e6bc366be90e..20a05e23d2155e5ff01f84f1f412cdc5baeee614 100644 (file)
@@ -112,6 +112,8 @@ src/frontends/xforms/form_maths_panel.C
 src/frontends/xforms/FormMathsPanel.C
 src/frontends/xforms/form_maths_space.C
 src/frontends/xforms/FormMathsSpace.C
+src/frontends/xforms/form_maths_style.C
+src/frontends/xforms/FormMathsStyle.C
 src/frontends/xforms/form_minipage.C
 src/frontends/xforms/FormMinipage.C
 src/frontends/xforms/form_paragraph.C
index 36313b6f5df118c255388b7aa0d02c73a200c4d3..c2146b4cbc7333268a593b7a8e17dfe87cf6b582 100644 (file)
@@ -1,3 +1,26 @@
+2002-01-10  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
+
+       * lyxrc.C (getDescription): document that document_path and
+       template_path can be empty.
+
+2002-01-09  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
+
+       * LaTeXFeatures.C (getMacros): 
+       * buffer.C (validate): rename feature "amsstyle" to "amsmath"
+       
+       * buffer.C (makeLaTeXFile): remove test for "amsstyle" from here.
+
+       * LaTeXFeatures.C (useFloat): require "float" here instead of in
+       getPackages. 
+       (getPackages): rename feature "floats" to "float". Use an array to
+       iterate over 'simple' features (i.e. just a \usepackage). Add
+       handling of "amsmath" (renamed from "amsstyle").
+
+2001-12-29  Michael A. Koziarski  <michael@koziarski.org>
+
+       * LaTeXFeatures.C (require): Prevent duplicate entries in the
+       features list.
+
 2002-01-08  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * FuncStatus.C: small compile fix for DEC cxx. Doesn't like
index 92462114bfa3e7d0c744cd319c1320ac054196dd..cb28134d432034f442f6318caccdf850e197464d 100644 (file)
@@ -41,6 +41,9 @@ LaTeXFeatures::LaTeXFeatures(BufferParams const & p, layout_type n)
 
 void LaTeXFeatures::require(string const & name)
 {
+       if (isRequired(name))
+               return;
+       
        // INSET_GRAPHICS: remove this when InsetFig is thrown.
        if (name == "graphics") {
                features.push_back("graphicx");
@@ -74,6 +77,13 @@ void LaTeXFeatures::addExternalPreamble(string const & pream)
 void LaTeXFeatures::useFloat(string const & name)
 {
        usedFloats.insert(name);
+       // We only need float.sty if we use non builtin floats, or if we
+       // use the "H" modifier. This includes modified table and
+       // figure floats. (Lgb)
+       Floating const & fl = floatList.getType(name);
+       if (!fl.type().empty() && !fl.builtin()) {
+               require("float");
+       }
 }
 
 
@@ -120,6 +130,25 @@ set<string> LaTeXFeatures::getEncodingSet(string const & doc_encoding)
        return encodings;
 }
 
+namespace {
+       
+char const * simplefeatures[] = {
+       "array",
+       "verbatim",
+       "longtable",
+       "rotating",
+       "latexsym",
+       "pifont",
+       "subfigure",
+       "floatflt",
+       "varioref",
+       "prettyref",
+       "float"
+};
+
+const int nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *);
+
+}
 
 string const LaTeXFeatures::getPackages() const
 {
@@ -132,54 +161,23 @@ string const LaTeXFeatures::getPackages() const
         *  These are all the 'simple' includes.  i.e
         *  packages which we just \usepackage{package}
         **/
-
-       // array-package
-       if (isRequired("array"))
-               packages << "\\usepackage{array}\n";
-
-       // verbatim.sty
-       if (isRequired("verbatim"))
-               packages << "\\usepackage{verbatim}\n";
-
-       //longtable.sty
-       if (isRequired("longtable"))
-               packages << "\\usepackage{longtable}\n";
-
-       //rotating.sty
-       if (isRequired("rotating"))
-               packages << "\\usepackage{rotating}\n";
-
-
-       // latexsym.sty
-       if (isRequired("latexsym"))
-               packages << "\\usepackage{latexsym}\n";
-
-       // pifont.sty
-       if (isRequired("pifont"))
-               packages << "\\usepackage{pifont}\n";
-
-       // subfigure.sty
-       if (isRequired("subfigure"))
-               packages << "\\usepackage{subfigure}\n";
-
-       // floatflt.sty
-       if (isRequired("floatflt"))
-               packages << "\\usepackage{floatflt}\n";
-
-
-       // varioref.sty
-       if (isRequired("varioref"))
-               packages << "\\usepackage{varioref}\n";
-
-       // prettyref.sty
-       if (isRequired("prettyref"))
-               packages << "\\usepackage{prettyref}\n";
-
+       for (int i = 0 ; i < nb_simplefeatures ; ++i) {
+               if (isRequired(simplefeatures[i]))
+                       packages << "\\usepackage{"
+                                << simplefeatures[i]
+                                << "}\n";
+       }
+       
        /**
         * The rest of these packages are somewhat more complicated
         * than those above.
         **/
 
+       if (isRequired("amsmath")
+           && ! tclass.provides(LyXTextClass::amsmath)) {
+               packages << "\\usepackage{amsmath}\n";
+       }
+               
        // color.sty
        if (isRequired("color")) {
                if (params.graphicsDriver == "default")
@@ -260,24 +258,6 @@ string const LaTeXFeatures::getPackages() const
                            "                      {\\newcommand{\\url}{\\texttt}}\n";
 
        // float.sty
-       // We only need float.sty if we use non builtin floats, or if we
-       // use the "H" modifier. This includes modified table and
-       // figure floats. (Lgb)
-       if (!usedFloats.empty()) {
-               UsedFloats::const_iterator beg = usedFloats.begin();
-               UsedFloats::const_iterator end = usedFloats.end();
-               for (; beg != end; ++beg) {
-                       Floating const & fl = floatList.getType((*beg));
-                       if (!fl.type().empty() && !fl.builtin()) {
-                               const_cast<LaTeXFeatures *>(this)->require("floats");
-                               break;
-                       }
-               }
-       }
-       if (isRequired("floats")) {
-               packages << "\\usepackage{float}\n";
-       }
-       
        // natbib.sty
        if (isRequired("natbib")) {
                packages << "\\usepackage[";
@@ -327,9 +307,9 @@ string const LaTeXFeatures::getMacros() const
                macros << guillemotright_def << '\n';
     
         // Math mode    
-       if (isRequired("boldsymbol") && !isRequired("amsstyle"))
+       if (isRequired("boldsymbol") && !isRequired("amsmath"))
                macros << boldsymbol_def << '\n';
-       if (isRequired("binom") && !isRequired("amsstyle"))
+       if (isRequired("binom") && !isRequired("amsmath"))
                macros << binom_def << '\n';
 
        // other
@@ -467,7 +447,7 @@ void LaTeXFeatures::getFloatDefinitions(std::ostream & os) const
                           << name << "}\n";
                        
                        // What missing here is to code to minimalize the code
-                       // outputted so that the same floatstyle will not be
+                       // output so that the same floatstyle will not be
                        // used several times, when the same style is still in
                        // effect. (Lgb)
                }
index 20bd850f4525b6c4eec545a1d85bf6493b25f9a5..e241f7373e4643b7aa9f41df940166576ac661fb 100644 (file)
@@ -2322,12 +2322,6 @@ void Buffer::makeLaTeXFile(string const & fname,
                        texrow.newline();
                }
 
-               if (features.isRequired("amsstyle")
-                           && !tclass.provides(LyXTextClass::amsmath)) {
-                       ofs << "\\usepackage{amsmath}\n";
-                       texrow.newline();
-               }
-               
                if (tokenPos(tclass.opt_pagestyle(),
                             '|', params.pagestyle) >= 0) {
                        if (params.pagestyle == "fancy") {
@@ -3491,7 +3485,7 @@ void Buffer::validate(LaTeXFeatures & features) const
     
         // AMS Style is at document level
         if (params.use_amsmath || tclass.provides(LyXTextClass::amsmath))
-               features.require("amsstyle");
+               features.require("amsmath");
     
        while (par) {
                // We don't use "lyxerr.debug" because of speed. (Asger)
index 02d7ae3b12c1139a928b7a676848bbde860155de..6b1533be7c34a65c3b7114cf47472bf368177635 100644 (file)
@@ -44,24 +44,27 @@ public:
 
        /**
         * Constructs a file dialog attached to LyXView \param lv, with
-        * title \param title. If param \a is \const LFUN_SELECT_FILE_SYNC
+        * title \param title. If \param a is \const LFUN_SELECT_FILE_SYNC
         * then a value will be returned immediately upon performing a Select(),
         * otherwise a callback Dispatch() will be invoked with the filename as
         * argument, of action \param a.
         *
-        * Up to two optional extra buttons are allowed for specifying addtional
-        * directories in the navigation.
+        * Up to two optional extra buttons are allowed for specifying
+        * additional directories in the navigation (an empty
+        * directory is interpreted as getcwd())
         */
-       FileDialog(LyXView * lv, string const & title, kb_action a = LFUN_SELECT_FILE_SYNC,
-               Button b1 = Button(string(), string()),
-               Button b2 = Button(string(), string()));
+       FileDialog(LyXView * lv, string const & title,
+                  kb_action a = LFUN_SELECT_FILE_SYNC,
+                  Button b1 = Button(string(), string()),
+                  Button b2 = Button(string(), string()));
                        
 
        ~FileDialog();
 
        /**
-        * Choose a file for selection, starting in directory \param path, with the file
-        * selection \param mask. The \param mask string is of the form :
+        * Choose a file for selection, starting in directory \param
+        * path, with the file selection \param mask. The \param mask
+        * string is of the form : 
         *
         * <regular expression to match> | <description>
         *
index 2697bf5317e7c2630fb8ff11dc187e467466e7f3..e8c54d6a1cb20d54087ab3a29e2d834b9e2ecbc4 100644 (file)
@@ -1,3 +1,14 @@
+2002-01-10  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
+
+       * FormPreferences.C (input): allow empty values for document_path
+       and template_path.
+
+       * FormFiledialog.C (SetButton):
+       (FileDlgCB): do not disable directory buttons if they have an
+       empty path.
+       (SetDirectory): if the argument is an empty string, change to
+       cwd().
+
 2002-01-09  Martin Vermeer <martin.vermeer@hut.fi>
 
        * forms/form_maths_style.fd:
index 3e67b753b4e94ff03d59fd5724378a04450415c8..53cbf5e0420a9c613c55600b23277b09d2195ceb 100644 (file)
@@ -375,15 +375,13 @@ void FileDialog::Private::Reread()
 // SetDirectory: sets dialog current directory
 void FileDialog::Private::SetDirectory(string const & Path)
 {
+       
        string tmp;
-       if (!pszDirectory.empty()) {
-               string TempPath = ExpandPath(Path); // Expand ~/
-               TempPath = MakeAbsPath(TempPath, pszDirectory);
-               tmp = MakeAbsPath(TempPath);
-       } else {
-               tmp = MakeAbsPath(Path);
-       }
+
+       if (Path.empty()) 
+               tmp = lyx::getcwd();
+       else
+               tmp = MakeAbsPath(ExpandPath(Path), pszDirectory);
  
        // must check the directory exists
        DIR * pDirectory = ::opendir(tmp.c_str());
@@ -481,7 +479,7 @@ void FileDialog::Private::SetButton(int iIndex, string const & pszName,
                pTemp = &pszUserPath2;
        } else return;
 
-       if (!pszName.empty() && !pszPath.empty()) {
+       if (!pszName.empty()) {
                fl_set_object_label(pObject, pszName.c_str());
                fl_show_object(pObject);
                *pTemp = pszPath;
@@ -558,21 +556,17 @@ void FileDialog::Private::FileDlgCB(FL_OBJECT *, long lArgument)
                break;
 
        case 12: // user button 1
-               if (!pCurrentDlg->pszUserPath1.empty()) {
-                       pCurrentDlg->SetDirectory(pCurrentDlg->pszUserPath1);
-                       pCurrentDlg->SetMask(fl_get_input(pFileDlgForm
-                                                         ->PatBox));
-                       pCurrentDlg->Reread();
-               }
+               pCurrentDlg->SetDirectory(pCurrentDlg->pszUserPath1);
+               pCurrentDlg->SetMask(fl_get_input(pFileDlgForm
+                                                 ->PatBox));
+               pCurrentDlg->Reread();
                break;
 
        case 13: // user button 2
-               if (!pCurrentDlg->pszUserPath2.empty()) {
-                       pCurrentDlg->SetDirectory(pCurrentDlg->pszUserPath2);
-                       pCurrentDlg->SetMask(fl_get_input(pFileDlgForm
-                                                         ->PatBox));
-                       pCurrentDlg->Reread();
-               }
+               pCurrentDlg->SetDirectory(pCurrentDlg->pszUserPath2);
+               pCurrentDlg->SetMask(fl_get_input(pFileDlgForm
+                                                 ->PatBox));
+               pCurrentDlg->Reread();
                break;
 
        }
@@ -716,8 +710,10 @@ void FileDialog::Private::Force(bool cancel)
 
 
 // Select: launches dialog and returns selected file
-string const FileDialog::Private::Select(string const & title, string const & path,
-                               string const & mask, string const & suggested)
+string const FileDialog::Private::Select(string const & title,
+                                        string const & path,
+                                        string const & mask,
+                                        string const & suggested)
 {
        // handles new mask and path
        bool isOk = true;
index 083a47c27b480e9f8b762888f79e0ab2678fe936..929a6efe38b0ee433ff6db40b6d58af3749c1a39 100644 (file)
@@ -2157,7 +2157,7 @@ bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
 
        if (!ob || ob == dialog_->input_default_path) {
                string const name = fl_get_input(dialog_->input_default_path);
-               if (!RWInfo::WriteableDir(name)) {
+               if (!name.empty() && !RWInfo::WriteableDir(name)) {
                        parent_.printWarning(RWInfo::ErrorMessage());
                        return false;
                }
@@ -2165,7 +2165,7 @@ bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
 
        if (!ob || ob == dialog_->input_template_path) {
                string const name = fl_get_input(dialog_->input_template_path);
-               if (!RWInfo::ReadableDir(name)) {
+               if (!name.empty() && !RWInfo::ReadableDir(name)) {
                        parent_.printWarning(RWInfo::ErrorMessage());
                        return false;
                }
index bef607c9f040151a8c84bfd0c3d59c72357b4d73..391812b3a6a3509f0b64c17ecf2f08bc8169d181 100644 (file)
@@ -1,3 +1,7 @@
+2002-01-09  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
+
+       * insetfloat.C (validate): require "float" instead of "floats".
+
 2002-01-08  Martin Vermeer  <martin.vermeer@hut.fi>
 
        * insettabular.C (getStatus): use FuncStatus
index 1d4c3614cb81a9fbc0dc6b67415468138b08ec09..e31523429f107f9da5c754b0923f0d5a92981d9b 100644 (file)
@@ -185,7 +185,7 @@ void InsetFloat::read(Buffer const * buf, LyXLex & lex)
 void InsetFloat::validate(LaTeXFeatures & features) const
 {
        if (contains(placement(), "H")) {
-               features.require("floats");
+               features.require("float");
        }
        
        features.useFloat(floatType_);
index 857c2d96f0ad7c4a75b050978da802a236109e21..b7a5035676978abdc7d8b4f2751c053ca3029af9 100644 (file)
@@ -1786,11 +1786,11 @@ string const LyXRC::getDescription(LyXRCTags tag)
                break;
                
        case RC_DOCUMENTPATH:
-               str = N_("The default path for your documents.");
+               str = N_("The default path for your documents.  An empty value selects the directory LyX was started from.");
                break;
                
        case RC_TEMPLATEPATH:
-               str = N_("The path that LyX will set when offering to choose a template.");
+               str = N_("The path that LyX will set when offering to choose a template.  An empty value selects the directory LyX was started from.");
                break;
                
        case RC_TEMPDIRPATH:
index ee3cda7a210d22c8d8dfc0fa9c783ec83b5d4c12..e39c887e0a60b453697a86b0e459d56b8ca62d87 100644 (file)
@@ -1,3 +1,8 @@
+2002-01-09  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
+
+       * math_hullinset.C (validate): rename feature "amsstyle" to
+       "amsmath". 
+
 2002-01-09  Martin Vermeer <martin.vermeer@hut.fi>
 
        * math_support.C: modified to support  a mathed pop-up for math 
index e2683fcf29100c77a7bd314cdc4b089b36a37d9b..0e0db0d0d01ab24022ccb0f9d007e242723fcefd 100644 (file)
@@ -261,7 +261,7 @@ bool MathHullInset::numberedType() const
 void MathHullInset::validate(LaTeXFeatures & features) const
 {
        if (ams())
-               features.require("amsstyle");
+               features.require("amsmath");
 
 
        // Validation is necessary only if not using AMS math.