From c0e2193b6c379b34fbc589343d31f71e02513f03 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Thu, 28 Oct 2021 11:38:54 +0200 Subject: 2021-10-28 10:19:00 --- tex/context/base/mkii/cont-new.mkii | 2 +- tex/context/base/mkii/context.mkii | 2 +- tex/context/base/mkii/mult-ro.mkii | 1 + tex/context/base/mkiv/cont-new.mkiv | 2 +- tex/context/base/mkiv/context.mkiv | 2 +- tex/context/base/mkiv/core-con.lua | 4 +- tex/context/base/mkiv/mult-low.lua | 2 +- tex/context/base/mkiv/status-files.pdf | Bin 24705 -> 24701 bytes tex/context/base/mkiv/status-lua.pdf | Bin 253744 -> 253854 bytes tex/context/base/mkxl/anch-bar.mkxl | 2 + tex/context/base/mkxl/cont-new.mkxl | 2 +- tex/context/base/mkxl/context.mkxl | 3 +- tex/context/base/mkxl/grph-inc.lmt | 2 +- tex/context/base/mkxl/node-par.lmt | 17 ++ tex/context/base/mkxl/node-tsk.lmt | 52 +++++ tex/context/base/mkxl/spac-hor.mkxl | 12 ++ tex/context/base/mkxl/syst-ini.mkxl | 5 + tex/context/base/mkxl/task-ini.lmt | 4 + tex/context/base/mkxl/typo-lbx.lmt | 179 ++++++++++++++++ tex/context/base/mkxl/typo-lbx.mkxl | 229 +++++++++++++++++++++ tex/context/interface/mkii/keys-ro.xml | 1 + tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 22 files changed, 515 insertions(+), 10 deletions(-) create mode 100644 tex/context/base/mkxl/typo-lbx.lmt create mode 100644 tex/context/base/mkxl/typo-lbx.mkxl (limited to 'tex') diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index cbb77a698..3fac13aaf 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2021.10.24 21:42} +\newcontextversion{2021.10.28 10:17} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index e1a1ec97c..fedf5acb3 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2021.10.24 21:42} +\edef\contextversion{2021.10.28 10:17} %D For those who want to use this: diff --git a/tex/context/base/mkii/mult-ro.mkii b/tex/context/base/mkii/mult-ro.mkii index 9aede3730..87a4a91c0 100644 --- a/tex/context/base/mkii/mult-ro.mkii +++ b/tex/context/base/mkii/mult-ro.mkii @@ -188,6 +188,7 @@ \setinterfacevariable{enumeration}{enumerare} \setinterfacevariable{environment}{mediu} \setinterfacevariable{even}{par} +\setinterfacevariable{explicit}{explicit} \setinterfacevariable{export}{export} \setinterfacevariable{external}{extern} \setinterfacevariable{extremestretch}{extremestretch} diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index e5bd908d4..8c12216dd 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2021.10.24 21:42} +\newcontextversion{2021.10.28 10:17} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 146d9b365..6cc906cf4 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -49,7 +49,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2021.10.24 21:42} +\edef\contextversion{2021.10.28 10:17} %D Kind of special: diff --git a/tex/context/base/mkiv/core-con.lua b/tex/context/base/mkiv/core-con.lua index 289a34b0e..ea11ffcd0 100644 --- a/tex/context/base/mkiv/core-con.lua +++ b/tex/context/base/mkiv/core-con.lua @@ -2011,7 +2011,9 @@ function converters.totime(s) return s elseif type(s) == "string" then local t = lpegmatch(p,s) - if t.tzh then + if not t then + logs.report("system","invalid time specification %a",s) + elseif t.tzh then local localtzh, localtzm = ostimezone(true) t.hour = t.hour + localtzh - t.tzs * t.tzh t.min = t.min + localtzm - t.tzs * t.tzm diff --git a/tex/context/base/mkiv/mult-low.lua b/tex/context/base/mkiv/mult-low.lua index ef9a33153..125434d9a 100644 --- a/tex/context/base/mkiv/mult-low.lua +++ b/tex/context/base/mkiv/mult-low.lua @@ -91,7 +91,7 @@ return { "localboxgroupcode", "splitoffgroupcode", "splitkeepgroupcode", "preamblegroupcode", "alignsetgroupcode", "finrowgroupcode", "discretionarygroupcode", -- - "markautomigrationcode", "insertautomigrationcode", "preautomigrationcode", "postautomigrationcode", + "markautomigrationcode", "insertautomigrationcode", "adjustautomigrationcode", "preautomigrationcode", "postautomigrationcode", -- "charnodecode", "hlistnodecode", "vlistnodecode", "rulenodecode", "insertnodecode", "marknodecode", "adjustnodecode", "ligaturenodecode", "discretionarynodecode", "whatsitnodecode", "mathnodecode", diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf index 894a4da54..4a0bc353d 100644 Binary files a/tex/context/base/mkiv/status-files.pdf and b/tex/context/base/mkiv/status-files.pdf differ diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf index fe34b4772..78253afaf 100644 Binary files a/tex/context/base/mkiv/status-lua.pdf and b/tex/context/base/mkiv/status-lua.pdf differ diff --git a/tex/context/base/mkxl/anch-bar.mkxl b/tex/context/base/mkxl/anch-bar.mkxl index 9fa9d6bf2..23a009e97 100644 --- a/tex/context/base/mkxl/anch-bar.mkxl +++ b/tex/context/base/mkxl/anch-bar.mkxl @@ -78,6 +78,7 @@ \c!bottomoffset=\zeropoint, \c!distance=.5\bodyfontsize, \c!level=, + \c!location=\v!left, \c!leftmargindistance=\zeropoint] \aliased\let\setupsidebars\setupsidebar @@ -124,6 +125,7 @@ {e:sidebar:\the\c_anch_sidebars_n}% {mpos:sidebar}% {self=sidebar:\the\c_anch_sidebars_n, + location=\mplocation{\sidebarparameter\c!location}, linewidth=\sidebarparameter\c!rulethickness, linecolor=\sidebarparameter\c!rulecolor, alternative=\sidebarparameter\c!alternative, diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index b300fcf1b..c09d7a8ae 100644 --- a/tex/context/base/mkxl/cont-new.mkxl +++ b/tex/context/base/mkxl/cont-new.mkxl @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2021.10.24 21:42} +\newcontextversion{2021.10.28 10:17} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkxl/context.mkxl b/tex/context/base/mkxl/context.mkxl index 41d4e1ca3..afb958933 100644 --- a/tex/context/base/mkxl/context.mkxl +++ b/tex/context/base/mkxl/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \immutable\edef\contextformat {\jobname} -\immutable\edef\contextversion{2021.10.24 21:42} +\immutable\edef\contextversion{2021.10.28 10:17} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error @@ -387,6 +387,7 @@ \loadmkxlfile{typo-tal} \loadmkxlfile{typo-par} % par builders (uses fonts) +\loadmkxlfile{typo-lbx} \loadmkxlfile{tabl-com} %loadmarkfile{tabl-pln} diff --git a/tex/context/base/mkxl/grph-inc.lmt b/tex/context/base/mkxl/grph-inc.lmt index 8c4cb62b3..0ba4b093c 100644 --- a/tex/context/base/mkxl/grph-inc.lmt +++ b/tex/context/base/mkxl/grph-inc.lmt @@ -1316,7 +1316,7 @@ function figures.identify(data) for i=1,#list do local identifier = list[i] local data = identifier(data) - if data and (not data.status and data.status.status > 0) then + if data and data.status and (not data.status and data.status.status > 0) then break end end diff --git a/tex/context/base/mkxl/node-par.lmt b/tex/context/base/mkxl/node-par.lmt index 290c2fbd8..fb492b84b 100644 --- a/tex/context/base/mkxl/node-par.lmt +++ b/tex/context/base/mkxl/node-par.lmt @@ -95,6 +95,23 @@ do end +-- These are node handlers but fit it the overall paragraph handling so we +-- hook it into the callback here. + +do + + local localboxactions = nodes.tasks.actions("localboxes") + + function localboxfilter(...) + starttiming(builders) + localboxactions(...) + stoptiming(builders) + end + + callbacks.register("local_box_filter",localboxfilter,"process local boxes") + +end + -- This means that we now have most callbacks in use, even the ones that I'm not sure -- about. It also means that with the above enabled we might have performance now at -- its worst. I can optimize this a little but it's not worth the effort (and added diff --git a/tex/context/base/mkxl/node-tsk.lmt b/tex/context/base/mkxl/node-tsk.lmt index 61e5bc0d4..c12c9597e 100644 --- a/tex/context/base/mkxl/node-tsk.lmt +++ b/tex/context/base/mkxl/node-tsk.lmt @@ -952,3 +952,55 @@ nonut = [[ -- -- } -- } + +-- -- localboxes -- -- + +tasks.new { + name = "localboxes", + processor = nodeprocessor, + sequence = { + "before", -- for users + "lists", + "after", -- for users + }, + templates = { + +default = [[ +return function(head) +end +]], + +process = [[ +local tonut = nodes.tonut +local tonode = nodes.nuts.tonode + +%localize% + +-- line,leftbox,rightbox,linenumber,leftskip,rightskip,lefthang,righthang,indent,parfillleftskip,parfillrightskip + +return function(line,leftbox,rightbox,...) + nutline = tonut(line) + nutleftbox = leftbox and tonut(leftbox) + nutrightbox = rightbox and tonut(rightbox) +%actions% +end +]], + +step = [[ + tonut((%action%(line,leftbox,rightbox,...))) +]], + +nut = [[ + %action%(nutline,nutleftbox,nutrightbox,...) +]], + +nohead = [[ + %action%(line,leftbox,rightbox,...) +]], + +nonut = [[ + %action%(nutline,nutleftbox,nutrightbox,...) +]], + + } +} diff --git a/tex/context/base/mkxl/spac-hor.mkxl b/tex/context/base/mkxl/spac-hor.mkxl index 0b047ccff..06a8f74f4 100644 --- a/tex/context/base/mkxl/spac-hor.mkxl +++ b/tex/context/base/mkxl/spac-hor.mkxl @@ -1217,4 +1217,16 @@ \permanent\protected\def\interwordspacesafter #1{\dofastloopcs{#1}\interwordspaceafter} \permanent\protected\def\interwordspaces #1{\wordboundary\zwnj\dofastloopcs{\numexpr#1+\minusone}\interwordspaceafter} +%D For mp: + +\installcorenamespace{mplocation} + +\defcsname\??mplocation\v!left \endcsname{1} +\defcsname\??mplocation\v!right\endcsname{2} +\defcsname\??mplocation\v!inner\endcsname{3} +\defcsname\??mplocation\v!outer\endcsname{4} + +\permanent\def\mplocation#1{\ifcsname\??mplocation#1\endcsname\lastnamedcs\else0\fi} +%permanent\def\mplocation#1{\csname\??mplocation\ifcsname\??mplocation#1\endcsname#1\else\v!left\fi\endcsname} + \protect \endinput diff --git a/tex/context/base/mkxl/syst-ini.mkxl b/tex/context/base/mkxl/syst-ini.mkxl index a873d15a3..11b7c1262 100644 --- a/tex/context/base/mkxl/syst-ini.mkxl +++ b/tex/context/base/mkxl/syst-ini.mkxl @@ -1414,4 +1414,9 @@ \autoparagraphmode\plusone % we need at least 1 in order to be able to switch to 2 %autoparagraphmode\plustwo % because we define two \par delimited macros +%D The same values apply as \type {\shownodedetails}. When set the box is shown in +%D the the log file but that is pretty slow when we have much detail. + +\tracingfullboxes\zerocount + \protect \endinput diff --git a/tex/context/base/mkxl/task-ini.lmt b/tex/context/base/mkxl/task-ini.lmt index 78d7ab657..0018ed690 100644 --- a/tex/context/base/mkxl/task-ini.lmt +++ b/tex/context/base/mkxl/task-ini.lmt @@ -151,6 +151,8 @@ appendaction("everypar", "normalizers", "nodes.handlers.checkparcounter", appendaction("alignments", "normalizers", "nodes.handlers.aligncharacter", nil, "nut", "disabled" ) +appendaction("localboxes", "lists", "typesetters.localboxes.handler", nil, "nut", "enabled" ) + -- some protection freezecallbacks("find_.*_file", "find file using resolver") @@ -189,6 +191,8 @@ freezegroup("everypar", "normalizers") freezegroup("alignments", "normalizers") +freezegroup("localboxes", "lists") + -- new: disabled here directives.register("nodes.basepass", function(v) diff --git a/tex/context/base/mkxl/typo-lbx.lmt b/tex/context/base/mkxl/typo-lbx.lmt new file mode 100644 index 000000000..00ba1cc7f --- /dev/null +++ b/tex/context/base/mkxl/typo-lbx.lmt @@ -0,0 +1,179 @@ +if not modules then modules = { } end modules ['typo-lbx'] = { + version = 1.001, + optimize = true, + comment = "companion to typo-lbx.mkxl", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local tostring = tostring + +local nuts = nodes.nuts + +local left_box_code = nodes.listcodes.left +local right_box_code = nodes.listcodes.right +local hlist_code = nodes.nodecodes.hlist + +local getlist = nuts.getlist +local getprev = nuts.getprev +local getnext = nuts.getnext +local getattribute = nuts.getattribute +local gettail = nuts.tail +local getwidth = nuts.getwidth +local setlist = nuts.setlist +local setoffsets = nuts.setoffsets +local flushlist = nuts.flushlist +local takebox = nuts.takebox +local setbox = nuts.setbox +local copynode = nuts.copynode +local rangedimensions = nuts.rangedimensions +local traverse_list = nuts.traversers.list + +local expandmacro = token.expandmacro + +local dimension_value = tokens.values.dimension +local integer_value = tokens.values.integer + +local implement = interfaces.implement + +typesetters = typesetters or { } +local typesetters = typesetters + +typesetters.localboxes = typesetters.localboxes or { } +local localboxes = typesetters.localboxes + +local a_localboxes = attributes.private("localboxes") + +local starttiming = statistics.starttiming +local stoptiming = statistics.stoptiming + +do + + local lb_attribute = 0 + local lb_linenumber = 0 + local lb_width = 0 + local lb_offset = 0 + local lb_leftskip = 0 + local lb_rightskip = 0 + local lb_lefthang = 0 + local lb_righthang = 0 + local lb_indent = 0 + local lb_parfillleftskip = 0 + local lb_parfillrightskip = 0 + local lb_overshoot = 0 + + implement { name = "localboxattribute", public = true, usage = "value", actions = function() return integer_value, lb_attribute end } + implement { name = "localboxlinenumber", public = true, usage = "value", actions = function() return integer_value, lb_linenumber end } + implement { name = "localboxwidth", public = true, usage = "value", actions = function() return dimension_value, lb_width end } + implement { name = "localboxoffset", public = true, usage = "value", actions = function() return dimension_value, lb_offset end } + implement { name = "localboxleftskip", public = true, usage = "value", actions = function() return dimension_value, lb_leftskip end } + implement { name = "localboxrightskip", public = true, usage = "value", actions = function() return dimension_value, lb_rightskip end } + implement { name = "localboxlefthang", public = true, usage = "value", actions = function() return dimension_value, lb_lefthang end } + implement { name = "localboxrighthang", public = true, usage = "value", actions = function() return dimension_value, lb_righthang end } + implement { name = "localboxindent", public = true, usage = "value", actions = function() return dimension_value, lb_indent end } + implement { name = "localboxparfillleftskip", public = true, usage = "value", actions = function() return dimension_value, lb_parfillleftskip end } + implement { name = "localboxparfillrightskip", public = true, usage = "value", actions = function() return dimension_value, lb_parfillrightskip end } + implement { name = "localboxovershoot", public = true, usage = "value", actions = function() return dimension_value, lb_overshoot end } + + local function action(current,where) + -- We can have nested leftboxes! + local l = getlist(current) + setlist(current) + local h = copynode(current) + setlist(h,l) + setbox("localboxcontentbox",h) + expandmacro("localboxcommand") -- no longer pass arguments + local b = takebox("localboxcontentbox") + setlist(current,b) + if where == "left" then + local w = getwidth(b) + setoffsets(b,lb_width - lb_offset - w) + else + setoffsets(b,lb_offset - lb_width) + end + end + + local function processleftbox(box,width) + local list = getlist(box) + if not width then + width = 0 + end + for current, id, subtype in traverse_list, list do + if id == hlist_code then + local a = getattribute(current,a_localboxes) + if a then + lb_attribute = a + lb_width = width + rangedimensions(box,list,getprev(current)) + action(current,"left") + end + if subtype == left_box_code then + processleftbox(current,width + rangedimensions(box,list,getprev(current))) + end + end + end + end + + local function processrightbox(box,width) + local list = getlist(box) + local tail = gettail(list) + if not width then + width = 0 + end + for current, id, subtype in traverse_list, list do + if id == hlist_code then + local a = getattribute(current,a_localboxes) + if a then + lb_attribute = a + lb_width = width + rangedimensions(box,list,getnext(current),tail) + action(current,"right") + end + if subtype == right_box_code then + processrightbox(current,width + rangedimensions(box,getnext(current),tail)) + end + end + end + end + + local function processlocalboxes(line, leftbox, rightbox, linenumber, leftskip, rightskip, lefthang, righthang, indent, parfillleftskip, parfillrightskip, overshoot) + -- + lb_attribute = 0 + lb_linenumber = linenumber + lb_width = 0 + -- lb_offset = 0 + lb_leftskip = leftskip + lb_rightskip = rightskip + lb_lefthang = lefthang + lb_righthang = righthang + lb_indent = indent + lb_parfillleftskip = parfillleftskip + lb_parfillrightskip = parfillrightskip + lb_overshoot = overshoot + -- + -- for now we always anchor + -- + if leftbox then + lb_offset = leftskip + lefthang + indent + parfillleftskip + getwidth(leftbox) + processleftbox(leftbox) + end + if rightbox then + lb_offset = rightskip + righthang + parfillrightskip + getwidth(rightbox) - overshoot + processrightbox(rightbox) + end + end + + typesetters.localboxes.handler = processlocalboxes + +end + +local localboxactions = nodes.tasks.actions("localboxes") + +function builders.local_box_filter(...) + starttiming(builders) + localboxactions(...) + stoptiming(builders) +end + +-- we register the function elsewhere + +callbacks.register("local_box_filter", builders.local_box_filter, "process local boxes") diff --git a/tex/context/base/mkxl/typo-lbx.mkxl b/tex/context/base/mkxl/typo-lbx.mkxl new file mode 100644 index 000000000..f8d252a27 --- /dev/null +++ b/tex/context/base/mkxl/typo-lbx.mkxl @@ -0,0 +1,229 @@ +%D \module +%D [ file=typo-dig, +%D version=2010.01.18, +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Digits, +%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 Typesetting Macros / Local Boxes} + +% musical timestamp: New Scary Goldings ft. John Scofield MonoNeon & Louis Cole (late +% October 2021) + +% maybe: \iflocalleftbox + +\registerctxluafile{typo-lbx}{autosuffix} + +%D The advantage is that it's deal with in the par builder which has some advantages +%D but when used in complex situation there can be side effects. Therefore is should +%D be considered a somewhat low level mechanism on top of which one can write more +%D mechanisms that provide more rendering control. Also, keep in mind that combining +%D many instances at the same time add some complizity. Therefore, for the moment it's +%D a playground. + + +\unprotect + +\def\v!lefttext {lefttext} +\def\v!righttext{righttext} + +\appendtoks + \localleftbox {}% \nolocalboxes : we don't have a nice command category for it + \localrightbox{}% +\to\everyforgetall + +\definesystemattribute[localboxes][public] + +%D We used to pass arguments but there might be many so ... + +\newbox\localboxcontentbox + +\installcorenamespace{localboxes} +\installcorenamespace{localboxesattribute} +\installcorenamespace{localboxesnamespace} +\installcorenamespace{localboxeslocations} + +\installcommandhandler \??localboxes {localboxes} \??localboxes + +\setuplocalboxes + [\c!location=\v!left] + +\newcount\c_typo_localboxes + +\appendtoks + \global\advance\c_typo_localboxes\plusone + \global\expandafter\integerdef\csname\??localboxesattribute\currentlocalboxes\endcsname\c_typo_localboxes + \gletcsname\??localboxesnamespace\number\c_typo_localboxes\endcsname\currentlocalboxes +\to \everydefinelocalboxes + +%D The optional argument forces seting the \quote {whole} paragraph properties (which is needed +%D when the assignment happens after e.g.\ \type {\everypar} but is also meant for the first +%D line. + +\def\typo_paragraphs_l#1{\localleftbox \ifcstok{#1}\v!global par\fi} +\def\typo_paragraphs_r#1{\localrightbox\ifcstok{#1}\v!global par\fi} + +\permanent\tolerant\protected\def\leftparbox [#1]{\typo_paragraphs_l{#1}\bgroup\enforced\let\leftparbox \relax\let\next} +\permanent\tolerant\protected\def\rightparbox [#1]{\typo_paragraphs_r{#1}\bgroup\enforced\let\rightparbox\relax\let\next} + +\permanent\tolerant\protected\def\appendleftparbox [#1]{\dowithnextbox{\leftparbox [#1]{\the\localleftbox \unhbox\nextbox}}\hbox} +\permanent\tolerant\protected\def\appendrightparbox [#1]{\dowithnextbox{\rightparbox[#1]{\the\localrightbox\unhbox\nextbox}}\hbox} + +\permanent\tolerant\protected\def\prependleftparbox [#1]{\dowithnextbox{\leftparbox [#1]{\unhbox\nextbox\the\localleftbox }}\hbox} +\permanent\tolerant\protected\def\prependrightparbox[#1]{\dowithnextbox{\rightparbox[#1]{\unhbox\nextbox\the\localrightbox}}\hbox} + +\permanent\tolerant\protected\def\resetleftparbox [#1]{\typo_paragraphs_l{#1}{}} +\permanent\tolerant\protected\def\resetrightparbox [#1]{\typo_paragraphs_r{#1}{}} + +% called back: + +\permanent\protected\def\localboxcommand + {\ifcsname\??localboxesnamespace\number\localboxattribute\endcsname + %\edef\currentlocalboxes{\lastnamedcs}% + \expandafter\let\expandafter\currentlocalboxes\lastnamedcs + \setbox\localboxcontentbox\hbox + {\uselocalboxesstyleandcolor\c!style\c!color + \localboxesparameter\c!command}% + \fi} + +%D We don't group because we set the local boxes. Also, watch out: by injecting the +%D existing local box we create nested ones. This is handled in the callback but if +%D really needed one can do something like (do we need a primitive?): + +% \localrightbox{% +% \the\localrightbox +% \setbox\scratchbox\lastbox +% \unhbox\scratchbox +% additional}% + +\def\typo_localboxes_zero#1#2% + {\ifcsname\??localboxesattribute#1\endcsname + \hpack attr \localboxesattribute \lastnamedcs to \zeropoint \bgroup + \edef\currentlocalboxes{#1}% + #2% + \egroup + \fi} + +\def\typo_localboxes_asis#1#2% + {\hpack \bgroup % todo: use width if dimension, use distance if given + \edef\currentlocalboxes{#1}% + \localboxesparameter\c!command{#2}% + \egroup} + +\defcsname\??localboxeslocations\v!left\endcsname#1#2% + {\leftparbox \bgroup + \typo_localboxes_zero{#1}{#2}% + \the\localleftbox + \egroup} + +\defcsname\??localboxeslocations\v!right\endcsname#1#2% + {\rightparbox \bgroup + \the\localrightbox + \typo_localboxes_zero{#1}{#2}% + \egroup} + +\defcsname\??localboxeslocations\v!lefttext\endcsname#1#2% + {\leftparbox \bgroup + \typo_localboxes_asis{#1}{#2}% + \the\localleftbox + \egroup} + +\defcsname\??localboxeslocations\v!righttext\endcsname#1#2% + {\rightparbox \bgroup + \the\localrightbox + \typo_localboxes_asis{#1}{#2}% + \egroup} + +\permanent\tolerant\protected\def\localbox[#1]% + {\dowithnextboxcontent + {\edef\currentlocalboxes{#1}% + \uselocalboxesstyleandcolor\c!style\c!color} + {\ifcsname\??localboxeslocations\namedlocalboxesparameter{#1}\c!location\endcsname + \expandafter\lastnamedcs + \else + \csname\??localboxeslocations\v!left\expandafter\endcsname + \fi{#1}{\unhbox\nextbox}}% + \hbox} + +\permanent\tolerant\protected\def\startlocalbox[#1]% + {\dowithnextbox + {\ifcsname\??localboxeslocations\namedlocalboxesparameter{#1}\c!location\endcsname + \expandafter\lastnamedcs + \else + \csname\??localboxeslocations\v!left\expandafter\endcsname + \fi{#1}{\unhbox\nextbox}}% + \hbox\bgroup + \edef\currentlocalboxes{#1}% + \uselocalboxesstyleandcolor\c!style\c!color + \enforced\def\stoplocalbox{\removeunwantedspaces\egroup}% + \ignorespaces} + +\aliased\let\stoplocalbox\donothing + +%D Here is an example of usage: + +%D \starttyping +%D \definelocalboxes +%D [linenumber] +%D [command=\LeftNumber,location=left,width=3em,style=\bs,color=darkred] +%D +%D \definelocalboxes +%D [linenumbertwo] [linenumber] +%D [command=\RightNumber,location=right,width=6em,style=\bf,color=darkgreen] +%D +%D \definelocalboxes +%D [linetext] +%D [command=\LeftText,location=lefttext,style=\bs,color=darkblue] +%D +%D \definelocalboxes +%D [linetexttwo] [linetext] +%D [command=\RightText,location=righttext,style=\bf,color=darkgray] +%D +%D % \def\LineNumberL{\the\localboxlinenumber} +%D % \def\LineNumberR{\the\localboxlinenumber} +%D +%D % \newcount\MyLineNumberL +%D % \newcount\MyLineNumberR +%D % \def\LineNumberL{\global\advance\MyLineNumberL\plusone\the\MyLineNumberL} +%D % \def\LineNumberR{\global\advance\MyLineNumberR\plusone\the\MyLineNumberR} +%D +%D \definecounter[MyLineNumberL] +%D \definecounter[MyLineNumberR] +%D +%D \setupcounter[MyLineNumberL][numberconversion=characters] +%D \setupcounter[MyLineNumberR][numberconversion=romannumerals] +%D +%D \def\LineNumberL{\incrementcounter[MyLineNumberL]\convertedcounter[MyLineNumberL]} +%D \def\LineNumberR{\incrementcounter[MyLineNumberR]\convertedcounter[MyLineNumberR]} +%D +%D \protected\def\LeftNumber {\hbox to \localboxesparameter{width}{\strut(\LineNumberL\hss)}} +%D \protected\def\RightNumber{\hbox to \localboxesparameter{width}{\strut(\hss\LineNumberR)}} +%D +%D % \protected\def\LeftNumber {\hbox to \localboxesparameter{width}{\strut\box\localboxcontentbox\hss)}} +%D % \protected\def\RightNumber{\hbox to \localboxesparameter{width}{\strut(\hss\box\localboxcontentbox)}} +%D +%D \protected\def\LeftText #1{#1\quad} +%D \protected\def\RightText#1{\quad#1} +%D +%D \start +%D \localbox[linenumber]{}% +%D \localbox[linenumbertwo]{}% +%D \localbox[linetext]{L}% +%D \startlocalbox[linetexttwo] +%D R +%D \stoplocalbox +%D \dorecurse{100}{ +%D \samplefile{tufte} +%D \par +%D } +%D \stop +%D \stoptyping + +\protect \endinput + diff --git a/tex/context/interface/mkii/keys-ro.xml b/tex/context/interface/mkii/keys-ro.xml index 158a8b8ac..447cfd580 100644 --- a/tex/context/interface/mkii/keys-ro.xml +++ b/tex/context/interface/mkii/keys-ro.xml @@ -191,6 +191,7 @@ + diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 550f1096f..27a2037c1 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 : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 2021-10-24 21:42 +-- merge date : 2021-10-28 10:17 do -- begin closure to overcome local limits and interference -- cgit v1.2.3