Fix / remove some final todos.
[matthijs/master-project/report.git] / pret-trans.lua
index 212c835ace52d0c7b026fc606dca6d336cba5ba1..a0ae9c2c73747ae99650e63d6f87f19b6d14c591 100644 (file)
@@ -14,13 +14,14 @@ local vis = buffers.newvisualizer("trans")
 local commands = {}
 -- A command to create a horizontal rule.
 commands.rule = "\\HLine[width=.40 * \\the\\textwidth]"
 local commands = {}
 -- A command to create a horizontal rule.
 commands.rule = "\\HLine[width=.40 * \\the\\textwidth]"
--- Pretty printer to use for the stuff before and after the line
-commands.before_pret = "lam"
-commands.after_pret = "lam"
+-- Typing environment to use for the stuff before and after the line. Will be
+-- prefixed with \start and \stop automatically.
+commands.beforeenv = "unboxedlambda"
+commands.afterenv = "unboxedlambda"
 -- Frame commands to use for the left (before + line + after) and right
 -- (conditions) parts. Should include an opening {, which will be closed
 -- automatically.
 -- Frame commands to use for the left (before + line + after) and right
 -- (conditions) parts. Should include an opening {, which will be closed
 -- automatically.
-commands.leftframe = "\\framed[offset=0mm,location=middle,strut=no,align=right,frame=off,width=.48\\textwidth]{\\sans"
+commands.leftframe = "\\framed[offset=0mm,location=middle,strut=no,align=right,frame=off,width=.48\\textwidth]{"
 commands.rightframe = "\\framed[offset=0mm,location=middle,strut=no,align=right,frame=off,width=.48\\textwidth]{"
 
 -- A table to keep the lines in this buffer, so we can process them all at
 commands.rightframe = "\\framed[offset=0mm,location=middle,strut=no,align=right,frame=off,width=.48\\textwidth]{"
 
 -- A table to keep the lines in this buffer, so we can process them all at
@@ -63,9 +64,6 @@ end
 -- Capture all lines, without generating any output
 function vis.begin_of_display()
     lines = {}
 -- Capture all lines, without generating any output
 function vis.begin_of_display()
     lines = {}
-    -- Let all the lambda pretty printing in this buffer use shared subscript
-    -- detection
-    buffers.visualizers.handlers.lam.begin_of_block()
 end
 function vis.begin_of_line(n)
     -- Don't generate output here
 end
 function vis.begin_of_line(n)
     -- Don't generate output here
@@ -128,17 +126,29 @@ function vis.end_of_display()
     -- Real output starts here
     --
 
     -- Real output starts here
     --
 
+    -- Let all the lambda pretty printing in this buffer use shared subscript
+    -- detection
+    tex.sprint("\\directlua{buffers.visualizers.handlers.lam.begin_of_block()}")
+
     -- Ensure the left and right frames end up next to each other.
     tex.sprint("\\dontleavehmode")
 
     -- Open and fill the left frame
     tex.sprint(commands.leftframe)
 
     -- Ensure the left and right frames end up next to each other.
     tex.sprint("\\dontleavehmode")
 
     -- Open and fill the left frame
     tex.sprint(commands.leftframe)
 
-    prettyprint('lam', before)
+    tex.sprint("\\start" .. commands.beforeenv)
+
+    tex.sprint(table.concat(before, "\n"))
+
+    tex.sprint("\\stop" .. commands.beforeenv)
 
     tex.sprint(commands.rule)
 
 
     tex.sprint(commands.rule)
 
-    prettyprint('lam', after)
+    tex.sprint("\\start" .. commands.afterenv)
+
+    tex.sprint(table.concat(after, "\n"))
+
+    tex.sprint("\\stop" .. commands.afterenv)
 
     -- Close the left frame
     tex.sprint("}")
 
     -- Close the left frame
     tex.sprint("}")
@@ -165,10 +175,11 @@ function vis.end_of_display()
 
     -- Close the right frame 
     tex.sprint("}")
 
     -- Close the right frame 
     tex.sprint("}")
+
+    tex.sprint("\\directlua{buffers.visualizers.handlers.lam.end_of_block()}")
     
     -- Clean up
     lines = {}
     
     -- Clean up
     lines = {}
-    buffers.visualizers.handlers.lam.end_of_block()
 end
 
 -- vim: set sw=4 sts=4 expandtab ai:
 end
 
 -- vim: set sw=4 sts=4 expandtab ai: