From: Enrico Forestieri Date: Sun, 26 Oct 2008 18:32:25 +0000 (+0000) Subject: The LaTeX control space "\ " is a special char, too. In mathed, it should X-Git-Tag: 1.6.10~2826 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=cb2933147cef7912db65b74285fd20c9a728de1e;p=features.git The LaTeX control space "\ " is a special char, too. In mathed, it should be represented on screen as a visible space rather than as an empty macro. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27140 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp index ffde2ad45f..63e368cb80 100644 --- a/src/mathed/InsetMathNest.cpp +++ b/src/mathed/InsetMathNest.cpp @@ -1593,7 +1593,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type c) } if (c == '{' || c == '}' || c == '&' || c == '$' || c == '#' || - c == '%' || c == '_') { + c == '%' || c == '_' || c == ' ') { cur.niceInsert(createInsetMath(docstring(1, c))); return true; } diff --git a/src/mathed/InsetMathSpecialChar.cpp b/src/mathed/InsetMathSpecialChar.cpp index 8282788110..926dde6e69 100644 --- a/src/mathed/InsetMathSpecialChar.cpp +++ b/src/mathed/InsetMathSpecialChar.cpp @@ -21,6 +21,7 @@ #include "TextPainter.h" #include "frontends/FontMetrics.h" +#include "frontends/Painter.h" #include "support/lassert.h" @@ -54,7 +55,11 @@ Inset * InsetMathSpecialChar::clone() const void InsetMathSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const { - if (mi.base.fontname == "mathnormal") { + if (char_ == ' ') { + dim.asc = 4; + dim.des = 0; + dim.wid = 10; + } else if (mi.base.fontname == "mathnormal") { ShapeChanger dummy(mi.base.font, UP_SHAPE); dim = theFontMetrics(mi.base.font).dimension(char_); } else { @@ -67,7 +72,18 @@ void InsetMathSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const void InsetMathSpecialChar::draw(PainterInfo & pi, int x, int y) const { - if (pi.base.fontname == "mathnormal") { + if (char_ == ' ') { + int xp[4]; + int yp[4]; + int w = 10; + + xp[0] = ++x; yp[0] = y - 3; + xp[1] = x; yp[1] = y; + xp[2] = x + w - 2; yp[2] = y; + xp[3] = x + w - 2; yp[3] = y - 3; + + pi.pain.lines(xp, yp, 4, Color_special); + } else if (pi.base.fontname == "mathnormal") { ShapeChanger dummy(pi.base.font, UP_SHAPE); pi.draw(x, y, char_); } else { diff --git a/src/mathed/MathFactory.cpp b/src/mathed/MathFactory.cpp index 50e3fb4cee..4c32281d83 100644 --- a/src/mathed/MathFactory.cpp +++ b/src/mathed/MathFactory.cpp @@ -227,7 +227,7 @@ bool isSpecialChar(docstring const & name) char_type const c = name.at(0); return c == '{' || c == '}' || c == '&' || c == '$' || - c == '#' || c == '%' || c == '_'; + c == '#' || c == '%' || c == '_' || c == ' '; }