Improved appearence of regexp insets (at least I hope so), also suggested in #6498 (Regex looks like math).

- 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
This commit is contained in:
Tommaso Cucinotta 2010-02-05 09:00:40 +00:00
parent d652a84f4b
commit 9e057e7533
3 changed files with 24 additions and 1 deletions

View File

@ -241,6 +241,7 @@ ColorSet::ColorSet()
{ Color_buttonhoverbg, N_("button background under focus"), "buttonhoverbg", "#C7C7CA", "buttonhoverbg" }, { Color_buttonhoverbg, N_("button background under focus"), "buttonhoverbg", "#C7C7CA", "buttonhoverbg" },
{ Color_paragraphmarker, N_("paragraph marker"), "paragraphmarker", grey80, "paragraphmarker"}, { Color_paragraphmarker, N_("paragraph marker"), "paragraphmarker", grey80, "paragraphmarker"},
{ Color_inherit, N_("inherit"), "inherit", "black", "inherit" }, { Color_inherit, N_("inherit"), "inherit", "black", "inherit" },
{ Color_regexpframe, N_("regexp frame"), "regexpframe", "green", "regexpframe" },
{ Color_ignore, N_("ignore"), "ignore", "black", "ignore" }, { Color_ignore, N_("ignore"), "ignore", "black", "ignore" },
{ Color_ignore, 0, 0, 0, 0 } { Color_ignore, 0, 0, 0, 0 }
}; };

View File

@ -196,6 +196,8 @@ enum ColorCode
/// Color is inherited /// Color is inherited
Color_inherit, Color_inherit,
/// Color for regexp frame
Color_regexpframe,
/// For ignoring updates of a color /// For ignoring updates of a color
Color_ignore Color_ignore
}; };

View File

@ -312,7 +312,18 @@ int InsetMathHull::defaultColSpace(col_type col)
docstring InsetMathHull::standardFont() const 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); 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_) { if (use_preview_) {
// one pixel gap in front // one pixel gap in front
preview_->draw(pi, x + 1, y); preview_->draw(pi, x + 1, y);
@ -620,6 +636,10 @@ void InsetMathHull::validate(LaTeXFeatures & features) const
if (ams()) if (ams())
features.require("amsmath"); features.require("amsmath");
if (type_ == hullRegexp)
features.addPreambleSnippet(
"\\newcommand{\\regexp}[1]{\\fbox{\\texttt{#1}}}");
// Validation is necessary only if not using AMS math. // Validation is necessary only if not using AMS math.
// To be safe, we will always run mathedvalidate. // To be safe, we will always run mathedvalidate.
//if (features.amsstyle) //if (features.amsstyle)