1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
%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\ feature 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,9pt,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",
mpiv = "mp",
mpii = "mp",
}
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
local done = false
local files = document.files
if #files > 0 then
if document.arguments.sort then
table.sort(files)
end
for i=1,#files do
local filename = 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
done = true
end
end
end
if not done then
context("no files given")
end
\stopluacode
\stoptext
|