tex2lyx/text.cpp: support for the commands \fboxsep etc.

It is impossible handle all cases because the closing brace of an \fboxsep block can be everywhere. Therefore the braces remain in ERT.
This commit is contained in:
Uwe Stöhr 2015-05-18 00:56:23 +02:00
parent 52a158b6d7
commit 5449a5b837
2 changed files with 61 additions and 2 deletions

View File

@ -157,6 +157,18 @@ blabla \doublebox{doublebox} blabla
$\boxed{\int A=B}$
\subsection{Boxes with custom settings}
\fboxsep 35pt
\framebox[1cm]{www}
\fboxsep 20pt \framebox[1cm]{www}
{\fboxsep 1pt \fboxrule 10pt \framebox[1cm]{www}}
{\fboxsep 35pt\shadowsize 15pt\shadowbox{\centering www}}
\subsection{Color Boxes}
\colorbox{blue}{www}

View File

@ -124,6 +124,9 @@ string parse_text_snippet(Parser & p, unsigned flags, const bool outer,
return os.str();
}
string fboxrule = "";
string fboxsep = "";
string shadow_size = "";
char const * const known_ref_commands[] = { "ref", "pageref", "vref",
"vpageref", "prettyref", "nameref", "eqref", 0 };
@ -849,8 +852,20 @@ void parse_box(Parser & p, ostream & os, unsigned outer_flags,
string latex_width;
string width_special = "none";
string thickness = "0.4pt";
string separation = "3pt";
string shadowsize = "4pt";
if (fboxrule != "")
thickness = fboxrule;
else
thickness = "0.4pt";
string separation;
if (fboxsep != "")
separation = fboxsep;
else
separation = "3pt";
string shadowsize;
if (shadow_size != "")
shadowsize = shadow_size;
else
shadowsize = "4pt";
string framecolor = "black";
string backgroundcolor = "none";
if (frame_color != "")
@ -1190,6 +1205,17 @@ void parse_box(Parser & p, ostream & os, unsigned outer_flags,
// in this case we have to eat the the closing brace of the color box
p.get_token().asInput(); // the '}'
}
if (p.next_token().asInput() == "}"
&& (fboxrule != "" || fboxsep != "" || shadow_size != "")) {
// in this case we assume that the closing brace is from the box settings
// therefore reset these values for the next box
if (fboxrule != "")
fboxrule = "";
if (fboxsep != "")
fboxsep = "";
if (shadow_size != "")
shadow_size = "";
}
}
@ -4206,6 +4232,27 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
parse_box(p, os, 0, 0, outer, context, "", "", "", "", backgroundcolor);
}
else if (t.cs() == "fboxrule" || t.cs() == "fboxsep"
|| t.cs() == "shadowsize") {
p.skip_spaces(true);
if (t.cs() == "fboxrule")
fboxrule = "";
if (t.cs() == "fboxsep")
fboxsep = "";
if (t.cs() == "shadowsize")
shadow_size = "";
while (p.good() && p.next_token().cat() != catSpace
&& p.next_token().cat() != catNewline
&& p.next_token().cat() != catEscape) {
if (t.cs() == "fboxrule")
fboxrule = fboxrule + p.get_token().asInput();
if (t.cs() == "fboxsep")
fboxsep = fboxsep + p.get_token().asInput();
if (t.cs() == "shadowsize")
shadow_size = shadow_size + p.get_token().asInput();
}
}
//\framebox() is part of the picture environment and different from \framebox{}
//\framebox{} will be parsed by parse_outer_box
else if (t.cs() == "framebox") {