]> git.lyx.org Git - features.git/commitdiff
Improved appearence of regexp insets (at least I hope so), also suggested in #6498...
authorTommaso Cucinotta <tommaso@lyx.org>
Fri, 5 Feb 2010 09:00:40 +0000 (09:00 +0000)
committerTommaso Cucinotta <tommaso@lyx.org>
Fri, 5 Feb 2010 09:00:40 +0000 (09:00 +0000)
- added a frame around regexp insets, with a customizable dedicated color code
- regexp insets font turned to texttt
- recovered back the preamble snippet allowing for latex compilation of regexp insets, something that happens if you have instant preview on.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33329 a592a061-630c-0410-9148-cb99ea01b6c8

src/Color.cpp
src/ColorCode.h
src/mathed/InsetMathHull.cpp

index 1b1f513862397c7f7d08138f1e25b7c7de028994..e71dd6e51b1dfefbf3978f1dfe374cfdb2da0a35 100644 (file)
@@ -241,6 +241,7 @@ ColorSet::ColorSet()
        { Color_buttonhoverbg, N_("button background under focus"), "buttonhoverbg", "#C7C7CA", "buttonhoverbg" },
        { Color_paragraphmarker, N_("paragraph marker"), "paragraphmarker", grey80, "paragraphmarker"},
        { Color_inherit, N_("inherit"), "inherit", "black", "inherit" },
+       { Color_regexpframe, N_("regexp frame"), "regexpframe", "green", "regexpframe" },
        { Color_ignore, N_("ignore"), "ignore", "black", "ignore" },
        { Color_ignore, 0, 0, 0, 0 }
        };
index d26f5535ca5003ffea32019d4c7d5cb6549fbac6..fff1a54aed5e6da6d24e6e3c3ad050a60bd66baf 100644 (file)
@@ -196,6 +196,8 @@ enum ColorCode
 
        /// Color is inherited
        Color_inherit,
+       /// Color for regexp frame
+       Color_regexpframe,
        /// For ignoring updates of a color
        Color_ignore
 };
index 003c3e0aaef8e2f8d743041a49bbf79394ee501e..f1891a1564491eda68e532ff7724317798dda2e3 100644 (file)
@@ -312,7 +312,18 @@ int InsetMathHull::defaultColSpace(col_type col)
 
 docstring InsetMathHull::standardFont() const
 {
-       return from_ascii(type_ == hullNone ? "lyxnochange" : "mathnormal");
+       const char *font_name;
+       switch (type_) {
+       case hullRegexp:
+               font_name = "texttt";
+               break;
+       case hullNone:
+               font_name = "lyxnochange";
+               break;
+       default:
+               font_name = "mathnormal";
+       }
+       return from_ascii(font_name);
 }
 
 
@@ -393,6 +404,11 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
 {
        use_preview_ = previewState(pi.base.bv);
 
+       if (type_ == hullRegexp) {
+               Dimension const dim = dimension(*pi.base.bv);
+               pi.pain.rectangle(x + 1, y - dim.ascent() + 1,
+                       dim.width() - 2, dim.height() - 2, Color_regexpframe);
+       }
        if (use_preview_) {
                // one pixel gap in front
                preview_->draw(pi, x + 1, y);
@@ -620,6 +636,10 @@ void InsetMathHull::validate(LaTeXFeatures & features) const
        if (ams())
                features.require("amsmath");
 
+       if (type_ == hullRegexp)
+               features.addPreambleSnippet(
+                       "\\newcommand{\\regexp}[1]{\\fbox{\\texttt{#1}}}");
+
        // Validation is necessary only if not using AMS math.
        // To be safe, we will always run mathedvalidate.
        //if (features.amsstyle)