[prev in list] [next in list] [prev in thread] [next in thread]
List: lyx-cvs
Subject: [LyX/master] tex2lyx: support for glue lengths in InsetSpace
From: Uwe Stöhr <uwestoehr () lyx ! org>
Date: 2014-11-24 23:50:44
Message-ID: 20141124235044.1967028079E () lyx ! lyx ! org
[Download RAW message or body]
commit 1427b6fe316e257ce40512872c44cd438a51c498
Author: Uwe Stöhr <uwestoehr@lyx.org>
Date: Tue Nov 25 00:50:39 2014 +0100
tex2lyx: support for glue lengths in InsetSpace
diff --git a/src/tex2lyx/TODO.txt b/src/tex2lyx/TODO.txt
index 2196789..eb599bc 100644
--- a/src/tex2lyx/TODO.txt
+++ b/src/tex2lyx/TODO.txt
@@ -36,7 +36,6 @@ Format LaTeX feature LyX feature
358 custom makeindex command \index_command
363 horizontal longtable alignment InsetTabular
364 branch file name suffix \filename_suffix
-368 glue lengths InsetSpace
371 automatic mhchem loading \use_mhchem
375 \includeonly \{begin,end}_includeonly
376 update .aux of unincluded children \maintain_unincluded_children
diff --git a/src/tex2lyx/test/box-color-size-space-align.lyx.lyx \
b/src/tex2lyx/test/box-color-size-space-align.lyx.lyx index c8bef4e..5b41fab 100644
--- a/src/tex2lyx/test/box-color-size-space-align.lyx.lyx
+++ b/src/tex2lyx/test/box-color-size-space-align.lyx.lyx
@@ -1694,16 +1694,21 @@ in the middle. Lines can have a downbrace fill
\end_inset
-in the middle. Lines can have absolute space
+in the middle. Lines can have an absolute space
\begin_inset space \hspace{}
\length 2cm
\end_inset
- in the middle. Lines can have relative space
+ in the middle. Lines can have a relative space
\begin_inset space \hspace{}
\length 12text%
\end_inset
+ in the middle. Lines can have a glue-length space
+\begin_inset space \hspace{}
+\length 2cm+2mm-1mm
+\end_inset
+
in the middle. Lines can have protected space
\begin_inset space \hspace*{}
\length 2cm
@@ -2011,14 +2016,18 @@ in the middle. Lines can have a vfill
\begin_inset VSpace vfill*
\end_inset
- in the middle. Lines can have vertical absolute space
+ in the middle. Lines can have a vertical absolute space
\begin_inset VSpace 2cm
\end_inset
- in the middle. Lines can have vertical relative space
+ in the middle. Lines can have a vertical relative space
\begin_inset VSpace 9col%
\end_inset
+ in the middle. Lines can have a vertical glue-length space
+\begin_inset VSpace 2cm-2bp+1cc
+\end_inset
+
in the middle. Lines can have protected vertical space
\begin_inset VSpace 2cm*
\end_inset
diff --git a/src/tex2lyx/test/box-color-size-space-align.tex \
b/src/tex2lyx/test/box-color-size-space-align.tex index 009fcc0..7bff4bd 100644
--- a/src/tex2lyx/test/box-color-size-space-align.tex
+++ b/src/tex2lyx/test/box-color-size-space-align.tex
@@ -357,8 +357,9 @@ Lines can have a left arrow fill \leftarrowfill in the middle.
Lines can have a right arrow fill \rightarrowfill in the middle.
Lines can have a upbrace fill \upbracefill in the middle.
Lines can have a downbrace fill \downbracefill in the middle.
-Lines can have absolute space \hspace{2cm} in the middle.
-Lines can have relative space \hspace{0.12\textwidth} in the middle.
+Lines can have an absolute space \hspace{2cm} in the middle.
+Lines can have a relative space \hspace{0.12\textwidth} in the middle.
+Lines can have a glue-length space \hspace{2cm plus 2mm minus 1mm} in the middle.
Lines can have protected space \hspace*{2cm} in the middle.
We also handle defined spaces:
@@ -422,8 +423,9 @@ interword: $a\ b$
Lines can have a vfill \vfill in the middle.
Lines can have a vfill \vspace{\fill} in the middle.
Lines can have a protected vfill \vspace*{\fill} in the middle.
-Lines can have vertical absolute space \vspace{2cm} in the middle.
-Lines can have vertical relative space \vspace{0.09\columnwidth} in the middle.
+Lines can have a vertical absolute space \vspace{2cm} in the middle.
+Lines can have a vertical relative space \vspace{0.09\columnwidth} in the middle.
+Lines can have a vertical glue-length space \vspace{2cm minus 2bp plus 1cc} in the \
middle. Lines can have protected vertical space \vspace*{2cm} in the middle.
We also handle skips:
diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index 36efcae..ed4fd0d 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -4408,7 +4408,27 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool \
outer, }
}
- if (t.cs()[0] == 'h' && (known_unit || known_hspace)) {
+ // check for glue lengths
+ bool is_gluelength = false;
+ string gluelength = length;
+ string::size_type i = length.find(" minus");
+ if (i == string::npos) {
+ i = length.find(" plus");
+ if (i != string::npos)
+ is_gluelength = true;
+ } else
+ is_gluelength = true;
+ // if yes transform "9xx minus 8yy plus 7zz"
+ if (is_gluelength) {
+ i = gluelength.find(" minus");
+ if (i != string::npos)
+ gluelength.replace(i, 7, "-");
+ i = gluelength.find(" plus");
+ if (i != string::npos)
+ gluelength.replace(i, 6, "+");
+ }
+
+ if (t.cs()[0] == 'h' && (known_unit || known_hspace || is_gluelength)) {
// Literal horizontal length or known variable
context.check_layout(os);
begin_inset(os, "space ");
@@ -4420,10 +4440,11 @@ void parse_text(Parser & p, ostream & os, unsigned flags, \
bool outer, os << unit;
os << "}";
if (known_unit && !known_hspace)
- os << "\n\\length "
- << translate_len(length);
+ os << "\n\\length " << translate_len(length);
+ if (is_gluelength)
+ os << "\n\\length " << gluelength;
end_inset(os);
- } else if (known_unit || known_vspace) {
+ } else if (known_unit || known_vspace || is_gluelength) {
// Literal vertical length or known variable
context.check_layout(os);
begin_inset(os, "VSpace ");
@@ -4431,6 +4452,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool \
outer, os << unit;
if (known_unit && !known_vspace)
os << translate_len(length);
+ if (is_gluelength)
+ os << gluelength;
if (starred)
os << '*';
end_inset(os);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic