]> git.lyx.org Git - features.git/commitdiff
Nuked the SpaceLess function. Read ChangeLog.
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 3 Dec 1999 13:51:01 +0000 (13:51 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 3 Dec 1999 13:51:01 +0000 (13:51 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@349 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
src/LaTeXLog.C
src/LyXSendto.C
src/buffer.C
src/buffer.h
src/lyx_cb.C
src/lyxfunc.C
src/support/filetools.C
src/support/filetools.h

index 2c23cd21a896dcb8fe68c8493d32726436f0f0a0..76772473b510f4cfb5ce5ec534158df9588c0ca9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,31 @@
-1999-12-01  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
+1999-12-03  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
+
+       * src/lyxfunc.C (getStatus): do not query current font if no
+       buffer exists.
+
+       * src/lyx_cb.C (RunScript): use QuoteName
+       (MenuRunDvips): ditto
+       (PrintApplyCB): ditto
+
+       * src/support/filetools.[Ch] (QuoteName): new function. Add quotes
+       around argument, so that it works well with the current shell.
+       Does not work properly with OS/2 shells currently.
+
+       * src/LaTeXLog.C (ShowLatexLog): use Buffer::getLatexName
+       * src/LyXSendto.C (SendtoApplyCB): ditto
+       * src/lyxfunc.C (Dispatch): ditto
+       * src/buffer.C (runLaTeX): ditto
+       (runLiterate): ditto
+       (buildProgram): ditto
+       (runChktex): ditto
+       * src/lyx_cb.C (RunScript): ditto
+       (MenuMakeLaTeX): ditto
+       
+       * src/buffer.h (getLatexName): new method 
+
+       * src/support/filetools.C (MakeLatexName): renamed from SpaceLess
+
+1999-12-02  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * images/sqrt.xpm: change name of the sqrt icon to sqrt_xpm.
        * src/mathed/math_panel.C (mathed_get_pixmap_from_icon): ditto
@@ -11,7 +38,7 @@
        few "using".
 
        * src/bmtable.C (fl_set_bmtable_data): add a const_cast.
-
+       
 1999-12-01  Lars Gullik Bjønnes  <larsbj@lyx.org>
 
        * src/mathed/formula.C (LocalDispatch): fix small whitspace bug
index fcb3acca8c03b356bb3b88fcbf4cba2b5b0522f1..19d3c255a2e77f2aeb0df265b6f214d4a8d5f9d0 100644 (file)
@@ -22,11 +22,12 @@ void ShowLatexLog()
        bool use_build = false;
        static int ow = -1, oh;
 
-       filename = current_view->buffer()->getFileName();
+       filename = current_view->buffer()->getLatexName();
        if (!filename.empty()) {
-               fname = SpaceLess(ChangeExtension(filename, ".log", true));
-               bname = SpaceLess(ChangeExtension(filename,
-                                                 lyxrc->literate_extension + ".out", true));
+               fname = ChangeExtension(filename, ".log", true);
+               bname = ChangeExtension(filename,
+                                       lyxrc->literate_extension + ".out", 
+                                       true);
                path = OnlyPath(filename);
                if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
                        path = current_view->buffer()->tmppath;
index e71baf3e23c620ad51a198d5dcb3efb3e85c4ea2..57c30c97d4eb7dfd23832471ac16dcab7c3fd876 100644 (file)
@@ -78,8 +78,8 @@ void SendtoApplyCB(FL_OBJECT *, long)
            return;
        }
     }
-    string fname = SpaceLess(ChangeExtension(buffer->getFileName(), 
-                                             ftypeext, true));
+
+    string fname = ChangeExtension(buffer->getLatexName(), ftypeext, true);
     if (!contains(command, "$$FName"))
         command = "( " + command + " ) <$$FName";
     command = subst(command, "$$FName", fname);
index a0225b519956c55404224f9ab87ef3674336c8b3..d044911f9c1c358f2ac556113043ca1805354f60 100644 (file)
@@ -3161,7 +3161,7 @@ int Buffer::runLaTeX()
        ProhibitInput();
 
        // get LaTeX-Filename
-       string name = SpaceLess(ChangeExtension (filename, ".tex", true));
+       string name = getLatexName();
 
        string path = OnlyPath(filename);
 
@@ -3224,9 +3224,10 @@ int Buffer::runLiterate()
        ProhibitInput();
 
        // get LaTeX-Filename
-       string name = SpaceLess(ChangeExtension (filename, ".tex", true));
+       string name = getLatexName();
         // get Literate-Filename
-        string lit_name = SpaceLess(ChangeExtension (filename, lyxrc->literate_extension, true));
+        string lit_name = ChangeExtension (getLatexName(), 
+                                          lyxrc->literate_extension, true);
 
        string path = OnlyPath(filename);
 
@@ -3292,9 +3293,10 @@ int Buffer::buildProgram()
         ProhibitInput();
  
         // get LaTeX-Filename
-        string name = SpaceLess(ChangeExtension (filename, ".tex", true));
+        string name = getLatexName();
         // get Literate-Filename
-        string lit_name = SpaceLess(ChangeExtension (filename, lyxrc->literate_extension, true));
+        string lit_name = ChangeExtension(getLatexName(), 
+                                         lyxrc->literate_extension, true);
  
         string path = OnlyPath(filename);
  
@@ -3362,7 +3364,7 @@ int Buffer::runChktex()
        ProhibitInput();
 
        // get LaTeX-Filename
-       string name = SpaceLess(ChangeExtension (filename, ".tex", true));
+       string name = getLatexName();
        string path = OnlyPath(filename);
 
        string org_path = path;
index 932fb61731d5a93781ba785336a5fca4602e63af..03dea1ae29aead681ae2a7c7375773c6bfc37c87 100644 (file)
@@ -32,6 +32,7 @@
 #include "bufferparams.h"
 #include "texrow.h"
 #include "lyxtext.h"
+#include "support/filetools.h"
 
 class LyXRC;
 class TeXErrors;
@@ -231,6 +232,11 @@ public:
        ///
        string getFileName() const { return filename; }
 
+       /// A transformed version of the file name, adequate for LaTeX  
+       string getLatexName() const {
+               return ChangeExtension(MakeLatexName(filename), ".tex", true); 
+       }
+
        /// Change name of buffer. Updates "read-only" flag.
        void setFileName(string const & newfile);
 
index 17dc46664a409d315259ec797e9b0fc23c3d19de..9e0882f2bb6a89c83f9cbb51da73cae70d823505 100644 (file)
@@ -557,7 +557,7 @@ bool RunScript(Buffer * buffer, bool wait,
                return false;
        /* get DVI-Filename */
        if (name.empty())
-               name = ChangeExtension(buffer->getFileName(),
+               name = ChangeExtension(buffer->getLatexName(),
                                       ".dvi", true);
 
        path = OnlyPath(name);
@@ -566,7 +566,8 @@ bool RunScript(Buffer * buffer, bool wait,
        }
        Path p(path);
 
-       cmd = command + ' ' + SpaceLess(name);
+       cmd = command + ' ' + QuoteName(name);
+
        Systemcalls one;
 
        if (need_shell) {
@@ -624,7 +625,7 @@ bool MenuRunDvips(Buffer * buffer, bool wait = false)
                return false;
         }
        // Generate postscript file
-       string ps = ChangeExtension (buffer->getFileName(),
+       string psname = ChangeExtension (buffer->getFileName(),
                                      ".ps_tmp", true);
 
        string paper;
@@ -661,7 +662,7 @@ bool MenuRunDvips(Buffer * buffer, bool wait = false)
 
        // Make postscript file.
        string command = "dvips " + lyxrc->print_to_file + ' ';
-       command += SpaceLess(ps);
+       command += QuoteName(psname);
        if (buffer->params.use_geometry
            && buffer->params.papersize2 == BufferParams::VM_PAPER_CUSTOM
            && !lyxrc->print_paper_dimension_flag.empty()
@@ -815,9 +816,7 @@ void MenuMakeLaTeX(Buffer * buffer)
 {
        if (buffer->text) {
                // Get LaTeX-Filename
-               string s = SpaceLess(ChangeExtension(
-                                               buffer->getFileName(),
-                                               ".tex", false));
+         string s = buffer->getLatexName();
 
                FileInfo fi(s);
                if (fi.readable() &&
@@ -3314,7 +3313,7 @@ extern "C" void PrintApplyCB(FL_OBJECT *, long)
        if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
                orientationflag = lyxrc->print_landscape_flag + ' ';
    
-       string ps_file = SpaceLess(fl_get_input(fd_form_print->input_file));
+       string ps_file = fl_get_input(fd_form_print->input_file);
        string printer = strip(fl_get_input(fd_form_print->input_printer));
 
        string printerflag;
@@ -3378,12 +3377,11 @@ extern "C" void PrintApplyCB(FL_OBJECT *, long)
                command += " " + lyxrc->print_paper_flag + " " + paper + " ";
        }
        if (fl_get_button(fd_form_print->radio_file))
-               command += lyxrc->print_to_file + '\"'
-                       + MakeAbsPath(ps_file, path)
-                       + '\"';
+               command += lyxrc->print_to_file 
+                          + QuoteName(MakeAbsPath(ps_file, path));
        else if (!lyxrc->print_spool_command.empty())
                command += lyxrc->print_to_file 
-                       + '\"' + ps_file + '\"';
+                       + QuoteName(ps_file);
        
        // push directorypath, if necessary 
         if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
index 86d7345070093297a90497ded4b4dc17a61dda51..b18ceb47f9b30b0ab80a2a749ac20cf09feec53a 100644 (file)
@@ -398,30 +398,32 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
         if (disable)
                 flag |= LyXFunc::Disabled;
 
-       func_status box = LyXFunc::ToggleOff;
-       LyXFont font = buf->text->real_current_font;
-       switch (action) {
-       case LFUN_EMPH:
-               if (font.emph() == LyXFont::ON)
-                       box = LyXFunc::ToggleOn;
-               break;
-       case LFUN_NOUN:
-               if (font.noun() == LyXFont::ON)
-                       box = LyXFunc::ToggleOn;
-               break;
-       case LFUN_BOLD:
-               if (font.series() == LyXFont::BOLD_SERIES)
-                       box = LyXFunc::ToggleOn;
-               break;
-       case LFUN_TEX:
-               if (font.latex() == LyXFont::ON)
-                       box = LyXFunc::ToggleOn;
-               break;
-       default:
-               box = LyXFunc::OK;
-               break;
+       if (buf) {
+               func_status box = LyXFunc::ToggleOff;
+               LyXFont font = buf->text->real_current_font;
+               switch (action) {
+               case LFUN_EMPH:
+                       if (font.emph() == LyXFont::ON)
+                               box = LyXFunc::ToggleOn;
+                       break;
+               case LFUN_NOUN:
+                       if (font.noun() == LyXFont::ON)
+                               box = LyXFunc::ToggleOn;
+                       break;
+               case LFUN_BOLD:
+                       if (font.series() == LyXFont::BOLD_SERIES)
+                               box = LyXFunc::ToggleOn;
+                       break;
+               case LFUN_TEX:
+                       if (font.latex() == LyXFont::ON)
+                               box = LyXFunc::ToggleOn;
+                       break;
+               default:
+                       box = LyXFunc::OK;
+                       break;
+               }
+               flag |= box;
        }
-       flag |= box;
 
 
        return flag;
@@ -801,9 +803,9 @@ string LyXFunc::Dispatch(int ac,
                        // latex, but the html file name can be
                        // anything.
                        string result = ChangeExtension(file, ".html", false);
-                       file = ChangeExtension(SpaceLess(file), ".tex", false);
+                       string infile = owner->buffer()->getLatexName();
                        string tmp = lyxrc->html_command;
-                       tmp = subst(tmp, "$$FName", file);
+                       tmp = subst(tmp, "$$FName", infile);
                        tmp = subst(tmp, "$$OutName", result);
                        Systemcalls one;
                        int res = one.startscript(Systemcalls::System, tmp);
@@ -812,7 +814,7 @@ string LyXFunc::Dispatch(int ac,
                                           + MakeDisplayPath(result) +'\'');
                        } else {
                                setErrorMessage(N_("Unable to convert to HTML the file `")
-                                               + MakeDisplayPath(file) 
+                                               + MakeDisplayPath(infile) 
                                                + '\'');
                        }
                }
index e29bbcdd02eba81e37ace3281cdf6753aa687057..28268b7258adc472e6b3d8d00bbd04199cb2cf65 100644 (file)
@@ -26,6 +26,7 @@ using std::pair;
 #endif
 
 #include "filetools.h"
+#include "LSubstring.h"
 #include "lyx_gui_misc.h"
 #include "FileInfo.h"
 #include "support/path.h"        // I know it's OS/2 specific (SMiyata)
@@ -70,7 +71,7 @@ bool IsSGMLFilename(string const & filename)
 
 
 // Substitutes spaces with underscores in filename (and path)
-string SpaceLess(string const & file)
+string MakeLatexName(string const & file)
 {
        string name = OnlyFilename(file);
        string path = OnlyPath(file);
@@ -91,6 +92,18 @@ string SpaceLess(string const & file)
        return AddName(path, name);
 }
 
+// Substitutes spaces with underscores in filename (and path)
+string QuoteName(string const & name)
+{
+#ifdef WITH_WARNINGS
+#warning Add proper emx support here!
+#endif
+       string qname = name;
+       while (qname.find("'") != string::npos) 
+         LSubstring(qname,"'") = "\\'";
+       return '\'' + qname + '\'';
+}
+
 
 /// Returns an unique name to be used as a temporary file. 
 string TmpFileName(string const & dir, string const & mask)
index 84ec94a9e30aa9c1ebf60fea033e668c2d789d5e..72752f1a15ac00bb8d970b10395eaefcac19b2c2 100644 (file)
@@ -208,8 +208,11 @@ bool PutEnv(string const & envstr);
 ///
 bool PutEnvPath(string const & envstr);
 
-/// Substitutes spaces with underscores in filename (and path)
-string SpaceLess(string const & file);
+/// Substitutes active latex characters with underscores in filename
+string MakeLatexName(string const & file);
+
+/// Put the name in quotes suitable for the current shell
+string QuoteName(string const & file);
 
 /** Returns an unique name to be used as a temporary file. If given,
   'mask' should the prefix to the temporary file, the rest of the