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.
* 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

View 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;

View 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);

View 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;

View 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);

View 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)){

View 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)
+ '\'');
}
}

View 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)

View 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