From d48764d88ac59aa9b0130f1049892296a3eb4684 Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Wed, 1 Apr 2015 12:15:05 +0200 Subject: 2015-04-01 12:02:00 --- tex/context/base/back-pdf.lua | 5 + tex/context/base/back-pdf.mkiv | 46 ++--- tex/context/base/cldf-scn.lua | 9 + tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4333 -> 4190 bytes tex/context/base/context.mkiv | 15 +- tex/context/base/core-uti.lua | 38 ++++- tex/context/base/core-uti.mkiv | 4 +- tex/context/base/file-res.lua | 28 ++-- tex/context/base/file-res.mkvi | 6 +- tex/context/base/font-ctx.lua | 24 +++ tex/context/base/grph-epd.mkiv | 2 +- tex/context/base/grph-inc.lua | 19 ++- tex/context/base/grph-inc.mkiv | 14 +- tex/context/base/lang-lab.mkiv | 3 +- tex/context/base/lpdf-col.lua | 6 + tex/context/base/lpdf-fmt.lua | 8 +- tex/context/base/lpdf-ini.lua | 39 ++++- tex/context/base/luat-ini.lua | 186 +-------------------- tex/context/base/luat-ini.mkiv | 82 +-------- tex/context/base/luat-usr.lua | 122 ++++++++++++++ tex/context/base/luat-usr.mkiv | 108 ++++++++++++ tex/context/base/math-ini.mkiv | 2 +- tex/context/base/meta-imp-tab.mkiv | 73 ++++++++ tex/context/base/meta-ini.mkiv | 1 + tex/context/base/meta-pag.mkiv | 96 +++++------ tex/context/base/mult-aux.lua | 12 ++ tex/context/base/mult-aux.mkiv | 4 +- tex/context/base/mult-low.lua | 1 + tex/context/base/node-rul.lua | 47 ++++++ tex/context/base/node-rul.mkiv | 44 ++--- tex/context/base/pack-box.mkiv | 10 +- tex/context/base/page-imp.mkiv | 2 +- tex/context/base/page-inj.lua | 29 +++- tex/context/base/page-inj.mkvi | 14 +- tex/context/base/publ-ini.lua | 4 + tex/context/base/publ-ini.mkiv | 10 +- tex/context/base/publ-jrn.lua | 42 ++++- tex/context/base/status-files.pdf | Bin 24461 -> 24462 bytes tex/context/base/status-lua.pdf | Bin 409131 -> 410661 bytes tex/context/base/strc-bkm.lua | 55 ++++-- tex/context/base/strc-bkm.mkiv | 30 ++-- tex/context/base/strc-con.mkvi | 13 +- tex/context/base/strc-itm.mkvi | 78 ++++----- tex/context/base/strc-ref.lua | 4 +- tex/context/base/syst-aux.lua | 34 ++-- tex/context/base/syst-aux.mkiv | 8 +- tex/context/base/syst-lua.lua | 68 +++++++- tex/context/base/syst-lua.mkiv | 17 +- tex/context/base/syst-rtp.mkiv | 2 +- tex/context/base/toks-scn.lua | 1 - tex/context/base/trac-deb.lua | 19 +++ tex/context/base/trac-deb.mkiv | 34 ++-- tex/context/base/trac-set.lua | 1 + tex/context/base/trac-vis.lua | 22 +-- tex/context/base/trac-vis.mkiv | 30 ++-- tex/context/base/type-ini.mkvi | 8 +- tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 58 files changed, 996 insertions(+), 587 deletions(-) create mode 100644 tex/context/base/luat-usr.lua create mode 100644 tex/context/base/luat-usr.mkiv create mode 100644 tex/context/base/meta-imp-tab.mkiv (limited to 'tex') diff --git a/tex/context/base/back-pdf.lua b/tex/context/base/back-pdf.lua index 8a41d9960..7f0b1acc7 100644 --- a/tex/context/base/back-pdf.lua +++ b/tex/context/base/back-pdf.lua @@ -19,6 +19,7 @@ local context = context local scanners = tokens.scanners local scanstring = scanners.string local scannumber = scanners.number +local scaninteger = scanners.integer local scankeyword = scanners.keyword local scanners = interfaces.scanners @@ -142,4 +143,8 @@ end scanners.pdfstopmirroring = scanners.pdfstartmirroring +scanners.registerbackendsymbol = function() + backends.codeinjections.registersymbol(scanstring(),scaninteger()) +end + -- todo : clipping diff --git a/tex/context/base/back-pdf.mkiv b/tex/context/base/back-pdf.mkiv index 2f8215d16..90e957fd1 100644 --- a/tex/context/base/back-pdf.mkiv +++ b/tex/context/base/back-pdf.mkiv @@ -85,14 +85,14 @@ % \doifsomething{\backendparameter\c!format} .. at the lua end \appendtoks - \ctxcommand{setformat { - format = "\backendparameter\c!format", - level = "\backendparameter\c!level", - option = "\backendparameter\c!option", - profile = "\backendparameter\c!profile", - intent = "\backendparameter\c!intent", - file = "\backendparameter\c!file", - }}% + \clf_setformat + format {\backendparameter\c!format}% + level {\backendparameter\c!level}% + option {\backendparameter\c!option}% + profile {\backendparameter\c!profile}% + intent {\backendparameter\c!intent}% + file {\backendparameter\c!file}% + \relax \to \everysetupbackend %D For the moment we keep these. @@ -102,21 +102,21 @@ %D These are the only official methods to add stuff to the resources. -\unexpanded\def\pdfbackendsetcatalog #1#2{\ctxlua{lpdf.addtocatalog ("#1",\!!bs#2\!!es)}} -\unexpanded\def\pdfbackendsetinfo #1#2{\ctxlua{lpdf.addtoinfo ("#1",\!!bs#2\!!es)}} -\unexpanded\def\pdfbackendsetname #1#2{\ctxlua{lpdf.addtonames ("#1",\!!bs#2\!!es)}} +\unexpanded\def\pdfbackendsetcatalog #1#2{\clf_lpdf_addtocatalog {#1}{#2}} +\unexpanded\def\pdfbackendsetinfo #1#2{\clf_lpdf_addtoinfo {#1}{#2}} +\unexpanded\def\pdfbackendsetname #1#2{\clf_lpdf_addtonames {#1}{#2}} -\unexpanded\def\pdfbackendsetpageattribute #1#2{\ctxlua{lpdf.addtopageattributes ("#1",\!!bs#2\!!es)}} -\unexpanded\def\pdfbackendsetpagesattribute#1#2{\ctxlua{lpdf.addtopagesattributes("#1",\!!bs#2\!!es)}} -\unexpanded\def\pdfbackendsetpageresource #1#2{\ctxlua{lpdf.addtopageresources ("#1",\!!bs#2\!!es)}} +\unexpanded\def\pdfbackendsetpageattribute #1#2{\clf_lpdf_addtopageattributes {#1}{#2}} +\unexpanded\def\pdfbackendsetpagesattribute#1#2{\clf_lpdf_addtopagesattributes {#1}{#2}} +\unexpanded\def\pdfbackendsetpageresource #1#2{\clf_lpdf_addtopageresources {#1}{#2}} -\unexpanded\def\pdfbackendsetextgstate #1#2{\ctxlua{lpdf.adddocumentextgstate ("#1",lpdf.verbose(\!!bs#2\!!es))}} -\unexpanded\def\pdfbackendsetcolorspace #1#2{\ctxlua{lpdf.adddocumentcolorspace("#1",lpdf.verbose(\!!bs#2\!!es))}} -\unexpanded\def\pdfbackendsetpattern #1#2{\ctxlua{lpdf.adddocumentpattern ("#1",lpdf.verbose(\!!bs#2\!!es))}} -\unexpanded\def\pdfbackendsetshade #1#2{\ctxlua{lpdf.adddocumentshade ("#1",lpdf.verbose(\!!bs#2\!!es))}} +\unexpanded\def\pdfbackendsetextgstate #1#2{\clf_lpdf_adddocumentextgstate {#1}{#2}} +\unexpanded\def\pdfbackendsetcolorspace #1#2{\clf_lpdf_adddocumentcolorspace{#1}{#2}} +\unexpanded\def\pdfbackendsetpattern #1#2{\clf_lpdf_adddocumentpattern {#1}{#2}} +\unexpanded\def\pdfbackendsetshade #1#2{\clf_lpdf_adddocumentshade {#1}{#2}} - \def\pdfbackendcurrentresources {\cldcontext{lpdf.collectedresources()}} - \def\pdfcolor #1{\cldcontext{lpdf.pdfcolor(\thecolorattribute{#1})}} + \def\pdfbackendcurrentresources {\clf_lpdf_collectedresources} + \def\pdfcolor #1{\clf_lpdf_color\numexpr\thecolorattribute{#1}\relax} \let\PDFcolor\pdfcolor %D An example of usage is: @@ -326,7 +326,7 @@ \xdef\lastpredefinedsymbol{#1}% \settightobject{SYM}{#1}\hbox{\symbol[#1]}% to be checked ... maybe only fitting \dogetobjectreference{SYM}{#1}\m_back_object_reference - \ctxlua{backends.codeinjections.registersymbol("#1",\m_back_object_reference)}% + \clf_registerbackendsymbol{#1}\m_back_object_reference\relax \endgroup} % for the moment here @@ -579,9 +579,9 @@ \egroup} \unexpanded\def\pdfbackendactualtext#1#2% not interfaced - {\ctxcommand{startactualtext(\!!bs#2\!!es)}% + {\clf_startactualtext{#2}% #1% - \ctxcommand{stopactualtext()}} + \clf_stopactualtext} \let\pdfactualtext\pdfbackendactualtext diff --git a/tex/context/base/cldf-scn.lua b/tex/context/base/cldf-scn.lua index 5948fdeaf..e87736033 100644 --- a/tex/context/base/cldf-scn.lua +++ b/tex/context/base/cldf-scn.lua @@ -114,3 +114,12 @@ end interfaces.setmacro = tokens.setters.macro interfaces.setcount = tokens.setters.count interfaces.setdimen = tokens.setters.dimen + +interfaces.strings = table.setmetatableindex(function(t,k) + local v = { } + for i=1,k do + v[i] = "string" + end + t[k] = v + return v +end) diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 139afb2a3..0eae7d27d 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.03.31 12:04} +\newcontextversion{2015.04.01 12:00} %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/context-version.pdf b/tex/context/base/context-version.pdf index 6c9b3a8c3..93a090e6a 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 646c99cb4..257fd1712 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -11,6 +11,17 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. +% Here is some timing (2015-04-01) luajittex format generation: +% +% 2.6 sec : normal make +% 2.0 sec : with terminal output piped to file +% 0.2 sec : format dumped +% 0.2 sec : char-def/char-ini (no bytecode) +% +% So a format still saves some 1.5 seconds (with luajjitex) startup and +% on network shares cq. when no files are cached by the os it's of course +% much worse. A zero run is .27 sec with luajittex. + % Welcome to context, pronounced as kontekst (rather dutch) and not as % conτεχt. @@ -28,7 +39,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2015.03.31 12:04} +\edef\contextversion{2015.04.01 12:00} \edef\contextkind {beta} %D For those who want to use this: @@ -109,6 +120,8 @@ \loadmarkfile{syst-fnt} \loadmarkfile{syst-rtp} +\loadmarkfile{luat-usr} + % \loadmarkfile{luat-ini} % moved up % \loadmarkfile{toks-ini} % moved up diff --git a/tex/context/base/core-uti.lua b/tex/context/base/core-uti.lua index b6ddf775e..9faf9ad30 100644 --- a/tex/context/base/core-uti.lua +++ b/tex/context/base/core-uti.lua @@ -64,7 +64,8 @@ end job.comment("version",job.version) -local enabled = true +local enabled = true +local initialized = false directives.register("job.save",function(v) enabled = v end) ----------.register("job.keep",function(v) kept = v end) @@ -74,15 +75,24 @@ function job.disablesave() -- can be command end function job.initialize(loadname,savename) - job.load(loadname) -- has to come after structure is defined ! - luatex.registerstopactions(function() - if enabled and not status.lasterrorstring or status.lasterrorstring == "" then - -- if kept then - -- job.keep(loadname) -- could move to mtx-context instead - -- end - job.save(savename) + if not initialized then + if not loadname or loadname == "" then + loadname = tex.jobname .. ".tuc" + end + if not savename or savename == "" then + savename = tex.jobname .. ".tua" end - end) + job.load(loadname) -- has to come after structure is defined ! + luatex.registerstopactions(function() + if enabled and not status.lasterrorstring or status.lasterrorstring == "" then + -- if kept then + -- job.keep(loadname) -- could move to mtx-context instead + -- end + job.save(savename) + end + end) + initialized = true + end end function job.register(collected, tobesaved, initializer, finalizer, serializer) @@ -391,3 +401,13 @@ implement { actions = job.comment, arguments = { { "*" } } } + +implement { + name = "initializejob", + actions = job.initialize +} + +implement { + name = "disablejobsave", + actions = job.disablesave +} diff --git a/tex/context/base/core-uti.mkiv b/tex/context/base/core-uti.mkiv index 1fb8f0b57..cdd8958ff 100644 --- a/tex/context/base/core-uti.mkiv +++ b/tex/context/base/core-uti.mkiv @@ -30,9 +30,7 @@ \to \everystarttext \appendtoks - \ctxlua { - job.initialize(tex.jobname .. ".tuc",tex.jobname .. ".tua") - }% + \clf_initializejob \to \everyjob \protect \endinput diff --git a/tex/context/base/file-res.lua b/tex/context/base/file-res.lua index 78fdc3404..a1c4986b5 100644 --- a/tex/context/base/file-res.lua +++ b/tex/context/base/file-res.lua @@ -149,16 +149,24 @@ end resolvers.getreadfilename = getreadfilename -function commands.getreadfilename(scheme,path,name) - context(getreadfilename(scheme,path,name)) -end - -- a name belonging to the run but also honoring qualified -function commands.locfilename(name) - context(getreadfilename("loc",".",name)) -end +local implement = interfaces.implement -function commands.doiflocfileelse(name) - commands.doifelse(isfile(getreadfilename("loc",".",name))) -end +implement { + name = "getreadfilename", + actions = { getreadfilename, context }, + arguments = { "string", "string", "string" } +} + +implement { + name = "locfilename", + actions = { getreadfilename, context }, + arguments = { "'loc'","'.'", "string" }, +} + +implement { + name = "doiflocfileelse", + actions = { getreadfilename, isfile, commands.doifelse }, + arguments = { "'loc'","'.'", "string" }, +} diff --git a/tex/context/base/file-res.mkvi b/tex/context/base/file-res.mkvi index 5162e63be..2799254d2 100644 --- a/tex/context/base/file-res.mkvi +++ b/tex/context/base/file-res.mkvi @@ -70,7 +70,7 @@ \let\readfilename\empty \def\syst_files_read_file#protocol#path#name% #true #false - {\edef\readfilename{\ctxcommand{getreadfilename("#protocol","#path","#name")}}% + {\edef\readfilename{\clf_getreadfilename{#protocol}{#path}{#name}}% \ifx\readfilename\empty \expandafter\secondoftwoarguments \else @@ -145,7 +145,7 @@ %D \doiflocfileelse {filename} {before loading} {not found} %D \stoptyping -\unexpanded\def\doiflocfileelse#name{\ctxcommand{doiflocfileelse([[#name]])}} - \def\locfilename #name{\ctxcommand{locfilename([[#name]])}} +\unexpanded\def\doiflocfileelse#name{\clf_doiflocfileelse{#name}} + \def\locfilename #name{\clf_locfilename {#name}} \protect \endinput diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua index 0a0e5eab6..d55bf2dad 100644 --- a/tex/context/base/font-ctx.lua +++ b/tex/context/base/font-ctx.lua @@ -1484,6 +1484,24 @@ end mappings.reset() -- resets the default file +implement { + name = "loadmapfile", + actions = mappings.loadfile, + arguments = "string" +} + +implement { + name = "loadmapline", + actions = mappings.loadline, + arguments = "string" +} + +implement { + name = "resetmapfiles", + actions = mappings.reset, + arguments = "string" +} + -- we need an 'do after the banner hook' -- => commands @@ -1770,6 +1788,12 @@ function fonts.definetypeface(name,t) ctx_dofastdefinetypeface(name, shortcut, shape, size, settings) end +implement { + name = "definetypeface", + actions = fonts.definetypeface, + arguments = { "string", "string" } +} + function fonts.current() -- todo: also handle name return fontdata[currentfont()] or fontdata[0] end diff --git a/tex/context/base/grph-epd.mkiv b/tex/context/base/grph-epd.mkiv index 444fa55a6..66984618a 100644 --- a/tex/context/base/grph-epd.mkiv +++ b/tex/context/base/grph-epd.mkiv @@ -17,7 +17,7 @@ \registerctxluafile{grph-epd}{1.001} -\def\figurereference{\ctxcommand{figurestatus("reference")}} % might become private +\def\figurereference{\clf_figurestatus{reference}{}} % might become private \defineoverlay[system:graphics:epdf][\directsetup{system:graphics:epdf}] diff --git a/tex/context/base/grph-inc.lua b/tex/context/base/grph-inc.lua index 751a6fa63..c538c5759 100644 --- a/tex/context/base/grph-inc.lua +++ b/tex/context/base/grph-inc.lua @@ -1103,7 +1103,7 @@ function figures.identify(data) for i=1,#list do local identifier = list[i] local data = identifier(data) - if data.status and data.status.status > 0 then + if data and (not data.status and data.status.status > 0) then break end end @@ -2034,4 +2034,19 @@ implement { name = "figure_scale", scope = "private", actions = figures.scale implement { name = "figure_check", scope = "private", actions = figures.check } implement { name = "figure_include", scope = "private", actions = figures.include } -implement { name = "setfigurelookuporder", actions = figures.setorder, arguments = "string" } +implement { + name = "setfigurelookuporder", + actions = figures.setorder, + arguments = "string" +} + +implement { + name = "figure_reset", + scope = "private", + arguments = { "integer", "dimen", "dimen" }, + actions = function(box,width,height) + figures.boxnumber = box + figures.defaultwidth = width + figures.defaultheight = height + end +} diff --git a/tex/context/base/grph-inc.mkiv b/tex/context/base/grph-inc.mkiv index b3a21f073..1f1c0054d 100644 --- a/tex/context/base/grph-inc.mkiv +++ b/tex/context/base/grph-inc.mkiv @@ -510,12 +510,14 @@ \fi} \appendtoks - \clf_setfigurepaths{\externalfigureparameter\c!location}{\externalfigureparameter\c!directory}% - \ctxlua { % figures.defaultwidth .. maybe a dimen some day - figures.defaultwidth = \number\dimexpr\defaultfigurewidth \relax ; - figures.defaultheight = \number\dimexpr\defaultfigureheight\relax ; - figures.boxnumber = \number\foundexternalfigure ; - }% + \clf_setfigurepaths + {\externalfigureparameter\c!location}% + {\externalfigureparameter\c!directory}% + \clf_figure_reset + \foundexternalfigure + \defaultfigurewidth + \defaultfigureheight + \relax \to \everyexternalfigureresets \appendtoks diff --git a/tex/context/base/lang-lab.mkiv b/tex/context/base/lang-lab.mkiv index afa9f2b2b..9b6989903 100644 --- a/tex/context/base/lang-lab.mkiv +++ b/tex/context/base/lang-lab.mkiv @@ -181,7 +181,8 @@ \grabuntil{stop#1text}\lang_labels_text_prefix_start_indeed} \def\lang_labels_text_prefix_start_indeed#1% text (not special checking done here yet, only for long texts anyway) - {\expandafter\edef\csname\??label\currenttextprefixclass:\currenttextprefixtag:\currenttextprefixname\endcsname{{\ctxcommand{strip(\!!bs#1\!!es)}}\empty}} + {\expandafter\edef\csname\??label\currenttextprefixclass:\currenttextprefixtag:\currenttextprefixname\endcsname% + {{\clf_strip{#1}}\empty}} \def\lang_labels_text_prefix_setup[#1][#2]% {\ifsecondargument diff --git a/tex/context/base/lpdf-col.lua b/tex/context/base/lpdf-col.lua index a2fda8ca5..877c01a1c 100644 --- a/tex/context/base/lpdf-col.lua +++ b/tex/context/base/lpdf-col.lua @@ -532,6 +532,12 @@ end lpdf.color = lpdfcolor +interfaces.implement { + name = "lpdf_color", + actions = { lpdfcolor, context }, + arguments = "integer" +} + function lpdf.colorspec(model,ca,default) if ca and ca > 0 then local cv = colors.value(ca) diff --git a/tex/context/base/lpdf-fmt.lua b/tex/context/base/lpdf-fmt.lua index 9a5005782..862c011b8 100644 --- a/tex/context/base/lpdf-fmt.lua +++ b/tex/context/base/lpdf-fmt.lua @@ -734,9 +734,11 @@ directives.register("backend.format", function(v) -- table ! end end) -function commands.setformat(s) - codeinjections.setformat(s) -end +interfaces.implement { + name = "setformat", + actions = codeinjections.setformat, + arguments = { { "*" } } +} function codeinjections.getformatoption(key) return formatspecification and formatspecification[key] diff --git a/tex/context/base/lpdf-ini.lua b/tex/context/base/lpdf-ini.lua index d6f5ef197..834f845c5 100644 --- a/tex/context/base/lpdf-ini.lua +++ b/tex/context/base/lpdf-ini.lua @@ -20,6 +20,9 @@ local report_objects = logs.reporter("backend","objects") local report_finalizing = logs.reporter("backend","finalizing") local report_blocked = logs.reporter("backend","blocked") +local implement = interfaces.implement +local two_strings = interfaces.strings[2] + -- In ConTeXt MkIV we use utf8 exclusively so all strings get mapped onto a hex -- encoded utf16 string type between <>. We could probably save some bytes by using -- strings between () but then we end up with escaped ()\ too. @@ -1175,12 +1178,36 @@ do end end - function commands.startactualtext(str) - context(pdfdirect(f_actual_text(tosixteen(str)))) - end + implement { + name = "startactualtext", + arguments = "string", + actions = function(str) + context(pdfdirect(f_actual_text(tosixteen(str)))) + end + } - function commands.stopactualtext() - context(pdfdirect("EMC")) - end + implement { + name = "stopactualtext", + actions = function() + context(pdfdirect("EMC")) + end + } end + +-- interface + +local lpdfverbose = lpdf.verbose + +implement { name = "lpdf_collectedresources", actions = { lpdf.collectedresources, context } } +implement { name = "lpdf_addtocatalog", arguments = two_strings, actions = lpdf.addtocatalog } +implement { name = "lpdf_addtoinfo", arguments = two_strings, actions = lpdf.addtoinfo } +implement { name = "lpdf_addtonames", arguments = two_strings, actions = lpdf.addtonames } +implement { name = "lpdf_addpageattributes", arguments = two_strings, actions = lpdf.addtopageattributes } +implement { name = "lpdf_addpagesattributes", arguments = two_strings, actions = lpdf.addtopagesattributes } +implement { name = "lpdf_addpageresources", arguments = two_strings, actions = lpdf.addtopageresources } +implement { name = "lpdf_adddocumentextgstate", arguments = two_strings, actions = function(a,b) lpdf.adddocumentextgstate (a,lpdfverbose(b)) end } +implement { name = "lpdf_adddocumentcolorspace", arguments = two_strings, actions = function(a,b) lpdf.adddocumentcolorspace(a,lpdfverbose(b)) end } +implement { name = "lpdf_adddocumentpattern", arguments = two_strings, actions = function(a,b) lpdf.adddocumentpattern (a,lpdfverbose(b)) end } +implement { name = "lpdf_adddocumentshade", arguments = two_strings, actions = function(a,b) lpdf.adddocumentshade (a,lpdfverbose(b)) end } + diff --git a/tex/context/base/luat-ini.lua b/tex/context/base/luat-ini.lua index 9303b614a..34e83e7bb 100644 --- a/tex/context/base/luat-ini.lua +++ b/tex/context/base/luat-ini.lua @@ -6,14 +6,6 @@ if not modules then modules = { } end modules ['luat-ini'] = { license = "see context related readme files" } --- rather experimental down here ... adapted to lua 5.2 ... but still --- experimental - -local debug = require("debug") - -local string, table, lpeg, math, io, system = string, table, lpeg, math, io, system -local rawset, rawget, next, setmetatable = rawset, rawget, next, setmetatable - --[[ldx--

We cannot load anything yet. However what we will do us reserve a few tables. These can be used for runtime user data or third party modules and will not be @@ -29,180 +21,6 @@ parametersets = parametersets or { } -- experimental for team table.setmetatableindex(moduledata,table.autokey) table.setmetatableindex(thirddata, table.autokey) ---[[ldx-- -

Please create a namespace within these tables before using them!

- - -userdata ['my.name'] = { } -thirddata['tricks' ] = { } - ---ldx]]-- - ---[[ldx-- -

We could cook up a readonly model for global tables but it makes more sense -to invite users to use one of the predefined namespaces. One can redefine the -protector. After all, it's just a lightweight suggestive system, not a -watertight one.

---ldx]]-- - -local global = _G -global.global = global - -local dummy = function() end - ---[[ldx-- -

Another approach is to freeze tables by using a metatable, this will be -implemented stepwise.

---ldx]]-- - --- moduledata : no need for protection (only for developers) --- isolatedata : full protection --- userdata : protected --- thirddata : protected - ---[[ldx-- -

We could have a metatable that automaticaly creates a top level namespace.

---ldx]]-- - -local luanames = lua.name -- luatex itself - -lua.numbers = lua.numbers or { } local numbers = lua.numbers -lua.messages = lua.messages or { } local messages = lua.messages - -storage.register("lua/numbers", numbers, "lua.numbers" ) -storage.register("lua/messages", messages, "lua.messages") - -local f_message = string.formatters["=[instance: %s]"] -- the = controls the lua error / see: lobject.c - -local setfenv = setfenv or debug.setfenv -- < 5.2 - -if setfenv then - - local protected = { - -- global table - global = global, - -- user tables - -- moduledata = moduledata, - userdata = userdata, - thirddata = thirddata, - documentdata = documentdata, - -- reserved - protect = dummy, - unprotect = dummy, - -- luatex - tex = tex, - -- lua - string = string, - table = table, - lpeg = lpeg, - math = math, - io = io, - file = file, - bit32 = bit32, - -- - context = context, - } - - local protect_full = function(name) - local t = { } - for k, v in next, protected do - t[k] = v - end - return t - end - - local protect_part = function(name) -- adds - local t = rawget(global,name) - if not t then - t = { } - for k, v in next, protected do - t[k] = v - end - rawset(global,name,t) - end - return t - end - - protect = function(name) - if name == "isolateddata" then - setfenv(2,protect_full(name)) - else - setfenv(2,protect_part(name or "shareddata")) - end - end - - function lua.registername(name,message) - local lnn = lua.numbers[name] - if not lnn then - lnn = #messages + 1 - messages[lnn] = message - numbers[name] = lnn - end - luanames[lnn] = message - context(lnn) - -- initialize once - if name ~= "isolateddata" then - protect_full(name or "shareddata") - end - end - -elseif libraries then -- assume >= 5.2 - - local shared - - protect = function(name) - if not shared then - -- e.g. context is not yet known - local public = { - global = global, - -- moduledata = moduledata, - userdata = userdata, - thirddata = thirddata, - documentdata = documentdata, - protect = dummy, - unprotect = dummy, - context = context, - } - -- - for k, v in next, libraries.builtin do public[k] = v end - for k, v in next, libraries.functions do public[k] = v end - for k, v in next, libraries.obsolete do public[k] = nil end - -- - shared = { __index = public } - protect = function(name) - local t = global[name] or { } - setmetatable(t,shared) -- set each time - return t - end - end - return protect(name) - end - - function lua.registername(name,message) - local lnn = lua.numbers[name] - if not lnn then - lnn = #messages + 1 - messages[lnn] = message - numbers[name] = lnn - end - luanames[lnn] = f_message(message) - context(lnn) - end - -else - - protect = dummy - - function lua.registername(name,message) - local lnn = lua.numbers[name] - if not lnn then - lnn = #messages + 1 - messages[lnn] = message - numbers[name] = lnn - end - luanames[lnn] = f_message(message) - context(lnn) - end - +if not global then + global = _G end - diff --git a/tex/context/base/luat-ini.mkiv b/tex/context/base/luat-ini.mkiv index f2355da2a..37d84ccce 100644 --- a/tex/context/base/luat-ini.mkiv +++ b/tex/context/base/luat-ini.mkiv @@ -101,78 +101,6 @@ \edef\luamajorversion{\ctxwrite{_MINORVERSION}} \edef\luaminorversion{\ctxwrite{_MAJORVERSION}} -%D \macros -%D {definenamedlua} -%D -%D We provide an interface for defining instances: - -\def\s!lua {lua} -\def\s!code {code} -\def\s!data {data} -\def\s!start{start} -\def\s!stop {stop} - -%D Beware: because \type {\expanded} is een convert command, the error -%D message will show \type{} as part of the message. - -\installsystemnamespace{luacode} - -\normalprotected\def\luat_start_named_lua_code#1% - {\begingroup - \obeylualines - \obeyluatokens - \csname\??luacode#1\endcsname} - -\normalprotected\def\definenamedlua[#1]#2[#3]% no optional arg handling here yet / we could use numbers instead (more efficient) - {\ifcsname\??luacode#1\endcsname \else - \expandafter\chardef\csname\??luacode:#1\endcsname\ctxlua{lua.registername("#1","#3")}% - \normalexpanded{\xdef\csname\??luacode#1\endcsname##1\csname\s!stop#1\s!code\endcsname}% - {\noexpand\normalexpanded{\endgroup\noexpand\directlua\csname\??luacode:#1\endcsname{_G=protect("#1\s!data")##1}}}% - \expandafter\edef\csname\s!start#1\s!code\endcsname {\luat_start_named_lua_code{#1}}% - \expandafter\edef\csname #1\s!code\endcsname##1{\noexpand\directlua\csname\??luacode:#1\endcsname{_G=protect("#1\s!data")##1}}% - \fi} - -%D We predefine a few. - -% \definenamedlua[module][module instance] % not needed - -\definenamedlua[user] [private user] -\definenamedlua[third] [third party module] -\definenamedlua[isolated][isolated] - -%D In practice this works out as follows: -%D -%D \startbuffer -%D \startluacode -%D context("LUA") -%D \stopluacode -%D -%D \startusercode -%D global.context("USER 1") -%D context.par() -%D context("USER 2") -%D context.par() -%D if characters then -%D context("ACCESS directly") -%D elseif global.characters then -%D context("ACCESS via global") -%D else -%D context("NO ACCESS at all") -%D end -%D context.par() -%D if bogus then -%D context("ACCESS directly") -%D elseif global.bogus then -%D context("ACCESS via global") -%D else -%D context("NO ACCESS at all") -%D end -%D context.par() -%D \stopusercode -%D \stopbuffer -%D -%D \typebuffer - %D We need a way to pass strings safely to \LUA\ without the %D need for tricky escaping. Compare: %D @@ -291,9 +219,6 @@ \normalprotected\def\startctxfunctiondefinition #1 % {\begingroup \obeylualines \obeyluatokens \luat_start_lua_function_definition_indeed{#1}} -% \def\luat_start_lua_function_definition_indeed#1#2\stopctxfunctiondefinition -% {\endgroup\expandafter\edef\csname#1\endcsname{\noexpand\luafunction\ctxcommand{ctxfunction(\!!bs#2\!!es)}\relax}} - \installsystemnamespace{luafunction} \def\luat_start_lua_function_definition_indeed#1#2\stopctxfunctiondefinition @@ -301,9 +226,6 @@ \expandafter\chardef\csname\??luafunction#1\endcsname\ctxcommand{ctxfunction(\!!bs#2\!!es)}\relax \expandafter\edef\csname#1\endcsname{\noexpand\luafunction\csname\??luafunction#1\endcsname}} -% \normalprotected\def\setctxluafunction#1#2% experiment -% {\expandafter\chardef\csname#1\endcsname#2\relax} - \normalprotected\def\setctxluafunction#1#2% experiment {\expandafter\chardef\csname\??luafunction#1\endcsname#2\relax \expandafter\edef\csname#1\endcsname{\noexpand\luafunction\csname\??luafunction#1\endcsname}} @@ -343,7 +265,7 @@ {\if\noexpand#1\letterbackslash\else#1\fi} \normalprotected\def\installctxfunction#1#2% - {\expandafter\chardef\csname\??luafunction\checkedstrippedcsname#1\endcsname\ctxcommand{ctxfunction("#2",true)}\relax - \expandafter\edef\csname\checkedstrippedcsname#1\endcsname{\noexpand\luafunction\csname\??luafunction\checkedstrippedcsname#1\endcsname}} + {\global\expandafter\chardef\csname\??luafunction\checkedstrippedcsname#1\endcsname\ctxcommand{ctxfunction("#2",true)}\relax + \expandafter\xdef\csname\checkedstrippedcsname#1\endcsname{\noexpand\luafunction\csname\??luafunction\checkedstrippedcsname#1\endcsname}} \protect \endinput diff --git a/tex/context/base/luat-usr.lua b/tex/context/base/luat-usr.lua new file mode 100644 index 000000000..e84cacab3 --- /dev/null +++ b/tex/context/base/luat-usr.lua @@ -0,0 +1,122 @@ +if not modules then modules = { } end modules ['luat-usr'] = { + version = 1.001, + comment = "companion to luat-lib.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local global = global + +local moduledata = moduledata +local thirddata = thirddata +local userdata = userdata +local documentdata = documentdata + +local context = context +local tostring = tostring +local tonumber = tonumber +local print = print + +local string = string +local table = table +local lpeg = lpeg +local math = math +local io = io +local os = os +local lpeg = lpeg + +local luanames = lua.name -- luatex itself + +local setmetatableindex = table.setmetatableindex +local load = load +local xpcall = xpcall +local instance_banner = string.formatters["=[instance: %s]"] -- the = controls the lua error / see: lobject.c +local tex_errormessage = context.errmessage + +local implement = interfaces.implement +local reporter = logs.reporter + +local report = reporter("lua instance") + +lua.numbers = lua.numbers or { } +lua.messages = lua.messages or { } + +local numbers = lua.numbers +local messages = lua.messages + +storage.register("lua/numbers", numbers, "lua.numbers" ) +storage.register("lua/messages", messages, "lua.messages") + +local function registername(name,message) + if not name or name == "" then + report("no valid name given") + return + end + if not message or message == "" then + message = name + end + if not message or message == "" then + message = name + end + local lnn = numbers[name] + if not lnn then + lnn = #messages + 1 + messages[lnn] = message + numbers[name] = lnn + end + luanames[lnn] = instance_banner(message) + local report = reporter("lua instance",message) + local proxy = { + -- we can access all via: + global = global, + -- some protected data + moduledata = setmetatableindex(moduledata), -- + thirddata = setmetatableindex(thirddata), + -- less protected data + userdata = userdata, + documentdata = documentdata, + -- always there fast + context = context, + tostring = tostring, + tonumber = tonumber, + -- standard lua modules + string = string, + table = table, + lpeg = lpeg, + math = math, + io = io, + os = os, + lpeg = lpeg, + -- + print = print, + report = report, + } + return function(code) + local code, message = load(code,nil,nil,proxy) + if not code then + report("error: %s",message or code) + elseif not xpcall(code,report) then + tex_errormessage("hit return to continue or quit this run") + end + end +end + +lua.registername = registername + +implement { + name = "registernamedlua", + arguments = { "string", "string", "string" }, + actions = function(name,message,csname) + if csname and csname ~= "" then + implement { + name = csname, + arguments = "string", + actions = registername(name,message) or report, + scope = "private", + } + else + report("unvalid csname for %a",message or name or "?") + end + end +} diff --git a/tex/context/base/luat-usr.mkiv b/tex/context/base/luat-usr.mkiv new file mode 100644 index 000000000..648a806af --- /dev/null +++ b/tex/context/base/luat-usr.mkiv @@ -0,0 +1,108 @@ +%D \module +%D [ file=luat-usr, +%D version=2005.08.11,% moved from luat-ini +%D title=\CONTEXT\ Lua Macros, +%D subtitle=Initialization, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Lua Macros / Userspace} + +\unprotect + +\registerctxluafile{luat-usr}{1.001} + +%D \macros +%D {definenamedlua} +%D +%D We provide an interface for defining instances: + +\def\s!lua {lua} +\def\s!code {code} +\def\s!data {data} +%def\s!start{start} +%def\s!stop {stop} + +%D Beware: because \type {\expanded} is een convert command, the error +%D message will show \type{} as part of the message. + +\installsystemnamespace{luacode} + +\unexpanded\def\definenamedlua + {\bgroup + \dodoubleempty\syst_definenamedlua} + +\unexpanded\def\syst_definenamedlua[#1][#2]% no optional arg handling here yet / we could use numbers instead (more efficient) + {\iffirstargument + \ifcsname\??luacode#1\endcsname \else + % + \edef\fullname{lua_code_#1}% + % + \clf_registernamedlua{#1}{#2}{\fullname}% + % + \unexpanded\expandafter\xdef\csname\s!start#1\s!code\endcsname + {\begingroup + \obeylualines + \obeyluatokens + \csname\??luacode#1\endcsname}% + % + \global\expandafter\let\csname\s!stop#1\s!code\endcsname\relax + % + \normalexpanded{\xdef\csname\??luacode#1\endcsname##1\csname\s!stop#1\s!code\endcsname}% + {\noexpand\expandafter\endgroup + \noexpand\expandafter + \expandafter\noexpand\csname clf_\fullname\endcsname + \noexpand\expandafter{\noexpand\normalexpanded{##1}}}% + % + \global\expandafter\let\csname#1\s!code\expandafter\endcsname\csname clf_\fullname\endcsname + \fi + \fi + \egroup} + +%D We predefine a few. + +% \definenamedlua[module][module instance] % not needed + +\definenamedlua[user] [private user] +\definenamedlua[third] [third party module] +\definenamedlua[isolated][isolated] + +%D In practice this works out as follows: +%D +%D \startbuffer +%D \startluacode +%D context("LUA") +%D \stopluacode +%D +%D \startusercode +%D global.context("USER 1") +%D context.par() +%D context("USER 2") +%D context.par() +%D if characters then +%D context("ACCESS directly") +%D elseif global.characters then +%D context("ACCESS via global") +%D else +%D context("NO ACCESS at all") +%D end +%D context.par() +%D if bogus then +%D context("ACCESS directly") +%D elseif global.bogus then +%D context("ACCESS via global") +%D else +%D context("NO ACCESS at all") +%D end +%D context.par() +%D \stopusercode +%D \stopbuffer +%D +%D \typebuffer + +\protect \endinput diff --git a/tex/context/base/math-ini.mkiv b/tex/context/base/math-ini.mkiv index 1c6179523..c59ab1849 100644 --- a/tex/context/base/math-ini.mkiv +++ b/tex/context/base/math-ini.mkiv @@ -897,7 +897,7 @@ \to \everysetupmathematics \setupmathematics - [\c!compact=no] + [\c!compact=\v!no] % \enabletrackers[typesetters.directions.math] diff --git a/tex/context/base/meta-imp-tab.mkiv b/tex/context/base/meta-imp-tab.mkiv new file mode 100644 index 000000000..a4affbea4 --- /dev/null +++ b/tex/context/base/meta-imp-tab.mkiv @@ -0,0 +1,73 @@ +%D \module +%D [ file=meta-tab, +%D version=2003.03.21, % very old but now with splitter +%D title=\METAPOST\ Graphics, +%D subtitle=Dummy (External) Graphics, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\startuseMPgraphic{TallyBar} + height := (10/12) * LineHeight ; + span := ( 4/10) * LineHeight ; + drift := ( 1/10) * LineHeight ; + def d = (uniformdeviate drift) enddef ; + for i := 1 upto \MPvar{n} : + draw + if (i mod 5)=0 : + ((-d-4.5span,d)--(+d-0.5span,height-d)) + else : + ((-d,+d)--(+d,height-d)) + fi + shifted (span*i,d-drift) withpen pencircle ; + endfor ; + currentpicture := currentpicture scaled .75 ; +\stopuseMPgraphic + +\setupMPvariables + [TallyBar] + [n=0] + +\unexpanded\def\tallynumeral#1% + {\dontleavehmode + \lower.25\exheight\hbox{\useMPgraphic{TallyBar}{n=#1}}} + +\unexpanded\def\tallynumerals#1% + {\dontleavehmode + \begingroup + \scratchcounter#1\relax + \doloop + {\ifnum\scratchcounter>\plusfive + \lower.25\exheight\hbox{\useMPgraphic{TallyBar}{n=5}}% + \advance\scratchcounter-\plusfive + \space + \else + \lower.25\exheight\hbox{\useMPgraphic{TallyBar}{n=\the\scratchcounter}}% + \exitloop + \fi}% + \endgroup} + +\let\FunnyBar\tallynumeral + +\defineconversion[tally][\tallynumerals] + +\continueifinputfile{meta-imp-tab.mkiv} + +\starttext + + \starttabulate[|pr|c|] + \NC \tallynumerals {24} \NC \NR + \NC \tallynumerals {12} \NC \times \NR + \HL + \NC \tallynumerals{288} \NC = \NR + \stoptabulate + + \tallynumerals{"FFFF} + +\stoptext + +\endinput diff --git a/tex/context/base/meta-ini.mkiv b/tex/context/base/meta-ini.mkiv index 2c4023de8..5628a6744 100644 --- a/tex/context/base/meta-ini.mkiv +++ b/tex/context/base/meta-ini.mkiv @@ -219,6 +219,7 @@ \defineMPinstance[metafun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes] \defineMPinstance[extrafun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes] +\defineMPinstance[lessfun] [\s!format=metafun] \defineMPinstance[doublefun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!double] \defineMPinstance[binaryfun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!binary] \defineMPinstance[decimalfun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!decimal] diff --git a/tex/context/base/meta-pag.mkiv b/tex/context/base/meta-pag.mkiv index a25353b18..4f4d0de3f 100644 --- a/tex/context/base/meta-pag.mkiv +++ b/tex/context/base/meta-pag.mkiv @@ -41,56 +41,52 @@ % maybe always set as frozen anyway \startMPinitializations - % def LoadPageState = - 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; - def LoadPageState = - % now always set .. this dummy can move to the mp code - enddef; + 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 \def\MPonrightpage{true} diff --git a/tex/context/base/mult-aux.lua b/tex/context/base/mult-aux.lua index 5a103213c..353b5e69c 100644 --- a/tex/context/base/mult-aux.lua +++ b/tex/context/base/mult-aux.lua @@ -154,3 +154,15 @@ function namespaces.list() local keys = { "type", "name", "comment", "version", "parent", "definition", "setup", "style" } utilities.formatters.list(data,"namespace",keys) end + + +interfaces.implement { + name = "definenamespace", + arguments = { "string", "string" }, + actions = namespaces.define +} + +interfaces.implement { + name = "listnamespaces", + actions = namespaces.list +} diff --git a/tex/context/base/mult-aux.mkiv b/tex/context/base/mult-aux.mkiv index bc178fdb6..17a7a5224 100644 --- a/tex/context/base/mult-aux.mkiv +++ b/tex/context/base/mult-aux.mkiv @@ -869,10 +869,10 @@ {\dodoubleargument\mult_interfaces_define_name_space} \def\mult_interfaces_define_name_space[#1][#2]% namespace settings - {\ctxlua{interfaces.namespaces.define(\!!bs#1\!!es,\!!bs#2\!!es)}} + {\clf_definenamespace{#1}{#2}} \def\listnamespaces - {\ctxlua{interfaces.namespaces.list()}} + {\clf_listnamespaces} %D Helper: %D diff --git a/tex/context/base/mult-low.lua b/tex/context/base/mult-low.lua index 625217803..0a3d9f55b 100644 --- a/tex/context/base/mult-low.lua +++ b/tex/context/base/mult-low.lua @@ -388,5 +388,6 @@ return { -- "Ucheckedstartdisplaymath", "Ucheckedstopdisplaymath", -- + "nobreak", "allowbreak", "goodbreak", } } diff --git a/tex/context/base/node-rul.lua b/tex/context/base/node-rul.lua index 6f3bc9df9..ddbd3963b 100644 --- a/tex/context/base/node-rul.lua +++ b/tex/context/base/node-rul.lua @@ -424,3 +424,50 @@ nodes.shifts.handler = function(head) return process(a_shifted,data,flush_shifte function nodes.shifts.enable() tasks.enableaction("shipouts","nodes.shifts.handler") end + +-- interface + +local implement = interfaces.implement + +implement { + name = "definerule", + actions = { nodes.rules.define, context }, + arguments = { + { + { "continue" }, + { "unit" }, + { "order" }, + { "method", "integer" }, + { "offset", "number" }, + { "rulethickness", "string" }, + { "dy", "number" }, + { "max", "number" }, + { "ma", "integer" }, + { "ca", "integer" }, + { "ta", "integer" }, + } + } +} + +implement { + name = "enablerules", + actions = nodes.rules.enable +} + +implement { + name = "defineshift", + actions = { nodes.shifts.define, context }, + arguments = { + { + { "continue" }, + { "unit" }, + { "method", "integer" }, + { "dy", "number" }, + } + } +} + +implement { + name = "enableshifts", + actions = nodes.shifts.enable +} diff --git a/tex/context/base/node-rul.mkiv b/tex/context/base/node-rul.mkiv index 3cf91624a..e1c8c8413 100644 --- a/tex/context/base/node-rul.mkiv +++ b/tex/context/base/node-rul.mkiv @@ -112,19 +112,20 @@ \unexpanded\def\node_rules_define {\edef\p_node_rules_color{\barparameter\c!color}% - \setevalue{\??barattribute\currentbar}{\number\ctxlua{nodes.rules.define { - method = \barparameter\c!method, - offset = \barparameter\c!offset, - continue = "\barparameter\c!continue", - dy = \barparameter\c!dy, - rulethickness = "\barparameter\c!rulethickness", - unit = "\barparameter\c!unit", - order = "\barparameter\c!order", - max = \barparameter\c!max, - ma = \thecolormodelattribute, - ca = \thecolorattribute\p_node_rules_color, - ta = \thetransparencyattribute\p_node_rules_color - }}}} + \setevalue{\??barattribute\currentbar}{\number + \clf_definerule + continue {\barparameter\c!continue}% + unit {\barparameter\c!unit}% + order {\barparameter\c!order}% + rulethickness {\barparameter\c!rulethickness}% + method \barparameter\c!method + ma \thecolormodelattribute + ca \thecolorattribute\p_node_rules_color + ta \thetransparencyattribute\p_node_rules_color + offset \barparameter\c!offset\space % number + dy \barparameter\c!dy\space % number + max \barparameter\c!max + \relax}} \unexpanded\def\node_rules_redefine#1% {\def\currentbar{#1}\node_rules_define} @@ -133,7 +134,7 @@ {\groupedcommand{\node_rules_set{#1}}\relax} \unexpanded\def\node_rules_set - {\ctxlua{nodes.rules.enable()}% will be moved to lua + {\clf_enablerules % will be moved to lua \glet\node_rules_set\node_rules_set_indeed \node_rules_set} @@ -281,18 +282,19 @@ \to \everydefineshift \unexpanded\def\node_shifts_define - {\setevalue{\??shiftattribute\currentshift}{\number\ctxlua{nodes.shifts.define { - method = \shiftparameter\c!method, - continue = "\shiftparameter\c!continue", - dy = \shiftparameter\c!dy, - unit = "\shiftparameter\c!unit", - }}}} + {\setevalue{\??shiftattribute\currentshift}{\number + \clf_defineshift + continue {\shiftparameter\c!continue}% + unit {\shiftparameter\c!unit}% + method \shiftparameter\c!method + dy \shiftparameter\c!dy % number + \relax}} \unexpanded\def\node_shifts_redefine#1% {\def\currentshift{#1}\node_shifts_define} \unexpanded\def\node_shifts_set - {\ctxlua{nodes.shifts.enable()}% + {\clf_enableshifts \glet\node_shifts_set\node_shifts_set_indeed \node_shifts_set} diff --git a/tex/context/base/pack-box.mkiv b/tex/context/base/pack-box.mkiv index 133dcb260..721561323 100644 --- a/tex/context/base/pack-box.mkiv +++ b/tex/context/base/pack-box.mkiv @@ -552,7 +552,7 @@ % \doifelse{\bleedingparameter\c!stretch}\v!yes\donetrue\donefalse % - \xdef\bleedwidth{\dimexpr + \xdef\bleedwidth{\the\dimexpr \ifdone \ifconditional\c_pack_boxes_l \scratchwidth+\MPx\currentbgposition-\MPx\currentpageposition @@ -563,8 +563,9 @@ \fi\fi \else \scratchwidth - \fi+\scratchhoffset}% - \xdef\bleedheight{\dimexpr + \fi+\scratchhoffset + \relax}% + \xdef\bleedheight{\the\dimexpr \ifdone \ifconditional\c_pack_boxes_t \paperheight -\MPy\currentbgposition+\MPy\currentpageposition % not checked @@ -575,7 +576,8 @@ \fi\fi \else \scratchheight - \fi+\scratchvoffset}% + \fi+\scratchvoffset + \relax}% \dowithnextboxcontentcs\pack_boxes_bleed_settings\pack_boxes_bleed_finish\hbox} \def\pack_boxes_bleed_settings diff --git a/tex/context/base/page-imp.mkiv b/tex/context/base/page-imp.mkiv index e3668a6cd..e523ee9d7 100644 --- a/tex/context/base/page-imp.mkiv +++ b/tex/context/base/page-imp.mkiv @@ -288,7 +288,7 @@ \fi \setuppapersize \ifarrangingpages - \ctxlua{job.disablesave()}% + \clf_disablejobsave %\disabledirective[job.save]% \fi \fi} diff --git a/tex/context/base/page-inj.lua b/tex/context/base/page-inj.lua index 56e5a234e..fd66ead08 100644 --- a/tex/context/base/page-inj.lua +++ b/tex/context/base/page-inj.lua @@ -16,10 +16,9 @@ pagebuilders.injections = injections local report = logs.reporter("pagebuilder","injections") local trace = false trackers.register("pagebuilder.injections",function(v) trace = v end) -local variables = interfaces.variables - local context = context -local commands = commands +local implement = interfaces.implement +local variables = interfaces.variables local texsetcount = tex.setcount @@ -103,6 +102,24 @@ function injections.flushafter() -- maybe not public, just commands.* end end -commands.page_injections_save = injections.save -commands.page_injections_flush_after = injections.flushafter -commands.page_injections_flush_before = injections.flushbefore +implement { + name = "savepageinjections", + actions = injections.save, + arguments = { + { + { "name" }, + { "state" }, + { "userdata" } + } + } +} + +implement { + name = "flushpageinjectionsbefore", + actions = injections.flushbefore +} + +implement { + name = "flushpageinjectionsafter", + actions = injections.flushafter +} diff --git a/tex/context/base/page-inj.mkvi b/tex/context/base/page-inj.mkvi index bee564683..912471b23 100644 --- a/tex/context/base/page-inj.mkvi +++ b/tex/context/base/page-inj.mkvi @@ -29,8 +29,8 @@ \installframedcommandhandler \??pageinjection {pageinjection} \??pageinjection \installcommandhandler \??pageinjectionalternative {pageinjectionalternative} \??pageinjectionalternative -\def\page_boxes_flush_before{\ctxcommand{page_injections_flush_before()}} -\def\page_boxes_flush_after {\ctxcommand{page_injections_flush_after ()}} +\let\page_boxes_flush_before\clf_flushpageinjectionsbefore +\let\page_boxes_flush_after \clf_flushpageinjectionsafter \def\page_injections_flush_saved#name#parameters% {\begingroup @@ -87,11 +87,11 @@ \fi} \def\page_injections_direct_indeed_yes#parameters% - {\ctxcommand{page_injections_save{ - name = "\currentpageinjection", - state = "\p_page_injections_state", - userdata = \!!bs\normalunexpanded{#parameters}\!!es - }}% + {\clf_savepageinjections + name {\currentpageinjection}% + state {\p_page_injections_state}% + userdata {\normalunexpanded{#parameters}}% + \relax \endgroup} \def\page_injections_direct_indeed_nop#parameters% diff --git a/tex/context/base/publ-ini.lua b/tex/context/base/publ-ini.lua index 6a9dd744f..392742c37 100644 --- a/tex/context/base/publ-ini.lua +++ b/tex/context/base/publ-ini.lua @@ -2300,6 +2300,10 @@ do local oneleft = lefttext and #lefttext == 1 and lefttext [1] local oneright = righttext and #righttext == 1 and righttext[1] + if not oneleft or not oneright then + compress = false -- very hard coded, or should we have compreess == auto? + end + local function flush(i,n,entry,last) local tag = entry.tag local currentcitation = markcite(dataset,tag) diff --git a/tex/context/base/publ-ini.mkiv b/tex/context/base/publ-ini.mkiv index d75ba036e..6cad81dcf 100644 --- a/tex/context/base/publ-ini.mkiv +++ b/tex/context/base/publ-ini.mkiv @@ -1433,11 +1433,11 @@ %D Journals -\unexpanded\def\btxloadjournallist [#1]{\ctxcommand{btxloadjournallist("#1")}} -\unexpanded\def\btxsavejournallist [#1]{\ctxcommand{btxsavejournallist("#1")}} -\unexpanded\def\btxaddjournal [#1][#2]{\ctxcommand{btxaddjournal("#1"."#2")}} - \def\btxexpandedjournal #1{\ctxcommand{btxexpandedjournal("#1")}} % \unexpanded ? - \def\btxabbreviatedjournal#1{\ctxcommand{btxabbreviatedjournal("#1")}} % \unexpanded ? +\unexpanded\def\btxloadjournallist [#1]{\clf_btxloadjournallist{#1}} +\unexpanded\def\btxsavejournallist [#1]{\clf_btxsavejournallist{#1}} +\unexpanded\def\btxaddjournal [#1][#2]{\clf_btxaddjournal{#1}{#2}} + \def\btxexpandedjournal #1{\clf_btxexpandedjournal{#1}} % \unexpanded ? + \def\btxabbreviatedjournal#1{\clf_btxabbreviatedjournal{#1}} % \unexpanded ? % \installcorenamespace{btxjournal} % diff --git a/tex/context/base/publ-jrn.lua b/tex/context/base/publ-jrn.lua index 91df21904..2e0408417 100644 --- a/tex/context/base/publ-jrn.lua +++ b/tex/context/base/publ-jrn.lua @@ -137,14 +137,40 @@ function journals.abbreviated(name) return abbreviations[s] or abbreviations[simplify(expansions[s])] or name end -local commands, context = commands, context - -if commands then - commands.btxloadjournallist = journals.load - commands.btxsavejournallist = journals.save - commands.btxaddjournal = function(...) context(journals.add(...)) end - commands.btxexpandedjournal = function(name) context(journals.expanded(name)) end - commands.btxabbreviatedjournal = function(name) context(journals.abbreviated(name)) end +local implement = interfaces and interfaces.implement + +if implement then + + implement { + name = "btxloadjournallist", + arguments = "string", + actions = journals.load + } + + implement { + name = "btxsavejournallist", + arguments = "string", + actions = journals.save + } + + implement { + name = "btxaddjournal", + arguments = { "string", "string" }, + actions = { journals.add, context } + } + + implement { + name = "btxexpandedjournal", + arguments = "string", + actions = { journals.expanded, context }, + } + + implement { + name = "btxabbreviatedjournal", + arguments = "string", + actions = { journals.abbreviated, context }, + } + end -- journals.load("e:/tmp/journals.txt") diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index f6528b644..b81d43b32 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 4863d95ae..751b19917 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-bkm.lua b/tex/context/base/strc-bkm.lua index f41f79db8..1ff75aa5f 100644 --- a/tex/context/base/strc-bkm.lua +++ b/tex/context/base/strc-bkm.lua @@ -15,14 +15,13 @@ if not modules then modules = { } end modules ['strc-bkm'] = { -- todo: make an lpeg for stripped -local format, concat, gsub, lower = string.format, table.concat, string.gsub, string.lower +local next, type = next, type +local gsub, lower = string.gsub, string.lower +local concat = table.concat local utfvalues = utf.values local settings_to_hash = utilities.parsers.settings_to_hash -local codeinjections = backends.codeinjections - -local trace_bookmarks = false trackers.register("references.bookmarks", function(v) trace_bookmarks = v end) - +local trace_bookmarks = false trackers.register("references.bookmarks", function(v) trace_bookmarks = v end) local report_bookmarks = logs.reporter("structure","bookmarks") local structures = structures @@ -32,13 +31,17 @@ structures.bookmarks = structures.bookmarks or { } local bookmarks = structures.bookmarks local sections = structures.sections local lists = structures.lists - local levelmap = sections.levelmap local variables = interfaces.variables +local implement = interfaces.implement +local codeinjections = backends.codeinjections -bookmarks.method = "internal" -- or "page" +bookmarks.method = "internal" -- or "page" -local names, opened, forced, numbered = { }, { }, { }, { } +local names = { } +local opened = { } +local forced = { } +local numbered = { } function bookmarks.register(settings) local force = settings.force == variables.yes @@ -475,6 +478,36 @@ end -- interface -commands.overloadbookmark = bookmarks.overload -commands.registerbookmark = bookmarks.register -commands.setupbookmarks = bookmarks.setup +implement { + name = "setupbookmarks", + actions = bookmarks.setup, + arguments = { + { + { "separatorset" }, + { "conversionset" }, + { "starter" }, + { "stopper" }, + { "segments" }, + { "showblocktitle" }, + } + } +} + +implement { + name = "registerbookmark", + actions = bookmarks.register, + arguments = { + { + { "names" }, + { "opened" }, + { "force" }, + { "number" }, + } + } +} + +implement { + name = "overloadbookmark", + actions = bookmarks.overload, + arguments = { "string", "string" } +} diff --git a/tex/context/base/strc-bkm.mkiv b/tex/context/base/strc-bkm.mkiv index 48273787a..f61017cf3 100644 --- a/tex/context/base/strc-bkm.mkiv +++ b/tex/context/base/strc-bkm.mkiv @@ -75,7 +75,7 @@ {\begingroup \simplifycommands \ifnum\thenamedheadlevel{#1}>\zerocount - \ctxcommand{overloadbookmark("#1",\!!bs\detokenize\expandafter{\normalexpanded{#2}}\!!es)}% + \clf_overloadbookmark{#1}{\detokenize\expandafter{\normalexpanded{#2}}}% \else \strc_lists_write_to[#1][]{#2}{}% todo: a dedicated bookmark writer \fi @@ -112,23 +112,23 @@ \else\ifsecondargument \doifassignmentelse{#2}{\let\m_bookmarks_opened\empty\setupcurrentbookmark[#2]}\donothing \fi\fi - \ctxcommand{registerbookmark { - names = "\m_bookmarks_names", - opened = "\m_bookmarks_opened", - force = "\bookmarkparameter\c!force", - number = "\bookmarkparameter\c!number", - }}% + \clf_registerbookmark + names {\m_bookmarks_names}% + opened {\m_bookmarks_opened}% + force {\bookmarkparameter\c!force}% + number {\bookmarkparameter\c!number}% + \relax \endgroup} \appendtoks - \ctxcommand{setupbookmarks { - separatorset = "\bookmarkparameter\c!numberseparatorset", - conversionset = "\bookmarkparameter\c!numberconversionset", - starter = \!!bs\bookmarkparameter\c!numberstarter\!!es, - stopper = \!!bs\bookmarkparameter\c!numberstopper\!!es, - segments = "\bookmarkparameter\c!numbersegments", - showblocktitle = "\bookmarkparameter\c!sectionblock", - }}% + \clf_setupbookmarks + separatorset {\bookmarkparameter\c!numberseparatorset}% + conversionset {\bookmarkparameter\c!numberconversionset}% + starter {\bookmarkparameter\c!numberstarter}% + stopper {\bookmarkparameter\c!numberstopper}% + segments {\bookmarkparameter\c!numbersegments}% + showblocktitle {\bookmarkparameter\c!sectionblock}% + \relax \to \everysetupbookmark %D There is a plugin mechanism but this is for experts only. The intermediate diff --git a/tex/context/base/strc-con.mkvi b/tex/context/base/strc-con.mkvi index 63c609070..31311279e 100644 --- a/tex/context/base/strc-con.mkvi +++ b/tex/context/base/strc-con.mkvi @@ -508,7 +508,7 @@ \setupalign[\p_strc_constructions_headalign]% use fast one \fi \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox}% -\setbox\constructionheadbox\hbox{\box\constructionheadbox}% needed in case of e.g. a real big head font, see descriptions-006.tex + \setbox\constructionheadbox\hbox{\box\constructionheadbox}% needed in case of e.g. a real big head font, see descriptions-006.tex \ht\constructionheadbox\strutht \dp\constructionheadbox\strutdp} @@ -567,6 +567,7 @@ \copy\constructionheadbox\hss } } + \nobreak \useconstructionstyleandcolor\c!style\c!color \ignorespaces \stopsetups @@ -591,6 +592,7 @@ \copy\constructionheadbox \hskip\rightconstructionskip } + \nobreak \advance\rightskip \constructionsheaddistance \useconstructionstyleandcolor\c!style\c!color \ignorespaces @@ -645,6 +647,7 @@ \box\constructionheadbox } } + \nobreak \useconstructionstyleandcolor\c!style\c!color \ignorespaces \stopsetups @@ -664,6 +667,7 @@ } } } + \nobreak \useconstructionstyleandcolor\c!style\c!color \ignorespaces \stopsetups @@ -752,7 +756,7 @@ \let\\=\crlf \noindent \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox % why copy? leftover? - \penalty\plustenthousand % new + \nobreak \hskip\constructionsheaddistance\relax \useconstructionstyleandcolor\c!style\c!color \ignorespaces @@ -763,8 +767,8 @@ \noindent \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox % why copy? leftover? \ifconditional\c_strc_constructions_distance_none \else - \penalty\plustenthousand % new - \hskip\constructionsheaddistance \!!plus .5\constructionsheaddistance \!!minus .25\constructionsheaddistance\relax + \nobreak + \hskip\constructionsheaddistance \!!plus .5\constructionsheaddistance \!!minus .25\constructionsheaddistance\relax \fi \useconstructionstyleandcolor\c!style\c!color \ignorespaces @@ -781,6 +785,7 @@ \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox \hss } + \nobreak \hskip\constructionsheaddistance\relax \useconstructionstyleandcolor\c!style\c!color \ignorespaces diff --git a/tex/context/base/strc-itm.mkvi b/tex/context/base/strc-itm.mkvi index c709463a8..dc95f569b 100644 --- a/tex/context/base/strc-itm.mkvi +++ b/tex/context/base/strc-itm.mkvi @@ -247,50 +247,52 @@ \normalexpanded{\textreference[\currentitemreference]{\strc_itemgroups_extra_symbol}}% \fi \fi} +\let\dofinishitemreference\dofinishfullreference % finalizer + \def\strc_itemgroups_insert_reference_indeed % maybe we need a 'frozen counter' numberdata blob / quick hack .. .mive this to strc-ref {%\setnextinternalreference % no need to collect nodes in \b_strc_destination_nodes here ... maybe at some point \strc_references_start_destination_nodes % this is somewhat over the top ... we should use the counter's reference \clf_setreferenceattribute - {\referenceprefix}% - {\currentitemreference}% - {% - metadata {% - kind {\s!full}% was item, why? - \ifx\currentreferencecoding\s!xml - xmlroot {\xmldocument}% only useful when text - \fi - catcodes \catcodetable - }% - references {% - % internal \nextinternalreference % no: this spoils references - block {\currentsectionblock}% - view {\interactionparameter\c!focus}% - }% - prefixdata {% - prefix {\namedcounterparameter\v_strc_itemgroups_counter\c!prefix}% - separatorset {\namedcounterparameter\v_strc_itemgroups_counter\c!prefixseparatorset}% - conversion {\namedcounterparameter\v_strc_itemgroups_counter\c!prefixconversion}% - conversionset {\namedcounterparameter\v_strc_itemgroups_counter\c!prefixconversionset}% - set {\namedcounterparameter\v_strc_itemgroups_counter\c!prefixset}% - segments {\namedcounterparameter\v_strc_itemgroups_counter\c!prefixsegments}% - % segments {\askedprefixsegments}% - connector {\namedcounterparameter\v_strc_itemgroups_counter\c!prefixconnector}% - }% - numberdata {% - numbers {\v_strc_itemgroups_counter}% - separatorset {\namedcounterparameter\v_strc_itemgroups_counter\c!numberseparatorset}% - % conversion {\namedcounterparameter\v_strc_itemgroups_counter\c!numberconversion}% - % conversionset {\namedcounterparameter\v_strc_itemgroups_counter\c!numberconversionset}% - % fixedconversion {\currentitemgroupconversionset}% - conversionset {fixed::\currentitemgroupconversionset}% temp hack - % - % for the moment no stopper, we need to make references configurable first - % stopper {\namedcounterparameter\v_strc_itemgroups_counter\c!numberstopper}% - segments {\namedcounterparameter\v_strc_itemgroups_counter\c!numbersegments}% - }% - }% + {\referenceprefix}% + {\currentitemreference}% + {% + metadata {% + kind {item}% was item, why? + \ifx\currentreferencecoding\s!xml + xmlroot {\xmldocument}% only useful when text + \fi + catcodes \catcodetable + }% + references {% + % internal \nextinternalreference % no: this spoils references + block {\currentsectionblock}% + view {\interactionparameter\c!focus}% + }% + prefixdata {% + prefix {\namedcounterparameter\v_strc_itemgroups_counter\c!prefix}% + separatorset {\namedcounterparameter\v_strc_itemgroups_counter\c!prefixseparatorset}% + conversion {\namedcounterparameter\v_strc_itemgroups_counter\c!prefixconversion}% + conversionset {\namedcounterparameter\v_strc_itemgroups_counter\c!prefixconversionset}% + set {\namedcounterparameter\v_strc_itemgroups_counter\c!prefixset}% + segments {\namedcounterparameter\v_strc_itemgroups_counter\c!prefixsegments}% + % segments {\askedprefixsegments}% + connector {\namedcounterparameter\v_strc_itemgroups_counter\c!prefixconnector}% + }% + numberdata {% + numbers {\v_strc_itemgroups_counter}% + separatorset {\namedcounterparameter\v_strc_itemgroups_counter\c!numberseparatorset}% + % conversion {\namedcounterparameter\v_strc_itemgroups_counter\c!numberconversion}% + % conversionset {\namedcounterparameter\v_strc_itemgroups_counter\c!numberconversionset}% + % fixedconversion {\currentitemgroupconversionset}% + conversionset {fixed::\currentitemgroupconversionset}% temp hack + % + % for the moment no stopper, we need to make references configurable first + % stopper {\namedcounterparameter\v_strc_itemgroups_counter\c!numberstopper}% + segments {\namedcounterparameter\v_strc_itemgroups_counter\c!numbersegments}% + }% + }% \relax \strc_references_stop_destination_nodes \xdef\currentdestinationattribute{\number\lastdestinationattribute}% diff --git a/tex/context/base/strc-ref.lua b/tex/context/base/strc-ref.lua index 5627fffbc..f684a6170 100644 --- a/tex/context/base/strc-ref.lua +++ b/tex/context/base/strc-ref.lua @@ -1887,7 +1887,7 @@ function references.setandgetattribute(prefix,tag,data) -- maybe do internal aut if ndat then local numbers = ndat.numbers if type(numbers) == "string" then - ndat.numbers = structures.counters.compact(numbers) + ndat.numbers = structures.counters.compact(numbers,nil,true) end data.numberdata = structures.helpers.simplify(ndat) end @@ -1899,7 +1899,7 @@ function references.setandgetattribute(prefix,tag,data) -- maybe do internal aut if type(udat) == "string" then data.userdata = structures.helpers.touserdata(udat) end - local done = references.set(mdat.kind or "page",prefix,tag,data) + local done = references.set(mdat.kind or "page",prefix,tag,data) -- we had kind i.e .item -> full if done then attr = setinternalreference(prefix,tag,nil,rdat.view) or unsetvalue end diff --git a/tex/context/base/syst-aux.lua b/tex/context/base/syst-aux.lua index ab4358b85..7eec63e4f 100644 --- a/tex/context/base/syst-aux.lua +++ b/tex/context/base/syst-aux.lua @@ -12,21 +12,15 @@ if not modules then modules = { } end modules ['syst-aux'] = { -- utf.sub(str,1,1) local tonumber = tonumber -local format = string.format local utfsub = utf.sub local P, S, R, C, Cc, Cs, Carg, lpegmatch = lpeg.P, lpeg.S, lpeg.R, lpeg.C, lpeg.Cc, lpeg.Cs, lpeg.Carg, lpeg.match -local todimen = number.todimen -local commands = commands local context = context - local implement = interfaces.implement - +local formatters = string.formatters local setcatcode = tex.setcatcode - local utf8character = lpeg.patterns.utf8character local settings_to_array = utilities.parsers.settings_to_array - local setmacro = interfaces.setmacro local pattern = C(utf8character^-1) * C(P(1)^0) @@ -59,13 +53,14 @@ implement { end } -local pattern = C(utf8character^-1) +local pattern = C(utf8character^-1) +local ctx_doifelse = commands.doifelse implement { name = "doiffirstcharelse", arguments = { "string", "string" }, actions = function(str) - commands.doifelse(lpegmatch(pattern,str) == chr) + ctx_doifelse(lpegmatch(pattern,str) == chr) end } @@ -107,7 +102,8 @@ implement { -- end -- end -local pattern = (C((1-P("%"))^1) * Carg(1)) /function(n,d) return format("%.0fsp",d * tonumber(n)/100) end * P("%") * P(-1) -- .0 ? +local pattern = (C((1-P("%"))^1) * Carg(1)) / function(n,d) + return formatters["%.0fsp"](d * tonumber(n)/100) end * P("%") * P(-1) -- .0 ? -- percentageof("10%",65536*10) @@ -184,9 +180,9 @@ end implement { name = "texdefinition_one", actions = texdefinition_one, scope = "private", arguments = "string" } implement { name = "texdefinition_two", actions = texdefinition_two, scope = "private" } -implement { name = "upper", arguments = "string", actions = { utf.upper, context } } -implement { name = "lower", arguments = "string", actions = { utf.lower, context } } -implement { name = "strip", arguments = "string", actions = { utf.strip, context } } +implement { name = "upper", arguments = "string", actions = { utf.upper, context } } +implement { name = "lower", arguments = "string", actions = { utf.lower, context } } +implement { name = "strip", arguments = "string", actions = { string.strip, context } } -- or utf.strip -- implement { -- name = "converteddimen", @@ -213,3 +209,15 @@ implement { context(statistics.elapsedtime("whatever")) end } + +local accuracy = table.setmetatableindex(function(t,k) + local v = formatters["%0." ..k .. "f"] + t[k] = v + return v +end) + +implement { + name = "rounded", + arguments = "integer", + actions = function(n,m) context(accuracy[n](m)) end +} diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv index 2689354e5..77ee8bee8 100644 --- a/tex/context/base/syst-aux.mkiv +++ b/tex/context/base/syst-aux.mkiv @@ -6166,10 +6166,10 @@ % \def\threedigitrounding#1% % {\expandafter\expandafter\expandafter\dothreedigitrounding\expandafter\WITHOUTPT\the\dimexpr#1\points+.0005\points\relax0000.*00\relax} -\def\integerrounding #1{\cldcontext{"\letterpercent 0.0f",#1}} -\def\onedigitrounding #1{\cldcontext{"\letterpercent 0.1f",#1}} -\def\twodigitrounding #1{\cldcontext{"\letterpercent 0.2f",#1}} -\def\threedigitrounding#1{\cldcontext{"\letterpercent 0.3f",#1}} +\def\integerrounding #1{\clf_rounded\zerocount\numexpr#1\relax} +\def\onedigitrounding #1{\clf_rounded\plusone \numexpr#1\relax} +\def\twodigitrounding #1{\clf_rounded\plustwo \numexpr#1\relax} +\def\threedigitrounding#1{\clf_rounded\plusthree\numexpr#1\relax} %D \macros %D {processcontent} diff --git a/tex/context/base/syst-lua.lua b/tex/context/base/syst-lua.lua index 9466ed94b..aa258d542 100644 --- a/tex/context/base/syst-lua.lua +++ b/tex/context/base/syst-lua.lua @@ -15,12 +15,18 @@ local commands = commands local implement = interfaces.implement +local two_strings = interfaces.strings[2] + local context = context local csprint = context.sprint local prtcatcodes = tex.prtcatcodes -function commands.writestatus(...) logs.status(...) end -- overloaded later +implement { -- will b eoverloaded later + name = "writestatus", + arguments = two_strings, + actions = logs.status, +} local ctx_firstoftwoarguments = context.firstoftwoarguments -- context.constructcsonly("firstoftwoarguments" ) local ctx_secondoftwoarguments = context.secondoftwoarguments -- context.constructcsonly("secondoftwoarguments") @@ -109,7 +115,7 @@ end local s = lpegtsplitat(",") local h = { } -function commands.doifcommonelse(a,b) -- often the same test +local function doifcommonelse(a,b) -- often the same test local ha = h[a] local hb = h[b] if not ha then @@ -133,7 +139,7 @@ function commands.doifcommonelse(a,b) -- often the same test ctx_secondoftwoarguments() end -function commands.doifinsetelse(a,b) +local function doifinsetelse(a,b) local hb = h[b] if not hb then hb = lpegmatch(s,b) h[b] = hb end for i=1,#hb do @@ -145,6 +151,18 @@ function commands.doifinsetelse(a,b) ctx_secondoftwoarguments() end +implement { + name = "doifcommonelse", + arguments = two_strings, + actions = doifcommonelse +} + +implement { + name = "doifinsetelse", + arguments = two_strings, + actions = doifinsetelse +} + local pattern = lpeg.patterns.validdimen function commands.doifdimenstringelse(str) @@ -166,9 +184,11 @@ implement { arguments = { "string", "integer" } } -function commands.execute(str) - os.execute(str) -- wrapped in sandbox -end +implement { + name = "execute", + arguments = "string", + actions = os.execute -- wrapped in sandbox +} -- function commands.write(n,str) -- if n == 18 then @@ -181,3 +201,39 @@ end -- context.writeviatex(n,str) -- end -- end + +implement { + name = "doifsameelse", + arguments = two_strings, + actions = function(a,b) + if a == b then + ctx_firstoftwoarguments() + else + ctx_secondoftwoarguments() + end + end +} + +implement { + name = "doifsame", + arguments = two_strings, + actions = function(a,b) + if a == b then + ctx_firstofoneargument() + else + ctx_gobbleoneargument() + end + end +} + +implement { + name = "doifnotsame", + arguments = two_strings, + actions = function(a,b) + if a == b then + ctx_gobbleoneargument() + else + ctx_firstofoneargument() + end + end +} diff --git a/tex/context/base/syst-lua.mkiv b/tex/context/base/syst-lua.mkiv index 2a6bcdf6d..145cb3ebe 100644 --- a/tex/context/base/syst-lua.mkiv +++ b/tex/context/base/syst-lua.mkiv @@ -15,15 +15,15 @@ \unprotect -\def\expdoifelse#1#2{\ctxcommand{doifelse(\!!bs#1\!!es==\!!bs#2\!!es)}} -\def\expdoif #1#2{\ctxcommand{doif (\!!bs#1\!!es==\!!bs#2\!!es)}} -\def\expdoifnot #1#2{\ctxcommand{doifnot (\!!bs#1\!!es==\!!bs#2\!!es)}} +\def\expdoifelse#1#2{\clf_doifsameelse{#1}{#2}} +\def\expdoif #1#2{\clf_doifsame {#1}{#2}} +\def\expdoifnot #1#2{\clf_doifnotsame {#1}{#2}} % \testfeatureonce{100000}{\doifelse{hello world}{here i am}{}} % 0.3 % \testfeatureonce{100000}{\expandabledoifelse{hello world}{here i am}{}} % 1.5 -\def\expdoifcommonelse#1#2{\ctxcommand{doifcommonelse("#1","#2")}} -\def\expdoifinsetelse #1#2{\ctxcommand{doifinsetelse("#1","#2")}} +\def\expdoifcommonelse#1#2{\clf_doifcommonelse{#1}{#2}} +\def\expdoifinsetelse #1#2{\clf_doifinset {#1}{#2}} % we define these here, just in case ... @@ -32,7 +32,7 @@ \edef\!!bs{[\luastringsep[} \edef\!!es{]\luastringsep]} -\unexpanded\def\writestatus#1#2{\ctxcommand{writestatus(\!!bs#1\!!es,\!!bs#2\!!es)}} +\unexpanded\def\writestatus#1#2{\clf_writestatus{#1}{#2}} % A handy helper: @@ -41,7 +41,7 @@ % We can omit the tex.ctxcatcodes here as nowadays we seldom % change the regime at the \TEX\ end: -\def\luaexpr#1{\directlua{tex.print(tostring(#1))}} +\def\luaexpr#1{\ctxlua{tex.print(tostring(#1))}} % no use is shortcutting has to be compiled % helpers: @@ -86,8 +86,7 @@ % we have no way yet to pickup \immediate unless we redefine it % we assume immediate execution -\def\syst_write_execute#1% - {\ctxcommand{execute(\!!bs#1\!!es)}} +\let\syst_write_execute\clf_execute % always {...} \unexpanded\def\write#1#% {\ifnum#1=18 diff --git a/tex/context/base/syst-rtp.mkiv b/tex/context/base/syst-rtp.mkiv index 58278972b..82c0778b4 100644 --- a/tex/context/base/syst-rtp.mkiv +++ b/tex/context/base/syst-rtp.mkiv @@ -13,6 +13,6 @@ \unprotect -\def\executesystemcommand#1{\ctxlua{os.execute(\!!bs#1\!!es)}} +\let\executesystemcommand\clf_execute \protect \endinput diff --git a/tex/context/base/toks-scn.lua b/tex/context/base/toks-scn.lua index b01376b60..9b6b440f8 100644 --- a/tex/context/base/toks-scn.lua +++ b/tex/context/base/toks-scn.lua @@ -16,7 +16,6 @@ local type, next, tostring, tonumber = type, next, tostring, tonumber local formatters = string.formatters local concat = table.concat -local loadstring = loadstring local scanners = tokens.scanners local tokenbits = tokens.bits diff --git a/tex/context/base/trac-deb.lua b/tex/context/base/trac-deb.lua index d52399bcf..d998295c1 100644 --- a/tex/context/base/trac-deb.lua +++ b/tex/context/base/trac-deb.lua @@ -32,6 +32,8 @@ local texgetdimen = tex.getdimen local texgettoks = tex.gettoks local texgetcount = tex.getcount +local implement = interfaces.implement + strings.undefined = "undefined" lists.scratch = { @@ -304,3 +306,20 @@ local function trace_calls(n) end directives.register("system.tracecalls", function(n) trace_calls(n) end) -- indirect is needed for nilling + +implement { name = "showtrackers", actions = trackers.show } +implement { name = "enabletrackers", actions = trackers.enable, arguments = "string" } +implement { name = "disabletrackers", actions = trackers.disable, arguments = "string" } +implement { name = "resettrackers", actions = trackers.reset } + +implement { name = "showdirectives", actions = directives.show } +implement { name = "enabledirectives", actions = directives.enable, arguments = "string" } +implement { name = "disabledirectives", actions = directives.disable, arguments = "string" } + +implement { name = "showexperiments", actions = experiments.show } +implement { name = "enableexperiments", actions = experiments.enable, arguments = "string" } +implement { name = "disableexperiments", actions = experiments.disable, arguments = "string" } + +implement { name = "showdebuginfo", actions = lmx.showdebuginfo } +implement { name = "overloaderror", actions = lmx.overloaderror } +implement { name = "showlogcategories", actions = logs.show } diff --git a/tex/context/base/trac-deb.mkiv b/tex/context/base/trac-deb.mkiv index fe5dd02dc..1e61a3512 100644 --- a/tex/context/base/trac-deb.mkiv +++ b/tex/context/base/trac-deb.mkiv @@ -13,25 +13,31 @@ \writestatus{loading}{ConTeXt Tracing Macros / Debugger} +\unprotect + %registerctxluafile{trac-lmx}{1.001} \registerctxluafile{trac-deb}{1.001} -\unexpanded\def\breakpoint{\showdebuginfo\wait} +\unexpanded\def\breakpoint {\showdebuginfo\wait} + +\unexpanded\def\showtrackers {\clf_showtrackers} +\unexpanded\def\enabletrackers [#1]{\clf_enabletrackers{#1}} +\unexpanded\def\disabletrackers [#1]{\clf_disabletrackers{#1}} +\unexpanded\def\resettrackers {\clf_resettrackers} + +\unexpanded\def\showdirectives {\clf_showdirectives} +\unexpanded\def\enabledirectives [#1]{\clf_enabledirectives{#1}} +\unexpanded\def\disabledirectives [#1]{\clf_disabledirectives{#1}} -\unexpanded\def\showtrackers {\ctxlua{trackers.show()}} -\unexpanded\def\enabletrackers [#1]{\ctxlua{trackers.enable("#1")}} -\unexpanded\def\disabletrackers [#1]{\ctxlua{trackers.disable("#1")}} -\unexpanded\def\resettrackers {\ctxlua{trackers.reset()}} +\unexpanded\def\showexperiments {\clf_showexperiments} +\unexpanded\def\enableexperiments [#1]{\clf_enableexperiments{#1}} +\unexpanded\def\disableexperiments[#1]{\clf_disableexperiments{#1}} -\unexpanded\def\showdirectives {\ctxlua{directives.show()}} -\unexpanded\def\enabledirectives [#1]{\ctxlua{directives.enable("#1")}} -\unexpanded\def\disabledirectives [#1]{\ctxlua{directives.disable("#1")}} +\unexpanded\def\showdebuginfo {\clf_showdebuginfo} +\unexpanded\def\overloaderror {\clf_overloaderror} -\unexpanded\def\showexperiments {\ctxlua{experiments.show()}} -\unexpanded\def\enableexperiments [#1]{\ctxlua{experiments.enable("#1")}} -\unexpanded\def\disableexperiments[#1]{\ctxlua{experiments.disable("#1")}} +\unexpanded\def\showlogcategories {\clf_showlogcategories} -\unexpanded\def\showdebuginfo {\ctxlua{lmx.showdebuginfo()}} -\unexpanded\def\overloaderror {\ctxlua{lmx.overloaderror()}} % \enabledirectives[system.showerror] +% \enabledirectives[system.showerror] -\unexpanded\def\showlogcategories {\ctxlua{logs.show()}} +\protect \endinput diff --git a/tex/context/base/trac-set.lua b/tex/context/base/trac-set.lua index 569bb90ea..9e2bf8758 100644 --- a/tex/context/base/trac-set.lua +++ b/tex/context/base/trac-set.lua @@ -258,6 +258,7 @@ function setters.new(name) -- we could use foo:bar syntax (but not used that oft report = function(...) setters.report (setter,...) end, enable = function(...) enable (setter,...) end, disable = function(...) disable (setter,...) end, + reset = function(...) reset (setter,...) end, -- can be dangerous register = function(...) register(setter,...) end, list = function(...) list (setter,...) end, show = function(...) show (setter,...) end, diff --git a/tex/context/base/trac-vis.lua b/tex/context/base/trac-vis.lua index 0ee40db80..d1323698b 100644 --- a/tex/context/base/trac-vis.lua +++ b/tex/context/base/trac-vis.lua @@ -280,13 +280,6 @@ function visualizers.setlayer(n) texsetattribute(a_layer,layers[n] or unsetvalue) end -commands.setvisual = visualizers.setvisual -commands.setlayer = visualizers.setlayer - -function commands.visual(n) - context(setvisual(n)) -end - local function set(mode,v) texsetattribute(a_visual,setvisual(mode,texgetattribute(a_visual),v)) end @@ -961,10 +954,6 @@ function visualizers.markfonts(list) markfonts(type(n) == "number" and getlist(getbox(n)) or n) end -function commands.markfonts(n) - visualizers.markfonts(n) -end - luatex.registerstopactions(cleanup) statistics.register("visualization time",function() @@ -973,3 +962,14 @@ statistics.register("visualization time",function() return format("%s seconds",statistics.elapsedtime(visualizers)) end end) + +-- interface + +local implement = interfaces.implement + +implement { name = "setvisual", arguments = "string", actions = visualizers.setvisual } +implement { name = "getvisual", arguments = "string", actions = { setvisual, context } } +implement { name = "setvisuallayer", arguments = "string", actions = visualizers.setlayer } +implement { name = "markvisualfonts", arguments = "integer", actions = visualizers.markfonts } +implement { name = "setvisualfont", arguments = "integer", actions = visualizers.setfont } + diff --git a/tex/context/base/trac-vis.mkiv b/tex/context/base/trac-vis.mkiv index 7517037ea..1264ec49a 100644 --- a/tex/context/base/trac-vis.mkiv +++ b/tex/context/base/trac-vis.mkiv @@ -54,10 +54,10 @@ \let\syst_visualizers_vbox\vbox \let\syst_visualizers_vtop\vtop -\unexpanded\def\ruledhbox{\syst_visualizers_hbox attr \visualattribute \ctxcommand{visual("simplehbox")} } -\unexpanded\def\ruledvbox{\syst_visualizers_vbox attr \visualattribute \ctxcommand{visual("simplevbox")} } -\unexpanded\def\ruledvtop{\syst_visualizers_vtop attr \visualattribute \ctxcommand{visual("simplevtop")} } % special case -\unexpanded\def\ruledtopv{\syst_visualizers_vtop attr \visualattribute \ctxcommand{visual("vtop")} } +\unexpanded\def\ruledhbox{\syst_visualizers_hbox attr \visualattribute \clf_getvisual{simplehbox} } +\unexpanded\def\ruledvbox{\syst_visualizers_vbox attr \visualattribute \clf_getvisual{simplevbox} } +\unexpanded\def\ruledvtop{\syst_visualizers_vtop attr \visualattribute \clf_getvisual{simplevtop} } % special case +\unexpanded\def\ruledtopv{\syst_visualizers_vtop attr \visualattribute \clf_getvisual{vtop} } \unexpanded\def\ruledmbox#1{\ruledhbox{\startimath#1\stopimath}} @@ -87,29 +87,29 @@ \unexpanded\def\syst_visualizers_makeup[#1]% {\iffirstargument - \ctxcommand{setvisual("#1")}% + \clf_setvisual{#1}% \else - \ctxcommand{setvisual("makeup")}% + \clf_setvisual{makeup}% \let\normalvtop\ruledtopv \let\vtop \ruledtopv \fi} \unexpanded\def\showallmakeup - {\ctxcommand{setvisual("all")}% + {\clf_setvisual{all}% \let\normalvtop\ruledtopv \let\vtop \ruledtopv \showstruts} \unexpanded\def\showboxes - {\ctxcommand{setvisual("boxes")}% + {\clf_setvisual{boxes}% \let\normalvtop\ruledtopv \let\vtop \ruledtopv} \unexpanded\def\showglyphs - {\ctxcommand{setvisual("glyph")}} + {\clf_setvisual{glyph}} \unexpanded\def\showfontkerns - {\ctxcommand{setvisual("fontkern")}} + {\clf_setvisual{fontkern}} \unexpanded\def\setvisualizerfont {\dosingleempty\syst_visualizers_setfont} @@ -117,7 +117,7 @@ \def\syst_visualizers_setfont[#1]% somename at 4pt {\begingroup \doifelsenothing{#1}{\definedfont[Mono at 4pt]}{\definedfont[#1]}% - \ctxlua{nodes.visualizers.setfont()}% + \clf_setvisualfont \endgroup} %D New (these might also be a visualizers): @@ -148,14 +148,14 @@ %D Overload: % \def\spac_struts_vide_hbox -% {\hbox attr \visualattribute \ctxcommand{visual("strut")} } +% {\hbox attr \visualattribute \clf_getvisual{strut} } % % \def\spac_struts_vide_hbox -% {\xdef\spac_struts_vide_hbox{\hbox attr \visualattribute \ctxcommand{visual("strut")} }% +% {\xdef\spac_struts_vide_hbox{\hbox attr \visualattribute \clf_getvisual{strut} }% % \spac_struts_vide_hbox} \unexpanded\def\spac_struts_vide_hbox - {\hbox attr \visualattribute \ctxcommand{visual("strut")} } + {\hbox attr \visualattribute \clf_getvisual{strut} } \appendtoks \normalexpanded{\unexpanded\xdef\spac_struts_vide_hbox\expandafter{\spac_struts_vide_hbox}}% @@ -167,7 +167,7 @@ {\dontleavehmode \begingroup \setbox\scratchbox\hbox{\getbuffer}% - \ctxcommand{markfonts(\number\scratchbox)}% + \clf_markvisualfonts\scratchbox \unhbox\scratchbox \endgroup} diff --git a/tex/context/base/type-ini.mkvi b/tex/context/base/type-ini.mkvi index 4514a8b5f..01b2e9524 100644 --- a/tex/context/base/type-ini.mkvi +++ b/tex/context/base/type-ini.mkvi @@ -381,13 +381,13 @@ \unexpanded\def\loadmapline{\dodoubleempty\font_map_load_line} \def\font_map_load_file[#filename]% - {\ctxlua{fonts.mappings.loadfile("#filename")}} + {\clf_loadmapfile{#filename}} \def\font_map_load_line[#kind][#data]% - {\ctxlua{fonts.mappings.loadline("#kind","#data")}} + {\clf_loadmapline{#kind}{#data}} \unexpanded\def\forgetmapfiles - {\ctxlua{fonts.mappings.reset()}} + {\clf_resetmapfiles} % \prependtoks % \loadmapfile[mkiv-base.map]% can't we preload this one? @@ -497,7 +497,7 @@ {\font_typefaces_define_indeed[#name][#style]} \def\font_typefaces_define_d[#name][#specification][#dummya][#dummyb][#dummyc][#dummyd]% use definitions in lfg file - {\ctxlua{fonts.definetypeface("#name",\!!bs#specification\!!es)}} + {\clf_definetypeface{#name}{#specification}} \def\font_typefaces_define_indeed[#name][#style]% saveguard against redefinition {\doifsomething{#name} diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 4ea486bb8..e8f62413e 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 : 03/31/15 12:04:36 +-- merge date : 04/01/15 12:00:07 do -- begin closure to overcome local limits and interference -- cgit v1.2.3