]> git.lyx.org Git - features.git/commitdiff
tex2lyx/text.cpp: support for the commands \fboxsep etc.
authorUwe Stöhr <uwestoehr@lyx.org>
Sun, 17 May 2015 22:56:23 +0000 (00:56 +0200)
committerUwe Stöhr <uwestoehr@lyx.org>
Sun, 17 May 2015 22:56:23 +0000 (00:56 +0200)
It is impossible handle all cases because the closing brace of an \fboxsep block can be everywhere. Therefore the braces remain in ERT.

src/tex2lyx/test/box-color-size-space-align.tex
src/tex2lyx/text.cpp

index ab658c62c29d98c19db0ff0e5876688d4d16f2c5..b004eedbbddc7721f2e57f0556f93044cac1fd81 100644 (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}
index 2ed73959bd6402d2ab3e5fa73f3b497115aa4caa..9f1dd5d9b0a564635e9473e8368eeb90772f333a 100644 (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") {