diff options
author | Hans Hagen <pragma@wxs.nl> | 2021-02-27 20:17:05 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2021-02-27 20:17:05 +0100 |
commit | 4f7f67101a808c6b6c89d64ad5ee1f1701d8f632 (patch) | |
tree | c5f90a0b8e8a4e9d2cab82a0abebc65c6a93288e /tex | |
parent | c3ae4997f73041c6b97d8aec055ba24096602ab4 (diff) | |
download | context-4f7f67101a808c6b6c89d64ad5ee1f1701d8f632.tar.gz |
2021-02-27 19:30:00
Diffstat (limited to 'tex')
33 files changed, 1032 insertions, 169 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 6c083cd0b..b1c603769 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.02.23 17:41} +\newcontextversion{2021.02.27 19:27} %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 4b20c792e..8486049d0 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.02.23 17:41} +\edef\contextversion{2021.02.27 19:27} %D For those who want to use this: diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 60bb0d85d..c984f50cf 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.02.23 17:41} +\newcontextversion{2021.02.27 19:27} %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 b5d86869c..e2afeb0d4 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -45,7 +45,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2021.02.23 17:41} +\edef\contextversion{2021.02.27 19:27} %D Kind of special: diff --git a/tex/context/base/mkiv/mlib-mpf.lua b/tex/context/base/mkiv/mlib-mpf.lua index 00ebb1ae5..7452c0111 100644 --- a/tex/context/base/mkiv/mlib-mpf.lua +++ b/tex/context/base/mkiv/mlib-mpf.lua @@ -927,6 +927,11 @@ do function mp.setcount(k,v) setcount(k,v) end function mp.settoks (k,v) settoks (k,v) end + function mp.setglobalmacro(k,v) setmacro(k,v,"global") end + function mp.setglobaldimen(k,v) setdimen("global",k,v/bpfactor) end + function mp.setglobalcount(k,v) setcount("global",k,v) end + function mp.setglobaltoks (k,v) settoks ("global",k,v) end + -- def foo = lua.mp.foo ... enddef ; % loops due to foo in suffix mp._get_macro_ = mp.getmacro @@ -939,6 +944,11 @@ do mp._set_count_ = mp.setcount mp._set_toks_ = mp.settoks + mp._set_global_macro_ = mp.setglobalmacro + mp._set_global_dimen_ = mp.setglobaldimen + mp._set_global_count_ = mp.setglobalcount + mp._set_global_toks_ = mp.setglobaltoks + end -- position fun diff --git a/tex/context/base/mkiv/mtx-context-select.tex b/tex/context/base/mkiv/mtx-context-select.tex index 5ae151f90..61f58d61f 100644 --- a/tex/context/base/mkiv/mtx-context-select.tex +++ b/tex/context/base/mkiv/mtx-context-select.tex @@ -1,5 +1,3 @@ -% engine=luatex - %D \module %D [ file=mtx-context-select, %D version=2008.11.10, % about that time i started playing with this diff --git a/tex/context/base/mkiv/mult-fun.lua b/tex/context/base/mkiv/mult-fun.lua index 7bfda80bc..4ecbb1abd 100644 --- a/tex/context/base/mkiv/mult-fun.lua +++ b/tex/context/base/mkiv/mult-fun.lua @@ -176,6 +176,7 @@ return { "isarray", "prefix", "dimension", "getmacro", "getdimen", "getcount", "gettoks", "setmacro", "setdimen", "setcount", "settoks", + "setglobalmacro", "setglobaldimen", "setglobalcount", "setglobaltoks", -- "positionpath", "positioncurve", "positionxy", "positionpxy", "positionwhd", "positionpage", "positionregion", "positionbox", diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex b1533b02b..0b1992890 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex a2c0ea9a5..b52a1d01d 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/util-str.lua b/tex/context/base/mkiv/util-str.lua index 2d3f4d669..0d1f39de9 100644 --- a/tex/context/base/mkiv/util-str.lua +++ b/tex/context/base/mkiv/util-str.lua @@ -70,27 +70,63 @@ local function points(n) n = n * ptf if n % 1 == 0 then return format("%ipt",n) + else + return lpegmatch(stripzeros,format("%.5fpt",n)) -- plural as we need to keep the pt + end +end + +local function nupoints(n) + if n == 0 then + return "0" + end + n = tonumber(n) + if not n or n == 0 then + return "0" + end + n = n * ptf + if n % 1 == 0 then + return format("%i",n) + else + return format("%.5f",n) -- no strip end - return lpegmatch(stripzeros,format("%.5fpt",n)) -- plural as we need to keep the pt end local function basepoints(n) if n == 0 then - return "0pt" + return "0bp" end n = tonumber(n) if not n or n == 0 then - return "0pt" + return "0bp" end n = n * bpf if n % 1 == 0 then return format("%ibp",n) + else + return lpegmatch(stripzeros,format("%.5fbp",n)) -- plural as we need to keep the pt + end +end + +local function nubasepoints(n) + if n == 0 then + return "0" + end + n = tonumber(n) + if not n or n == 0 then + return "0" + end + n = n * bpf + if n % 1 == 0 then + return format("%i",n) + else + return format("%.5f",n) -- no strip end - return lpegmatch(stripzeros,format("%.5fbp",n)) -- plural as we need to keep the pt end -number.points = points -number.basepoints = basepoints +number.points = points +number.nupoints = nupoints +number.basepoints = basepoints +number.nubasepoints = nubasepoints -- str = " \n \ntest \n test\ntest " -- print("["..string.gsub(string.collapsecrlf(str),"\n","+").."]") @@ -357,7 +393,9 @@ end -- U+hexadecimal %...u character number -- U+HEXADECIMAL %...U character number -- points %p number (scaled points) +-- nupoints %P number (scaled points) / without unit / always 5 decimals -- basepoints %b number (scaled points) +-- nubasepoints %B number (scaled points) / without unit / always 5 decimals -- table concat %...t table -- table concat %{.}t table -- serialize %...T sequenced (no nested tables) @@ -616,7 +654,9 @@ local environment = { concat = table.concat, signed = number.signed, points = number.points, + nupoints = number.nupoints, basepoints = number.basepoints, + nubasepoints = number.nubasepoints, utfchar = utf.char, utfbyte = utf.byte, lpegmatch = lpeg.match, @@ -879,11 +919,21 @@ local format_p = function() return format("points(a%s)",n) end +local format_P = function() + n = n + 1 + return format("nupoints(a%s)",n) +end + local format_b = function() n = n + 1 return format("basepoints(a%s)",n) end +local format_B = function() + n = n + 1 + return format("nubasepoints(a%s)",n) +end + local format_t = function(f) n = n + 1 if f and f ~= "" then @@ -1125,7 +1175,7 @@ local builder = Cs { "start", -- + V("r") + V("h") + V("H") + V("u") + V("U") - + V("p") + V("b") + + V("p") + V("P") + V("b") + V("B") + V("t") + V("T") + V("l") + V("L") + V("I") @@ -1174,8 +1224,10 @@ local builder = Cs { "start", ["H"] = (prefix_any * P("H")) / format_H, -- %H => 0x0A1B2 (when - no 0x) was V ["u"] = (prefix_any * P("u")) / format_u, -- %u => u+0a1b2 (when - no u+) ["U"] = (prefix_any * P("U")) / format_U, -- %U => U+0A1B2 (when - no U+) - ["p"] = (prefix_any * P("p")) / format_p, -- %p => 12.345pt / maybe: P (and more units) - ["b"] = (prefix_any * P("b")) / format_b, -- %b => 12.342bp / maybe: B (and more units) + ["p"] = (prefix_any * P("p")) / format_p, -- %p => 12.345pt + ["P"] = (prefix_any * P("P")) / format_P, -- %p => 12.345 + ["b"] = (prefix_any * P("b")) / format_b, -- %b => 12.342bp + ["B"] = (prefix_any * P("B")) / format_B, -- %b => 12.342 ["t"] = (prefix_tab * P("t")) / format_t, -- %t => concat ["T"] = (prefix_tab * P("T")) / format_T, -- %t => sequenced ["l"] = (prefix_any * P("l")) / format_l, -- %l => boolean diff --git a/tex/context/base/mkxl/bibl-tra.mkxl b/tex/context/base/mkxl/bibl-tra.mkxl index 8c24024fd..536de8d31 100644 --- a/tex/context/base/mkxl/bibl-tra.mkxl +++ b/tex/context/base/mkxl/bibl-tra.mkxl @@ -354,9 +354,10 @@ \protected\def\dousepublications#1% {\doonlyonce{#1.\f!bibextension}{\dodousepublications{#1}}} +\pushoverloadmode + \protected\def\dodousepublications#1% brr, this par stuff - {\let\@@savedpar\par - \let\par\ignorespaces + {\enforced\let\par\ignorespaces \ifhmode\kern\zeropoint\fi \pushcatcodetable \setcatcodetable\ctxcatcodes @@ -365,7 +366,9 @@ {\showmessage\m!publications{2}{#1.\f!bibextension}}% \popcatcodetable \ifhmode\removeunwantedspaces\fi - \let\par\@@savedpar} + \enforced\let\par\normalpar} + +\popoverloadmode %D \macros{setuppublicationlist} %D diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index 26de0b443..8e2816e46 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.02.23 17:41} +\newcontextversion{2021.02.27 19:27} %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 f72721c9c..4976b707d 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.02.23 17:41} +\immutable\edef\contextversion{2021.02.27 19:27} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error diff --git a/tex/context/base/mkxl/meta-imp-txt.lmt b/tex/context/base/mkxl/meta-imp-txt.lmt new file mode 100644 index 000000000..f7721956f --- /dev/null +++ b/tex/context/base/mkxl/meta-imp-txt.lmt @@ -0,0 +1,86 @@ +if not modules then modules = { } end modules ['meta-imp-txt'] = { + version = 1.001, + comment = "companion to meta-imp-txt.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files", +} + +local setmetatableindex = table.setmetatableindex + +local texset = tex.set + +local scannumeric = mp.scan.numeric +local scaninteger = mp.scan.integer +local scanboolean = mp.scan.boolean +local scanstring = mp.scan.string + +local bpfactor = number.dimenfactors.bp + +local metapost = metapost + +local parshapes = { } +local properties = { } + +-- initialize shapes to 0 hsize + +metapost.parshapes = { } + +function metapost.parshapes.reset() + parshapes = { } + properties = { } +end + +function metapost.parshapes.next() + properties = { } + parshapes[#parshapes+1] = properties +end + +function metapost.parshapes.inspect() + inspect(parshapes) +end + +function metapost.parshapes.get(index,name) + local v = parshapes[index][name] + if type(v) == "boolean" then + context(v and 1 or 0) + else + context(v) + end +end + +function metapost.parshapes.wholeshape() -- maybe just collect them earlier + local t, n = { }, 0 + for i=1,#parshapes do + local s = parshapes[i].shape + for i=1,#s do + n = n + 1 + t[n] = s[i] + end + end + texset("parshape",t) +end + +metapost.registerscript("setparshapeproperty", function() + local k = scanstring() + if k == "line" then + local entry = properties.shape[scannumeric()] + local indent = scannumeric() / bpfactor + local width = scannumeric() / bpfactor + entry[1] = indent + entry[2] = width + elseif k == "lines" then + properties.lines = scaninteger() + properties.shape = setmetatableindex(function(t,k) + local v = { 0, properties.width or 0 } + t[k] = v + return v + end) + elseif k == "first" then + properties[k] = scanboolean() + elseif k == "inspect" then + inspect(properties) + else + properties[k] = scannumeric() / bpfactor + end +end) diff --git a/tex/context/base/mkxl/meta-imp-txt.mkxl b/tex/context/base/mkxl/meta-imp-txt.mkxl new file mode 100644 index 000000000..4654ca722 --- /dev/null +++ b/tex/context/base/mkxl/meta-imp-txt.mkxl @@ -0,0 +1,339 @@ +%D \module +%D [ file=meta-txt, +%D version=2000.07.06, +%D title=\METAPOST\ Graphics, +%D subtitle=Text Tricks, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D See comments in the \MKIV\ module. This is an upgraded version for \LMTX, +%D where we can so some things nicer. + +\unprotect + +%D Text in shapes. Here we use the option to prune a parshape when a new paragraph +%D is seen. It's an experimental feature so I need to keep an eye on how it evolves. +%D This time we combine \TEX, \METAPOST\ and \LUA, so we do't need a temporary file +%D to communicate from \METAPOST\ to \TEX. We just store information in \LUA\ tables. + +\ifdefined\startshapetext + + % now moved into the core + +\else + + \ifdefined\shapetextbox \else + \newbox \shapetextbox + \newcount\shapetextindex + \fi + + \ctxloadluafile{meta-imp-txt.lmt} + + \startMPextensions loadmodule "text" ; \stopMPextensions + + \protected\def\startshapetext[#1]% + {\begingroup + \global\shapetextindex\zerocount + \global\setbox\shapetextbox\vbox\bgroup + % analyze the mp shapes + \ctxlua{metapost.parshapes.reset()} + \def\docommand##1% + {\ctxlua{metapost.parshapes.next()}% + \startMPcalculation + \includeMPgraphic{##1}% + \stopMPcalculation}% + \processcommalist[#1]\docommand + \forgetall + \dontcomplain + % setup tex part (maybe just enable grid snapping) + \setuptolerance[\v!verytolerant,\v!stretch]% default + \setuplayout[\c!grid=\v!yes]% + \ctxlua{metapost.parshapes.wholeshape()}% + \pushparagraphtweak {prune}} + + \protected\def\stopshapetext + {\popparagraphtweak + \egroup + \endgroup} + + \def\getshapeparameter#1{\ctxlua{metapost.parshapes.get(\number\shapetextindex,"#1")}} + + \protected\def\getshapetext + {\vbox\bgroup + \forgetall + \dontcomplain + \global\advance\shapetextindex\plusone + \scratchcounter\getshapeparameter{lines}\relax + \scratchwidth \getshapeparameter{width}\scaledpoint\relax + \scratchheight \getshapeparameter{height}\scaledpoint\relax + \setbox\scratchbox\vpack to \scratchheight + {\splittopskip\strutheight + \vskip\dimexpr\getshapeparameter{voffset}\scaledpoint\relax + \ifcase\numexpr\getshapeparameter{first}\relax\else + \vskip\lineheight + \fi + \hskip\dimexpr\getshapeparameter{hoffset}\scaledpoint\relax + \hpack{\vsplit\shapetextbox to \scratchcounter\lineheight}}% + \wd\scratchbox\scratchwidth + \ht\scratchbox\scratchheight + \dp\scratchbox\zeropoint + \box\scratchbox + \egroup} + +\fi + +%D Following: + +% \doifundefined{RotFont}{\definefont[RotFont][RegularBold*default]} +% +% \unexpanded\def\getfollowtoken#1% +% {\hbox\bgroup +% \strut +% \ctxlua{mp.follow_text(#1)}% +% \egroup} + +\definefontfeature[mp:tp][liga=no] + +% if unknown RotPath : path RotPath ; RotPath := origin ; fi ; +% if unknown TraceRot : boolean TraceRot ; TraceRot := false ; fi ; +% if unknown ExtraRot : numeric ExtraRot ; ExtraRot := 0 ; fi ; +% if al < len[n]: +% RotPath := RotPath scaled ((len[n]+ExtraRot)/al) ; +% al := arclength RotPath ; +% fi ; +% if TraceRot : +% draw RotPath withpen pencircle scaled 1pt withcolor blue ; +% fi ; +% if TraceRot : +% draw boundingbox currentpicture withpen pencircle scaled .25pt withcolor blue ; +% fi ; + +\protected\def\dofollowtokens#1#2% + {\dontleavehmode + \vpack\bgroup + \forgetall + \dontcomplain + \addff{mp:tp}% + \startMPcode + \includeMPgraphic{followtokens} + draw lmt_followtext [ path = RotPath, text = "#2", spread = #1 ] ; + \stopMPcode + \egroup} + +\protected\def\followtokens {\dofollowtokens{true}} +\protected\def\followtokenscentered{\dofollowtokens{false}} + +%D Fuzzy counters: + +\startuseMPgraphic{fuzzycount} + begingroup + save height, span, drift, d, cp ; + height := 3/ 5 * LineHeight ; + span := 1/ 3 * height ; + drift := 1/10 * height ; + pickup pencircle scaled (1/12 * height) ; + 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) ; + endfor; + picture cp ; cp := currentpicture ; % for readability + setbounds currentpicture to + (llcorner cp shifted (0,-ypart llcorner cp) -- + lrcorner cp shifted (0,-ypart lrcorner cp) -- + urcorner cp -- + ulcorner cp -- cycle) ; + endgroup ; +\stopuseMPgraphic + +\setupMPvariables + [fuzzycount] + [n=10] + +\protected\def\fuzzycount#1% + {\dontleavehmode\bgroup + \tx + \useMPgraphic{fuzzycount}{n=#1}% + \egroup} + +\defineconversion[fuzzy][\fuzzycount] + +%D English rules: + +\setupMPvariables + [EnglishRule] + [height=1ex, + width=\localhsize, + color=darkgray] + +\defineblank + [EnglishRule] + [medium] + +\startuniqueMPgraphic{EnglishRule}{height,width,color} + x1 = 0 ; x3 = \MPvar{width} ; x2 = x4 = .5x3 ; + y1 = y3 = 0 ; y2 = -y4 = \MPvar{height} / 2 ; + fill z1 .. z2 .. z3 & z3 .. z4 .. z1 & cycle withcolor \MPvar{color} ; +\stopuniqueMPgraphic + +\protected\def\EnglishRule + {\startlinecorrection[EnglishRule]% + \setlocalhsize + \noindentation + \reuseMPgraphic{EnglishRule}% + \stoplinecorrection} + +%D Tight text (for old times sake): the following macro returns a tight bound +%D character sequence. +%D +%D \useMPlibrary[txt] +%D +%D \startlinecorrection +%D \TightText{\ss\bf 123}{0cm}{3cm}{red} +%D \stoplinecorrection + +\protected\def\TightText#1#2#3#4% + {\hpack + {\startMPcode + picture p ; p := image (graphictext "#1" withfillcolor red) ; + draw p xsized #2 ysized #3 withcolor \MPcolor{#4} ; + \stopMPcode}} + +\protected\def\TightText#1#2#3#4% + {\dontleavehmode + \startMPcode + draw outlinetext.f ("#1") (\iftok{#4}\emptytoks \else withcolor \MPcolor{#4} \fi) + \iftok{#2}\emptytoks \else xsized #2 \fi + \iftok{#3}\emptytoks \else ysized #3 \fi + ; + \stopMPcode} + +\protect + +\continueifinputfile{meta-imp-txt.mkxl} + +\setupbodyfont[pagella,10pt] + +% \useMPlibrary[txt] + +\starttext + +%D Shapes: + +\startuseMPgraphic{test 1} + path p ; p := fullcircle scaled 6cm ; + + build_parshape(p,BodyFontSize/2,0,0,LineHeight,StrutHeight,StrutDepth,StrutHeight) ; + + draw p withpen pencircle scaled 1pt ; +\stopuseMPgraphic + +\startuseMPgraphic{test 2} + path p ; p := fullsquare rotated 45 scaled 5cm ; + + build_parshape(p,BodyFontSize/2,0,0,LineHeight,StrutHeight,StrutDepth,StrutHeight) ; + + draw p withpen pencircle scaled 1pt ; +\stopuseMPgraphic + +\startuseMPgraphic{test 3} + numeric w, h ; w := h := 6cm ; + path p ; p := (.5w,h) -- (0,h) -- (0,0) -- (w,0) & + (w,0) .. (.75w,.5h) .. (w,h) & (w,h) -- cycle ; + + build_parshape(p,BodyFontSize/2,0,0,LineHeight,StrutHeight,StrutDepth,StrutHeight) ; + + draw p withpen pencircle scaled 1pt ; +\stopuseMPgraphic + +\startuseMPgraphic{test 4} + numeric w, h, o, d ; + + def shape = (o,o) -- (w-o,o) & (w-o,o) .. (.75w-o,.5h) .. + (w-2o,h-o) & (w-2o,h-o) -- (o,h-o) -- cycle + enddef ; + + d := BodyFontSize/2; + + w := h := 6cm ; o := d ; path p ; p := shape ; + w := h := 6cm ; o := 0 ; path q ; q := shape ; + + build_parshape(p,q,d,d,LineHeight,StrutHeight,StrutDepth,StrutHeight) ; + + draw q withpen pencircle scaled 1pt ; +\stopuseMPgraphic + +\defineoverlay[test 1][\useMPgraphic{test 1}] +\defineoverlay[test 2][\useMPgraphic{test 2}] +\defineoverlay[test 3][\useMPgraphic{test 3}] +\defineoverlay[test 4][\useMPgraphic{test 4}] + +\startbuffer + \startshapetext[test 1,test 2,test 3,test 4] + \setupalign[verytolerant,stretch,normal]% + \samplefile{douglas} % Douglas R. Hofstadter + \stopshapetext + \startTEXpage[offset=10pt] + \startcombination[2*2] + {\framed[offset=overlay,frame=off,background=test 1]{\getshapetext}} {test 1} + {\framed[offset=overlay,frame=off,background=test 2]{\getshapetext}} {test 2} + {\framed[offset=overlay,frame=off,background=test 3]{\getshapetext}} {test 3} + {\framed[offset=overlay,frame=off,background=test 4]{\getshapetext}} {test 4} + \stopcombination + \stopTEXpage +\stopbuffer + +\getbuffer + +\startMPextensions + boolean trace_parshape ; trace_parshape := true ; +\stopMPextensions + +\getbuffer + +%D Fuzzycount (maybe handy): + +\startitemize[fuzzy,nostopper] + \startitem This is real fuzzy. \stopitem + \startitem But it can be even more fuzzier. \stopitem + \startitem And how about this. \stopitem +\stopitemize + +\EnglishRule + +\startitemize[continue,broad] + \startitem This is real fuzzy. \stopitem + \startitem But it can be even more fuzzier. \stopitem + \startitem And how about this. \stopitem +\stopitemize + +%D Tight text (manual stuff): + +\ruledhbox{\TightText{oeps wat doet dit}{10cm}{1cm}{red}} \blank +\ruledhbox{\TightText{oeps wat doet dit}{10cm}{} {green}} \blank +\ruledhbox{\TightText{oeps wat doet dit}{} {1cm}{blue}} \blank +\ruledhbox{\TightText{oeps wat doet dit}{} {} {}} \blank + +%D Old fashioned: + +\startuseMPgraphic{followtokens} + path RotPath ; RotPath := reverse halfcircle xyscaled 3cm ; + draw RotPath ; +\stopuseMPgraphic + +\startTEXpage + \followtokens{{\hskip1em}some text{\hskip1em}} +\stopTEXpage + +\startTEXpage + \followtokenscentered{{\hskip1em}some text{\hskip1em}} +\stopTEXpage + +\stoptext diff --git a/tex/context/base/mkxl/mlib-lua.lmt b/tex/context/base/mkxl/mlib-lua.lmt index cb2718f9b..e8f33a53a 100644 --- a/tex/context/base/mkxl/mlib-lua.lmt +++ b/tex/context/base/mkxl/mlib-lua.lmt @@ -9,9 +9,15 @@ if not modules then modules = { } end modules ['mlib-lua'] = { local type = type local insert, remove = table.insert, table.remove +local trace = false trackers.register("metapost.instance",function(v) trace = v end) + +local report = logs.reporter("metapost","instance") + local codes = mplib.getcodes() local types = mplib.gettypes() +-- for k,v in next, mplib do if type(v) == "function" then local f = v mplib[k] = function(...) print(k) return v(...) end end end + table.hashed(codes) table.hashed(types) @@ -26,6 +32,9 @@ local inject = mp.inject local currentmpx = nil local stack = { } +local function reports(s) report("%a scan %s", tostring(currentmpx),s) end -- temporary, till we're okay +local function reporti(s) report("%a inject %s",tostring(currentmpx),s) end -- temporary, till we're okay + local scan_next = mplib.scan_next local scan_expression = mplib.scan_expression local scan_token = mplib.scan_token @@ -46,21 +55,21 @@ local skip_token = mplib.skip_token local get_hashentry = mplib.gethashentry -scan.next = function(k) return scan_next (currentmpx,k) end -scan.expression = function(k) return scan_expression(currentmpx,k) end -scan.token = function(k) return scan_token (currentmpx,k) end -scan.symbol = function(k,e) return scan_symbol (currentmpx,k,e) end -scan.property = function(k) return scan_property (currentmpx,k) end -scan.numeric = function() return scan_numeric (currentmpx) end -scan.integer = function() return scan_integer (currentmpx) end -scan.boolean = function() return scan_boolean (currentmpx) end -scan.string = function() return scan_string (currentmpx) end -scan.pair = function(t) return scan_pair (currentmpx,t) end -scan.color = function(t) return scan_color (currentmpx,t) end -scan.cmykcolor = function(t) return scan_cmykcolor (currentmpx,t) end -scan.transform = function(t) return scan_transform (currentmpx,t) end -scan.path = function(t) return scan_path (currentmpx,t) end -scan.pen = function(t) return scan_pen (currentmpx,t) end +scan.next = function(k) if trace then reporti("next") end return scan_next (currentmpx,k) end +scan.expression = function(k) if trace then reporti("expression") end return scan_expression(currentmpx,k) end +scan.token = function(k) if trace then reporti("token") end return scan_token (currentmpx,k) end +scan.symbol = function(k,e) if trace then reporti("symbol") end return scan_symbol (currentmpx,k,e) end +scan.property = function(k) if trace then reporti("property") end return scan_property (currentmpx,k) end +scan.numeric = function() if trace then reporti("numeric") end return scan_numeric (currentmpx) end +scan.integer = function() if trace then reporti("integer") end return scan_integer (currentmpx) end +scan.boolean = function() if trace then reporti("boolean") end return scan_boolean (currentmpx) end +scan.string = function() if trace then reporti("string") end if currentmpx then return scan_string (currentmpx) end end +scan.pair = function(t) if trace then reporti("pair") end return scan_pair (currentmpx,t) end +scan.color = function(t) if trace then reporti("color") end return scan_color (currentmpx,t) end +scan.cmykcolor = function(t) if trace then reporti("cmykcolor") end return scan_cmykcolor (currentmpx,t) end +scan.transform = function(t) if trace then reporti("transform") end return scan_transform (currentmpx,t) end +scan.path = function(t) if trace then reporti("path") end return scan_path (currentmpx,t) end +scan.pen = function(t) if trace then reporti("pen") end return scan_pen (currentmpx,t) end skip.token = function(t) return skip_token (currentmpx,t) end @@ -84,16 +93,17 @@ local inject_cmykcolor = mplib.inject_cmykcolor local inject_transform = mplib.inject_transform local inject_whatever = mplib.inject_whatever -------.path = function(t,cycle,curled) return inject_path (currentmpx,t,cycle,curled) end -inject.numeric = function(n) return inject_numeric (currentmpx,n) end -inject.pair = function(x,y) return inject_pair (currentmpx,x,y) end -inject.boolean = function(b) return inject_boolean (currentmpx,b) end -inject.integer = function(i) return inject_integer (currentmpx,i) end -inject.string = function(s) return inject_string (currentmpx,s) end -inject.color = function(r,g,b) return inject_color (currentmpx,r,g,b) end -inject.cmykcolor = function(c,m,y,k) return inject_cmykcolor(currentmpx,c,m,y,k) end -inject.transform = function(x,y,xx,xy,yx,yy) return inject_transform(currentmpx,x,y,xx,xy,yx,yy) end -inject.whatever = function(...) return inject_whatever (currentmpx,...) end + +------.path = function(t,cycle,curled) if trace then reporti("path") end return inject_path (currentmpx,t,cycle,curled) end +inject.numeric = function(n) if trace then reporti("numeric") end return inject_numeric (currentmpx,n) end +inject.pair = function(x,y) if trace then reporti("pair") end return inject_pair (currentmpx,x,y) end +inject.boolean = function(b) if trace then reporti("boolean") end return inject_boolean (currentmpx,b) end +inject.integer = function(i) if trace then reporti("integer") end return inject_integer (currentmpx,i) end +inject.string = function(s) if trace then reporti("string") end return inject_string (currentmpx,s) end +inject.color = function(r,g,b) if trace then reporti("color") end return inject_color (currentmpx,r,g,b) end +inject.cmykcolor = function(c,m,y,k) if trace then reporti("cmykcolor") end return inject_cmykcolor(currentmpx,c,m,y,k) end +inject.transform = function(x,y,xx,xy,yx,yy) if trace then reporti("transform") end return inject_transform(currentmpx,x,y,xx,xy,yx,yy) end +inject.whatever = function(...) if trace then reporti("whatever") end return inject_whatever (currentmpx,...) end inject.triplet = inject.color inject.quadruplet = inject.cmykcolor @@ -136,6 +146,7 @@ function inject.path(p,close,connector) end end end + if trace then reporti("path") end return inject_path(currentmpx,p,close,curled) end @@ -173,12 +184,19 @@ function mp.autoinject(m) end function metapost.pushscriptrunner(mpx) - insert(stack,mpx) + if trace then + report("%a => %a",tostring(currentmpx),tostring(mpx)) + end + insert(stack,currentmpx) currentmpx = mpx end function metapost.popscriptrunner() - currentmpx = remove(stack,mpx) + local mpx = remove(stack) + if trace then + report("%a <= %a",tostring(mpx),tostring(currentmpx)) + end + currentmpx = mpx end function metapost.currentmpx() diff --git a/tex/context/base/mkxl/mlib-mpf.lmt b/tex/context/base/mkxl/mlib-mpf.lmt index d66491a16..42cee676c 100644 --- a/tex/context/base/mkxl/mlib-mpf.lmt +++ b/tex/context/base/mkxl/mlib-mpf.lmt @@ -943,6 +943,12 @@ do registerscript("setcount", function() setcount(scanstring(),scannumeric()) end) registerscript("settoks", function() settoks (scanstring(),scanstring()) end) + registerscript("setglobalmacro", function() setmacro(scanstring(),scanstring(),"global") end) + registerscript("setglobaldimen", function() setdimen("global",scanstring(),scannumeric()/bpfactor) end) + registerscript("setglobalcount", function() setcount("global",scanstring(),scannumeric()) end) + registerscript("setglobaltoks", function() settoks ("global",scanstring(),scanstring()) end) + + local utfnum = utf.byte local utflen = utf.len local utfsub = utf.sub diff --git a/tex/context/base/mkxl/mlib-pps.lmt b/tex/context/base/mkxl/mlib-pps.lmt index 31ef130a3..32f23c39d 100644 --- a/tex/context/base/mkxl/mlib-pps.lmt +++ b/tex/context/base/mkxl/mlib-pps.lmt @@ -565,26 +565,6 @@ local function checkaskedfig(askedfig) -- return askedfig, wrappit end end -local function extrapass() - if trace_runs then - report_metapost("second run of job %s, asked figure %a",top.nofruns,top.askedfig) - end - metapost.preparetextextsdata() - runmetapost { - mpx = top.mpx, - askedfig = top.askedfig, - incontext = true, - data = { - top.wrappit and do_begin_fig or "", - no_trial_run, - top.initializations, - do_safeguard, - top.data, - top.wrappit and do_end_fig or "", - }, - } -end - -- This one is called from the \TEX\ end so the specification is different -- from the specification to metapost,run cum suis! The definitions and -- extension used to be handled here but are now delegated to the format diff --git a/tex/context/base/mkxl/mlib-run.lmt b/tex/context/base/mkxl/mlib-run.lmt index 8ab998bb8..a79ce99ef 100644 --- a/tex/context/base/mkxl/mlib-run.lmt +++ b/tex/context/base/mkxl/mlib-run.lmt @@ -535,7 +535,7 @@ function metapost.run(specification) tra.log:write(banner) end stoptiming(metapost) - metapost.popscriptrunner(mpx) + metapost.popscriptrunner() end if mpxdone then metapost.popformat() diff --git a/tex/context/base/mkxl/mult-sys.mkxl b/tex/context/base/mkxl/mult-sys.mkxl index 64cedbfad..3e1d32a91 100644 --- a/tex/context/base/mkxl/mult-sys.mkxl +++ b/tex/context/base/mkxl/mult-sys.mkxl @@ -571,7 +571,7 @@ %D The setup files for the language, font, color and special subsystems have a common %D prefix. This means that we have at most three characters for unique filenames. -\definefileconstant {colo_run} {s-colors-run} +\definefileconstant {colo_run} {s-colors-show} \definefileconstant {font_run} {s-fonts-show} \definefileconstant {page_run} {s-layout-show} \definefileconstant {symb_run} {s-symbols-show} diff --git a/tex/context/base/mkxl/node-par.lmt b/tex/context/base/mkxl/node-par.lmt index af3125d23..9354d769f 100644 --- a/tex/context/base/mkxl/node-par.lmt +++ b/tex/context/base/mkxl/node-par.lmt @@ -13,36 +13,76 @@ local sequencers = utilities.sequencers -- This are called a lot! -local actions = nodes.tasks.actions("everypar") +do + + local actions = nodes.tasks.actions("everypar") + + local function everypar(head) + starttiming(builders) + head = actions(head) + stoptiming(builders) + return head + end + + callbacks.register("insert_par",everypar,"after paragraph start") -local function everypar(head) - starttiming(builders) - head = actions(head) - stoptiming(builders) - return head end -callbacks.register("insert_par",everypar,"after paragraph start") +do -local actions = sequencers.new { - name = "paragraph", - arguments = "mode,indented", - returnvalues = "indented", - results = "indented", -} + local actions = sequencers.new { + name = "paragraph", + arguments = "mode,indented,context", + returnvalues = "indented", + results = "indented", + } -sequencers.appendgroup(actions,"before") -- user -sequencers.appendgroup(actions,"system") -- private -sequencers.appendgroup(actions,"after" ) -- user + sequencers.appendgroup(actions,"before") -- user + sequencers.appendgroup(actions,"system") -- private + sequencers.appendgroup(actions,"after" ) -- user -local function paragraph(mode,indented) - local runner = actions.runner - if runner then - starttiming(builders) - indented = runner(mode,indented) - stoptiming(builders) + local function paragraph(mode,indented) + local runner = actions.runner + if runner then + starttiming(builders) + indented = runner(mode,indented) + stoptiming(builders) + end + return indented end - return indented + + callbacks.register("begin_paragraph",paragraph,"before paragraph start") + end -callbacks.register("begin_paragraph",paragraph,"before paragraph start") +-- This one is a playground for some old metafun gimmicks that I want to improve +-- while I'm updating the manual to lmtx. but it might also be useful for other +-- purposes. It fits in the category obscure and probably takes while to stabelize +-- (if it stays at all). + +do + + local actions = sequencers.new { + name = "paragraphcontext", + arguments = "context", + returnvalues = "ignore", + results = "ignore", + } + + ----------.appendgroup(actions,"before") -- user + sequencers.appendgroup(actions,"system") -- private + ----------.appendgroup(actions,"after" ) -- user + + local function parcontext(parcontext) + local runner = actions.runner + if runner then + starttiming(builders) + local ignore = runner(parcontext) + stoptiming(builders) + return ignore + end + end + + callbacks.register("paragraph_context",parcontext,"when the context is dealt with") + +end diff --git a/tex/context/base/mkxl/pack-mrl.mkxl b/tex/context/base/mkxl/pack-mrl.mkxl index 678afb68a..8bbeeb798 100644 --- a/tex/context/base/mkxl/pack-mrl.mkxl +++ b/tex/context/base/mkxl/pack-mrl.mkxl @@ -771,7 +771,7 @@ \begingroup \def\pack_fillinrules_rule_indeed{\unhbox\nextbox\unskip}% hm, needs checking \dowithnextbox{\fillinrules[#1]{#2}{\hfill#3}}% - \hbox\bgroup\let\par\egroup\ignorespaces} + \hbox\bgroup\enforced\let\par\egroup\ignorespaces} % bah, i will drop this compatibility hack %D \macros %D {fillinline, setupfillinlines} diff --git a/tex/context/base/mkxl/page-imp.mkxl b/tex/context/base/mkxl/page-imp.mkxl index 89a2be030..4ee7c159b 100644 --- a/tex/context/base/mkxl/page-imp.mkxl +++ b/tex/context/base/mkxl/page-imp.mkxl @@ -76,7 +76,7 @@ \endgroup} \permanent\protected\def\installshipoutmethod#1#2% % a handler takes one argument: something to be boxed - {\setgvalue{\??shipoutmethod#1}##1{#2{##1}}} % and shipped out (don't depend on the exact package) + {\gdefcsname\??shipoutmethod#1\endcsname##1{#2{##1}}} % and shipped out (don't depend on the exact package) \aliased\let\installpagehandler\installshipoutmethod % will go @@ -257,7 +257,7 @@ \global\advance\paperheight-2\dimexpr\paperoffset/\arrangedpageY\relax} \permanent\protected\def\doinstallarrangedoption#1#2% - {\setvalue{\??layoutarrangeoption#1}{#2}} + {\gdefcsname\??layoutarrangeoption#1\endcsname{#2}} \permanent\def\doinstalledarrangedoption#1% {\ifcsname\??layoutarrangeoption#1\endcsname @@ -306,6 +306,10 @@ \doinstallarrangedoption\v!background {\global\settrue\arrangedbackgroundstate} +\aliased\let\poparrangedpages \relax +\aliased\let\pusharrangedpage \gobbleoneargument +\aliased\let\handlearrangedpage\relax + \permanent\protected\def\setuparranging[#1]% {\ifconditional\arrangingdisabledstate \else %global\setfalse\arrangingdisabledstate @@ -316,9 +320,10 @@ \global\setfalse\arrangedswapstate \gdef\arrangedrotationO{0}% \gdef\arrangedrotationE{180}% + % if we use --arrange we have an initial "disable" here \processcommalist[#1]\doinstalledarrangedoption - \ifdefined\handlearrangedpage\else - \global\arrangingpagesfalse + \ifrelax\poparrangedpages + \global\arrangingpagesfalse % nothing set yet \fi \setuppapersize \ifarrangingpages @@ -331,24 +336,20 @@ \fi} \permanent\protected\def\installpagearrangement #1 % will change, no space - {\setgvalue{\??layoutarranger#1}} + {\gdefcsname\??layoutarranger#1\endcsname} \permanent\def\checkinstalledpagearrangement#1% can be empty: aaa,,bbb {\begincsname\??layoutarranger#1\endcsname} -\aliased\let\poparrangedpages \relax -\aliased\let\pusharrangedpage \relax -\aliased\let\handlearrangedpage\relax - \permanent\protected\def\dosetuparrangement#1#2#3#4#5#6#7#8% {\global\arrangedpageX #1% \global\arrangedpageY #2% \global\arrangedpageT #3% \global\c_page_marks_nx#4% \global\c_page_marks_ny#5% - \enforced\permanent\glet\pusharrangedpage #6% - \enforced\permanent\glet\poparrangedpages #7% - \enforced\permanent\glet\handlearrangedpage#8} + \enforced\glet\pusharrangedpage #6% + \enforced\glet\poparrangedpages #7% + \enforced\glet\handlearrangedpage#8} \installpagearrangement {\v!normal} {\global\arrangingpagesfalse} diff --git a/tex/context/base/mkxl/spac-def.mkxl b/tex/context/base/mkxl/spac-def.mkxl index bba0d47f2..294843cce 100644 --- a/tex/context/base/mkxl/spac-def.mkxl +++ b/tex/context/base/mkxl/spac-def.mkxl @@ -45,7 +45,7 @@ % maybe more \prependtoks - \let\par\normalpar + \enforced\let\par\normalpar \to \everybeforepagebody % see \fillinline (was endgraf) % needs checking: diff --git a/tex/context/base/mkxl/spac-grd.mkxl b/tex/context/base/mkxl/spac-grd.mkxl index 0f21db726..65739cabe 100644 --- a/tex/context/base/mkxl/spac-grd.mkxl +++ b/tex/context/base/mkxl/spac-grd.mkxl @@ -33,19 +33,19 @@ \fi \endcsname} -\setvalue{\??lastnodepusher\number\kernnodecode}% +\defcsname\??lastnodepusher\number\kernnodecode\endcsname {\enforced\permanent\protected\edef\poplastnode{\kern\the\lastkern\relax}% \kern-\lastkern} -\setvalue{\??lastnodepusher\number\gluenodecode}% +\defcsname\??lastnodepusher\number\gluenodecode\endcsname {\enforced\permanent\protected\edef\poplastnode{\vskip\the\lastskip\relax}% \vskip-\lastskip} -\setvalue{\??lastnodepusher\number\penaltynodecode}% +\defcsname\??lastnodepusher\number\penaltynodecode\endcsname {\enforced\permanent\protected\edef\poplastnode{\penalty\the\lastpenalty\relax}% \nobreak} -\setvalue{\??lastnodepusher\s!unknown}% +\defcsname\??lastnodepusher\s!unknown\endcsname {\enforced\permanent\let\poplastnode\relax} %D Moved from supp-box: diff --git a/tex/context/base/mkxl/spac-par.mkxl b/tex/context/base/mkxl/spac-par.mkxl index 134a60e2a..06aeee4d8 100644 --- a/tex/context/base/mkxl/spac-par.mkxl +++ b/tex/context/base/mkxl/spac-par.mkxl @@ -453,4 +453,59 @@ \expandafter\firstofoneargument \fi} +%D Something new (experimental and evolving): +%D +%D \starttyping +%D \parshape +%D 3 +%D options 1 % repeat +%D 0cm 10cm 2cm 8cm 4cm 6cm +%D lots of text +%D \stoptyping +%D +%D \starttyping +%D \parshape 4 5mm 125mm 0mm 120mm 5mm 125mm 0mm 120mm +%D \pushparagraphtweak {repeat} +%D verse line 1\crlf +%D verse line 2\crlf +%D verse line 3\crlf +%D verse line 4\par +%D etc +%D \popparagraphtweak +%D \stoptyping + +%D But we wrap this in a more abstract interface: + +\installcorenamespace {parshapes} + +% \installcommandhandler \??shapedparagraph {shapedparagraph} \??shapedparagraph + +\aliased\let\stopparagraphshape\relax + +\permanent\protected\def\startparagraphshape[#1]#2\stopparagraphshape + {\defcsname\??parshapes#1\endcsname{#2}} + +\permanent\protected\def\rawparagraphshape#1% + {\begincsname\??parshapes#1\endcsname} + +\permanent\protected\def\setparagraphshape[#1]% + {\ifcsname\??parshapes#1\endcsname + \expandafter\clf_setparagraphshape\lastnamedcs done\relax + \fi} + +% \permanent\protected\tolerant\def\startshapedparagraph[#1]#*[#2]% no grouping +% {\setparshape[#1]% +% \pushparagraphtweak{#2}\relax} + +\permanent\protected\tolerant\def\startshapedparagraph[#1]% no grouping + {\begingroup + \getdummyparameters[\c!method=,\c!list=,#1]% + \normalexpanded + {\endgroup + \setparagraphshape[\dummyparameter\c!list]% + \pushparagraphtweak{\dummyparameter\c!method}\relax}} + +\permanent\protected\def\stopshapedparagraph + {\popparagraphtweak} + \protect \endinput diff --git a/tex/context/base/mkxl/spac-ver.mkxl b/tex/context/base/mkxl/spac-ver.mkxl index 6787c7cad..d11611339 100644 --- a/tex/context/base/mkxl/spac-ver.mkxl +++ b/tex/context/base/mkxl/spac-ver.mkxl @@ -112,12 +112,12 @@ \aliased\let\setrelativeinterlinespace \relax % used elsewhere \mutable\let\currentrelativeinterlinespace\empty -\setvalue{\??interlinespacerelative\v!on }{\oninterlineskip} -\setvalue{\??interlinespacerelative\v!off }{\offinterlineskip} -\setvalue{\??interlinespacerelative\v!reset}{\enforced\let\currentrelativeinterlinespace\empty - \enforced\let\setrelativeinterlinespace\relax - \setfontparameters} -\setvalue{\??interlinespacerelative\v!auto }{\enforced\let\setrelativeinterlinespace\spac_linespacing_set_relative_interlinespace} +\defcsname\??interlinespacerelative\v!on \endcsname{\oninterlineskip} +\defcsname\??interlinespacerelative\v!off \endcsname{\offinterlineskip} +\defcsname\??interlinespacerelative\v!reset\endcsname{\enforced\let\currentrelativeinterlinespace\empty + \enforced\let\setrelativeinterlinespace\relax + \setfontparameters} +\defcsname\??interlinespacerelative\v!auto \endcsname{\enforced\let\setrelativeinterlinespace\spac_linespacing_set_relative_interlinespace} \def\spac_linespacing_set_specified_relative_interlinespace#1% fragile? {\doifelsedimenstring{#1}% @@ -1244,14 +1244,14 @@ %D Keyword based strutting: -\letvalue{\??struts\v!yes }\setstrut -\letvalue{\??struts\v!auto }\setautostrut -\letvalue{\??struts\v!no }\setnostrut -\letvalue{\??struts\v!cap }\setcapstrut -\letvalue{\??struts\v!fit }\setfontstrut -\letvalue{\??struts\v!line }\setstrut -\letvalue{\??struts\s!default}\setstrut -\letvalue{\??struts\empty }\setstrut +\letcsname\??struts\v!yes \endcsname\setstrut +\letcsname\??struts\v!auto \endcsname\setautostrut +\letcsname\??struts\v!no \endcsname\setnostrut +\letcsname\??struts\v!cap \endcsname\setcapstrut +\letcsname\??struts\v!fit \endcsname\setfontstrut +\letcsname\??struts\v!line \endcsname\setstrut +\letcsname\??struts\s!default\endcsname\setstrut +\letcsname\??struts\empty \endcsname\setstrut %D Handy: @@ -2333,12 +2333,12 @@ {\stopbaselinecorrection \egroup} -\letvalue{\??fixedalternatives \v!high}\bbox -\letvalue{\??fixedalternatives \v!low}\tbox -\letvalue{\??fixedalternatives \v!middle}\vcenter -\letvalue{\??fixedalternatives \v!lohi}\vcenter -\letvalue{\??fixedalternatives\s!unknown}\tbox -\letvalue{\??fixedalternatives\s!default}\tbox +\letcsname\??fixedalternatives \v!high\endcsname\bbox +\letcsname\??fixedalternatives \v!low\endcsname\tbox +\letcsname\??fixedalternatives \v!middle\endcsname\vcenter +\letcsname\??fixedalternatives \v!lohi\endcsname\vcenter +\letcsname\??fixedalternatives\s!unknown\endcsname\tbox +\letcsname\??fixedalternatives\s!default\endcsname\tbox \protected\def\typo_fixed_finish#1% {\expandnamespacevalue\??fixedalternatives{#1}\s!default{\box\nextbox}} diff --git a/tex/context/base/mkxl/syst-ini.mkxl b/tex/context/base/mkxl/syst-ini.mkxl index 0efbaaaa7..50304d104 100644 --- a/tex/context/base/mkxl/syst-ini.mkxl +++ b/tex/context/base/mkxl/syst-ini.mkxl @@ -1131,9 +1131,9 @@ %D For now here: will get a proper solution -\pushoverloadmode -\mutable\let\par\par -\popoverloadmode +% \pushoverloadmode +% \mutable\let\par\par +% \popoverloadmode %D Also here: diff --git a/tex/context/base/mkxl/tabl-tbl.mkxl b/tex/context/base/mkxl/tabl-tbl.mkxl index 9eede7720..88cd791e4 100644 --- a/tex/context/base/mkxl/tabl-tbl.mkxl +++ b/tex/context/base/mkxl/tabl-tbl.mkxl @@ -760,11 +760,11 @@ \installcorenamespace{tabulatecolorspec} -\setvalue{\??tabulatecolorspec C}#1{\xdef\m_tabl_tabulate_color {#1}\global\c_tabl_tabulate_colorspan\zerocount} -\setvalue{\??tabulatecolorspec L}#1{\xdef\m_tabl_tabulate_color {#1}\global\c_tabl_tabulate_colorspan\plusone } -\setvalue{\??tabulatecolorspec M}#1{\xdef\m_tabl_tabulate_color {#1}\global\c_tabl_tabulate_colorspan\plustwo } -\setvalue{\??tabulatecolorspec R}#1{\xdef\m_tabl_tabulate_color {#1}\global\c_tabl_tabulate_colorspan\plusthree} -\setvalue{\??tabulatecolorspec T}#1{\xdef\m_tabl_tabulate_text_color{#1}} +\defcsname\??tabulatecolorspec C\endcsname#1{\xdef\m_tabl_tabulate_color {#1}\global\c_tabl_tabulate_colorspan\zerocount} +\defcsname\??tabulatecolorspec L\endcsname#1{\xdef\m_tabl_tabulate_color {#1}\global\c_tabl_tabulate_colorspan\plusone } +\defcsname\??tabulatecolorspec M\endcsname#1{\xdef\m_tabl_tabulate_color {#1}\global\c_tabl_tabulate_colorspan\plustwo } +\defcsname\??tabulatecolorspec R\endcsname#1{\xdef\m_tabl_tabulate_color {#1}\global\c_tabl_tabulate_colorspan\plusthree} +\defcsname\??tabulatecolorspec T\endcsname#1{\xdef\m_tabl_tabulate_text_color{#1}} \def\tabl_tabulate_set_color_span#1#2% {\csname\??tabulatecolorspec#1\endcsname{#2}% @@ -1163,19 +1163,40 @@ \let\currenttabulationparent\empty \tabl_start_regular} +% \tolerant\protected\def\tabl_start_regular[#1]#*[#2]% [format] | [settings] | [format] [settings] | [settings] [format] +% {\let\currenttabulation\currenttabulationparent +% \iftok{#1}\emptytoks +% \ifhastok={#2}\relax +% \setupcurrenttabulation[#2]% +% \fi +% \orelse\ifhastok={#1}\relax +% \iftok{#2}\emptytoks\else +% \settabulationparameter\c!format{#2}% +% \fi +% \setupcurrenttabulation[#1]% +% \else +% \settabulationparameter\c!format{#1}% +% \ifhastok={#2}\relax +% \setupcurrenttabulation[#2]% +% \fi +% \fi +% \tabl_tabulate_start_building} + \tolerant\protected\def\tabl_start_regular[#1]#*[#2]% [format] | [settings] | [format] [settings] | [settings] [format] {\let\currenttabulation\currenttabulationparent \iftok{#1}\emptytoks \ifhastok={#2}\relax \setupcurrenttabulation[#2]% \fi - \orelse\ifhastok={#1} - \ifhastok{#2}\relax + \orelse\ifhastok={#1}\relax + \iftok{#2}\emptytoks\else \settabulationparameter\c!format{#2}% \fi \setupcurrenttabulation[#1]% \else - \settabulationparameter\c!format{#1}% + \iftok{#1}\emptytoks\else + \settabulationparameter\c!format{#1}% + \fi \ifhastok={#2}\relax \setupcurrenttabulation[#2]% \fi @@ -1194,10 +1215,10 @@ \enforced\letvalue{\e!start\v!tabulate}\tabl_tabulate_start_ignore % only the main one \to \everytabulate -\setvalue{\??tabulatesplit\v!yes }{\settrue\c_tabl_tabulate_split} -\setvalue{\??tabulatesplit\v!repeat}{\settrue\c_tabl_tabulate_split} -\setvalue{\??tabulatesplit\v!no }{\setfalse\c_tabl_tabulate_split} -\setvalue{\??tabulatesplit\v!auto }{\ifinsidefloat\ifinsidesplitfloat\else\setfalse\c_tabl_tabulate_split\fi\fi} +\defcsname\??tabulatesplit\v!yes \endcsname{\settrue\c_tabl_tabulate_split} +\defcsname\??tabulatesplit\v!repeat\endcsname{\settrue\c_tabl_tabulate_split} +\defcsname\??tabulatesplit\v!no \endcsname{\setfalse\c_tabl_tabulate_split} +\defcsname\??tabulatesplit\v!auto \endcsname{\ifinsidefloat\ifinsidesplitfloat\else\setfalse\c_tabl_tabulate_split\fi\fi} % todo: spacing around tabulate when bodyfont is set @@ -1548,13 +1569,13 @@ {\enforced\let#1\tabl_tabulate_column_inject_auto \enforced\let\\\tabl_tabulate_column_inject_auto} % brrr, will go -\setvalue{\??tabulateseparator\v!blank }{\s_tabl_tabulate_separator\bigskipamount} -\setvalue{\??tabulateseparator\v!depth }{\s_tabl_tabulate_separator\strutdp} -\setvalue{\??tabulateseparator\v!small }{\def\m_tabl_tabulate_separator_factor{.25}} -\setvalue{\??tabulateseparator\v!medium}{\def\m_tabl_tabulate_separator_factor{.5}} -\setvalue{\??tabulateseparator\v!big }{} -\setvalue{\??tabulateseparator\v!none }{\s_tabl_tabulate_separator\zeropoint\let\m_tabl_tabulate_separator_factor\zerocount} -\setvalue{\??tabulateseparator\v!grid }{\s_tabl_tabulate_separator\zeropoint\let\m_tabl_tabulate_separator_factor\zerocount} +\defcsname\??tabulateseparator\v!blank \endcsname{\s_tabl_tabulate_separator\bigskipamount} +\defcsname\??tabulateseparator\v!depth \endcsname{\s_tabl_tabulate_separator\strutdp} +\defcsname\??tabulateseparator\v!small \endcsname{\def\m_tabl_tabulate_separator_factor{.25}} +\defcsname\??tabulateseparator\v!medium\endcsname{\def\m_tabl_tabulate_separator_factor{.5}} +\defcsname\??tabulateseparator\v!big \endcsname{} +\defcsname\??tabulateseparator\v!none \endcsname{\s_tabl_tabulate_separator\zeropoint\let\m_tabl_tabulate_separator_factor\zerocount} +\defcsname\??tabulateseparator\v!grid \endcsname{\s_tabl_tabulate_separator\zeropoint\let\m_tabl_tabulate_separator_factor\zerocount} \def\tabl_tabulate_column_rule_separator_step#1% {\ifcsname\??tabulateseparator#1\endcsname @@ -1758,13 +1779,13 @@ %D Beware, we cannot use \type {\protected} on \type {\HL} cum suis, since \TEX's %D hard coded noalign lookahead fails on it! I mistakenly added this for a while. -\setvalue{\??tabulatealigning\v!normal}{0} -\setvalue{\??tabulatealigning\v!right }{1} -\setvalue{\??tabulatealigning\v!left }{2} -\setvalue{\??tabulatealigning\v!middle}{3} +\defcsname\??tabulatealigning\v!normal\endcsname{0} +\defcsname\??tabulatealigning\v!right \endcsname{1} +\defcsname\??tabulatealigning\v!left \endcsname{2} +\defcsname\??tabulatealigning\v!middle\endcsname{3} -\setvalue{\??tabulateheader\v!repeat}{\plusone} -\setvalue{\??tabulateheader\v!text }{\plustwo} +\defcsname\??tabulateheader\v!repeat\endcsname{\plusone} +\defcsname\??tabulateheader\v!text \endcsname{\plustwo} \protected\def\tabl_tabulate_bskip_first {\setbox\b_tabl_tabulate\vbox\bgroup\glet\tabl_tabulate_hook\tabl_tabulate_hook_nop} \protected\def\tabl_tabulate_eskip_first {\par\egroup\glet\tabl_tabulate_hook\tabl_tabulate_hook_yes} @@ -2584,13 +2605,13 @@ \pushoverloadmode -\permanent\protected\setuvalue{starttabulate}% +\permanent\protected\defcsname starttabulate\endcsname {\bgroup % whole thing \settrue\c_tabl_generic \let\currenttabulationparent\empty \tabl_start_regular} -\permanent\letvalue{stoptabulate}\relax % testcase cvs-002.tex +\permanent\letcsname stoptabulate\endcsname\relax % testcase cvs-002.tex \popoverloadmode diff --git a/tex/context/base/mkxl/typo-par.lmt b/tex/context/base/mkxl/typo-par.lmt new file mode 100644 index 000000000..c7204ecd2 --- /dev/null +++ b/tex/context/base/mkxl/typo-par.lmt @@ -0,0 +1,177 @@ +if not modules then modules = { } end modules ['typo-par'] = { + version = 1.001, + comment = "companion to node-ini.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- Just some experimental stuff .. trying to improve some ancient metafun manual +-- hackery that has been on the angenda for too long already. Names might names +-- anyway. + +local insert, remove = table.insert, table.remove + +local texget = tex.get +local texset = tex.set +local shiftparshape = tex.shiftparshape + +local sequencers = utilities.sequencers +local appendaction = sequencers.appendaction +local enableaction = sequencers.enableaction +local disableaction = sequencers.disableaction + +local stack = { } +local top = nil +local enabled = false + +interfaces.implement { + name = "pushparagraphtweak", + public = true, + protected = true, + arguments = "string", + actions = function(t) + insert(stack,top) + if not top then + enableaction("paragraphcontext","builders.checkparcontext") + enabled = true + end + top = t + end +} +interfaces.implement { + name = "popparagraphtweak", + public = true, + protected = true, + actions = function() + top = remove(stack) + if not top then + disableaction("paragraphcontext","builders.checkparcontext") + enabled = false + end + end +} + +function builders.checkparcontext(where) + if top and where == "normal" then + if top == "cycle" then + local s = texget("parshape",true) + if s then + local p = texget("prevgraf") + while p > s do + p = p - s + end + shiftparshape(p,true) + end + return true + elseif top == "shift" then + shiftparshape(texget("prevgraf")) + return true + end + end +end + +appendaction("paragraphcontext","system","builders.checkparcontext") + +-- Another experiment: continuing parshapes with alternative definitions: +-- +-- left d | right d | left d right d | both d | left d hsize d | +-- copy n | reset | repeat | done + +do + + local scanners = tokens.scanners + local scanword = scanners.word + local scandimen = scanners.dimen + local scancardinal = scanners.cardinal + + interfaces.implement { + name = "setparagraphshape", + protected = true, + actions = function() + local t = { } + local n = 0 + local h = texget("hsize") + while true do + local key = scanword() + ::AGAIN:: + if key == "left" then + local l = scandimen() + key = scanword() + if key == "right" then + n = n + 1 ; t[n] = { l, h - l - scandimen() } + elseif key == "hsize" then + n = n + 1 ; t[n] = { l, scandimen() } + else + n = n + 1 ; t[n] = { l, h } + goto AGAIN + end + elseif key == "right" then + n = n + 1 ; t[n] = { 0, h - scandimen() } + elseif key == "both" then + local b = scandimen() + n = n + 1 ; t[n] = { b, h - b - b } + elseif key == "copy" then + local c = scancardinal() + for i=1,c do + local m = n + 1 + t[m] = t[n] + n = m + end + elseif key == "done" then + -- in case the user ended with "done" + scanword() + break + elseif key == "repeat" then + t["repeat"] = true + elseif key == "reset" then + n = n + 1 ; t[n] = { 0, h } + break + else + logs.report("system","bad key %a in paragraphshape",key) + break + end + end + texset("parshape",t) + end, + } + + local NC = context.NC + local NR = context.NR + local VL = context.VL + + interfaces.implement { + name = "showparagraphshape", + protected = true, + public = true, + actions = function() + local p = texget("parshape") + if p then + -- only english interface (for now) + context.inleftmargin( + { + align = "flushright", + strut = "no", + width = "0pt", + -- voffset = "-\\lineheight" + }, function() + context.starttabulate { + before = "", + after = "", + unit = "2pt", + rulethickness = ".1pt", + format = "|rb{\\smallinfofont}|lb{\\smallinfofont}|" + } + for i=1,#p do + NC() context("%P",p[i][1]) + VL() context("%P",p[i][2]) + NC() NR() + end + context.stoptabulate() + end + ) + end + end + } + +end diff --git a/tex/context/base/mkxl/typo-par.mkxl b/tex/context/base/mkxl/typo-par.mkxl index de40c6568..22450e76e 100644 --- a/tex/context/base/mkxl/typo-par.mkxl +++ b/tex/context/base/mkxl/typo-par.mkxl @@ -26,5 +26,35 @@ %registerctxluafile{node-ltp}{optimize} \registerctxluafile{node-ltp}{} \registerctxluafile{trac-par}{} +\registerctxluafile{typo-par}{} + +%D Just a reminder: +%D +%D \starttyping +%D \def\whatever#1{#1mm \dimexpr\hsize-#1mm\relax} +%D +%D \parshape +%D 14 +%D options 1 % repeat +%D \whatever{0} \whatever {2}\whatever {4}\whatever{6}\whatever{8}\whatever{10}\whatever{12}\whatever{14} +%D \whatever{12}\whatever{10}\whatever{8}\whatever{6}\whatever {4}\whatever {2} +%D \pushparagraphtweak {repeat} +%D \dorecurse{10}{\samplefile{tufte} \samplefile{tufte} \par} +%D \popparagraphtweak +%D \page +%D +%D \dorecurse{2}{ +%D \parshape 4 5mm 125mm 0mm 120mm 5mm 125mm 0mm 120mm +%D \pushparagraphtweak {repeat} +%D \dorecurse{10}{ +%D verse line 1\crlf +%D verse line 2\crlf +%D verse line 3\crlf +%D verse line 4\par +%D } +%D \popparagraphtweak +%D \page +%D } +%D \stoptyping \protect \endinput diff --git a/tex/context/modules/mkxl/s-colors-show.mkxl b/tex/context/modules/mkxl/s-colors-show.mkxl index 7467acd4c..aa0e3227e 100644 --- a/tex/context/modules/mkxl/s-colors-show.mkxl +++ b/tex/context/modules/mkxl/s-colors-show.mkxl @@ -41,7 +41,7 @@ %D Palets -permanent\protected\tolerant\gdef\showpalet[#1]#*[#2]% +\permanent\protected\tolerant\gdef\showpalet[#1]#*[#2]% {\doifelsecolorpalet{#1} {\doifelseinset\v!vertical{#2}\colo_palets_show_vertical\colo_palets_show_horizontal{#1}{#2}}% {}} @@ -152,7 +152,7 @@ permanent\protected\tolerant\gdef\showpalet[#1]#*[#2]% %D Groups -permanent\protected\tolerant\gdef\showcolorgroup[#1]#*[#2]% +\permanent\protected\tolerant\gdef\showcolorgroup[#1]#*[#2]% {\doifcolor{#1:1} {\doifelseinset\v!vertical{#2}\colo_groups_show_vertical\colo_groups_show_horizontal{#1}{#2}}} diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 7952d615c..2880d77c0 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-02-23 17:41 +-- merge date : 2021-02-27 19:27 do -- begin closure to overcome local limits and interference @@ -3158,25 +3158,59 @@ local function points(n) n=n*ptf if n%1==0 then return format("%ipt",n) + else + return lpegmatch(stripzeros,format("%.5fpt",n)) + end +end +local function nupoints(n) + if n==0 then + return "0" + end + n=tonumber(n) + if not n or n==0 then + return "0" + end + n=n*ptf + if n%1==0 then + return format("%i",n) + else + return format("%.5f",n) end - return lpegmatch(stripzeros,format("%.5fpt",n)) end local function basepoints(n) if n==0 then - return "0pt" + return "0bp" end n=tonumber(n) if not n or n==0 then - return "0pt" + return "0bp" end n=n*bpf if n%1==0 then return format("%ibp",n) + else + return lpegmatch(stripzeros,format("%.5fbp",n)) + end +end +local function nubasepoints(n) + if n==0 then + return "0" + end + n=tonumber(n) + if not n or n==0 then + return "0" + end + n=n*bpf + if n%1==0 then + return format("%i",n) + else + return format("%.5f",n) end - return lpegmatch(stripzeros,format("%.5fbp",n)) end number.points=points +number.nupoints=nupoints number.basepoints=basepoints +number.nubasepoints=nubasepoints local rubish=spaceortab^0*newline local anyrubish=spaceortab+newline local stripped=(spaceortab^1/"")*newline @@ -3454,7 +3488,9 @@ local environment={ concat=table.concat, signed=number.signed, points=number.points, + nupoints=number.nupoints, basepoints=number.basepoints, + nubasepoints=number.nubasepoints, utfchar=utf.char, utfbyte=utf.byte, lpegmatch=lpeg.match, @@ -3649,10 +3685,18 @@ local format_p=function() n=n+1 return format("points(a%s)",n) end +local format_P=function() + n=n+1 + return format("nupoints(a%s)",n) +end local format_b=function() n=n+1 return format("basepoints(a%s)",n) end +local format_B=function() + n=n+1 + return format("nubasepoints(a%s)",n) +end local format_t=function(f) n=n+1 if f and f~="" then @@ -3805,7 +3849,7 @@ local builder=Cs { "start", +V("n") +V("N") +V("k") -+V("r")+V("h")+V("H")+V("u")+V("U")+V("p")+V("b")+V("t")+V("T")+V("l")+V("L")+V("I")+V("w") ++V("r")+V("h")+V("H")+V("u")+V("U")+V("p")+V("P")+V("b")+V("B")+V("t")+V("T")+V("l")+V("L")+V("I")+V("w") +V("W") +V("a") +V("A") @@ -3843,7 +3887,9 @@ local builder=Cs { "start", ["u"]=(prefix_any*P("u"))/format_u, ["U"]=(prefix_any*P("U"))/format_U, ["p"]=(prefix_any*P("p"))/format_p, + ["P"]=(prefix_any*P("P"))/format_P, ["b"]=(prefix_any*P("b"))/format_b, + ["B"]=(prefix_any*P("B"))/format_B, ["t"]=(prefix_tab*P("t"))/format_t, ["T"]=(prefix_tab*P("T"))/format_T, ["l"]=(prefix_any*P("l"))/format_l, |