From 360fa910df40934b12cd76a2f1b4627d73ac9e68 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 4 Nov 2009 10:58:19 +0100 Subject: [PATCH] Make pret-trans call pret-lam indirectly. Previously, the pret-lam functions were called directly from lua. Now, the pret-trans prettyprinter generates \startlambda commands so the pretty printer is called later. This means the start/end_of_block calls now also include the right part. --- Utils/Lambda.tex | 2 ++ pret-trans.lua | 31 +++++++++++++++++++++---------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/Utils/Lambda.tex b/Utils/Lambda.tex index fe1fb6f..4d9de33 100644 --- a/Utils/Lambda.tex +++ b/Utils/Lambda.tex @@ -61,6 +61,8 @@ draw b; \installprettytype [LAM] [LAM] % Define \startlambda \stoplambda \definetyping[lambda][option=LAM,style=sans,before=\startboxed,after=\stopboxed] +% Define \startunboxedlambda \stopunboxedlambda +\definetyping[unboxedlambda][option=LAM,style=sans] % Define \lam{} (since \lambda is taken) \definetype[lam][option=LAM,style=sans] diff --git a/pret-trans.lua b/pret-trans.lua index 062eceb..148d3ca 100644 --- a/pret-trans.lua +++ b/pret-trans.lua @@ -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]" --- 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. -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 @@ -66,9 +67,6 @@ end -- 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() min_indent = nil end function vis.begin_of_line(n) @@ -146,17 +144,29 @@ function vis.end_of_display() -- 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) - prettyprint('lam', before) + tex.sprint("\\start" .. commands.beforeenv) + + tex.sprint(table.concat(before, "\n")) + + tex.sprint("\\stop" .. commands.beforeenv) 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("}") @@ -183,10 +193,11 @@ function vis.end_of_display() -- Close the right frame tex.sprint("}") + + tex.sprint("\\directlua{buffers.visualizers.handlers.lam.end_of_block()}") -- Clean up lines = {} - buffers.visualizers.handlers.lam.end_of_block() end -- vim: set sw=4 sts=4 expandtab ai: -- 2.30.2