Attached is a simple patch that adds support for the verbatim* environment. Simple, because we already have all we need, even the lyx2lyx routine (I took it from LyX 2.1)

When we implemented support for verbatim, I simply forgot that there is also a starred version:
http://www.lyx.org/trac/ticket/9013

OK to go in or do you think that LyX should not support verbatim* or that it should support it, but should show the visible space also in within LyX? If you vote for the latter, then we will have to postpone because this needs then also to be implemented for the visible space option in listings.

thanks and regards
Uwe
 lib/layouts/stdlayouts.inc |  5 ++++
 lib/lyx2lyx/lyx_2_2.py     | 67 +++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 71 insertions(+), 1 deletion(-)

diff --git a/lib/layouts/stdlayouts.inc b/lib/layouts/stdlayouts.inc
index f8367eb..4612cbd 100644
--- a/lib/layouts/stdlayouts.inc
+++ b/lib/layouts/stdlayouts.inc
@@ -95,3 +95,8 @@ Style Verbatim
        HTMLItem              p
 End
 
+
+Style Verbatim*
+       CopyStyle             Verbatim
+       LatexName             verbatim*
+End
diff --git a/lib/lyx2lyx/lyx_2_2.py b/lib/lyx2lyx/lyx_2_2.py
index e4d5387..2401247 100644
--- a/lib/lyx2lyx/lyx_2_2.py
+++ b/lib/lyx2lyx/lyx_2_2.py
@@ -2156,6 +2156,71 @@ def revert_solution(document):
         i = j
 
 
+def revert_verbatim(document):
+    " Revert verbatim* einvironments completely to TeX-code. "
+    i = 0
+    consecutive = False
+    subst_end = ['\end_layout', '', '\\begin_layout Plain Layout',
+                '\end_layout', '',
+                 '\\begin_layout Plain Layout', '', '',
+                 '\\backslash', '',
+                 'end{verbatim*}',
+                 '\\end_layout', '', '\\end_inset',
+                 '', '', '\\end_layout']
+    subst_begin = ['\\begin_layout Standard', '\\noindent',
+                   '\\begin_inset ERT', 'status open', '',
+                   '\\begin_layout Plain Layout', '', '', '\\backslash',
+                   'begin{verbatim*}',
+                   '\\end_layout', '', '\\begin_layout Plain Layout', '']
+
+    while 1:
+        i = find_token(document.body, "\\begin_layout Verbatim*", i)
+        if i == -1:
+            return
+        j = find_end_of_layout(document.body, i)
+        if j == -1:
+            document.warning("Malformed LyX document: Can't find end of 
Verbatim layout")
+            i += 1
+            continue
+        # delete all line breaks insets (there are no other insets)
+        l = i
+        while 1:
+            n = find_token(document.body, "\\begin_inset Newline newline", l, 
j)
+            if n == -1:
+                n = find_token(document.body, "\\begin_inset Newline 
linebreak", l, j)
+                if n == -1:
+                    break
+            m = find_end_of_inset(document.body, n)
+            del(document.body[m:m+1])
+            document.body[n:n+1] = ['\end_layout', '', '\\begin_layout Plain 
Layout']
+            l += 1
+            # we deleted a line, so the end of the inset moved forward.
+            j -= 1
+        # consecutive verbatim environments need to be connected
+        k = find_token(document.body, "\\begin_layout Verbatim", j)
+        if k == j + 2 and consecutive == False:
+            consecutive = True
+            document.body[j:j+1] = ['\end_layout', '', '\\begin_layout Plain 
Layout']
+            document.body[i:i+1] = subst_begin
+            continue
+        if k == j + 2 and consecutive == True:
+            document.body[j:j+1] = ['\end_layout', '', '\\begin_layout Plain 
Layout']
+            del(document.body[i:i+1])
+            continue
+        if k != j + 2 and consecutive == True:
+            document.body[j:j+1] = subst_end
+            # the next paragraph must not be indented
+            document.body[j+19:j+19] = ['\\noindent']
+            del(document.body[i:i+1])
+            consecutive = False
+            continue
+        else:
+            document.body[j:j+1] = subst_end
+            # the next paragraph must not be indented
+            document.body[j+19:j+19] = ['\\noindent']
+            document.body[i:i+1] = subst_begin
+
+
 ##
 # Conversion hub
 #
@@ -2196,7 +2261,7 @@ convert = [
           ]
 
 revert =  [
-           [501, [revert_solution]],
+           [501, [revert_solution, revert_verbatim]],
            [500, [revert_fontsettings]],
            [499, [revert_achemso]],
            [498, [revert_moderncv_1, revert_moderncv_2]],

Reply via email to