Nuked the SpaceLess function. Read ChangeLog.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@349 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 1999-12-03 13:51:01 +00:00
parent ec7a8ffeba
commit 136367d229
9 changed files with 107 additions and 55 deletions

View File

@ -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. * images/sqrt.xpm: change name of the sqrt icon to sqrt_xpm.
* src/mathed/math_panel.C (mathed_get_pixmap_from_icon): ditto * src/mathed/math_panel.C (mathed_get_pixmap_from_icon): ditto
@ -11,7 +38,7 @@
few "using". few "using".
* src/bmtable.C (fl_set_bmtable_data): add a const_cast. * src/bmtable.C (fl_set_bmtable_data): add a const_cast.
1999-12-01 Lars Gullik Bjønnes <larsbj@lyx.org> 1999-12-01 Lars Gullik Bjønnes <larsbj@lyx.org>
* src/mathed/formula.C (LocalDispatch): fix small whitspace bug * src/mathed/formula.C (LocalDispatch): fix small whitspace bug

View File

@ -22,11 +22,12 @@ void ShowLatexLog()
bool use_build = false; bool use_build = false;
static int ow = -1, oh; static int ow = -1, oh;
filename = current_view->buffer()->getFileName(); filename = current_view->buffer()->getLatexName();
if (!filename.empty()) { if (!filename.empty()) {
fname = SpaceLess(ChangeExtension(filename, ".log", true)); fname = ChangeExtension(filename, ".log", true);
bname = SpaceLess(ChangeExtension(filename, bname = ChangeExtension(filename,
lyxrc->literate_extension + ".out", true)); lyxrc->literate_extension + ".out",
true);
path = OnlyPath(filename); path = OnlyPath(filename);
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) { if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
path = current_view->buffer()->tmppath; path = current_view->buffer()->tmppath;

View File

@ -78,8 +78,8 @@ void SendtoApplyCB(FL_OBJECT *, long)
return; return;
} }
} }
string fname = SpaceLess(ChangeExtension(buffer->getFileName(),
ftypeext, true)); string fname = ChangeExtension(buffer->getLatexName(), ftypeext, true);
if (!contains(command, "$$FName")) if (!contains(command, "$$FName"))
command = "( " + command + " ) <$$FName"; command = "( " + command + " ) <$$FName";
command = subst(command, "$$FName", fname); command = subst(command, "$$FName", fname);

View File

@ -3161,7 +3161,7 @@ int Buffer::runLaTeX()
ProhibitInput(); ProhibitInput();
// get LaTeX-Filename // get LaTeX-Filename
string name = SpaceLess(ChangeExtension (filename, ".tex", true)); string name = getLatexName();
string path = OnlyPath(filename); string path = OnlyPath(filename);
@ -3224,9 +3224,10 @@ int Buffer::runLiterate()
ProhibitInput(); ProhibitInput();
// get LaTeX-Filename // get LaTeX-Filename
string name = SpaceLess(ChangeExtension (filename, ".tex", true)); string name = getLatexName();
// get Literate-Filename // 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); string path = OnlyPath(filename);
@ -3292,9 +3293,10 @@ int Buffer::buildProgram()
ProhibitInput(); ProhibitInput();
// get LaTeX-Filename // get LaTeX-Filename
string name = SpaceLess(ChangeExtension (filename, ".tex", true)); string name = getLatexName();
// get Literate-Filename // 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); string path = OnlyPath(filename);
@ -3362,7 +3364,7 @@ int Buffer::runChktex()
ProhibitInput(); ProhibitInput();
// get LaTeX-Filename // get LaTeX-Filename
string name = SpaceLess(ChangeExtension (filename, ".tex", true)); string name = getLatexName();
string path = OnlyPath(filename); string path = OnlyPath(filename);
string org_path = path; string org_path = path;

View File

@ -32,6 +32,7 @@
#include "bufferparams.h" #include "bufferparams.h"
#include "texrow.h" #include "texrow.h"
#include "lyxtext.h" #include "lyxtext.h"
#include "support/filetools.h"
class LyXRC; class LyXRC;
class TeXErrors; class TeXErrors;
@ -231,6 +232,11 @@ public:
/// ///
string getFileName() const { return filename; } 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. /// Change name of buffer. Updates "read-only" flag.
void setFileName(string const & newfile); void setFileName(string const & newfile);

View File

@ -557,7 +557,7 @@ bool RunScript(Buffer * buffer, bool wait,
return false; return false;
/* get DVI-Filename */ /* get DVI-Filename */
if (name.empty()) if (name.empty())
name = ChangeExtension(buffer->getFileName(), name = ChangeExtension(buffer->getLatexName(),
".dvi", true); ".dvi", true);
path = OnlyPath(name); path = OnlyPath(name);
@ -566,7 +566,8 @@ bool RunScript(Buffer * buffer, bool wait,
} }
Path p(path); Path p(path);
cmd = command + ' ' + SpaceLess(name); cmd = command + ' ' + QuoteName(name);
Systemcalls one; Systemcalls one;
if (need_shell) { if (need_shell) {
@ -624,7 +625,7 @@ bool MenuRunDvips(Buffer * buffer, bool wait = false)
return false; return false;
} }
// Generate postscript file // Generate postscript file
string ps = ChangeExtension (buffer->getFileName(), string psname = ChangeExtension (buffer->getFileName(),
".ps_tmp", true); ".ps_tmp", true);
string paper; string paper;
@ -661,7 +662,7 @@ bool MenuRunDvips(Buffer * buffer, bool wait = false)
// Make postscript file. // Make postscript file.
string command = "dvips " + lyxrc->print_to_file + ' '; string command = "dvips " + lyxrc->print_to_file + ' ';
command += SpaceLess(ps); command += QuoteName(psname);
if (buffer->params.use_geometry if (buffer->params.use_geometry
&& buffer->params.papersize2 == BufferParams::VM_PAPER_CUSTOM && buffer->params.papersize2 == BufferParams::VM_PAPER_CUSTOM
&& !lyxrc->print_paper_dimension_flag.empty() && !lyxrc->print_paper_dimension_flag.empty()
@ -815,9 +816,7 @@ void MenuMakeLaTeX(Buffer * buffer)
{ {
if (buffer->text) { if (buffer->text) {
// Get LaTeX-Filename // Get LaTeX-Filename
string s = SpaceLess(ChangeExtension( string s = buffer->getLatexName();
buffer->getFileName(),
".tex", false));
FileInfo fi(s); FileInfo fi(s);
if (fi.readable() && if (fi.readable() &&
@ -3314,7 +3313,7 @@ extern "C" void PrintApplyCB(FL_OBJECT *, long)
if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE) if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
orientationflag = lyxrc->print_landscape_flag + ' '; 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 printer = strip(fl_get_input(fd_form_print->input_printer));
string printerflag; string printerflag;
@ -3378,12 +3377,11 @@ extern "C" void PrintApplyCB(FL_OBJECT *, long)
command += " " + lyxrc->print_paper_flag + " " + paper + " "; command += " " + lyxrc->print_paper_flag + " " + paper + " ";
} }
if (fl_get_button(fd_form_print->radio_file)) if (fl_get_button(fd_form_print->radio_file))
command += lyxrc->print_to_file + '\"' command += lyxrc->print_to_file
+ MakeAbsPath(ps_file, path) + QuoteName(MakeAbsPath(ps_file, path));
+ '\"';
else if (!lyxrc->print_spool_command.empty()) else if (!lyxrc->print_spool_command.empty())
command += lyxrc->print_to_file command += lyxrc->print_to_file
+ '\"' + ps_file + '\"'; + QuoteName(ps_file);
// push directorypath, if necessary // push directorypath, if necessary
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){ if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){

View File

@ -398,30 +398,32 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
if (disable) if (disable)
flag |= LyXFunc::Disabled; flag |= LyXFunc::Disabled;
func_status box = LyXFunc::ToggleOff; if (buf) {
LyXFont font = buf->text->real_current_font; func_status box = LyXFunc::ToggleOff;
switch (action) { LyXFont font = buf->text->real_current_font;
case LFUN_EMPH: switch (action) {
if (font.emph() == LyXFont::ON) case LFUN_EMPH:
box = LyXFunc::ToggleOn; if (font.emph() == LyXFont::ON)
break; box = LyXFunc::ToggleOn;
case LFUN_NOUN: break;
if (font.noun() == LyXFont::ON) case LFUN_NOUN:
box = LyXFunc::ToggleOn; if (font.noun() == LyXFont::ON)
break; box = LyXFunc::ToggleOn;
case LFUN_BOLD: break;
if (font.series() == LyXFont::BOLD_SERIES) case LFUN_BOLD:
box = LyXFunc::ToggleOn; if (font.series() == LyXFont::BOLD_SERIES)
break; box = LyXFunc::ToggleOn;
case LFUN_TEX: break;
if (font.latex() == LyXFont::ON) case LFUN_TEX:
box = LyXFunc::ToggleOn; if (font.latex() == LyXFont::ON)
break; box = LyXFunc::ToggleOn;
default: break;
box = LyXFunc::OK; default:
break; box = LyXFunc::OK;
break;
}
flag |= box;
} }
flag |= box;
return flag; return flag;
@ -801,9 +803,9 @@ string LyXFunc::Dispatch(int ac,
// latex, but the html file name can be // latex, but the html file name can be
// anything. // anything.
string result = ChangeExtension(file, ".html", false); string result = ChangeExtension(file, ".html", false);
file = ChangeExtension(SpaceLess(file), ".tex", false); string infile = owner->buffer()->getLatexName();
string tmp = lyxrc->html_command; string tmp = lyxrc->html_command;
tmp = subst(tmp, "$$FName", file); tmp = subst(tmp, "$$FName", infile);
tmp = subst(tmp, "$$OutName", result); tmp = subst(tmp, "$$OutName", result);
Systemcalls one; Systemcalls one;
int res = one.startscript(Systemcalls::System, tmp); int res = one.startscript(Systemcalls::System, tmp);
@ -812,7 +814,7 @@ string LyXFunc::Dispatch(int ac,
+ MakeDisplayPath(result) +'\''); + MakeDisplayPath(result) +'\'');
} else { } else {
setErrorMessage(N_("Unable to convert to HTML the file `") setErrorMessage(N_("Unable to convert to HTML the file `")
+ MakeDisplayPath(file) + MakeDisplayPath(infile)
+ '\''); + '\'');
} }
} }

View File

@ -26,6 +26,7 @@ using std::pair;
#endif #endif
#include "filetools.h" #include "filetools.h"
#include "LSubstring.h"
#include "lyx_gui_misc.h" #include "lyx_gui_misc.h"
#include "FileInfo.h" #include "FileInfo.h"
#include "support/path.h" // I know it's OS/2 specific (SMiyata) #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) // Substitutes spaces with underscores in filename (and path)
string SpaceLess(string const & file) string MakeLatexName(string const & file)
{ {
string name = OnlyFilename(file); string name = OnlyFilename(file);
string path = OnlyPath(file); string path = OnlyPath(file);
@ -91,6 +92,18 @@ string SpaceLess(string const & file)
return AddName(path, name); 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. /// Returns an unique name to be used as a temporary file.
string TmpFileName(string const & dir, string const & mask) string TmpFileName(string const & dir, string const & mask)

View File

@ -208,8 +208,11 @@ bool PutEnv(string const & envstr);
/// ///
bool PutEnvPath(string const & envstr); bool PutEnvPath(string const & envstr);
/// Substitutes spaces with underscores in filename (and path) /// Substitutes active latex characters with underscores in filename
string SpaceLess(string const & file); 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, /** 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 'mask' should the prefix to the temporary file, the rest of the