From 8ce9c33634056a6c8b9673c7f14a27cef1f3348f Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Thu, 25 Feb 2010 19:46:00 +0100 Subject: beta 2010.02.25 19:46 --- tex/context/base/anch-bar.mkiv | 33 ++++--------- tex/context/base/anch-pgr.mkiv | 2 + tex/context/base/cont-new.mkiv | 74 ++--------------------------- tex/context/base/cont-new.tex | 2 +- tex/context/base/context.tex | 2 +- tex/context/base/core-def.mkiv | 1 - tex/context/base/core-env.mkiv | 4 ++ tex/context/base/core-mis.mkiv | 37 +++++++++++++++ tex/context/base/enco-ini.mkiv | 44 +++++++---------- tex/context/base/font-ctx.lua | 8 ++-- tex/context/base/l-aux.lua | 2 + tex/context/base/l-lpeg.lua | 2 + tex/context/base/luat-cbk.lua | 2 + tex/context/base/node-par.lua | 2 +- tex/context/base/page-not.mkiv | 11 ++--- tex/context/base/spac-def.mkiv | 1 - tex/context/base/strc-not.mkiv | 35 +++++++++----- tex/context/base/supp-dir.mkiv | 3 ++ tex/context/base/syst-aux.mkiv | 18 +++---- tex/context/base/syst-lua.lua | 4 ++ tex/context/base/trac-deb.lua | 3 ++ tex/context/base/trac-inf.lua | 25 ++++++++++ tex/context/base/trac-tex.mkiv | 19 ++++++++ tex/context/base/trac-tra.lua | 7 +++ tex/generic/context/luatex-fonts-merged.lua | 4 +- 25 files changed, 188 insertions(+), 157 deletions(-) (limited to 'tex') diff --git a/tex/context/base/anch-bar.mkiv b/tex/context/base/anch-bar.mkiv index d08573c0f..f914976b2 100644 --- a/tex/context/base/anch-bar.mkiv +++ b/tex/context/base/anch-bar.mkiv @@ -119,30 +119,15 @@ {\removelastspace\tpos{side:\the\currentsidebar}\carryoverpar\egroup} \startMPpositionmethod{mpos:bar} - \startMPpositiongraphic{mpos:bar}{linecolor,linewidth,distance}% - StartPage ; - path p ; p := - if \MPp\MPbself=\MPp\MPeself : - (xpart ulcorner Field[Text][Text],\MPy\MPbself+\MPh\MPbself) -- - (xpart llcorner Field[Text][Text],\MPy\MPeself-\MPd\MPeself) ; - elseif RealPageNumber=\MPp\MPbself : - (xpart ulcorner Field[Text][Text],\MPy\MPbself+\MPh\MPbself) -- - (llcorner Field[Text][Text]) ; - elseif RealPageNumber=\MPp\MPeself : - (ulcorner Field[Text][Text]) -- - (xpart llcorner Field[Text][Text],\MPy\MPeself-\MPd\MPeself) ; - else : - (ulcorner Field[Text][Text]) -- - (llcorner Field[Text][Text]) ; - fi ; - p := p shifted (-llcorner Field[Text][Text]-(\MPvar{distance},0)) ; - interim linecap := butt ; - draw p - withpen pencircle scaled \MPvar{linewidth} - withcolor \MPvar{linecolor} ; - StopPage ; - \stopMPpositiongraphic - \MPpositiongraphic{mpos:bar}{}% + \startMPpositiongraphic{mpos:bar}{linecolor,linewidth,distance}% + position_anchor_bar ( + \MPp\MPbself, \MPp\MPeself, + \MPy\MPbself, \MPy\MPeself, + \MPh\MPbself, \MPd\MPeself, + \MPvar{distance}, \MPvar{linewidth}, \MPvar{linecolor} + ) ; + \stopMPpositiongraphic + \MPpositiongraphic{mpos:bar}{}% \stopMPpositionmethod %D We now reimplement the margin rules handler defined in diff --git a/tex/context/base/anch-pgr.mkiv b/tex/context/base/anch-pgr.mkiv index 642a20d93..7a8fcd07f 100644 --- a/tex/context/base/anch-pgr.mkiv +++ b/tex/context/base/anch-pgr.mkiv @@ -1031,6 +1031,8 @@ linecolor=blue, linewidth=1pt] +% these might become macros in mp-page + \startuseMPgraphic{mpos:common:ec} path pa ; pair ca ; color lc ; numeric lw ; lw := \MPvar{linewidth} ; diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index ce16ac69a..6269e5a61 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,29 +11,15 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -% 2009-07-15 / vista sp 2 / 2.2G duo dell M90 precision: -% -% \dorecurse{10000}{test \page} % 300 pps -% \dorecurse {2000}{test \page} % 260 pps -% \dorecurse {300}{test \page} % 135 pps - -% \ctxlua { fonts.define.method = 2 } % normally 3 - -\enablemode[mkiv] \setsystemmode{mkiv} - % potential new defaults: % % \setbreakpoints[compound] -\ctxlua{logs.report=function(s,t,...) commands.writestatus("!"..s,string.format(t,...)) end} - \unprotect -\def\immediatemessage#1{\ctxlua{commands.writestatus("message","#1")}} - -% % % % % % needs testing but saves runtime +\ctxlua{logs.report = commands.report} % this will become default -\let\checknotes\relax % probably not needed, checking already done +\def\immediatemessage#1{\ctxlua{commands.writestatus("message","#1")}} % we need to figure this out (to be discussed) @@ -47,60 +33,8 @@ \unexpanded\def\textplus {\char"002B } % plus -\let\\=\crlf % till we fixed all styles - -% \def\pagedir{\expandafter\gobblethreearguments} -% \def\bodydir{\expandafter\gobblethreearguments} - -%D Since this can be a showstopper, we report the path at the beginning -%D as well as at the end of a run. - -% \writestatus\m!lua{used config path - \ctxlua{tex.print(caches.configpath())}} -% \writestatus\m!lua{used cache path - \ctxlua{tex.print(caches.path)}} - -%D For the moment we report some statistics. Later this will become an option, -%D but for now we need this information. +% till we fixed all styles -\def\nomkivstatistics{\ctxlua{statistics.enable = false}} % for taco - -\def\resettimer {\ctxlua{environment.starttime = os.clock()}} -\def\elapsedtime {\ctxlua{tex.sprint(os.clock()-environment.starttime)}} -\let\elapsedseconds \elapsedtime - -% we will have a bunch of extra tracers (--dumphash --dumpdelta) - -\def\tracersdumphash {\ctxlua{tracers.register_dump_hash(false)}} -\def\tracersdumpdelta{\ctxlua{tracers.register_dump_hash(true)}} - -\resettimer - -%D For me. - -\def\traceluausage - {\dosingleempty\dotraceluausage} - -\def\dotraceluausage[#1]% - {\ctxlua{debugger.enable()}% - \appendtoks\ctxlua{debugger.disable() debugger.showstats(print,\doifnumberelse{#1}{#1}{5000})}\to\everybye} - -%D Fonts (experimental AFM loading} - -% \ctxlua { -% remapper.define('encoding','^lm' ,'^(.*)$','lm-\letterpercent1') -% remapper.define('encoding','^qbk','^(.*)$','q-\letterpercent1') -% remapper.define('encoding','^qcs','^(.*)$','q-\letterpercent1') -% remapper.define('encoding','^qpl','^(.*)$','q-\letterpercent1') -% remapper.define('encoding','^qtm','^(.*)$','q-\letterpercent1') -% } - -% \appendtoksonce \loadallXfontmapfiles \to \pdfbackendeveryximage -% \appendtoksonce \loadallXfontmapfiles \to \pdfbackendeveryxform -% \appendtoksonce \loadallXfontmapfiles \to \everystarttext -% \appendtoksonce \loadallXfontmapfiles \to \everybeforepagebody - -% \def\loadallXfontmapfiles{\ctxlua{fonts.map.flush("pdftex")}} +\let\\=\crlf \protect \endinput - -% \expanded{\defineactivecharacter \number"2000E} {\textdir TRT\relax} -% \expanded{\defineactivecharacter \number"2000F} {\textdir TLT\relax} diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index 1c4d68b39..ad7d67d32 100644 --- a/tex/context/base/cont-new.tex +++ b/tex/context/base/cont-new.tex @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2010.02.24 22:28} +\newcontextversion{2010.02.25 19:46} %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.tex b/tex/context/base/context.tex index f030aa5e1..20cd0b843 100644 --- a/tex/context/base/context.tex +++ b/tex/context/base/context.tex @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2010.02.24 22:28} +\edef\contextversion{2010.02.25 19:46} %D For those who want to use this: diff --git a/tex/context/base/core-def.mkiv b/tex/context/base/core-def.mkiv index 9f9d5b927..38c467a55 100644 --- a/tex/context/base/core-def.mkiv +++ b/tex/context/base/core-def.mkiv @@ -35,7 +35,6 @@ \appendtoks \settopskip \to \everyjob \appendtoks \preloadlanguages \to \everyjob \appendtoks \preloadspecials \to \everyjob -\appendtoks \checknotes \to \everyjob % depends on bodyfont \appendtoks \initializeMPgraphics \to \everyjob % after loading system files \appendtoks \initializemainlanguage \to \everyjob \appendtoks \MPLIBregister \to \everyjob diff --git a/tex/context/base/core-env.mkiv b/tex/context/base/core-env.mkiv index db05e8bd5..573aae0b2 100644 --- a/tex/context/base/core-env.mkiv +++ b/tex/context/base/core-env.mkiv @@ -162,6 +162,10 @@ \long\def\dostopallmodes #1\stopallmodes {} \long\def\dostopnotallmodes#1\stopnotallmodes{} +%D Lets now set a mode: + +\enablemode[mkiv] \setsystemmode{mkiv} + %D Setups: \let\startsetups\relax % to please dep checker diff --git a/tex/context/base/core-mis.mkiv b/tex/context/base/core-mis.mkiv index 0babb77f1..63f279c92 100644 --- a/tex/context/base/core-mis.mkiv +++ b/tex/context/base/core-mis.mkiv @@ -895,6 +895,39 @@ \doifinsetelse{\delimitedtextparameter\c!location}{\v!paragraph,\v!margin}% {\dosingleempty\dostartdelimitedtextpar}\dostartdelimitedtexttxt}} +% \def\dostartdelimitedtextpar[#1]% +% {\let\dostopdelimitedtext\dostopdelimitedtextpar +% \doifsomething{\delimitedtextparameter\c!spacebefore} +% {\blank[\delimitedtextparameter\c!spacebefore]}% +% \delimitedtextparameter\c!before +% % nicer: +% % \doadaptleftskip {\delimitedtextparameter\c!leftmargin}% +% % \doadaptrightskip{\delimitedtextparameter\c!rightmargin}% +% % backward compatible: +% \doifelsenothing{#1} +% {\endgraf +% \doadaptleftskip {\delimitedtextparameter\c!leftmargin}% +% \doadaptrightskip{\delimitedtextparameter\c!rightmargin}% +% \let\dodostopdelimitedtextpar\endgraf} +% {\startnarrower[#1]\let\dodostopdelimitedtextpar\stopnarrower}% +% % so far +% % \dochecknextindentation{\??ci\currentdelimitedtext}% AM: not here +% \dostartattributes{\??ci\currentdelimitedtext}\c!style\c!color\empty +% \leftdelimitedtextmark +% \ignorespaces} + +% \def\dostopdelimitedtextpar +% {\removeunwantedspaces +% \removelastskip +% \rightdelimitedtextmark +% \dostopattributes +% \dodostopdelimitedtextpar +% \delimitedtextparameter\c!after +% \doifsomething{\delimitedtextparameter\c!spaceafter} +% {\blank[\delimitedtextparameter\c!spaceafter]}% +% \dochecknextindentation{\??ci\currentdelimitedtext}% AM: here +% \dorechecknextindentation}% AM: This was missing! + \def\dostartdelimitedtextpar[#1]% {\let\dostopdelimitedtext\dostopdelimitedtextpar \doifsomething{\delimitedtextparameter\c!spacebefore} @@ -912,6 +945,9 @@ {\startnarrower[#1]\let\dodostopdelimitedtextpar\stopnarrower}% % so far % \dochecknextindentation{\??ci\currentdelimitedtext}% AM: not here + \pushmacro\checkindentation + \doifsomething{\delimitedtextparameter\c!indenting} % WS + {\setupindenting[\delimitedtextparameter\c!indenting]}% \dostartattributes{\??ci\currentdelimitedtext}\c!style\c!color\empty \leftdelimitedtextmark \ignorespaces} @@ -921,6 +957,7 @@ \removelastskip \rightdelimitedtextmark \dostopattributes + \popmacro\checkindentation \dodostopdelimitedtextpar \delimitedtextparameter\c!after \doifsomething{\delimitedtextparameter\c!spaceafter} diff --git a/tex/context/base/enco-ini.mkiv b/tex/context/base/enco-ini.mkiv index af4ddabaa..bab631ef9 100644 --- a/tex/context/base/enco-ini.mkiv +++ b/tex/context/base/enco-ini.mkiv @@ -335,39 +335,29 @@ \fallbackcontrolspace \fi} -\unexpanded\def\fastcontrolspace +\unexpanded\def\fastcontrolspace % no glyph resolving after first (use grouped) + {\dofastcontrolspace} + +\def\dofastcontrolspace {\iffontchar\font\textcontrolspace - \textcontrolspace + \nofastfallbackcontrolspace \else - \fallbackcontrolspace - \let\normalcontrolspace\fallbackcontrolspace - \fi} + \dofastfallbackcontrolspace + \fi + \dofastcontrolspace} -% helpers +\newbox\controlspacebox -\def\fakepercent - {\mathematics{^{\scriptscriptstyle0}\kern-.25em/\kern-.2em_{\scriptscriptstyle0}}} - -\def\fakeperthousand - {\mathematics{^{\scriptscriptstyle0}\kern-.25em/\kern-.2em_{\scriptscriptstyle00}}} +\def\nofastfallbackcontrolspace + {\let\dofastcontrolspace\textcontrolspace} -\def\fakepermine - {\dontleavehmode - \bgroup - \setbox\scratchbox\hbox - {\mathematics{+}}% - \hbox to \wd\scratchbox - {\hss\mathematics{^{\scriptscriptstyle-}\kern-.4em/\kern-.3em_{\scriptscriptstyle-}}\hss}% - \egroup} +\def\dofastfallbackcontrolspace + {\setbox\controlspacebox\hbox{\space}% + \setbox\controlspacebox\hbox to \wd\controlspacebox{\hss\fallbackcontrolspace\hss}% + \let\dofastcontrolspace\flushcontrolspacebox} -\def\fakedcontrolspace % can be virtual in luatex - {\dontleavehmode\hbox - {\scratchdimen.1ex% - \kern\scratchdimen - \vrule \!!width\scratchdimen \!!height5.5\scratchdimen\!!depth3\scratchdimen - \vrule \!!width\dimexpr.5em-4\scratchdimen\!!height -2\scratchdimen\!!depth3\scratchdimen - \vrule \!!width\scratchdimen \!!height5.5\scratchdimen\!!depth3\scratchdimen - \kern\scratchdimen}} +\def\flushcontrolspacebox + {\copy\controlspacebox} % from enco-acc: % diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua index 6ee2ca0d9..e37c0ea76 100644 --- a/tex/context/base/font-ctx.lua +++ b/tex/context/base/font-ctx.lua @@ -451,12 +451,14 @@ function fonts.cleanname(name) texsprint(ctxcatcodes,fonts.names.cleanname(name)) end -local p, f = 1, "%0.01fpt" -- normally this value is changed only once +local p, f = 1, "%0.1fpt" -- normally this value is changed only once + +local stripper = lpeg.patterns.strip_zeros function fonts.nbfs(amount,precision) if precision ~= p then p = precision - f = "%0.0" .. p .. "fpt" + f = "%0." .. p .. "fpt" end - texsprint(ctxcatcodes,format(f,amount/65536)) + texsprint(ctxcatcodes,lpegmatch(stripper,format(f,amount/65536))) end diff --git a/tex/context/base/l-aux.lua b/tex/context/base/l-aux.lua index e55f59758..4cee5f324 100644 --- a/tex/context/base/l-aux.lua +++ b/tex/context/base/l-aux.lua @@ -209,6 +209,8 @@ local stripper = lpeg.Cs((number + 1)^0) --~ lpegmatch(stripper,str) --~ print(#str, os.clock()-ts, lpegmatch(stripper,sample)) +lpeg.patterns.strip_zeros = stripper + function aux.strip_zeros(str) return lpegmatch(stripper,str) end diff --git a/tex/context/base/l-lpeg.lua b/tex/context/base/l-lpeg.lua index 9e761e4b3..e7b319874 100644 --- a/tex/context/base/l-lpeg.lua +++ b/tex/context/base/l-lpeg.lua @@ -8,6 +8,8 @@ if not modules then modules = { } end modules ['l-lpeg'] = { lpeg = require("lpeg") +lpeg.patterns = lpeg.patterns or { } -- so that we can share + local P, R, S, Ct, C, Cs, Cc = lpeg.P, lpeg.R, lpeg.S, lpeg.Ct, lpeg.C, lpeg.Cs, lpeg.Cc local match = lpeg.match diff --git a/tex/context/base/luat-cbk.lua b/tex/context/base/luat-cbk.lua index aa6f8c794..47dd94a05 100644 --- a/tex/context/base/luat-cbk.lua +++ b/tex/context/base/luat-cbk.lua @@ -29,6 +29,8 @@ local trace_callbacks = false trackers.register("system.callbacks", function(v) local register_callback, find_callback = callback.register, callback.find local frozen, stack = { }, { } +callback.original_register_callback = register_callback + local function frozenmessage(what,name) logs.report("callbacks","not %s frozen '%s' (%s)",what,name,frozen[name]) end diff --git a/tex/context/base/node-par.lua b/tex/context/base/node-par.lua index 2066d8ca4..ee0dfaf8a 100644 --- a/tex/context/base/node-par.lua +++ b/tex/context/base/node-par.lua @@ -44,7 +44,7 @@ end -- also for testing (no surrounding spacing done) function parbuilders.constructors.oneline(head,is_display) --- head.list = node.hpack(head) + return node.hpack(head) end local actions = tasks.actions("parbuilders",1) diff --git a/tex/context/base/page-not.mkiv b/tex/context/base/page-not.mkiv index 9628b9d5f..95229f9d0 100644 --- a/tex/context/base/page-not.mkiv +++ b/tex/context/base/page-not.mkiv @@ -29,17 +29,15 @@ \flushnotes \savenotecontent \fi - \savenotedata - \checknotes} + \savenotedata} \def\checkendcolumnfootnotes - {\restorenotedata % maybe better just \checknotes + {\restorenotedata \ifcase\clevernotes\else \restorenotecontent \fi} -\def\checksinglecolumnfootnotes - {\checknotes} % niet : \restorenotedata +\let\checksinglecolumnfootnotes\relax \newdimen\totalinsertionheight @@ -58,8 +56,7 @@ \flushnotes \savenotecontent \fi - \savenotedata - \checknotes} + \savenotedata} \def\checkendcolumnfootnotes {\restorenotedata diff --git a/tex/context/base/spac-def.mkiv b/tex/context/base/spac-def.mkiv index db4f4c2a4..3aa85dda5 100644 --- a/tex/context/base/spac-def.mkiv +++ b/tex/context/base/spac-def.mkiv @@ -59,7 +59,6 @@ \appendtoks \simplesetupindenting \to \everybodyfont \appendtoks \simplesetupblank \to \everybodyfont \appendtoks \simplesetupwhitespace \to \everybodyfont -%appendtoks \checknotes \to \everybodyfont % not \appendtoks \simplesetupspacing \to \everybodyfont % nieuw \appendtoks \setrelativeinterlinespace \to \everybodyfont diff --git a/tex/context/base/strc-not.mkiv b/tex/context/base/strc-not.mkiv index 088475d34..824fe3def 100644 --- a/tex/context/base/strc-not.mkiv +++ b/tex/context/base/strc-not.mkiv @@ -405,15 +405,8 @@ \ifnotelimit \global\dimen\currentnoteins\dimexpr\noteparameter\c!height*\scratchcounter\relax \fi - % distance - \begingroup - \setbox\scratchbox\vbox - {\forgetall - \noteparameter\c!before - \placenoterule - \noteparameter\c!after}% - \global\skip\currentnoteins\ht\scratchbox - \endgroup + % distance -> tricky as this might depend on a font switch so we need a fast checker + \dosetnotedistance % play safe \ifnum\noteparameter\s!noteloc=\plusfive \ctxlua{structure.notes.setstate("\currentnote","store")}% @@ -423,10 +416,28 @@ \global\skip \currentnoteins\zeropoint \fi} -% \def\checknotes -% {\processnotes\dochecknote} +\def\dosetnotedistance + {\begingroup + \setbox\scratchbox\vbox + {\forgetall + \dontcomplain + \noteparameter\c!before + \placenoterule + \noteparameter\c!after}% + \global\skip\currentnoteins\ht\scratchbox + \endgroup} -\let\checknotes\relax % experiment, avoiding this saves a lot of time +% \def\checknotes % no longer needed +% {\processnotes\dochecknote} +% +% \def\checknotedistances +% {\processnotes\dosetnotedistance} +% +% fails but not that much needed anyway: +% +% \appendtoks +% \checknotedistances +% \to \everyglobalbodyfont % D When \type{n} exceeds~1, footnotes are typeset in % D multi||columns, using the algoritm presented on page~397 diff --git a/tex/context/base/supp-dir.mkiv b/tex/context/base/supp-dir.mkiv index 2d7f6bd66..70738357b 100644 --- a/tex/context/base/supp-dir.mkiv +++ b/tex/context/base/supp-dir.mkiv @@ -15,4 +15,7 @@ \unprotect +% \expanded{\defineactivecharacter \number"2000E} {\textdir TRT\relax} +% \expanded{\defineactivecharacter \number"2000F} {\textdir TLT\relax} + \protect \endinput diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv index b8551999e..815d5add0 100644 --- a/tex/context/base/syst-aux.mkiv +++ b/tex/context/base/syst-aux.mkiv @@ -6532,10 +6532,15 @@ % awaiting the definitive implementation -\ifdefined\resettimer \else - \let\resettimer \relax - \newcount\elapsedtime -\fi +% \ifdefined\resettimer \else +% \let\resettimer \relax +% \newcount\elapsedtime +% \fi +% \def\elapsedseconds{\expandafter\withoutpt\the\dimexpr\elapsedtime sp\relax} + +\def\resettimer {\ctxlua{commands.resettimer()}} +\def\elapsedtime {\ctxlua{commands.elapsedtime()}} +\let\elapsedseconds \elapsedtime \newcount\featuretest @@ -6555,8 +6560,6 @@ \wait \egroup} -\def\elapsedseconds{\expandafter\withoutpt\the\dimexpr\elapsedtime sp\relax} - \def\showtimer#1% {\writestatus{runtime}{\elapsedseconds\space s / #1}} @@ -6812,8 +6815,7 @@ %D \stoptyping \def\stripstring#1% #1 is \cs - {\edef\cs{\ctxlua - {tex.sprint(tex.vrbcatcodes,string.strip(\!!bs\detokenize\expandafter{#1}\!!es))}}} + {\edef\cs{\ctxlua{tex.sprint(tex.vrbcatcodes,string.strip(\!!bs\detokenize\expandafter{#1}\!!es))}}} %D \macros %D {dowithrange} diff --git a/tex/context/base/syst-lua.lua b/tex/context/base/syst-lua.lua index 23c5b05ef..bd4aad891 100644 --- a/tex/context/base/syst-lua.lua +++ b/tex/context/base/syst-lua.lua @@ -29,6 +29,10 @@ function commands.writedebug(a,b,c,...) end end +function commands.report(s,t,...) + commands.writestatus("!"..s,format(t,...)) +end + function commands.doifelse(b) if b then -- faster with if than with expression texsprint(ctxcatcodes,"\\firstoftwoarguments") diff --git a/tex/context/base/trac-deb.lua b/tex/context/base/trac-deb.lua index 1a7c55594..11d044af4 100644 --- a/tex/context/base/trac-deb.lua +++ b/tex/context/base/trac-deb.lua @@ -182,3 +182,6 @@ function tracers.register_dump_hash(delta) end main.register_stop_actions(1,function() tracers.dump_hash(nil,true) end) -- at front end + +directives.register("system.dumphash", function() tracers.register_dump_hash(false) end) +directives.register("system.dumpdelta", function() tracers.register_dump_hash(true ) end) diff --git a/tex/context/base/trac-inf.lua b/tex/context/base/trac-inf.lua index 84fa5507a..315195012 100644 --- a/tex/context/base/trac-inf.lua +++ b/tex/context/base/trac-inf.lua @@ -25,6 +25,14 @@ function statistics.hastimer(instance) return instance and instance.starttime end +function statistics.resettiming(instance) + if not instance then + notimer = { timing = 0, loadtime = 0 } + else + instance.timing, instance.loadtime = 0, 0 + end +end + function statistics.starttiming(instance) if not instance then notimer = { } @@ -168,3 +176,20 @@ function statistics.timed(action,report) report("total runtime: %s",statistics.elapsedtime(timer)) end +-- where, not really the best spot for this: + +commands = commands or { } + +local timer + +function commands.resettimer() + statistics.resettiming(timer) + statistics.starttiming(timer) +end + +function commands.elapsedtime() + statistics.stoptiming(timer) + tex.sprint(statistics.elapsedtime(timer)) +end + +commands.resettimer() diff --git a/tex/context/base/trac-tex.mkiv b/tex/context/base/trac-tex.mkiv index 844354160..9c596feab 100644 --- a/tex/context/base/trac-tex.mkiv +++ b/tex/context/base/trac-tex.mkiv @@ -33,4 +33,23 @@ \def\doenabletextracer #1{\csname enabletracer#1\endcsname} \def\dodisabletextracer#1{\csname disabletracer#1\endcsname} +% context --directives=system.nostatistics ... + +\def\nomkivstatistics{\ctxlua{statistics.enable = false}} % for taco + +\def\tracersdumphash {\ctxlua{tracers.register_dump_hash(false)}} +\def\tracersdumpdelta{\ctxlua{tracers.register_dump_hash(true)}} + +% wrong place: + +\def\traceluausage + {\dosingleempty\dotraceluausage} + +\def\dotraceluausage[#1]% + {\ctxlua{debugger.enable()}% + \appendtoks + \ctxlua{debugger.disable() debugger.showstats(print,\doifnumberelse{#1}{#1}{5000})}^ + \to \everybye + \gdef\dotraceluausage[#1]{}} + \protect \endinput diff --git a/tex/context/base/trac-tra.lua b/tex/context/base/trac-tra.lua index b6598484e..4c578fcee 100644 --- a/tex/context/base/trac-tra.lua +++ b/tex/context/base/trac-tra.lua @@ -329,3 +329,10 @@ function experiments.disable(...) commands.writestatus("experiments","disabling: %s",concat({...}," ")) d(...) end + +-- a useful example + +directives.register("system.nostatistics", function(v) + statistics.enable = not v +end) + diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua index 559220bc8..47feb5236 100644 --- a/tex/generic/context/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts.lua --- merge date : 02/24/10 22:33:12 +-- merge date : 02/25/10 19:56:12 do -- begin closure to overcome local limits and interference @@ -304,6 +304,8 @@ if not modules then modules = { } end modules ['l-lpeg'] = { lpeg = require("lpeg") +lpeg.patterns = lpeg.patterns or { } -- so that we can share + local P, R, S, Ct, C, Cs, Cc = lpeg.P, lpeg.R, lpeg.S, lpeg.Ct, lpeg.C, lpeg.Cs, lpeg.Cc local match = lpeg.match -- cgit v1.2.3