mtx-context-select.tex /size: 2879 b    last modification: 2021-10-28 13:50
1
%D \module
2
%D [ file=mtx-context-select,
3
%D version=2008.11.10, % about that time i started playing with this
4
%D title=\CONTEXT\ Extra Trickry,
5
%D subtitle=Selecting Files,
6
%D author=Hans Hagen,
7
%D date=\currentdate,
8
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9
%C
10
%C This module is part of the \CONTEXT\ macro||package and is
11
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12
%C details.
13 14
%D This is a \TEXEXEC\ features that has been moved to \MKIV.
15 16
% begin help
17
%
18
% usage: context --extra=select [options] list-of-files
19
%
20
% --sort : sort filenames first
21
% --topspace=dimension : distance above first line
22
% --backspace=dimension : distance before left margin
23
% --selection=list : n:m,p:q,...
24
% --paperformat=spec : paper*print or paperxprint or 'fit'
25
% --interaction : add hyperlinks
26
%
27
% end help
28 29
\input
mtx
-
context
-
common
.
tex
30 31
\setuppapersize
32
[
\getdocumentargumentdefault
{
paperformat
_
paper
}
{
A
4
}
]
33
[
\getdocumentargumentdefault
{
paperformat
_
print
}
{
A
4
}
]
34 35
\setuppaper
36
[
offset
=
\getdocumentargumentdefault
{
paperoffset
}
{
0
pt
}
]
37 38
\setuplayout
39
[
width
=
middle
,
40
height
=
middle
,
41
topspace
=
\getdocumentargumentdefault
{
topspace
}
{
0
pt
}
,
42
backspace
=
\getdocumentargumentdefault
{
backspace
}
{
0
pt
}
,
43
location
=
middle
,
44
header
=
0
pt
,
45
footer
=
0
pt
]
46 47
\doif
{
\getdocumentargument
{
marking
}
}
{
yes
}
{
48
\setuplayout
49
[
marking
=
on
]
50
}
51 52
\doif
{
\getdocumentargument
{
interaction
}
}
{
yes
}
{
53
\setupinteraction
54
[
state
=
start
]
55
\setupexternalfigures
56
[
interaction
=
yes
]
57
}
58 59
\setupexternalfigures
60
[
directory
=
]
61 62
\doifelse
{
\getdocumentargument
{
paperformat
_
paper
}
}
{
fit
}
{
63
\doifdocumentfilename
{
1
}
{
64
\getfiguredimensions
65
[
\getdocumentfilename
{
1
}
]
66
\definepapersize
67
[
fit
]
68
[
width
=
\figurewidth
,
69
height
=
\figureheight
]
70
\setuppapersize
71
[
fit
]
72
[
fit
]
73
}
74
}
75 76
\starttext
77 78
\startluacode
79 80
local
papersize
=
document
.
arguments
.
paperformat_paper
or
"
A4
"
81
local
printsize
=
document
.
arguments
.
paperformat_print
or
"
A4
"
82
local
selection
=
document
.
arguments
.
selection
or
"
"
83
local
textwidth
=
document
.
arguments
.
textwidth
or
"
0cm
"
-- needed ?
84 85
if
#
document
.
files
=
=
0
then
86
context
(
"
no files given
"
)
87
elseif
selection
=
=
"
"
then
88
context
(
"
no selection given
"
)
89
else
90
if
document
.
arguments
.
sort
then
91
table
.
sort
(
document
.
files
)
92
end
93
for
_
,
filename
in
ipairs
(
document
.
files
)
do
94
if
not
string
.
find
(
filename
,
"
^mtx%-context%-
"
)
then
95
logs
.
report
(
"
select
"
,
filename
)
96
context
.
filterpages
(
97
{
filename
}
,
98
{
selection
}
,
99
{
width
=
textwidth
}
100
)
101
end
102
end
103
end
104 105
\stopluacode
106 107
\stoptext
108 109