summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/mtx-context-select.tex
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/mtx-context-select.tex')
-rw-r--r--tex/context/base/mkiv/mtx-context-select.tex110
1 files changed, 110 insertions, 0 deletions
diff --git a/tex/context/base/mkiv/mtx-context-select.tex b/tex/context/base/mkiv/mtx-context-select.tex
new file mode 100644
index 000000000..2f63f5955
--- /dev/null
+++ b/tex/context/base/mkiv/mtx-context-select.tex
@@ -0,0 +1,110 @@
+% engine=luatex
+
+%D \module
+%D [ file=mtx-context-select,
+%D version=2008.11.10, % about that time i started playing with this
+%D title=\CONTEXT\ Extra Trickry,
+%D subtitle=Selecting 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=select [options] list-of-files
+%
+% --sort : sort filenames first
+% --topspace=dimension : distance above first line
+% --backspace=dimension : distance before left margin
+% --selection=list : n:m,p:q,...
+% --paperformat=spec : paper*print or paperxprint or 'fit'
+% --interaction : add hyperlinks
+%
+% end help
+
+\input mtx-context-common.tex
+
+\setuppapersize
+ [\getdocumentargumentdefault{paperformat_from}{A4}]
+ [\getdocumentargumentdefault{paperformat_to}{A4}]
+
+\setuppaper
+ [offset=\getdocumentargumentdefault{paperformat_to}{0pt}]
+
+\setuplayout
+ [width=middle,
+ height=middle,
+ topspace=\getdocumentargumentdefault{topspace}{0pt},
+ backspace=\getdocumentargumentdefault{backspace}{0pt},
+ location=middle,
+ header=0pt,
+ footer=0pt]
+
+\doif {\getdocumentargument{marking}} {yes} {
+ \setuplayout
+ [marking=on]
+}
+
+\doif {\getdocumentargument{interaction}} {yes} {
+ \setupinteraction
+ [state=start]
+ \setupexternalfigures
+ [interaction=yes]
+}
+
+\setupexternalfigures
+ [directory=]
+
+\doifelse {\getdocumentargument{paperformat_paper}} {fit} {
+ \doifdocumentfilename {1} {
+ \getfiguredimensions
+ [\getdocumentfilename{1}]
+ \definepapersize
+ [fit]
+ [width=\figurewidth,
+ height=\figureheight]
+ \setuppapersize
+ [fit]
+ [fit]
+ }
+}
+
+\starttext
+
+\startluacode
+
+ local papersize = document.arguments.paperformat_paper or "A4"
+ local printsize = document.arguments.paperformat_print or "A4"
+ local selection = document.arguments.selection or ""
+ local textwidth = document.arguments.textwidth or "0cm" -- needed ?
+
+ if #document.files == 0 then
+ context("no files given")
+ elseif selection == "" then
+ context("no selection given")
+ else
+ if document.arguments.sort then
+ table.sort(document.files)
+ end
+ for _, filename in ipairs(document.files) do
+ if not string.find(filename,"^mtx%-context%-") then
+ logs.report("select",filename)
+ context.filterpages (
+ { filename },
+ { selection },
+ { width = textwidth }
+ )
+ end
+ end
+ end
+
+\stopluacode
+
+\stoptext
+