diff options
author | Hans Hagen <pragma@wxs.nl> | 2012-07-21 13:05:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2012-07-21 13:05:00 +0200 |
commit | 7b3b116e3777e1dd17ef3d335b2a503a603bc264 (patch) | |
tree | 2c2e89ecc26d502df0e8170416317e7490443e11 /tex | |
parent | 3d9b3d2671f2e3f7f0b77099ecd5fbf677400cf4 (diff) | |
download | context-7b3b116e3777e1dd17ef3d335b2a503a603bc264.tar.gz |
beta 2012.07.21 13:05
Diffstat (limited to 'tex')
28 files changed, 461 insertions, 253 deletions
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 545963860..1ce6d3cff 100644 --- a/tex/context/base/cont-new.mkii +++ b/tex/context/base/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.07.20 00:58} +\newcontextversion{2012.07.21 13:05} %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/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 754b48578..e8deeca22 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{2012.07.20 00:58} +\newcontextversion{2012.07.21 13:05} %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/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex 58f649c2b..979ac35af 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png Binary files differindex 5192af42d..e81da871f 100644 --- a/tex/context/base/context-version.png +++ b/tex/context/base/context-version.png diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index b6fac744d..716ef999d 100644 --- a/tex/context/base/context.mkii +++ b/tex/context/base/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2012.07.20 00:58} +\edef\contextversion{2012.07.21 13:05} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 63bd13e3a..3bad2caba 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -25,7 +25,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2012.07.20 00:58} +\edef\contextversion{2012.07.21 13:05} %D For those who want to use this: diff --git a/tex/context/base/grph-epd.mkiv b/tex/context/base/grph-epd.mkiv index f8e7461c2..26c07e731 100644 --- a/tex/context/base/grph-epd.mkiv +++ b/tex/context/base/grph-epd.mkiv @@ -22,7 +22,7 @@ \defineoverlay[system:graphics:epdf][\directsetup{system:graphics:epdf}] \startsetups system:graphics:epdf - \ctxlua{figures.mergegoodies("\externalfiguresparameter\c!interaction")}% + \ctxlua{figures.mergegoodies("\externalfigureparameter\c!interaction")}% \reference[\figurereference]{}% todo: dest area \stopsetups @@ -39,7 +39,7 @@ \appendtoks \iflocation - \doif\figurefiletype{pdf}{\doifnot{\externalfiguresparameter\c!interaction}\v!none\grph_epdf_add_overlay}% + \doif\figurefiletype{pdf}{\doifnot{\externalfigureparameter\c!interaction}\v!none\grph_epdf_add_overlay}% \fi \to \externalfigurepostprocessors diff --git a/tex/context/base/grph-fig.mkiv b/tex/context/base/grph-fig.mkiv index 55264dd0c..864bd29fb 100644 --- a/tex/context/base/grph-fig.mkiv +++ b/tex/context/base/grph-fig.mkiv @@ -129,10 +129,10 @@ \ifvoid\b_grph_steps_colorbar\else\box\b_grph_steps_colorbar\fi}} % not really needed \unexpanded\def\grph_steps_one_referring(#1,#2)#3(#4,#5)#6[#7]% - {\position(#1,#2){\grph_steps_goto(#4,#5){\externalfiguresparameter\c!frames}[#7]}} + {\position(#1,#2){\grph_steps_goto(#4,#5){\externalfigureparameter\c!frames}[#7]}} \unexpanded\def\grph_steps_one_marking(#1,#2)#3(#4,#5)#6[#7]% - {\position(#1,#2){\grph_steps_this_is(#4,#5){\externalfiguresparameter\c!frames}[#7]}} + {\position(#1,#2){\grph_steps_this_is(#4,#5){\externalfigureparameter\c!frames}[#7]}} \unexpanded\def\grph_steps_one_remark(#1,#2)#3(#4,#5)% (x,y)(h,b)[...]{tekst} {\def\grph_steps_no_comment_indeed[##1]##2{}% @@ -172,10 +172,10 @@ {\dotripleargument\grph_steps_figure_process_indeed#1\stopfigure} \def\grph_steps_figure_process_indeed[#1][#2][#3]#4\stopfigure - {\doifelse{\externalfiguresparameter\c!option}\v!test + {\doifelse{\externalfigureparameter\c!option}\v!test {\teststartfigure[#1][#2][#3]#4\teststopfigure - \letexternalfiguresparameter\c!frames\v!on} - {\letexternalfiguresparameter\c!frames\v!off}% + \letexternalfigureparameter\c!frames\v!on} + {\letexternalfigureparameter\c!frames\v!off}% \setvalue{\??externalfigureinstance#1}% {\dosingleempty{\placestartfigure[#1][#2][#3]#4\placestopfigure}}} @@ -199,9 +199,9 @@ {\box\scratchbox}% \position(0,0) {\basegrid - [\c!nx=\externalfiguresparameter\c!xmax, + [\c!nx=\externalfigureparameter\c!xmax, \c!dx=\withoutpt\the\d_grph_steps_x, - \c!ny=\externalfiguresparameter\c!ymax, + \c!ny=\externalfigureparameter\c!ymax, \c!dy=\withoutpt\the\d_grph_steps_y, \c!xstep=1, \c!ystep=1, @@ -264,20 +264,20 @@ % Helpers: \def\grph_steps_calculate - {\ifnum0\externalfiguresparameter\c!xmax=\zerocount - \ifnum0\externalfiguresparameter\c!ymax=\zerocount - \setexternalfiguresparameter\c!ymax{24}% + {\ifnum0\externalfigureparameter\c!xmax=\zerocount + \ifnum0\externalfigureparameter\c!ymax=\zerocount + \setexternalfigureparameter\c!ymax{24}% \fi \d_grph_steps_y\figureheight - \divide\d_grph_steps_y \externalfiguresparameter\c!ymax + \divide\d_grph_steps_y \externalfigureparameter\c!ymax \d_grph_steps_x\d_grph_steps_y \scratchdimen\figurewidth \advance\scratchdimen\d_grph_steps_y \divide \scratchdimen\d_grph_steps_y - \setexternalfiguresparameter\c!xmax{\number\scratchdimen}% + \setexternalfigureparameter\c!xmax{\number\scratchdimen}% \else - \d_grph_steps_x\figurewidth \divide\d_grph_steps_x \externalfiguresparameter\c!xmax\relax - \d_grph_steps_y\figureheight \divide\d_grph_steps_y \externalfiguresparameter\c!ymax\relax + \d_grph_steps_x\figurewidth \divide\d_grph_steps_x \externalfigureparameter\c!xmax\relax + \d_grph_steps_y\figureheight \divide\d_grph_steps_y \externalfigureparameter\c!ymax\relax \fi} \def\grph_steps_comment#1(#2,#3)#4(#5,#6)% {kader}(x,y)(h,b)[...]{tekst} diff --git a/tex/context/base/grph-inc.mkiv b/tex/context/base/grph-inc.mkiv index cc3989491..32fba6c04 100644 --- a/tex/context/base/grph-inc.mkiv +++ b/tex/context/base/grph-inc.mkiv @@ -11,6 +11,8 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. +% todo: messages + \writestatus{loading}{ConTeXt Graphic Macros / Figure Inclusion} \registerctxluafile{grph-inc}{1.001} @@ -30,11 +32,13 @@ \ifdefined\dotagfigure \else \let\dotagfigure\relax \fi -\installcorenamespace{externalfigures} +\installcorenamespace{externalfigure} \installcorenamespace{externalfigureinstance} \installcorenamespace{externalfigurecollection} -\installframedcommandhandler \??externalfigures {externalfigures} \??externalfigures +\installframedcommandhandler \??externalfigure {externalfigure} \??externalfigure + +\let\setupexternalfigures\setupexternalfigure \setupexternalfigures[% we really need the defaults \c!method =, @@ -60,8 +64,8 @@ \c!hfactor =, \c!wfactor =, \c!factor =, - \c!maxwidth =\externalfiguresparameter\c!width, - \c!maxheight =\externalfiguresparameter\c!height, + \c!maxwidth =\externalfigureparameter\c!width, + \c!maxheight =\externalfigureparameter\c!height, \c!xscale =, \c!yscale =, \c!scale =, @@ -137,93 +141,179 @@ % % \defineexternalfigure[name][settings] -\unexpanded\def\defineexternalfigure - {\dodoubleargument\grph_include_define} +%D Defining is persistent, i.e.\ when you redefine an instance, +%D the already set parameters need to be set again or otherwise +%D the old values will be used. + +\newconditional\c_grph_include_trace_inheritance + +\installtextracker + {graphics.inheritance} + {\settrue \c_grph_include_trace_inheritance} + {\setfalse\c_grph_include_trace_inheritance} + +\installcorenamespace{externalfiguredefinition} + +% \unexpanded\def\defineexternalfigure +% {\dodoubleargument\grph_include_define} +% +% \def\grph_include_define[#1][#2]% +% {\setvalue{\??externalfiguredefinition#1}{\setupcurrentexternalfigure[#2]}} -\def\grph_include_define[#1][#2]% - {\setvalue{\??externalfigureinstance#1}{\grph_include_use[#1][][][#2]}} +\let\defineexternalfigures\defineexternalfigure -\def\useexternalfigure +\unexpanded\def\useexternalfigure {\doquadrupleempty\grph_include_use} +% label file parent settings +% label file settings +% label file parent + \def\grph_include_use[#1][#2][#3][#4]% {\doifelsenothing{#1} {\doifsomething{#2} {\doifassignmentelse{#3} {\grph_include_use_indeed{#2}{#2}{#3}{#4}} - {\grph_include_use_indeed{#2}{#2}{}{#4}}}} + {\grph_include_use_indeed{#2}{#2}\empty{#4}}}} {\doifelsenothing{#2} {\doifassignmentelse{#3} - {\grph_include_use_indeed{#1}{#1}{}{#3}} + {\grph_include_use_indeed{#1}{#1}\empty{#3}} {\grph_include_use_indeed{#1}{#1}{#3}{#4}}} {\doifassignmentelse{#3} - {\grph_include_use_indeed{#1}{#2}{}{#3}} + {\grph_include_use_indeed{#1}{#2}\empty{#3}} {\grph_include_use_indeed{#1}{#2}{#3}{#4}}}}} \def\grph_include_use_indeed#1#2#3#4% - {\setvalue{\??externalfigureinstance#1}{\grph_include_place[#1][#2][#3][#4]}% + {\setvalue{\??externalfigureinstance#1}{\grph_include_setup{#2}{#3}{#4}}% \grph_include_analyze_collection[#2][#4]} -\def\grph_include_place[#1][#2][#3][#4][#5]% - {\doifsomething{#2}% catches \defineexternalfigure dummies - {\ifcsname\??externalfigureinstance#2\endcsname - \doifelse{#1}{#2} - {\grph_include_place_indeed[#1][#2][#3][#4][#5]} - {\csname\??externalfigureinstance#2\endcsname[#5]}% - \else - \grph_include_place_indeed[#1][#2][#3][#4][#5]% - \fi}} +% inclusion -\def\grph_include_place_indeed[#1][#2][#3][#4][#5]% - {\bgroup - \advance\c_grph_include_nesting\plusone - \edef\currentexternalfigures{\the\c_grph_include_nesting}% - \checkexternalfiguresparent % each inherits from the root - % - \dostarttagged\t!image\empty - % +\unexpanded\def\externalfigure + {\dotripleempty\grph_include_figure} + +\def\grph_include_figure[#1][#2][#3]% + {\docheckassignment{#2}% + \ifassignment + \grph_include_place[#1][][#2]% + \else + \grph_include_place[#1][#2][#3]% + \fi} + +% todo: chain them + +\def\grph_include_setup#1#2#3% name parent settings + {\edef\m_grph_include_name {#1}% + \edef\m_grph_include_parent{#2}% + \ifx\m_grph_include_name\empty \else + \let\p_grph_include_name\m_grph_include_name + \fi + \ifx\m_grph_include_parent\empty \else + \grph_include_inherit_from_parent\m_grph_include_parent + \fi + \setupcurrentexternalfigure[#3]} + +% \def\grph_include_inherit_from_parent#1% +% {\ifcsname\??externalfiguredefinition#1\endcsname +% \ifconditional\c_grph_include_trace_inheritance\c_grph_include_trace_inheritance\writestatus\m!figures{inheriting from definition: #1}\fi +% \csname\??externalfiguredefinition#1\endcsname +% \fi +% \ifcsname\??externalfigureinstance#1\endcsname +% \ifconditional\c_grph_include_trace_inheritance\c_grph_include_trace_inheritance\writestatus\m!figures{inheriting from instance: #1}\fi +% \csname\??externalfigureinstance#1\endcsname +% \fi} + +\def\grph_include_inherit_from_parent#1% + {%\ifcsname\??externalfiguredefinition#1\endcsname + % \ifconditional\c_grph_include_trace_inheritance\writestatus\m!figures{inheriting from definition: #1}\fi + % \csname\??externalfiguredefinition#1\endcsname + %\fi + \ifcsname\??externalfigure#1:\s!parent\endcsname + \let\currentexternalfigure#1% + \fi + \ifcsname\??externalfigureinstance#1\endcsname + \ifconditional\c_grph_include_trace_inheritance\writestatus\m!figures{inheriting from instance: #1}\fi + \csname\??externalfigureinstance#1\endcsname + \fi} + +\newtoks\t_grph_include_local_settings + +\appendtoks \let\textunderscore\letterunderscore % {\string _} % space needed as _ is now letter in unprotected mode (probably no longer needed) % \dontcomplain \restorecatcodes \forgetall +\to \t_grph_include_local_settings + +\def\grph_include_place_inherit + {\ifconditional\c_grph_include_trace_inheritance + \writestatus\m!figures{label: \p_grph_include_label, name: \p_grph_include_name, parent: \p_grph_include_parent}% + \fi + \ifx\p_grph_include_parent\empty + % nothing to be done + \else\ifx\p_grph_include_parent\p_grph_include_label + % redundant + \else + \grph_include_inherit_from_parent\p_grph_include_parent + \fi\fi + \ifx\p_grph_include_label\empty + % nothing to be done + \else + \grph_include_inherit_from_parent\p_grph_include_label + \fi} + +\def\grph_include_place[#1][#2][#3]% [label][file][settings] | [file][settings] | [file][parent][settings] + {\bgroup + \advance\c_grph_include_nesting\plusone + \edef\currentexternalfigure{\the\c_grph_include_nesting}% + \checkexternalfigureparent % each inherits from the root % \the\everyexternalfigureresets % - \doifelsenothing{#3} % inherit from parent ... needs checking - {\setupcurrentexternalfigures[#4,#5]} - {\ifcsname\??externalfigureinstance#3\endcsname - \pushmacro\grph_include_place - \def\grph_include_place[##1][##2][##3][##4]{\setupcurrentexternalfigures[##4,#4,#5]}% - \csname\??externalfigureinstance#3\endcsname - \popmacro\grph_include_place - \else - \setupcurrentexternalfigures[#4,#5]% - \fi}% + \edef\p_grph_include_label{#1}% + \let\p_grph_include_name\p_grph_include_label + \docheckassignment{#2}% + \ifassignment + % [label] [settings] + \let\p_grph_include_parent\p_grph_include_label + \grph_include_place_inherit + \setupcurrentexternalfigure[#2]% + \else + % [label] [parent] [settings] + \edef\p_grph_include_parent{#2}% + \ifx\p_grph_include_parent\empty + \let\p_grph_include_parent\p_grph_include_label + \fi + \grph_include_place_inherit + \setupcurrentexternalfigure[#3]% + \fi % \the\everyexternalfigurechecks % + \the\t_grph_include_local_settings + \dostarttagged\t!image\empty \ctxlua{figures.push { - name = "#2", - label = "#1", % todo: \externalfiguresparameter\c!label - page = "\externalfiguresparameter\c!page", - size = "\externalfiguresparameter\c!size", - object = "\externalfiguresparameter\c!object", - prefix = "\externalfiguresparameter\c!prefix", - cache = "\externalfiguresparameter\c!cache", - format = "\externalfiguresparameter\c!method", - preset = "\externalfiguresparameter\c!prefix", - controls = "\externalfiguresparameter\c!controls", - resources = "\externalfiguresparameter\c!resources", - preview = "\externalfiguresparameter\c!preview", - display = "\externalfiguresparameter\c!display", - mask = "\externalfiguresparameter\c!mask", - conversion = "\externalfiguresparameter\c!conversion", - resolution = "\externalfiguresparameter\c!resolution", - color = "\internalspotcolorparent{\externalfiguresparameter\c!color}", % hack is needed - ["repeat"] = "\externalfiguresparameter\c!repeat", - width = "\externalfiguresparameter\c!width", % can be crap - height = "\externalfiguresparameter\c!height", % can be crap + name = "\p_grph_include_name", + label = "\p_grph_include_label", + page = "\externalfigureparameter\c!page", + size = "\externalfigureparameter\c!size", + object = "\externalfigureparameter\c!object", + prefix = "\externalfigureparameter\c!prefix", + cache = "\externalfigureparameter\c!cache", + format = "\externalfigureparameter\c!method", + preset = "\externalfigureparameter\c!prefix", + controls = "\externalfigureparameter\c!controls", + resources = "\externalfigureparameter\c!resources", + preview = "\externalfigureparameter\c!preview", + display = "\externalfigureparameter\c!display", + mask = "\externalfigureparameter\c!mask", + conversion = "\externalfigureparameter\c!conversion", + resolution = "\externalfigureparameter\c!resolution", + color = "\internalspotcolorparent{\externalfigureparameter\c!color}", % hack is needed + ["repeat"] = "\externalfigureparameter\c!repeat", + width = "\externalfigureparameter\c!width", % can be crap + height = "\externalfigureparameter\c!height", % can be crap } }% \ctxlua{figures.identify()}% % also mode: checkpresense only @@ -249,7 +339,6 @@ \grph_include_finalize \fi \ctxlua{figures.pop()}% - % \dotagfigure \naturalvbox attr \imageattribute 2 {\box\foundexternalfigure}% \dostoptagged @@ -264,21 +353,21 @@ \definescale % some day we will inherit [\v!figure] - [\c!hfactor =\externalfiguresparameter\c!hfactor, - \c!wfactor =\externalfiguresparameter\c!wfactor, - \c!factor =\externalfiguresparameter\c!factor, - \c!maxwidth =\externalfiguresparameter\c!maxwidth , - \c!maxheight =\externalfiguresparameter\c!maxheight, - \c!equalwidth =\externalfiguresparameter\c!equalwidth , - \c!equalheight=\externalfiguresparameter\c!equalheight, - \c!xscale =\externalfiguresparameter\c!xscale, - \c!yscale =\externalfiguresparameter\c!yscale, - \c!scale =\externalfiguresparameter\c!scale, - \c!sx =\externalfiguresparameter\c!sx, - \c!sy =\externalfiguresparameter\c!sy, - \c!width =\externalfiguresparameter\c!width, - \c!height =\externalfiguresparameter\c!height, - \c!lines =\externalfiguresparameter\c!lines] + [\c!hfactor =\externalfigureparameter\c!hfactor, + \c!wfactor =\externalfigureparameter\c!wfactor, + \c!factor =\externalfigureparameter\c!factor, + \c!maxwidth =\externalfigureparameter\c!maxwidth , + \c!maxheight =\externalfigureparameter\c!maxheight, + \c!equalwidth =\externalfigureparameter\c!equalwidth , + \c!equalheight=\externalfigureparameter\c!equalheight, + \c!xscale =\externalfigureparameter\c!xscale, + \c!yscale =\externalfigureparameter\c!yscale, + \c!scale =\externalfigureparameter\c!scale, + \c!sx =\externalfigureparameter\c!sx, + \c!sy =\externalfigureparameter\c!sy, + \c!width =\externalfigureparameter\c!width, + \c!height =\externalfigureparameter\c!height, + \c!lines =\externalfigureparameter\c!lines] %D You can register additional suffixes with the following command: %D @@ -298,7 +387,7 @@ %D macro picks up the list. \unexpanded\def\setfigurepathlist - {\ctxlua{figures.setpaths("\externalfiguresparameter\c!location",\!!bs\externalfiguresparameter\c!directory\!!es)}} + {\ctxlua{figures.setpaths("\externalfigureparameter\c!location",\!!bs\externalfigureparameter\c!directory\!!es)}} %D Variables: @@ -347,23 +436,6 @@ \let\figurescalexscale \figurexscale \let\figurescaleyscale \figureyscale -%D The main command: - -\unexpanded\def\externalfigure - {\dotripleempty\grph_include_set_type_synonym} - -\def\grph_include_set_type_synonym[#1][#2][#3]% [label][file][settings] | [file][settings] | [file][parent][settings] - {\bgroup % also catched #1 == empty ... scales nicer now - \ifcsname\??externalfigureinstance#1\endcsname - \doifassignmentelse{#2} - {\csname\??externalfigureinstance#1\endcsname[#2]}% - {\csname\??externalfigureinstance#1\endcsname[#3]}% - \else - \useexternalfigure[\s!dummy][#1][#2][#3]% - \csname\??externalfigureinstance\s!dummy\endcsname[]% [] is dummy arg 5 - \fi - \egroup} - %D Calculating: % \enabletrackers[figures.conversion] @@ -388,7 +460,7 @@ \appendtoks \ctxlua { % figures.defaultwidth .. maybe a dimen some day - figures.setpaths("\externalfiguresparameter\c!location","\externalfiguresparameter\c!directory") ; + figures.setpaths("\externalfigureparameter\c!location","\externalfigureparameter\c!directory") ; figures.defaultwidth = \number\dimexpr\defaultfigurewidth \relax ; figures.defaultheight = \number\dimexpr\defaultfigureheight\relax ; figures.boxnumber = \number\foundexternalfigure ; @@ -396,22 +468,22 @@ \to \everyexternalfigureresets \appendtoks - \edef\p_option{\externalfiguresparameter\c!option}% + \edef\p_option{\externalfigureparameter\c!option}% \ifx\p_option\v!frame \setfalse\c_grph_include_skip - \letexternalfiguresparameter\c!frame\v!on + \letexternalfigureparameter\c!frame\v!on \else\ifx\p_option\v!empty \settrue\c_grph_include_skip - \letexternalfiguresparameter\c!frame\v!off + \letexternalfigureparameter\c!frame\v!off \else \setfalse\c_grph_include_skip \fi\fi % fake color in gray bitmaps, assumes that % a transparent color is used - \edef\p_foregroundcolor{\externalfiguresparameter\c!foregroundcolor}% + \edef\p_foregroundcolor{\externalfigureparameter\c!foregroundcolor}% \ifx\p_foregroundcolor\empty \else - \setexternalfiguresparameter\c!background{\v!foreground,\v!color}% - \letexternalfiguresparameter\c!backgroundcolor\p_foregroundcolor + \setexternalfigureparameter\c!background{\v!foreground,\v!color}% + \letexternalfigureparameter\c!backgroundcolor\p_foregroundcolor \fi \to \everyexternalfigurechecks @@ -458,7 +530,7 @@ \def\grph_include_finalize {\global\setbox\foundexternalfigure\vbox {\ifcase\figurestatus - \letexternalfiguresparameter\c!frame\v!on + \letexternalfigureparameter\c!frame\v!on \fi \ifconditional\c_grph_include_flush \ifconditional\c_grph_include_level % probably background @@ -484,17 +556,17 @@ \grph_include_replacement\figurelabel\figurefileoriginal{unknown}% \else \the\externalfigurepostprocessors - \edef\p_reset{\externalfiguresparameter\c!reset}% + \edef\p_reset{\externalfigureparameter\c!reset}% \ifx\p_reset\v!yes \wd\foundexternalfigure\figurewidth \ht\foundexternalfigure\figureheight \dp\foundexternalfigure\zeropoint \box\foundexternalfigure \else - \letexternalfiguresparameter\c!offset\v!overlay - \letexternalfiguresparameter\c!width \figurewidth - \letexternalfiguresparameter\c!height\figureheight - \inheritedexternalfiguresframed{\vfilll\box\foundexternalfigure}% + \letexternalfigureparameter\c!offset\v!overlay + \letexternalfigureparameter\c!width \figurewidth + \letexternalfigureparameter\c!height\figureheight + \inheritedexternalfigureframed{\vfilll\box\foundexternalfigure}% \fi \fi\fi \fi @@ -550,21 +622,21 @@ \appendtoks \setfigurepathlist % the path may be used elsewhere too (as in x-res-04) -\to \everysetupexternalfigures +\to \everysetupexternalfigure \appendtoks - \ctxcommand{setfigurelookuporder("\externalfiguresparameter\c!order")}% -\to \everysetupexternalfigures + \ctxcommand{setfigurelookuporder("\externalfigureparameter\c!order")}% +\to \everysetupexternalfigure \definecolor[missingfigurecolor][s=.8] \def\grph_include_replacement#1#2#3% {\bgroup - \letexternalfiguresparameter\c!width\figurewidth - \letexternalfiguresparameter\c!height\figureheight - \letexternalfiguresparameter\c!background\v!color - \setexternalfiguresparameter\c!backgroundcolor{missingfigurecolor}% - \inheritedexternalfiguresframed + \letexternalfigureparameter\c!width\figurewidth + \letexternalfigureparameter\c!height\figureheight + \letexternalfigureparameter\c!background\v!color + \setexternalfigureparameter\c!backgroundcolor{missingfigurecolor}% + \inheritedexternalfigureframed {\tt\tfxx \nohyphens name: \expanded{\verbatimstring{#1}}\\% file: \expanded{\verbatimstring{#2}}\\% diff --git a/tex/context/base/grph-trf.mkiv b/tex/context/base/grph-trf.mkiv index dd28f56fb..f1ac9c310 100644 --- a/tex/context/base/grph-trf.mkiv +++ b/tex/context/base/grph-trf.mkiv @@ -417,8 +417,8 @@ \setvalue{\??scalenorm\v!max }#1#2#3#4#5{\global#1#4} \setvalue{\??scalenorm\v!fit }#1#2#3#4#5{\global#1#5} -\setvalue{\??scalenorm\v!broad }#1#2#3#4#5{\global#1\dimexpr#5-4\externalfiguresparameter\c!bodyfont\relax} -\setvalue{\??scalenorm\s!unknown}#1#2#3#4#5{\global#1\dimexpr#2\dimexpr\externalfiguresparameter\c!bodyfont/10\relax\relax} % brr ex +\setvalue{\??scalenorm\v!broad }#1#2#3#4#5{\global#1\dimexpr#5-4\externalfigureparameter\c!bodyfont\relax} +\setvalue{\??scalenorm\s!unknown}#1#2#3#4#5{\global#1\dimexpr#2\dimexpr\externalfigureparameter\c!bodyfont/10\relax\relax} % brr ex \setvalue{\??scalenorm\v!auto }#1#2#3#4#5{\ifx#3\empty\else\global#1#3\fi} \setvalue{\??scalenorm\empty }#1#2#3#4#5{\ifx#3\empty\else\global#1#3\fi} \setvalue{\??scalenorm\s!default}#1#2#3#4#5{\ifx#3\empty\else\global#1#3\fi} diff --git a/tex/context/base/l-lpeg.lua b/tex/context/base/l-lpeg.lua index 50b14db06..dc479dd5f 100644 --- a/tex/context/base/l-lpeg.lua +++ b/tex/context/base/l-lpeg.lua @@ -349,11 +349,11 @@ function lpeg.keeper(str) end function lpeg.frontstripper(str) -- or pattern (yet undocumented) - return (P(str) + P(true)) * Cs(P(1)^0) + return (P(str) + P(true)) * Cs(anything^0) end function lpeg.endstripper(str) -- or pattern (yet undocumented) - return Cs((1 - P(str) * P(-1))^0) + return Cs((1 - P(str) * endofstring)^0) end -- Just for fun I looked at the used bytecode and diff --git a/tex/context/base/luat-cnf.lua b/tex/context/base/luat-cnf.lua index 609dc412b..07a5d51f2 100644 --- a/tex/context/base/luat-cnf.lua +++ b/tex/context/base/luat-cnf.lua @@ -123,19 +123,20 @@ function texconfig.init() local function init(start) local b = lua.bytecode local i = start + local t = os.clock() while b[i] do b[i]() ; b[i] = nil ; i = i + 1 -- collectgarbage('step') end - return i - start + return i - start, os.clock() - t end -- the stored tables and modules - storage.noftables = init(0) - storage.nofmodules = init(%s) + storage.noftables , storage.toftables = init(0) + storage.nofmodules, storage.tofmodules = init(%s) end diff --git a/tex/context/base/luat-sto.lua b/tex/context/base/luat-sto.lua index 860aa1121..30a72a29b 100644 --- a/tex/context/base/luat-sto.lua +++ b/tex/context/base/luat-sto.lua @@ -104,9 +104,15 @@ end --~ end statistics.register("stored bytecode data", function() - local modules = (storage.nofmodules > 0 and storage.nofmodules) or (status.luabytecodes - lua.firstbytecode - 1) - local dumps = (storage.noftables > 0 and storage.noftables) or storage.max-storage.min + 1 - return format("%s modules, %s tables, %s chunks",modules,dumps,modules+dumps) + local nofmodules = (storage.nofmodules > 0 and storage.nofmodules) or (status.luabytecodes - lua.firstbytecode - 1) + local nofdumps = (storage.noftables > 0 and storage.noftables ) or storage.max-storage.min + 1 + local tofmodules = storage.tofmodules or 0 + local tofdumps = storage.toftables or 0 + return format("%s modules (%0.3f sec), %s tables (%0.3f sec), %s chunks (%0.3f sec)", + nofmodules, tofmodules, + nofdumps, tofdumps, + nofmodules + nofdumps, tofmodules + tofdumps + ) end) if lua.bytedata then diff --git a/tex/context/base/m-ipsum.mkiv b/tex/context/base/m-ipsum.mkiv index 3ac54044d..1fb482c43 100644 --- a/tex/context/base/m-ipsum.mkiv +++ b/tex/context/base/m-ipsum.mkiv @@ -17,75 +17,80 @@ \startluacode -local word = lpeg.R("az","AZ")^1 -local period = lpeg.S(".") -local rest = lpeg.P(1) -local whitespace = lpeg.patterns.whitespace^1 / " " - -local oneword = lpeg.Cs(word / characters.lower) -local onesentence = lpeg.Cs(word * (whitespace + word + (1-period))^0 * period) - -local allwords = lpeg.Ct((oneword + rest)^1) -local allsentences = lpeg.Ct((onesentence + rest)^1) +local patterns = lpeg.patterns local variables = interfaces.variables - -local v_paragraph = variables.paragraph -local v_lines = variables.lines -local v_words = variables.words local v_random = variables.random -local ipsum = { } moduledata.ipsum = ipsum +local lowercase = characters.lower -local data = { } +local ipsum = { } +moduledata.ipsum = ipsum + +local data = { } local function getfiledata(settings) local filename = settings.filename or "" local filedata = data[filename] if not filedata then local text = resolvers.loadtexfile(filename) or "" + local paragraphs = lpeg.match(patterns.paragraphs,text) or { } + local sentences = lpeg.match(patterns.sentences, text) or { } + local words = lpeg.match(patterns.words, text) or { } + for i=1,#words do + words[i] = lowercase(words[i]) + end filedata = { - [v_paragraph] = { text or "" }, - [v_lines] = lpeg.match(allsentences,text) or { }, - [v_words] = lpeg.match(allwords,text) or { }, + -- [variables.paragraphs] = paragraphs, + [variables.paragraph] = paragraphs, + [variables.lines] = sentences, + [variables.line] = sentences, + [variables.words] = words, + [variables.word] = words, } + -- inspect(filedata) data[filename] = filedata end local d = filedata[settings.alternative or v_paragraph] or filedata[v_paragraph] or { } + local nd = #d local n = settings.n if n ~= v_random then n = tonumber(n) or 0 if n == 0 then - n = #d + n = nd end end - return d, n + return d, n, nd end function moduledata.ipsum.typeset(settings) - local d, n = getfiledata(settings) - context(settings.before) - if n == v_random then - context(settings.left) - context(d[math.random(1,#d)]) - context(settings.right) - else - for i=1,n do + local d, n, nd = getfiledata(settings) + if nd > 0 then + context(settings.before) + if n == v_random then context(settings.left) - context(d[i]) + context(d[math.random(1,nd)]) context(settings.right) - if i < n then - context(settings.inbetween) + else + for i=1,n do + context(settings.left) + context(d[i]) + context(settings.right) + if i < n then + context(settings.inbetween) + end end end + context(settings.after) end - context(settings.after) end function moduledata.ipsum.direct(settings) - local d, n = getfiledata(settings) - if n == v_random then - context(d[math.random(1,#d)]) + local d, n, nd = getfiledata(settings) + if nd == 0 then + -- nothing + elseif n == v_random then + context(d[math.random(1,nd)]) else for i=1,n do context(d[i]) diff --git a/tex/context/base/meta-imp-dum.mkiv b/tex/context/base/meta-imp-dum.mkiv index 489d5d253..83fe12f09 100644 --- a/tex/context/base/meta-imp-dum.mkiv +++ b/tex/context/base/meta-imp-dum.mkiv @@ -88,7 +88,7 @@ {figure:placeholder}% {width=\figurewidth,% height=\figureheight,% - reduction=\externalfiguresparameter\c!reduction,% + reduction=\externalfigureparameter\c!reduction,% color=placeholder:\the\c_grph_replacement_n}] \definepalet @@ -115,20 +115,20 @@ \ifnum\c_grph_replacement_n>\paletsize \global\c_grph_replacement_n\plusone \fi - \setupcurrentexternalfigures + \setupcurrentexternalfigure [\c!width=\figurewidth, \c!height=\figureheight, \c!frame=\v!off, \c!strut=\v!no, \c!background=figure:placeholder:graphic, \c!foregroundcolor=\s!white]% - \doifelse{\externalfiguresparameter\c!text}\v!yes + \doifelse{\externalfigureparameter\c!text}\v!yes {\edef\m_graphics_text_a{#1}\edef\m_graphics_text_a{\ifx\m_graphics_text_a\s!dummy\else\detokenize\expandafter{\m_graphics_text_a}\fi}% \edef\m_graphics_text_b{#2}\edef\m_graphics_text_b{\ifx\m_graphics_text_b\s!dummy\else\detokenize\expandafter{\m_graphics_text_b}\fi}% \edef\m_graphics_text_c{#3}\edef\m_graphics_text_c{\ifx\m_graphics_text_c\s!dummy\else\detokenize\expandafter{\m_graphics_text_c}\fi}% \infofont\setupinterlinespace\dohyphens - \inheritedexternalfiguresframed{\directsetup{figure:placeholder:text}}}% - {\inheritedexternalfiguresframed{}}% + \inheritedexternalfigureframed{\directsetup{figure:placeholder:text}}}% + {\inheritedexternalfigureframed{}}% \endgroup} \unexpanded\def\dummyfigure @@ -188,11 +188,11 @@ \defineoverlay [figure:comment] - [\figurecomment{\externalfiguresparameter\c!comment}] + [\figurecomment{\externalfigureparameter\c!comment}] \defineoverlay [figure:dummy] - [\figuredummy{\externalfiguresparameter\c!comment}] + [\figuredummy{\externalfigureparameter\c!comment}] \setupexternalfigures [\c!comment=] diff --git a/tex/context/base/mult-aux.mkiv b/tex/context/base/mult-aux.mkiv index db636d9a1..beb107e26 100644 --- a/tex/context/base/mult-aux.mkiv +++ b/tex/context/base/mult-aux.mkiv @@ -129,6 +129,17 @@ % End of experimental code. +% the commented detokenized variant that backtracks ... needs testing usage first +% +% \let\whatever\relax +% +% \definetest[oeps][bagger=\whatever] +% +% \def\currenttest{oeps} \edef\hans{\detokenizedtestparameter{bagger}}\meaning\hans\par +% \def\currenttest{oeps} \edef\hans{\detokenizedtestparameter{reggab}}\meaning\hans\par + +\def\mult_interfaces_detokenize{\expandafter\expandafter\expandafter\detokenize\expandafter\expandafter\expandafter} + \unexpanded\def\mult_interfaces_install_parameter_handler#1#2#3#4#5#6#7#8#9% inlining \csname*\endcsname is more efficient (#3 and #6 only) {\ifx#2\relax\let#2\empty\fi % it is hardly faster but produces less expansion tracing %\def#3##1{\csname#4{#1#2}{##1}\endcsname}% @@ -137,6 +148,8 @@ \def#5##1##2{\ifx##1\relax\s!empty\else#4{##1}{##2}\fi}% is {} needed around ##1 ? \def#6##1##2{\csname\ifcsname#1##1:##2\endcsname#1##1:##2\else\expandafter#5\csname#1##1:\s!parent\endcsname{##2}\fi\endcsname}% \def#7##1{\detokenize\expandafter\expandafter\expandafter{\csname#1#2:##1\endcsname}}% always root, no backtrack + % \def#7##1{\mult_interfaces_detokenize{\csname#4{#1#2}{##1}\endcsname}}% compact version + % \def#7##1{\mult_interfaces_detokenize{\csname\ifcsname#1#2:##1\endcsname#1#2:##1\else\expandafter#5\csname#1#2:\s!parent\endcsname{##1}\fi\endcsname}}% \def#8##1{\csname\ifcsname#1#2:##1\endcsname#1#2:##1\else\s!empty\fi\endcsname}% \def#9##1{\csname#1#2:##1\endcsname}} @@ -489,15 +502,17 @@ %D We don't need colons for such simple cases. -\unexpanded\def\mult_interfaces_install_direct_parameter_handler#1#2#3#4% - {\def#2##1{\csname\ifcsname#1##1\endcsname#1##1\else\s!empty\fi\endcsname}% - \def#3##1{\detokenize\expandafter\expandafter\expandafter{\csname#1##1\endcsname}}% - \def#4##1{\csname#1##1\endcsname}} +\unexpanded\def\mult_interfaces_install_direct_parameter_handler#1#2#3#4#5% + {\def#3##1{\csname\ifcsname#1##1\endcsname#1##1\else\s!empty\fi\endcsname}% + \def#4##1{\detokenize\expandafter\expandafter\expandafter{\csname#1##1\endcsname}}% + % \def#4##1{\mult_interfaces_detokenize{\csname\ifcsname#1#2:##1\endcsname#1#2:##1\else\expandafter#5\csname#1#2:\s!parent\endcsname{##1}\fi\endcsname}}% + \def#5##1{\csname#1##1\endcsname}} \unexpanded\def\installdirectparameterhandler#1#2% {\normalexpanded {\mult_interfaces_install_direct_parameter_handler {\noexpand#1}% + \expandafter\noexpand\csname current#2\endcsname \expandafter\noexpand\csname #2parameter\endcsname \expandafter\noexpand\csname detokenized#2parameter\endcsname \expandafter\noexpand\csname direct#2parameter\endcsname}} diff --git a/tex/context/base/mult-low.lua b/tex/context/base/mult-low.lua index fd9493ba1..4246eca2c 100644 --- a/tex/context/base/mult-low.lua +++ b/tex/context/base/mult-low.lua @@ -207,7 +207,7 @@ return { "doifdimensionelse", "doifnumberelse", "doifnumber", "doifnotnumber", "doifcommonelse", "doifcommon", "doifnotcommon", "doifinstring", "doifnotinstring", "doifinstringelse", - "doifassignmentelse", + "doifassignmentelse", "docheckassignment", -- "tracingall", "tracingnone", "loggingall", -- diff --git a/tex/context/base/page-app.mkiv b/tex/context/base/page-app.mkiv index 8580b9f2e..abd3d0ae5 100644 --- a/tex/context/base/page-app.mkiv +++ b/tex/context/base/page-app.mkiv @@ -180,14 +180,16 @@ %D \starttext \pagefigure[two.1] \stoptext %D \stoptyping +\defineexternalfigure[\v!page:\v!figure][\c!offset=\v!overlay] % we force a parent + \unexpanded\def\startpagefigure {\dodoubleempty\page_figures_start} \def\page_figures_start[#1][#2]% {\bgroup - \setupexternalfigures[\c!offset=\v!overlay,#2]% - \startTEXpage[\c!offset=\externalfiguresparameter\c!offset]% - \externalfigure[#1][#2]\ignorespaces} % so we can put some text below the graphic + \setupexternalfigure[\v!page:\v!figure][\c!offset=\v!overlay,#2]% + \startTEXpage[\c!offset=\externalfigureparameter\c!offset]% + \externalfigure[#1][\v!page:\v!figure]\ignorespaces} % so we can put some text below the graphic \unexpanded\def\stoppagefigure {\stopTEXpage diff --git a/tex/context/base/s-pre-60.mkiv b/tex/context/base/s-pre-60.mkiv index b39a06311..70f8978b0 100644 --- a/tex/context/base/s-pre-60.mkiv +++ b/tex/context/base/s-pre-60.mkiv @@ -13,6 +13,8 @@ % use lua instead of global mess +\unprotect + \startmode[paper,print] \let\StartSteps\relax \let\StopSteps \relax @@ -23,22 +25,31 @@ \endinput \stopmode -\newcounter\StepCounter -\newcounter\StepMaximum +\newcount\c_module_pre_steps_current +\newcount\c_module_pre_steps_maximum +\newcount\c_module_pre_steps_nesting_step +\newcount\c_module_pre_steps_nesting_steps +\newcount\c_module_pre_steps_nesting_busy + +\def\StepCounter {\the\c_module_pre_steps_current} +\def\StepMaximum {\the\c_module_pre_steps_maximum} +\def\StepLayer {step:\the\c_module_pre_steps_current} +\def\NextStepLayer {step:\the\numexpr\c_module_pre_steps_current+\plusone\relax} +\def\FirstStepLayer{step:1} \useJSscripts[stp] \startsetups[set-stepper] - \ifnum\getvariable{stepper}{nofsteps}>\StepMaximum + \ifnum\getvariable{stepper}{nofsteps}>\c_module_pre_steps_maximum - \dostepwiserecurse {\numexpr\StepMaximum+1\relax} {\getvariable{stepper}{nofsteps}} {1} { + \dostepwiserecurse {\numexpr\c_module_pre_steps_maximum+\plusone\relax} {\getvariable{stepper}{nofsteps}} {1} { \doifnotmode{nosteps,nostep} { \expanded{\defineviewerlayer[step:\recurselevel][state=stop,scope=global]} } } - \xdef\StepMaximum{\getvariable{stepper}{nofsteps}} + \global\c_module_pre_steps_maximum\getvariable{stepper}{nofsteps}\relax \fi @@ -58,25 +69,100 @@ % todo: roll back blank -\def\ResetStep {\doglobal\newcounter\StepCounter} -\def\NextStep {\doglobal\increment \StepCounter} -\def\PrevStep {\doglobal\decrement \StepCounter} +\unexpanded\def\ResetStep + {\iftrialtypesetting\else + \global\c_module_pre_steps_current\zerocount + \fi} + +\unexpanded\def\NextStep + {\iftrialtypesetting\else + \global\advance\c_module_pre_steps_current\plusone + \fi} + +\unexpanded\def\PrevStep + {\iftrialtypesetting\else + \global\advance\c_module_pre_steps_current\minusone + \fi} + +\unexpanded\def\FlushStep + {\iftrialtypesetting\else + \StopStep + \NextStep + \StartStep + \fi} + +\unexpanded\def\StartStep + {\iftrialtypesetting\else + \global\advance\c_module_pre_steps_nesting_step\plusone + \ifcase\c_module_pre_steps_nesting_step\or + \startviewerlayer[\StepLayer]% + \fi + \fi + \ignorespaces} + +\unexpanded\def\StopStep + {\removeunwantedspaces + \iftrialtypesetting\else + \ifcase\c_module_pre_steps_nesting_step\or + \stopviewerlayer + \fi + \global\advance\c_module_pre_steps_nesting_step\minusone + \fi} + +\unexpanded\def\StartSteps + {\iftrialtypesetting\else + \global\advance\c_module_pre_steps_nesting_steps\plusone + \ifcase\c_module_pre_steps_nesting_steps\or + \ResetStep + \NextStep + \StartStep + \fi + \fi} + +\unexpanded\def\StopSteps + {\iftrialtypesetting\else + \ifcase\c_module_pre_steps_nesting_steps\or + \StopStep + \PrevStep + \fi + \global\advance\c_module_pre_steps_nesting_steps\minusone + \fi} + +\unexpanded\def\StartBusy + {\iftrialtypesetting\else + \global\advance\c_module_pre_steps_nesting_busy\plusone + \ifcase\c_module_pre_steps_nesting_busy\or + \startviewerlayer[step:busy] + \fi + \fi + \ignorespaces} + +\unexpanded\def\StopBusy + {\removeunwantedspaces + \iftrialtypesetting\else + \ifcase\c_module_pre_steps_nesting_busy\or + \stopviewerlayer + \fi + \global\advance\c_module_pre_steps_nesting_busy\minusone + \fi} -\def\StepLayer {step:\StepCounter} -\def\NextStepLayer {step:\the\numexpr\StepCounter+1\relax} -\def\FirstStepLayer{step:1} +%D Handy: + +\unexpanded\def\StartLocalSteps + {\ResetStep} -\def\StartStep {\startviewerlayer[\StepLayer]\ignorespaces} -\def\StopStep {\removeunwantedspaces\stopviewerlayer} -\def\StartSteps {\iftrialtypesetting\else\ResetStep\NextStep\StartStep\fi} -\def\StopSteps {\iftrialtypesetting\else\StopStep \PrevStep \fi} -\def\FlushStep {\iftrialtypesetting\else\StopStep \NextStep\StartStep\fi} +\unexpanded\def\StopLocalSteps + {} -\def\StartBusy {\startviewerlayer[step:busy]\ignorespaces} -\def\StopBusy {\removeunwantedspaces\stopviewerlayer} +\unexpanded\def\StartLocalStep + {\NextStep + \StartStep} + +\unexpanded\def\StopLocalStep + {\StopStep} \appendtoks - \ResetStep + \ResetStep \to \everyaftershipout \setupinteraction @@ -112,14 +198,6 @@ [symbol={attach-normal,attach-down}, textlayer=\StepLayer] -%D Handy: - -\def\StartLocalSteps{\ResetStep} -\def\StopLocalSteps {} - -\def\StartLocalStep {\NextStep\StartStep} -\def\StopLocalStep {\StopStep} - %D used as (given some definitions): %D %D \starttyping @@ -131,4 +209,4 @@ %D \StopLocalSteps %D \stoptyping -\endinput +\protect \endinput diff --git a/tex/context/base/s-pre-61.tex b/tex/context/base/s-pre-61.tex index 21e461320..ea221fbcb 100644 --- a/tex/context/base/s-pre-61.tex +++ b/tex/context/base/s-pre-61.tex @@ -16,7 +16,7 @@ \usemodule[pre-60] \doifmodeelse {mkiv} { - \usetypescriptfile[type-hgz] + \usetypescriptfile[ghz] \definetypeface[mainface][ss][sans][optima-nova][default] } { \usetypescriptfile[type-ghz] diff --git a/tex/context/base/scrn-wid.mkvi b/tex/context/base/scrn-wid.mkvi index f128c171d..9b3f0cb78 100644 --- a/tex/context/base/scrn-wid.mkvi +++ b/tex/context/base/scrn-wid.mkvi @@ -504,8 +504,6 @@ \box\b_scrn_comment_collect \fi} -\unexpanded\def\scrn_comment_collect - \unexpanded\def\placecomments {\ifvoid\b_scrn_comment_collect\else \box\b_scrn_comment_collect diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex 8cbe8b533..809fb32b8 100644 --- a/tex/context/base/status-files.pdf +++ b/tex/context/base/status-files.pdf diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf Binary files differindex 0459fbe75..0a0b624a3 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/strc-lnt.mkvi b/tex/context/base/strc-lnt.mkvi index f07ce7839..1366e6cdc 100644 --- a/tex/context/base/strc-lnt.mkvi +++ b/tex/context/base/strc-lnt.mkvi @@ -79,9 +79,14 @@ \unexpanded\def\tracelinenotes {\let\strc_linenotes_traced\strc_linenotes_traced_indeed} +%D Use these when not properly nested: + +\let\fromlinenote\startlinenote +\let\tolinenote \stoplinenote + % We predefine one, namely \type {\linenote} cum suis. -% \definelinenote[\v!linenote] +\definelinenote[\v!linenote] % beware: line numbers are added later on so grouping setups is a bad idea % diff --git a/tex/context/base/strc-reg.mkiv b/tex/context/base/strc-reg.mkiv index 44bca68d1..d377e0736 100644 --- a/tex/context/base/strc-reg.mkiv +++ b/tex/context/base/strc-reg.mkiv @@ -46,7 +46,7 @@ \let\strc_registers_setup_saved\setupregister -\unexpanded\def\setupregister +\unexpanded\def\setupregister % maybe we should drop the plural form {\dotripleempty\strc_registers_setup} \def\strc_registers_setup[#1][#2][#3]% @@ -104,12 +104,6 @@ \setupregister [\c!label=, \c!entries=, - \c!entries:1=, - \c!entries:2=, - \c!entries:3=, - \c!keys:1=, - \c!keys:2=, - \c!keys:3=, \c!alternative=] %D \starttyping @@ -133,12 +127,16 @@ \setuevalue{\currentregister}{\dodoubleempty\strc_registers_insert_entry[\currentregister]}% \setuevalue{\e!see\currentregister}{\dodoubleempty\strc_registers_insert_see[\currentregister]}% %setuevalue{\e!coupled\currentregister}{\dolinkedregister{\currentregister}}% - \setuevalue{\e!place\currentregister}{\placeregister[\currentregister]}% % historic ballast - \setuevalue{\e!complete\currentregister}{\completeregister[\currentregister]}% % historic ballast - \setuevalue{\e!setup\currentregister\e!endsetup}{\setupregister[\currentregister}% % historic ballast - \normalexpanded{\defineregister[\currentregister:1][\currentregister]}% expansion should not be needed - \normalexpanded{\defineregister[\currentregister:2][\currentregister]}% expansion should not be needed - \normalexpanded{\defineregister[\currentregister:3][\currentregister]}% expansion should not be needed + % historic ballast + \setuevalue{\e!place\currentregister}{\placeregister[\currentregister]}% + \setuevalue{\e!complete\currentregister}{\completeregister[\currentregister]}% + \setuevalue{\e!setup\currentregister\e!endsetup}{\setupregister[\currentregister]}% + \dorecurse\plusthree {% + \defineregister[\currentregister:\recurselevel][\currentregister]% + \letregisterparameter{\c!entries:\recurselevel}\empty % needed as we use detokenize (ok, we can + \letregisterparameter{\c!keys :\recurselevel}\empty % avoid it, but it's faster too) + }% + % \setfalse\c_strc_registers_defining \fi \to \everydefineregister diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv index 07fa7c7ac..c09608f8d 100644 --- a/tex/context/base/syst-aux.mkiv +++ b/tex/context/base/syst-aux.mkiv @@ -3865,7 +3865,7 @@ \def\syst_helpers_check_if_assignment_else#1=#2#3\_e_o_p_{\if#2@}% -\def\doifassignmentelse#1% expandable +\unexpanded\def\doifassignmentelse#1% expandable {\expandafter\syst_helpers_check_if_assignment_else\detokenize{#1}=@@\_e_o_p_ \expandafter\secondoftwoarguments \else @@ -3874,6 +3874,13 @@ \newif\ifassignment +\unexpanded\def\docheckassignment#1% + {\expandafter\syst_helpers_check_if_assignment_else\detokenize{#1}=@@\_e_o_p_ + \assignmentfalse + \else + \assignmenttrue + \fi} + %D In \ETEX\ we can use \type {\detokenize} and gain some %D speed, but in general far less that 1\% for \type %D {\convertargument} and nil for \type {\convertcommand}. diff --git a/tex/context/base/util-prs.lua b/tex/context/base/util-prs.lua index 3d3ef6610..e7191d0e9 100644 --- a/tex/context/base/util-prs.lua +++ b/tex/context/base/util-prs.lua @@ -8,7 +8,7 @@ if not modules then modules = { } end modules ['util-prs'] = { local lpeg, table, string = lpeg, table, string -local P, R, V, C, Ct, Cs, Carg, Cc = lpeg.P, lpeg.R, lpeg.V, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.Carg, lpeg.Cc +local P, R, V, S, C, Ct, Cs, Carg, Cc = lpeg.P, lpeg.R, lpeg.V, lpeg.S, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.Carg, lpeg.Cc local lpegmatch, patterns = lpeg.match, lpeg.patterns local concat, format, gmatch, find = table.concat, string.format, string.gmatch, string.find local tostring, type, next = tostring, type, next @@ -21,6 +21,21 @@ parsers.patterns = parsers.patterns or { } local setmetatableindex = table.setmetatableindex local sortedhash = table.sortedhash +-- we share some patterns + +local space = P(' ') +local equal = P("=") +local comma = P(",") +local lbrace = P("{") +local rbrace = P("}") +local period = S(".") +local punctuation = S(".,:;") +local spacer = patterns.spacer +local whitespace = patterns.whitespace +local newline = patterns.newline +local anything = patterns.anything +local endofstring = patterns.endofstring + -- we could use a Cf Cg construct local escape, left, right = P("\\"), P('{'), P('}') @@ -30,16 +45,11 @@ patterns.balanced = P { [2] = left * V(1) * right } -local space = P(' ') -local equal = P("=") -local comma = P(",") -local lbrace = P("{") -local rbrace = P("}") local nobrace = 1 - (lbrace+rbrace) local nested = P { lbrace * (nobrace + V(1))^0 * rbrace } local spaces = space^0 local argument = Cs((lbrace/"") * ((nobrace + nested)^0) * (rbrace/"")) -local content = (1-P(-1))^0 +local content = (1-endofstring)^0 patterns.nested = nested -- no capture patterns.argument = argument -- argument after e.g. = @@ -241,7 +251,7 @@ local digit = R("09") local pattern = Cs { "start", start = V("one") + V("two") + V("three"), - rest = (Cc(",") * V("thousand"))^0 * (P(".") + P(-1)) * P(1)^0, + rest = (Cc(",") * V("thousand"))^0 * (P(".") + endofstring) * anything^0, thousand = digit * digit * digit, one = digit * V("rest"), two = digit * digit * V("rest"), @@ -255,3 +265,14 @@ function parsers.splitthousands(str) end -- print(parsers.splitthousands("11111111111.11")) + +local optionalwhitespace = whitespace^0 + +patterns.words = Ct((Cs((1-punctuation-whitespace)^1) + anything)^1) +patterns.sentences = Ct((optionalwhitespace * Cs((1-period)^0 * period))^1) +patterns.paragraphs = Ct((optionalwhitespace * Cs((whitespace^1*endofstring/"" + 1 - (spacer^0*newline*newline))^1))^1) + +-- local str = " Word1 word2. \n Word3 word4. \n\n Word5 word6.\n " +-- inspect(lpegmatch(patterns.paragraphs,str)) +-- inspect(lpegmatch(patterns.sentences,str)) +-- inspect(lpegmatch(patterns.words,str)) diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index cc93c37db..dfd812d6a 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 : 07/20/12 00:58:15 +-- merge date : 07/21/12 13:05:20 do -- begin closure to overcome local limits and interference @@ -1451,11 +1451,11 @@ function lpeg.keeper(str) end function lpeg.frontstripper(str) -- or pattern (yet undocumented) - return (P(str) + P(true)) * Cs(P(1)^0) + return (P(str) + P(true)) * Cs(anything^0) end function lpeg.endstripper(str) -- or pattern (yet undocumented) - return Cs((1 - P(str) * P(-1))^0) + return Cs((1 - P(str) * endofstring)^0) end -- Just for fun I looked at the used bytecode and |