Nicer previews.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5434 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2002-10-17 15:56:42 +00:00
parent b265e8fb05
commit 160b147186
3 changed files with 22 additions and 4 deletions

View File

@ -479,9 +479,7 @@ void PreviewLoader::Impl::startLoading()
string const command = "sh " + LibScriptSearch(cs.str().c_str());
// Initiate the conversion from LaTeX to bitmap images files.
Forkedcall::SignalTypePtr convert_ptr;
convert_ptr.reset(new Forkedcall::SignalType);
Forkedcall::SignalTypePtr convert_ptr(new Forkedcall::SignalType);
convert_ptr->connect(
boost::bind(&Impl::finishedGenerating, this, _1, _2, _3));

View File

@ -1,3 +1,8 @@
2002-10-17 Angus Leeming <leeming@lyx.org>
* formula.C (latexString): change "\[ ... \]" to "$ \displaystyle ... $"
for nicer previews.
2002-10-17 Dekel Tsur <dekelts@tau.ac.il>
* math_kerninset.C (metrics): Use LyXLength::inPixels.

View File

@ -330,5 +330,20 @@ string const InsetFormula::PreviewImpl::latexString() const
ostringstream ls;
WriteStream wi(ls, false, false);
parent().par_->write(wi);
return ls.str().c_str();
string str = ls.str().c_str();
// If we are in displaymode, the preview will include the margins
// on either side of the previewed equation.
// We can create an image with a tight bounding box by replacing the
// "\[ ... \]" delimiters with "$ \displaystyle ... $".
// Note that we have to get rid of any trailing '\n's for the fix
// to work.
if (prefixIs(str, "\\[")) {
std::cerr << "before\n" << str << std::endl;
str = rtrim(rtrim(ltrim(str, "\\["), "\n"), "\\]");
str = "$ \\displaystyle " + str + " $";
std::cerr << "after\n" << str << std::endl;
}
return str;
}