diff options
author | Hans Hagen <pragma@wxs.nl> | 2018-02-25 20:49:38 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2018-02-25 20:49:38 +0100 |
commit | 2d50de713c23ec150dab395dcbce69b854db2d58 (patch) | |
tree | 7f071526a9f838d07b66837ef15864c17628b03a /tex/context/base | |
parent | 661fb34ced40815e1e5e9073de9c8475127da094 (diff) | |
download | context-2d50de713c23ec150dab395dcbce69b854db2d58.tar.gz |
2018-02-25 19:57:00
Diffstat (limited to 'tex/context/base')
-rw-r--r-- | tex/context/base/mkii/cont-new.mkii | 2 | ||||
-rw-r--r-- | tex/context/base/mkii/context.mkii | 2 | ||||
-rw-r--r-- | tex/context/base/mkii/mult-it.mkii | 1 | ||||
-rw-r--r-- | tex/context/base/mkiv/cont-fil.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/cont-new.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/context.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/lang-url.lua | 1 | ||||
-rw-r--r-- | tex/context/base/mkiv/lpdf-mis.lua | 17 | ||||
-rw-r--r-- | tex/context/base/mkiv/mtx-context-module.tex | 166 | ||||
-rw-r--r-- | tex/context/base/mkiv/mult-def.lua | 4 | ||||
-rw-r--r-- | tex/context/base/mkiv/pack-rul.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/page-ini.lua | 193 | ||||
-rw-r--r-- | tex/context/base/mkiv/page-ini.mkiv | 9 | ||||
-rw-r--r-- | tex/context/base/mkiv/scrn-pag.lua | 1 | ||||
-rw-r--r-- | tex/context/base/mkiv/scrn-pag.mkvi | 1 | ||||
-rw-r--r-- | tex/context/base/mkiv/status-files.pdf | bin | 25807 -> 25818 bytes | |||
-rw-r--r-- | tex/context/base/mkiv/status-lua.pdf | bin | 251734 -> 252080 bytes |
17 files changed, 376 insertions, 29 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 0ae066a63..ccba6be79 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2018.02.23 22:11} +\newcontextversion{2018.02.25 19:48} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index 4e584f125..4c8a44aac 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2018.02.23 22:11} +\edef\contextversion{2018.02.25 19:48} %D For those who want to use this: diff --git a/tex/context/base/mkii/mult-it.mkii b/tex/context/base/mkii/mult-it.mkii index 19ec32e10..38fb2de40 100644 --- a/tex/context/base/mkii/mult-it.mkii +++ b/tex/context/base/mkii/mult-it.mkii @@ -1077,6 +1077,7 @@ \setinterfaceconstant{preview}{anteprima} \setinterfaceconstant{previous}{precedente} \setinterfaceconstant{previousnumber}{numeroprecedente} +\setinterfaceconstant{print}{print} \setinterfaceconstant{printable}{stampabile} \setinterfaceconstant{process}{process} \setinterfaceconstant{profile}{profile} diff --git a/tex/context/base/mkiv/cont-fil.mkiv b/tex/context/base/mkiv/cont-fil.mkiv index efadd8ca4..ed1a873f3 100644 --- a/tex/context/base/mkiv/cont-fil.mkiv +++ b/tex/context/base/mkiv/cont-fil.mkiv @@ -139,6 +139,8 @@ \definefilesynonym [syn-01] [syntax] +\definefilesynonym [mod-01] [modules-basics] + \definefilesynonym [reg-01] [regimes-list] \definefilesynonym [set-11] [setups-basics] diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index d0dc335c9..f88f14fa6 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2018.02.23 22:11} +\newcontextversion{2018.02.25 19:48} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 2f889f572..c5122398c 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -42,7 +42,7 @@ %D has to match \type {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2018.02.23 22:11} +\edef\contextversion{2018.02.25 19:48} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/mkiv/lang-url.lua b/tex/context/base/mkiv/lang-url.lua index 24a5b9863..651c6bd52 100644 --- a/tex/context/base/mkiv/lang-url.lua +++ b/tex/context/base/mkiv/lang-url.lua @@ -194,7 +194,6 @@ local function action(hyphenatedurl,str,left,right,disc) end end list = concat(list) - print(list) context(list) end diff --git a/tex/context/base/mkiv/lpdf-mis.lua b/tex/context/base/mkiv/lpdf-mis.lua index 5fe064030..4ccbd0e4f 100644 --- a/tex/context/base/mkiv/lpdf-mis.lua +++ b/tex/context/base/mkiv/lpdf-mis.lua @@ -15,8 +15,9 @@ if not modules then modules = { } end modules ['lpdf-mis'] = { -- referencing and references had to be tracked in multiple passes. Of -- course there are a couple of more changes. -local next, tostring = next, tostring +local next, tostring, type = next, tostring, type local format, gsub, formatters = string.format, string.gsub, string.formatters +local flattened = table.flattened local texset, texget = tex.set, tex.get local backends, lpdf, nodes = backends, lpdf, nodes @@ -364,6 +365,7 @@ local pagespecs = { local pagespec, topoffset, leftoffset, height, width, doublesided = "default", 0, 0, 0, 0, false local cropoffset, bleedoffset, trimoffset, artoffset = 0, 0, 0, 0 +local marked = false local copies = false function codeinjections.setupcanvas(specification) @@ -381,6 +383,7 @@ function codeinjections.setupcanvas(specification) leftoffset = specification.leftoffset or 0 height = specification.height or texget("pageheight") width = specification.width or texget("pagewidth") + marked = specification.print -- copies = specification.copies if copies and copies < 2 then @@ -439,13 +442,23 @@ local function documentspecification() if mode then addtocatalog("PageMode",pdfconstant(mode)) end - if fit or fixed or duplex or copies or paper then + local prints = nil + if marked then + local pages = structures.pages + local marked = pages.allmarked(marked) + local nofmarked = marked and #marked or 0 + if nofmarked > 0 then + prints = pdfarray(flattened(pages.toranges(marked))) + end + end + if fit or fixed or duplex or copies or paper or marked then addtocatalog("ViewerPreferences",pdfdictionary { FitWindow = fit and true or nil, PrintScaling = fixed and pdfconstant("None") or nil, Duplex = duplex and pdfconstant(duplex) or nil, NumCopies = copies and copies or nil, PickTrayByPDFSize = paper and true or nil, + PrintPageRange = prints or nil, }) end addtoinfo ("Trapped", pdfconstant("False")) -- '/Trapped' in /Info, 'Trapped' in XMP diff --git a/tex/context/base/mkiv/mtx-context-module.tex b/tex/context/base/mkiv/mtx-context-module.tex new file mode 100644 index 000000000..d754f5305 --- /dev/null +++ b/tex/context/base/mkiv/mtx-context-module.tex @@ -0,0 +1,166 @@ +%D \module +%D [ file=mtx-context-modules, +%D version=2018.02.24, % very old stuff, now also as extra +%D title=\CONTEXT\ Extra Trickry, +%D subtitle=Module TYpesetting, +%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 +% +% end help + +\input mtx-context-common.tex + +\usemodule[scite] +\usemodule[modules-basics] + +\dontcomplain + +\starttext + +\startluacode + local find, gsub, match, sub = string.find, string.gsub, string.match, string.sub + local formatters, strip, splitlines, is_empty = string.formatters, string.strip, string.splitlines, string.is_empty + + local types = { + mkiv = "tex", + mkii = "tex", + cld = "lua", + lfg = "lua", + mpiv = "mp", + mpii = "mp", + } + + local function process(inpname,filetype) + local data = io.loaddata(inpname) + if data and data ~= "" then + local result = { } + local skiplevel = 0 + local indocument = false + local indefinition = false + local started = false + local settings = formatters["type=%s"](filetype) + local preamble, n = lpeg.match(lpeg.Cs((1-lpeg.patterns.newline^2)^1) * lpeg.Cp(),data) + local r = 0 + if preamble then + preamble = match(preamble,"\\module.-%[(.-)%]") + if preamble then + preamble = gsub(preamble,"%%D *","") + preamble = gsub(preamble,"%%(.-)[\n\r]","") + preamble = gsub(preamble,"[\n\r]","") + preamble = strip(preamble) + settings = formatters["%s,%s"](settings,preamble) + data = sub(data,n,#data) + end + end + local lines = splitlines(data) + r = r + 1 ; result[r] = formatters["\\startmoduledocumentation[%s]"](settings) + for i=1,#lines do + local line = lines[i] + if find(line,"^%%D ") or find(line,"^%%D$") then + if skiplevel == 0 then + local someline = #line < 3 and "" or sub(line,4,#line) + if indocument then + r = r + 1 ; result[r] = someline + else + if indefinition then + r = r + 1 ; result[r] = "\\stopdefinition" + indefinition = false + end + if not indocument then + r = r + 1 ; result[r] = "\\startdocumentation" + end + r = r + 1 ; result[r] = someline + indocument = true + end + end + elseif find(line,"^%%M ") or find(line,"^%%M$") then + if skiplevel == 0 then + local someline = (#line < 3 and "") or sub(line,4,#line) + r = r + 1 ; result[r] = someline + end + elseif find(line,"^%%S B") then + skiplevel = skiplevel + 1 + elseif find(line,"^%%S E") then + skiplevel = skiplevel - 1 + elseif find(line,"^%%") then + -- nothing + elseif skiplevel == 0 then + inlocaldocument = indocument + inlocaldocument = false + local someline = line + if indocument then + r = r + 1 ; result[r] = "\\stopdocumentation" + indocument = false + end + if indefinition then + if is_empty(someline) then + r = r + 1 ; result[r] = "\\stopdefinition" + indefinition = false + else + r = r + 1 ; result[r] = someline + end + elseif not is_empty(someline) then + r = r + 1 ; result[r] = "\\startdefinition" + indefinition = true + if inlocaldocument then + -- nothing + else + r = r + 1 ; result[r] = someline + end + end + end + end + if indocument then + r = r + 1 ; result[r] = "\\stopdocumentation" + end + if indefinition then + r = r + 1 ; result[r] = "\\stopdefinition" + end + r = r + 1 ; result[r] = "\\stopmoduledocumentation" + result = table.concat(result,"\r") + buffers.assign("module",result) + context.getbuffer { "module" } + end + end + + local pattern = document.arguments.pattern + + if pattern then + document.files = dir.glob(pattern) + 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 find(filename,"^mtx%-context%-") then + local suffix = file.extname(filename) or "" + process(filename,types[suffix] or suffix) + done = true + end + end + end + + if not done then + context("no files given") + end + +\stopluacode + +\stoptext diff --git a/tex/context/base/mkiv/mult-def.lua b/tex/context/base/mkiv/mult-def.lua index e15306c7c..925c22cd2 100644 --- a/tex/context/base/mkiv/mult-def.lua +++ b/tex/context/base/mkiv/mult-def.lua @@ -9863,6 +9863,10 @@ return { ["pe"]="شمارهقبلی", ["ro"]="numarprecedent", }, + ["print"]={ + ["en"]="print", + ["nl"]="print", + }, ["printable"]={ ["cs"]="tisknutelne", ["de"]="druckbar", diff --git a/tex/context/base/mkiv/pack-rul.mkiv b/tex/context/base/mkiv/pack-rul.mkiv index 9ad33642b..c208baaf0 100644 --- a/tex/context/base/mkiv/pack-rul.mkiv +++ b/tex/context/base/mkiv/pack-rul.mkiv @@ -2476,6 +2476,7 @@ %D \dontcomplain %D %D \startbuffer +%D \unprotect %D \vbox to \vsize %D \bgroup %D \startalignment[middle] @@ -2509,6 +2510,7 @@ %D \vss %D \stopalignment %D \egroup +%D \protect %D \stopbuffer %D %D \getbuffer \page diff --git a/tex/context/base/mkiv/page-ini.lua b/tex/context/base/mkiv/page-ini.lua index 1aeae8f09..a02bbc892 100644 --- a/tex/context/base/mkiv/page-ini.lua +++ b/tex/context/base/mkiv/page-ini.lua @@ -6,46 +6,195 @@ if not modules then modules = { } end modules ['page-ini'] = { license = "see context related readme files" } -local tonumber, rawget = tonumber, rawget -local gmatch = string.gmatch +local tonumber, rawget, type, next = tonumber, rawget, type, next +local match = string.match +local sort, tohash, insert, remove = table.sort, table.tohash, table.insert, table.remove +local settings_to_array, settings_to_hash = utilities.parsers.settings_to_array, utilities.parsers.settings_to_hash local texgetcount = tex.getcount +local context = context local ctx_testcase = commands.testcase -local data = table.setmetatableindex("table") -local last = 0 +local data = table.setmetatableindex("table") +local last = 0 +local pages = structures.pages +local autolist = { } +local report = logs.reporter("pages","mark") -interfaces.implement { - name = "markpage", - arguments = { "string", "string" }, - actions = function(name,list) - local realpage = texgetcount("realpageno") - if list and list ~= "" then - for sign, page in gmatch(list,"([%+%-])(%d+)") do - page = tonumber(page) - if page then - if sign == "+" then - page = realpage + page +local trace = false trackers.register("pages.mark",function(v) trace = v end) + +function pages.mark(name,list) + local realpage = texgetcount("realpageno") + if not list or list == "" then + if trace then + report("marking current page %i as %a",realpage,name) + end + data[realpage][name] = true + return + end + if type(list) == "string" then + list = settings_to_array(list) + end + if type(list) == "table" then + for i=1,#list do + local page = list[i] + local sign = false + if type(page) == "string" then + sign, page = match(page,"([%+%-])(%d+)") + end + page = tonumber(page) + if page then + if sign == "+" then + page = realpage + page + end + if sign == "-" then + report("negative page numbers are not supported") + else + if trace then + report("marking page %i as %a",page,name) end data[page][name] = true end end - else - data[realpage][name] = true end + else + if trace then + report("marking current page %i as %a",realpage,name) + end + data[realpage][name] = true end +end + +function pages.marked(name) + local realpage = texgetcount("realpageno") + for i=last,realpage-1 do + data[i] = nil + end + local pagedata = rawget(data,realpage) + return pagedata and pagedata[name] +end + +local function toranges(marked) + local list = { } + local size = #marked + if size > 0 then + local first = marked[1] + local last = first + for i=2,size do + local page = marked[i] + if page > last + 1 then + list[#list+1] = { first, last } + first = page + end + last = page + end + list[#list+1] = { first, last } + end + return list +end + +pages.toranges = toranges + +local function allmarked(list) + if list then + local collected = pages.collected + if collected then + if type(list) == "string" then + list = settings_to_hash(list) + elseif type(list) == "table" and #list > 0 then + list = tohash(list) + end + if type(list) == "table" then + local found = { } + for name in next, list do + for page, list in next, data do + if list[name] and collected[page] then + found[#found+1] = page + end + end + end + if #found > 0 then + sort(found) + if trace then + local ranges = toranges(found) + for i=1,#ranges do + local range = ranges[i] + local first = range[1] + local last = range[2] + if first == last then + report("marked page : %i",first) + else + report("marked range: %i upto %i",first,last) + end + end + end + return found + end + end + end + end +end + +pages.allmarked = allmarked + +-- An alternative is to use an attribute and identify the state by parsing the node +-- list but that's a bit overkill for a hardly used feature like this. + +luatex.registerpageactions(function() + local nofauto = #autolist + if nofauto > 0 then + local realpage = texgetcount("realpageno") + for i=1,nofauto do + local names = autolist[i] + for j=1,#names do + local name = names[j] + data[realpage][name] = true + if trace then + report("automatically marking page %i as %a",realpage,name) + end + end + end + end +end) + +interfaces.implement { + name = "markpage", + arguments = { "string", "string" }, + actions = pages.mark } interfaces.implement { name = "doifelsemarkedpage", arguments = "string", + actions = { marked, ctx_testcase } +} + +interfaces.implement { + name = "markedpages", + arguments = "string", actions = function(name) - local realpage = texgetcount("realpageno") - for i=last,realpage-1 do - data[i] = nil + local t = allmarked(name) + if t then + context("%,t",t) + end + end +} + +interfaces.implement { + name = "startmarkpages", + arguments = "string", + actions = function(name) + insert(autolist,settings_to_array(name)) + end +} + +interfaces.implement { + name = "stopmarkpages", + arguments = "string", + actions = function(name) + if #autolist > 0 then + remove(autolist) end - local pagedata = rawget(data,realpage) - ctx_testcase(pagedata and pagedata[name]) end } diff --git a/tex/context/base/mkiv/page-ini.mkiv b/tex/context/base/mkiv/page-ini.mkiv index a2559481a..dc94edf76 100644 --- a/tex/context/base/mkiv/page-ini.mkiv +++ b/tex/context/base/mkiv/page-ini.mkiv @@ -316,9 +316,18 @@ \def\page_mark[#1][#2]% {\clf_markpage{#1}{#2}} +\def\markedpages[#1]% expandable + {\clf_markedpages{#1}} + \unexpanded\def\doifelsemarkedpage#1% {\clf_doifelsemarkedpage{#1}} +\unexpanded\def\startmarkpages[#1]% + {\clf_startmarkpages{#1}} + +\unexpanded\def\stopmarkpages + {\clf_stopmarkpages} + %D Experimental: \newconstant\c_page_force_strut_depth_trace_mode diff --git a/tex/context/base/mkiv/scrn-pag.lua b/tex/context/base/mkiv/scrn-pag.lua index bd65e53d9..4f77a7d24 100644 --- a/tex/context/base/mkiv/scrn-pag.lua +++ b/tex/context/base/mkiv/scrn-pag.lua @@ -41,6 +41,7 @@ implement { { "artoffset", "dimen" }, { "trimoffset", "dimen" }, { "copies", "integer" }, + { "print", "string" }, -- , tohash } } } diff --git a/tex/context/base/mkiv/scrn-pag.mkvi b/tex/context/base/mkiv/scrn-pag.mkvi index 573b61696..d96d8d3c1 100644 --- a/tex/context/base/mkiv/scrn-pag.mkvi +++ b/tex/context/base/mkiv/scrn-pag.mkvi @@ -228,6 +228,7 @@ bleedoffset \canvasbleedoffset artoffset \canvasartoffset copies \numexpr\interactionscreenparameter\c!copies\relax + print {\interactionscreenparameter\c!print}% \relax %\global\let\scrn_canvas_synchronize_simple \relax \global\let\scrn_canvas_synchronize_complex\relax} diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex ea587d3a0..4b3857135 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex d8c1b019b..fea1f2b83 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf |