From 32948ef106b3d0bbe9c0d7622c292a42080f7dbe Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Wed, 8 Apr 2015 15:15:05 +0200 Subject: 2015-04-08 14:22:00 --- tex/context/base/anch-pgr.mkiv | 12 +- tex/context/base/attr-col.lua | 6 +- tex/context/base/back-exp.mkiv | 4 +- tex/context/base/back-ini.lua | 10 +- tex/context/base/back-ini.mkiv | 2 +- tex/context/base/back-pdf.mkiv | 2 +- tex/context/base/buff-par.lua | 62 ++- tex/context/base/buff-par.mkvi | 30 +- tex/context/base/buff-ver.lua | 110 +++--- tex/context/base/buff-ver.mkiv | 8 +- tex/context/base/char-fio.lua | 8 +- tex/context/base/char-ini.lua | 437 ++++++++++++--------- tex/context/base/char-tex.lua | 8 + tex/context/base/char-utf.lua | 6 + tex/context/base/char-utf.mkiv | 4 +- tex/context/base/cldf-scn.lua | 6 +- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/cont-run.lua | 11 +- tex/context/base/cont-yes.mkiv | 4 +- tex/context/base/context-version.pdf | Bin 4187 -> 4190 bytes tex/context/base/context.mkiv | 2 +- tex/context/base/core-con.lua | 6 + tex/context/base/core-con.mkiv | 4 + tex/context/base/core-ctx.lua | 70 ++-- tex/context/base/core-ctx.mkiv | 14 +- tex/context/base/core-def.mkiv | 12 +- tex/context/base/core-ini.mkiv | 3 + tex/context/base/core-sys.lua | 52 +-- tex/context/base/core-sys.mkiv | 16 +- tex/context/base/core-uti.lua | 2 +- tex/context/base/enco-ini.mkiv | 2 +- tex/context/base/file-job.lua | 29 +- tex/context/base/file-job.mkvi | 2 +- tex/context/base/font-chk.lua | 20 +- tex/context/base/font-chk.mkiv | 8 +- tex/context/base/font-ctx.lua | 81 ++-- tex/context/base/font-gds.lua | 2 +- tex/context/base/font-set.mkvi | 13 +- tex/context/base/font-tra.mkiv | 2 +- tex/context/base/font-uni.mkiv | 10 +- tex/context/base/grph-epd.lua | 6 + tex/context/base/grph-epd.mkiv | 2 +- tex/context/base/grph-fig.mkiv | 2 +- tex/context/base/grph-fil.lua | 6 + tex/context/base/grph-inc.mkiv | 2 +- tex/context/base/grph-raw.lua | 15 + tex/context/base/grph-raw.mkiv | 16 +- tex/context/base/java-ini.lua | 52 ++- tex/context/base/java-ini.mkiv | 14 +- tex/context/base/lang-lab.lua | 18 +- tex/context/base/lang-lab.mkiv | 12 +- tex/context/base/lang-rep.lua | 21 +- tex/context/base/lang-rep.mkiv | 4 +- tex/context/base/lang-url.lua | 27 +- tex/context/base/lang-url.mkiv | 18 +- tex/context/base/lang-wrd.lua | 29 +- tex/context/base/lang-wrd.mkiv | 9 +- tex/context/base/lpdf-fld.lua | 2 +- tex/context/base/lpdf-xmp.lua | 7 +- tex/context/base/luat-mac.lua | 2 +- tex/context/base/luat-run.lua | 22 +- tex/context/base/lxml-lpt.lua | 2 +- tex/context/base/lxml-tex.lua | 82 ++-- tex/context/base/m-chart.lua | 36 +- tex/context/base/m-steps.lua | 21 +- tex/context/base/math-act.lua | 79 ---- tex/context/base/math-fbk.lua | 4 +- tex/context/base/math-ini.lua | 8 + tex/context/base/math-ini.mkiv | 7 +- tex/context/base/math-noa.lua | 2 - tex/context/base/math-rad.mkvi | 20 +- tex/context/base/math-stc.mkvi | 10 +- tex/context/base/meta-fnt.lua | 11 +- tex/context/base/meta-fnt.mkiv | 8 +- tex/context/base/meta-ini.mkiv | 176 +++++---- tex/context/base/meta-pag.mkiv | 118 +++--- tex/context/base/meta-pdf.lua | 8 + tex/context/base/meta-pdf.mkiv | 2 +- tex/context/base/meta-pdh.mkiv | 10 +- tex/context/base/meta-tex.lua | 12 + tex/context/base/meta-tex.mkiv | 6 +- tex/context/base/mlib-ctx.lua | 2 +- tex/context/base/mlib-ctx.mkiv | 1 + tex/context/base/mlib-int.lua | 147 +++++++ tex/context/base/mlib-lua.lua | 9 +- tex/context/base/mlib-pps.lua | 6 + tex/context/base/mlib-run.lua | 34 +- tex/context/base/mult-chk.lua | 21 +- tex/context/base/mult-chk.mkiv | 7 +- tex/context/base/mult-def.mkiv | 2 +- tex/context/base/mult-ini.lua | 8 + tex/context/base/node-aux.lua | 16 +- tex/context/base/node-bck.lua | 4 +- tex/context/base/node-ref.lua | 7 + tex/context/base/node-rul.lua | 12 +- tex/context/base/node-tra.lua | 14 +- tex/context/base/pack-box.mkiv | 8 +- tex/context/base/pack-fen.mkiv | 18 +- tex/context/base/pack-lyr.mkiv | 10 +- tex/context/base/pack-rul.mkiv | 56 ++- tex/context/base/page-ini.mkiv | 1 + tex/context/base/page-ins.lua | 54 ++- tex/context/base/page-ins.mkiv | 18 +- tex/context/base/page-lin.lua | 46 ++- tex/context/base/page-lin.mkvi | 47 ++- tex/context/base/page-pst.lua | 41 +- tex/context/base/page-pst.mkiv | 5 +- tex/context/base/page-str.lua | 56 +++ tex/context/base/page-str.mkiv | 24 +- tex/context/base/regi-ini.lua | 1 + tex/context/base/s-fonts-shapes.lua | 19 +- tex/context/base/s-math-characters.lua | 286 ++++++++------ tex/context/base/s-math-characters.mkiv | 15 +- tex/context/base/s-math-repertoire.mkiv | 50 ++- tex/context/base/scrn-but.lua | 10 +- tex/context/base/scrn-but.mkvi | 20 +- tex/context/base/scrn-fld.lua | 163 ++++++-- tex/context/base/scrn-fld.mkvi | 123 +++--- tex/context/base/scrn-hlp.lua | 123 +++--- tex/context/base/scrn-hlp.mkvi | 16 +- tex/context/base/scrn-ref.lua | 18 +- tex/context/base/scrn-ref.mkvi | 14 +- tex/context/base/scrn-wid.lua | 211 +++++++--- tex/context/base/scrn-wid.mkvi | 187 ++++----- tex/context/base/spac-adj.lua | 8 + tex/context/base/spac-adj.mkiv | 7 +- tex/context/base/status-files.pdf | Bin 24525 -> 24529 bytes tex/context/base/status-lua.pdf | Bin 411820 -> 416994 bytes tex/context/base/strc-doc.lua | 4 +- tex/context/base/strc-lst.lua | 2 +- tex/context/base/strc-pag.lua | 18 + tex/context/base/strc-pag.mkiv | 9 + tex/context/base/strc-ref.lua | 7 + tex/context/base/strc-reg.lua | 192 +++++++-- tex/context/base/strc-reg.mkiv | 180 +++++---- tex/context/base/strc-sec.mkiv | 2 +- tex/context/base/syst-aux.lua | 10 +- tex/context/base/syst-aux.mkiv | 2 +- tex/context/base/tabl-xtb.mkvi | 9 +- tex/context/base/task-ini.lua | 6 +- tex/context/base/toks-scn.lua | 83 ++-- tex/context/base/trac-jus.lua | 7 +- tex/context/base/trac-jus.mkiv | 2 +- tex/context/base/typo-cln.lua | 6 +- tex/context/base/typo-cln.mkiv | 2 +- tex/context/base/typo-dig.lua | 6 +- tex/context/base/typo-dig.mkiv | 2 +- tex/context/base/typo-drp.lua | 22 +- tex/context/base/typo-drp.mkiv | 30 +- tex/context/base/typo-fln.lua | 27 +- tex/context/base/typo-fln.mkiv | 20 +- tex/context/base/typo-lan.lua | 8 +- tex/context/base/typo-lan.mkiv | 2 +- tex/context/base/typo-mar.lua | 2 - tex/context/base/typo-rep.lua | 6 +- tex/context/base/typo-rep.mkiv | 2 +- tex/context/base/typo-tal.lua | 14 +- tex/context/base/typo-tal.mkiv | 4 +- tex/context/base/typo-wrp.lua | 11 +- tex/context/base/typo-wrp.mkiv | 10 +- tex/context/base/unic-ini.lua | 14 +- tex/context/base/unic-ini.mkiv | 3 +- tex/context/base/x-asciimath.lua | 8 +- tex/context/base/x-asciimath.mkiv | 2 +- tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 165 files changed, 3010 insertions(+), 1661 deletions(-) create mode 100644 tex/context/base/mlib-int.lua (limited to 'tex') diff --git a/tex/context/base/anch-pgr.mkiv b/tex/context/base/anch-pgr.mkiv index 8523cde82..56ff656d9 100644 --- a/tex/context/base/anch-pgr.mkiv +++ b/tex/context/base/anch-pgr.mkiv @@ -256,15 +256,15 @@ \def\MPoverlayanchor#1{\MPpos\MPanchorid} \def\anch_positions_overlay_compose - {\vbox to \overlayheight + {\vbox to \d_overlay_height {%\writestatus{!!!}{\currentpositionoverlay/\MPanchoridentifier/\MPanchornumber}% \edef\MPanchorid{\currentpositionoverlay::\MPanchoridentifier:\MPanchornumber}% realpageno % \edef\MPanchor##1{\MPpos\MPanchorid}% \let\MPanchor\MPoverlayanchor % no need to fetch it already, seldom used \the\everyinsertpositionaction \copyposition{\currentpositionoverlay::\MPanchoridentifier}\MPanchorid - \setbox\scratchbox\hbox to \overlaywidth{\dopositionaction{\currentpositionoverlay::\MPanchoridentifier}\hss}% - \ht\scratchbox\overlayheight + \setbox\scratchbox\hbox to \d_overlay_width{\dopositionaction{\currentpositionoverlay::\MPanchoridentifier}\hss}% + \ht\scratchbox\d_overlay_height \dp\scratchbox\zeropoint \anch_mark_tagged_box\scratchbox\MPanchorid % needs an hbox \box\scratchbox @@ -289,13 +289,13 @@ \endgroup} \def\anch_positions_region_overlay_compose - {\vbox to \overlayheight + {\vbox to \d_overlay_height {\let\MPanchorid\currentpositionregion \let\MPanchor\MPoverlayanchor % no need to fetch it already, seldom used \the\everyinsertpositionaction \copyposition{\currentpositionoverlay::\MPanchoridentifier}\MPanchorid - \setbox\scratchbox\hbox to \overlaywidth{\dopositionaction{\currentpositionoverlay::\MPanchoridentifier}\hss}% - \ht\scratchbox\overlayheight + \setbox\scratchbox\hbox to \d_overlay_width{\dopositionaction{\currentpositionoverlay::\MPanchoridentifier}\hss}% + \ht\scratchbox\d_overlay_height \dp\scratchbox\zeropoint \box\scratchbox \vfill}} diff --git a/tex/context/base/attr-col.lua b/tex/context/base/attr-col.lua index d6e751d89..28eda5ca9 100644 --- a/tex/context/base/attr-col.lua +++ b/tex/context/base/attr-col.lua @@ -568,9 +568,9 @@ end -- interface -implement { name = "enablecolor", once = true, actions = colors.enable } -implement { name = "enabletransparency", once = true, actions = transparencies.enable } -implement { name = "enablecolorintents", once = true, actions = colorintents.enable } +implement { name = "enablecolor", onlyonce = true, actions = colors.enable } +implement { name = "enabletransparency", onlyonce = true, actions = transparencies.enable } +implement { name = "enablecolorintents", onlyonce = true, actions = colorintents.enable } --------- { name = "registercolor", actions = { colors .register, context }, arguments = "string" } --------- { name = "registertransparency", actions = { transparencies.register, context }, arguments = { ... } } diff --git a/tex/context/base/back-exp.mkiv b/tex/context/base/back-exp.mkiv index 3b26e5ace..64ec1a674 100644 --- a/tex/context/base/back-exp.mkiv +++ b/tex/context/base/back-exp.mkiv @@ -38,8 +38,8 @@ \doubleexpandafter\back_export_set_element_tag_b \fi\fi} -\def\back_export_set_element_tag_a[#1][#2][#3]{\taggedctxcommand{settagproperty("#1","#2","#3")}} -\def\back_export_set_element_tag_b[#1][#2][#3]{\taggedctxcommand{settagproperty("#1","export","#2")}} +\def\back_export_set_element_tag_a[#1][#2][#3]{\clf_settagproperty{#1}{#2}{#3}} +\def\back_export_set_element_tag_b[#1][#2][#3]{\clf_settagproperty{#1}{export}{#2}} % todo: no need for calls when trialtypesetting diff --git a/tex/context/base/back-ini.lua b/tex/context/base/back-ini.lua index 129e7b75c..e8af4d9d9 100644 --- a/tex/context/base/back-ini.lua +++ b/tex/context/base/back-ini.lua @@ -113,6 +113,10 @@ function codeinjections.getmatrix() return 1, 0, 0, 1, 0, 0 end -- can best be here -function commands.setrealspaces(v) - nodes.tasks.setaction("shipouts","nodes.handlers.accessibility",v == interfaces.variables.yes) -end +interfaces.implement { + name = "setrealspaces", + arguments = "string", + actions = function(v) + nodes.tasks.setaction("shipouts","nodes.handlers.accessibility",v == interfaces.variables.yes) + end +} diff --git a/tex/context/base/back-ini.mkiv b/tex/context/base/back-ini.mkiv index 057cb840f..2b0f054ee 100644 --- a/tex/context/base/back-ini.mkiv +++ b/tex/context/base/back-ini.mkiv @@ -155,7 +155,7 @@ % \setupbackend[space=yes] % replace spacing in (pdf) file \appendtoks - \ctxcommand{setrealspaces("\backendparameter\c!space")}% + \clf_setrealspaces{\backendparameter\c!space}% \to \everysetupbackend %D For older styles: diff --git a/tex/context/base/back-pdf.mkiv b/tex/context/base/back-pdf.mkiv index f54675022..ef004fb4e 100644 --- a/tex/context/base/back-pdf.mkiv +++ b/tex/context/base/back-pdf.mkiv @@ -79,7 +79,7 @@ \appendtoks \doifsomething{\backendparameter{xmpfile}} - {\ctxcommand{setxmpfile("\backendparameter{xmpfile}")}}% + {\clf_setxmpfile{\backendparameter{xmpfile}}}% \to \everysetupbackend % \doifsomething{\backendparameter\c!format} .. at the lua end diff --git a/tex/context/base/buff-par.lua b/tex/context/base/buff-par.lua index d12eddebc..58ea9ab9d 100644 --- a/tex/context/base/buff-par.lua +++ b/tex/context/base/buff-par.lua @@ -6,8 +6,6 @@ if not modules then modules = { } end modules ['buff-par'] = { license = "see context related readme files" } -local context, commands = context, commands - local insert, remove, find, gmatch = table.insert, table.remove, string.find, string.gmatch local fullstrip, formatters = string.fullstrip, string.formatters @@ -23,6 +21,9 @@ buffers.parallel = parallel local settings_to_array = utilities.parsers.settings_to_array +local context = context +local implement = interfaces.implement + local data = { } function parallel.define(category,tags) @@ -63,7 +64,10 @@ function parallel.next(category) end end -function parallel.save(category,tag,content) +function parallel.save(category,tag,content,frombuffer) + if frombuffer then + content = buffers.raw(content) + end local dc = data[category] if not dc then report_parallel("unknown category %a",category) @@ -131,7 +135,6 @@ function parallel.hassomecontent(category,tags) end local ctx_doflushparallel = context.doflushparallel -local ctx_doifelse = commands.doifelse local f_content = formatters["\\input{%s}"] local save_byscheme = resolvers.savers.byscheme @@ -183,12 +186,47 @@ end -- interface -commands.defineparallel = parallel.define -commands.nextparallel = parallel.next -commands.saveparallel = parallel.save -commands.placeparallel = parallel.place -commands.resetparallel = parallel.reset +implement { + name = "defineparallel", + actions = parallel.define, + arguments = { "string", "string" } +} + +implement { + name = "nextparallel", + actions = parallel.next, + arguments = "string" +} -function commands.doifelseparallel(category,tags) - ctx_doifelse(parallel.hassomecontent(category,tags)) -end +implement { + name = "saveparallel", + actions = parallel.save, + arguments = { "string", "string", "string", true }, +} + +implement { + name = "placeparallel", + actions = parallel.place, + arguments = { + "string", + "string", + { + { "start" }, + { "n" }, + { "criterium" }, + { "setups" }, + } + } +} + +implement { + name = "resetparallel", + actions = parallel.reset, + arguments = { "string", "string" } +} + +implement { + name = "doifelseparallel", + actions = { parallel.hassomecontent, commands.doifelse } , + arguments = { "string", "string" } +} diff --git a/tex/context/base/buff-par.mkvi b/tex/context/base/buff-par.mkvi index fb14f017c..5af04ba7c 100644 --- a/tex/context/base/buff-par.mkvi +++ b/tex/context/base/buff-par.mkvi @@ -54,7 +54,7 @@ \def\buff_parallel_define[#name][#instances]% {\buff_parallel_define_saved[#name][\c!list={#instances}]% list is internal - \ctxcommand{defineparallel("#name","#instances")}% + \clf_defineparallel{#name}{#instances}% \expandafter\newtoks\csname\??parallelhandler#name\endcsname \processcommacommand[#instances]{\buff_parallel_define_instance{#name}}% \setuevalue{\e!start#name}{\buff_parallel_start{#name}}% @@ -85,13 +85,17 @@ \unexpanded\def\buff_parallel_start#name% {\pushmacro\currentparallel \edef\currentparallel{#name}% - \ctxcommand{nextparallel("\currentparallel")}} + \clf_nextparallel{\currentparallel}} \unexpanded\def\buff_parallel_stop {\popmacro\currentparallel} \unexpanded\def\buff_parallel_save#instance% defined moet ook aan de lua kant kunnen - {\ctxcommand{saveparallel("\currentparallel","#instance",buffers.raw("\thedefinedbuffer{#instance}"))}} + {\clf_saveparallel + {\currentparallel}% + {#instance}, + {\thedefinedbuffer{#instance}}% + \relax} \unexpanded\def\placeparallel {\dotripleempty\buff_parallel_place} @@ -100,12 +104,16 @@ {\begingroup \edef\currentparallel{#name}% \setupcurrentparallel[#settings]% - \ctxcommand{placeparallel("\currentparallel","#instance",{ - % setups = "\parallelparameter\c!setups", - start = "\parallelparameter\c!start", - n = "\parallelparameter\c!n", - criterium = "\parallelparameter\c!criterium", - })}% + \clf_placeparallel + {\currentparallel}% + {#instance}% + {% + % setups {\parallelparameter\c!setups}% + start {\parallelparameter\c!start}% + n {\parallelparameter\c!n}% + criterium {\parallelparameter\c!criterium}% + }% + \relax \endgroup} \def\doflushparallel#instance#status#line#label#content% called at lua end @@ -129,7 +137,7 @@ {\directsetup{\namedparallelparameter{\currentparallel:\currentparallelinstance}\c!setups}} \unexpanded\def\doifelseparallel#name#instance% - {\ctxcommand{doifelseparallel("#name","#instance")}} + {\clf_doifelseparallel{#name}{#instance}} \let\doifparallelelse\doifelseparallel @@ -137,7 +145,7 @@ {\dodoubleempty\buff_parallel_reset} \def\buff_parallel_reset[#name][#instance]% - {\ctxcommand{resetparallel("#name","#instance"))}} + {\clf_resetparallel{#name}{#instance}} \startsetups parallel:place:default \hangafter\plusone diff --git a/tex/context/base/buff-ver.lua b/tex/context/base/buff-ver.lua index 0dc079b31..6dd9d8ebe 100644 --- a/tex/context/base/buff-ver.lua +++ b/tex/context/base/buff-ver.lua @@ -29,14 +29,9 @@ visualizers = visualizers or { } local specifications = allocate() visualizers.specifications = specifications -local scanners = tokens.scanners -local scanstring = scanners.string - -local compilescanner = tokens.compile -local scanners = interfaces.scanners - local context = context local commands = commands +local implement = interfaces.implement local tabtospace = utilities.strings.tabtospace local variables = interfaces.variables @@ -326,6 +321,10 @@ function visualizers.register(name,specification) return specification end +function visualizers.getspecification(name) + return specifications[lower(name)] +end + local escapepatterns = allocate() visualizers.escapepatterns = escapepatterns @@ -708,14 +707,6 @@ end local getlines = buffers.getlines --- interface - -function commands.doifelsevisualizer(name) - commands.doifelse(specifications[lower(name)]) -end - -commands.loadvisualizer = visualizers.load - -- local decodecomment = resolvers.macros.decodecomment -- experiment local function typebuffer(settings) @@ -742,9 +733,6 @@ local function processbuffer(settings) end end -commands.typebuffer = typebuffer -commands.processbuffer = processbuffer - -- not really buffers but it's closely related -- A string.gsub(str,"(\\.-) +$","%1") is faster than an lpeg when there is a @@ -805,32 +793,8 @@ local function typefile(settings) end end -commands.typestring = typestring -commands.typefile = typefile - --- scanners.typenormal = function() --- typestring { --- nature = "inline", --- data = scanstring(), --- tab = scanstring(), --- method = scanstring(), --- compact = scanstring(), --- escape = scanstring(), --- } --- end - --- scanners.typenested = function() --- typestring { --- nature = "inline", --- method = "nested", --- data = scanstring(), --- tab = scanstring(), --- option = scanstring(), --- escape = scanstring(), --- } --- end - -scanners.type = compilescanner { +implement { + name = "type", actions = typestring, arguments = { { @@ -845,7 +809,8 @@ scanners.type = compilescanner { } } -scanners.processbuffer = compilescanner { +implement { + name = "processbuffer", actions = processbuffer, arguments = { { @@ -858,23 +823,48 @@ scanners.processbuffer = compilescanner { } } -local get_typing = compilescanner { - { - { "name" }, - { "strip" }, - { "range" }, - { "regime" }, - { "tab" }, - { "method" }, - { "escape" }, - { "nature" }, +implement { + name = "typebuffer", + actions = typebuffer, + arguments = { + { + { "name" }, + { "strip" }, + { "range" }, + { "regime" }, + { "tab" }, + { "method" }, + { "escape" }, + { "nature" }, + } + } +} + +implement { + name = "typefile", + actions = typefile, + arguments = { + { + { "name" }, + { "strip" }, + { "range" }, + { "regime" }, + { "tab" }, + { "method" }, + { "escape" }, + { "nature" }, + } } } -scanners.typebuffer = function() - typebuffer(get_typing()) -end +implement { + name = "doifelsevisualizer", + actions = { visualizers.getspecification, commands.doifelse }, + arguments = "string" +} -scanners.typefile = function() - typefile(get_typing()) -end +implement { + name = "loadvisualizer", + actions = visualizers.load, + arguments = "string" +} diff --git a/tex/context/base/buff-ver.mkiv b/tex/context/base/buff-ver.mkiv index a6bacb04f..ace149184 100644 --- a/tex/context/base/buff-ver.mkiv +++ b/tex/context/base/buff-ver.mkiv @@ -191,13 +191,17 @@ \fi \to \everydefinetyping - \appendtoks \buff_verbatim_initialize_visualizer{\typingparameter\c!option}% we can check at the tex end \to \everysetuptyping \def\buff_verbatim_initialize_visualizer#1% - {\ifproductionrun\ctxcommand{loadvisualizer("#1")}\fi} + {\ifproductionrun\clf_loadvisualizer{#1}\fi} + +\unexpanded\def\doifelsevisualizer#1% + {\clf_doifelsevisualizer{#1}} + +\let\doifvisualizerelse\doifelsevisualizer %D Verbatim command are very sensitive to argument processing, %D which is a direct result of the \CATCODES\ being fixed at diff --git a/tex/context/base/char-fio.lua b/tex/context/base/char-fio.lua index 4f091ebec..ab2555935 100644 --- a/tex/context/base/char-fio.lua +++ b/tex/context/base/char-fio.lua @@ -47,7 +47,7 @@ local enforced = { ["characters.filters.utf.decompose"] = true, } -function characters.filters.utf.enable() +function utffilters.enable() for k, v in next, enforced do if v then if reporting == "yes" then @@ -86,3 +86,9 @@ directives.register("filters.utf.collapse", function(v) configure("characters.f directives.register("filters.utf.decompose", function(v) configure("characters.filters.utf.decompose",v) end) utffilters.setskippable { "mkiv", "mkvi", "mkix", "mkxi" } + +interfaces.implement { + name = "enableutf", + onlyonce = true, + actions = utffilters.enable +} diff --git a/tex/context/base/char-ini.lua b/tex/context/base/char-ini.lua index b50847d8e..56b038cee 100644 --- a/tex/context/base/char-ini.lua +++ b/tex/context/base/char-ini.lua @@ -170,9 +170,8 @@ local blocks = allocate { ["buginese"] = { first = 0x01A00, last = 0x01A1F, otf="bugi", description = "Buginese" }, ["buhid"] = { first = 0x01740, last = 0x0175F, otf="buhd", description = "Buhid" }, ["byzantinemusicalsymbols"] = { first = 0x1D000, last = 0x1D0FF, otf="byzm", description = "Byzantine Musical Symbols" }, - ["caucasianalbanian"] = { first = 0x10530, last = 0x1056F, description = "Caucasian Albanian" }, - ["commonindicnumberforms"] = { first = 0x0A830, last = 0x0A83F, description = "Common Indic Number Forms" }, ["carian"] = { first = 0x102A0, last = 0x102DF, description = "Carian" }, + ["caucasianalbanian"] = { first = 0x10530, last = 0x1056F, description = "Caucasian Albanian" }, ["chakma"] = { first = 0x11100, last = 0x1114F, description = "Chakma" }, ["cham"] = { first = 0x0AA00, last = 0x0AA5F, description = "Cham" }, ["cherokee"] = { first = 0x013A0, last = 0x013FF, otf="cher", description = "Cherokee" }, @@ -193,6 +192,7 @@ local blocks = allocate { ["combiningdiacriticalmarksforsymbols"] = { first = 0x020D0, last = 0x020FF, description = "Combining Diacritical Marks for Symbols" }, ["combiningdiacriticalmarkssupplement"] = { first = 0x01DC0, last = 0x01DFF, description = "Combining Diacritical Marks Supplement" }, ["combininghalfmarks"] = { first = 0x0FE20, last = 0x0FE2F, description = "Combining Half Marks" }, + ["commonindicnumberforms"] = { first = 0x0A830, last = 0x0A83F, description = "Common Indic Number Forms" }, ["controlpictures"] = { first = 0x02400, last = 0x0243F, description = "Control Pictures" }, ["coptic"] = { first = 0x02C80, last = 0x02CFF, otf="copt", description = "Coptic" }, ["copticepactnumbers"] = { first = 0x102E0, last = 0x102FF, description = "Coptic Epact Numbers" }, @@ -208,189 +208,256 @@ local blocks = allocate { ["deseret"] = { first = 0x10400, last = 0x1044F, otf="dsrt", description = "Deseret" }, ["devanagari"] = { first = 0x00900, last = 0x0097F, otf="deva", description = "Devanagari" }, ["devanagariextended"] = { first = 0x0A8E0, last = 0x0A8FF, description = "Devanagari Extended" }, - ["dingbats"] = { first = 0x02700, last = 0x027BF, description = "Dingbats" }, - ["dominotiles"] = { first = 0x1F030, last = 0x1F09F, description = "Domino Tiles" }, - ["duployan"] = { first = 0x1BC00, last = 0x1BC9F, description = "Duployan" }, - ["egyptianhieroglyphs"] = { first = 0x13000, last = 0x1342F, description = "Egyptian Hieroglyphs" }, - ["elbasan"] = { first = 0x10500, last = 0x1052F, description = "Elbasan" }, - ["emoticons"] = { first = 0x1F600, last = 0x1F64F, description = "Emoticons" }, - ["enclosedalphanumericsupplement"] = { first = 0x1F100, last = 0x1F1FF, description = "Enclosed Alphanumeric Supplement" }, - ["enclosedalphanumerics"] = { first = 0x02460, last = 0x024FF, description = "Enclosed Alphanumerics" }, - ["enclosedcjklettersandmonths"] = { first = 0x03200, last = 0x032FF, description = "Enclosed CJK Letters and Months" }, - ["enclosedideographicsupplement"] = { first = 0x1F200, last = 0x1F2FF, description = "Enclosed Ideographic Supplement" }, - ["ethiopic"] = { first = 0x01200, last = 0x0137F, otf="ethi", description = "Ethiopic" }, - ["ethiopicextended"] = { first = 0x02D80, last = 0x02DDF, otf="ethi", description = "Ethiopic Extended" }, - ["ethiopicextendeda"] = { first = 0x0AB00, last = 0x0AB2F, description = "Ethiopic Extended-A" }, - ["ethiopicsupplement"] = { first = 0x01380, last = 0x0139F, otf="ethi", description = "Ethiopic Supplement" }, - ["generalpunctuation"] = { first = 0x02000, last = 0x0206F, description = "General Punctuation" }, - ["geometricshapes"] = { first = 0x025A0, last = 0x025FF, description = "Geometric Shapes" }, - ["geometricshapesextended"] = { first = 0x1F780, last = 0x1F7FF, description = "Geometric Shapes Extended" }, - ["georgian"] = { first = 0x010A0, last = 0x010FF, otf="geor", description = "Georgian" }, - ["georgiansupplement"] = { first = 0x02D00, last = 0x02D2F, otf="geor", description = "Georgian Supplement" }, - ["glagolitic"] = { first = 0x02C00, last = 0x02C5F, otf="glag", description = "Glagolitic" }, - ["gothic"] = { first = 0x10330, last = 0x1034F, otf="goth", description = "Gothic" }, - ["grantha"] = { first = 0x11300, last = 0x1137F, description = "Grantha" }, - ["greekandcoptic"] = { first = 0x00370, last = 0x003FF, otf="grek", description = "Greek and Coptic" }, - ["greekextended"] = { first = 0x01F00, last = 0x01FFF, otf="grek", description = "Greek Extended" }, - ["gujarati"] = { first = 0x00A80, last = 0x00AFF, otf="gujr", description = "Gujarati" }, - ["gurmukhi"] = { first = 0x00A00, last = 0x00A7F, otf="guru", description = "Gurmukhi" }, - ["halfwidthandfullwidthforms"] = { first = 0x0FF00, last = 0x0FFEF, description = "Halfwidth and Fullwidth Forms" }, - ["hangulcompatibilityjamo"] = { first = 0x03130, last = 0x0318F, otf="jamo", description = "Hangul Compatibility Jamo" }, - ["hanguljamo"] = { first = 0x01100, last = 0x011FF, otf="jamo", description = "Hangul Jamo" }, - ["hanguljamoextendeda"] = { first = 0x0A960, last = 0x0A97F, description = "Hangul Jamo Extended-A" }, - ["hanguljamoextendedb"] = { first = 0x0D7B0, last = 0x0D7FF, description = "Hangul Jamo Extended-B" }, - ["hangulsyllables"] = { first = 0x0AC00, last = 0x0D7AF, otf="hang", description = "Hangul Syllables" }, - ["hanunoo"] = { first = 0x01720, last = 0x0173F, otf="hano", description = "Hanunoo" }, - ["hebrew"] = { first = 0x00590, last = 0x005FF, otf="hebr", description = "Hebrew" }, - ["highprivateusesurrogates"] = { first = 0x0DB80, last = 0x0DBFF, description = "High Private Use Surrogates" }, - ["highsurrogates"] = { first = 0x0D800, last = 0x0DB7F, description = "High Surrogates" }, - ["hiragana"] = { first = 0x03040, last = 0x0309F, otf="kana", description = "Hiragana" }, - ["ideographicdescriptioncharacters"] = { first = 0x02FF0, last = 0x02FFF, description = "Ideographic Description Characters" }, - ["imperialaramaic"] = { first = 0x10840, last = 0x1085F, description = "Imperial Aramaic" }, - ["inscriptionalpahlavi"] = { first = 0x10B60, last = 0x10B7F, description = "Inscriptional Pahlavi" }, - ["inscriptionalparthian"] = { first = 0x10B40, last = 0x10B5F, description = "Inscriptional Parthian" }, - ["ipaextensions"] = { first = 0x00250, last = 0x002AF, description = "IPA Extensions" }, - ["javanese"] = { first = 0x0A980, last = 0x0A9DF, description = "Javanese" }, - ["kaithi"] = { first = 0x11080, last = 0x110CF, description = "Kaithi" }, - ["kanasupplement"] = { first = 0x1B000, last = 0x1B0FF, description = "Kana Supplement" }, - ["kanbun"] = { first = 0x03190, last = 0x0319F, description = "Kanbun" }, - ["kangxiradicals"] = { first = 0x02F00, last = 0x02FDF, description = "Kangxi Radicals" }, - ["kannada"] = { first = 0x00C80, last = 0x00CFF, otf="knda", description = "Kannada" }, - ["katakana"] = { first = 0x030A0, last = 0x030FF, otf="kana", description = "Katakana" }, - ["katakanaphoneticextensions"] = { first = 0x031F0, last = 0x031FF, otf="kana", description = "Katakana Phonetic Extensions" }, - ["kayahli"] = { first = 0x0A900, last = 0x0A92F, description = "Kayah Li" }, - ["kharoshthi"] = { first = 0x10A00, last = 0x10A5F, otf="khar", description = "Kharoshthi" }, - ["khmer"] = { first = 0x01780, last = 0x017FF, otf="khmr", description = "Khmer" }, - ["khmersymbols"] = { first = 0x019E0, last = 0x019FF, otf="khmr", description = "Khmer Symbols" }, - ["khojki"] = { first = 0x11200, last = 0x1124F, description = "Khojki" }, - ["khudawadi"] = { first = 0x112B0, last = 0x112FF, description = "Khudawadi" }, - ["lao"] = { first = 0x00E80, last = 0x00EFF, otf="lao", description = "Lao" }, - ["latinextendeda"] = { first = 0x00100, last = 0x0017F, otf="latn", description = "Latin Extended-A" }, - ["latinextendedadditional"] = { first = 0x01E00, last = 0x01EFF, otf="latn", description = "Latin Extended Additional" }, - ["latinextendedb"] = { first = 0x00180, last = 0x0024F, otf="latn", description = "Latin Extended-B" }, - ["latinextendedc"] = { first = 0x02C60, last = 0x02C7F, otf="latn", description = "Latin Extended-C" }, - ["latinextendedd"] = { first = 0x0A720, last = 0x0A7FF, otf="latn", description = "Latin Extended-D" }, - ["latinextendede"] = { first = 0x0AB30, last = 0x0AB6F, description = "Latin Extended-E" }, - ["latinsupplement"] = { first = 0x00080, last = 0x000FF, otf="latn", description = "Latin-1 Supplement" }, - ["lepcha"] = { first = 0x01C00, last = 0x01C4F, description = "Lepcha" }, - ["letterlikesymbols"] = { first = 0x02100, last = 0x0214F, description = "Letterlike Symbols" }, - ["limbu"] = { first = 0x01900, last = 0x0194F, otf="limb", description = "Limbu" }, - ["lineara"] = { first = 0x10600, last = 0x1077F, description = "Linear A" }, - ["linearbideograms"] = { first = 0x10080, last = 0x100FF, otf="linb", description = "Linear B Ideograms" }, - ["linearbsyllabary"] = { first = 0x10000, last = 0x1007F, otf="linb", description = "Linear B Syllabary" }, - ["lisu"] = { first = 0x0A4D0, last = 0x0A4FF, description = "Lisu" }, - ["lowsurrogates"] = { first = 0x0DC00, last = 0x0DFFF, description = "Low Surrogates" }, - ["lycian"] = { first = 0x10280, last = 0x1029F, description = "Lycian" }, - ["lydian"] = { first = 0x10920, last = 0x1093F, description = "Lydian" }, - ["mahajani"] = { first = 0x11150, last = 0x1117F, description = "Mahajani" }, - ["mahjongtiles"] = { first = 0x1F000, last = 0x1F02F, description = "Mahjong Tiles" }, - ["malayalam"] = { first = 0x00D00, last = 0x00D7F, otf="mlym", description = "Malayalam" }, - ["mandaic"] = { first = 0x00840, last = 0x0085F, otf="mand", description = "Mandaic" }, - ["manichaean"] = { first = 0x10AC0, last = 0x10AFF, description = "Manichaean" }, - ["mathematicalalphanumericsymbols"] = { first = 0x1D400, last = 0x1D7FF, description = "Mathematical Alphanumeric Symbols" }, - ["mathematicaloperators"] = { first = 0x02200, last = 0x022FF, description = "Mathematical Operators" }, - ["meeteimayek"] = { first = 0x0ABC0, last = 0x0ABFF, description = "Meetei Mayek" }, - ["meeteimayekextensions"] = { first = 0x0AAE0, last = 0x0AAFF, description = "Meetei Mayek Extensions" }, - ["mendekikakui"] = { first = 0x1E800, last = 0x1E8DF, description = "Mende Kikakui" }, - ["meroiticcursive"] = { first = 0x109A0, last = 0x109FF, description = "Meroitic Cursive" }, - ["meroitichieroglyphs"] = { first = 0x10980, last = 0x1099F, description = "Meroitic Hieroglyphs" }, - ["miao"] = { first = 0x16F00, last = 0x16F9F, description = "Miao" }, - ["miscellaneousmathematicalsymbolsa"] = { first = 0x027C0, last = 0x027EF, description = "Miscellaneous Mathematical Symbols-A" }, - ["miscellaneousmathematicalsymbolsb"] = { first = 0x02980, last = 0x029FF, description = "Miscellaneous Mathematical Symbols-B" }, - ["miscellaneoussymbols"] = { first = 0x02600, last = 0x026FF, description = "Miscellaneous Symbols" }, - ["miscellaneoussymbolsandarrows"] = { first = 0x02B00, last = 0x02BFF, description = "Miscellaneous Symbols and Arrows" }, - ["miscellaneoussymbolsandpictographs"] = { first = 0x1F300, last = 0x1F5FF, description = "Miscellaneous Symbols and Pictographs" }, - ["miscellaneoustechnical"] = { first = 0x02300, last = 0x023FF, description = "Miscellaneous Technical" }, - ["modi"] = { first = 0x11600, last = 0x1165F, description = "Modi" }, - ["modifiertoneletters"] = { first = 0x0A700, last = 0x0A71F, description = "Modifier Tone Letters" }, - ["mongolian"] = { first = 0x01800, last = 0x018AF, otf="mong", description = "Mongolian" }, - ["mro"] = { first = 0x16A40, last = 0x16A6F, description = "Mro" }, - ["musicalsymbols"] = { first = 0x1D100, last = 0x1D1FF, otf="musc", description = "Musical Symbols" }, - ["myanmar"] = { first = 0x01000, last = 0x0109F, otf="mymr", description = "Myanmar" }, - ["myanmarextendeda"] = { first = 0x0AA60, last = 0x0AA7F, description = "Myanmar Extended-A" }, - ["myanmarextendedb"] = { first = 0x0A9E0, last = 0x0A9FF, description = "Myanmar Extended-B" }, - ["nabataean"] = { first = 0x10880, last = 0x108AF, description = "Nabataean" }, - ["newtailue"] = { first = 0x01980, last = 0x019DF, description = "New Tai Lue" }, - ["nko"] = { first = 0x007C0, last = 0x007FF, otf="nko", description = "NKo" }, - ["numberforms"] = { first = 0x02150, last = 0x0218F, description = "Number Forms" }, - ["ogham"] = { first = 0x01680, last = 0x0169F, otf="ogam", description = "Ogham" }, - ["olchiki"] = { first = 0x01C50, last = 0x01C7F, description = "Ol Chiki" }, - ["olditalic"] = { first = 0x10300, last = 0x1032F, otf="ital", description = "Old Italic" }, - ["oldnortharabian"] = { first = 0x10A80, last = 0x10A9F, description = "Old North Arabian" }, - ["oldpermic"] = { first = 0x10350, last = 0x1037F, description = "Old Permic" }, - ["oldpersian"] = { first = 0x103A0, last = 0x103DF, otf="xpeo", description = "Old Persian" }, - ["oldsoutharabian"] = { first = 0x10A60, last = 0x10A7F, description = "Old South Arabian" }, - ["oldturkic"] = { first = 0x10C00, last = 0x10C4F, description = "Old Turkic" }, - ["opticalcharacterrecognition"] = { first = 0x02440, last = 0x0245F, description = "Optical Character Recognition" }, - ["oriya"] = { first = 0x00B00, last = 0x00B7F, otf="orya", description = "Oriya" }, - ["ornamentaldingbats"] = { first = 0x1F650, last = 0x1F67F, description = "Ornamental Dingbats" }, - ["osmanya"] = { first = 0x10480, last = 0x104AF, otf="osma", description = "Osmanya" }, - ["pahawhhmong"] = { first = 0x16B00, last = 0x16B8F, description = "Pahawh Hmong" }, - ["palmyrene"] = { first = 0x10860, last = 0x1087F, description = "Palmyrene" }, - ["paucinhau"] = { first = 0x11AC0, last = 0x11AFF, description = "Pau Cin Hau" }, - ["phagspa"] = { first = 0x0A840, last = 0x0A87F, otf="phag", description = "Phags-pa" }, - ["phaistosdisc"] = { first = 0x101D0, last = 0x101FF, description = "Phaistos Disc" }, - ["phoenician"] = { first = 0x10900, last = 0x1091F, otf="phnx", description = "Phoenician" }, - ["phoneticextensions"] = { first = 0x01D00, last = 0x01D7F, description = "Phonetic Extensions" }, - ["phoneticextensionssupplement"] = { first = 0x01D80, last = 0x01DBF, description = "Phonetic Extensions Supplement" }, - ["playingcards"] = { first = 0x1F0A0, last = 0x1F0FF, description = "Playing Cards" }, - ["privateusearea"] = { first = 0x0E000, last = 0x0F8FF, description = "Private Use Area" }, - ["psalterpahlavi"] = { first = 0x10B80, last = 0x10BAF, description = "Psalter Pahlavi" }, - ["rejang"] = { first = 0x0A930, last = 0x0A95F, description = "Rejang" }, - ["ruminumeralsymbols"] = { first = 0x10E60, last = 0x10E7F, description = "Rumi Numeral Symbols" }, - ["runic"] = { first = 0x016A0, last = 0x016FF, otf="runr", description = "Runic" }, - ["samaritan"] = { first = 0x00800, last = 0x0083F, description = "Samaritan" }, - ["saurashtra"] = { first = 0x0A880, last = 0x0A8DF, description = "Saurashtra" }, - ["sharada"] = { first = 0x11180, last = 0x111DF, description = "Sharada" }, - ["shavian"] = { first = 0x10450, last = 0x1047F, otf="shaw", description = "Shavian" }, - ["shorthandformatcontrols"] = { first = 0x1BCA0, last = 0x1BCAF, description = "Shorthand Format Controls" }, - ["siddham"] = { first = 0x11580, last = 0x115FF, description = "Siddham" }, - ["sinhala"] = { first = 0x00D80, last = 0x00DFF, otf="sinh", description = "Sinhala" }, - ["sinhalaarchaicnumbers"] = { first = 0x111E0, last = 0x111FF, description = "Sinhala Archaic Numbers" }, - ["smallformvariants"] = { first = 0x0FE50, last = 0x0FE6F, description = "Small Form Variants" }, - ["sorasompeng"] = { first = 0x110D0, last = 0x110FF, description = "Sora Sompeng" }, - ["spacingmodifierletters"] = { first = 0x002B0, last = 0x002FF, description = "Spacing Modifier Letters" }, - ["specials"] = { first = 0x0FFF0, last = 0x0FFFF, description = "Specials" }, - ["sundanese"] = { first = 0x01B80, last = 0x01BBF, description = "Sundanese" }, - ["sundanesesupplement"] = { first = 0x01CC0, last = 0x01CCF, description = "Sundanese Supplement" }, - ["superscriptsandsubscripts"] = { first = 0x02070, last = 0x0209F, description = "Superscripts and Subscripts" }, - ["supplementalarrowsa"] = { first = 0x027F0, last = 0x027FF, description = "Supplemental Arrows-A" }, - ["supplementalarrowsb"] = { first = 0x02900, last = 0x0297F, description = "Supplemental Arrows-B" }, - ["supplementalarrowsc"] = { first = 0x1F800, last = 0x1F8FF, description = "Supplemental Arrows-C" }, - ["supplementalmathematicaloperators"] = { first = 0x02A00, last = 0x02AFF, description = "Supplemental Mathematical Operators" }, - ["supplementalpunctuation"] = { first = 0x02E00, last = 0x02E7F, description = "Supplemental Punctuation" }, - ["supplementaryprivateuseareaa"] = { first = 0xF0000, last = 0xFFFFF, description = "Supplementary Private Use Area-A" }, - ["supplementaryprivateuseareab"] = { first = 0x100000,last = 0x10FFFF, description = "Supplementary Private Use Area-B" }, - ["sylotinagri"] = { first = 0x0A800, last = 0x0A82F, otf="sylo", description = "Syloti Nagri" }, - ["syriac"] = { first = 0x00700, last = 0x0074F, otf="syrc", description = "Syriac" }, - ["tagalog"] = { first = 0x01700, last = 0x0171F, otf="tglg", description = "Tagalog" }, - ["tagbanwa"] = { first = 0x01760, last = 0x0177F, otf="tagb", description = "Tagbanwa" }, - ["tags"] = { first = 0xE0000, last = 0xE007F, description = "Tags" }, - ["taile"] = { first = 0x01950, last = 0x0197F, otf="tale", description = "Tai Le" }, - ["taitham"] = { first = 0x01A20, last = 0x01AAF, description = "Tai Tham" }, - ["taiviet"] = { first = 0x0AA80, last = 0x0AADF, description = "Tai Viet" }, - ["taixuanjingsymbols"] = { first = 0x1D300, last = 0x1D35F, description = "Tai Xuan Jing Symbols" }, - ["takri"] = { first = 0x11680, last = 0x116CF, description = "Takri" }, - ["tamil"] = { first = 0x00B80, last = 0x00BFF, otf="taml", description = "Tamil" }, - ["telugu"] = { first = 0x00C00, last = 0x00C7F, otf="telu", description = "Telugu" }, - ["thaana"] = { first = 0x00780, last = 0x007BF, otf="thaa", description = "Thaana" }, - ["thai"] = { first = 0x00E00, last = 0x00E7F, otf="thai", description = "Thai" }, - ["tibetan"] = { first = 0x00F00, last = 0x00FFF, otf="tibt", description = "Tibetan" }, - ["tifinagh"] = { first = 0x02D30, last = 0x02D7F, otf="tfng", description = "Tifinagh" }, - ["tirhuta"] = { first = 0x11480, last = 0x114DF, description = "Tirhuta" }, - ["transportandmapsymbols"] = { first = 0x1F680, last = 0x1F6FF, description = "Transport and Map Symbols" }, - ["ugaritic"] = { first = 0x10380, last = 0x1039F, otf="ugar", description = "Ugaritic" }, - ["unifiedcanadianaboriginalsyllabics"] = { first = 0x01400, last = 0x0167F, otf="cans", description = "Unified Canadian Aboriginal Syllabics" }, - ["unifiedcanadianaboriginalsyllabicsextended"] = { first = 0x018B0, last = 0x018FF, description = "Unified Canadian Aboriginal Syllabics Extended" }, - ["vai"] = { first = 0x0A500, last = 0x0A63F, description = "Vai" }, - ["variationselectors"] = { first = 0x0FE00, last = 0x0FE0F, description = "Variation Selectors" }, - ["variationselectorssupplement"] = { first = 0xE0100, last = 0xE01EF, description = "Variation Selectors Supplement" }, - ["vedicextensions"] = { first = 0x01CD0, last = 0x01CFF, description = "Vedic Extensions" }, - ["verticalforms"] = { first = 0x0FE10, last = 0x0FE1F, description = "Vertical Forms" }, - ["warangciti"] = { first = 0x118A0, last = 0x118FF, description = "Warang Citi" }, - ["yijinghexagramsymbols"] = { first = 0x04DC0, last = 0x04DFF, otf="yi", description = "Yijing Hexagram Symbols" }, - ["yiradicals"] = { first = 0x0A490, last = 0x0A4CF, otf="yi", description = "Yi Radicals" }, - ["yisyllables"] = { first = 0x0A000, last = 0x0A48F, otf="yi", description = "Yi Syllables" }, + ["digitsarabicindic"] = { first = 0x00660, last = 0x00669, math = true }, + -- ["digitsbengali"] = { first = 0x009E6, last = 0x009EF, math = true }, + ["digitsbold"] = { first = 0x1D7CE, last = 0x1D7D8, math = true }, + -- ["digitsdevanagari"] = { first = 0x00966, last = 0x0096F, math = true }, + ["digitsdoublestruck"] = { first = 0x1D7D8, last = 0x1D7E2, math = true }, + -- ["digitsethiopic"] = { first = 0x01369, last = 0x01371, math = true }, + ["digitsextendedarabicindic"] = { first = 0x006F0, last = 0x006F9, math = true }, + -- ["digitsgujarati"] = { first = 0x00AE6, last = 0x00AEF, math = true }, + -- ["digitsgurmukhi"] = { first = 0x00A66, last = 0x00A6F, math = true }, + -- ["digitskannada"] = { first = 0x00CE6, last = 0x00CEF, math = true }, + -- ["digitskhmer"] = { first = 0x017E0, last = 0x017E9, math = true }, + -- ["digitslao"] = { first = 0x00ED0, last = 0x00ED9, math = true }, + ["digitslatin"] = { first = 0x00030, last = 0x00039, math = true }, + -- ["digitsmalayalam"] = { first = 0x00D66, last = 0x00D6F, math = true }, + -- ["digitsmongolian"] = { first = 0x01810, last = 0x01809, math = true }, + ["digitsmonospace"] = { first = 0x1D7F6, last = 0x1D80F, math = true }, + -- ["digitsmyanmar"] = { first = 0x01040, last = 0x01049, math = true }, + ["digitsnormal"] = { first = 0x00030, last = 0x00039, math = true }, + -- ["digitsoriya"] = { first = 0x00B66, last = 0x00B6F, math = true }, + ["digitssansserifbold"] = { first = 0x1D7EC, last = 0x1D805, math = true }, + ["digitssansserifnormal"] = { first = 0x1D7E2, last = 0x1D7EC, math = true }, + -- ["digitstamil"] = { first = 0x00030, last = 0x00039, math = true }, -- no zero + -- ["digitstelugu"] = { first = 0x00C66, last = 0x00C6F, math = true }, + -- ["digitsthai"] = { first = 0x00E50, last = 0x00E59, math = true }, + -- ["digitstibetan"] = { first = 0x00F20, last = 0x00F29, math = true }, + ["dingbats"] = { first = 0x02700, last = 0x027BF, description = "Dingbats" }, + ["dominotiles"] = { first = 0x1F030, last = 0x1F09F, description = "Domino Tiles" }, + ["duployan"] = { first = 0x1BC00, last = 0x1BC9F, description = "Duployan" }, + ["egyptianhieroglyphs"] = { first = 0x13000, last = 0x1342F, description = "Egyptian Hieroglyphs" }, + ["elbasan"] = { first = 0x10500, last = 0x1052F, description = "Elbasan" }, + ["emoticons"] = { first = 0x1F600, last = 0x1F64F, description = "Emoticons" }, + ["enclosedalphanumerics"] = { first = 0x02460, last = 0x024FF, description = "Enclosed Alphanumerics" }, + ["enclosedalphanumericsupplement"] = { first = 0x1F100, last = 0x1F1FF, description = "Enclosed Alphanumeric Supplement" }, + ["enclosedcjklettersandmonths"] = { first = 0x03200, last = 0x032FF, description = "Enclosed CJK Letters and Months" }, + ["enclosedideographicsupplement"] = { first = 0x1F200, last = 0x1F2FF, description = "Enclosed Ideographic Supplement" }, + ["ethiopic"] = { first = 0x01200, last = 0x0137F, otf="ethi", description = "Ethiopic" }, + ["ethiopicextended"] = { first = 0x02D80, last = 0x02DDF, otf="ethi", description = "Ethiopic Extended" }, + ["ethiopicextendeda"] = { first = 0x0AB00, last = 0x0AB2F, description = "Ethiopic Extended-A" }, + ["ethiopicsupplement"] = { first = 0x01380, last = 0x0139F, otf="ethi", description = "Ethiopic Supplement" }, + ["generalpunctuation"] = { first = 0x02000, last = 0x0206F, description = "General Punctuation" }, + ["geometricshapes"] = { first = 0x025A0, last = 0x025FF, description = "Geometric Shapes" }, + ["geometricshapes"] = { first = 0x025A0, last = 0x025FF, math = true }, + ["geometricshapesextended"] = { first = 0x1F780, last = 0x1F7FF, description = "Geometric Shapes Extended" }, + ["georgian"] = { first = 0x010A0, last = 0x010FF, otf="geor", description = "Georgian" }, + ["georgiansupplement"] = { first = 0x02D00, last = 0x02D2F, otf="geor", description = "Georgian Supplement" }, + ["glagolitic"] = { first = 0x02C00, last = 0x02C5F, otf="glag", description = "Glagolitic" }, + ["gothic"] = { first = 0x10330, last = 0x1034F, otf="goth", description = "Gothic" }, + ["grantha"] = { first = 0x11300, last = 0x1137F, description = "Grantha" }, + ["greekandcoptic"] = { first = 0x00370, last = 0x003FF, otf="grek", description = "Greek and Coptic" }, + ["greekextended"] = { first = 0x01F00, last = 0x01FFF, otf="grek", description = "Greek Extended" }, + ["gujarati"] = { first = 0x00A80, last = 0x00AFF, otf="gujr", description = "Gujarati" }, + ["gurmukhi"] = { first = 0x00A00, last = 0x00A7F, otf="guru", description = "Gurmukhi" }, + ["halfwidthandfullwidthforms"] = { first = 0x0FF00, last = 0x0FFEF, description = "Halfwidth and Fullwidth Forms" }, + ["hangulcompatibilityjamo"] = { first = 0x03130, last = 0x0318F, otf="jamo", description = "Hangul Compatibility Jamo" }, + ["hanguljamo"] = { first = 0x01100, last = 0x011FF, otf="jamo", description = "Hangul Jamo" }, + ["hanguljamoextendeda"] = { first = 0x0A960, last = 0x0A97F, description = "Hangul Jamo Extended-A" }, + ["hanguljamoextendedb"] = { first = 0x0D7B0, last = 0x0D7FF, description = "Hangul Jamo Extended-B" }, + ["hangulsyllables"] = { first = 0x0AC00, last = 0x0D7AF, otf="hang", description = "Hangul Syllables" }, + ["hanunoo"] = { first = 0x01720, last = 0x0173F, otf="hano", description = "Hanunoo" }, + ["hebrew"] = { first = 0x00590, last = 0x005FF, otf="hebr", description = "Hebrew" }, + ["highprivateusesurrogates"] = { first = 0x0DB80, last = 0x0DBFF, description = "High Private Use Surrogates" }, + ["highsurrogates"] = { first = 0x0D800, last = 0x0DB7F, description = "High Surrogates" }, + ["hiragana"] = { first = 0x03040, last = 0x0309F, otf="kana", description = "Hiragana" }, + ["ideographicdescriptioncharacters"] = { first = 0x02FF0, last = 0x02FFF, description = "Ideographic Description Characters" }, + ["imperialaramaic"] = { first = 0x10840, last = 0x1085F, description = "Imperial Aramaic" }, + ["inscriptionalpahlavi"] = { first = 0x10B60, last = 0x10B7F, description = "Inscriptional Pahlavi" }, + ["inscriptionalparthian"] = { first = 0x10B40, last = 0x10B5F, description = "Inscriptional Parthian" }, + ["ipaextensions"] = { first = 0x00250, last = 0x002AF, description = "IPA Extensions" }, + ["javanese"] = { first = 0x0A980, last = 0x0A9DF, description = "Javanese" }, + ["kaithi"] = { first = 0x11080, last = 0x110CF, description = "Kaithi" }, + ["kanasupplement"] = { first = 0x1B000, last = 0x1B0FF, description = "Kana Supplement" }, + ["kanbun"] = { first = 0x03190, last = 0x0319F, description = "Kanbun" }, + ["kangxiradicals"] = { first = 0x02F00, last = 0x02FDF, description = "Kangxi Radicals" }, + ["kannada"] = { first = 0x00C80, last = 0x00CFF, otf="knda", description = "Kannada" }, + ["katakana"] = { first = 0x030A0, last = 0x030FF, otf="kana", description = "Katakana" }, + ["katakanaphoneticextensions"] = { first = 0x031F0, last = 0x031FF, otf="kana", description = "Katakana Phonetic Extensions" }, + ["kayahli"] = { first = 0x0A900, last = 0x0A92F, description = "Kayah Li" }, + ["kharoshthi"] = { first = 0x10A00, last = 0x10A5F, otf="khar", description = "Kharoshthi" }, + ["khmer"] = { first = 0x01780, last = 0x017FF, otf="khmr", description = "Khmer" }, + ["khmersymbols"] = { first = 0x019E0, last = 0x019FF, otf="khmr", description = "Khmer Symbols" }, + ["khojki"] = { first = 0x11200, last = 0x1124F, description = "Khojki" }, + ["khudawadi"] = { first = 0x112B0, last = 0x112FF, description = "Khudawadi" }, + ["lao"] = { first = 0x00E80, last = 0x00EFF, otf="lao", description = "Lao" }, + ["latinextendeda"] = { first = 0x00100, last = 0x0017F, otf="latn", description = "Latin Extended-A" }, + ["latinextendedadditional"] = { first = 0x01E00, last = 0x01EFF, otf="latn", description = "Latin Extended Additional" }, + ["latinextendedb"] = { first = 0x00180, last = 0x0024F, otf="latn", description = "Latin Extended-B" }, + ["latinextendedc"] = { first = 0x02C60, last = 0x02C7F, otf="latn", description = "Latin Extended-C" }, + ["latinextendedd"] = { first = 0x0A720, last = 0x0A7FF, otf="latn", description = "Latin Extended-D" }, + ["latinextendede"] = { first = 0x0AB30, last = 0x0AB6F, description = "Latin Extended-E" }, + ["latinsupplement"] = { first = 0x00080, last = 0x000FF, otf="latn", description = "Latin-1 Supplement" }, + ["lepcha"] = { first = 0x01C00, last = 0x01C4F, description = "Lepcha" }, + ["letterlikesymbols"] = { first = 0x02100, last = 0x0214F, description = "Letterlike Symbols" }, + ["letterlikesymbols"] = { first = 0x02100, last = 0x0214F, math = true }, + ["limbu"] = { first = 0x01900, last = 0x0194F, otf="limb", description = "Limbu" }, + ["lineara"] = { first = 0x10600, last = 0x1077F, description = "Linear A" }, + ["linearbideograms"] = { first = 0x10080, last = 0x100FF, otf="linb", description = "Linear B Ideograms" }, + ["linearbsyllabary"] = { first = 0x10000, last = 0x1007F, otf="linb", description = "Linear B Syllabary" }, + ["lisu"] = { first = 0x0A4D0, last = 0x0A4FF, description = "Lisu" }, + ["lowercasebold"] = { first = 0x1D41A, last = 0x1D433, math = true }, + ["lowercaseboldfraktur"] = { first = 0x1D586, last = 0x1D59F, math = true }, + ["lowercasebolditalic"] = { first = 0x1D482, last = 0x1D49B, math = true }, + ["lowercaseboldscript"] = { first = 0x1D4EA, last = 0x1D503, math = true }, + ["lowercasedoublestruck"] = { first = 0x1D552, last = 0x1D56B, math = true }, + ["lowercasefraktur"] = { first = 0x1D51E, last = 0x1D537, math = true }, + ["lowercasegreekbold"] = { first = 0x1D6C2, last = 0x1D6DB, math = true }, + ["lowercasegreekbolditalic"] = { first = 0x1D736, last = 0x1D74F, math = true }, + ["lowercasegreekitalic"] = { first = 0x1D6FC, last = 0x1D715, math = true }, + ["lowercasegreeknormal"] = { first = 0x003B1, last = 0x003CA, math = true }, + ["lowercasegreeksansserifbold"] = { first = 0x1D770, last = 0x1D789, math = true }, + ["lowercasegreeksansserifbolditalic"] = { first = 0x1D7AA, last = 0x1D7C3, math = true }, + ["lowercaseitalic"] = { first = 0x1D44E, last = 0x1D467, math = true }, + ["lowercasemonospace"] = { first = 0x1D68A, last = 0x1D6A3, math = true }, + ["lowercasenormal"] = { first = 0x00061, last = 0x0007A, math = true }, + ["lowercasesansserifbold"] = { first = 0x1D5EE, last = 0x1D607, math = true }, + ["lowercasesansserifbolditalic"] = { first = 0x1D656, last = 0x1D66F, math = true }, + ["lowercasesansserifitalic"] = { first = 0x1D622, last = 0x1D63B, math = true }, + ["lowercasesansserifnormal"] = { first = 0x1D5BA, last = 0x1D5D3, math = true }, + ["lowercasescript"] = { first = 0x1D4B6, last = 0x1D4CF, math = true }, + ["lowsurrogates"] = { first = 0x0DC00, last = 0x0DFFF, description = "Low Surrogates" }, + ["lycian"] = { first = 0x10280, last = 0x1029F, description = "Lycian" }, + ["lydian"] = { first = 0x10920, last = 0x1093F, description = "Lydian" }, + ["mahajani"] = { first = 0x11150, last = 0x1117F, description = "Mahajani" }, + ["mahjongtiles"] = { first = 0x1F000, last = 0x1F02F, description = "Mahjong Tiles" }, + ["malayalam"] = { first = 0x00D00, last = 0x00D7F, otf="mlym", description = "Malayalam" }, + ["mandaic"] = { first = 0x00840, last = 0x0085F, otf="mand", description = "Mandaic" }, + ["manichaean"] = { first = 0x10AC0, last = 0x10AFF, description = "Manichaean" }, + ["mathematicalalphanumericsymbols"] = { first = 0x1D400, last = 0x1D7FF, math = true, description = "Mathematical Alphanumeric Symbols" }, + ["mathematicaloperators"] = { first = 0x02200, last = 0x022FF, math = true, description = "Mathematical Operators" }, + ["meeteimayek"] = { first = 0x0ABC0, last = 0x0ABFF, description = "Meetei Mayek" }, + ["meeteimayekextensions"] = { first = 0x0AAE0, last = 0x0AAFF, description = "Meetei Mayek Extensions" }, + ["mendekikakui"] = { first = 0x1E800, last = 0x1E8DF, description = "Mende Kikakui" }, + ["meroiticcursive"] = { first = 0x109A0, last = 0x109FF, description = "Meroitic Cursive" }, + ["meroitichieroglyphs"] = { first = 0x10980, last = 0x1099F, description = "Meroitic Hieroglyphs" }, + ["miao"] = { first = 0x16F00, last = 0x16F9F, description = "Miao" }, + ["miscellaneousmathematicalsymbolsa"] = { first = 0x027C0, last = 0x027EF, math = true, description = "Miscellaneous Mathematical Symbols-A" }, + ["miscellaneousmathematicalsymbolsb"] = { first = 0x02980, last = 0x029FF, math = true, description = "Miscellaneous Mathematical Symbols-B" }, + ["miscellaneoussymbols"] = { first = 0x02600, last = 0x026FF, math = true, description = "Miscellaneous Symbols" }, + ["miscellaneoussymbolsandarrows"] = { first = 0x02B00, last = 0x02BFF, math = true, description = "Miscellaneous Symbols and Arrows" }, + ["miscellaneoussymbolsandpictographs"] = { first = 0x1F300, last = 0x1F5FF, description = "Miscellaneous Symbols and Pictographs" }, + ["miscellaneoustechnical"] = { first = 0x02300, last = 0x023FF, math = true, description = "Miscellaneous Technical" }, + ["modi"] = { first = 0x11600, last = 0x1165F, description = "Modi" }, + ["modifiertoneletters"] = { first = 0x0A700, last = 0x0A71F, description = "Modifier Tone Letters" }, + ["mongolian"] = { first = 0x01800, last = 0x018AF, otf="mong", description = "Mongolian" }, + ["mro"] = { first = 0x16A40, last = 0x16A6F, description = "Mro" }, + ["musicalsymbols"] = { first = 0x1D100, last = 0x1D1FF, otf="musc", description = "Musical Symbols" }, + ["myanmar"] = { first = 0x01000, last = 0x0109F, otf="mymr", description = "Myanmar" }, + ["myanmarextendeda"] = { first = 0x0AA60, last = 0x0AA7F, description = "Myanmar Extended-A" }, + ["myanmarextendedb"] = { first = 0x0A9E0, last = 0x0A9FF, description = "Myanmar Extended-B" }, + ["nabataean"] = { first = 0x10880, last = 0x108AF, description = "Nabataean" }, + ["newtailue"] = { first = 0x01980, last = 0x019DF, description = "New Tai Lue" }, + ["nko"] = { first = 0x007C0, last = 0x007FF, otf="nko", description = "NKo" }, + ["numberforms"] = { first = 0x02150, last = 0x0218F, description = "Number Forms" }, + ["ogham"] = { first = 0x01680, last = 0x0169F, otf="ogam", description = "Ogham" }, + ["olchiki"] = { first = 0x01C50, last = 0x01C7F, description = "Ol Chiki" }, + ["olditalic"] = { first = 0x10300, last = 0x1032F, otf="ital", description = "Old Italic" }, + ["oldnortharabian"] = { first = 0x10A80, last = 0x10A9F, description = "Old North Arabian" }, + ["oldpermic"] = { first = 0x10350, last = 0x1037F, description = "Old Permic" }, + ["oldpersian"] = { first = 0x103A0, last = 0x103DF, otf="xpeo", description = "Old Persian" }, + ["oldsoutharabian"] = { first = 0x10A60, last = 0x10A7F, description = "Old South Arabian" }, + ["oldturkic"] = { first = 0x10C00, last = 0x10C4F, description = "Old Turkic" }, + ["opticalcharacterrecognition"] = { first = 0x02440, last = 0x0245F, description = "Optical Character Recognition" }, + ["oriya"] = { first = 0x00B00, last = 0x00B7F, otf="orya", description = "Oriya" }, + ["ornamentaldingbats"] = { first = 0x1F650, last = 0x1F67F, description = "Ornamental Dingbats" }, + ["osmanya"] = { first = 0x10480, last = 0x104AF, otf="osma", description = "Osmanya" }, + ["pahawhhmong"] = { first = 0x16B00, last = 0x16B8F, description = "Pahawh Hmong" }, + ["palmyrene"] = { first = 0x10860, last = 0x1087F, description = "Palmyrene" }, + ["paucinhau"] = { first = 0x11AC0, last = 0x11AFF, description = "Pau Cin Hau" }, + ["phagspa"] = { first = 0x0A840, last = 0x0A87F, otf="phag", description = "Phags-pa" }, + ["phaistosdisc"] = { first = 0x101D0, last = 0x101FF, description = "Phaistos Disc" }, + ["phoenician"] = { first = 0x10900, last = 0x1091F, otf="phnx", description = "Phoenician" }, + ["phoneticextensions"] = { first = 0x01D00, last = 0x01D7F, description = "Phonetic Extensions" }, + ["phoneticextensionssupplement"] = { first = 0x01D80, last = 0x01DBF, description = "Phonetic Extensions Supplement" }, + ["playingcards"] = { first = 0x1F0A0, last = 0x1F0FF, description = "Playing Cards" }, + ["privateusearea"] = { first = 0x0E000, last = 0x0F8FF, description = "Private Use Area" }, + ["psalterpahlavi"] = { first = 0x10B80, last = 0x10BAF, description = "Psalter Pahlavi" }, + ["rejang"] = { first = 0x0A930, last = 0x0A95F, description = "Rejang" }, + ["ruminumeralsymbols"] = { first = 0x10E60, last = 0x10E7F, description = "Rumi Numeral Symbols" }, + ["runic"] = { first = 0x016A0, last = 0x016FF, otf="runr", description = "Runic" }, + ["samaritan"] = { first = 0x00800, last = 0x0083F, description = "Samaritan" }, + ["saurashtra"] = { first = 0x0A880, last = 0x0A8DF, description = "Saurashtra" }, + ["sharada"] = { first = 0x11180, last = 0x111DF, description = "Sharada" }, + ["shavian"] = { first = 0x10450, last = 0x1047F, otf="shaw", description = "Shavian" }, + ["shorthandformatcontrols"] = { first = 0x1BCA0, last = 0x1BCAF, description = "Shorthand Format Controls" }, + ["siddham"] = { first = 0x11580, last = 0x115FF, description = "Siddham" }, + ["sinhala"] = { first = 0x00D80, last = 0x00DFF, otf="sinh", description = "Sinhala" }, + ["sinhalaarchaicnumbers"] = { first = 0x111E0, last = 0x111FF, description = "Sinhala Archaic Numbers" }, + ["smallformvariants"] = { first = 0x0FE50, last = 0x0FE6F, description = "Small Form Variants" }, + ["sorasompeng"] = { first = 0x110D0, last = 0x110FF, description = "Sora Sompeng" }, + ["spacingmodifierletters"] = { first = 0x002B0, last = 0x002FF, description = "Spacing Modifier Letters" }, + ["specials"] = { first = 0x0FFF0, last = 0x0FFFF, description = "Specials" }, + ["sundanese"] = { first = 0x01B80, last = 0x01BBF, description = "Sundanese" }, + ["sundanesesupplement"] = { first = 0x01CC0, last = 0x01CCF, description = "Sundanese Supplement" }, + ["superscriptsandsubscripts"] = { first = 0x02070, last = 0x0209F, description = "Superscripts and Subscripts" }, + ["supplementalarrowsa"] = { first = 0x027F0, last = 0x027FF, math = true, description = "Supplemental Arrows-A" }, + ["supplementalarrowsb"] = { first = 0x02900, last = 0x0297F, math = true, description = "Supplemental Arrows-B" }, + ["supplementalarrowsc"] = { first = 0x1F800, last = 0x1F8FF, math = true, description = "Supplemental Arrows-C" }, + ["supplementalmathematicaloperators"] = { first = 0x02A00, last = 0x02AFF, math = true, description = "Supplemental Mathematical Operators" }, + ["supplementalpunctuation"] = { first = 0x02E00, last = 0x02E7F, description = "Supplemental Punctuation" }, + ["supplementaryprivateuseareaa"] = { first = 0xF0000, last = 0xFFFFF, description = "Supplementary Private Use Area-A" }, + ["supplementaryprivateuseareab"] = { first = 0x100000,last = 0x10FFFF, description = "Supplementary Private Use Area-B" }, + ["sylotinagri"] = { first = 0x0A800, last = 0x0A82F, otf="sylo", description = "Syloti Nagri" }, + ["syriac"] = { first = 0x00700, last = 0x0074F, otf="syrc", description = "Syriac" }, + ["tagalog"] = { first = 0x01700, last = 0x0171F, otf="tglg", description = "Tagalog" }, + ["tagbanwa"] = { first = 0x01760, last = 0x0177F, otf="tagb", description = "Tagbanwa" }, + ["tags"] = { first = 0xE0000, last = 0xE007F, description = "Tags" }, + ["taile"] = { first = 0x01950, last = 0x0197F, otf="tale", description = "Tai Le" }, + ["taitham"] = { first = 0x01A20, last = 0x01AAF, description = "Tai Tham" }, + ["taiviet"] = { first = 0x0AA80, last = 0x0AADF, description = "Tai Viet" }, + ["taixuanjingsymbols"] = { first = 0x1D300, last = 0x1D35F, description = "Tai Xuan Jing Symbols" }, + ["takri"] = { first = 0x11680, last = 0x116CF, description = "Takri" }, + ["tamil"] = { first = 0x00B80, last = 0x00BFF, otf="taml", description = "Tamil" }, + ["telugu"] = { first = 0x00C00, last = 0x00C7F, otf="telu", description = "Telugu" }, + ["thaana"] = { first = 0x00780, last = 0x007BF, otf="thaa", description = "Thaana" }, + ["thai"] = { first = 0x00E00, last = 0x00E7F, otf="thai", description = "Thai" }, + ["tibetan"] = { first = 0x00F00, last = 0x00FFF, otf="tibt", description = "Tibetan" }, + ["tifinagh"] = { first = 0x02D30, last = 0x02D7F, otf="tfng", description = "Tifinagh" }, + ["tirhuta"] = { first = 0x11480, last = 0x114DF, description = "Tirhuta" }, + ["transportandmapsymbols"] = { first = 0x1F680, last = 0x1F6FF, description = "Transport and Map Symbols" }, + ["ugaritic"] = { first = 0x10380, last = 0x1039F, otf="ugar", description = "Ugaritic" }, + ["unifiedcanadianaboriginalsyllabics"] = { first = 0x01400, last = 0x0167F, otf="cans", description = "Unified Canadian Aboriginal Syllabics" }, + ["unifiedcanadianaboriginalsyllabicsextended"] = { first = 0x018B0, last = 0x018FF, description = "Unified Canadian Aboriginal Syllabics Extended" }, + ["uppercasebold"] = { first = 0x1D400, last = 0x1D419, math = true }, + ["uppercaseboldfraktur"] = { first = 0x1D56C, last = 0x1D585, math = true }, + ["uppercasebolditalic"] = { first = 0x1D468, last = 0x1D481, math = true }, + ["uppercaseboldscript"] = { first = 0x1D4D0, last = 0x1D4E9, math = true }, + ["uppercasedoublestruck"] = { first = 0x1D538, last = 0x1D551, math = true }, + ["uppercasefraktur"] = { first = 0x1D504, last = 0x1D51D, math = true }, + ["uppercasegreekbold"] = { first = 0x1D6A8, last = 0x1D6C1, math = true }, + ["uppercasegreekbolditalic"] = { first = 0x1D71C, last = 0x1D735, math = true }, + ["uppercasegreekitalic"] = { first = 0x1D6E2, last = 0x1D6FB, math = true }, + ["uppercasegreeknormal"] = { first = 0x00391, last = 0x003AA, math = true }, + ["uppercasegreeksansserifbold"] = { first = 0x1D756, last = 0x1D76F, math = true }, + ["uppercasegreeksansserifbolditalic"] = { first = 0x1D790, last = 0x1D7A9, math = true }, + ["uppercaseitalic"] = { first = 0x1D434, last = 0x1D44D, math = true }, + ["uppercasemonospace"] = { first = 0x1D670, last = 0x1D689, math = true }, + ["uppercasenormal"] = { first = 0x00041, last = 0x0005A, math = true }, + ["uppercasesansserifbold"] = { first = 0x1D5D4, last = 0x1D5ED, math = true }, + ["uppercasesansserifbolditalic"] = { first = 0x1D63C, last = 0x1D655, math = true }, + ["uppercasesansserifitalic"] = { first = 0x1D608, last = 0x1D621, math = true }, + ["uppercasesansserifnormal"] = { first = 0x1D5A0, last = 0x1D5B9, math = true }, + ["uppercasescript"] = { first = 0x1D49C, last = 0x1D4B5, math = true }, + ["vai"] = { first = 0x0A500, last = 0x0A63F, description = "Vai" }, + ["variationselectors"] = { first = 0x0FE00, last = 0x0FE0F, description = "Variation Selectors" }, + ["variationselectorssupplement"] = { first = 0xE0100, last = 0xE01EF, description = "Variation Selectors Supplement" }, + ["vedicextensions"] = { first = 0x01CD0, last = 0x01CFF, description = "Vedic Extensions" }, + ["verticalforms"] = { first = 0x0FE10, last = 0x0FE1F, description = "Vertical Forms" }, + ["warangciti"] = { first = 0x118A0, last = 0x118FF, description = "Warang Citi" }, + ["yijinghexagramsymbols"] = { first = 0x04DC0, last = 0x04DFF, otf="yi", description = "Yijing Hexagram Symbols" }, + ["yiradicals"] = { first = 0x0A490, last = 0x0A4CF, otf="yi", description = "Yi Radicals" }, + ["yisyllables"] = { first = 0x0A000, last = 0x0A48F, otf="yi", description = "Yi Syllables" }, } characters.blocks = blocks diff --git a/tex/context/base/char-tex.lua b/tex/context/base/char-tex.lua index 7d2579814..537ab8581 100644 --- a/tex/context/base/char-tex.lua +++ b/tex/context/base/char-tex.lua @@ -468,6 +468,14 @@ implement { arguments = "integer" } +implement { + name = "uchar", + arguments = { "integer", "integer" }, + actions = function(h,l) + context(utfchar(h*256+l)) + end +} + tex.uprint = commands.utfchar -- in contect we don't use lc and uc codes (in fact in luatex we should have a hf code) diff --git a/tex/context/base/char-utf.lua b/tex/context/base/char-utf.lua index 267c97c26..9ed861be0 100644 --- a/tex/context/base/char-utf.lua +++ b/tex/context/base/char-utf.lua @@ -478,6 +478,12 @@ function utffilters.addgrapheme(result,first,second) -- can be U+ 0x string or u end end +interfaces.implement { + name = "addgrapheme", + actions = utffilters.addgrapheme, + arguments = { "string", "string", "string" } +} + -- -- local p_reorder = nil diff --git a/tex/context/base/char-utf.mkiv b/tex/context/base/char-utf.mkiv index 381360905..fe9f402ef 100644 --- a/tex/context/base/char-utf.mkiv +++ b/tex/context/base/char-utf.mkiv @@ -32,7 +32,7 @@ %D initialization till runtime. \appendtoks - \ctxlua{characters.filters.utf.enable()}% + \clf_enableutf % not needed when we create a format so we do it now \to \everyjob %D The next one influences input parsing. @@ -42,6 +42,6 @@ %D \stoptyping \unexpanded\def\definecomposedutf#1 #2 #3 % - {\ctxlua{characters.filters.utf.addgrapheme("#1","#2","#3")}} + {\clf_addgrapheme{#1}{#2}{#3}} \protect diff --git a/tex/context/base/cldf-scn.lua b/tex/context/base/cldf-scn.lua index 3d29f4087..5f7e0c74b 100644 --- a/tex/context/base/cldf-scn.lua +++ b/tex/context/base/cldf-scn.lua @@ -34,7 +34,7 @@ function interfaces.implement(specification) local name = specification.name local arguments = specification.arguments local private = specification.scope == "private" - local once = specification.once + local onlyonce = specification.onlyonce if not actions then if name then report("error: no actions for %a",name) @@ -47,7 +47,7 @@ function interfaces.implement(specification) name = nil end local scanner - local resetter = once and name and commands.ctxresetter(name) + local resetter = onlyonce and name and commands.ctxresetter(name) if resetter then local scan = compile(specification) if private then @@ -76,7 +76,7 @@ function interfaces.implement(specification) return end local command - if once then + if onlyonce then if type(actions) == "function" then actions = { actions } elseif #actions == 1 then diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index f4900cb6e..4a7dcb59a 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2015.04.03 20:01} +\newcontextversion{2015.04.08 14:19} %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/cont-run.lua b/tex/context/base/cont-run.lua index da3fee9f1..08bbe5c3c 100644 --- a/tex/context/base/cont-run.lua +++ b/tex/context/base/cont-run.lua @@ -18,6 +18,9 @@ local fastserialize = table.fastserialize local quoted = string.quoted local possiblepath = sandbox.possiblepath +local context = context +local implement = interfaces.implement + local qualified = { } local writeable = { } local readable = { } @@ -170,7 +173,7 @@ if sandboxing then end -function commands.processjob() +local function processjob() environment.initializefilenames() -- todo: check if we really need to pre-prep the filename @@ -241,3 +244,9 @@ function commands.processjob() context.finishjob() end + +implement { + name = "processjob", + onlyonce = true, + actions = processjob, +} diff --git a/tex/context/base/cont-yes.mkiv b/tex/context/base/cont-yes.mkiv index bc8a0c64b..0b7f3231b 100644 --- a/tex/context/base/cont-yes.mkiv +++ b/tex/context/base/cont-yes.mkiv @@ -92,6 +92,8 @@ % % \stopluacode -\ctxcommand{processjob()} % from cont-run.lua +% We don't want to be in protected mode! + +\getvalue{clf_processjob} % from cont-run.lua \endinput diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf index 246c94b88..7b5df2493 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index ff7b7985a..51212fd07 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -39,7 +39,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2015.04.03 20:01} +\edef\contextversion{2015.04.08 14:19} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/core-con.lua b/tex/context/base/core-con.lua index 19714c900..be462e1d2 100644 --- a/tex/context/base/core-con.lua +++ b/tex/context/base/core-con.lua @@ -1264,3 +1264,9 @@ implement { actions = currentdate, arguments = { "string", false } } + +implement { + name = "unihex", + actions = { formatters["U+%05X"], context }, + arguments = "integer" +} diff --git a/tex/context/base/core-con.mkiv b/tex/context/base/core-con.mkiv index 2d4fca473..f7d718f44 100644 --- a/tex/context/base/core-con.mkiv +++ b/tex/context/base/core-con.mkiv @@ -762,6 +762,10 @@ \m{ν},\m{ξ},\m{ο},\m{π},\m{ρ},\m{σ}, \m{τ},\m{υ},\m{φ},\m{χ},\m{ψ},\m{ω}] +%D Handy too (expanded!): + +\def\unihex#1{\clf_unihex\numexpr#1\relax} + %D Symbol sets: \ifdefined\symbol \else \def\symbol[#1]{#1} \fi % todo diff --git a/tex/context/base/core-ctx.lua b/tex/context/base/core-ctx.lua index a99680778..c20691cd7 100644 --- a/tex/context/base/core-ctx.lua +++ b/tex/context/base/core-ctx.lua @@ -39,12 +39,12 @@ local xmltext = xml.text local report_prepfiles = logs.reporter("system","prepfiles") -commands = commands or { } -local commands = commands +local commands = commands +local implement = interfaces.implement -ctxrunner = ctxrunner or { } +ctxrunner = ctxrunner or { } -ctxrunner.prepfiles = utilities.storage.allocate() +ctxrunner.prepfiles = utilities.storage.allocate() local function dontpreparefile(t,k) return k -- we only store when we have a prepper @@ -301,35 +301,55 @@ local function resolve(name) -- used a few times later on return ctxrunner.prepfiles[file.collapsepath(name)] or false end +function ctxrunner.preparedfile(name) + return resolve(name) or name +end + local processfile = commands.processfile local doifelseinputfile = commands.doifelseinputfile -function commands.processfile(name,maxreadlevel) -- overloaded - local prepname = resolve(name) - if prepname then - return processfile(prepname,0) +implement { + name = "processfile", + overload = true, + arguments = { "string", "integer" }, + actions = function(name,maxreadlevel) -- overloaded + local prepname = resolve(name) + if prepname then + return processfile(prepname,0) + end + return processfile(name,maxreadlevel) end - return processfile(name,maxreadlevel) -end +} -function commands.doifelseinputfile(name,depth) - local prepname = resolve(name) - if prepname then - return doifelseinputfile(prepname,0) +implement { + name = "doifelseinputfile", + overload = true, + arguments = { "string", "integer" }, + actions = function(name,depth) + local prepname = resolve(name) + if prepname then + return doifelseinputfile(prepname,0) + end + return doifelseinputfile(name,depth) end - return doifelseinputfile(name,depth) -end - -function commands.preparedfile(name) - return resolve(name) or name -end +} -function commands.getctxfile() - local ctxfile = document.arguments.ctx or "" - if ctxfile ~= "" then - ctxrunner.load(ctxfile) -- do we need to locate it? +-- implement { +-- name = "preparedfile", -- not used +-- arguments = "string", +-- actions = { ctxrunner.preparedfile, context } +-- } + +implement { + name = "setdocumentctxfile", + onlyonce = true, + actions = function() + local ctxfile = document.arguments.ctx or "" + if ctxfile ~= "" then + ctxrunner.load(ctxfile) -- do we need to locate it? + end end -end +} function ctxrunner.resolve(name) -- used a few times later on local collapsedname = file.collapsepath(name,".") diff --git a/tex/context/base/core-ctx.mkiv b/tex/context/base/core-ctx.mkiv index 59115621a..e6372d099 100644 --- a/tex/context/base/core-ctx.mkiv +++ b/tex/context/base/core-ctx.mkiv @@ -17,11 +17,13 @@ \unprotect -\unexpanded\def\job_options_get_commandline {\ctxcommand{getcommandline()}} -\unexpanded\def\job_options_get_ctxfile {\ctxcommand{getctxfile()}} -\unexpanded\def\job_options_set_modes {\ctxcommand{setdocumentmodes()}} -\unexpanded\def\job_options_set_modules {\ctxcommand{setdocumentmodules()}} -\unexpanded\def\job_options_set_environments{\ctxcommand{setdocumentenvironments()}} -\unexpanded\def\job_options_set_filenames {\ctxcommand{setdocumentfilenames()}} +% called directly in core-def.mkiv +% +% \unexpanded\def\job_options_get_commandline {\clf_setdocumentcommandline} +% \unexpanded\def\job_options_get_ctxfile {\clf_setdocumentctxfile} +% \unexpanded\def\job_options_set_modes {\clf_setdocumentmodes} +% \unexpanded\def\job_options_set_modules {\clf_setdocumentmodules} +% \unexpanded\def\job_options_set_environments{\clf_setdocumentenvironments} +% \unexpanded\def\job_options_set_filenames {\clf_setdocumentfilenames} \protect \endinput diff --git a/tex/context/base/core-def.mkiv b/tex/context/base/core-def.mkiv index 99bed6d34..acd411fac 100644 --- a/tex/context/base/core-def.mkiv +++ b/tex/context/base/core-def.mkiv @@ -107,17 +107,17 @@ \initializenewlinechar \calculatecurrenttime \syst_files_load - \job_options_get_commandline % expands some commands - \job_options_get_ctxfile % might expand some commands - \job_options_set_filenames + \clf_setdocumentcommandline + \clf_setdocumentctxfile + \clf_setdocumentfilenames \font_preloads_at_every_job \settopskip % brrr \initializemainlanguage \initializepagebackgrounds \initializepagecounters - \job_options_set_modes - \job_options_set_modules - \job_options_set_environments + \clf_setdocumentmodes + \clf_setdocumentmodules + \clf_setdocumentenvironments \to \everyjob \appendtoks diff --git a/tex/context/base/core-ini.mkiv b/tex/context/base/core-ini.mkiv index 711c43f94..c338f6f81 100644 --- a/tex/context/base/core-ini.mkiv +++ b/tex/context/base/core-ini.mkiv @@ -172,6 +172,9 @@ \newif \ifdoingblocks \newif \ifgridsnapping +\newconstant\pageduplexmode % 0 single 1 double 2 mix +\newconstant\pagebodymode % 0 not 1 normal pagebody 2 spread + %D \macros %D {ifproductionrun} %D diff --git a/tex/context/base/core-sys.lua b/tex/context/base/core-sys.lua index 263b4dc76..cf74d68f4 100644 --- a/tex/context/base/core-sys.lua +++ b/tex/context/base/core-sys.lua @@ -10,46 +10,12 @@ local lower, format, gsub = string.lower, string.format, string.gsub local suffixonly, basename, removesuffix = file.suffix, file.basename, file.removesuffix local environment = environment +local context = context local implement = interfaces.implement local report_files = logs.reporter("system","files") --- function commands.updatefilenames(jobname,fulljobname,inputfilename,outputfilename) --- -- --- environment.jobname = jobname --- -- --- local jobfilename = gsub(fulljobname or jobname or inputfilename or tex.jobname or "","%./","") --- -- --- environment.jobfilename = jobfilename --- environment.jobfilesuffix = lower(suffixonly(environment.jobfilename)) --- -- --- local inputfilename = gsub(inputfilename or "","%./","") --- environment.inputfilename = inputfilename --- environment.inputfilebarename = removesuffix(basename(inputfilename)) --- -- --- local inputfilerealsuffix = suffixonly(inputfilename) --- environment.inputfilerealsuffix = inputfilerealsuffix --- -- --- local inputfilesuffix = inputfilerealsuffix == "" and "tex" or lower(inputfilerealsuffix) --- environment.inputfilesuffix = inputfilesuffix --- -- --- local outputfilename = outputfilename or environment.inputfilebarename or "" --- environment.outputfilename = outputfilename --- -- --- local runpath = resolvers.cleanpath(lfs.currentdir()) --- environment.runpath = runpath --- -- --- statistics.register("running on path", function() --- return environment.runpath --- end) --- -- --- statistics.register("job file properties", function() --- return format("jobname %a, input %a, suffix %a",jobfilename,inputfilename,inputfilesuffix) --- end) --- -- --- end - -function environment.initializefilenames() -- commands.updatefilenames(jobname,fulljobname,input,result) +function environment.initializefilenames() local arguments = environment.arguments @@ -91,10 +57,16 @@ function environment.initializefilenames() -- commands.updatefilenames(jobname,f function environment.initializefilenames() end end -implement { - name = "setdocumentfilenames", - actions = environment.initializefilenames, -} +-- we could set a macro (but will that work when we're expanding? needs testing!) + +implement { name = "operatingsystem", actions = function() context(os.platform) end } +implement { name = "jobfilename", actions = function() context(environment.jobfilename) end } +implement { name = "jobfilesuffix", actions = function() context(environment.jobfilesuffix) end } +implement { name = "inputfilebarename", actions = function() context(environment.inputfilebarename) end } +implement { name = "inputfilerealsuffix", actions = function() context(environment.inputfilerealsuffix) end } +implement { name = "inputfilesuffix", actions = function() context(environment.inputfilesuffix) end } +implement { name = "inputfilename", actions = function() context(environment.inputfilename) end } +implement { name = "outputfilename", actions = function() context(environment.outputfilename) end } statistics.register("result saved in file", function() -- suffix will be fetched from backend diff --git a/tex/context/base/core-sys.mkiv b/tex/context/base/core-sys.mkiv index f61c74743..27bbec0b1 100644 --- a/tex/context/base/core-sys.mkiv +++ b/tex/context/base/core-sys.mkiv @@ -35,24 +35,24 @@ %D End of lines to the output. \TEX\ will map this onto the platform specific %D line ending. I hate this mess. -\edef\operatingsystem {\cldcontext{os.platform}} +\let\operatingsystem\clf_operatingsystem %D The jobname is what gets loaded by the cont-yes stub file. This name %D also determines the name of tuc etc files. -\def \jobfilename {\cldcontext{environment.jobfilename or ""}} -\def \jobfilesuffix {\cldcontext{environment.jobfilesuffix or ""}} +\let\jobfilename \clf_jobfilename +\let\jobfilesuffix\clf_jobfilesuffix %D However, that one can itself load another file. -\def \inputfilebarename {\cldcontext{environment.inputfilebarename or ""}} -\def \inputfilerealsuffix{\cldcontext{environment.inputfilerealsuffix or ""}} -\def \inputfilesuffix {\cldcontext{environment.inputfilesuffix or ""}} -\def \inputfilename {\cldcontext{environment.inputfilename or ""}} +\let\inputfilebarename \clf_inputfilebarename +\let\inputfilerealsuffix\clf_inputfilerealsuffix +\let\inputfilesuffix \clf_inputfilesuffix +\let\inputfilename \clf_inputfilename %D The output name is only used for some checking. -\def \outputfilename {\cldcontext{environment.outputfilename or ""}} +\let\outputfilename\clf_outputfilename \installcorenamespace{system} diff --git a/tex/context/base/core-uti.lua b/tex/context/base/core-uti.lua index 9faf9ad30..346dec89e 100644 --- a/tex/context/base/core-uti.lua +++ b/tex/context/base/core-uti.lua @@ -38,7 +38,7 @@ local report_passes = logs.reporter("job","passes") job = job or { } local job = job -job.version = 1.28 +job.version = 1.29 job.packversion = 1.02 -- some day we will implement loading of other jobs and then we need diff --git a/tex/context/base/enco-ini.mkiv b/tex/context/base/enco-ini.mkiv index 4e06fa15f..2c5488bcd 100644 --- a/tex/context/base/enco-ini.mkiv +++ b/tex/context/base/enco-ini.mkiv @@ -106,7 +106,7 @@ \unexpanded\def\buildtextaccent#1#2% we could do all at the lua end {\begingroup % but that's no fun (yet) \setbox\b_enco_accent\hbox{#1}% - \ctxcommand{buildtextaccent(\number\b_enco_accent)}#2% + \clf_buildtextaccent\b_enco_accent#2% \endgroup} \unexpanded\def\bottomaccent#1#2#3#4#5% down right slantcorrection accent char diff --git a/tex/context/base/file-job.lua b/tex/context/base/file-job.lua index e8ccb045b..9bf43bbdc 100644 --- a/tex/context/base/file-job.lua +++ b/tex/context/base/file-job.lua @@ -794,7 +794,11 @@ function environment.loadexamodes(filename) end end -commands.loadexamodes = environment.loadexamodes +implement { + name = "loadexamodes", + actions = environment.loadexamodes, + arguments = "string" +} -- changed in mtx-context -- code moved from luat-ini @@ -881,7 +885,7 @@ implement { arguments = "integer" } -function commands.getcommandline() -- has to happen at the tex end in order to expand +function document.setcommandline() -- has to happen at the tex end in order to expand -- the document[arguments|files] tables are copies @@ -1020,21 +1024,36 @@ local function apply(list,action) end end -function commands.setdocumentmodes() -- was setup: *runtime:modes +function document.setmodes() -- was setup: *runtime:modes apply(document.options.ctxfile .modes,context.enablemode) apply(document.options.commandline.modes,context.enablemode) end -function commands.setdocumentmodules() -- was setup: *runtime:modules +function document.setmodules() -- was setup: *runtime:modules apply(document.options.ctxfile .modules,context.usemodule) apply(document.options.commandline.modules,context.usemodule) end -function commands.setdocumentenvironments() -- was setup: *runtime:environments +function document.setenvironments() -- was setup: *runtime:environments apply(document.options.ctxfile .environments,context.environment) apply(document.options.commandline.environments,context.environment) end +function document.setfilenames() + local initialize = environment.initializefilenames + if initialize then + initialize() + else + -- fatal error + end +end + +implement { name = "setdocumentcommandline", actions = document.setcommandline, onlyonce = true } +implement { name = "setdocumentmodes", actions = document.setmodes, onlyonce = true } +implement { name = "setdocumentmodules", actions = document.setmodules, onlyonce = true } +implement { name = "setdocumentenvironments", actions = document.setenvironments, onlyonce = true } +implement { name = "setdocumentfilenames", actions = document.setfilenames, onlyonce = true } + local report_files = logs.reporter("system","files") local report_options = logs.reporter("system","options") local report_file = logs.reporter("used file") diff --git a/tex/context/base/file-job.mkvi b/tex/context/base/file-job.mkvi index b3aa2e85d..bd10c59e0 100644 --- a/tex/context/base/file-job.mkvi +++ b/tex/context/base/file-job.mkvi @@ -69,7 +69,7 @@ {\dosingleempty\syst_files_load_exa_modes} \def\syst_files_load_exa_modes[#name]% - {\ctxcommand{loadexamodes("#name")}} + {\clf_loadexamodes{#name}} % runtime files (maybe also do this in lua?) diff --git a/tex/context/base/font-chk.lua b/tex/context/base/font-chk.lua index e5c46dd62..a3ac8f20e 100644 --- a/tex/context/base/font-chk.lua +++ b/tex/context/base/font-chk.lua @@ -46,6 +46,8 @@ local tasks = nodes.tasks local enableaction = tasks.enableaction local disableaction = tasks.disableaction +local implement = interfaces.implement + local glyph_code = nodes.nodecodes.glyph local nuts = nodes.nuts @@ -337,24 +339,6 @@ trackers.register("fonts.missing", function(v) action = v end) -function commands.checkcharactersinfont() - enableaction("processors","fonts.checkers.missing") - tracked = true -end - -function commands.removemissingcharacters() - enableaction("processors","fonts.checkers.missing") - action = "remove" - tracked = true -end - -function commands.replacemissingcharacters() - enableaction("processors","fonts.checkers.missing") - action = "replace" - otffeatures.defaults.missing = true - tracked = true -end - local report_characters = logs.reporter("fonts","characters") local report_character = logs.reporter("missing") diff --git a/tex/context/base/font-chk.mkiv b/tex/context/base/font-chk.mkiv index 4572041c2..4c8967532 100644 --- a/tex/context/base/font-chk.mkiv +++ b/tex/context/base/font-chk.mkiv @@ -21,11 +21,9 @@ % % \definefontfeature[default][default][missing=yes] % \enabletrackers[fonts.missing=replace] -% -% or better: -\unexpanded\def\checkcharactersinfont {\ctxcommand{checkcharactersinfont()}} -\unexpanded\def\removemissingcharacters {\ctxcommand{removemissingcharacters()}} -\unexpanded\def\replacemissingcharacters{\ctxcommand{replacemissingcharacters()}} +\unexpanded\def\checkcharactersinfont {\enabletrackers[fonts.missing]} +\unexpanded\def\removemissingcharacters {\enabletrackers[fonts.missing=remove]} +\unexpanded\def\replacemissingcharacters{\enabletrackers[fonts.missing=replace]} \endinput diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua index d55bf2dad..a58a3b9d6 100644 --- a/tex/context/base/font-ctx.lua +++ b/tex/context/base/font-ctx.lua @@ -94,6 +94,7 @@ local csnames = hashes.csnames local lastmathids = hashes.lastmathids local exheights = hashes.exheights local emwidths = hashes.emwidths +local parameters = hashes.parameters local designsizefilename = fontgoodies.designsizes.filename @@ -249,7 +250,17 @@ function definers.resetnullfont() definers.resetnullfont = function() end end -commands.resetnullfont = definers.resetnullfont +implement { + name = "resetnullfont", + onlyonce = true, + actions = function() + for i=1,7 do + -- we have no direct method yet + context([[\fontdimen%s\nullfont\zeropoint]],i) + end + definers.resetnullfont() + end +} -- this cannot be a feature initializer as there is no auto namespace -- so we never enter the loop then; we can store the defaults in the tma @@ -2084,6 +2095,13 @@ do end end + local function resetfeature() + if trace_features and texgetattribute(0) ~= 0 then + report_cummulative("font %!font:name!, reset",fontdata[true]) + end + texsetattribute(0,0) + end + local function registerlanguagefeatures() local specifications = languages.data.specifications for i=1,#specifications do @@ -2105,7 +2123,7 @@ do end end - implement { name = "resetfeature", actions = setfeature, arguments = { false } } + implement { name = "resetfeature", actions = resetfeature } implement { name = "addfeature", actions = setfeature, arguments = { "'+'", "string", "string" } } implement { name = "subtractfeature", actions = setfeature, arguments = { "'-'", "string", "string" } } implement { name = "replacefeature", actions = setfeature, arguments = { "'='", "string", "string" } } @@ -2256,42 +2274,36 @@ implement { local list = storage.shared.bodyfontsizes or { } storage.shared.bodyfontsizes = list -local function registerbodyfontsize(size) - list[size] = true -end - implement { name = "registerbodyfontsize", - actions = registerbodyfontsize, - arguments = "string" + arguments = "string", + actions = function(size) + list[size] = true + end } -local function getbodyfontsizes(separator) - context(concat(sortedkeys(list),separator)) -end - implement { name = "getbodyfontsizes", - actions = getbodyfontsizes, - arguments = "string" -} - -local function processbodyfontsizes(command) - local keys = sortedkeys(list) - if command then - local action = context[command] - for i=1,#keys do - action(keys[i]) - end - else - context(concat(keys,",")) + arguments = "string", + actions = function(separator) + context(concat(sortedkeys(list),separator)) end -end +} implement { name = "processbodyfontsizes", - actions = processbodyfontsizes, - arguments = "string" + arguments = "string", + actions = function(command) + local keys = sortedkeys(list) + if command then + local action = context[command] + for i=1,#keys do + action(keys[i]) + end + else + context(concat(keys,",")) + end + end } implement { @@ -2358,3 +2370,16 @@ function commands.showfontparameters(tfmdata) end end end + +implement { + name = "currentdesignsize", + actions = function() + context(parameters[currentfont()].designsize) + end +} + +implement { + name = "doifelsefontpresent", + actions = { names.exists, commands.doifelse }, + arguments = "string" +} diff --git a/tex/context/base/font-gds.lua b/tex/context/base/font-gds.lua index 51fe6d0a1..073d9ed57 100644 --- a/tex/context/base/font-gds.lua +++ b/tex/context/base/font-gds.lua @@ -834,7 +834,7 @@ implement { implement { name = "enablefontcolorschemes", - once = true, + onlyonce = true, actions = colorschemes.enable } diff --git a/tex/context/base/font-set.mkvi b/tex/context/base/font-set.mkvi index b185b2659..b29545ace 100644 --- a/tex/context/base/font-set.mkvi +++ b/tex/context/base/font-set.mkvi @@ -41,10 +41,12 @@ \let\m_font_fallback_name\empty -\def\font_preloads_reset_nullfont % this is needed because some macro packages (tikz) misuse \nullfont - {\dorecurse\plusseven{\fontdimen\recurselevel\nullfont\zeropoint}% keep en eye on this as: - \ctxcommand{resetnullfont()}% in luatex 0.70 this will also do the previous - \globallet\font_preloads_reset_nullfont\relax} +% keep as reference: +% +% \def\font_preloads_reset_nullfont % this is needed because some macro packages (tikz) misuse \nullfont +% {\dorecurse\plusseven{\fontdimen\recurselevel\nullfont\zeropoint}% keep en eye on this as: +% \clf_resetnullfont % in luatex 0.70 this will also do the previous +% \globallet\font_preloads_reset_nullfont\relax} \def\font_preload_check_mode {\doifelsemode{lmmath} @@ -81,7 +83,8 @@ \glet\fourthstagepreloadfonts \relax \global\everyhbox\emptytoks \global\everyvbox\emptytoks - \font_preloads_reset_nullfont} + % old: \font_preloads_reset_nullfont, new: + \clf_resetnullfont} \appendtoks \font_preloads_reset diff --git a/tex/context/base/font-tra.mkiv b/tex/context/base/font-tra.mkiv index d251b8b69..b0c3ae55b 100644 --- a/tex/context/base/font-tra.mkiv +++ b/tex/context/base/font-tra.mkiv @@ -95,7 +95,7 @@ %D \doiffontpresentelse{adam-lindsay-modern-serif}{YES}{NO} %D \stoptyping -\unexpanded\def\doifelsefontpresent#1{\ctxcommand{doifelse(fonts.names.exists("#1"))}} +\unexpanded\def\doifelsefontpresent#1{\clf_doifelsefontpresent{#1}} \let\doiffontpresentelse\doifelsefontpresent diff --git a/tex/context/base/font-uni.mkiv b/tex/context/base/font-uni.mkiv index 223d27606..91a488ff2 100644 --- a/tex/context/base/font-uni.mkiv +++ b/tex/context/base/font-uni.mkiv @@ -13,14 +13,14 @@ \writestatus{loading}{ConTeXt Font Macros / Unicode} -%D In \MKIV\ we only provide the \type {\uchar} macro and -%D implement it as just an \UTF\ converter. We expand it so -%D best not use not use it for active characters. +%D In \MKIV\ we only provide the \type {\uchar} macro and implement it as just +%D an \UTF\ converter. We expand it so best not use not use it for active +%D characters. In practice this command is probably never used anyway but we keep +%D if for old styles. \unprotect -%def\uchar#1#2{\ctxcommand{uchar(,)}} -\def\uchar#1#2{\cldcontext{utf.char(\number\numexpr#1*256+#2\relax)}} +\def\uchar#1#2{\clf_uchar\numexpr#1\relax\numexpr#2\relax} \let\uc\uchar diff --git a/tex/context/base/grph-epd.lua b/tex/context/base/grph-epd.lua index 8dcb58b3d..17f04d593 100644 --- a/tex/context/base/grph-epd.lua +++ b/tex/context/base/grph-epd.lua @@ -26,3 +26,9 @@ function figures.mergegoodies(optionlist) codeinjections.mergebookmarks() end end + +interfaces.implement { + name = "figure_mergegoodies", + actions = figures.mergegoodies, + arguments = "string" +} diff --git a/tex/context/base/grph-epd.mkiv b/tex/context/base/grph-epd.mkiv index 66984618a..2df195589 100644 --- a/tex/context/base/grph-epd.mkiv +++ b/tex/context/base/grph-epd.mkiv @@ -22,7 +22,7 @@ \defineoverlay[system:graphics:epdf][\directsetup{system:graphics:epdf}] \startsetups system:graphics:epdf - \ctxlua{figures.mergegoodies("\externalfigureparameter\c!interaction")}% + \clf_figure_mergegoodies{\externalfigureparameter\c!interaction}% \reference[\figurereference]{}% todo: dest area \stopsetups diff --git a/tex/context/base/grph-fig.mkiv b/tex/context/base/grph-fig.mkiv index 9566bb0a1..f5152874d 100644 --- a/tex/context/base/grph-fig.mkiv +++ b/tex/context/base/grph-fig.mkiv @@ -94,7 +94,7 @@ \def\grph_typesetting_process_indeed#1#2#3#4% options settings-a filename settings-b {\begingroup - \edef\m_typesetting_name{\cldcontext{job.files.context("#3","#1")}}% + \edef\m_typesetting_name{\clf_runcontextjob{#3}{#1}}% \ifx\m_typesetting_name\empty \else \expanded{\externalfigure[\m_typesetting_name]}[#2,#4]% \fi diff --git a/tex/context/base/grph-fil.lua b/tex/context/base/grph-fil.lua index 3449f1779..c1532ce25 100644 --- a/tex/context/base/grph-fil.lua +++ b/tex/context/base/grph-fil.lua @@ -69,3 +69,9 @@ function jobfiles.context(name,options) return file.replacesuffix(name,"pdf") end end + +interfaces.implement { + name = "runcontextjob", + arguments = { "string", "string" }, + actions = { jobfiles.context, context } +} diff --git a/tex/context/base/grph-inc.mkiv b/tex/context/base/grph-inc.mkiv index fa2efeccc..6b7f2bd63 100644 --- a/tex/context/base/grph-inc.mkiv +++ b/tex/context/base/grph-inc.mkiv @@ -776,7 +776,7 @@ {\writestatus\m!system{the \string\showexternalfigures\space command is not (yet) implemented in mkiv}} \unexpanded\def\overlayfigure#1% - {\externalfigure[#1][\c!width=\overlaywidth,\c!height=\overlayheight]} + {\externalfigure[#1][\c!width=\d_overlay_width,\c!height=\d_overlay_height]} % Bonus: diff --git a/tex/context/base/grph-raw.lua b/tex/context/base/grph-raw.lua index 4c5b031ea..62e96fcc9 100644 --- a/tex/context/base/grph-raw.lua +++ b/tex/context/base/grph-raw.lua @@ -40,3 +40,18 @@ function figures.bitmapimage(t) report_bitmap("invalid specification") end end + +interfaces.implement { + name = "bitmapimage", + actions = figures.bitmapimage, + arguments = { + { + { "data" }, + { "colorspace" }, + { "width" }, + { "height" }, + { "xresolution" }, + { "yresolution" }, + } + } +} diff --git a/tex/context/base/grph-raw.mkiv b/tex/context/base/grph-raw.mkiv index 1c6835564..8978ba267 100644 --- a/tex/context/base/grph-raw.mkiv +++ b/tex/context/base/grph-raw.mkiv @@ -46,14 +46,14 @@ \unexpanded\def\bitmapimage[#1]#2% {\hbox\bgroup \getdummyparameters[\c!color=rgb,\c!width=,\c!height=,\c!x=,\c!y=,#1]% - \ctxlua{figures.bitmapimage { % we could pass #1 directly ... todo - data = \!!bs#2\!!es, - colorspace = "\directdummyparameter\c!color", - width = "\directdummyparameter\c!width", - height = "\directdummyparameter\c!height", - xresolution = "\directdummyparameter\c!x", - yresolution = "\directdummyparameter\c!y", - }}% + \clf_bitmapimage + data {#2}% + colorspace {\directdummyparameter\c!color}% + width {\directdummyparameter\c!width}% + height {\directdummyparameter\c!height}% + xresolution {\directdummyparameter\c!x}% + yresolution {\directdummyparameter\c!y}% + \relax \egroup} \unexpanded\def\startbitmapimage[#1]#2\stopbitmapimage diff --git a/tex/context/base/java-ini.lua b/tex/context/base/java-ini.lua index 673379494..069eb5ab6 100644 --- a/tex/context/base/java-ini.lua +++ b/tex/context/base/java-ini.lua @@ -19,7 +19,7 @@ local variables = interfaces.variables local formatters = string.formatters local context = context -local commands = commands +local implement = interfaces.implement local trace_javascript = false trackers.register("backends.javascript", function(v) trace_javascript = v end) @@ -196,7 +196,13 @@ function javascripts.flushpreambles() return t end -local patterns = { "java-imp-%s.mkiv", "java-imp-%s.tex", "java-%s.mkiv", "java-%s.tex" } +local patterns = { + "java-imp-%s.mkiv", + "java-imp-%s.tex", + -- obsolete: + "java-%s.mkiv", + "java-%s.tex" +} local function action(name,foundname) context.startnointerference() @@ -213,7 +219,7 @@ end function javascripts.usescripts(name) if name ~= variables.reset then -- reset is obsolete - commands.uselibrary { + resolvers.uselibrary { name = name, patterns = patterns, action = action, @@ -225,8 +231,38 @@ end -- interface -commands.storejavascriptcode = interactions.javascripts.storecode -commands.storejavascriptpreamble = interactions.javascripts.storepreamble -commands.addtojavascriptpreamble = interactions.javascripts.addtopreamble -commands.usejavascriptpreamble = interactions.javascripts.usepreamblenow -commands.usejavascriptscripts = interactions.javascripts.usescripts +implement { + name = "storejavascriptcode", + actions = javascripts.storecode, + arguments = "string" +} + +implement { + name = "storejavascriptpreamble", + actions = javascripts.storepreamble, + arguments = "string" +} + +implement { + name = "setjavascriptpreamble", + actions = javascripts.setpreamble, + arguments = { "string", "string" } +} + +implement { + name = "addtojavascriptpreamble", + actions = javascripts.addtopreamble, + arguments = { "string", "string" } +} + +implement { + name = "usejavascriptpreamble", + actions = javascripts.usepreamblenow, + arguments = "string" +} + +implement { + name = "usejavascriptscripts", + actions = javascripts.usescripts, + arguments = "string" +} diff --git a/tex/context/base/java-ini.mkiv b/tex/context/base/java-ini.mkiv index e4f0bf28b..59679e463 100644 --- a/tex/context/base/java-ini.mkiv +++ b/tex/context/base/java-ini.mkiv @@ -113,7 +113,7 @@ \java_start_code} \def\java_start_code#1\stopJScode - {\normalexpanded{\endgroup\ctxcommand{storejavascriptcode(\!!bs#1\!!es)}}} + {\normalexpanded{\endgroup\clf_storejavascriptcode{#1}}} \let\stopJScode\relax @@ -125,12 +125,12 @@ \java_start_preamble} \def\java_start_preamble#1\stopJSpreamble - {\normalexpanded{\endgroup\ctxcommand{storejavascriptpreamble(\!!bs#1\!!es)}}} + {\normalexpanded{\endgroup\clf_storejavascriptpreamble{#1}}} \let\stopJSpreamble\relax -\unexpanded\def\setJSpreamble #1#2{\ctxcommand{storejavascriptpreamble("#1",\!!bs#2\!!es)}} -\unexpanded\def\addtoJSpreamble#1#2{\ctxcommand{addtojavascriptpreamble("#1",\!!bs#2\!!es)}} +\unexpanded\def\setJSpreamble #1#2{\clf_setjavascriptpreamble {#1}{#2}} +\unexpanded\def\addtoJSpreamble#1#2{\clf_addtojavascriptpreamble{#1}{#2}} %D \macros %D {useJSscripts} @@ -147,11 +147,11 @@ %D %D The not so complicated implementation of this macro is: -\def\useJSscripts +\unexpanded\def\useJSscripts {\dodoubleempty\java_use_scripts} \def\java_use_scripts[#1][#2]% - {\ctxcommand{usejavascriptscripts(\!!bs#1\!!es)}% two steps as this one calls tex code - \ctxcommand{usejavascriptpreamble("#2")}} % so this one comes later + {\clf_usejavascriptscripts {#1}% two steps as this one calls tex code + \clf_usejavascriptpreamble{#2}}% so this one comes later \protect \endinput diff --git a/tex/context/base/lang-lab.lua b/tex/context/base/lang-lab.lua index 5ce1b7b01..e90bee017 100644 --- a/tex/context/base/lang-lab.lua +++ b/tex/context/base/lang-lab.lua @@ -19,6 +19,9 @@ local report_labels = logs.reporter("languages","labels") languages.labels = languages.labels or { } local labels = languages.labels +local context = context +local implement = interfaces.implement + local variables = interfaces.variables local settings_to_array = utilities.parsers.settings_to_array @@ -128,7 +131,7 @@ interfaces.implement { -- text : "a,b,c" -- separators : "{, },{ and }" -function commands.concatcommalist(settings) -- it's too easy to forget that this one is there +local function concatcommalist(settings) -- it's too easy to forget that this one is there local list = settings.list or settings_to_array(settings.text or "") local size = #list local command = settings.command and context[settings.command] or context @@ -153,3 +156,16 @@ function commands.concatcommalist(settings) -- it's too easy to forget that this command(list[size]) end end + +implement { + name = "concatcommalist", + actions = concatcommalist, + arguments = { + { + { "text" }, + { "separators" }, + { "first" }, + { "second" }, + } + } +} diff --git a/tex/context/base/lang-lab.mkiv b/tex/context/base/lang-lab.mkiv index 9b6989903..fbe3346dc 100644 --- a/tex/context/base/lang-lab.mkiv +++ b/tex/context/base/lang-lab.mkiv @@ -349,12 +349,12 @@ {\dodoubleempty\typo_helpers_concat_comma_list} \def\typo_helpers_concat_comma_list[#1][#2]% - {\ctxcommand{concatcommalist{ - text = \!!bs#1\!!es, - separators = \!!bs#2\!!es, - first = \!!bs\labeltext{and-1}\!!es, - second = \!!bs\labeltext{and-2}\!!es - }}} + {\clf_concatcommalist + text {#1}% + separators {#2}% + first {\detokenize\expandafter{\normalexpanded{\labeltext{and-1}}}}% + second {\detokenize\expandafter{\normalexpanded{\labeltext{and-2}}}}% + \relax} \setuplabeltext [\s!nl] [and-1={{, }}, and-2={{ en }}] % 1, 2 en 3 \setuplabeltext [\s!en] [and-1={{, }}, and-2={{, }}] % 1, 2, 3 diff --git a/tex/context/base/lang-rep.lua b/tex/context/base/lang-rep.lua index 02eb59f48..95a5e545a 100644 --- a/tex/context/base/lang-rep.lua +++ b/tex/context/base/lang-rep.lua @@ -15,7 +15,7 @@ if not modules then modules = { } end modules ['lang-rep'] = { -- although (given experiences so far) we don't really need that. After all, each problem -- is somewhat unique. -local type = type +local type, tonumber = type, tonumber local utfbyte, utfsplit = utf.byte, utf.split local P, C, U, Cc, Ct, lpegmatch = lpeg.P, lpeg.C, lpeg.patterns.utf8character, lpeg.Cc, lpeg.Ct, lpeg.match local find = string.find @@ -56,6 +56,8 @@ local unsetvalue = attributes.unsetvalue local v_reset = interfaces.variables.reset +local implement = interfaces.implement + local replacements = languages.replacements or { } languages.replacements = replacements @@ -75,6 +77,8 @@ table.setmetatableindex(lists,function(lists,name) return data end) +lists[v_reset].attribute = unsetvalue -- so we discard 0 + -- todo: glue kern local function add(root,word,replacement) @@ -260,7 +264,7 @@ end local enabled = false -function replacements.set(n) -- number or 'reset' +function replacements.set(n) if n == v_reset then n = unsetvalue else @@ -278,5 +282,14 @@ end -- interface -commands.setreplacements = replacements.set -commands.addreplacements = replacements.add +implement { + name = "setreplacements", + actions = replacements.set, + arguments = "string" +} + +implement { + name = "addreplacements", + actions = replacements.add, + arguments = { "string", "string", "string" } +} diff --git a/tex/context/base/lang-rep.mkiv b/tex/context/base/lang-rep.mkiv index b3f21f22a..a98d51f6c 100644 --- a/tex/context/base/lang-rep.mkiv +++ b/tex/context/base/lang-rep.mkiv @@ -51,7 +51,7 @@ %D \stoptyping \unexpanded\def\setreplacements[#1]% - {\ctxcommand{setreplacements("#1")}} + {\clf_setreplacements{#1}} \unexpanded\def\resetreplacements {\attribute\replacementsattribute\attributeunsetvalue} @@ -61,7 +61,7 @@ \unexpanded\def\languages_replacements_replace[#1][#2][#3]% {\ifthirdargument - \ctxcommand{addreplacements("#1",\!!bs#2\!!es,\!!bs#3\!!es)}% + \clf_addreplacements{#1}{#2}{#3}% \fi} \appendtoks diff --git a/tex/context/base/lang-url.lua b/tex/context/base/lang-url.lua index fb4147580..27f3116f9 100644 --- a/tex/context/base/lang-url.lua +++ b/tex/context/base/lang-url.lua @@ -8,10 +8,14 @@ if not modules then modules = { } end modules ['lang-url'] = { local utfcharacters, utfvalues, utfbyte, utfchar = utf.characters, utf.values, utf.byte, utf.char -commands = commands or { } local commands = commands +local context = context -context = context +local implement = interfaces.implement + +local variables = interfaces.variables +local v_before = variables.before +local v_after = variables.after local is_letter = characters.is_letter @@ -129,10 +133,10 @@ local function action(hyphenatedurl,str,left,right,disc) ctx_d(utfbyte(s)) else local c = characters[s] - if c == 1 then + if c == v_before then p = false ctx_b(utfbyte(s)) - elseif c == 2 then + elseif c == v_after then p = false ctx_a(utfbyte(s)) else @@ -162,8 +166,21 @@ table.setmetatablecall(hyphenatedurl,action) -- watch out: a caller function hyphenatedurl.setcharacters(str,value) -- 1, 2 == before, after for s in utfcharacters(str) do - characters[s] = value or 1 + characters[s] = value or v_before end end -- .hyphenatedurl.setcharacters("')]}",2) + +implement { + name = "sethyphenatedurlcharacters", + actions = hyphenatedurl.setcharacters, + arguments = { "string", "integer" } +} + +implement { + name = "hyphenatedurl", + scope = "private", + actions = function(...) action(hyphenatedurl,...) end, + arguments = { "string", "integer", "integer", "string" } +} diff --git a/tex/context/base/lang-url.mkiv b/tex/context/base/lang-url.mkiv index fd3bd3b0d..53b775ffc 100644 --- a/tex/context/base/lang-url.mkiv +++ b/tex/context/base/lang-url.mkiv @@ -86,9 +86,9 @@ \let\lang_url_show\relax -\unexpanded\def\sethyphenatedurlnormal#1{\ctxcommand{hyphenatedurl.setcharacters(\!!bs#1\!!es,0)}} % Lua names will change -\unexpanded\def\sethyphenatedurlbefore#1{\ctxcommand{hyphenatedurl.setcharacters(\!!bs#1\!!es,1)}} % Lua names will change -\unexpanded\def\sethyphenatedurlafter #1{\ctxcommand{hyphenatedurl.setcharacters(\!!bs#1\!!es,2)}} % Lua names will change +\unexpanded\def\sethyphenatedurlnormal#1{\clf_sethyphenatedurlcharacters{#1}{\v!normal}} +\unexpanded\def\sethyphenatedurlbefore#1{\clf_sethyphenatedurlcharacters{#1}{\v!before}} +\unexpanded\def\sethyphenatedurlafter #1{\clf_sethyphenatedurlcharacters{#1}{\v!after }} % \sethyphenatedurlafter{ABCDEF} @@ -106,12 +106,12 @@ \let\C\lang_url_C % character_nobreak \scratchskipone\zeropoint\s!plus\dimexpr\emwidth/12\s!minus\dimexpr\emwidth/24\relax % 1.00pt @ 12pt \scratchskiptwo\zeropoint\s!plus\dimexpr\emwidth/48\s!minus\dimexpr\emwidth/96\relax % 0.25pt @ 12pt - \normalexpanded{\noexpand\ctxcommand{hyphenatedurl( - \!!bs\noexpand\detokenize{#1}\!!es, - \number\hyphenatedurllefthyphenmin, - \number\hyphenatedurlrighthyphenmin, - "\hyphenatedurldiscretionary" - )}}% + \normalexpanded{\noexpand\clf_hyphenatedurl + {\noexpand\detokenize{#1}}% + \hyphenatedurllefthyphenmin + \hyphenatedurlrighthyphenmin + {\hyphenatedurldiscretionary}% + }% \endgroup} %D \macros diff --git a/tex/context/base/lang-wrd.lua b/tex/context/base/lang-wrd.lua index 5fc23757e..b564a02ae 100644 --- a/tex/context/base/lang-wrd.lua +++ b/tex/context/base/lang-wrd.lua @@ -14,7 +14,10 @@ local P, S, Cs = lpeg.P, lpeg.S, lpeg.Cs local report_words = logs.reporter("languages","words") -local nodes, node, languages = nodes, node, languages +local nodes = nodes +local languages = languages + +local implement = interfaces.implement languages.words = languages.words or { } local words = languages.words @@ -361,6 +364,24 @@ end -- interface -commands.enablespellchecking = words.enable -commands.disablespellchecking = words.disable -commands.loadspellchecklist = words.load +implement { + name = "enablespellchecking", + actions = words.enable, + arguments = { + { + { "method" }, + { "list" } + } + } +} + +implement { + name = "disablespellchecking", + actions = words.disable +} + +implement { + name = "loadspellchecklist", + arguments = { "string", "string" }, + actions = words.load +} diff --git a/tex/context/base/lang-wrd.mkiv b/tex/context/base/lang-wrd.mkiv index 682489912..8c544773b 100644 --- a/tex/context/base/lang-wrd.mkiv +++ b/tex/context/base/lang-wrd.mkiv @@ -40,15 +40,18 @@ \appendtoks \doifelse{\directspellcheckingparameter\c!state}\v!start - {\ctxcommand{enablespellchecking { method = "\directspellcheckingparameter\c!method", list = "\directspellcheckingparameter\c!list" }}} - {\ctxcommand{disablespellchecking()}}% + {\clf_enablespellchecking + method {\directspellcheckingparameter\c!method}% + list {\directspellcheckingparameter\c!list}% + \relax} + {\clf_disablespellchecking}% \to \everysetupspellchecking \unexpanded\def\loadspellchecklist {\dodoubleempty\lang_spellchecking_load_list} \def\lang_spellchecking_load_list[#1][#2]% - {\ctxcommand{loadspellchecklist("#1","#2")}} + {\clf_loadspellchecklist{#1}{#2}} \setupspellchecking [\c!state=\v!stop, diff --git a/tex/context/base/lpdf-fld.lua b/tex/context/base/lpdf-fld.lua index 4f15b3c7b..f0aad3623 100644 --- a/tex/context/base/lpdf-fld.lua +++ b/tex/context/base/lpdf-fld.lua @@ -332,7 +332,7 @@ local function fieldsurrounding(specification) local fontsize = specification.fontsize or "12pt" local fontstyle = specification.fontstyle or "rm" local fontalternative = specification.fontalternative or "tf" - local colorvalue = specification.colorvalue + local colorvalue = tonumber(specification.colorvalue) local s = fontnames[fontstyle] if not s then fontstyle, s = "rm", fontnames.rm diff --git a/tex/context/base/lpdf-xmp.lua b/tex/context/base/lpdf-xmp.lua index aa205d10a..b44c57b42 100644 --- a/tex/context/base/lpdf-xmp.lua +++ b/tex/context/base/lpdf-xmp.lua @@ -91,7 +91,12 @@ local function setxmpfile(name) end codeinjections.setxmpfile = setxmpfile -commands.setxmpfile = setxmpfile + +interfaces.implement { + name = "setxmpfile", + arguments = "string", + actions = setxmpfile +} local function valid_xmp() if not xmp then diff --git a/tex/context/base/luat-mac.lua b/tex/context/base/luat-mac.lua index 8e2524dce..6214e591e 100644 --- a/tex/context/base/luat-mac.lua +++ b/tex/context/base/luat-mac.lua @@ -204,7 +204,7 @@ end function macros.convertfile(oldname,newname) -- beware, no testing on oldname == newname local data = resolvers.loadtexfile(oldname) - data = interfaces.preprocessed(data) or "" + data = interfaces.preprocessed(data) or "" -- interfaces not yet defined io.savedata(newname,data) end diff --git a/tex/context/base/luat-run.lua b/tex/context/base/luat-run.lua index e71215f13..65cf0f338 100644 --- a/tex/context/base/luat-run.lua +++ b/tex/context/base/luat-run.lua @@ -130,31 +130,21 @@ luatex.registerstopactions(luatex.cleanuptempfiles) -- for the moment here -local synctex = false - local report_system = logs.reporter("system") +local synctex = 0 directives.register("system.synctex", function(v) - synctex = v - if v then - report_system("synctex functionality is enabled!") + synctex = tonumber(v) or (toboolean(v,true) and 1) or (v == "zipped" and 1) or (v == "unzipped" and -1) or 0 + if synctex ~= 0 then + report_system("synctex functionality is enabled (%s)!",tostring(synctex)) else report_system("synctex functionality is disabled!") end - synctex = tonumber(synctex) or (toboolean(synctex,true) and 1) or (synctex == "zipped" and 1) or (synctex == "unzipped" and -1) or false - -- currently this is bugged: - tex.synctex = synctex - -- so for the moment we need: - context.normalsynctex() - if synctex then - context.plusone() - else - context.zerocount() - end + tex.normalsynctex = synctex end) statistics.register("synctex tracing",function() - if synctex or tex.synctex ~= 0 then + if synctex ~= 0 then return "synctex has been enabled (extra log file generated)" end end) diff --git a/tex/context/base/lxml-lpt.lua b/tex/context/base/lxml-lpt.lua index a38a7a8e2..decb6567b 100644 --- a/tex/context/base/lxml-lpt.lua +++ b/tex/context/base/lxml-lpt.lua @@ -808,7 +808,7 @@ local function nodesettostring(set,nodetest) if not ns or ns == "" then ns = "*" end if not tg or tg == "" then tg = "*" end tg = (tg == "@rt@" and "[root]") or format("%s:%s",ns,tg) - t[i] = (directive and tg) or format("not(%s)",tg) + t[#t+1] = (directive and tg) or format("not(%s)",tg) end if nodetest == false then return format("not(%s)",concat(t,"|")) diff --git a/tex/context/base/lxml-tex.lua b/tex/context/base/lxml-tex.lua index 82495383e..adb849347 100644 --- a/tex/context/base/lxml-tex.lua +++ b/tex/context/base/lxml-tex.lua @@ -11,7 +11,7 @@ if not modules then modules = { } end modules ['lxml-tex'] = { -- be an cldf-xml helper library. local utfchar = utf.char -local concat, insert, remove = table.concat, table.insert, table.remove +local concat, insert, remove, sortedkeys = table.concat, table.insert, table.remove, table.sortedkeys local format, sub, gsub, find, gmatch, match = string.format, string.sub, string.gsub, string.find, string.gmatch, string.match local type, next, tonumber, tostring, select = type, next, tonumber, tostring, select local lpegmatch = lpeg.match @@ -47,7 +47,7 @@ local xmlunprivatized = xml.unprivatized local xmlprivatetoken = xml.privatetoken local xmlprivatecodes = xml.privatecodes local xmlstripelement = xml.stripelement -local xmlinclusion = xml.inclusio +local xmlinclusion = xml.inclusion local xmlinclusions = xml.inclusions local xmlcontent = xml.content @@ -66,13 +66,14 @@ local resolveprefix = resolvers.resolve local starttiming = statistics.starttiming local stoptiming = statistics.stoptiming -local trace_setups = false trackers.register("lxml.setups", function(v) trace_setups = v end) -local trace_loading = false trackers.register("lxml.loading", function(v) trace_loading = v end) -local trace_access = false trackers.register("lxml.access", function(v) trace_access = v end) -local trace_comments = false trackers.register("lxml.comments", function(v) trace_comments = v end) -local trace_entities = false trackers.register("xml.entities", function(v) trace_entities = v end) +local trace_setups = false trackers.register("lxml.setups", function(v) trace_setups = v end) +local trace_loading = false trackers.register("lxml.loading", function(v) trace_loading = v end) +local trace_access = false trackers.register("lxml.access", function(v) trace_access = v end) +local trace_comments = false trackers.register("lxml.comments", function(v) trace_comments = v end) +local trace_entities = false trackers.register("xml.entities", function(v) trace_entities = v end) +local trace_selectors = false trackers.register("lxml.selectors",function(v) trace_selectors = v end) -local report_lxml = logs.reporter("xml","tex") +local report_lxml = logs.reporter("lxml","tex") local report_xml = logs.reporter("xml","tex") local forceraw = false @@ -438,7 +439,7 @@ function lxml.convert(id,data,entities,compress,currentresource) end function lxml.load(id,filename,compress,entities) - filename = commands.preparedfile(filename) -- not commands! + filename = ctxrunner.preparedfile(filename) if trace_loading then report_lxml("loading file %a as %a",filename,id) end @@ -1904,7 +1905,8 @@ function lxml.applyselectors(id) local dt = e.dt local ndt = #dt local done = false - for i=1,ndt do + local i = 1 + while i <= ndt do local dti = dt[i] if type(dti) == "table" then if dti.tg == "@pi@" then @@ -1916,30 +1918,39 @@ function lxml.applyselectors(id) local okay = false for k, v in next, permitted do if categories[k] then - okay = true + okay = k break end end - if not okay then - for j=i,ndt do - local dtj = dt[j] - if type(dtj) == "table" then - local tg = dtj.tg - if tg == "@pi@" then - local text = dtj.dt[1] - local what, rest = lpegmatch(pattern,text) - if what == "select" then - local categories = options_to_hash(rest) - if categories["end"] then - break - else - -- error - end + if not trace_selectors then + -- skip + elseif okay then + report_lxml("accepting selector: %s",okay) + else + categories.begin = false + report_lxml("rejecting selector: % t",sortedkeys(categories)) + end + for j=i,ndt do + local dtj = dt[j] + if type(dtj) == "table" then + local tg = dtj.tg + if tg == "@pi@" then + local text = dtj.dt[1] + local what, rest = lpegmatch(pattern,text) + if what == "select" then + local categories = options_to_hash(rest) + if categories["end"] then + i = j + break + else + -- error end - else - dtj.tg = "@cm@" end + elseif not okay then + dtj.tg = "@cm@" end + else +-- dt[j] = "" -- okay ? end end end @@ -1949,10 +1960,18 @@ function lxml.applyselectors(id) local okay = false for k, v in next, permitted do if categories[k] then - okay = true + okay = k break end end + if not trace_selectors then + -- skip + elseif okay then + report_lxml("accepting include: %s",okay) + else + categories.begin = false + report_lxml("rejecting include: % t",sortedkeys(categories)) + end if okay then for j=i,ndt do local dtj = dt[j] @@ -1965,11 +1984,12 @@ function lxml.applyselectors(id) element.__p__ = dt -- needs checking done = true elseif tg == "@pi@" then - local text = dti.dt[1] + local text = dtj.dt[1] local what, rest = lpegmatch(pattern,text) if what == "include" then local categories = options_to_hash(rest) if categories["end"] then + i = j break else -- error @@ -1978,7 +1998,6 @@ function lxml.applyselectors(id) end end end - break end end else @@ -1990,6 +2009,7 @@ function lxml.applyselectors(id) xml.reindex(dt) end end + i = i + 1 end end xmlwithelements(root,filter) diff --git a/tex/context/base/m-chart.lua b/tex/context/base/m-chart.lua index 92b079b8d..f1e7f4cb9 100644 --- a/tex/context/base/m-chart.lua +++ b/tex/context/base/m-chart.lua @@ -19,8 +19,6 @@ local P, S, C, Cc, lpegmatch = lpeg.P, lpeg.S, lpeg.C, lpeg.Cc, lpeg.match local report_chart = logs.reporter("chart") -local points = number.points -- we can use %p instead - local variables = interfaces.variables local v_yes = variables.yes @@ -507,17 +505,17 @@ local function process_cells(chart,xoffset,yoffset) local linesettings = settings.line context("flow_shape_line_color := \\MPcolor{%s} ;", linesettings.color) context("flow_shape_fill_color := \\MPcolor{%s} ;", linesettings.backgroundcolor) - context("flow_shape_line_width := %s ; ", points(linesettings.rulethickness)) + context("flow_shape_line_width := %p ; ", linesettings.rulethickness) elseif focus[cell.focus] or focus[cell.name] then local focussettings = settings.focus context("flow_shape_line_color := \\MPcolor{%s} ;", focussettings.framecolor) context("flow_shape_fill_color := \\MPcolor{%s} ;", focussettings.backgroundcolor) - context("flow_shape_line_width := %s ; ", points(focussettings.rulethickness)) + context("flow_shape_line_width := %p ; ", focussettings.rulethickness) else local shapesettings = settings.shape context("flow_shape_line_color := \\MPcolor{%s} ;", shapesettings.framecolor) context("flow_shape_fill_color := \\MPcolor{%s} ;", shapesettings.backgroundcolor) - context("flow_shape_line_width := %s ; " , points(shapesettings.rulethickness)) + context("flow_shape_line_width := %p ; " , shapesettings.rulethickness) end context("flow_peepshape := false ;") -- todo context("flow_new_shape(%s,%s,%s) ;",cell.x+xoffset,cell.y+yoffset,shapedata.number) @@ -588,7 +586,7 @@ local function process_connections(chart,xoffset,yoffset) context("flow_touchshape := %s ;", linesettings.offset == v_none and "true" or "false") context("flow_dsp_x := %s ; flow_dsp_y := %s ;",connection.dx or 0, connection.dy or 0) context("flow_connection_line_color := \\MPcolor{%s} ;",linesettings.color) - context("flow_connection_line_width := %s ;",points(linesettings.rulethickness)) + context("flow_connection_line_width := %p ;",linesettings.rulethickness) context("flow_connect_%s_%s (%s) (%s,%s,%s) (%s,%s,%s) ;",where_cell,where_other,j,cellx,celly,what_cell,otherx,othery,what_other) context("flow_dsp_x := 0 ; flow_dsp_y := 0 ;") end @@ -803,14 +801,14 @@ local function makechart(chart) local labeloffset = chartsettings.labeloffset local exitoffset = chartsettings.exitoffset local commentoffset = chartsettings.commentoffset - context("flow_grid_width := %s ;", points(gridwidth)) - context("flow_grid_height := %s ;", points(gridheight)) - context("flow_shape_width := %s ;", points(shapewidth)) - context("flow_shape_height := %s ;", points(shapeheight)) - context("flow_chart_offset := %s ;", points(chartoffset)) - context("flow_label_offset := %s ;", points(labeloffset)) - context("flow_exit_offset := %s ;", points(exitoffset)) - context("flow_comment_offset := %s ;", points(commentoffset)) + context("flow_grid_width := %p ;", gridwidth) + context("flow_grid_height := %p ;", gridheight) + context("flow_shape_width := %p ;", shapewidth) + context("flow_shape_height := %p ;", shapeheight) + context("flow_chart_offset := %p ;", chartoffset) + context("flow_label_offset := %p ;", labeloffset) + context("flow_exit_offset := %p ;", exitoffset) + context("flow_comment_offset := %p ;", commentoffset) -- local radius = settings.line.radius local rulethickness = settings.line.rulethickness @@ -825,10 +823,10 @@ local function makechart(chart) radius = dy end end - context("flow_connection_line_width := %s ;", points(rulethickness)) - context("flow_connection_smooth_size := %s ;", points(radius)) - context("flow_connection_arrow_size := %s ;", points(radius)) - context("flow_connection_dash_size := %s ;", points(radius)) + context("flow_connection_line_width := %p ;", rulethickness) + context("flow_connection_smooth_size := %p ;", radius) + context("flow_connection_arrow_size := %p ;", radius) + context("flow_connection_dash_size := %p ;", radius) -- local offset = chartsettings.offset -- todo: pass string if offset == v_none or offset == v_overlay or offset == "" then @@ -836,7 +834,7 @@ local function makechart(chart) elseif offset == v_standard then offset = radius -- or rulethickness? end - context("flow_chart_offset := %s ;",points(offset)) + context("flow_chart_offset := %p ;",offset) -- context("flow_reverse_y := true ;") process_cells(chart,0,0) diff --git a/tex/context/base/m-steps.lua b/tex/context/base/m-steps.lua index 97759b799..8eb481550 100644 --- a/tex/context/base/m-steps.lua +++ b/tex/context/base/m-steps.lua @@ -10,7 +10,6 @@ if not modules then modules = { } end modules ['x-flow'] = { moduledata.steps = moduledata.steps or { } -local points = number.points -- number.pt local variables = interfaces.variables local trace_charts = false @@ -100,22 +99,22 @@ function commands.step_make_chart(settings) end -- context("text_line_color := \\MPcolor{%s} ;", textsettings.framecolor) - context("text_line_width := %s ;", points(textsettings.rulethickness)) + context("text_line_width := %p ;", textsettings.rulethickness) context("text_fill_color := \\MPcolor{%s} ;", textsettings.backgroundcolor) - context("text_offset := %s ;", points(textsettings.offset)) - context("text_distance_set := %s ;", points(textsettings.distance)) + context("text_offset := %p ;", textsettings.offset) + context("text_distance_set := %p ;", textsettings.distance) -- context("cell_line_color := \\MPcolor{%s} ;", cellsettings.framecolor) - context("cell_line_width := %s ;", points(cellsettings.rulethickness)) + context("cell_line_width := %p ;", cellsettings.rulethickness) context("cell_fill_color := \\MPcolor{%s} ;", cellsettings.backgroundcolor) - context("cell_offset := %s ;", points(cellsettings.offset)) - context("cell_distance_x := %s ;", points(cellsettings.dx)) - context("cell_distance_y := %s ;", points(cellsettings.dy)) + context("cell_offset := %p ;", cellsettings.offset) + context("cell_distance_x := %p ;", cellsettings.dx) + context("cell_distance_y := %p ;", cellsettings.dy) -- context("line_line_color := \\MPcolor{%s} ;", linesettings.color) - context("line_line_width := %s ;", points(linesettings.rulethickness)) - context("line_distance := %s ;", points(linesettings.distance)) - context("line_offset := %s ;", points(linesettings.offset)) + context("line_line_width := %p ;", linesettings.rulethickness) + context("line_distance := %p ;", linesettings.distance) + context("line_offset := %p ;", linesettings.offset) -- for i=1,#steps do local step = steps[i] diff --git a/tex/context/base/math-act.lua b/tex/context/base/math-act.lua index 9c69a09de..76222913b 100644 --- a/tex/context/base/math-act.lua +++ b/tex/context/base/math-act.lua @@ -538,85 +538,6 @@ interfaces.implement { local blocks = characters.blocks -- this will move to char-ini -blocks["uppercasenormal"] = { first = 0x00041, last = 0x0005A } -blocks["uppercasebold"] = { first = 0x1D400, last = 0x1D419 } -blocks["uppercaseitalic"] = { first = 0x1D434, last = 0x1D44D } -blocks["uppercasebolditalic"] = { first = 0x1D468, last = 0x1D481 } -blocks["uppercasescript"] = { first = 0x1D49C, last = 0x1D4B5 } -blocks["uppercaseboldscript"] = { first = 0x1D4D0, last = 0x1D4E9 } -blocks["uppercasefraktur"] = { first = 0x1D504, last = 0x1D51D } -blocks["uppercasedoublestruck"] = { first = 0x1D538, last = 0x1D551 } -blocks["uppercaseboldfraktur"] = { first = 0x1D56C, last = 0x1D585 } -blocks["uppercasesansserifnormal"] = { first = 0x1D5A0, last = 0x1D5B9 } -blocks["uppercasesansserifbold"] = { first = 0x1D5D4, last = 0x1D5ED } -blocks["uppercasesansserifitalic"] = { first = 0x1D608, last = 0x1D621 } -blocks["uppercasesansserifbolditalic"] = { first = 0x1D63C, last = 0x1D655 } -blocks["uppercasemonospace"] = { first = 0x1D670, last = 0x1D689 } -blocks["uppercasegreeknormal"] = { first = 0x00391, last = 0x003AA } -blocks["uppercasegreekbold"] = { first = 0x1D6A8, last = 0x1D6C1 } -blocks["uppercasegreekitalic"] = { first = 0x1D6E2, last = 0x1D6FB } -blocks["uppercasegreekbolditalic"] = { first = 0x1D71C, last = 0x1D735 } -blocks["uppercasegreeksansserifbold"] = { first = 0x1D756, last = 0x1D76F } -blocks["uppercasegreeksansserifbolditalic"] = { first = 0x1D790, last = 0x1D7A9 } - -blocks["lowercasenormal"] = { first = 0x00061, last = 0x0007A } -blocks["lowercasebold"] = { first = 0x1D41A, last = 0x1D433 } -blocks["lowercaseitalic"] = { first = 0x1D44E, last = 0x1D467 } -blocks["lowercasebolditalic"] = { first = 0x1D482, last = 0x1D49B } -blocks["lowercasescript"] = { first = 0x1D4B6, last = 0x1D4CF } -blocks["lowercaseboldscript"] = { first = 0x1D4EA, last = 0x1D503 } -blocks["lowercasefraktur"] = { first = 0x1D51E, last = 0x1D537 } -blocks["lowercasedoublestruck"] = { first = 0x1D552, last = 0x1D56B } -blocks["lowercaseboldfraktur"] = { first = 0x1D586, last = 0x1D59F } -blocks["lowercasesansserifnormal"] = { first = 0x1D5BA, last = 0x1D5D3 } -blocks["lowercasesansserifbold"] = { first = 0x1D5EE, last = 0x1D607 } -blocks["lowercasesansserifitalic"] = { first = 0x1D622, last = 0x1D63B } -blocks["lowercasesansserifbolditalic"] = { first = 0x1D656, last = 0x1D66F } -blocks["lowercasemonospace"] = { first = 0x1D68A, last = 0x1D6A3 } -blocks["lowercasegreeknormal"] = { first = 0x003B1, last = 0x003CA } -blocks["lowercasegreekbold"] = { first = 0x1D6C2, last = 0x1D6DB } -blocks["lowercasegreekitalic"] = { first = 0x1D6FC, last = 0x1D715 } -blocks["lowercasegreekbolditalic"] = { first = 0x1D736, last = 0x1D74F } -blocks["lowercasegreeksansserifbold"] = { first = 0x1D770, last = 0x1D789 } -blocks["lowercasegreeksansserifbolditalic"] = { first = 0x1D7AA, last = 0x1D7C3 } - -blocks["digitsnormal"] = { first = 0x00030, last = 0x00039 } -blocks["digitsbold"] = { first = 0x1D7CE, last = 0x1D7D8 } -blocks["digitsdoublestruck"] = { first = 0x1D7D8, last = 0x1D7E2 } -blocks["digitssansserifnormal"] = { first = 0x1D7E2, last = 0x1D7EC } -blocks["digitssansserifbold"] = { first = 0x1D7EC, last = 0x1D805 } -blocks["digitsmonospace"] = { first = 0x1D7F6, last = 0x1D80F } - -blocks["mathematicaloperators"] = { first = 0x02200, last = 0x022FF } -blocks["miscellaneousmathematicalsymbolsa"] = { first = 0x027C0, last = 0x027EF } -blocks["miscellaneousmathematicalsymbolsb"] = { first = 0x02980, last = 0x029FF } -blocks["supplementalmathematicaloperators"] = { first = 0x02A00, last = 0x02AFF } -blocks["letterlikesymbols"] = { first = 0x02100, last = 0x0214F } -blocks["miscellaneoustechnical"] = { first = 0x02308, last = 0x0230B } -blocks["geometricshapes"] = { first = 0x025A0, last = 0x025FF } -blocks["miscellaneoussymbolsandarrows"] = { first = 0x02B30, last = 0x02B4C } -blocks["mathematicalalphanumericsymbols"] = { first = 0x00400, last = 0x1D7FF } - -blocks["digitslatin"] = { first = 0x00030, last = 0x00039 } -blocks["digitsarabicindic"] = { first = 0x00660, last = 0x00669 } -blocks["digitsextendedarabicindic"] = { first = 0x006F0, last = 0x006F9 } -------["digitsdevanagari"] = { first = 0x00966, last = 0x0096F } -------["digitsbengali"] = { first = 0x009E6, last = 0x009EF } -------["digitsgurmukhi"] = { first = 0x00A66, last = 0x00A6F } -------["digitsgujarati"] = { first = 0x00AE6, last = 0x00AEF } -------["digitsoriya"] = { first = 0x00B66, last = 0x00B6F } -------["digitstamil"] = { first = 0x00030, last = 0x00039 } -- no zero -------["digitstelugu"] = { first = 0x00C66, last = 0x00C6F } -------["digitskannada"] = { first = 0x00CE6, last = 0x00CEF } -------["digitsmalayalam"] = { first = 0x00D66, last = 0x00D6F } -------["digitsthai"] = { first = 0x00E50, last = 0x00E59 } -------["digitslao"] = { first = 0x00ED0, last = 0x00ED9 } -------["digitstibetan"] = { first = 0x00F20, last = 0x00F29 } -------["digitsmyanmar"] = { first = 0x01040, last = 0x01049 } -------["digitsethiopic"] = { first = 0x01369, last = 0x01371 } -------["digitskhmer"] = { first = 0x017E0, last = 0x017E9 } -------["digitsmongolian"] = { first = 0x01810, last = 0x01809 } - -- operators : 0x02200 -- symbolsa : 0x02701 -- symbolsb : 0x02901 diff --git a/tex/context/base/math-fbk.lua b/tex/context/base/math-fbk.lua index 271fe3e59..76dd1ad9b 100644 --- a/tex/context/base/math-fbk.lua +++ b/tex/context/base/math-fbk.lua @@ -189,12 +189,12 @@ virtualcharacters[0x207B] = function(data) end virtualcharacters[0x208A] = function(data) - data.replacement = 0x2212 + data.replacement = 0x002B return raised(data,true) end virtualcharacters[0x208B] = function(data) - data.replacement = 0x002B + data.replacement = 0x2212 return raised(data,true) end diff --git a/tex/context/base/math-ini.lua b/tex/context/base/math-ini.lua index 78ccf1779..88159e107 100644 --- a/tex/context/base/math-ini.lua +++ b/tex/context/base/math-ini.lua @@ -699,3 +699,11 @@ implement { name = "resetmathattributes", actions = mathematics.resetattributes } + +-- weird to do this here but it's a side affect of math anyway + +interfaces.implement { + name = "enableasciimode", + onlyonce = true, + actions = resolvers.macros.enablecomment, +} diff --git a/tex/context/base/math-ini.mkiv b/tex/context/base/math-ini.mkiv index a724bda58..2d6090c03 100644 --- a/tex/context/base/math-ini.mkiv +++ b/tex/context/base/math-ini.mkiv @@ -874,17 +874,16 @@ % \ifconditional\knuthmode\else\donknuthmode\fi} \unexpanded\def\enableasciimode - {\ctxlua{resolvers.macros.enablecomment()}% - \glet\enableasciimode\relax} + {\clf_enableasciimode} % relaxes itself \unexpanded\def\asciimode {\catcodetable\txtcatcodes - \enableasciimode} + \clf_enableasciimode} \unexpanded\def\startasciimode {\pushcatcodetable \catcodetable\txtcatcodes - \enableasciimode} + \clf_enableasciimode} \unexpanded\def\stopasciimode {\popcatcodetable} diff --git a/tex/context/base/math-noa.lua b/tex/context/base/math-noa.lua index 412d18d05..0670b3529 100644 --- a/tex/context/base/math-noa.lua +++ b/tex/context/base/math-noa.lua @@ -90,8 +90,6 @@ local font_of_family = node.family_font local new_kern = nodepool.kern local new_rule = nodepool.rule -local topoints = number.points - local fonthashes = fonts.hashes local fontdata = fonthashes.identifiers local fontcharacters = fonthashes.characters diff --git a/tex/context/base/math-rad.mkvi b/tex/context/base/math-rad.mkvi index c52fd8e93..23e056c1f 100644 --- a/tex/context/base/math-rad.mkvi +++ b/tex/context/base/math-rad.mkvi @@ -173,11 +173,11 @@ \setbox\nextbox\mathstylehbox{#body}% % we use the \overlay variables as these are passes anyway and % it's more efficient than using parameters - \edef\overlaywidth {\the\wd\nextbox}% - \edef\overlayheight {\the\ht\nextbox}% - \edef\overlaydepth {\the\dp\nextbox}% - \edef\overlayoffset {\the\scratchoffset}% - \edef\overlaylinewidth{\the\linewidth}% + \d_overlay_width \wd\nextbox + \d_overlay_height \ht\nextbox + \d_overlay_depth \dp\nextbox + \d_overlay_offset \scratchoffset + \d_overlay_linewidth\linewidth \edef\overlaylinecolor{\mathradicalparameter\c!color}% % \edef\p_mp{\mathradicalparameter\c!mp}% @@ -233,11 +233,11 @@ {\begingroup \scratchoffset\mathornamentparameter\c!mpoffset \setbox\nextbox\mathstylehbox{#body}% - \edef\overlaywidth {\the\wd\nextbox}% - \edef\overlayheight {\the\ht\nextbox}% - \edef\overlaydepth {\the\dp\nextbox}% - \edef\overlayoffset {\the\scratchoffset}% - \edef\overlaylinewidth{\the\linewidth}% + \d_overlay_width \wd\nextbox + \d_overlay_height \ht\nextbox + \d_overlay_depth \dp\nextbox + \d_overlay_offset \scratchoffset + \d_overlay_linewidth\linewidth \edef\overlaylinecolor{\mathornamentparameter\c!color}% \edef\p_mp{\mathornamentparameter\c!mp}% % thw width of the graphic determines the width of the final result diff --git a/tex/context/base/math-stc.mkvi b/tex/context/base/math-stc.mkvi index e7c775ae4..a879d157f 100644 --- a/tex/context/base/math-stc.mkvi +++ b/tex/context/base/math-stc.mkvi @@ -222,11 +222,11 @@ \setvalue{\??mathstackersalternative\v!mp}% {\hbox\bgroup % todo: add code key + tag - \edef\overlaywidth {\the\scratchwidth}% - \edef\overlayheight {\the\dimexpr\mathstackersparameter\c!mpheight}% - \edef\overlaydepth {\the\dimexpr\mathstackersparameter\c!mpdepth}% - \edef\overlayoffset {\the\dimexpr\mathstackersparameter\c!mpoffset}% - \edef\overlaylinewidth{\the\linewidth}% + \d_overlay_width \scratchwidth + \d_overlay_height \dimexpr\mathstackersparameter\c!mpheight + \d_overlay_depth \dimexpr\mathstackersparameter\c!mpdepth + \d_overlay_offset \dimexpr\mathstackersparameter\c!mpoffset + \d_overlay_linewidth\linewidth \edef\overlaylinecolor{\mathstackersparameter\c!color}% \edef\p_mp{\mathstackersparameter\c!mp}% \uniqueMPgraphic{\p_mp}% diff --git a/tex/context/base/meta-fnt.lua b/tex/context/base/meta-fnt.lua index 02bf5d6b2..95bdfa6d9 100644 --- a/tex/context/base/meta-fnt.lua +++ b/tex/context/base/meta-fnt.lua @@ -249,7 +249,16 @@ function metapost.fonts.define(specification) } ) end -commands.definemetafont = metapost.fonts.define +interfaces.implement { + name = "definemetafont", + actions = metapost.fonts.define, + arguments = { + { + { "fontname" }, + { "filename" }, + } + } +} -- metapost.fonts.define { -- fontname = "bidi", diff --git a/tex/context/base/meta-fnt.mkiv b/tex/context/base/meta-fnt.mkiv index 603fcf14d..e54c0be0a 100644 --- a/tex/context/base/meta-fnt.mkiv +++ b/tex/context/base/meta-fnt.mkiv @@ -21,11 +21,11 @@ {\dotripleempty\meta_font_define} \def\meta_font_define[#1][#2][#3]% - {\ctxcommand{definemetafont { - fontname = "#1", - filename = "#2" + {\clf_definemetafont + fontname {#1}% + filename {#2}% % no #3 settings yet (compose, instances) - }}} + \relax} % \startluacode % metapost.fonts.define { fontname = "bidi-symbols", filename = "bidi-symbols.mp" } diff --git a/tex/context/base/meta-ini.mkiv b/tex/context/base/meta-ini.mkiv index d0c5896f4..6e23411f9 100644 --- a/tex/context/base/meta-ini.mkiv +++ b/tex/context/base/meta-ini.mkiv @@ -155,12 +155,12 @@ \global\t_meta_inclusions\expandafter{\the\t_meta_inclusions#2}% \let\currentMPinstance\m_meta_saved_instance} -\def\meta_preset_definitions - {\edef\overlaywidth {\overlaywidth \space}% - \edef\overlayheight {\overlayheight \space}% - \edef\overlaylinewidth{\overlaylinewidth\space}% - \edef\currentwidth {\the\hsize \space}% - \edef\currentheight {\the\vsize \space}} +% \def\meta_preset_definitions +% {\edef\overlaywidth {\overlaywidth \space}% +% \edef\overlayheight {\overlayheight \space}% +% \edef\overlaylinewidth{\overlaylinewidth\space}} + +\let\meta_preset_definitions\relax \installcommandhandler \??mpinstance {MPinstance} \??mpinstance @@ -426,8 +426,10 @@ \unexpanded\def\meta_grab_clip_path#1#2#3#4% #4 is alternative (called in backend code) {\begingroup - \edef\width {#2\space}\let\overlaywidth \width - \edef\height{#3\space}\let\overlayheight\height +% \edef\width {#2\space}\let\overlaywidth \width +% \edef\height{#3\space}\let\overlayheight\height + \d_overlay_width #2\onebasepoint\edef\width {\the\d_overlay_width \space}% + \d_overlay_height#3\onebasepoint\edef\height{\the\d_overlay_height\space}% \edef\currentMPclip{#1}% \ifcsname\??mpclip\currentMPclip\endcsname \meta_grab_clip_path_indeed @@ -459,7 +461,7 @@ {\dontleavehmode \begingroup \definedfont[#1]% - \hskip\cldcontext{fonts.hashes.parameters[font.current()].designsize}\scaledpoint\relax + \hskip\clf_currentdesignsize\scaledpoint\relax \endgroup} \definefontsynonym[MetafunDefault][Regular*default] @@ -467,7 +469,7 @@ \startMPinitializations % scale is not yet ok defaultfont:="\truefontname{MetafunDefault}"; % defaultscale:=\the\bodyfontsize/10pt; % only when hard coded 10pt - defaultscale:=1; + % defaultscale:=1; \stopMPinitializations % watch out, this is a type1 font because mp can only handle 8 bit fonts @@ -629,7 +631,13 @@ %D \stoptyping \def\overlaystamp % watch the \MPcolor, since colors can be redefined - {\overlaywidth:\overlayheight:\overlaydepth:\overlayoffset:\overlaylinewidth:\MPcolor\overlaycolor:\MPcolor\overlaylinecolor} + {\the\d_overlay_width :% + \the\d_overlay_height :% + \the\d_overlay_depth :% + \the\d_overlay_offset :% + \the\d_overlay_linewidth:% + \MPcolor\overlaycolor :% % todo, expand once \m_overlaycolor + \MPcolor\overlaylinecolor} % todo, expand once \m_overlaylinecolor %D A better approach is to let additional variables play a role %D in determining the uniqueness. In the next macro, the @@ -819,8 +827,18 @@ \def\m_meta_page_prefix{\doifelseoddpage oe} +% \def\overlaypagestamp +% {\m_meta_page_prefix:\overlaywidth:\overlayheight:\overlaydepth:\MPcolor\overlaycolor:\MPcolor\overlaylinecolor} + \def\overlaypagestamp - {\m_meta_page_prefix:\overlaywidth:\overlayheight:\overlaydepth:\MPcolor\overlaycolor:\MPcolor\overlaylinecolor} + {\m_meta_page_prefix :% + \the\d_overlay_width :% + \the\d_overlay_height :% + \the\d_overlay_depth :% + \the\d_overlay_offset :% + \the\d_overlay_linewidth:% + \MPcolor\overlaycolor :% + \MPcolor\overlaylinecolor} \unexpanded\def\startuniqueMPpagegraphic {\dodoublegroupempty\meta_start_unique_page_graphic} @@ -884,12 +902,21 @@ % makempy.registerfile(filename) -\startMPinitializations - boolean collapse_data; collapse_data:=true; - def data_mpd_file = "\MPdataMPDfile" enddef ; - def data_mpo_file = "\MPdataMPOfile" enddef ; - def data_mpy_file = "\MPdataMPYfile" enddef ; -\stopMPinitializations +% % hm. extensions get expanded so the wrong names then end up in format +% +% \startMPinitializations +% boolean collapse_data; collapse_data:=true ; % will be obsolete +% def data_mpd_file = "\MPdataMPDfile" enddef ; % will go via lua +% def data_mpo_file = "\MPdataMPOfile" enddef ; +% def data_mpy_file = "\MPdataMPYfile" enddef ; +% \stopMPinitializations + +\startMPextensions + boolean collapse_data; collapse_data:=true ; % will be obsolete + def data_mpd_file = "\noexpand\MPdataMPDfile" enddef ; % will go via lua + def data_mpo_file = "\noexpand\MPdataMPOfile" enddef ; + def data_mpy_file = "\noexpand\MPdataMPYfile" enddef ; +\stopMPextensions \unexpanded\def\getMPdata {\let\MPdata\secondoftwoarguments @@ -1113,46 +1140,62 @@ % \setupcolors[state=stop,conversion=never] % quite tricky ... type mismatch -% A dirty trick, ** in colo-ini.lua (mpcolor). +% \startMPextensions +% color OverlayColor,OverlayLineColor; +% \stopMPextensions -\def\m_meta_colo_initializations{% no vardef, goes wrong with spot colors - def OverlayLineColor=\MPcolor{\overlaylinecolor} enddef; - def OverlayColor=\MPcolor{\overlaycolor} enddef; -} +\startMPinitializations + CurrentLayout:="\currentlayout"; +\stopMPinitializations -\startMPextensions - color OverlayColor,OverlayLineColor; -\stopMPextensions +% \startMPinitializations +% OverlayWidth:=\overlaywidth; +% OverlayHeight:=\overlayheight; +% OverlayDepth:=\overlaydepth; +% OverlayLineWidth:=\overlaylinewidth; +% OverlayOffset:=\overlayoffset; +% \stopMPinitializations + +% A dirty trick, ** in colo-ini.lua (mpcolor). We cannot use a vardef, because +% that fails with spot colors. \startMPinitializations - CurrentLayout:="\currentlayout"; - OverlayWidth:=\overlaywidth; - OverlayHeight:=\overlayheight; - OverlayDepth:=\overlaydepth; - OverlayLineWidth:=\overlaylinewidth; - OverlayOffset:=\overlayoffset; - % - \m_meta_colo_initializations - % - BaseLineSkip:=\the\baselineskip; - LineHeight:=\the\baselineskip; - BodyFontSize:=\the\bodyfontsize; - % - TopSkip:=\the\topskip; - StrutHeight:=\strutheight; - StrutDepth:=\strutdepth; - % - CurrentWidth:=\the\hsize; - CurrentHeight:=\the\vsize; - % - EmWidth:=\the\emwidth; - ExHeight:=\the\exheight; - % - PageNumber:=\the\pageno; - RealPageNumber:=\the\realpageno; - LastPageNumber:= \lastpage; + def OverlayLineColor=\ifx\overlaylinecolor\empty black \else\MPcolor{\overlaylinecolor} \fi enddef; + def OverlayColor =\ifx\overlaycolor \empty black \else\MPcolor{\overlaycolor} \fi enddef; \stopMPinitializations +% \newcount\c_overlay_colormodel +% \newcount\c_overlay_color +% \newcount\c_overlay_transparency +% \newcount\c_overlay_linecolor +% \newcount\c_overlay_linetransparency + +% \appendtoks +% \c_overlay_colormodel \attribute\colormodelattribute +% \c_overlay_color \colo_helpers_inherited_current_ca\overlaycolor +% \c_overlay_transparency \colo_helpers_inherited_current_ta\overlaycolor +% \c_overlay_linecolor \colo_helpers_inherited_current_ca\overlaylinecolor +% \c_overlay_linetransparency\colo_helpers_inherited_current_ta\overlaylinecolor +% \to \everyMPgraphic + +% \startMPinitializations +% BaseLineSkip:=\the\baselineskip; +% LineHeight:=\the\baselineskip; +% BodyFontSize:=\the\bodyfontsize; +% % +% TopSkip:=\the\topskip; +% StrutHeight:=\strutheight; +% StrutDepth:=\strutdepth; +% % +% CurrentWidth:=\the\hsize; +% CurrentHeight:=\the\vsize; +% HSize:=\the\hsize ; +% VSize:=\the\vsize ; +% % +% EmWidth:=\the\emwidth; +% ExHeight:=\the\exheight; +% \stopMPinitializations + \appendtoks \disablediscretionaries \disablecompoundcharacters @@ -1182,11 +1225,6 @@ \let \} \letterclosebrace \to \everyMPgraphic -\startMPinitializations - prologues:=0; - mpprocset:=1; -\stopMPinitializations - %D \macros %D {PDFMPformoffset} %D @@ -1213,21 +1251,19 @@ enddef; \stopMPextensions -\startMPinitializations - HSize:=\the\hsize ; - VSize:=\the\vsize ; -\stopMPinitializations - \startMPextensions vardef ForegroundBox = unitsquare xysized(HSize,VSize) enddef ; - PageFraction := 1 ; \stopMPextensions -\startMPinitializations - PageFraction := if \lastpage>1: (\realfolio-1)/(\lastpage-1) else: 1 fi ; -\stopMPinitializations +% \startMPextensions +% PageFraction := 1 ; +% \stopMPextensions + +% \startMPinitializations +% PageFraction := if \lastpage>1: (\realfolio-1)/(\lastpage-1) else: 1 fi ; +% \stopMPinitializations \startMPdefinitions {metapost} if unknown context_bare : input mp-bare.mpiv ; fi ; @@ -1412,9 +1448,9 @@ \dogetattribute{transparency}\relax \to \everyMPgraphic -\startMPinitializations - defaultcolormodel := \ifcase\MPcolormethod1\or1\or3\else3\fi; -\stopMPinitializations +% \startMPinitializations +% defaultcolormodel := \ifcase\MPcolormethod1\or1\or3\else3\fi; +% \stopMPinitializations %D macros %D {mprunvar,mpruntab,mprunset} @@ -1511,7 +1547,7 @@ \edef\p_mpy{\directMPgraphicsparameter{mpy}}% \ifx\p_mpy\empty \else \let\MPdataMPYfile\p_mpy - \ctxlua{metapost.makempy.registerfile("\p_mpy")}% + \clf_registermpyfile{\p_mpy}% \fi \to \everysetupMPgraphics diff --git a/tex/context/base/meta-pag.mkiv b/tex/context/base/meta-pag.mkiv index d28022164..3e3025344 100644 --- a/tex/context/base/meta-pag.mkiv +++ b/tex/context/base/meta-pag.mkiv @@ -23,71 +23,69 @@ %D pagebody looks. \startMPextensions - boolean PageStateAvailable,OnRightPage,InPageBody; + boolean PageStateAvailable; PageStateAvailable:=true; \stopMPextensions -\startMPinitializations - OnRightPage:=true; - InPageBody:=\ifinpagebody true \else false \fi; -\stopMPinitializations - -\startMPinitializations - CurrentColumn:=\number\mofcolumns; - NOfColumns:=\number\nofcolumns; - % todo: ColumnDistance -\stopMPinitializations - % maybe always set as frozen anyway -\startMPinitializations - OnRightPage:=\MPonrightpage; - OnOddPage:=\MPonoddpage; - RealPageNumber:=\the\realpageno; - PageNumber:=\the\pageno; - NOfPages:=\lastpage; - PaperHeight:=\the\paperheight; - PaperWidth:=\the\paperwidth; - PrintPaperHeight:=\the\printpaperheight; - PrintPaperWidth:=\the\printpaperwidth; - TopSpace:=\the\topspace; - BottomSpace:=\the\bottomspace; - BackSpace:=\the\backspace; - CutSpace:=\the\cutspace; - MakeupHeight:=\the\makeupheight; - MakeupWidth:=\the\makeupwidth; - TopHeight:=\the\topheight; - TopDistance:=\the\topdistance; - HeaderHeight:=\the\headerheight; - HeaderDistance:=\the\headerdistance; - TextHeight:=\the\textheight; - FooterDistance:=\the\footerdistance; - FooterHeight:=\the\footerheight; - BottomDistance:=\the\bottomdistance; - BottomHeight:=\the\bottomheight; - LeftEdgeWidth:=\the\leftedgewidth; - LeftEdgeDistance:=\the\leftedgedistance; - LeftMarginWidth:=\the\leftmarginwidth; - LeftMarginDistance:=\the\leftmargindistance; - TextWidth:=\the\textwidth; - RightMarginDistance:=\the\rightmargindistance; - RightMarginWidth:=\the\rightmarginwidth; - RightEdgeDistance:=\the\rightedgedistance; - RightEdgeWidth:=\the\rightedgewidth; - InnerMarginDistance:=\the\innermargindistance; - InnerMarginWidth:=\the\innermarginwidth; - OuterMarginDistance:=\the\outermargindistance; - OuterMarginWidth:=\the\outermarginwidth; - InnerEdgeDistance:=\the\inneredgedistance; - InnerEdgeWidth:=\the\inneredgewidth; - OuterEdgeDistance:=\the\outeredgedistance; - OuterEdgeWidth:=\the\outeredgewidth; - PageOffset:=\the\pagebackgroundoffset; - PageDepth:=\the\pagebackgrounddepth; - LayoutColumns:=\the\layoutcolumns; - LayoutColumnDistance:=\the\layoutcolumndistance; - LayoutColumnWidth:=\the\layoutcolumnwidth; -\stopMPinitializations +% \startMPinitializations +% PaperHeight:=\the\paperheight; +% PaperWidth:=\the\paperwidth; +% PrintPaperHeight:=\the\printpaperheight; +% PrintPaperWidth:=\the\printpaperwidth; +% TopSpace:=\the\topspace; +% BottomSpace:=\the\bottomspace; +% BackSpace:=\the\backspace; +% CutSpace:=\the\cutspace; +% MakeupHeight:=\the\makeupheight; +% MakeupWidth:=\the\makeupwidth; +% TopHeight:=\the\topheight; +% TopDistance:=\the\topdistance; +% HeaderHeight:=\the\headerheight; +% HeaderDistance:=\the\headerdistance; +% TextHeight:=\the\textheight; +% FooterDistance:=\the\footerdistance; +% FooterHeight:=\the\footerheight; +% BottomDistance:=\the\bottomdistance; +% BottomHeight:=\the\bottomheight; +% LeftEdgeWidth:=\the\leftedgewidth; +% LeftEdgeDistance:=\the\leftedgedistance; +% LeftMarginWidth:=\the\leftmarginwidth; +% LeftMarginDistance:=\the\leftmargindistance; +% TextWidth:=\the\textwidth; +% RightMarginDistance:=\the\rightmargindistance; +% RightMarginWidth:=\the\rightmarginwidth; +% RightEdgeDistance:=\the\rightedgedistance; +% RightEdgeWidth:=\the\rightedgewidth; +% InnerMarginDistance:=\the\innermargindistance; +% InnerMarginWidth:=\the\innermarginwidth; +% OuterMarginDistance:=\the\outermargindistance; +% OuterMarginWidth:=\the\outermarginwidth; +% InnerEdgeDistance:=\the\inneredgedistance; +% InnerEdgeWidth:=\the\inneredgewidth; +% OuterEdgeDistance:=\the\outeredgedistance; +% OuterEdgeWidth:=\the\outeredgewidth; +% PageOffset:=\the\pagebackgroundoffset; +% PageDepth:=\the\pagebackgrounddepth; +% LayoutColumns:=\the\layoutcolumns; +% LayoutColumnDistance:=\the\layoutcolumndistance; +% LayoutColumnWidth:=\the\layoutcolumnwidth; +% % +% boolean OnRightPage,OnOddPage,InPageBody; +% % +% OnRightPage:=\MPonrightpage; +% OnOddPage:=\MPonoddpage; +% InPageBody:=\ifinpagebody true \else false \fi; +% % +% RealPageNumber:=\the\realpageno; +% PageNumber:=\the\pageno; +% NOfPages:=\lastpage; +% LastPageNumber:=\lastpage; +% % +% CurrentColumn:=\number\mofcolumns; +% NOfColumns:=\number\nofcolumns; +% \stopMPinitializations \def\MPonrightpage{true} \def\MPonoddpage {true} diff --git a/tex/context/base/meta-pdf.lua b/tex/context/base/meta-pdf.lua index 7a66081e7..3cbff63b1 100644 --- a/tex/context/base/meta-pdf.lua +++ b/tex/context/base/meta-pdf.lua @@ -573,3 +573,11 @@ statistics.register("mps conversion time",function() return nil end end) + +-- interface + +interfaces.implement { + name = "convertmpstopdf", + arguments = "string", + actions = mptopdf.convertmpstopdf +} diff --git a/tex/context/base/meta-pdf.mkiv b/tex/context/base/meta-pdf.mkiv index 3469419d4..50eb1dd72 100644 --- a/tex/context/base/meta-pdf.mkiv +++ b/tex/context/base/meta-pdf.mkiv @@ -46,7 +46,7 @@ \forgetall \offinterlineskip \setbox\MPbox\vbox\bgroup - \ctxlua{metapost.mptopdf.convertmpstopdf("\MPfilename")}% + \clf_convertmpstopdf{\MPfilename}% \removeunwantedspaces % not that needed \egroup \finalizeMPbox diff --git a/tex/context/base/meta-pdh.mkiv b/tex/context/base/meta-pdh.mkiv index b65fe6ac6..f3db5b388 100644 --- a/tex/context/base/meta-pdh.mkiv +++ b/tex/context/base/meta-pdh.mkiv @@ -374,17 +374,17 @@ %D %D \startbuffer %D \startuniqueMPgraphic{CircularShade} -%D path p ; p := unitsquare xscaled \overlaywidth yscaled \overlayheight ; +%D path p ; p := unitsquare xscaled OverlayWidth yscaled OverlayHeight ; %D circular_shade(p,0,.2red,.9red) ; %D \stopuniqueMPgraphic %D %D \startuniqueMPgraphic{LinearShade} -%D path p ; p := unitsquare xscaled \overlaywidth yscaled \overlayheight ; +%D path p ; p := unitsquare xscaled OverlayWidth yscaled OverlayHeight ; %D linear_shade(p,0,.2blue,.9blue) ; %D \stopuniqueMPgraphic %D %D \startuniqueMPgraphic{DuotoneShade} -%D path p ; p := unitsquare xscaled \overlaywidth yscaled \overlayheight ; +%D path p ; p := unitsquare xscaled OverlayWidth yscaled OverlayHeight ; %D linear_shade(p,2,.5green,.5red) ; %D \stopuniqueMPgraphic %D \stopbuffer @@ -429,8 +429,8 @@ %D %D \def\SomeShade#1#2#3#4#5% %D {\startuniqueMPgraphic{Shade-#1} -%D width := \overlaywidth ; -%D height := \overlayheight ; +%D width := OverlayWidth ; +%D height := OverlayHeight ; %D path p ; p := unitsquare xscaled width yscaled height ; %D #2_shade(p,#3,#4,#5) ; %D \stopuniqueMPgraphic diff --git a/tex/context/base/meta-tex.lua b/tex/context/base/meta-tex.lua index d5af74f63..1008e45c0 100644 --- a/tex/context/base/meta-tex.lua +++ b/tex/context/base/meta-tex.lua @@ -6,12 +6,15 @@ if not modules then modules = { } end modules ['meta-tex'] = { license = "see context related readme files" } +local tostring = tostring local format, gsub, find, match = string.format, string.gsub, string.find, string.match local formatters = string.formatters local P, S, R, C, Cs, lpegmatch = lpeg.P, lpeg.S, lpeg.R, lpeg.C, lpeg.Cs, lpeg.match metapost = metapost or { } +local implement = interfaces.implement + -- local left = P("[") -- local right = P("]") -- local space = P(" ") @@ -39,6 +42,12 @@ function metapost.escaped(str) context(lpegmatch(pattern,str)) end +implement { + name = "metapostescaped", + actions = metapost.escaped, + arguments = "string" +} + local simplify = true -- local function strip(n,e) @@ -138,6 +147,9 @@ function metapost.nvformat(fmt,str) metapost.format_number(fmt,metapost.untagvariable(str,false)) end +implement { name = "metapostformatted", actions = metapost.svformat, arguments = { "string", "string" } } +implement { name = "metapostgraphformat", actions = metapost.nvformat, arguments = { "string", "string" } } + -- local function test(fmt,n) -- logs.report("mp format test","fmt: %s, n: %s, result: %s, \\exponent{%s}{%s}",fmt,n, -- formatters[lpegmatch(cleaner,fmt)](n), diff --git a/tex/context/base/meta-tex.mkiv b/tex/context/base/meta-tex.mkiv index 6ba75f355..0f5a27ff8 100644 --- a/tex/context/base/meta-tex.mkiv +++ b/tex/context/base/meta-tex.mkiv @@ -76,7 +76,7 @@ \def\sometxt#1#{\meta_some_txt{#1}} \def\meta_some_txt#1#2% we need to capture embedded quotes (a bit messy as later on textext is filtered - {textext.drt("\mpsometxt#1{\ctxlua{metapost.escaped(\!!bs#2\!!es)}}")} + {textext.drt("\mpsometxt#1{\clf_metapostescaped{#2}}")} \unexpanded\def\mpsometxt % no _ catcode {\doifelsenextoptionalcs\meta_some_txt_indeed_yes\meta_some_txt_indeed_nop} @@ -139,7 +139,7 @@ % {\showstruts\useMPgraphic{testgraphic}} \unexpanded\def\MPexponent #1#2{\mathematics{#1\times10^{#2}}} -\unexpanded\def\MPformatted #1#2{\ctxlua{metapost.svformat("#1","#2")}} -\unexpanded\def\MPgraphformat#1#2{\ctxlua{metapost.nvformat("#1","#2")}} +\unexpanded\def\MPformatted #1#2{\clf_metapostformatted{#1}{#2}} +\unexpanded\def\MPgraphformat#1#2{\clf_metapostgraphformat{#1}{#2}} \protect \endinput diff --git a/tex/context/base/mlib-ctx.lua b/tex/context/base/mlib-ctx.lua index f259113f4..b437e1212 100644 --- a/tex/context/base/mlib-ctx.lua +++ b/tex/context/base/mlib-ctx.lua @@ -201,7 +201,7 @@ end implement { name = "mpgraphic", - actions = function(specification) metapost.graphic_base_pass(setmpsformat(specification)) end, -- not yet implemented + actions = metapost.graphic, arguments = { { { "instance" }, diff --git a/tex/context/base/mlib-ctx.mkiv b/tex/context/base/mlib-ctx.mkiv index e4c1cb6fe..a7bb612c8 100644 --- a/tex/context/base/mlib-ctx.mkiv +++ b/tex/context/base/mlib-ctx.mkiv @@ -19,6 +19,7 @@ \registerctxluafile{mlib-run}{1.001} \registerctxluafile{mlib-ctx}{1.001} \registerctxluafile{mlib-lua}{1.001} +\registerctxluafile{mlib-int}{1.001} % here ? \unprotect diff --git a/tex/context/base/mlib-int.lua b/tex/context/base/mlib-int.lua new file mode 100644 index 000000000..d355f0bfe --- /dev/null +++ b/tex/context/base/mlib-int.lua @@ -0,0 +1,147 @@ +if not modules then modules = { } end modules ['mlib-int'] = { + version = 1.001, + comment = "companion to mlib-ctx.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files", +} + +local factor = number.dimenfactors.bp +local mpprint = mp.print +local mpboolean = mp.boolean +local mpquoted = mp.quoted +local getdimen = tex.getdimen +local getcount = tex.getcount +local get = tex.get +local mpcolor = attributes.colors.mpcolor +local emwidths = fonts.hashes.emwidths +local exheights = fonts.hashes.exheights + +function mp.PaperHeight () mpprint(getdimen("paperheight") *factor) end +function mp.PaperWidth () mpprint(getdimen("paperwidth") *factor) end +function mp.PrintPaperHeight () mpprint(getdimen("printpaperheight") *factor) end +function mp.PrintPaperWidth () mpprint(getdimen("printpaperwidth") *factor) end +function mp.TopSpace () mpprint(getdimen("topspace") *factor) end +function mp.BottomSpace () mpprint(getdimen("bottomspace") *factor) end +function mp.BackSpace () mpprint(getdimen("backspace") *factor) end +function mp.CutSpace () mpprint(getdimen("cutspace") *factor) end +function mp.MakeupHeight () mpprint(getdimen("makeupheight") *factor) end +function mp.MakeupWidth () mpprint(getdimen("makeupwidth") *factor) end +function mp.TopHeight () mpprint(getdimen("topheight") *factor) end +function mp.TopDistance () mpprint(getdimen("topdistance") *factor) end +function mp.HeaderHeight () mpprint(getdimen("headerheight") *factor) end +function mp.HeaderDistance () mpprint(getdimen("headerdistance") *factor) end +function mp.TextHeight () mpprint(getdimen("textheight") *factor) end +function mp.FooterDistance () mpprint(getdimen("footerdistance") *factor) end +function mp.FooterHeight () mpprint(getdimen("footerheight") *factor) end +function mp.BottomDistance () mpprint(getdimen("bottomdistance") *factor) end +function mp.BottomHeight () mpprint(getdimen("bottomheight") *factor) end +function mp.LeftEdgeWidth () mpprint(getdimen("leftedgewidth") *factor) end +function mp.LeftEdgeDistance () mpprint(getdimen("leftedgedistance") *factor) end +function mp.LeftMarginWidth () mpprint(getdimen("leftmarginwidth") *factor) end +function mp.LeftMarginDistance () mpprint(getdimen("leftmargindistance") *factor) end +function mp.TextWidth () mpprint(getdimen("textwidth") *factor) end +function mp.RightMarginDistance () mpprint(getdimen("rightmargindistance") *factor) end +function mp.RightMarginWidth () mpprint(getdimen("rightmarginwidth") *factor) end +function mp.RightEdgeDistance () mpprint(getdimen("rightedgedistance") *factor) end +function mp.RightEdgeWidth () mpprint(getdimen("rightedgewidth") *factor) end +function mp.InnerMarginDistance () mpprint(getdimen("innermargindistance") *factor) end +function mp.InnerMarginWidth () mpprint(getdimen("innermarginwidth") *factor) end +function mp.OuterMarginDistance () mpprint(getdimen("outermargindistance") *factor) end +function mp.OuterMarginWidth () mpprint(getdimen("outermarginwidth") *factor) end +function mp.InnerEdgeDistance () mpprint(getdimen("inneredgedistance") *factor) end +function mp.InnerEdgeWidth () mpprint(getdimen("inneredgewidth") *factor) end +function mp.OuterEdgeDistance () mpprint(getdimen("outeredgedistance") *factor) end +function mp.OuterEdgeWidth () mpprint(getdimen("outeredgewidth") *factor) end +function mp.PageOffset () mpprint(getdimen("pagebackgroundoffset")*factor) end +function mp.PageDepth () mpprint(getdimen("pagebackgrounddepth") *factor) end +function mp.LayoutColumns () mpprint(getcount("layoutcolumns")) end +function mp.LayoutColumnDistance() mpprint(getdimen("layoutcolumndistance")*factor) end +function mp.LayoutColumnWidth () mpprint(getdimen("layoutcolumnwidth") *factor) end + +function mp.PageNumber () mpprint(getcount("pageno")) end +function mp.RealPageNumber () mpprint(getcount("realpageno")) end +function mp.NOfPages () mpprint(getcount("lastpageno")) end + +function mp.CurrentColumn () mpprint(getcount("mofcolumns")) end +function mp.NOfColumns () mpprint(getcount("nofcolumns")) end + +function mp.BaseLineSkip () mpprint(getdimen("baselineskip") *factor) end +function mp.LineHeight () mpprint(getdimen("lineheight") *factor) end +function mp.BodyFontSize () mpprint(getdimen("bodyfontsize") *factor) end + +function mp.TopSkip () mpprint(getdimen("topskip") *factor) end +function mp.StrutHeight () mpprint(getdimen("strutht") *factor) end +function mp.StrutDepth () mpprint(getdimen("strutdp") *factor) end + +function mp.PageNumber () mpprint(getcount("pageno")) end +function mp.RealPageNumber () mpprint(getcount("realpageno")) end +function mp.NOfPages () mpprint(getcount("lastpageno")) end + +function mp.CurrentWidth () mpprint(get("hsize") *factor) end +function mp.CurrentHeight () mpprint(get("vsize") *factor) end + +function mp.EmWidth () mpprint(emwidths [false]*factor) end +function mp.ExHeight () mpprint(exheights[false]*factor) end + +mp.HSize = mp.CurrentWidth +mp.VSize = mp.CurrentHeight +mp.LastPageNumber = mp.NOfPages + +function mp.PageFraction () + local lastpage = getcount("lastpageno") + if lastpage > 1 then + mpprint((getcount("realpageno")-1)/(lastpage-1)) + else + mpprint(1) + end +end + +-- locals + +mp.OnRightPage = function() mpprint(structures.pages.on_right()) end -- needs checking +mp.OnOddPage = function() mpprint(structures.pages.is_odd ()) end -- needs checking +mp.InPageBody = function() mpprint(structures.pages.in_body ()) end -- needs checking + +-- mp.CurrentLayout : \currentlayout + +function mp.OverlayWidth () mpprint(getdimen("d_overlay_width") *factor) end +function mp.OverlayHeight () mpprint(getdimen("d_overlay_height") *factor) end +function mp.OverlayDepth () mpprint(getdimen("d_overlay_depth") *factor) end +function mp.OverlayLineWidth () mpprint(getdimen("d_overlay_linewidth")*factor) end +function mp.OverlayOffset () mpprint(getdimen("d_overlay_offset") *factor) end + +function mp.defaultcolormodel() + local colormethod = getcount("MPcolormethod") + -- if colormethod == 0 then + -- return 1 + -- elseif colormethod == 1 then + -- return 1 + -- elseif colormethod == 2 then + -- return 3 + -- else + -- return 3 + -- end + return (colormethod == 0 or colormethod == 1) and 1 or 3 +end + +-- not much difference (10000 calls in a graphic neither as expansion seems to win +-- over defining the macro etc) so let's not waste counters then + +-- function mp.OverlayColor() +-- local c = mpcolor( +-- getcount("c_overlay_colormodel"), +-- getcount("c_overlay_color"), +-- getcount("c_overlay_transparency") +-- ) +-- mpquoted(c) +-- end +-- +-- function mp.OverlayLineColor() +-- local c = mpcolor( +-- getcount("c_overlay_colormodel"), +-- getcount("c_overlay_linecolor"), +-- getcount("c_overlay_linetransparency") +-- ) +-- mpquoted(c) +-- end diff --git a/tex/context/base/mlib-lua.lua b/tex/context/base/mlib-lua.lua index d4af70a58..7d95e1b37 100644 --- a/tex/context/base/mlib-lua.lua +++ b/tex/context/base/mlib-lua.lua @@ -1,4 +1,4 @@ -if not modules then modules = { } end modules ['mlib-pdf'] = { +if not modules then modules = { } end modules ['mlib-lua'] = { version = 1.001, comment = "companion to mlib-ctx.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", @@ -68,7 +68,7 @@ local f_quadruple = formatters["(%.16f,%.16f,%.16f,%.16f)"] function mp.print(...) for i=1,select("#",...) do local value = select(i,...) - if value then + if value ~= nil then n = n + 1 local t = type(value) if t == "number" then @@ -84,6 +84,11 @@ function mp.print(...) end end +function mp.boolean(n) + n = n + 1 + buffer[n] = n and "true" or "false" +end + function mp.numeric(n) n = n + 1 buffer[n] = n and f_numeric(n) or "0" diff --git a/tex/context/base/mlib-pps.lua b/tex/context/base/mlib-pps.lua index 4006f9f1e..31dbaf2da 100644 --- a/tex/context/base/mlib-pps.lua +++ b/tex/context/base/mlib-pps.lua @@ -729,6 +729,12 @@ function makempy.registerfile(filename) mpyfilename = filename end +implement { + name = "registermpyfile", + actions = makempy.registerfile, + arguments = "string" +} + function makempy.processgraphics(graphics) if #graphics == 0 then return diff --git a/tex/context/base/mlib-run.lua b/tex/context/base/mlib-run.lua index ef4db6941..5b4301f9b 100644 --- a/tex/context/base/mlib-run.lua +++ b/tex/context/base/mlib-run.lua @@ -315,7 +315,8 @@ function metapost.reset(mpx) end end -local mp_inp, mp_log, mp_tag = { }, { }, 0 +local mp_tra = { } +local mp_tag = 0 -- key/values @@ -329,19 +330,24 @@ function metapost.process(mpx, data, trialrun, flusher, multipass, isextrapass, mpx = metapost.format(mpx) -- goody end if mpx and data then + local tra = nil starttiming(metapost) metapost.initializescriptrunner(mpx,trialrun) if trace_graphics then - if not mp_inp[mpx] then + tra = mp_tra[mpx] + if not tra then mp_tag = mp_tag + 1 local jobname = tex.jobname - mp_inp[mpx] = io.open(formatters["%s-mplib-run-%03i.mp"] (jobname,mp_tag,"w")) - mp_log[mpx] = io.open(formatters["%s-mplib-run-%03i.log"](jobname,mp_tag,"w")) + tra = { + inp = io.open(formatters["%s-mplib-run-%03i.mp"] (jobname,mp_tag),"w"), + log = io.open(formatters["%s-mplib-run-%03i.log"](jobname,mp_tag),"w"), + } + mp_tra[mpx] = tra end local banner = formatters["%% begin graphic: n=%s, trialrun=%s, multipass=%s, isextrapass=%s\n\n"]( metapost.n, tostring(trialrun), tostring(multipass), tostring(isextrapass)) - mp_inp[mpx]:write(banner) - mp_log[mpx]:write(banner) + tra.inp:write(banner) + tra.log:write(banner) end if type(data) == "table" then -- this hack is needed because the library currently barks on \n\n @@ -378,9 +384,9 @@ function metapost.process(mpx, data, trialrun, flusher, multipass, isextrapass, -- d = string.gsub(d,"\r","") if d then if trace_graphics then - mp_inp[mpx]:write(formatters["\n%% begin snippet %s\n"](i)) - mp_inp[mpx]:write(d) - mp_inp[mpx]:write(formatters["\n%% end snippet %s\n"](i)) + tra.inp:write(formatters["\n%% begin snippet %s\n"](i)) + tra.inp:write(d) + tra.inp:write(formatters["\n%% end snippet %s\n"](i)) end starttiming(metapost.exectime) result = mpx:execute(d) @@ -388,7 +394,7 @@ function metapost.process(mpx, data, trialrun, flusher, multipass, isextrapass, if trace_graphics and result then local str = result.log or result.error if str and str ~= "" then - mp_log[mpx]:write(str) + tra.log:write(str) end end if not metapost.reporterror(result) then @@ -412,7 +418,7 @@ function metapost.process(mpx, data, trialrun, flusher, multipass, isextrapass, data = "tracingall;" .. data end if trace_graphics then - mp_inp[mpx]:write(data) + tra.inp:write(data) end starttiming(metapost.exectime) result = mpx:execute(data) @@ -420,7 +426,7 @@ function metapost.process(mpx, data, trialrun, flusher, multipass, isextrapass, if trace_graphics and result then local str = result.log or result.error if str and str ~= "" then - mp_log[mpx]:write(str) + tra.log:write(str) end end -- todo: error message @@ -440,8 +446,8 @@ function metapost.process(mpx, data, trialrun, flusher, multipass, isextrapass, end if trace_graphics then local banner = "\n% end graphic\n\n" - mp_inp[mpx]:write(banner) - mp_log[mpx]:write(banner) + tra.inp:write(banner) + tra.log:write(banner) end stoptiming(metapost) end diff --git a/tex/context/base/mult-chk.lua b/tex/context/base/mult-chk.lua index 2a2dfcd4b..44a9f739f 100644 --- a/tex/context/base/mult-chk.lua +++ b/tex/context/base/mult-chk.lua @@ -16,7 +16,8 @@ local allocate = utilities.storage.allocate local report_interface = logs.reporter("interface","checking") -interfaces = interfaces or { } +local interfaces = interfaces +local implement = interfaces.implement interfaces.syntax = allocate { test = { keys = table.tohash { "a","b","c","d","e","f","g" } } @@ -48,6 +49,18 @@ function interfaces.addvalidkeys(category,list) end end +implement { + name = "setvalidinterfacekeys", + actions = interfaces.setvalidkeys, + arguments = { "string", "string" } +} + +implement { + name = "addvalidinterfacekeys", + actions = interfaces.addvalidkeys, + arguments = { "string", "string" } +} + -- weird code, looks incomplete ... probably an experiment local prefix, category, keys @@ -73,4 +86,8 @@ function interfaces.getcheckedparameters(k,p,s) end end --- _igcp_ = interfaces.getcheckedparameters +implement { + name = "getcheckedinterfaceparameters", + actions = interfaces.getcheckedparameters, + arguments = { "string", "string", "string" } +} diff --git a/tex/context/base/mult-chk.mkiv b/tex/context/base/mult-chk.mkiv index 1d02f166d..9208a73e1 100644 --- a/tex/context/base/mult-chk.mkiv +++ b/tex/context/base/mult-chk.mkiv @@ -38,8 +38,8 @@ \unexpanded\def\setvalidparameterkeys{\dodoubleargument\mult_checkers_set_valid_parameter_keys} \unexpanded\def\addvalidparameterkeys{\dodoubleargument\mult_checkers_add_valid_parameter_keys} -\def\mult_checkers_set_valid_parameter_keys[#1][#2]{\ctxlua{interfaces.setvalidkeys("#1",\!!bs#2\!!es)}} -\def\mult_checkers_add_valid_parameter_keys[#1][#2]{\ctxlua{interfaces.addvalidkeys("#1",\!!bs#2\!!es)}} +\def\mult_checkers_set_valid_parameter_keys[#1][#2]{\clf_setvalidinterfacekeys{#1}{#2}} +\def\mult_checkers_add_valid_parameter_keys[#1][#2]{\clf_addvalidinterfacekeys{#1}{#2}} \def\mult_checkers_get_checked_parameters_yes[#1]#2[#3]#4[#5% {\if\noexpand#5]% @@ -50,8 +50,7 @@ \fi{#1}{#3}#5} \def\mult_checkers_get_checked_parameters_yes_indeed#1#2#3]% - %{\ctxlua{_igcp_("#1","#2",\!!bs\detokenize{#3}\!!es)}} - {\ctxlua{interfaces.getcheckedparameters("#1","#2",\!!bs\detokenize{#3}\!!es)}} + {\clf_getcheckedinterfaceparameters{#1}{#2}{\detokenize{#3}}} \def\mult_checkers_get_checked_parameters_nop[#1]#2[#3]#4[#5% {\if\noexpand#5]% diff --git a/tex/context/base/mult-def.mkiv b/tex/context/base/mult-def.mkiv index 438df2308..6efeb3069 100644 --- a/tex/context/base/mult-def.mkiv +++ b/tex/context/base/mult-def.mkiv @@ -30,7 +30,7 @@ % \input mult-\userinterfacetag \relax % \input mult-m\userresponsestag \relax -\ctxlua{interfaces.setuserinterface("\userinterfacetag","\userresponsestag")} +\clf_setuserinterface{\userinterfacetag}{\userresponsestag} % start todo in mult-def.lua: diff --git a/tex/context/base/mult-ini.lua b/tex/context/base/mult-ini.lua index 17b92de28..bd3b1d38b 100644 --- a/tex/context/base/mult-ini.lua +++ b/tex/context/base/mult-ini.lua @@ -241,9 +241,17 @@ function interfaces.setuserinterface(interface,response) end report_interface("definitions: %a constants, %a variables, %a elements, %a commands, %a formats, %a translations", nofconstants,nofvariables,nofelements,nofcommands,nofformats,noftranslations) + else + report_interface("the language(s) can only be set when making the format") end end +interfaces.implement { + name = "setuserinterface", + actions = interfaces.setuserinterface, + arguments = { "string", "string" } +} + interfaces.cachedsetups = interfaces.cachedsetups or { } interfaces.hashedsetups = interfaces.hashedsetups or { } diff --git a/tex/context/base/node-aux.lua b/tex/context/base/node-aux.lua index f705e4774..12da8ea8a 100644 --- a/tex/context/base/node-aux.lua +++ b/tex/context/base/node-aux.lua @@ -314,13 +314,17 @@ nuts .firstcharinbox = firstcharinbox nodes.firstcharinbox = firstcharinbox nodes.firstcharacter = vianuts(firstcharacter) -function commands.buildtextaccent(n) -- Is this crap really used? Or was it an experiment? - local char = firstcharinbox(n) - if char > 0 then - -- context.accent(false,char) - context([[\accent%s\relax]],char) +interfaces.implement { + name = "buildtextaccent", + arguments = "integer", + actions = function(n) -- Is this crap really used? Or was it an experiment? + local char = firstcharinbox(n) + if char > 0 then + -- context.accent(false,char) + context([[\accent%s\relax]],char) + end end -end +} -- this depends on fonts, so we have a funny dependency ... will be -- sorted out .. we could make tonodes a plugin into this diff --git a/tex/context/base/node-bck.lua b/tex/context/base/node-bck.lua index 4e78e720a..99992de09 100644 --- a/tex/context/base/node-bck.lua +++ b/tex/context/base/node-bck.lua @@ -183,14 +183,14 @@ nodes.handlers.alignbackgrounds = function(head) local head, done = add_alignbac interfaces.implement { name = "enablebackgroundboxes", - once = true, + onlyonce = true, actions = nodes.tasks.enableaction, arguments = { "'shipouts'", "'nodes.handlers.backgrounds'" } } interfaces.implement { name = "enablebackgroundalign", - once = true, + onlyonce = true, actions = nodes.tasks.enableaction, arguments = { "'shipouts'", "'nodes.handlers.alignbackgrounds'" } } diff --git a/tex/context/base/node-ref.lua b/tex/context/base/node-ref.lua index fc3043516..f4c9866f5 100644 --- a/tex/context/base/node-ref.lua +++ b/tex/context/base/node-ref.lua @@ -744,4 +744,11 @@ end) function references.enableinteraction() tasks.enableaction("shipouts","nodes.references.handler") tasks.enableaction("shipouts","nodes.destinations.handler") + function references.enableinteraction() end end + +implement { + name = "enableinteraction", + actions = references.enableinteraction, + onlyonce = true +} diff --git a/tex/context/base/node-rul.lua b/tex/context/base/node-rul.lua index 736b67a7f..36d56a16c 100644 --- a/tex/context/base/node-rul.lua +++ b/tex/context/base/node-rul.lua @@ -450,9 +450,9 @@ implement { } implement { - name = "enablerules", - once = true, - actions = nodes.rules.enable + name = "enablerules", + onlyonce = true, + actions = nodes.rules.enable } implement { @@ -469,7 +469,7 @@ implement { } implement { - name = "enableshifts", - once = true, - actions = nodes.shifts.enable + name = "enableshifts", + onlyonce = true, + actions = nodes.shifts.enable } diff --git a/tex/context/base/node-tra.lua b/tex/context/base/node-tra.lua index 4d5ae5aca..a7ab7f77f 100644 --- a/tex/context/base/node-tra.lua +++ b/tex/context/base/node-tra.lua @@ -568,7 +568,7 @@ local points = function(n) elseif type(n) == "number" then return lpegmatch(stripper,format("%.5fpt",n*ptfactor)) -- faster than formatter else - return numbertodimen(n,"pt",true,true) -- also deals with nodes + return numbertodimen(n,"pt") -- also deals with nodes end end @@ -578,7 +578,7 @@ local basepoints = function(n) elseif type(n) == "number" then return lpegmatch(stripper,format("%.5fbp",n*bpfactor)) -- faster than formatter else - return numbertodimen(n,"bp",true,true) -- also deals with nodes + return numbertodimen(n,"bp") -- also deals with nodes end end @@ -588,7 +588,7 @@ local pts = function(n) elseif type(n) == "number" then return format("%.5fpt",n*ptfactor) -- faster than formatter else - return numbertodimen(n,"pt",true) -- also deals with nodes + return numbertodimen(n,"pt") -- also deals with nodes end end @@ -605,10 +605,10 @@ number.basepoints = basepoints number.pts = pts number.nopts = nopts -nodes.points = function(n) return numbertodimen(n,"pt",true,true) end -nodes.basepoints = function(n) return numbertodimen(n,"bp",true,true) end -nodes.pts = function(n) return numbertodimen(n,"pt",true) end -nodes.nopts = function(n) return format("%.5f",n*ptfactor) end +nodes.points = function(n) return numbertodimen(n,"pt") end +nodes.basepoints = function(n) return numbertodimen(n,"bp") end +nodes.pts = function(n) return numbertodimen(n,"pt") end +nodes.nopts = function(n) return format("%.5f",n*ptfactor) end local colors = { } tracers.colors = colors diff --git a/tex/context/base/pack-box.mkiv b/tex/context/base/pack-box.mkiv index ef299f51d..3fb56d799 100644 --- a/tex/context/base/pack-box.mkiv +++ b/tex/context/base/pack-box.mkiv @@ -24,10 +24,10 @@ %D which in itself is ok, but can lead to loops due to rounding errors (happened %D in demo-obv). -\definelayer[\v!text-2][\c!position=\v!yes,\c!region=,\c!width=\overlaywidth,\c!height=\overlayheight] -\definelayer[\v!text-1][\c!position=\v!yes,\c!region=,\c!width=\overlaywidth,\c!height=\overlayheight] -\definelayer[\v!text+1][\c!position=\v!yes,\c!region=,\c!width=\overlaywidth,\c!height=\overlayheight] -\definelayer[\v!text+2][\c!position=\v!yes,\c!region=,\c!width=\overlaywidth,\c!height=\overlayheight] +\definelayer[\v!text-2][\c!position=\v!yes,\c!region=,\c!width=\d_overlay_width,\c!height=\d_overlay_height] +\definelayer[\v!text-1][\c!position=\v!yes,\c!region=,\c!width=\d_overlay_width,\c!height=\d_overlay_height] +\definelayer[\v!text+1][\c!position=\v!yes,\c!region=,\c!width=\d_overlay_width,\c!height=\d_overlay_height] +\definelayer[\v!text+2][\c!position=\v!yes,\c!region=,\c!width=\d_overlay_width,\c!height=\d_overlay_height] \unexpanded\def\internaltextoverlay#1% will become more generic and installable {\startoverlay % i.e. probably an overlay by itself diff --git a/tex/context/base/pack-fen.mkiv b/tex/context/base/pack-fen.mkiv index 4253eeaa7..04a36fa46 100644 --- a/tex/context/base/pack-fen.mkiv +++ b/tex/context/base/pack-fen.mkiv @@ -50,12 +50,12 @@ \else \def\setinstalledframedimensions - {\edef\overlaywidth {\the\frameddimenwd\space}% - \edef\overlayheight {\the\dimexpr\frameddimenht+\frameddimendp\relax\space}% - \edef\overlaydepth {\the\frameddimendp\space}% + {\d_overlay_width \frameddimenwd + \d_overlay_height \dimexpr\frameddimenht+\frameddimendp\relax + \d_overlay_depth \frameddimendp + \d_overlay_linewidth \ruledlinewidth \edef\overlaycolor {\framedparameter\c!backgroundcolor}% - \edef\overlaylinecolor{\framedparameter\c!framecolor}% - \edef\overlaylinewidth{\the\ruledlinewidth}} + \edef\overlaylinecolor{\framedparameter\c!framecolor}} \fi @@ -63,7 +63,7 @@ \def\whateverleftframe#1% {\setinstalledframedimensions - \setbox\b_framed_rendered\vbox to \overlayheight{\vss#1\vss}% + \setbox\b_framed_rendered\vbox to \d_overlay_height{\vss#1\vss}% \setbox\b_framed_rendered\hbox to \zeropoint{\box\b_framed_rendered\hss}% \ht\b_framed_rendered\zeropoint \dp\b_framed_rendered\zeropoint @@ -71,7 +71,7 @@ \def\whateverrightframe#1% {\setinstalledframedimensions - \setbox\b_framed_rendered\vbox to \overlayheight{\vss#1\vss}% + \setbox\b_framed_rendered\vbox to \d_overlay_height{\vss#1\vss}% \setbox\b_framed_rendered\hbox to \zeropoint{\hss\box\b_framed_rendered}% \ht\b_framed_rendered\zeropoint \dp\b_framed_rendered\zeropoint @@ -79,7 +79,7 @@ \def\whatevertopframe#1% {\setinstalledframedimensions - \setbox\b_framed_rendered\hbox to \overlaywidth{\hss#1\hss}% + \setbox\b_framed_rendered\hbox to \d_overlay_width{\hss#1\hss}% \setbox\b_framed_rendered\vbox to \zeropoint{\box\b_framed_rendered\vss}% \ht\b_framed_rendered\zeropoint \dp\b_framed_rendered\zeropoint @@ -88,7 +88,7 @@ \def\whateverbottomframe#1% {\setinstalledframedimensions - \setbox\b_framed_rendered\hbox to \overlaywidth{\hss#1\hss}% + \setbox\b_framed_rendered\hbox to \d_overlay_width{\hss#1\hss}% \setbox\b_framed_rendered\vbox to \zeropoint{\vss\box\b_framed_rendered}% \ht\b_framed_rendered\zeropoint \dp\b_framed_rendered\zeropoint diff --git a/tex/context/base/pack-lyr.mkiv b/tex/context/base/pack-lyr.mkiv index 45113f286..a274a8d23 100644 --- a/tex/context/base/pack-lyr.mkiv +++ b/tex/context/base/pack-lyr.mkiv @@ -609,7 +609,7 @@ % {\setlayoutcomponentattribute{\v!layer:#2}}% % \resetlayoutcomponentattribute % \ifx\p_pack_layers_option\v!test \ruledvbox \else \vbox \fi \ifx\p_pack_layers_method\v!overlay to \overlayheight \fi \layoutcomponentboxattribute -% {\hbox \ifx\p_pack_layers_method\v!overlay to \overlaywidth \fi +% {\hbox \ifx\p_pack_layers_method\v!overlay to \d_overlay_width \fi % {\edef\currentlayer{#2\the\realpageno}% local % \edef\p_pack_layers_position{\layerparameter\c!position}% local % \ifx\p_pack_layers_position\v!yes @@ -676,7 +676,7 @@ \setbox\nextbox \ifx\p_pack_layers_option\v!test \ruledvbox \else \vbox \fi \ifx\p_pack_layers_method\v!overlay to \overlayheight \fi \layoutcomponentboxattribute {\pack_layers_top_fill - \hbox \ifx\p_pack_layers_method\v!overlay to \overlaywidth \fi + \hbox \ifx\p_pack_layers_method\v!overlay to \d_overlay_width \fi {\box\nextbox \hss}% \pack_layers_bottom_fill}% @@ -726,9 +726,9 @@ \unexpanded\def\tightlayer[#1]% {\hbox {\def\currentlayer{#1}% todo: left/right - \setbox\nextbox\emptybox % hoogte/breedte are \wd\nextbox/\ht\nextbox - \hsize\layerparameter\c!width % \overlaywidth = \hsize - \vsize\layerparameter\c!height % \overlaywheight = \vsize + \setbox\nextbox\emptybox + \hsize\layerparameter\c!width + \vsize\layerparameter\c!height \composedlayer{#1}}} \let\placelayer\flushlayer diff --git a/tex/context/base/pack-rul.mkiv b/tex/context/base/pack-rul.mkiv index 7fde68c8d..f2979a5e1 100644 --- a/tex/context/base/pack-rul.mkiv +++ b/tex/context/base/pack-rul.mkiv @@ -429,14 +429,26 @@ %D %D The resulting box is lowered to the right depth. -\def\overlaywidth {\the\hsize\space} % We preset the variables -\def\overlayheight {\the\vsize\space} % to some reasonable default -\def\overlaydepth {0pt } % values. The attributes -\let\overlayoffset \overlaydepth % of the frame can be (are) -\let\overlaylinewidth \overlaydepth % set somewhere else. +%def\overlaywidth {\the\hsize\space} % We preset the variables +%def\overlayheight {\the\vsize\space} % to some reasonable default +%def\overlaydepth {0pt } % values. The attributes +%let\overlayoffset \overlaydepth % of the frame can be (are) +%let\overlaylinewidth \overlaydepth % set somewhere else. \let\overlaycolor \empty \let\overlaylinecolor \empty +\newdimen\d_overlay_width +\newdimen\d_overlay_height +\newdimen\d_overlay_depth +\newdimen\d_overlay_offset +\newdimen\d_overlay_linewidth + +\def\overlaywidth {\the\d_overlay_width \space} % We preset the variables +\def\overlayheight {\the\d_overlay_height \space} % to some reasonable default +\def\overlaydepth {\the\d_overlay_depth \space} % values. +\def\overlayoffset {\the\d_overlay_offset \space} % of the frame can be (are) +\def\overlaylinewidth {\the\d_overlay_linewidth\space} % set somewhere else. + %D The next register is used to initialize overlays. \newtoks\everyoverlay @@ -452,8 +464,8 @@ \to \everyoverlay \prependtoks - \hsize\overlaywidth - \vsize\overlayheight + \hsize\d_overlay_width + \vsize\d_overlay_height \to \everyoverlay \unexpanded\def\defineoverlay @@ -475,8 +487,8 @@ \egroup \setlayoutcomponentattribute{\v!overlay:#1}% \setbox\scratchbox\hbox \layoutcomponentboxattribute - {\kern -.5\dimexpr\wd\scratchbox-\d_framed_target_wd\relax % was \overlaywidth - \raise-.5\dimexpr\ht\scratchbox-\d_framed_target_ht\relax % not \overlayheight ! + {\kern -.5\dimexpr\wd\scratchbox-\d_framed_target_wd\relax % was \d_overlay_width + \raise-.5\dimexpr\ht\scratchbox-\d_framed_target_ht\relax % not \d_overlay_height ! \box\scratchbox}% \wd\scratchbox\d_framed_target_wd \ht\scratchbox\d_framed_target_ht @@ -490,8 +502,8 @@ \unexpanded\def\overlayfakebox {\hbox {\setbox\scratchbox\emptyhbox - \wd\scratchbox\overlaywidth - \ht\scratchbox\overlayheight + \wd\scratchbox\d_overlay_width + \ht\scratchbox\d_overlay_height \box\scratchbox}} %D For testing we provide: @@ -601,16 +613,28 @@ \hss \egroup}} +% \def\pack_framed_overlay_initialize_indeed +% {\edef\overlaywidth {\the\d_framed_target_wd\space}% +% \edef\overlayheight {\the\dimexpr\d_framed_target_ht+\d_framed_target_dp\relax\space}% +% \edef\overlaydepth {\the\d_framed_target_dp\space}% +% \edef\overlaycolor {\framedparameter\c!backgroundcolor}% let ? +% \edef\overlaylinecolor{\framedparameter\c!framecolor}% only needed for layers +% \edef\overlaylinewidth{\the\d_framed_linewidth\space}% +% %\edef\overlaycorner {\framedparameter\c!backgroundcorner}% +% %\edef\overlayradius {\framedparameter\c!backgroundradius}% +% \edef\overlayoffset {\the\framedbackgroundoffset\space}% \backgroundoffset % we steal this one +% \let\pack_framed_overlay_initialize\relax} + \def\pack_framed_overlay_initialize_indeed - {\edef\overlaywidth {\the\d_framed_target_wd\space}% - \edef\overlayheight {\the\dimexpr\d_framed_target_ht+\d_framed_target_dp\relax\space}% - \edef\overlaydepth {\the\d_framed_target_dp\space}% + {\d_overlay_width \d_framed_target_wd + \d_overlay_height \dimexpr\d_framed_target_ht+\d_framed_target_dp\relax + \d_overlay_depth \d_framed_target_dp + \d_overlay_linewidth \d_framed_linewidth + \d_overlay_offset \framedbackgroundoffset\relax \edef\overlaycolor {\framedparameter\c!backgroundcolor}% let ? \edef\overlaylinecolor{\framedparameter\c!framecolor}% only needed for layers - \edef\overlaylinewidth{\the\d_framed_linewidth\space}% %\edef\overlaycorner {\framedparameter\c!backgroundcorner}% %\edef\overlayradius {\framedparameter\c!backgroundradius}% - \edef\overlayoffset {\the\framedbackgroundoffset\space}% \backgroundoffset % we steal this one \let\pack_framed_overlay_initialize\relax} %D One can explictly insert the foreground box. For that purpose we introduce the diff --git a/tex/context/base/page-ini.mkiv b/tex/context/base/page-ini.mkiv index 1f3ea74ae..15783a99b 100644 --- a/tex/context/base/page-ini.mkiv +++ b/tex/context/base/page-ini.mkiv @@ -102,6 +102,7 @@ \page_otr_check_for_pending_inserts % but does not hurt either (we're still in the otr!) \inpagebodytrue % needed for enabling \blank ! brrr + \pagebodymode\plusone % todo: \plustwo when spread \page_otr_command_flush_saved_floats \page_otr_command_set_vsize % this is needed for interacting components, like floats and multicolumns \strc_pagenumbers_increment_counters % should hook into an every diff --git a/tex/context/base/page-ins.lua b/tex/context/base/page-ins.lua index 7f870735d..235f586c6 100644 --- a/tex/context/base/page-ins.lua +++ b/tex/context/base/page-ins.lua @@ -4,19 +4,9 @@ if not modules then modules = { } end modules ['page-ins'] = { author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files", - -- public = { - -- functions = { - -- "inserts.define", - -- "inserts.getdata", - -- }, - -- commands = { - -- "defineinsertion", - -- "inserttionnumber", - -- } - -- } } --- Maybe we should only register in lua and forget about the tex end. +local next = next structures = structures or { } structures.inserts = structures.inserts or { } @@ -36,6 +26,9 @@ local v_firstcolumn = variables.firstcolumn local v_lastcolumn = variables.lastcolumn local v_text = variables.text +local context = context +local implement = interfaces.implement + storage.register("structures/inserts/stored", inserts.stored, "structures.inserts.stored") local data = inserts.data @@ -49,7 +42,7 @@ end function inserts.define(name,specification) specification.name= name local number = specification.number or 0 - data[name] = specification + data[name] = specification data[number] = specification -- only needed at runtime as this get stored in a bytecode register stored[name] = specification @@ -90,8 +83,37 @@ end -- interface -commands.defineinsertion = inserts.define -commands.setupinsertion = inserts.setup -commands.setinsertionlocation = inserts.setlocation -commands.insertionnumber = function(name) context(data[name].number or 0) end +implement { + name = "defineinsertion", + actions = inserts.define, + arguments = { + "string", + { + { "number", "integer" } + } + } +} + +implement { + name = "setupinsertion", + actions = inserts.setup, + arguments = { + "string", + { + { "location" } + } + } +} + +implement { + name = "setinsertionlocation", + actions = inserts.setlocation, + arguments = { "string", "string" } +} + +implement { + name = "insertionnumber", + actions = function(name) context(data[name].number or 0) end, + arguments = "string" +} diff --git a/tex/context/base/page-ins.mkiv b/tex/context/base/page-ins.mkiv index 5845f9930..c91073a14 100644 --- a/tex/context/base/page-ins.mkiv +++ b/tex/context/base/page-ins.mkiv @@ -110,7 +110,12 @@ \else \expandafter\newinsert\csname\??insertionnumber\currentinsertion\endcsname \page_inserts_synchronize_registers - \ctxcommand{defineinsertion("\currentinsertion",{ number = \number\currentinsertionnumber })}% + \clf_defineinsertion + {\currentinsertion}% + {% + number \currentinsertionnumber + }% + \relax \t_page_inserts_list\expandafter\expandafter\expandafter {\expandafter\the\expandafter\t_page_inserts_list \expandafter\page_inserts_process\csname\??insertionnumber\currentinsertion\endcsname}% @@ -125,13 +130,16 @@ \to \everydefineinsertion \appendtoks - \ctxcommand{setupinsertion("\currentinsertion",{ - location = "\insertionparameter\c!location", - })}% + \clf_setupinsertion + {\currentinsertion} + {% + location {\insertionparameter\c!location}% + }% + \relax \to \everysetupinsertion \unexpanded\def\page_inserts_set_location#1#2% fast one - {\ctxcommand{setinsertionlocation("#1","#2")}} + {\clf_setinsertionlocation{#1}{#2}} %D Auxiliary macros: diff --git a/tex/context/base/page-lin.lua b/tex/context/base/page-lin.lua index 0b241240c..8c8f9d425 100644 --- a/tex/context/base/page-lin.lua +++ b/tex/context/base/page-lin.lua @@ -21,6 +21,8 @@ local attributes = attributes local nodes = nodes local context = context +local implement = interfaces.implement + nodes.lines = nodes.lines or { } local lines = nodes.lines @@ -163,9 +165,19 @@ function boxed.register(configuration) return last end -function commands.registerlinenumbering(configuration) - context(boxed.register(configuration)) -end +implement { + name = "registerlinenumbering", + actions = { boxed.register, context }, + arguments = { + { + { "continue" }, + { "start", "integer" }, + { "step", "integer" }, + { "method" }, + { "tag" }, + } + } +} function boxed.setup(n,configuration) local d = data[n] @@ -185,7 +197,20 @@ function boxed.setup(n,configuration) return n end -commands.setuplinenumbering = boxed.setup +implement { + name = "setuplinenumbering", + actions = { boxed.setup, context }, + arguments = { + "integer", + { + { "continue" }, + { "start", "integer" }, + { "step", "integer" }, + { "method" }, + { "tag" }, + } + } +} local function check_number(n,a,skip,sameline) local d = data[a] @@ -394,5 +419,14 @@ function boxed.stage_two(n,m) end end -commands.linenumbersstageone = boxed.stage_one -commands.linenumbersstagetwo = boxed.stage_two +implement { + name = "linenumbersstageone", + actions = boxed.stage_one, + arguments = { "integer", "boolean" } +} + +implement { + name = "linenumbersstagetwo", + actions = boxed.stage_two, + arguments = { "integer", "integer" } +} diff --git a/tex/context/base/page-lin.mkvi b/tex/context/base/page-lin.mkvi index 73f8fe460..484412dbd 100644 --- a/tex/context/base/page-lin.mkvi +++ b/tex/context/base/page-lin.mkvi @@ -74,24 +74,33 @@ \unexpanded\def\page_postprocessors_linenumbers_column #tag{\page_lines_add_numbers_to_box{#tag}\currentcolumn\nofcolumns\zerocount} \def\page_lines_parameters_regular - {continue = "\ifnum\c_page_lines_mode=\zerocount\v!yes\else\v!no\fi", - start = \number\linenumberingparameter\c!start, - step = \number\linenumberingparameter\c!step, - method = "\linenumberingparameter\c!method", - tag = "\currentlinenumbering"} + {continue {\ifnum\c_page_lines_mode=\zerocount\v!yes\else\v!no\fi}% + start \linenumberingparameter\c!start + step \linenumberingparameter\c!step + method {\linenumberingparameter\c!method} + tag {\currentlinenumbering}} \def\page_lines_parameters_update - {continue = "\ifnum\c_page_lines_mode=\zerocount\v!yes\else\v!no\fi"} + {continue {\ifnum\c_page_lines_mode=\zerocount\v!yes\else\v!no\fi}} \def\page_lines_start_define - {\setxvalue{\??linenumberinginstance\currentlinenumbering}{\ctxcommand{registerlinenumbering({\page_lines_parameters_regular})}}} + {\setxvalue{\??linenumberinginstance\currentlinenumbering}% + {\clf_registerlinenumbering + \page_lines_parameters_regular + }} \def\page_lines_start_update - {\ctxcommand{setuplinenumbering(\csname\??linenumberinginstance\currentlinenumbering\endcsname,{\page_lines_parameters_update})}} + {\clf_setuplinenumbering + \csname\??linenumberinginstance\currentlinenumbering\endcsname + {\page_lines_parameters_update}% + \relax} \def\page_lines_setup {\ifcsname \??linenumberinginstance\currentlinenumbering\endcsname - \ctxcommand{setuplinenumbering(\csname\??linenumberinginstance\currentlinenumbering\endcsname,{\page_lines_parameters_regular})}% + \clf_setuplinenumbering + \csname\??linenumberinginstance\currentlinenumbering\endcsname + {\page_lines_parameters_regular}% + \relax \fi} % we could make this a bit more efficient by putting the end reference @@ -302,8 +311,14 @@ \setbox\b_page_lines_scratch\vbox {\forgetall \offinterlineskip - \ctxcommand{linenumbersstageone(\number\b_page_lines_number,\ifcase\c_page_lines_nesting false\else true\fi)}}% - \ctxcommand{linenumbersstagetwo(\number\b_page_lines_number,\number\b_page_lines_scratch)}% can move to lua code + \clf_linenumbersstageone + \b_page_lines_number + \ifcase\c_page_lines_nesting false\else true\fi + \relax}% + \clf_linenumbersstagetwo + \b_page_lines_number + \b_page_lines_scratch + \fi \egroup} \let\page_lines_make_number_indeed\relax @@ -322,8 +337,14 @@ \setbox\b_page_lines_scratch\vbox {\forgetall \offinterlineskip - \ctxcommand{linenumbersstageone(\number\b_page_lines_number,\ifcase\c_page_lines_nesting false\else true\fi)}}% - \ctxcommand{linenumbersstagetwo(\number\b_page_lines_number,\number\b_page_lines_scratch)}% can move to lua code + \clf_linenumbersstageone + \b_page_lines_number + \ifcase\c_page_lines_nesting false\else true\fi + \relax}% + \clf_linenumbersstagetwo + \b_page_lines_number + \b_page_lines_scratch + \relax \egroup} \def\page_lines_make_number#tag#mode#linenumber#shift#width#leftskip#dir% beware, one needs so compensate for this in the \hsize diff --git a/tex/context/base/page-pst.lua b/tex/context/base/page-pst.lua index 50580ae33..472bdbabe 100644 --- a/tex/context/base/page-pst.lua +++ b/tex/context/base/page-pst.lua @@ -8,16 +8,18 @@ if not modules then modules = { } end modules ['page-pst'] = { -- todo: adapt message -local tonumber, next = tonumber, next -local format, validstring = string.format, string.valid -local sortedkeys = table.sortedkeys +local tonumber, next, type = tonumber, next, type +local find, validstring = string.find, string.valid -local context = context -local commands = commands +local context = context +local implement = interfaces.implement local texgetcount = tex.getcount local texsetcount = tex.setcount +local sortedkeys = table.sortedkeys +local formatters = string.formatters + local cache = { } local function flush(page) @@ -25,7 +27,7 @@ local function flush(page) if c then for i=1,#c do -- characters.showstring(c[i]) - context.viafile(c[i],format("page.%s",validstring(page,"nopage"))) + context.viafile(c[i],formatters["page.%s"](validstring(page,"nopage"))) end cache[page] = nil end @@ -43,11 +45,11 @@ local function setnextpage() texsetcount("global","c_page_postponed_blocks_next_page",n) end -function commands.flushpostponedblocks(page) +local function flushpostponedblocks(specification) -- we need to flush previously pending pages as well and the zero -- slot is the generic one so that one is always flushed local t = sortedkeys(cache) - local p = tonumber(page) or texgetcount("realpageno") or 0 + local p = tonumber(specification.page) or texgetcount("realpageno") or 0 for i=1,#t do local ti = t[i] if ti <= p then @@ -59,9 +61,19 @@ function commands.flushpostponedblocks(page) setnextpage() end -function commands.registerpostponedblock(page) +implement { + name = "flushpostponedblocks", + actions = flushpostponedblocks, + arguments = { + { + { "page" } + } + } +} + +local function registerpostponedblock(page) if type(page) == "string" then - if string.find(page,"^+") then + if find(page,"^+") then page = texgetcount("realpageno") + (tonumber(page) or 1) -- future delta page else page = tonumber(page) or 0 -- preferred page or otherwise first possible occasion @@ -80,7 +92,14 @@ function commands.registerpostponedblock(page) if page == 0 then interfaces.showmessage("layouts",3,#c) else - interfaces.showmessage("layouts",3,string.format("%s (realpage: %s)",#c,page)) + interfaces.showmessage("layouts",3,formatters["%s (realpage: %s)"](#c,page)) end setnextpage() end + +implement { + name = "registerpostponedblock", + actions = registerpostponedblock, + arguments = "string" +} + diff --git a/tex/context/base/page-pst.mkiv b/tex/context/base/page-pst.mkiv index 93188f9fa..f12663f66 100644 --- a/tex/context/base/page-pst.mkiv +++ b/tex/context/base/page-pst.mkiv @@ -60,7 +60,7 @@ \doifelsenextoptional{\egroup\page_postponed_blocks_start}{\egroup\page_postponed_blocks_start[0]}} \unexpanded\setvalue{\e!stop\v!postponing}% - {\ctxcommand{registerpostponedblock("\currentpostponedpage")}\relax} + {\clf_registerpostponedblock{\currentpostponedpage}\relax} \def\page_postponed_blocks_start[#1]% {\edef\currentpostponedpage{#1}% @@ -80,7 +80,8 @@ \setnormalcatcodes % postponing in verbatim \uncatcodespacetokens % postponing in startlines \restoreglobalbodyfont % otherwise problems inside split verbatim - \ctxcommand{flushpostponedblocks()}% + \clf_flushpostponedblocks + % page {123} \relax \page_otr_command_flush_floats % new but potential dangerous, maybe we need a classification \endgroup} % of blocks: with and without flush diff --git a/tex/context/base/page-str.lua b/tex/context/base/page-str.lua index f2ac27cd9..56c6167aa 100644 --- a/tex/context/base/page-str.lua +++ b/tex/context/base/page-str.lua @@ -17,6 +17,8 @@ local nodes, node = nodes, node local nodepool = nodes.pool local tasks = nodes.tasks +local implement = interfaces.implement + local new_kern = nodepool.kern local new_glyph = nodepool.glyph @@ -235,6 +237,60 @@ tasks.disableaction("mvlbuilders", "streams.collect") function streams.initialize() tasks.enableaction ("mvlbuilders", "streams.collect") + function streams.initialize() end end -- todo: remove empty last { }'s +-- todo: better names, enable etc + +implement { + name = "initializestream", + actions = streams.initialize, + onlyonce = true, +} + +implement { + name = "enablestream", + actions = streams.enable, + arguments = "string" +} + +implement { + name = "disablestream", + actions = streams.disable +} + +implement { + name = "startstream", + actions = streams.start, + arguments = "string" +} + +implement { + name = "stopstream", + actions = streams.stop +} + +implement { + name = "flushstream", + actions = streams.flush, + arguments = "string" +} + +implement { + name = "flushstreamcopy", + actions = streams.flush, + arguments = { "string", true } +} + +implement { + name = "synchronizestream", + actions = streams.synchronize, + arguments = "string" +} + +implement { + name = "pushstream", + actions = streams.push, + arguments = "string" +} diff --git a/tex/context/base/page-str.mkiv b/tex/context/base/page-str.mkiv index 8284d4baa..e4b2fa229 100644 --- a/tex/context/base/page-str.mkiv +++ b/tex/context/base/page-str.mkiv @@ -42,7 +42,7 @@ \to \everyenableoutputstream \unexpanded\def\initializeoutputstreams - {\ctxlua{streams.initialize()}% + {\clf_initializestream \glet\initializeoutputstreams\relax} \unexpanded\def\enableoutputstream[#1]% could be \startoutputsubstream @@ -50,12 +50,12 @@ \the\everyenableoutputstream \inoutputstreamtrue \xdef\currentoutputstream{#1}% - \ctxlua{streams.enable("#1")}} + \clf_enablestream{#1}} \unexpanded\def\disableoutputstream {\inoutputstreamfalse \global\let\currentoutputstream\s!default - \ctxlua{streams.disable()}} + \clf_disablestream} \unexpanded\def\startoutputstream[#1]% {\begingroup @@ -63,10 +63,10 @@ \the\everyenableoutputstream \inoutputstreamtrue \xdef\currentoutputstream{#1}% - \ctxlua{streams.start("#1")}} + \clf_startstream{#1}} \unexpanded\def\stopoutputstream - {\ctxlua{streams.stop()}% + {\clf_stopstream \endgroup} \unexpanded\def\startoutputsubstream[#1]% just push/pop instead @@ -77,13 +77,13 @@ {\globalpopmacro\currentoutputstream \enableoutputstream[\currentoutputstream]} -\def\flushoutputstream [#1]{\ctxlua{streams.flush("#1")}} -\def\outputstreamcopy [#1]{\vbox{\ctxlua{streams.flush("#1",true)}}} -\def\outputstreambox [#1]{\vbox{\ctxlua{streams.flush("#1")}}} -\def\outputstreamunvcopy[#1]{\ctxlua{streams.flush("#1",true)}} -\def\outputstreamunvbox [#1]{\ctxlua{streams.flush("#1")}} -\def\synchronizestreams [#1]{\ctxlua{streams.synchronize("#1")}} -\def\dopushoutputstream [#1]{\ctxlua{streams.push("#1")}} +\def\flushoutputstream [#1]{\clf_flushstream{#1}} +\def\outputstreambox [#1]{\vbox{\clf_flushstream{#1}}} +\def\outputstreamcopy [#1]{\vbox{\clf_flushstreamcopy{#1}}} +\def\outputstreamunvbox [#1]{\clf_flushstream{#1}} +\def\outputstreamunvcopy[#1]{\clf_flushstreamcopy{#1}} +\def\synchronizestreams [#1]{\clf_synchronizestream{#1}} +\def\dopushoutputstream [#1]{\clf_pushstream{#1}} \unexpanded\def\pushoutputstream {\dosingleempty\dopushoutputstream} diff --git a/tex/context/base/regi-ini.lua b/tex/context/base/regi-ini.lua index e4a4e2399..37a88fd5f 100644 --- a/tex/context/base/regi-ini.lua +++ b/tex/context/base/regi-ini.lua @@ -28,6 +28,7 @@ local textlineactions = resolvers.openers.helpers.textlineactions local setmetatableindex = table.setmetatableindex local implement = interfaces.implement +local setmacro = interfaces.setmacro --[[ldx--

We will hook regime handling code into the input methods.

diff --git a/tex/context/base/s-fonts-shapes.lua b/tex/context/base/s-fonts-shapes.lua index d0c1e0b05..bca860f3f 100644 --- a/tex/context/base/s-fonts-shapes.lua +++ b/tex/context/base/s-fonts-shapes.lua @@ -131,7 +131,8 @@ local function showglyphshape(specification) local top_accent, bot_accent = (d.top_accent or 0)*factor, (d.bot_accent or 0)*factor local anchors, math = d.anchors, d.math context.startMPcode() - context("pickup pencircle scaled .25bp ;") + context("numeric lw ; lw := .125bp ;") + context("pickup pencircle scaled lw ;") context('picture p ; p := image(draw textext.drt("\\getuvalue{%s}\\gray\\char%s");); draw p ;',cs,charnum) context('draw (%s,%s)--(%s,%s)--(%s,%s)--(%s,%s)--cycle withcolor green ;',llx,lly,urx,lly,urx,ury,llx,ury) context('draw (%s,%s)--(%s,%s) withcolor green ;',llx,0,urx,0) @@ -147,11 +148,11 @@ local function showglyphshape(specification) l[#l+1] = formatters["((%s,%s) shifted (%s,%s))"](xsign*k*factor,ysign*h*factor,dx,dy) end end - context("draw ((%s,%s) shifted (%s,%s))--%s dashed (evenly scaled .25) withcolor .5white;", xsign*v[1].kern*factor,lly,dx,dy,l[1]) + context("draw ((%s,%s) shifted (%s,%s))--%s dashed (evenly scaled 1/16) withcolor .5white;", xsign*v[1].kern*factor,lly,dx,dy,l[1]) context("draw laddered (%s) withcolor .5white ;",table.concat(l,"..")) - context("draw ((%s,%s) shifted (%s,%s))--%s dashed (evenly scaled .25) withcolor .5white;", xsign*v[#v].kern*factor,ury,dx,dy,l[#l]) + context("draw ((%s,%s) shifted (%s,%s))--%s dashed (evenly scaled 1/16) withcolor .5white;", xsign*v[#v].kern*factor,ury,dx,dy,l[#l]) for k, v in ipairs(l) do - context("draw %s withcolor blue withpen pencircle scaled 1bp;",v) + context("draw %s withcolor blue withpen pencircle scaled 2lw ;",v) end end end @@ -197,7 +198,7 @@ local function showglyphshape(specification) end local function show(x,y,txt) local xx, yy = x*factor, y*factor - context("draw (%s,%s) withcolor blue withpen pencircle scaled 1bp;",xx,yy) + context("draw (%s,%s) withcolor blue withpen pencircle scaled 2lw ;",xx,yy) context('label.top("\\type{%s}",(%s,%s-2bp)) ;',txt,xx,yy) context('label.bot("(%s,%s)",(%s,%s+2bp)) ;',x,y,xx,yy) end @@ -236,9 +237,9 @@ local function showglyphshape(specification) end end if italic ~= 0 then - context('draw (%s,%s-1bp)--(%s,%s-0.5bp) withcolor blue;',width,ury,width,ury) - context('draw (%s,%s-1bp)--(%s,%s-0.5bp) withcolor blue;',width+italic,ury,width+italic,ury) - context('draw (%s,%s-1bp)--(%s,%s-1bp) withcolor blue;',width,ury,width+italic,ury) + context('draw (%s,%s-1bp)--(%s,%s-0.5bp) withcolor blue ;',width,ury,width,ury) + context('draw (%s,%s-1bp)--(%s,%s-0.5bp) withcolor blue ;',width+italic,ury,width+italic,ury) + context('draw (%s,%s-1bp)--(%s,%s-1bp) withcolor blue ;',width,ury,width+italic,ury) context('label.lft("\\type{%s}",(%s+2bp,%s-1bp));',"italic",width,ury) context('label.rt("%s",(%s-2bp,%s-1bp));',d.italic,width+italic,ury) end @@ -252,7 +253,7 @@ local function showglyphshape(specification) context('label.top("\\type{%s}",(%s,%s-1bp));',"bot_accent",top_accent,ury) context('label.bot("%s",(%s,%s+1bp));',d.bot_accent,bot_accent,lly) end - context('draw origin withcolor red withpen pencircle scaled 1bp;') + context('draw origin withcolor red withpen pencircle scaled 2lw;') context("setbounds currentpicture to boundingbox currentpicture enlarged 1bp ;") context("currentpicture := currentpicture scaled 8 ;") context.stopMPcode() diff --git a/tex/context/base/s-math-characters.lua b/tex/context/base/s-math-characters.lua index b0a79fcb6..8ff3a8660 100644 --- a/tex/context/base/s-math-characters.lua +++ b/tex/context/base/s-math-characters.lua @@ -16,23 +16,26 @@ local lower = string.lower local utfchar = utf.char local round = math.round -local fontdata = fonts.hashes.identifiers -local chardata = characters.data +local fontdata = fonts.hashes.identifiers +local chardata = characters.data +local blocks = characters.blocks local no_description = "no description, private to font" -local limited = true -local fillinthegaps = true -local upperlimit = 0x0007F -local upperlimit = 0xF0000 +local limited = true +local fillinthegaps = true +local upperlimit = 0x0007F +local upperlimit = 0xF0000 -local f_unicode = string.formatters["%U"] -local f_slot = string.formatters["%s/%0X"] +local f_unicode = string.formatters["%U"] +local f_slot = string.formatters["%s/%0X"] function moduledata.math.characters.showlist(specification) - specification = interfaces.checkedspecification(specification) - local id = specification.number -- or specification.id - local list = specification.list + specification = interfaces.checkedspecification(specification) + local id = specification.number -- or specification.id + local list = specification.list + local showvirtual = specification.virtual == "all" + local check = specification.check == "yes" if not id then id = font.current() end @@ -70,137 +73,170 @@ function moduledata.math.characters.showlist(specification) names[k] = (name and file.basename(name)) or id end end - context.showmathcharactersstart() - for _, unicode in next, sorted do - if not limited or unicode < upperlimit then - local code = gaps[unicode] or unicode - local char = characters[code] - local desc = descriptions[code] - local info = chardata[code] - if char then - local next_sizes = char.next - local v_variants = char.vert_variants - local h_variants = char.horiz_variants - local commands = char.commands - local slookups = desc and desc.slookups - local mlookups = desc and desc.mlookups - local mathclass = info.mathclass - local mathspec = info.mathspec - local mathsymbol = info.mathsymbol - local description = info.description or no_description - context.showmathcharactersstartentry() - context.showmathcharactersreference(f_unicode(unicode)) - context.showmathcharactersentryhexdectit(f_unicode(code),code,lower(description)) - context.showmathcharactersentrywdhtdpic(round(char.width or 0),round(char.height or 0),round(char.depth or 0),round(char.italic or 0)) - if virtual and commands then - local t = { } - for i=1,#commands do - local ci = commands[i] - if ci[1] == "slot" then - local fnt, idx = ci[2], ci[3] - t[#t+1] = f_slot(names[fnt] or fnt,idx) + if check then + for k, v in table.sortedhash(blocks) do + if v.math then + local first = v.first + local last = v.last + local f, l = 0, 0 + if first and last then + for unicode=first,last do + local code = gaps[unicode] or unicode + local char = characters[code] + if char and not (char.commands and not showvirtual) then + f = unicode + break end end - if #t > 0 then - context.showmathcharactersentryresource(concat(t,", ")) - end - end - if mathclass or mathspec then - context.showmathcharactersstartentryclassspec() - if mathclass then - context.showmathcharactersentryclassname(mathclass,info.mathname or "no name") - end - if mathspec then - for i=1,#mathspec do - local mi = mathspec[i] - context.showmathcharactersentryclassname(mi.class,mi.name or "no name") + for unicode=last,first,-1 do + local code = gaps[unicode] or unicode + local char = characters[code] + if char and not (char.commands and not showvirtual) then + l = unicode + break end end - context.showmathcharactersstopentryclassspec() + context.showmathcharacterssetrange(k,f,l) end - if mathsymbol then - context.showmathcharactersentrysymbol(f_unicode(mathsymbol),mathsymbol) - end - if next_sizes then - local n, done = 0, { } - context.showmathcharactersstartnext() - while next_sizes do - n = n + 1 - if done[next_sizes] then - context.showmathcharactersnextcycle(n) - break - else - done[next_sizes] = true - context.showmathcharactersnextentry(n,f_unicode(next_sizes),next_sizes) - next_sizes = characters[next_sizes] - v_variants = next_sizes.vert_variants or v_variants - h_variants = next_sizes.horiz_variants or h_variants - if next_sizes then - next_sizes = next_sizes.next + end + end + else + context.showmathcharactersstart() + for _, unicode in next, sorted do + if not limited or unicode < upperlimit then + local code = gaps[unicode] or unicode + local char = characters[code] + local desc = descriptions[code] + local info = chardata[code] + if char then + local commands = char.commands + if commands and not showvirtual then + -- skip + else + local next_sizes = char.next + local v_variants = char.vert_variants + local h_variants = char.horiz_variants + local slookups = desc and desc.slookups + local mlookups = desc and desc.mlookups + local mathclass = info.mathclass + local mathspec = info.mathspec + local mathsymbol = info.mathsymbol + local description = info.description or no_description + context.showmathcharactersstartentry() + context.showmathcharactersreference(f_unicode(unicode)) + context.showmathcharactersentryhexdectit(f_unicode(code),code,lower(description)) + context.showmathcharactersentrywdhtdpic(round(char.width or 0),round(char.height or 0),round(char.depth or 0),round(char.italic or 0)) + if virtual and commands then + local t = { } + for i=1,#commands do + local ci = commands[i] + if ci[1] == "slot" then + local fnt, idx = ci[2], ci[3] + t[#t+1] = f_slot(names[fnt] or fnt,idx) + end + end + if #t > 0 then + context.showmathcharactersentryresource(concat(t,", ")) end end - end - context.showmathcharactersstopnext() - if h_variants or v_variants then - context.showmathcharactersbetweennextandvariants() - end - end - if h_variants then - context.showmathcharactersstarthvariants() - for i=1,#h_variants do -- we might go top-down in the original - local vi = h_variants[i] - context.showmathcharactershvariantsentry(i,f_unicode(vi.glyph),vi.glyph) - end - context.showmathcharactersstophvariants() - elseif v_variants then - context.showmathcharactersstartvvariants() - for i=1,#v_variants do - local vi = v_variants[#v_variants-i+1] - context.showmathcharactersvvariantsentry(i,f_unicode(vi.glyph),vi.glyph) - end - context.showmathcharactersstopvvariants() - end - if slookups or mlookups then - local variants = { } - if slookups then - for lookupname, lookupdata in next, slookups do - local lookuptype = lookuptypes[lookupname] - if lookuptype == "substitution" then - variants[lookupdata] = "sub" - elseif lookuptype == "alternate" then - for i=1,#lookupdata do - variants[lookupdata[i]] = "alt" + if mathclass or mathspec then + context.showmathcharactersstartentryclassspec() + if mathclass then + context.showmathcharactersentryclassname(mathclass,info.mathname or "no name") + end + if mathspec then + for i=1,#mathspec do + local mi = mathspec[i] + context.showmathcharactersentryclassname(mi.class,mi.name or "no name") end end + context.showmathcharactersstopentryclassspec() end - end - if mlookups then - for lookupname, lookuplist in next, mlookups do - local lookuptype = lookuptypes[lookupname] - for i=1,#lookuplist do - local lookupdata = lookuplist[i] - local lookuptype = lookuptypes[lookupname] - if lookuptype == "substitution" then - variants[lookupdata] = "sub" - elseif lookuptype == "alternate" then - for i=1,#lookupdata do - variants[lookupdata[i]] = "alt" + if mathsymbol then + context.showmathcharactersentrysymbol(f_unicode(mathsymbol),mathsymbol) + end + if next_sizes then + local n, done = 0, { } + context.showmathcharactersstartnext() + while next_sizes do + n = n + 1 + if done[next_sizes] then + context.showmathcharactersnextcycle(n) + break + else + done[next_sizes] = true + context.showmathcharactersnextentry(n,f_unicode(next_sizes),next_sizes) + next_sizes = characters[next_sizes] + v_variants = next_sizes.vert_variants or v_variants + h_variants = next_sizes.horiz_variants or h_variants + if next_sizes then + next_sizes = next_sizes.next end end end + context.showmathcharactersstopnext() + if h_variants or v_variants then + context.showmathcharactersbetweennextandvariants() + end end + if h_variants then + context.showmathcharactersstarthvariants() + for i=1,#h_variants do -- we might go top-down in the original + local vi = h_variants[i] + context.showmathcharactershvariantsentry(i,f_unicode(vi.glyph),vi.glyph) + end + context.showmathcharactersstophvariants() + elseif v_variants then + context.showmathcharactersstartvvariants() + for i=1,#v_variants do + local vi = v_variants[#v_variants-i+1] + context.showmathcharactersvvariantsentry(i,f_unicode(vi.glyph),vi.glyph) + end + context.showmathcharactersstopvvariants() + end + if slookups or mlookups then + local variants = { } + if slookups then + for lookupname, lookupdata in next, slookups do + local lookuptype = lookuptypes[lookupname] + if lookuptype == "substitution" then + variants[lookupdata] = "sub" + elseif lookuptype == "alternate" then + for i=1,#lookupdata do + variants[lookupdata[i]] = "alt" + end + end + end + end + if mlookups then + for lookupname, lookuplist in next, mlookups do + local lookuptype = lookuptypes[lookupname] + for i=1,#lookuplist do + local lookupdata = lookuplist[i] + local lookuptype = lookuptypes[lookupname] + if lookuptype == "substitution" then + variants[lookupdata] = "sub" + elseif lookuptype == "alternate" then + for i=1,#lookupdata do + variants[lookupdata[i]] = "alt" + end + end + end + end + end + context.showmathcharactersstartlookupvariants() + local i = 0 + for variant, lookuptype in table.sortedpairs(variants) do + i = i + 1 + context.showmathcharacterslookupvariant(i,f_unicode(variant),variant,lookuptype) + end + context.showmathcharactersstoplookupvariants() + end + context.showmathcharactersstopentry() end - context.showmathcharactersstartlookupvariants() - local i = 0 - for variant, lookuptype in table.sortedpairs(variants) do - i = i + 1 - context.showmathcharacterslookupvariant(i,f_unicode(variant),variant,lookuptype) - end - context.showmathcharactersstoplookupvariants() end - context.showmathcharactersstopentry() end end + context.showmathcharactersstop() end - context.showmathcharactersstop() end diff --git a/tex/context/base/s-math-characters.mkiv b/tex/context/base/s-math-characters.mkiv index 1c4159544..3b273cb6c 100644 --- a/tex/context/base/s-math-characters.mkiv +++ b/tex/context/base/s-math-characters.mkiv @@ -46,6 +46,7 @@ \let\showmathcharactersstartlookupvariants \relax \let\showmathcharacterslookupvariant \gobblefourarguments \let\showmathcharactersstoplookupvariants \relax + \let\showmathcharacterssetrange \gobblethreearguments \stopsetups @@ -126,15 +127,23 @@ \def\module_math_characters_show[#1]% {\begingroup - \getdummyparameters[\c!bodyfont=,\c!list=,\c!alternative=default,#1]% + \getdummyparameters + [\c!bodyfont=, + \c!list=, + \c!check=, + \c!alternative=default, + \c!option=\v!all, + #1]% \directsetup{s-math-characters:\dummyparameter\c!alternative}% \doifelsenothing{\dummyparameter\c!bodyfont} {\definedfont[MathRoman*math-text]} {\definedfont[\dummyparameter\c!bodyfont]}% \dontcomplain \ctxlua{moduledata.math.characters.showlist { - number = false, - list = "\dummyparameter\c!list", + number = false, + check = "\dummyparameter\c!check", + list = "\dummyparameter\c!list", + option = "\dummyparameter\c!option", }}% \endgroup} diff --git a/tex/context/base/s-math-repertoire.mkiv b/tex/context/base/s-math-repertoire.mkiv index 53a173f16..230eb513e 100644 --- a/tex/context/base/s-math-repertoire.mkiv +++ b/tex/context/base/s-math-repertoire.mkiv @@ -39,7 +39,8 @@ % \setuplayout % [page] -\setuppapersize[HD+] +\setuppapersize + [HD+] \setuplayout [backspace=0pt, @@ -102,6 +103,16 @@ color=textcolor, contrastcolor=nonecolor] +\def\showmathcharacterssetrange#1#2#3% + {\writestatus{range}{#1: \unihex{#2} - \unihex{#3}}% + \ifcase#2\relax + \definereference[#1][notpresent]% + \else\ifcase#3\relax + \definereference[#1][notpresent]% + \else + \normalexpanded{\definereference[#1][\unihex{#2}]}% + \fi\fi} + \startinteractionmenu[bottom] \startgot [firstpage] first \stopgot \quad \startgot [deltapage(-100)] -100 \stopgot \quad @@ -159,6 +170,22 @@ \startgot [U+1D7AA] grk ss bolditalic \stopgot \stopinteractionmenu +% \startinteractionmenu[symbols] +% \startgot [U+00030] dig normal \stopgot \quad +% \startgot [U+1D7CE] dig bold \stopgot \quad +% \startgot [U+1D7D8] dig doublestruck \stopgot \quad +% \startgot [U+1D7E2] dig ss normal \stopgot \quad +% \startgot [U+1D7EC] dig ss bold \stopgot \quad +% \startgot [U+1D7F6] dig monospace \stopgot \quad +% \startgot [U+02200] operators \stopgot \quad +% \startgot [U+02701] symbols a \stopgot \quad +% \startgot [U+02901] symbols b \stopgot \quad +% \startgot [U+02A00] supplemental \stopgot \quad +% \startgot [U+027F0] arrows a \stopgot \quad +% \startgot [U+02900] arrows b \stopgot \quad +% \startgot [U+1F800] arrows c \stopgot +% \stopinteractionmenu + \startinteractionmenu[symbols] \startgot [U+00030] dig normal \stopgot \quad \startgot [U+1D7CE] dig bold \stopgot \quad @@ -167,12 +194,13 @@ \startgot [U+1D7EC] dig ss bold \stopgot \quad \startgot [U+1D7F6] dig monospace \stopgot \quad \startgot [U+02200] operators \stopgot \quad - \startgot [U+02701] symbols a \stopgot \quad - \startgot [U+02901] symbols b \stopgot \quad - \startgot [U+02A00] supplemental \stopgot \quad - \startgot [U+027F0] arrows a \stopgot \quad - \startgot [U+02900] arrows b \stopgot \quad - \startgot [U+1F800] arrows c \stopgot + \startgot [miscellaneousmathematicalsymbolsa] symbols a \stopgot \quad + \startgot [miscellaneousmathematicalsymbolsb] symbols b \stopgot \quad + \startgot [supplementalmathematicaloperators] supplemental \stopgot \quad + \startgot [supplementalarrowsa] arrows a \stopgot \quad + \startgot [supplementalarrowsb] arrows b \stopgot \quad + \startgot [supplementalarrowsc] arrows c \stopgot \quad + \removeunwantedspaces \stopinteractionmenu \defineframed @@ -407,13 +435,17 @@ % main +% this is a one-run style so we can forget about an alternative +% just assume that the previous definitions are global + \unprotect \unexpanded\def\showmathfontrepertoire {\dosingleempty\module_math_repertoire_show} -\def\module_math_repertoire_show[#1]% % this is a one-run style so we can forget about an alternative - {\showmathfontcharacters[\c!alternative=,#1]} % just assume that the previous definitions are global +\def\module_math_repertoire_show[#1]% + {\showmathfontcharacters[alternative=,option=,check=yes,#1] + \showmathfontcharacters[alternative=,option=,#1]} \protect diff --git a/tex/context/base/scrn-but.lua b/tex/context/base/scrn-but.lua index 74f6e0cd9..7d883c910 100644 --- a/tex/context/base/scrn-but.lua +++ b/tex/context/base/scrn-but.lua @@ -6,12 +6,10 @@ if not modules then modules = { } end modules ['scrn-but'] = { license = "see context related readme files" } -local commands = commands local context = context - local f_two_colon = string.formatters["%s:%s"] -function commands.registerbuttons(tag,register,language) +local function registerbuttons(tag,register,language) local data = sorters.definitions[language] local orders = daya and data.orders or sorters.definitions.default.orders local tag = tag == "" and { "" } or { tag } @@ -20,3 +18,9 @@ function commands.registerbuttons(tag,register,language) context.menubutton(tag,f_two_colon(register,order),order) end end + +interfaces.implement { + name = "registerbuttons", + actions = registerbuttons, + arguments = { "string", "string", "string" } +} diff --git a/tex/context/base/scrn-but.mkvi b/tex/context/base/scrn-but.mkvi index b2ee1827f..3fdaf2c5d 100644 --- a/tex/context/base/scrn-but.mkvi +++ b/tex/context/base/scrn-but.mkvi @@ -93,7 +93,7 @@ [\c!state=\v!start, \c!width=\v!fit, \c!height=\v!broad, - \c!offset=0.25em, + \c!offset=0.25\emwidth, \c!frame=\v!on, \c!background=, \c!backgroundcolor=, @@ -217,12 +217,12 @@ {\global\settrue\c_scrn_button_skipped} \def\scrn_button_make_normal#currentparameter#inheritedframed#letparameter#setparameter#text% - {\ctxcommand{injectcurrentreference()}% + {\clf_injectcurrentreference \hbox attr \referenceattribute \lastreferenceattribute {#inheritedframed{\ignorespaces#text\removeunwantedspaces}}} \def\scrn_button_make_contrast#currentparameter#inheritedframed#letparameter#setparameter#text% - {\ctxcommand{injectcurrentreference()}% + {\clf_injectcurrentreference \hbox attr \referenceattribute \lastreferenceattribute {#setparameter\c!foregroundcolor{#currentparameter\c!contrastcolor}% #inheritedframed{\ignorespaces#text\removeunwantedspaces}}} @@ -368,7 +368,7 @@ %D Fill menus: -\normalexpanded{\long\def\expandafter\noexpand\csname\e!start\v!interactionmenu\endcsname[#tag]#content\expandafter\noexpand\csname\e!stop\v!interactionmenu\endcsname}% +\normalexpanded{\def\expandafter\noexpand\csname\e!start\v!interactionmenu\endcsname[#tag]#content\expandafter\noexpand\csname\e!stop\v!interactionmenu\endcsname}% {\def\currentinteractionmenu{#tag}% \expandafter\settrue\csname\??menustate\interactionmenuparameter\c!category\endcsname \setinteractionmenuparameter\c!menu{#content}} @@ -709,7 +709,8 @@ \unexpanded\def\scrn_menu_got_start[#action]#text\stopgot {\scrn_menu_action_start - \setupcurrentinteractionmenu[\c!frame=\v!off,\c!background=]% needs checking, was buttons + \letinteractionmenuparameter\c!frame\v!off + \letinteractionmenuparameter\c!background\empty \scrn_button_make \interactionmenuparameter \inheritedinteractionmenuframed @@ -1022,9 +1023,14 @@ \def\scrn_menu_register_menu_buttons[#menu][#register]% {\ifsecondargument - \ctxcommand{registerbuttons("menu","#register","\currentlanguage")} + \clf_registerbuttons{menu}{#register}{\currentlanguage}% \else - \ctxcommand{registerbuttons("","#menu","\currentlanguage")} + \clf_registerbuttons{}{#menu}{\currentlanguage}% \fi} +% or less readable: +% +% \def\scrn_menu_register_menu_buttons[#menu][#register]% +% {\clf_registerbuttons\ifsecondargument{menu}{#register}\else{}{#menu}\fi{\currentlanguage}} + \protect \endinput diff --git a/tex/context/base/scrn-fld.lua b/tex/context/base/scrn-fld.lua index 69480b887..1563b9005 100644 --- a/tex/context/base/scrn-fld.lua +++ b/tex/context/base/scrn-fld.lua @@ -8,6 +8,10 @@ if not modules then modules = { } end modules ['scrn-fld'] = { -- we should move some code from lpdf-fld to here +local context = context +local ctx_doifelse = commands.doifelse +local implement = interfaces.implement + local variables = interfaces.variables local v_yes = variables.yes @@ -40,48 +44,141 @@ fields.defineset = defineset fields.clone = clone fields.insert = insert -commands.definefield = define -commands.definefieldset = defineset -commands.clonefield = clone +-- codeinjections are not yet defined + +implement { + name = "definefield", + actions = define, + arguments = { + { + { "name" }, + { "alternative" }, + { "type" }, + { "category" }, + { "values" }, + { "default" }, + } + } +} -function commands.insertfield(name,specification) - texsetbox("b_scrn_field_body",insert(name,specification)) -end +implement { + name = "definefieldset", + actions = defineset, + arguments = { "string", "string" } +} + +implement { + name = "clonefield", + actions = clone, + arguments = { + { + { "children" }, + { "alternative" }, + { "parent" }, + { "category" }, + { "values" }, + { "default" }, + } + } +} + +implement { + name = "insertfield", + actions = function(name,specification) + texsetbox("b_scrn_field_body",insert(name,specification)) + end, + arguments = { + "string", + { + { "title" }, + { "width", "dimen" }, + { "height", "dimen" }, + { "depth", "dimen" }, + { "align" }, + { "length" }, + { "fontstyle" }, + { "fontalternative" }, + { "fontsize" }, + { "fontsymbol" }, + { "colorvalue", "integer" }, + { "color" }, + { "backgroundcolorvalue", "integer" }, + { "backgroundcolor" }, + { "framecolorvalue", "integer" }, + { "framecolor" }, + { "layer" }, + { "option" }, + { "align" }, + { "clickin" }, + { "clickout" }, + { "regionin" }, + { "regionout" }, + { "afterkey" }, + { "format" }, + { "validate" }, + { "calculate" }, + { "focusin" }, + { "focusout" }, + { "openpage" }, + { "closepage" }, + } + } +} -- (for the monent) only tex interface -function commands.getfieldcategory(name) - local g = codeinjections.getfieldcategory(name) - if g then - context(g) +implement { + name = "getfieldcategory", + arguments = "string", + actions = function(name) + local g = codeinjections.getfieldcategory(name) + if g then + context(g) + end end -end +} -function commands.getdefaultfieldvalue(name) - local d = codeinjections.getdefaultfieldvalue(name) - if d then - context(d) +implement { + name = "getdefaultfieldvalue", + arguments = "string", + actions = function(name) + local d = codeinjections.getdefaultfieldvalue(name) + if d then + context(d) + end end -end +} -function commands.exportformdata(export) - if export == v_yes then - codeinjections.exportformdata() +implement { + name = "exportformdata", + arguments = "string", + actions = function(export) + if export == v_yes then + codeinjections.exportformdata() + end end -end - -function commands.setformsmethod(method) - codeinjections.setformsmethod(method) -end +} -function commands.doiffieldcategoryelse(name) - commands.doifelse(codeinjections.validfieldcategory(name)) -end +implement { + name = "setformsmethod", + arguments = "string", + actions = function(method) + codeinjections.setformsmethod(method) + end +} -function commands.doiffieldsetelse(tag) - commands.doifelse(codeinjections.validfieldset(name)) -end +implement { + name = "doifelsefieldcategory", + arguments = "string", + actions = function(name) + ctx_doifelse(codeinjections.validfieldcategory(name)) + end +} -function commands.doiffieldelse(name) - commands.doifelse(codeinjections.validfield(name)) -end +implement { + name = "doiffieldsetelse", + arguments = "string", + actions = function(name) + ctx_doifelse(codeinjections.validfieldset(name)) + end +} diff --git a/tex/context/base/scrn-fld.mkvi b/tex/context/base/scrn-fld.mkvi index d72592195..4b4c9d0ee 100644 --- a/tex/context/base/scrn-fld.mkvi +++ b/tex/context/base/scrn-fld.mkvi @@ -105,7 +105,7 @@ \installdirectcommandhandler \??forms {forms} \appendtoks - \ctxcommand{setformsmethod("\formsparameter\c!method")}% + \clf_setformsmethod{\formsparameter\c!method}% \to \everysetupforms \setupforms @@ -113,7 +113,7 @@ \appendtoks \iflocation - \ctxcommand{exportformdata("\formsparameter\c!export")}% + \clf_exportformdata{\formsparameter\c!export}% \fi \to \everystoptext @@ -177,23 +177,23 @@ \appendtoks % we cannot use parent .. maybe s!parent has to change \ifx\currentfieldbodyparent\empty \scrn_field_check_category - \ctxcommand{definefield{ - name = "\currentfieldbody", - alternative = "normal", - type = "\fieldbodyparameter\c!type", - category = "\fieldbodyparameter\c!category", - values = \!!bs\fieldbodyparameter\c!values\!!es, - default = \!!bs\fieldbodyparameter\c!default\!!es - }}% + \clf_definefield + name {\currentfieldbody}% + alternative {normal}% + type {\fieldbodyparameter\c!type}% + category {\fieldbodyparameter\c!category}% + values {\fieldbodyparameter\c!values}% + default {\fieldbodyparameter\c!default}% + \relax \else - \ctxcommand{clonefield{ - children = "\currentfieldbody", - alternative = "clone", - parent = "\currentfieldbodyparent", - category = "\fieldbodyparameter\c!category", - values = \!!bs\fieldbodyparameter\c!values\!!es, - default = \!!bs\fieldbodyparameter\c!default\!!es - }}% + \clf_clonefield + children {\currentfieldbody}% + alternative {clone}% + parent {\currentfieldbodyparent}% + category {\fieldbodyparameter\c!category}% + values {\fieldbodyparameter\c!values}% + default {\fieldbodyparameter\c!default}% + \relax \fi \to \everydefinefieldbody @@ -224,43 +224,46 @@ % == \edef\currentfieldbackgroundcolorvalue{\thecolorattribute\currentfieldbackgroundcolor}% \fi \usefieldbodystyleandcolor\c!style\c!color - \ctxcommand{insertfield("\currentfieldbody", { - title = "\currentfieldbody", - width = \number\dimexpr\fieldbodyparameter\c!width \relax, - height = \number\dimexpr\fieldbodyparameter\c!height\relax, - depth = \number\dimexpr\fieldbodyparameter\c!depth \relax, - align = "\fieldbodyparameter\c!align", - length = "\fieldbodyparameter\c!n", - fontstyle = "\fontstyle", - fontalternative = "\fontalternative", - fontsize = "\fontbody", - fontsymbol = "\fieldbodyparameter\c!symbol", - color = "\fieldbodyparameter\c!color", - colorvalue = \number\attribute\colorattribute, - \ifx\currentfieldbackgroundcolor\empty \else - backgroundcolor = "\currentfieldbackgroundcolor", - backgroundcolorvalue = "\currentfieldbackgroundcolorvalue", - \fi - \ifx\currentfieldframecolor\empty \else - framecolor = "\currentfieldframecolor", - framecolorvalue = "\currentfieldframecolorvalue", - \fi - layer = "\fieldbodyparameter\c!fieldlayer", - option = "\fieldbodyparameter\c!option", - align = "\fieldbodyparameter\c!align", - clickin = "\fieldbodyparameter\c!clickin", - clickout = "\fieldbodyparameter\c!clickout", - regionin = "\fieldbodyparameter\c!regionin", - regionout = "\fieldbodyparameter\c!regionout", - afterkey = "\fieldbodyparameter\c!afterkey", - format = "\fieldbodyparameter\c!format", - validate = "\fieldbodyparameter\c!validate", - calculate = "\fieldbodyparameter\c!calculate", - focusin = "\fieldbodyparameter\c!focusin", - focusout = "\fieldbodyparameter\c!focusout", - openpage = "\fieldbodyparameter\c!openpage", - closepage = "\fieldbodyparameter\c!closepage", - })}} + \clf_insertfield + {\currentfieldbody}% + {% + title {\currentfieldbody} + width \dimexpr\fieldbodyparameter\c!width \relax + height \dimexpr\fieldbodyparameter\c!height\relax + depth \dimexpr\fieldbodyparameter\c!depth \relax + align {\fieldbodyparameter\c!align}% + length {\fieldbodyparameter\c!n}% + fontstyle {\fontstyle}% + fontalternative {\fontalternative}% + fontsize {\fontbody}% + fontsymbol {\fieldbodyparameter\c!symbol}% + color {\fieldbodyparameter\c!color}% + colorvalue \attribute\colorattribute + \ifx\currentfieldbackgroundcolor\empty \else + backgroundcolor {\currentfieldbackgroundcolor}% + backgroundcolorvalue \numexpr\currentfieldbackgroundcolorvalue\relax + \fi + \ifx\currentfieldframecolor\empty \else + framecolor {\currentfieldframecolor}% + framecolorvalue \numexpr\currentfieldframecolorvalue\relax + \fi + layer {\fieldbodyparameter\c!fieldlayer}% + option {\fieldbodyparameter\c!option}% + align {\fieldbodyparameter\c!align}% + clickin {\fieldbodyparameter\c!clickin}% + clickout {\fieldbodyparameter\c!clickout}% + regionin {\fieldbodyparameter\c!regionin}% + regionout {\fieldbodyparameter\c!regionout}% + afterkey {\fieldbodyparameter\c!afterkey}% + format {\fieldbodyparameter\c!format}% + validate {\fieldbodyparameter\c!validate}% + calculate {\fieldbodyparameter\c!calculate}% + focusin {\fieldbodyparameter\c!focusin}% + focusout {\fieldbodyparameter\c!focusout}% + openpage {\fieldbodyparameter\c!openpage}% + closepage {\fieldbodyparameter\c!closepage}% + }% + \relax} %D The sets are used in grouped calculations. %D @@ -270,14 +273,14 @@ {\dodoubleempty\scrn_field_define_set} \def\scrn_field_define_set[#tag][#list]% - {\ctxcommand{definefieldset("#tag","#list")}} + {\clf_definefieldset{#tag}{#list}} \let\dodefinefieldset\definefieldbodyset % compatibility %D A few testing macros: -\def\doifelsefieldbody #tag{\ctxcommand{doiffieldelse("#tag")}} -\def\doifelsefieldcategory#tag{\ctxcommand{doiffieldcategoryelse("#tag")}} +\def\doifelsefieldbody #tag{\clf_doifelsefield{#tag}} +\def\doifelsefieldcategory#tag{\clf_doifelsefieldcategory{#tag}} \let\doiffieldbodyelse \doifelsefieldbody \let\doiffieldcategoryelse\doifelsefieldcategory @@ -369,7 +372,7 @@ \def\scrn_field_fit[#tag][#settings]% {\iflocation \begingroup - \edef\currentdefaultfieldvalue{\ctxcommand{getdefaultfieldvalue("#tag")}}% + \edef\currentdefaultfieldvalue{\clf_getdefaultfieldvalue{#tag}}% \setbox\b_scrn_field_fit_symbol\hbox{\symbol[\currentdefaultfieldvalue]}% \fitfieldframed {\fieldbody[#tag] @@ -498,7 +501,7 @@ \scrn_field_load_scripts \edef\currentfieldbody {#tag}% \edef\currentfieldlabel {#label}% - \edef\currentfieldcategory{\ctxcommand{getfieldcategory("#tag")}}% + \edef\currentfieldcategory{\clf_getfieldcategory{#tag}}% \ifx\currentfieldlabel\empty \let\currentfieldlabel\currentfieldbody \fi diff --git a/tex/context/base/scrn-hlp.lua b/tex/context/base/scrn-hlp.lua index d344ce280..99c0565a8 100644 --- a/tex/context/base/scrn-hlp.lua +++ b/tex/context/base/scrn-hlp.lua @@ -6,13 +6,15 @@ if not modules then modules = { } end modules ['scrn-hlp'] = { license = "see context related readme files" } -local format = string.format +local tonumber = tonumber local help = { } interactions.help = help local context = context -local commands = commands +local implement = interfaces.implement + +local formatters = string.formatters local a_help = attributes.private("help") @@ -48,21 +50,26 @@ local helpscript = [[ local template = "javascript(Hide_All_Help{help:}),action(show{help:%s})" -function help.register(number,name,box) - if helpscript then - interactions.javascripts.setpreamble("HelpTexts",helpscript) - helpscript = false - end - local b = copy_nodelist(texgetbox(box)) - register_list(b) - data[number] = b - if name and name ~= "" then - references[name] = number - structures.references.define("",name,format(template,number)) +local function register(specification) + local number = specification.number + local name = specification.name + local box = specification.box + if number and name and box then + if helpscript then + interactions.javascripts.setpreamble("HelpTexts",helpscript) + helpscript = false + end + local b = copy_nodelist(texgetbox(box)) + register_list(b) + data[number] = b + if name and name ~= "" then + references[name] = number + structures.references.define("",name,formatters[template](number)) + end end end -local function collect(head,used) +local function collectused(head,used) while head do local id = head.id if id == hlist_code then @@ -74,51 +81,77 @@ local function collect(head,used) used[#used+1] = a end else - used = collect(head.list,used) + used = collectused(head.list,used) end elseif id == vlist_code then - used = collect(head.list,used) + used = collectused(head.list,used) end head = head.next end return used end -function help.collect(box) +local function collect(box) if next(data) then - return collect(texgetbox(box).list) + return collectused(texgetbox(box).list) end end -commands.registerhelp = help.register - -function commands.collecthelp(box) - local used = help.collect(box) - if used then - local done = { } - context.startoverlay() - for i=1,#used do - local d = data[used[i]] - if d and not done[d] then - local box = hpack_nodelist(copy_nodelist(d)) - context(false,box) - done[d] = true - else - -- error +local function reference(name) + return references[name] or tonumber(name) or 0 +end + +help.register = register +help.collect = collect +help.reference = reference + +implement { + name = "registerhelp", + actions = register, + arguments = { + { + { "number", "integer" }, + { "name" }, + { "box" , "integer" } + } + } +} + +implement { + name = "collecthelp", + arguments = "integer", + actions = function(box) + local used = collect(box) + if used then + local done = { } + context.startoverlay() + for i=1,#used do + local d = data[used[i]] + if d and not done[d] then + local box = hpack_nodelist(copy_nodelist(d)) + context(false,box) + done[d] = true + else + -- error + end end + context.stopoverlay() end - context.stopoverlay() end -end - -function help.reference(name) - return references[name] or tonumber(name) or 0 -end +} -function commands.helpreference(name) - context(references[name] or tonumber(name) or 0) -end +implement { + name = "helpreference", + arguments = "string", + actions = function(name) + context(reference(name)) + end +} -function commands.helpaction(name) - context(template,references[name] or tonumber(name) or 0) -end +implement { + name = "helpaction", + arguments = "string", + actions = function(name) + context(template,reference(name)) + end +} diff --git a/tex/context/base/scrn-hlp.mkvi b/tex/context/base/scrn-hlp.mkvi index 8a8f5f094..eca79c90a 100644 --- a/tex/context/base/scrn-hlp.mkvi +++ b/tex/context/base/scrn-hlp.mkvi @@ -130,9 +130,13 @@ \c!values=\currenthelpname]% \setbox\b_scrn_help_box\hbox {\fieldbody[\currenthelpname]}% - \ctxcommand{registerhelp(\number\c_scrn_help_n,"\currenthelpreference",\number\b_scrn_help_box)}} + \clf_registerhelp + number \c_scrn_help_n + name {\currenthelpreference}% + box \b_scrn_help_box + \relax} -\def\doifelsehelp +\unexpanded\def\doifelsehelp {\ifcase\c_scrn_help_n \expandafter\firstoftwoarguments \else @@ -141,16 +145,16 @@ \let\doifhelpelse\doifelsehelp -\def\placehelp % was \helpdata +\unexpanded\def\placehelp % was \helpdata {\ifinpagebody\ifcase\c_scrn_help_n\else - \ctxcommand{collecthelp(255)}% rather hard coded ... bad + \clf_collecthelp\normalpagebox \fi\fi} \def\helpreference#category% - {\ctxcommand{helpreference("#category")}} + {\clf_helpreference{#category}} \def\helpaction#category% - {\ctxcommand{helpaction("#category")}} + {\clf_helpaction{#category}} \unexpanded\def\helpsignal#category% {\hbox attr \helpattribute \helpreference{#category}{}} diff --git a/tex/context/base/scrn-ref.lua b/tex/context/base/scrn-ref.lua index df71b6a97..c1fc94871 100644 --- a/tex/context/base/scrn-ref.lua +++ b/tex/context/base/scrn-ref.lua @@ -15,6 +15,8 @@ local codeinjections = backends.codeinjections local expandcurrent = structures.references.expandcurrent local identify = structures.references.identify +local implement = interfaces.implement + local function check(what) if what and what ~= "" then local set, bug = identify("",what) @@ -54,12 +56,12 @@ local function setclosepageaction(close) end end -references.setopendocument = setopendocumentaction -references.setclosedocument = setclosedocumentaction -references.setopenpage = setopenpageaction -references.setclosepage = setclosepageaction +references.setopendocument = setopendocumentaction +references.setclosedocument = setclosedocumentaction +references.setopenpage = setopenpageaction +references.setclosepage = setclosepageaction -commands.setopendocumentaction = setopendocumentaction -commands.setclosedocumentaction = setclosedocumentaction -commands.setopenpageaction = setopenpageaction -commands.setclosepageaction = setclosepageaction +implement { name = "setopendocumentaction", arguments = "string", actions = setopendocumentaction } +implement { name = "setclosedocumentaction", arguments = "string", actions = setclosedocumentaction } +implement { name = "setopenpageaction", arguments = "string", actions = setopenpageaction } +implement { name = "setclosepageaction", arguments = "string", actions = setclosepageaction } diff --git a/tex/context/base/scrn-ref.mkvi b/tex/context/base/scrn-ref.mkvi index a06ba1ad8..2b15b4677 100644 --- a/tex/context/base/scrn-ref.mkvi +++ b/tex/context/base/scrn-ref.mkvi @@ -25,7 +25,7 @@ \to \everysetupinteraction \def\scrn_reference_enable_page_destinations % no reset - {\ctxlua{structures.references.setinnermethod("\interactionparameter\c!page")}} + {\clf_setinnerreferencemethod{\interactionparameter\c!page}} \setupinteraction % start fit page and reset form [\c!page=\v!no, @@ -34,7 +34,7 @@ \c!focus=\v!fit, \c!calculate=, % rendering: - \c!width=1em, + \c!width=\emwidth, \c!height=\zeropoint, \c!depth=\zeropoint, \c!symbolset=] @@ -46,10 +46,10 @@ \edef\currentinteractionopenaction {\interactionparameter\c!openaction }% \edef\currentinteractioncloseaction{\interactionparameter\c!closeaction}% \ifx\currentinteractionopenaction\empty \else - \ctxcommand{setopendocumentaction("\currentinteractionopenaction")}% + \clf_setopendocumentaction{\currentinteractionopenaction}% \fi \ifx\currentinteractioncloseaction\empty \else - \ctxcommand{setclosedocumentaction("\currentinteractioncloseaction")}% + \clf_setclosedocumentaction{\currentinteractioncloseaction}% \fi \glet\scrn_reference_set_text_actions\relax \fi} @@ -59,10 +59,10 @@ \edef\currentinteractionopenpageaction {\interactionparameter\c!openpageaction }% \edef\currentinteractionclosepageaction{\interactionparameter\c!closepageaction}% \ifx\currentinteractionopenpageaction\empty \else - \ctxcommand{setopenpageaction("\currentinteractionopenpageaction")}% + \clf_setopenpageaction{\currentinteractionopenpageaction}% \fi \ifx\currentinteractionclosepageaction\empty \else - \ctxcommand{setclosepageaction("\currentinteractionclosepageaction")}% + \clf_setclosepageaction{\currentinteractionclosepageaction}% \fi \fi} @@ -73,7 +73,7 @@ \def\scrn_reference_enable_references {\ifproductionrun - \ctxlua{structures.references.enableinteraction()}% + \clf_enableinteraction % only once anyway \glet\scrn_reference_enable_references\relax \fi} diff --git a/tex/context/base/scrn-wid.lua b/tex/context/base/scrn-wid.lua index 5b319b07e..72c9bc733 100644 --- a/tex/context/base/scrn-wid.lua +++ b/tex/context/base/scrn-wid.lua @@ -10,6 +10,7 @@ interactions = interactions or { } local interactions = interactions local context = context +local implement = interfaces.implement local allocate = utilities.storage.allocate @@ -42,9 +43,13 @@ local report_attachments = logs.reporter("widgets","attachments") -- Symbols -function commands.presetsymbollist(list) - codeinjections.presetsymbollist(list) -end +implement { + name = "presetsymbollist", + arguments = "string", + actions = function(list) + codeinjections.presetsymbollist(list) + end +} -- Attachments -- @@ -108,11 +113,51 @@ function attachments.insert(specification) return nodeinjections.attachfile(specification) end -commands.registerattachment = attachments.register +implement { + name = "registerattachment", + actions = attachments.register, + arguments = { + { + { "tag" }, + { "registered" }, + { "title" }, + { "subtitle" }, + { "author" }, + { "file" }, + { "name" }, + { "buffer" }, + } + } +} -function commands.insertattachment(specification) - texsetbox("b_scrn_attachment_link",(attachments.insert(specification))) -end +implement { + name = "insertattachment", + actions = function(specification) + texsetbox("b_scrn_attachment_link",(attachments.insert(specification))) + end, + arguments = { + { + { "tag" }, + { "registered" }, + { "method" }, + { "width", "dimen" }, + { "height", "dimen" }, + { "depth", "dimen" }, + { "colormodel", "integer" }, + { "colorvalue", "integer" }, + { "color" }, + { "transparencyvalue", "integer" }, + { "symbol" }, + { "layer" }, + { "title" }, + { "subtitle" }, + { "author" }, + { "file" }, + { "name" }, + { "buffer" }, + } + } +} -- Comment @@ -124,9 +169,32 @@ function comments.insert(specification) return nodeinjections.comment(specification) end -function commands.insertcomment(specification) - texsetbox("b_scrn_comment_link",(comments.insert(specification))) -end +implement { + name = "insertcomment", + actions = function(specification) + texsetbox("b_scrn_comment_link",(comments.insert(specification))) + end, + arguments = { + { + { "tag" }, + { "title" }, + { "subtitle" }, + { "author" }, + { "width", "dimen" }, + { "height", "dimen" }, + { "depth", "dimen" }, + { "nx" }, + { "ny" }, + { "colormodel", "integer" }, + { "colorvalue", "integer" }, + { "transparencyvalue", "integer" }, + { "option" }, + { "symbol" }, + { "buffer" }, + { "layer" }, + } + } +} -- Soundclips @@ -153,8 +221,27 @@ function soundclips.insert(tag) end end -commands.registersoundclip = soundclips.register -commands.insertsoundclip = soundclips.insert +implement { + name = registersoundclip, + actions = soundclips.register, + arguments = { + { + { "tag" }, + { "file" } + } + } +} + +implement { + name = insertsoundclip, + actions = soundclips.insert, + arguments = { + { + { "tag" }, + { "repeat" } + } + } +} -- Renderings @@ -175,48 +262,84 @@ function renderings.rendering(label) end end -local function var(label,key) +function renderings.var(label,key) local rn = renderings[label] return rn and rn[key] or "" end -renderings.var = var - -function commands.renderingvar(label,key) - context(var(label,key)) -end +implement { + name = "renderingvar", + actions = { renderings.var, context }, + arguments = { "string", "string" } +} -commands.registerrendering = renderings.register +implement { + name = "registerrendering", + actions = renderings.register, + arguments = { + { + { "type" }, + { "label" }, + { "mime" }, + { "filename" }, + { "option" }, + } + } +} -- Rendering: -function commands.insertrenderingwindow(specification) - codeinjections.insertrenderingwindow(specification) -end +implement { + name = "insertrenderingwindow", + actions = function(specification) + codeinjections.insertrenderingwindow(specification) + end, + arguments = { + { + { "label" }, + { "width", "dimen" }, + { "height", "dimen" }, + { "option" }, + { "page", "integer" }, + } + } +} -- Linkedlists (only a context interface) -function commands.definelinkedlist(tag) - -- no need -end +implement { + name = "definelinkedlist", + arguments = "string", + actions = function(tag) + -- no need + end +} -function commands.enhancelinkedlist(tag,n) - local ll = jobpasses.gettobesaved(tag) - if ll then - ll[n] = texgetcount("realpageno") - end -end +implement { + name = "enhancelinkedlist", + arguments = { "string", "integer" }, + actions = function(tag,n) + local ll = jobpasses.gettobesaved(tag) + if ll then + ll[n] = texgetcount("realpageno") + end + end +} -function commands.addlinklistelement(tag) - local tobesaved = jobpasses.gettobesaved(tag) - local collected = jobpasses.getcollected(tag) or { } - local currentlink = #tobesaved + 1 - local noflinks = #collected - tobesaved[currentlink] = 0 - local f = collected[1] or 0 - local l = collected[noflinks] or 0 - local p = collected[currentlink-1] or f - local n = collected[currentlink+1] or l - context.setlinkedlistproperties(currentlink,noflinks,f,p,n,l) - -- context.ctxlatelua(function() commands.enhancelinkedlist(tag,currentlink) end) -end +implement { + name = "addlinklistelement", + arguments = "string", + actions = function(tag) + local tobesaved = jobpasses.gettobesaved(tag) + local collected = jobpasses.getcollected(tag) or { } + local currentlink = #tobesaved + 1 + local noflinks = #collected + tobesaved[currentlink] = 0 + local f = collected[1] or 0 + local l = collected[noflinks] or 0 + local p = collected[currentlink-1] or f + local n = collected[currentlink+1] or l + context.setlinkedlistproperties(currentlink,noflinks,f,p,n,l) + -- context.ctxlatelua(function() commands.enhancelinkedlist(tag,currentlink) end) + end +} diff --git a/tex/context/base/scrn-wid.mkvi b/tex/context/base/scrn-wid.mkvi index 931933bf1..57a4be276 100644 --- a/tex/context/base/scrn-wid.mkvi +++ b/tex/context/base/scrn-wid.mkvi @@ -100,16 +100,16 @@ \begingroup \def\currentattachment{_}% \setupcurrentattachment[#settings,\s!parent=\??attachment]% - \ctxcommand{registerattachment{ - tag = "#tag", - registered = "#tag", - title = "\attachmentparameter\c!title", - subtitle = "\attachmentparameter\c!subtitle", - author = "\attachmentparameter\c!author", - file = "\attachmentparameter\c!file", - name = "\attachmentparameter\c!name", - buffer = "\attachmentparameter\c!buffer", - }}% + \clf_registerattachment + tag {#tag}% + registered {#tag}% + title {\attachmentparameter\c!title}% + subtitle {\attachmentparameter\c!subtitle}% + author {\attachmentparameter\c!author}% + file {\attachmentparameter\c!file}% + name {\attachmentparameter\c!name}% + buffer {\attachmentparameter\c!buffer}% + \relax \endgroup \else % todo @@ -181,37 +181,37 @@ \edef\currentattachmentheight{\attachmentparameter\c!height}% \edef\currentattachmentdepth {\attachmentparameter\c!depth }% \ifx\currentattachmentsymbol\empty - \ifx\currentattachmentwidth \v!fit\edef\currentattachmentwidth {.5em}\fi - \ifx\currentattachmentheight\v!fit\edef\currentattachmentheight{.5em}\fi + \ifx\currentattachmentwidth \v!fit\edef\currentattachmentwidth {.5\emwidth}\fi + \ifx\currentattachmentheight\v!fit\edef\currentattachmentheight{.5\emwidth}\fi \ifx\currentattachmentdepth \v!fit\let \currentattachmentdepth \zeropoint\fi \else - \ctxcommand{presetsymbollist("\attachmentparameter\c!symbol")}% + \clf_presetsymbollist{\attachmentparameter\c!symbol}% % we cannot yet ask for the wd/ht/dp of an xform else we could use those \setbox\b_scrn_attachment_symbol\hbox{\symbol[\lastpredefinedsymbol]}% \ifx\currentattachmentwidth \v!fit\edef\currentattachmentwidth {\wd\b_scrn_attachment_symbol}\fi \ifx\currentattachmentheight\v!fit\edef\currentattachmentheight{\ht\b_scrn_attachment_symbol}\fi \ifx\currentattachmentdepth \v!fit\edef\currentattachmentdepth {\dp\b_scrn_attachment_symbol}\fi \fi - \ctxcommand{insertattachment{ - tag = "\currentattachment", - registered = "\currentattachmentregistered", - width = \number\dimexpr\currentattachmentwidth \relax, - height = \number\dimexpr\currentattachmentheight\relax, - depth = \number\dimexpr\currentattachmentdepth \relax, - color = "\attachmentparameter\c!color", - colormodel = \number\attribute\colormodelattribute, - colorvalue = \thecolorattribute{\attachmentparameter\c!color}, - transparencyvalue = \thetransparencyattribute{\attachmentparameter\c!color}, - symbol = "\currentattachmentsymbol", - layer = "\attachmentparameter\c!textlayer", + \clf_insertattachment + tag {\currentattachment}% + registered {\currentattachmentregistered}% + width \dimexpr\currentattachmentwidth \relax + height \dimexpr\currentattachmentheight\relax + depth \dimexpr\currentattachmentdepth \relax + color {\attachmentparameter\c!color}% + colormodel \attribute\colormodelattribute + colorvalue \numexpr\thecolorattribute{\attachmentparameter\c!color}\relax % or are these chardefs + transparencyvalue \numexpr\thetransparencyattribute{\attachmentparameter\c!color}\relax % or are these chardefs + symbol {\currentattachmentsymbol}% + layer {\attachmentparameter\c!textlayer}% % these will be overloaded by registered when available - title = "\attachmentparameter\c!title", - subtitle = "\attachmentparameter\c!subtitle", - author = "\attachmentparameter\c!author", - file = "\attachmentparameter\c!file", - name = "\attachmentparameter\c!name", - buffer = "\attachmentparameter\c!buffer", - }}% + title {\attachmentparameter\c!title}% + subtitle {\attachmentparameter\c!subtitle}% + author {\attachmentparameter\c!author}% + file {\attachmentparameter\c!file}% + name {\attachmentparameter\c!name}% + buffer {\attachmentparameter\c!buffer}% + \relax \setbox\b_scrn_attachment_link\hbox{\scrn_attachment_place}% \wd\b_scrn_attachment_link\currentattachmentwidth \ht\b_scrn_attachment_link\currentattachmentheight @@ -219,11 +219,11 @@ \box\b_scrn_attachment_link} \setvalue{\??attachmentmethod\v!hidden}% - {\ctxcommand{insertattachment{ - tag = "\currentattachment", - registered = "\currentattachmentregistered", - method = "\v!hidden" - }}} + {\clf_insertattachment + tag {\currentattachment}% + registered {\currentattachmentregistered}% + method {\v!hidden}% + \relax} \def\scrn_attachment_place {\executeifdefined @@ -401,7 +401,7 @@ {\doifelseassignment{#title} {\setupcurrentcomment[#title]} {\setupcurrentcomment[\c!title=#title,#settings]}% - \ctxcommand{assignbuffer("\v!comment",\!!bs#text\!!es)}% todo: expansion control, but expanded by default (xml) + \clf_assignbuffer{\v!comment}{#text}\catcodetable\relax% todo: expansion control, but expanded by default (xml) \scrn_comment_inject \ignorespaces} @@ -447,35 +447,35 @@ \edef\currentcommentheight{\commentparameter\c!height}% \edef\currentcommentdepth {\commentparameter\c!depth }% \ifx\currentcommentsymbol\empty - \ifx\currentcommentwidth \v!fit\edef\currentcommentwidth {.5em}\fi - \ifx\currentcommentheight\v!fit\edef\currentcommentheight{.5em}\fi + \ifx\currentcommentwidth \v!fit\edef\currentcommentwidth {.5\emwidth}\fi + \ifx\currentcommentheight\v!fit\edef\currentcommentheight{.5\emwidth}\fi \ifx\currentcommentdepth \v!fit\let \currentcommentdepth \zeropoint\fi \else - \ctxcommand{presetsymbollist("\commentparameter\c!symbol")}% + \clf_presetsymbollist{\commentparameter\c!symbol}% % we cannot yet ask for the wd/ht/dp of an xform else we could use those \setbox\b_scrn_comment_symbol\hbox{\symbol[\lastpredefinedsymbol]}% \ifx\currentcommentwidth \v!fit\edef\currentcommentwidth {\wd\b_scrn_comment_symbol}\fi \ifx\currentcommentheight\v!fit\edef\currentcommentheight{\ht\b_scrn_comment_symbol}\fi \ifx\currentcommentdepth \v!fit\edef\currentcommentdepth {\dp\b_scrn_comment_symbol}\fi \fi - \ctxcommand{insertcomment{ - tag = "\currentcomment", - title = "\commentparameter\c!title", - subtitle = "\commentparameter\c!subtitle", - author = "\commentparameter\c!author", - width = \number\dimexpr\currentcommentwidth, - height = \number\dimexpr\currentcommentheight, - depth = \number\dimexpr\currentcommentdepth, - nx = \commentparameter\c!nx, - ny = \commentparameter\c!ny, - colormodel = \number\attribute\colormodelattribute, - colorvalue = \thecolorattribute{\commentparameter\c!color}, - transparencyvalue = \thetransparencyattribute{\commentparameter\c!color}, - option = "\commentparameter\c!option", % todo - symbol = "\commentparameter\c!symbol", - buffer = "\v!comment", - layer = "\commentparameter\c!textlayer" - }}% + \clf_insertcomment + tag {\currentcomment}% + title {\commentparameter\c!title}% + subtitle {\commentparameter\c!subtitle}% + author {\commentparameter\c!author}% + width \dimexpr\currentcommentwidth\relax + height \dimexpr\currentcommentheight\relax + depth \dimexpr\currentcommentdepth\relax + nx {\commentparameter\c!nx}% + ny {\commentparameter\c!ny}% + colormodel \attribute\colormodelattribute + colorvalue \numexpr\thecolorattribute{\commentparameter\c!color}\relax + transparencyvalue \numexpr\thetransparencyattribute{\commentparameter\c!color}\relax + option {\commentparameter\c!option}% % todo + symbol {\commentparameter\c!symbol}% + buffer {\v!comment}% + layer {\commentparameter\c!textlayer}% + \relax \wd\b_scrn_comment_link\currentcommentwidth \ht\b_scrn_comment_link\currentcommentheight \dp\b_scrn_comment_link\currentcommentdepth @@ -542,17 +542,17 @@ {\dodoubleargument\scrn_soundtrack_indeed} \def\scrn_soundtrack_indeed[#tag][#filename]% - {\ctxcommand{registersoundclip{ - tag = "#tag", - file = "#filename" - }}} + {\clf_registersoundclip + tag {#tag}% + file {#filename}% + \relax} \def\checksoundtrack#tag% yet untested in mkiv (also move management to lua) {\iflocation - \ctxcommand{insertsoundclip{ - tag = "#tag", - ["repeat"] = "\directexternalsoundtrackparameter\c!option", % todo: pass option as-is - }}% + \clf_insertsoundclip + tag {#tag}% + repeat {\directexternalsoundtrackparameter\c!option}% + \relax \fi} %D Renderings (not yet tested in mkvi): @@ -571,31 +571,31 @@ \unexpanded\def\setinternalrendering{\dodoubleempty \scrn_rendering_set} \def\scrn_rendering_use[#tag][#mime][#file][#option]% - {\ctxcommand{registerrendering{ - type = "external", - label = "#tag", - mime = "#mime", - filename = "#file", - option = "#option", - }}} + {\clf_registerrendering + type {external}% + label {#tag}% + mime {#mime}% + filename {#file}% + option {#option}% + \relax} \def\scrn_rendering_set[#tag][#option]% {content} % crappy {\bgroup \dowithnextbox - {\ctxcommand{registerrendering{ - type = "internal", - label = "#tag", - mime = "IRO", % brrr - filename = "#tag", - option = "#option", - }}% + {\clf_registerrendering + type {internal}% + label {#tag}% + mime {IRO}% brrr + filename {#tag}% + option {#option}% + \relax \let\objectoffset\zeropoint \setobject{IRO}{#tag}\hbox{\box\nextbox}% \egroup}% \hbox} -\def\renderingtype #tag{\ctxcommand{renderingvar("#tag","type")}} -\def\renderingoption#tag{\ctxcommand{renderingvar("#tag","option")}} +\def\renderingtype #tag{\clf_renderingvar{#tag}{type}} +\def\renderingoption#tag{\clf_renderingvar{#tag}{option}} \newdimen\d_scrn_rendering_width \d_scrn_rendering_width 8cm \newdimen\d_scrn_rendering_height \d_scrn_rendering_height 6cm @@ -648,13 +648,14 @@ \letrenderingwindowparameter\c!offset\v!overlay \inheritedrenderingwindowframed {\vfill - \ctxcommand{insertrenderingwindow { - label = "\currentrendering", - width = \number\d_scrn_rendering_width, - height = \number\d_scrn_rendering_height, - option = "\renderingoption\currentrendering", - page = \number\m_scrn_rendering_page, - }}\hfill}% + \clf_insertrenderingwindow + label {\currentrendering}% + width \d_scrn_rendering_width + height \d_scrn_rendering_height + option {\renderingoption\currentrendering}% + page \m_scrn_rendering_page + \relax + \hfill}% \egroup} %D Linkedlists (not tested in mkvi): @@ -676,7 +677,7 @@ % \let\setupbutton\setuplinkedlists\setuplinkedlist % % \appendtoks -% \ctxcommand{definelinkedlist("\currentlinkedlist")}% +% \clf_definelinkedlist{\currentlinkedlist}% % \to \everydefinelinkedlist % % \def\setlinkedlistproperties#1#2#3#4#5#6% @@ -694,8 +695,8 @@ % \edef\currentlinkedlist{#1}% % \ifcsname\??lk\currentlinkedlist\s!parent\endcsname % \hskip\linkedlistparameter\c!distance -% \ctxcommand{addlinklistelement("\currentlinkedlist")}% -% \expanded{\ctxlatelua{commands.enhancelinkedlist("\currentlinkedlist",\currentlink)}}% can also be done at the lua end +% \clf_addlinklistelement{\currentlinkedlist}% +% \expanded{\ctxlatecommand{enhancelinkedlist("\currentlinkedlist",\currentlink)}}% can also be done at the lua end % \dogotosomepage {\??lk\currentlinkedlist}\gotobegincharacter \firstlink % \ifnum\noflinks>\plustwo % \dogotosomepage{\??lk\currentlinkedlist}\gobackwardcharacter\previouslink diff --git a/tex/context/base/spac-adj.lua b/tex/context/base/spac-adj.lua index c87a9d17f..cdf9b5051 100644 --- a/tex/context/base/spac-adj.lua +++ b/tex/context/base/spac-adj.lua @@ -56,3 +56,11 @@ function nodes.handlers.graphicvadjust(head,groupcode) -- we can make an actionc return head, false end end + +interfaces.implement { + name = "enablegraphicvadjust", + onlyonce = true, + actions = function() + nodes.tasks.enableaction("finalizers","nodes.handlers.graphicvadjust") + end +} diff --git a/tex/context/base/spac-adj.mkiv b/tex/context/base/spac-adj.mkiv index 447dd7229..b8534303d 100644 --- a/tex/context/base/spac-adj.mkiv +++ b/tex/context/base/spac-adj.mkiv @@ -16,18 +16,19 @@ \unprotect % Very nasty but needed for margin stuff inside colored -% paragraphs. Obsolete anyway. +% paragraphs. Obsolete for while . \registerctxluafile{spac-adj}{1.001} \definesystemattribute [graphicvadjust] [public] \unexpanded\def\enablegraphicvadjust - {\ctxlua{nodes.tasks.enableaction("finalizers","nodes.handlers.graphicvadjust")}% + {\writestatus\m!systems{graphicvadjusting is no longer needed!} + \clf_enablegraphicvadjust %once anyway \glet\enablegraphicvadjust\relax} \unexpanded\def\graphicvadjust % currently not enabled ... nasty bidi handling - {\enablegraphicvadjust % and no longer needed anyway + {\clf_enablegraphicvadjust % and probably no longer needed anyway \dowithnextboxcontentcs\forgetall\spac_vadjust_graphic_finish\vbox} \def\spac_vadjust_graphic_finish diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index b4e94c21c..aa810be4e 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index d01a9e85c..55f533996 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/context/base/strc-doc.lua b/tex/context/base/strc-doc.lua index b7487dbd1..a8647684c 100644 --- a/tex/context/base/strc-doc.lua +++ b/tex/context/base/strc-doc.lua @@ -989,8 +989,8 @@ implement { name = "structurecatcodedget", actions = sections.structuredat implement { name = "structuregivencatcodedget", actions = sections.structuredata, arguments = { false, "string", false, "integer" } } implement { name = "structureautocatcodedget", actions = sections.structuredata, arguments = { false, "string", false, "string" } } -implement { name = "namedstructurevariable", actions = sections.structuredata } -implement { name = "namedstructureuservariable", actions = sections.userdata } +implement { name = "namedstructurevariable", actions = sections.structuredata, arguments = { "string", "string" } } +implement { name = "namedstructureuservariable", actions = sections.userdata, arguments = { "string", "string" } } implement { name = "setstructurelevel", actions = sections.setlevel, arguments = { "string", "string" } } implement { name = "getstructurelevel", actions = sections.getcurrentlevel, arguments = { "string" } } diff --git a/tex/context/base/strc-lst.lua b/tex/context/base/strc-lst.lua index e63f70f9f..634d3a49a 100644 --- a/tex/context/base/strc-lst.lua +++ b/tex/context/base/strc-lst.lua @@ -974,7 +974,7 @@ implement { } }, { "userdata" }, - { "titledata", { + { "titledata", { { "label" }, { "title" }, { "bookmark" }, diff --git a/tex/context/base/strc-pag.lua b/tex/context/base/strc-pag.lua index ede731d2b..96d26e6f6 100644 --- a/tex/context/base/strc-pag.lua +++ b/tex/context/base/strc-pag.lua @@ -272,6 +272,24 @@ function pages.is_odd(n) end end +function pages.on_right(n) + local pagemode = texgetcount("pageduplexmode") + if pagemode == 2 or pagemode == 1 then + n = n or texgetcount("realpageno") + if texgetcount("pagenoshift") % 2 == 0 then + return n % 2 == 0 + else + return n % 2 ~= 0 + end + else + return true + end +end + +function pages.in_body(n) + return texgetcount("pagebodymode") > 0 +end + -- move to strc-pag.lua function counters.analyze(name,counterspecification) diff --git a/tex/context/base/strc-pag.mkiv b/tex/context/base/strc-pag.mkiv index 808a2854a..72f0cf32a 100644 --- a/tex/context/base/strc-pag.mkiv +++ b/tex/context/base/strc-pag.mkiv @@ -26,12 +26,14 @@ \countdef\subpageno \plustwo \subpageno \zerocount % ! \countdef\arrangeno \plusthree \arrangeno \zerocount % ! \countdef\pagenoshift\plusfour \pagenoshift\zerocount % ! +\countdef\lastpageno \plusfive \lastpageno \zerocount % ! \let\pageno\userpageno \def\realfolio{\the\realpageno} \def\userfolio{\the\userpageno} \def\subfolio {\the\subpageno } +\def\lastfolio{\the\lastpageno} \newtoks\everyinitializepagecounters @@ -103,6 +105,7 @@ \strc_counters_set\s!realpage\realpageno \strc_counters_set\s!userpage\userpageno \strc_counters_set\s!subpage \subpageno + \lastpageno\lastcountervalue[\s!realpage]\relax \to \everyinitializepagecounters \let\setuppagenumber\setupuserpagenumber @@ -304,6 +307,12 @@ \trackingmarginnotesfalse \fi \fi + \pageduplexmode + \ifsinglesided + \ifdoublesided\plustwo\else\zerocount\fi + \else + \ifdoublesided\plusone\else\zerocount\fi + \fi \page_backgrounds_recalculate \strc_pagenumbers_set_location \to \everysetuppagenumbering diff --git a/tex/context/base/strc-ref.lua b/tex/context/base/strc-ref.lua index 91417fe69..9cf703b74 100644 --- a/tex/context/base/strc-ref.lua +++ b/tex/context/base/strc-ref.lua @@ -1799,6 +1799,13 @@ function references.setinnermethod(m) end end +implement { + name = "setinnerreferencemethod", + actions = references.setinnermethod, + arguments = "string", + onlyonce = true +} + function references.getinnermethod() return innermethod or defaultinnermethod end diff --git a/tex/context/base/strc-reg.lua b/tex/context/base/strc-reg.lua index 99cad84a7..ed3292195 100644 --- a/tex/context/base/strc-reg.lua +++ b/tex/context/base/strc-reg.lua @@ -435,23 +435,54 @@ local entrysplitter = lpeg.tsplitat('+') -- & obsolete in mkiv local tagged = { } +-- this whole splitting is an inheritance of mkii + local function preprocessentries(rawdata) local entries = rawdata.entries if entries then - local e, k = entries[1] or "", entries[2] or "" - local et, kt, entryproc, pageproc - if type(e) == "table" then - et = e - else - entryproc, e = splitprocessor(e) + -- + -- local e = entries[1] or "" + -- local k = entries[2] or "" + -- local et, kt, entryproc, pageproc + -- if type(e) == "table" then + -- et = e + -- else + -- entryproc, e = splitprocessor(e) + -- et = lpegmatch(entrysplitter,e) + -- end + -- if type(k) == "table" then + -- kt = k + -- else + -- pageproc, k = splitprocessor(k) + -- kt = lpegmatch(entrysplitter,k) + -- end + -- + local processors = rawdata.processors + local et = entries.entries + local kt = entries.keys + local entryproc = processors and processors.entry + local pageproc = processors and processors.page + if entryproc == "" then + entryproc = nil + end + if pageproc == "" then + pageproc = nil + end + if not et then + local p, e = splitprocessor(entries.entry or "") + if p then + entryproc = p + end et = lpegmatch(entrysplitter,e) end - if type(k) == "table" then - kt = k - else - pageproc, k = splitprocessor(k) + if not kt then + local p, k = splitprocessor(entries.key or "") + if p then + pageproc = p + end kt = lpegmatch(entrysplitter,k) end + -- entries = { } local ok = false for k=#et,1,-1 do @@ -466,7 +497,7 @@ local function preprocessentries(rawdata) end rawdata.list = entries if pageproc or entryproc then - rawdata.processors = { entryproc, pageproc } + rawdata.processors = { entryproc, pageproc } -- old way: indexed .. will be keys end rawdata.entries = nil end @@ -479,8 +510,12 @@ end local function storeregister(rawdata) -- metadata, references, entries local references = rawdata.references local metadata = rawdata.metadata - local processors = rawdata.processors -- checking + if not metadata then + metadata = { } + rawdata.metadata = metadata + end + -- if not metadata.kind then metadata.kind = "entry" end @@ -489,10 +524,6 @@ local function storeregister(rawdata) -- metadata, references, entries metadata.catcodes = tex.catcodetable -- get end -- - if processors and processors[1] == "" and processors[2] == "" then - rawdata.processors = nil - end - -- local name = metadata.name local notsaved = tobesaved[name].metadata.notsaved -- @@ -537,7 +568,9 @@ local function storeregister(rawdata) -- metadata, references, entries return #entries end -local function enhanceregister(name,n) +registers.store = storeregister + +function registers.enhance(name,n) local data = tobesaved[name].metadata.notsaved and collected[name] or tobesaved[name] local entry = data.entries[n] if entry then @@ -545,7 +578,7 @@ local function enhanceregister(name,n) end end -local function extendregister(name,tag,rawdata) -- maybe do lastsection internally +function registers.extend(name,tag,rawdata) -- maybe do lastsection internally if type(tag) == "string" then tag = tagged[tag] end @@ -589,23 +622,70 @@ local function extendregister(name,tag,rawdata) -- maybe do lastsection internal end end -registers.store = storeregister -registers.enhance = enhanceregister -registers.extend = extendregister - function registers.get(tag,n) local list = tobesaved[tag] return list and list.entries[n] end -function commands.storeregister(rawdata) - local nofentries = storeregister(rawdata) - setinternalreference { internal = rawdata.references.internal } - context(nofentries) -end +implement { + name = "enhanceregister", + actions = registers.enhance, + arguments = { "string", "integer" } +} -commands.enhanceregister = enhanceregister -commands.extendregister = extendregister +implement { + name = "extendregister", + actions = registers.extend, + arguments = { "string", "string" } +} + +implement { + name = "storeregister", + actions = function(rawdata) + local nofentries = storeregister(rawdata) + setinternalreference { internal = rawdata.references.internal } + context(nofentries) + end, + arguments = { + { + { "metadata", { + { "kind" }, + { "name" }, + { "coding" }, + { "level", "integer" }, + { "catcodes", "integer" }, + { "own" }, + { "xmlroot" }, + { "xmlsetup" } + } + }, + { "entries", { + { "entries", "list" }, + { "keys", "list" }, + { "entry" }, + { "key" } + } + }, + { "references", { + { "internal", "integer" }, + { "section", "integer" }, + { "label" } + } + }, + { "seeword", { + { "text" } + } + }, + { "processors", { + { "entry" }, + { "key" }, + { "page" } + } + }, + { "userdata" }, + } + } +} -- sorting and rendering @@ -846,9 +926,21 @@ end registers.analyze = analyzeregister -function commands.analyzeregister(class,options) - context(analyzeregister(class,options)) -end +implement { + name = "analyzeregister", + actions = { analyzeregister, context }, + arguments = { + "string", + { + { "language" }, + { "method" }, + { "numberorder" }, + { "compress" }, + { "criterium" }, + { "pagenumber", "boolean" }, + } + } +} -- todo take conversion from index @@ -1214,12 +1306,42 @@ function registers.flush(data,options,prefixspec,pagespec) -- collectgarbage("collect") end -local function processregister(class,...) +function registers.process(class,...) if analyzeregister(class,...) > 0 then local data = collected[class] registers.flush(data,...) end end -registers.process = processregister -commands.processregister = processregister +implement { + name = "processregister", + actions = registers.process, + arguments = { + "string", + { + { "language" }, + { "method" }, + { "numberorder" }, + { "compress" }, + { "criterium" }, + { "pagenumber", "boolean" }, + }, + { + { "separatorset" }, + { "conversionset" }, + { "starter" }, + { "stopper" }, + { "set" }, + { "segments" }, + { "connector" }, + }, + { + { "prefix" }, + { "separatorset" }, + { "conversionset" }, + { "starter" }, + { "stopper" }, + { "segments" }, + } + } +} diff --git a/tex/context/base/strc-reg.mkiv b/tex/context/base/strc-reg.mkiv index d4dbea9d5..138a1486f 100644 --- a/tex/context/base/strc-reg.mkiv +++ b/tex/context/base/strc-reg.mkiv @@ -251,48 +251,48 @@ \setnextinternalreference % we could consider storing register entries in a list which we % could then sort - \xdef\currentregisternumber{\ctxcommand{storeregister{ % 'own' should not be in metadata - metadata = { - % kind = "entry", - name = "\currentregister", - % level = structures.sections.currentlevel(), - coding = "\currentregistercoding", - % catcodes = \the\catcodetable, + \xdef\currentregisternumber{\clf_storeregister % 'own' should not be in metadata + metadata {% + name {\currentregister}% + coding {\currentregistercoding}% \ifx\currentregisterownnumber\v!yes - own = "\registerparameter\c!alternative", % can be used instead of pagenumber + own {\registerparameter\c!alternative}% can be used instead of pagenumber \fi \ifx\currentreferencecoding\s!xml - xmlroot = "\xmldocument", % only useful when text + xmlroot {\xmldocument} % only useful when text \fi \ifx\currentregisterxmlsetup\empty \else - xmlsetup = "\currentregisterxmlsetup", + xmlsetup {\currentregisterxmlsetup}% \fi - }, - references = { - % internal = \nextinternalreference, - % section = structures.sections.currentid(), % hm, why then not also lastsection the same way + }% + references {% \ifx\currentregisterlabel\empty \else - label = "\currentregisterlabel", + label {\currentregisterlabel}% \fi - }, - % \ifx\currentregisterentries\empty \else - entries = { + }% + entries {% % we need a special one for xml, this is just a single one \ifx\currentregisterentries\empty - { \!!bs\currentregisterentriesa\!!es, \!!bs\currentregisterentriesb\!!es, \!!bs\currentregisterentriesc\!!es }, + entries { + {\currentregisterentriesa}% + {\currentregisterentriesb}% + {\currentregisterentriesc}% + } \else - \!!bs\currentregisterentries\!!es, + entry {\currentregisterentries}% \fi \ifx\currentregisterkeys\empty - { \!!bs\currentregisterkeysa\!!es, \!!bs\currentregisterkeysb\!!es, \!!bs\currentregisterkeysc\!!es }, + keys { + {\currentregisterkeysa}% + {\currentregisterkeysb}% + {\currentregisterkeysc}% + } \else - \!!bs\currentregisterkeys\!!es, + key {\currentregisterkeys}% \fi - }, - % \fi - userdata = structures.helpers.touserdata(\!!bs\detokenize{#3}\!!es) - } - }}% + }% + userdata {\detokenize\expandafter{\normalexpanded{#3}}} + }% % \clf_setinternalreference internal \nextinternalreference\relax % in previous \ifx\currentregisterownnumber\v!yes \glet\currentregistersynchronize\relax @@ -312,12 +312,21 @@ {\begingroup \edef\currentregister{#1}% \setnextinternalreference - \xdef\currentregisternumber{\ctxcommand{storeregister{ - metadata = { name = "\currentregister" }, - entries = { \!!bs#2\!!es, \!!bs#3\!!es }, - processors = { \!!bs#4\!!es, \!!bs#5\!!es }, - } - }}% + \xdef\currentregisternumber{\clf_storeregister + {% + metadata {% + name {\currentregister}% + } + entries {% + entry {#2}% + key {#3}% + }% + processors {% + entry {#4}% + page {#5}% + }% + }% + }% % overlap with the above \xdef\currentregistersynchronize{\ctxlatecommand{enhanceregister("\currentregister",\currentregisternumber)}}% \currentregistersynchronize % here? @@ -485,26 +494,23 @@ \fi \setnextinternalreference % we could consider storing register entries in list - \edef\temp{\ctxcommand{storeregister{ - metadata = { - kind = "see", - name = "\currentregister", - % level = structures.sections.currentlevel(), - % catcodes = \the\catcodetable, - }, - references = { - % internal = \nextinternalreference, - % section = structures.sections.currentid(), - }, - entries = { - % we need a special one for xml, this is just a single one - \!!bs\currentregisterentries\!!es, - \!!bs#2\!!es - }, - seeword = { - text = \!!bs\currentregisterseeword\!!es - }, - } + \edef\temp{\clf_storeregister{ + metadata {% + kind {see}% + name {\currentregister}% + }% + references {% + % internal = \nextinternalreference, + % section = structures.sections.currentid(), + }% + entries {% + % we need a special one for xml, this is just a single one + entry {\currentregisterentries}% + key {#2}% + }% + seeword {% + text {\currentregisterseeword}% + }% }}% \dostarttagged\t!registerlocation\currentregister \attribute\destinationattribute\lastdestinationattribute \signalcharacter % no \strut as it will be removed during cleanup @@ -525,14 +531,17 @@ {\begingroup \edef\currentregister{#1}% \setupregister[\currentregister][#2]% - \normalexpanded{\endgroup\noexpand\xdef\noexpand\utilityregisterlength{\ctxcommand{analyzeregister('\currentregister',{ - language = "\registerparameter\s!language", - method = "\registerparameter\c!method", - numberorder = "\registerparameter\c!numberorder", - compress = "\registerparameter\c!compress", - criterium = "\registerparameter\c!criterium", - pagenumber = \ifx\registerpageseparatorsymbol\empty false\else true\fi, - })}}}% brrr + \normalexpanded{\endgroup\noexpand\xdef\noexpand\utilityregisterlength{\clf_analyzeregister + {\currentregister}% + {% + language {\registerparameter\s!language}% + method {\registerparameter\c!method}% + numberorder {\registerparameter\c!numberorder}% + compress {\registerparameter\c!compress}% + criterium {\registerparameter\c!criterium}% + pagenumber \ifx\registerpageseparatorsymbol\empty false\else true\fi + }% + }}% \ifcase\utilityregisterlength\relax \resetsystemmode\v!register \else @@ -566,29 +575,32 @@ \fi} \def\strc_registers_place_indeed - {\ctxcommand{processregister('\currentregister',{ - language = "\registerparameter\s!language", - method = "\registerparameter\c!method", - numberorder = "\registerparameter\c!numberorder", - compress = "\registerparameter\c!compress", - criterium = "\registerparameter\c!criterium", - pagenumber = \ifx\registerpageseparatorsymbol\empty false\else true\fi, - },{ - separatorset = "\registerparameter\c!pageprefixseparatorset", - conversionset = "\registerparameter\c!pageprefixconversionset", - starter = \!!bs\registerparameter\c!pageprefixstarter\!!es, - stopper = \!!bs\registerparameter\c!pageprefixstopper\!!es, - set = "\registerparameter\c!pageprefixset", - segments = "\registerparameter\c!pageprefixsegments", - connector = \!!bs\registerparameter\c!pageprefixconnector\!!es, - },{ - prefix = "\registerparameter\c!pageprefix", - separatorset = "\registerparameter\c!pageseparatorset", - conversionset = "\registerparameter\c!pageconversionset", - starter = \!!bs\registerparameter\c!pagestarter\!!es, - stopper = \!!bs\registerparameter\c!pagestopper\!!es, - segments = "\registerparameter\c!pagesegments", - })}} + {\clf_processregister + {\currentregister}% + {% + language {\registerparameter\s!language}% + method {\registerparameter\c!method}% + numberorder {\registerparameter\c!numberorder}% + compress {\registerparameter\c!compress}% + criterium {\registerparameter\c!criterium}% + pagenumber \ifx\registerpageseparatorsymbol\empty false\else true\fi + }{% + separatorset {\registerparameter\c!pageprefixseparatorset}% + conversionset {\registerparameter\c!pageprefixconversionset}% + starter {\registerparameter\c!pageprefixstarter}% + stopper {\registerparameter\c!pageprefixstopper}% + set {\registerparameter\c!pageprefixset}% + segments {\registerparameter\c!pageprefixsegments}% + connector {\registerparameter\c!pageprefixconnector}% + }{% + prefix {\registerparameter\c!pageprefix}% + separatorset {\registerparameter\c!pageseparatorset}% + conversionset {\registerparameter\c!pageconversionset}% + starter {\registerparameter\c!pagestarter}% + stopper {\registerparameter\c!pagestopper}% + segments {\registerparameter\c!pagesegments}% + }% + \relax} \def\strc_registers_limited_entry#1% {\limitatetext{#1}\currentregistermaxwidth\unknown}% diff --git a/tex/context/base/strc-sec.mkiv b/tex/context/base/strc-sec.mkiv index ae5a271c9..eb6d3738d 100644 --- a/tex/context/base/strc-sec.mkiv +++ b/tex/context/base/strc-sec.mkiv @@ -267,7 +267,7 @@ \def\structuretitle {\clf_structuretitle} \def\structurevariable #1{\clf_structurevariable {#1}} \def\structureuservariable #1{\clf_structureuservariable {#1}} -\def\structurecatcodedget #1{\clf_structurecatcodedget {#1}} % bad name +\def\structurecatcodedget #1{\clf_structurecatcodedget {#1}} % bad name \def\structuregivencatcodedget #1#2{\clf_structuregivencatcodedget {#1}#2 } % bad name \def\structureautocatcodedget #1#2{\clf_structureautocatcodedget {#1}{#2}} \def\namedstructurevariable #1#2{\clf_namedstructurevariable {#1}{#2}} diff --git a/tex/context/base/syst-aux.lua b/tex/context/base/syst-aux.lua index 71c56169f..a880bace3 100644 --- a/tex/context/base/syst-aux.lua +++ b/tex/context/base/syst-aux.lua @@ -59,7 +59,7 @@ local ctx_doifelse = commands.doifelse implement { name = "doifelsefirstchar", arguments = { "string", "string" }, - actions = function(str) + actions = function(str,chr) ctx_doifelse(lpegmatch(pattern,str) == chr) end } @@ -67,7 +67,7 @@ implement { implement { name = "getsubstring", arguments = { "string", "string", "string" }, - actions = function(str) + actions = function(str,first,last) context(utfsub(str,tonumber(first),tonumber(last))) end } @@ -194,6 +194,12 @@ implement { name = "strip", arguments = "string", actions = { string.strip, cont -- where, not really the best spot for this: +implement { + name = "immediatemessage", + arguments = { "'message'", "string" }, + actions = logs.status +} + implement { name = "resettimer", actions = function() diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv index 1a05ba3df..c39f0cc0d 100644 --- a/tex/context/base/syst-aux.mkiv +++ b/tex/context/base/syst-aux.mkiv @@ -3083,7 +3083,7 @@ %D %D A fully expandable message: -\def\immediatemessage#1{\ctxlua{logs.status("message","#1")}} +\let\immediatemessage\clf_immediatemessage % {} mandate %D \macros %D {debuggerinfo} diff --git a/tex/context/base/tabl-xtb.mkvi b/tex/context/base/tabl-xtb.mkvi index 8742818d5..777016d50 100644 --- a/tex/context/base/tabl-xtb.mkvi +++ b/tex/context/base/tabl-xtb.mkvi @@ -80,8 +80,13 @@ \let\dotagxtablesignal\relax % names will change \appendtoks - \def\dotagxtablecell {\taggedctxcommand{settagtablecell(\number\tablecellrows,\number\tablecellcolumns,\number\raggedstatus)}}% - \def\dotagxtablesignal{\char\zerocount}% not used + \def\dotagxtablecell + {\clf_settagtablecell + \numexpr\tablecellrows\relax + \numexpr\tablecellcolumns\relax + \numexpr\raggedstatus\relax}% + \def\dotagxtablesignal + {\char\zerocount}% not used \to \everyenableelements \newdimen\d_tabl_x_width diff --git a/tex/context/base/task-ini.lua b/tex/context/base/task-ini.lua index f1df46ec8..ed9989a81 100644 --- a/tex/context/base/task-ini.lua +++ b/tex/context/base/task-ini.lua @@ -108,10 +108,8 @@ appendaction("math", "builders", "builders.kernel.mlist_to_hlist") ------------("math", "builders", "noads.handlers.italics", nil, "nohead") -- disabled appendaction("math", "builders", "typesetters.directions.processmath") -- disabled (has to happen pretty late) --- quite experimental (nodes.handlers.graphicvadjust might go away) - appendaction("finalizers", "lists", "builders.paragraphs.keeptogether") -appendaction("finalizers", "lists", "nodes.handlers.graphicvadjust") -- todo +------------("finalizers", "lists", "nodes.handlers.graphicvadjust") -- todo appendaction("finalizers", "fonts", "builders.paragraphs.solutions.splitters.optimize") -- experimental appendaction("finalizers", "lists", "builders.paragraphs.tag") @@ -184,7 +182,7 @@ disableaction("processors", "builders.paragraphs.solutions.splitters.split") disableaction("finalizers", "builders.paragraphs.keeptogether") disableaction("finalizers", "builders.paragraphs.solutions.splitters.optimize") -disableaction("finalizers", "nodes.handlers.graphicvadjust") -- sort of obsolete +-------------("finalizers", "nodes.handlers.graphicvadjust") -- sort of obsolete disableaction("finalizers", "builders.paragraphs.tag") disableaction("math", "noads.handlers.showtree") diff --git a/tex/context/base/toks-scn.lua b/tex/context/base/toks-scn.lua index 9b6b440f8..84924c694 100644 --- a/tex/context/base/toks-scn.lua +++ b/tex/context/base/toks-scn.lua @@ -69,29 +69,68 @@ end scanners.scanopen = scanopen scanners.scanclose = scanclose +local function scanlist() + local wrapped = scanopen() + local list = { } + local size = 0 + while true do + local entry = scanstring() + if entry then + size = size + 1 + list[size] = entry + else + break + end + end + if wrapped then + scanclose() + end + return list +end + +local function scanconditional() + local kw = scanword() + if kw == "true" then + return true + end + if kw == "false" then + return false + end + local c = scaninteger() + if c then + return c == 0 -- with a conditional 0=true + end + return nil +end + +scanners.list = scanlist +scanners.conditional = scanconditional + local shortcuts = { - tokens = tokens, - bits = tokenbits, - open = open, - close = close, - scanners = scanners, - scanstring = scanstring, - scaninteger = scaninteger, - scannumber = scannumber, - scankeyword = scankeyword, - scanword = scanword, - scancode = scancode, - scanboolean = scanboolean, - scandimen = scandimen, - scandimension = scandimen, - scanopen = scanopen, - scanclose = scanclose, - todimen = todimen, - tonumber = tonumber, - tostring = tostring, - toboolean = toboolean, - inspect = inspect, - report = report_scan, + tokens = tokens, + bits = tokenbits, + open = open, + close = close, + scanners = scanners, + scanstring = scanstring, + scaninteger = scaninteger, + scannumber = scannumber, + scankeyword = scankeyword, + scanword = scanword, + scancode = scancode, + scanboolean = scanboolean, + scandimen = scandimen, + scandimension = scandimen, + scanconditional = scanconditional, + scanopen = scanopen, + scanclose = scanclose, + scanlist = scanlist, + todimen = todimen, + tonumber = tonumber, + tostring = tostring, + toboolean = toboolean, + inspect = inspect, + report = report_scan, } tokens.shortcuts = shortcuts diff --git a/tex/context/base/trac-jus.lua b/tex/context/base/trac-jus.lua index e4cbdb2e8..0c92848dc 100644 --- a/tex/context/base/trac-jus.lua +++ b/tex/context/base/trac-jus.lua @@ -62,9 +62,10 @@ end checkers.set = set checkers.reset = reset -function commands.showjustification(n) - set(n) -end +interfaces.implement { + name = "showjustification", + actions = set +} trackers.register("visualizers.justification", function(v) if v then diff --git a/tex/context/base/trac-jus.mkiv b/tex/context/base/trac-jus.mkiv index 7a5347da8..d0823d311 100644 --- a/tex/context/base/trac-jus.mkiv +++ b/tex/context/base/trac-jus.mkiv @@ -20,6 +20,6 @@ \definesystemattribute[justification] [public] \unexpanded\def\showjustification - {\ctxcommand{showjustification()}} + {\clf_showjustification} % currently no argument (default 1) \protect \endinput diff --git a/tex/context/base/typo-cln.lua b/tex/context/base/typo-cln.lua index 8b1ac7876..7228e02c5 100644 --- a/tex/context/base/typo-cln.lua +++ b/tex/context/base/typo-cln.lua @@ -101,4 +101,8 @@ end -- interface -commands.setcharactercleaning = cleaners.set +interfaces.implement { + name = "setcharactercleaning", + actions = cleaners.set, + arguments = "string" +} diff --git a/tex/context/base/typo-cln.mkiv b/tex/context/base/typo-cln.mkiv index 5306f614f..193198dc5 100644 --- a/tex/context/base/typo-cln.mkiv +++ b/tex/context/base/typo-cln.mkiv @@ -24,7 +24,7 @@ %D 1: Autocap first character of a line \unexpanded\def\setcharactercleaning[#1]% This name might change! - {\ctxcommand{setcharactercleaning("#1")}} % also accepts "reset" + {\clf_setcharactercleaning{#1}} % also accepts "reset" % \appendtoks % \attribute\cleanerattribute\attributeunsetvalue diff --git a/tex/context/base/typo-dig.lua b/tex/context/base/typo-dig.lua index f5b8a6ddd..c753a0352 100644 --- a/tex/context/base/typo-dig.lua +++ b/tex/context/base/typo-dig.lua @@ -173,4 +173,8 @@ end -- interface -commands.setdigitsmanipulation = digits.set +interfaces.implement { + name = "setdigitsmanipulation", + actions = digits.set, + arguments = "string" +} diff --git a/tex/context/base/typo-dig.mkiv b/tex/context/base/typo-dig.mkiv index 71425c594..aa610b3c9 100644 --- a/tex/context/base/typo-dig.mkiv +++ b/tex/context/base/typo-dig.mkiv @@ -39,7 +39,7 @@ %D \stoplines \unexpanded\def\setdigitsmanipulation[#1]% - {\ctxcommand{setdigitsmanipulation("#1")}} + {\clf_setdigitsmanipulation{#1}} \unexpanded\def\resetdigitsmanipulation {\attribute\digitsattribute\attributeunsetvalue} diff --git a/tex/context/base/typo-drp.lua b/tex/context/base/typo-drp.lua index ec1b52699..4bbf0b8e9 100644 --- a/tex/context/base/typo-drp.lua +++ b/tex/context/base/typo-drp.lua @@ -91,7 +91,27 @@ function initials.set(specification) texsetattribute(a_initial,1) end -commands.setinitial = initials.set +interfaces.implement { + name = "setinitial", + actions = initials.set, + arguments = { + { + { "location" }, + { "enabled", "boolean" }, + { "method" }, + { "distance" ,"dimen" }, + { "hoffset" ,"dimen" }, + { "voffset" ,"dimen" }, + { "font", "integer" }, + { "dynamic", "integer" }, + { "ca", "integer" }, + { "ma", "integer" }, + { "ta", "integer" }, + { "n", "integer" }, + { "m", "integer" }, + } + } +} -- dropped caps experiment (will be done properly when luatex -- stores the state in the local par node) .. btw, search still diff --git a/tex/context/base/typo-drp.mkiv b/tex/context/base/typo-drp.mkiv index 3ac47466f..2520c3bfd 100644 --- a/tex/context/base/typo-drp.mkiv +++ b/tex/context/base/typo-drp.mkiv @@ -99,21 +99,21 @@ {\useinitialstyleparameter\c!style}% \useinitialcolorparameter\c!color \edef\p_text{\initialparameter\c!text}% optional - \ctxcommand{setinitial{ - location = "\initialparameter\c!location", - enabled = true, - n = \number\scratchcounter, - m = \number\initialparameter\c!m, - method = "\initialparameter\c!method", - distance = \number\scratchdistance, - hoffset = \number\scratchhoffset, - voffset = \number\scratchvoffset, - ma = \the\attribute\colormodelattribute, - ca = \the\attribute\colorattribute, - ta = \the\attribute\transparencyattribute, - font = \fontid\font, - dynamic = \number\attribute\zerocount, % it's a bit over the top to support this here - }}% + \clf_setinitial + location {\initialparameter\c!location}% + enabled true\space + n \scratchcounter + m \numexpr\initialparameter\c!m\relax + method {\initialparameter\c!method}% + distance \scratchdistance + hoffset \scratchhoffset + voffset \scratchvoffset + ma \attribute\colormodelattribute + ca \attribute\colorattribute + ta \attribute\transparencyattribute + font \fontid\font + dynamic \attribute\zerocount % it's a bit over the top to support this here + \relax \stopluacode \kern\zeropoint % we need a node \p_text diff --git a/tex/context/base/typo-fln.lua b/tex/context/base/typo-fln.lua index 884a4c829..2076a7464 100644 --- a/tex/context/base/typo-fln.lua +++ b/tex/context/base/typo-fln.lua @@ -23,6 +23,9 @@ local firstlines = typesetters.firstlines local nodes = nodes local tasks = nodes.tasks +local context = context +local implement = interfaces.implement + local nuts = nodes.nuts local tonut = nuts.tonut local tonode = nuts.tonode @@ -85,7 +88,21 @@ function firstlines.set(specification) texsetattribute(a_firstline,1) end -commands.setfirstline = firstlines.set +implement { + name = "setfirstline", + actions = firstlines.set, + arguments = { + { + { "alternative" }, + { "font", "integer" }, + { "dynamic", "integer" }, + { "ma", "integer" }, + { "ca", "integer" }, + { "ta", "integer" }, + { "n", "integer" }, + } + } +} actions[v_line] = function(head,setting) -- local attribute = fonts.specifiers.contextnumber(setting.feature) -- was experimental @@ -262,7 +279,7 @@ end -- goodie -function commands.applytofirstcharacter(box,what) +local function applytofirstcharacter(box,what) local tbox = getbox(box) -- assumes hlist local list = getlist(tbox) local done = nil @@ -283,3 +300,9 @@ function commands.applytofirstcharacter(box,what) end end end + +implement { + name = "applytofirstcharacter", + actions = applytofirstcharacter, + arguments = { "integer", "string" } +} diff --git a/tex/context/base/typo-fln.mkiv b/tex/context/base/typo-fln.mkiv index c092fc922..38a53bfa9 100644 --- a/tex/context/base/typo-fln.mkiv +++ b/tex/context/base/typo-fln.mkiv @@ -79,15 +79,15 @@ \begingroup \edef\currentfirstline{#1}% \usefirstlinestyleandcolor\c!style\c!color - \ctxcommand{setfirstline { - alternative = "\firstlineparameter\c!alternative", - ma = \the\attribute\colormodelattribute, - ca = \the\attribute\colorattribute, - ta = \the\attribute\transparencyattribute, - n = \number\firstlineparameter\c!n, - font = \fontid\font, - dynamic = \number\attribute\zerocount, - }}% + \clf_setfirstline + alternative {\firstlineparameter\c!alternative}% + ma \attribute\colormodelattribute + ca \attribute\colorattribute + ta \attribute\transparencyattribute + n \numexpr\firstlineparameter\c!n\relax + font \fontid\font + dynamic \attribute\zerocount + \relax \kern\zeropoint % we need a node % \hskip\zeropoint\s!plus\emwidth\relax % can be an option \endgroup @@ -104,7 +104,7 @@ \unexpanded\def\applytofirstcharacter#1% {\begingroup \dowithnextbox - {\ctxcommand{applytofirstcharacter(\number\nextbox,"\strippedcsname#1")}% + {\clf_applytofirstcharacter\nextbox{\strippedcsname#1}% \unhbox\nextbox \endgroup}% \hbox} diff --git a/tex/context/base/typo-lan.lua b/tex/context/base/typo-lan.lua index 50927f744..c42d2119e 100644 --- a/tex/context/base/typo-lan.lua +++ b/tex/context/base/typo-lan.lua @@ -67,6 +67,8 @@ function frequencies.averagecharwidth(language,font) return frequencycache[language or "en"][font or currentfont()] end -function commands.averagecharwidth(language,font) - context(frequencycache[language or "en"][font or currentfont()]) -end +interfaces.implement { + name = "averagecharwidth", + actions = { frequencies.averagecharwidth, context }, + arguments = "string" +} diff --git a/tex/context/base/typo-lan.mkiv b/tex/context/base/typo-lan.mkiv index bb4ed2042..8b633957b 100644 --- a/tex/context/base/typo-lan.mkiv +++ b/tex/context/base/typo-lan.mkiv @@ -30,7 +30,7 @@ \def\charwidthlanguage{\currentmainlanguage} -\def\averagecharwidth{\dimexpr\ctxcommand{averagecharwidth("\charwidthlanguage")}\scaledpoint\relax} +\def\averagecharwidth{\dimexpr\clf_averagecharwidth{\charwidthlanguage}\scaledpoint\relax} \protect diff --git a/tex/context/base/typo-mar.lua b/tex/context/base/typo-mar.lua index a13b3b56b..fed9e0745 100644 --- a/tex/context/base/typo-mar.lua +++ b/tex/context/base/typo-mar.lua @@ -176,8 +176,6 @@ local texgetcount = tex.getcount local texgetdimen = tex.getdimen local texget = tex.get -local points = number.points - local isleftpage = layouts.status.isleftpage local registertogether = builders.paragraphs.registertogether -- tonode diff --git a/tex/context/base/typo-rep.lua b/tex/context/base/typo-rep.lua index aa75fbf46..d95eff68e 100644 --- a/tex/context/base/typo-rep.lua +++ b/tex/context/base/typo-rep.lua @@ -138,4 +138,8 @@ tasks.disableaction("processors","nodes.handlers.stripping") -- interface -commands.setcharacterstripping = stripping.set +interfaces.implement { + name = "setcharacterstripping", + actions = stripping.set, + arguments = "string" +} diff --git a/tex/context/base/typo-rep.mkiv b/tex/context/base/typo-rep.mkiv index 46b439491..c1146997e 100644 --- a/tex/context/base/typo-rep.mkiv +++ b/tex/context/base/typo-rep.mkiv @@ -38,7 +38,7 @@ \definesystemattribute[stripping][public] \unexpanded\def\setcharacterstripping[#1]% - {\ctxcommand{setcharacterstripping("#1")}} + {\clf_setcharacterstripping{#1}} \unexpanded\def\resetcharacterstripping {\attribute\strippingattribute\attributeunsetvalue} diff --git a/tex/context/base/typo-tal.lua b/tex/context/base/typo-tal.lua index c7c029ed5..5663c3bd9 100644 --- a/tex/context/base/typo-tal.lua +++ b/tex/context/base/typo-tal.lua @@ -74,6 +74,8 @@ local enabled = false local datasets = false +local implement = interfaces.implement + local comma = 0x002C local period = 0x002E local punctuationspace = 0x2008 @@ -141,8 +143,16 @@ end characteralign.setcharacteralign = setcharacteralign characteralign.resetcharacteralign = resetcharacteralign -commands.setcharacteralign = setcharacteralign -commands.resetcharacteralign = resetcharacteralign +implement { + name = "setcharacteralign", + actions = setcharacteralign, + arguments = { "integer", "string" } +} + +implement { + name = "resetcharacteralign", + actions = resetcharacteralign +} local function traced_kern(w) return tracedrule(w,nil,nil,"darkgray") diff --git a/tex/context/base/typo-tal.mkiv b/tex/context/base/typo-tal.mkiv index 91c22332b..570f1a1f5 100644 --- a/tex/context/base/typo-tal.mkiv +++ b/tex/context/base/typo-tal.mkiv @@ -57,8 +57,8 @@ % D \typebuffer \blank \getbuffer \blank \unexpanded\def\signalcharacteralign#1#2{\attribute\characteralignattribute\numexpr#1*\maxcardminusone+#2\relax} % 0xFFFF -\unexpanded\def\setcharacteralign #1#2{\ctxcommand{setcharacteralign(\number#1,"#2")}} -\unexpanded\def\resetcharacteralign {\ctxcommand{resetcharacteralign()}} +\unexpanded\def\setcharacteralign #1#2{\clf_setcharacteralign#1{#2}} +\unexpanded\def\resetcharacteralign {\clf_resetcharacteralign} \unexpanded\def\nocharacteralign {\attribute\characteralignattribute\attributeunsetvalue} %D Mostly downward compatible: diff --git a/tex/context/base/typo-wrp.lua b/tex/context/base/typo-wrp.lua index 1a3aac386..07639392f 100644 --- a/tex/context/base/typo-wrp.lua +++ b/tex/context/base/typo-wrp.lua @@ -67,7 +67,10 @@ function wrappers.handler(head) return head, true end -function commands.enablecrlf() - nodes.tasks.enableaction("processors","typesetters.wrappers.handler") - function commands.enablecrlf() end -end +interfaces.implement { + name = "enablecrlf", + onlyonce = true, + actions = function() + nodes.tasks.enableaction("processors","typesetters.wrappers.handler") + end +} diff --git a/tex/context/base/typo-wrp.mkiv b/tex/context/base/typo-wrp.mkiv index 111e47610..0538a9662 100644 --- a/tex/context/base/typo-wrp.mkiv +++ b/tex/context/base/typo-wrp.mkiv @@ -37,13 +37,9 @@ \expandafter\spac_crlf \fi} -\def\spac_crlf - {\ctxcommand{enablecrlf()}% - \glet\spac_crlf\spac_crlf_indeed - \spac_crlf} - -\unexpanded\def\spac_crlf_indeed - {\unskip +\unexpanded\def\spac_crlf + {\clf_enablecrlf % once + \unskip \prewordbreak % here or in \spac_crlf_placeholder \spac_crlf_placeholder \ifcase\raggedstatus\hfil\or\or\or\hfil\fi diff --git a/tex/context/base/unic-ini.lua b/tex/context/base/unic-ini.lua index cca1f0617..132c92efa 100644 --- a/tex/context/base/unic-ini.lua +++ b/tex/context/base/unic-ini.lua @@ -11,9 +11,13 @@ local utfchar = utf.char -- Beware, initializing unicodechar happens at first usage and takes -- 0.05 -- 0.1 second (lots of function calls). -function commands.unicodechar(asked) - local n = characters.unicodechar(asked) - if n then - context(utfchar(n)) +interfaces.implement { + name = "unicodechar", + arguments = "string", + actions = function(asked) + local n = characters.unicodechar(asked) + if n then + context(utfchar(n)) + end end -end +} diff --git a/tex/context/base/unic-ini.mkiv b/tex/context/base/unic-ini.mkiv index ece0da283..13ad4bdb9 100644 --- a/tex/context/base/unic-ini.mkiv +++ b/tex/context/base/unic-ini.mkiv @@ -26,8 +26,7 @@ %D %D \typebuffer \getbuffer -%def\unicodechar#1{\char\numexpr#1\relax} % no lookahead -\def\unicodechar#1{\ctxcommand{unicodechar("#1")}} +\def\unicodechar#1{\clf_unicodechar{#1}} \unexpanded\def\unknownchar {\dontleavehmode\hbox{\vrule\s!width.5\emwidth\s!height\exheight\s!depth\zeropoint}} diff --git a/tex/context/base/x-asciimath.lua b/tex/context/base/x-asciimath.lua index c9c787d84..4d29e8d31 100644 --- a/tex/context/base/x-asciimath.lua +++ b/tex/context/base/x-asciimath.lua @@ -29,6 +29,8 @@ local asciimath = { } local moduledata = moduledata or { } moduledata.asciimath = asciimath +local implement = interfaces.implement + if not characters then require("char-def") require("char-ini") @@ -1794,7 +1796,11 @@ local function convert(str) end end -commands.asciimath = convert +implement { + name = "asciimath", -- module_asciimath_convert + actions = convert, + arguments = "string" +} local context = context diff --git a/tex/context/base/x-asciimath.mkiv b/tex/context/base/x-asciimath.mkiv index 7007893ae..cc98b54ac 100644 --- a/tex/context/base/x-asciimath.mkiv +++ b/tex/context/base/x-asciimath.mkiv @@ -157,7 +157,7 @@ \to \everysetupasciimath \unexpanded\def\asciimath#1% - {\ctxcommand{asciimath(\!!bs\detokenize\expandafter{\normalexpanded{#1}}\!!es)}} + {\clf_asciimath{\detokenize\expandafter{\normalexpanded{#1}}}} \unexpanded\def\ctxmoduleasciimath#1% {\ctxlua{moduledata.asciimath.#1}} diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 516fa7778..2d65bb5e2 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 04/03/15 20:01:39 +-- merge date : 04/08/15 14:19:47 do -- begin closure to overcome local limits and interference -- cgit v1.2.3