summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/mtx-context-listing.tex
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2016-05-17 19:31:15 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2016-05-17 19:31:15 +0200
commit2017d30b4ca772c8eeac4fc0eb9b54e547a9a1d8 (patch)
treed96df31f305a095c078ea5fb9f639ca34ac36c12 /tex/context/base/mkiv/mtx-context-listing.tex
parent53ff76b73cd1f373ecdfb0f7f17df6f352621d6e (diff)
downloadcontext-2017d30b4ca772c8eeac4fc0eb9b54e547a9a1d8.tar.gz
2016-05-17 19:25:00
Diffstat (limited to 'tex/context/base/mkiv/mtx-context-listing.tex')
-rw-r--r--tex/context/base/mkiv/mtx-context-listing.tex138
1 files changed, 138 insertions, 0 deletions
diff --git a/tex/context/base/mkiv/mtx-context-listing.tex b/tex/context/base/mkiv/mtx-context-listing.tex
new file mode 100644
index 000000000..2deffd795
--- /dev/null
+++ b/tex/context/base/mkiv/mtx-context-listing.tex
@@ -0,0 +1,138 @@
+%D \module
+%D [ file=mtx-context-listing,
+%D version=2008.11.10, % about that time i started playing with this
+%D title=\CONTEXT\ Extra Trickry,
+%D subtitle=Listing Files,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This is a \TEXEXEC\ features that has been moved to \MKIV.
+
+% begin help
+%
+% usage: context --extra=listing [options] list-of-files
+%
+% --sort : sort filenames first
+% --topspace=dimension : distance above first line
+% --backspace=dimension : distance before left margin
+% --pretty : pretty print comform suffix
+% --scite : pretty print comform suffix using scite lexer
+% --bodyfont=list : additional bodyfont settings
+% --paperformat=spec : paper*print or paperxprint
+% --compact : small margins, 8pt font
+% --verycompact : small margins, 7pt font
+%
+% end help
+
+\input mtx-context-common.tex
+
+\doifdocumentargument {compact} {
+ \setdocumentargument{topspace} {5mm}
+ \setdocumentargument{backspace}{5mm}
+ \setdocumentargument{bodyfont} {8pt}
+}
+
+\doifdocumentargument {verycompact} {
+ \setdocumentargument{topspace} {5mm}
+ \setdocumentargument{backspace}{5mm}
+ \setdocumentargument{bodyfont} {7pt}
+}
+
+\setupbodyfont
+ [dejavu,11pt,tt,\getdocumentargument{bodyfont}] % dejavu is more complete
+
+\setuptyping
+ [lines=yes]
+
+\setuplayout
+ [header=0cm,
+ footer=1.5cm,
+ topspace=\getdocumentargumentdefault{topspace}{1.5cm},
+ backspace=\getdocumentargumentdefault{backspace}{1.5cm},
+ width=middle,
+ height=middle]
+
+\setuppapersize
+ [\getdocumentargument{paperformat_paper}]
+ [\getdocumentargument{paperformat_print}]
+
+% \startluacode
+% -- syntax check
+% local topspace = dimen(document.arguments.topspace or 0)
+% local backspace = dimen(document.arguments.backspace or 0)
+% local zeropoint = dimen(0)
+% if topspace > zeropoint then
+% context.setuplayout { topspace = tostring(topspace) }
+% end
+% if backspace > zeropoint then
+% context.setuplayout { backspace = tostring(backspace) }
+% end
+% \stopluacode
+
+\starttext
+
+\startluacode
+ local types = {
+ mkiv = "tex",
+ mkii = "tex",
+ cld = "lua",
+ lfg = "lua",
+ }
+
+ local pattern = document.arguments.pattern
+ local scite = document.arguments.scite
+
+ if pattern then
+ document.files = dir.glob(pattern)
+ end
+
+ if scite then
+ context.usemodule { "scite" }
+ end
+
+ if #document.files > 0 then
+ if document.arguments.sort then
+ table.sort(document.files)
+ end
+ for i=1,#document.files do
+ local filename = document.files[i]
+ if not string.find(filename,"^mtx%-context%-") then
+ local pretty = document.arguments.pretty
+ if pretty == true then
+ pretty = file.extname(filename) or ""
+ elseif pretty == false then
+ pretty = ""
+ else
+ -- forced
+ end
+ context.page()
+ context.setupfootertexts( -- return true: we need to keep this entry
+ { function() context.detokenize(pattern and filename or file.basename(filename)) return true end },
+ { function() context.pagenumber() return true end }
+ )
+ if scite then
+ context.scitefile { filename } -- here { }
+ elseif pretty then
+ if type(pretty) ~= "string" or pretty == "" then
+ context.setuptyping { option = "color" }
+ else
+ context.setuptyping { option = types[pretty] or pretty }
+ end
+ context.typefile(filename)
+ else
+ context.typefile(filename)
+ end
+ end
+ end
+ else
+ context("no files given")
+ end
+
+\stopluacode
+
+\stoptext