From 4e362156550b2624811c01de388d3d695f444d77 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Sun, 17 Jan 2010 23:50:00 +0100 Subject: beta 2010.01.17 23:50 --- tex/context/base/buff-ini.lua | 18 +++++++++-- tex/context/base/buff-ver.mkiv | 3 +- tex/context/base/chem-str.lua | 3 +- tex/context/base/cont-new.tex | 2 +- tex/context/base/context.tex | 2 +- tex/context/base/core-fil.mkiv | 39 ----------------------- tex/context/base/pret-lua.lua | 68 ++++++++++++++++++++++++++-------------- tex/context/base/strc-itm.mkiv | 10 ++++++ tex/context/base/strc-not.lua | 38 ++++++++++++++++++----- tex/context/base/strc-not.mkiv | 70 ++++++++++++++++++++++++++++-------------- tex/context/base/supp-fil.lua | 5 +-- 11 files changed, 157 insertions(+), 101 deletions(-) (limited to 'tex') diff --git a/tex/context/base/buff-ini.lua b/tex/context/base/buff-ini.lua index 4822e8b3c..1c20e24ac 100644 --- a/tex/context/base/buff-ini.lua +++ b/tex/context/base/buff-ini.lua @@ -384,15 +384,30 @@ local currentvisualizer, currenthandler function buffers.setvisualizer(str) currentvisualizer = lower(str) currenthandler = handlers[currentvisualizer] - if not currenthandler then + if currenthandler then + -- if trace_visualize then + -- logs.report("buffers","enabling specific '%s' visualizer",currentvisualizer) + -- end + else currentvisualizer = visualizers.defaultname currenthandler = handlers.default + -- if trace_visualize then + -- logs.report("buffers","enabling default visualizer '%s'",currentvisualizer) + -- end end if currenthandler.reset then currenthandler.reset() end end +function buffers.resetvisualizer() + currentvisualizer = visualizers.defaultname + currenthandler = handlers.default + if currenthandler.reset then + currenthandler.reset() + end +end + buffers.setvisualizer(visualizers.defaultname) function visualizers.reset() @@ -420,7 +435,6 @@ function hooks.end_of_inline() (currenthandler.end_of_inline or default.end_of_inline)() end - function hooks.flush_line(str,nesting) local fl = currenthandler.flush_line if fl then diff --git a/tex/context/base/buff-ver.mkiv b/tex/context/base/buff-ver.mkiv index 80816d0f7..1ade44c7c 100644 --- a/tex/context/base/buff-ver.mkiv +++ b/tex/context/base/buff-ver.mkiv @@ -157,7 +157,8 @@ \let\bop\doverbatimbop \let\eop\doverbatimeop \let\sop\doverbatimsop}% - {\let\bop\noverbatimbop + {\ctxlua{buffers.setvisualizer("\v!typing")}% or resetdefaultvisualizer + \let\bop\noverbatimbop \let\eop\noverbatimeop \let\sop\noverbatimsop}% \relax\the\everyinitializeverbatim\relax} diff --git a/tex/context/base/chem-str.lua b/tex/context/base/chem-str.lua index b151ab2a0..02fc585fc 100644 --- a/tex/context/base/chem-str.lua +++ b/tex/context/base/chem-str.lua @@ -142,10 +142,11 @@ local syntax = { local definitions = { } function chemicals.undefine(name) - definitions[name] = nil + definitions[lower(name)] = nil end function chemicals.define(name,spec,text) + name = lower(name) local dn = definitions[name] if not dn then dn = { } definitions[name] = dn end dn[#dn+1] = { diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index 65784070b..6dc37d037 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.01.14 18:25} +\newcontextversion{2010.01.17 23:50} %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 fb2f62aa7..ec74cc3c3 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.01.14 18:25} +\edef\contextversion{2010.01.17 23:50} %D For those who want to use this: diff --git a/tex/context/base/core-fil.mkiv b/tex/context/base/core-fil.mkiv index 2f77a0021..9aaa68c3f 100644 --- a/tex/context/base/core-fil.mkiv +++ b/tex/context/base/core-fil.mkiv @@ -114,45 +114,6 @@ %D their dedicated manuals. We use \type {\next} so that we %D can \type {\end} in modules. -% \newconditional\moduleisloaded - -% \def\dododousemodules#1#2% no \unprotect/\protect when loading, -% {\relax % since we need to use ? ! unprotected -% \ifconditional\moduleisloaded % sometimes (see xtag-map) -% \let\next\relax % or: \expandafter\gobbleoneargument -% \else -% \makeshortfilename[#1\truefilename{#2}]% beware: *- is not part of syn -% \doifelseflagged\shortfilename -% {\showmessage\m!systems7{#2 (line \number\inputlineno)}% -% \settrue\moduleisloaded -% \let\next\relax} -% {\doglobal\setflag\shortfilename -% \def\next -% {\startreadingfile -% \readsysfile\shortfilename -% {\showmessage\m!systems5{#2}\settrue\moduleisloaded} -% {\readsysfile{\shortfilename.\mksuffix} % new -% {\showmessage\m!systems5{#2 (\mksuffix)}\settrue\moduleisloaded} -% \donothing}% -% \stopreadingfile}}% -% \fi -% \next} - -% \def\dodousemodules#1#2% -% {\setfalse\moduleisloaded -% \doifelsenothing{#1} -% {\dododousemodules\f!moduleprefix {#2}% -% \dododousemodules\f!privateprefix{#2}% -% \dododousemodules\f!styleprefix {#2}% -% \dododousemodules\f!xstyleprefix {#2}% -% \dododousemodules\f!thirdprefix {#2}% -% \dododousemodules\empty {#2}}% new, fall back on raw name -% {\dododousemodules{#1-}{#2}}% -% \ifconditional\moduleisloaded\else -% \showmessage\m!systems6{#2}% -% \appendtoks\showmessage\m!systems6{#2}\to\everynotabene -% \fi} - \def\dodousemodules#1#2% {\ctxlua{support.usemodules("#1","#2","\truefilename{#2}")}} diff --git a/tex/context/base/pret-lua.lua b/tex/context/base/pret-lua.lua index 2809a1eca..67fc85368 100644 --- a/tex/context/base/pret-lua.lua +++ b/tex/context/base/pret-lua.lua @@ -169,7 +169,35 @@ function visualizer.flush_line(str, nested) end local p, s = nil, nil for c in utfcharacters(code) do - if c == "[" then + if instr then + if p then + texwrite(p) + p = nil + end + if c == s then + if inesc then + texwrite(c) + inesc = false + else + state = change_state(states[c],state) + instr = false + texwrite(c) + state = finish_state(state) + end + s = nil + else + if c == "\\" then + inesc = not inesc + else + inesc = false + end + texwrite(c) + end + elseif c == "[" then + if word then + texwrite(word) + word = nil + end if p == "[" then inlongstring = true state = change_state(states["[["],state) @@ -177,9 +205,16 @@ function visualizer.flush_line(str, nested) state = finish_state(state) p = nil else + if p then + texwrite(p) + end p = c end elseif c == "]" then + if word then + texwrite(word) + word = nil + end if p == "]" then inlongstring = false state = change_state(states["]]"],state) @@ -187,12 +222,15 @@ function visualizer.flush_line(str, nested) state = finish_state(state) p = nil else + if p then + texwrite(p) + end p = c end else if p then - state = change_state(states[c],state) - texwrite(p,c) + state = change_state(states[p],state) + texwrite(p) state = finish_state(state) p = nil end @@ -204,26 +242,6 @@ function visualizer.flush_line(str, nested) texsprint(ctxcatcodes,"\\obs") elseif inlongstring then texwrite(c) - elseif instr then - if c == s then - if inesc then - texwrite(c) - inesc = false - else - state = change_state(states[c],state) - instr = false - texwrite(c) - state = finish_state(state) - end - s = nil - else - if c == "\\" then - inesc = not inesc - else - inesc = false - end - texwrite(c) - end elseif c == '"' or c == "'" then instr = true state = change_state(states[c],state) @@ -244,6 +262,10 @@ function visualizer.flush_line(str, nested) end end end +if p then + texwrite(p) + p = nil +end state = flush_lua_word(state,word) if post then state = change_state(states['--'], state) diff --git a/tex/context/base/strc-itm.mkiv b/tex/context/base/strc-itm.mkiv index a67321e63..35ed67d77 100644 --- a/tex/context/base/strc-itm.mkiv +++ b/tex/context/base/strc-itm.mkiv @@ -860,6 +860,16 @@ \appendtoks \letvalue\v!mar \itemgroupmargin \to \itemgroupcommands % todo : \startitem .. \stopitem +% +% beware, we don't group (yet) as we want to keep the left/right skip +% +% \startitemize +% \startitem \stopitem +% some intermediate text that will properly indent +% \startitem \stopitem +% \stopitem +% +% so we need to keep that property \appendtoks \letvalue{\e!start\v!item}\itemgroupitem diff --git a/tex/context/base/strc-not.lua b/tex/context/base/strc-not.lua index f390c05b5..97e1ffe72 100644 --- a/tex/context/base/strc-not.lua +++ b/tex/context/base/strc-not.lua @@ -52,14 +52,14 @@ function notes.store(tag,n) end state.start = state.start or nnd end - tex.write(#nd) + texwrite(#nd) end -function notes.get(tag,n) +local function get(tag,n) local nd = notedata[tag] if nd then - n = n or #notedata - nd = nd[n or n] + n = n or #nd + nd = nd[n] if nd then if trace_notes then logs.report("notes","getting %s of %s",n,tag) @@ -69,6 +69,14 @@ function notes.get(tag,n) end end +local function getn(tag) + local nd = notedata[tag] + return (nd and #nd) or 0 +end + +nodes.get = get +nodes.getn = getn + -- we could make a special enhancer function notes.listindex(tag,n) @@ -142,7 +150,7 @@ function notes.doifcontent(tag) end local function internal(tag,n) - local nd = notes.get(tag,n) + local nd = get(tag,n) if nd then local r = nd.references if r then @@ -160,6 +168,20 @@ local function ordered(kind,name,n) return o and o[n] end +notes.internal = internal +notes.ordered = ordered + +function notes.doifonsamepageasprevious(tag) + local same = false + local n = getn(tag,n) + local current, previous = get(tag,n), get(tag,n-1) + if current and previous then + local cr, pr = current.references, previous.references + same = cr and pr and cr.realpage == pr.realpage + end + commands.doifelse(same) +end + function notes.checkpagechange(tag) -- called before increment ! local nd = notedata[tag] -- can be unset at first entry if nd then @@ -203,7 +225,7 @@ function notes.deltapage(tag,n) what = 3 end end - tex.write(what) + texwrite(what) end function notes.postpone() @@ -218,14 +240,14 @@ function notes.postpone() end function notes.setsymbolpage(tag,n) - local nd = notes.get(tag,n) + local nd = get(tag,n) if nd then nd.metadata.symbolpage = texcount.realpageno end end function notes.getsymbolpage(tag,n) - local nd = notes.get(tag,n) + local nd = get(tag,n) nd = nd and nd.metadata.symbolpage texwrite(nd or 0) end diff --git a/tex/context/base/strc-not.mkiv b/tex/context/base/strc-not.mkiv index 6be959fa3..4bc08f7cc 100644 --- a/tex/context/base/strc-not.mkiv +++ b/tex/context/base/strc-not.mkiv @@ -17,6 +17,12 @@ \unprotect +% this needs a further cleanup ... +% +% -- set breakpoin in descriptions +% -- reset after trialtypesetting +% -- that way we can trick the symbol space + % obsolete \let\autopostponenotes\relax @@ -539,35 +545,43 @@ \def\@@notemakedescription[#1]#2#3% todo ... proper [key=value] etc {\ifnotesenabled - \begingroup - \doenumerationcheckconditions - \let\currentnote\currentdescriptionmain - \dodescriptioncomponent[\c!reference=#1,\c!label={\descriptionparameter\c!text},\c!title={#3},\c!list=,\c!bookmark=,][]% - \xdef\currentnotenumber{\ctxlua{structure.notes.store("\currentnote",\currentdescriptionnumberentry)}}% - \settrue\processingnote - \ifconditional\skipnoteplacement - \globallet\lastnotesymbol\dolastnotesymbol + \iftrialtypesetting + % some day a roll back \else - \iftypesettinglines % otherwise problems with \type {xxx} - \ignorelines % makes footnotes work in \startlines ... \stoplines + \begingroup + \doenumerationcheckconditions + \let\currentnote\currentdescriptionmain + \dodescriptioncomponent[\c!reference=#1,\c!label={\descriptionparameter\c!text},\c!title={#3},\c!list=,\c!bookmark=,][]% + \xdef\currentnotenumber{\ctxlua{structure.notes.store("\currentnote",\currentdescriptionnumberentry)}}% + \settrue\processingnote + \ifconditional\skipnoteplacement + \globallet\lastnotesymbol\dolastnotesymbol + \else + \iftypesettinglines % otherwise problems with \type {xxx} + \ignorelines % makes footnotes work in \startlines ... \stoplines + \fi + \ifnotesymbol + \dolastnotesymbol + \else + \unskip\unskip + \globallet\lastnotesymbol\dolastnotesymbol + \fi \fi - \ifnotesymbol - \dolastnotesymbol + \ifconditional\postponingnotes + \global\settrue\postponednote \else - \unskip\unskip - \globallet\lastnotesymbol\dolastnotesymbol + \handlenoteinsert\currentnote\currentnotenumber \fi + \endgroup \fi - \ifconditional\postponingnotes - \global\settrue\postponednote + \fi + \ifconditional\skipnoteplacement \else + \kern\notesignal\relax % \relax is needed to honor spaces + \iftrialtypesetting + % todo: reserve some space for symbol, in that case we need to be able to roll back notes \else - \handlenoteinsert\currentnote\currentnotenumber - \fi - \ifconditional\skipnoteplacement \else - \kern\notesignal\relax % \relax is needed to honor spaces - \iftrialtypesetting \else \global\setfalse\skipnoteplacement \fi + \global\setfalse\skipnoteplacement \fi - \endgroup \fi} \def\dolastnotesymbol @@ -770,7 +784,7 @@ {% this should be checked, smells like a mix-up % does not split: \ifcase\noteparameter\c!n\unvbox\else\box\fi\currentnoteins \ifcase\noteparameter\c!n\relax - \iftrialtypesetting\unvcopied\else\unvboxed\fi\currentnoteins + \iftrialtypesetting\unvcopied\else\unvboxed\fi\currentnoteins % is this needed? \or \iftrialtypesetting\copy\else\box\fi\currentnoteins \obeydepth % (a) added , since split footnotes will not align properly @@ -1160,6 +1174,16 @@ \def\donote[#1][#2]{\ifsecondargument\donotesymbol[#1][#2]\else\secondargumenttrue\donotesymbol[\v!footnote][#1]\fi} +%D Goodies: +%D +%D \starttyping +%D \dorecurse {100} { +%D test \footnote{\doifnoteonsamepageelse[footnote]{ibidem}{aaa}} +%D } +%D \stoptyping + +\def\doifnoteonsamepageelse[#1]{\ctxlua{structure.notes.doifonsamepageasprevious("#1")}} + %D New trickery: \def\ownnotesymbol#1% #1 gets number passed diff --git a/tex/context/base/supp-fil.lua b/tex/context/base/supp-fil.lua index 974e39143..45fba4ae2 100644 --- a/tex/context/base/supp-fil.lua +++ b/tex/context/base/supp-fil.lua @@ -196,7 +196,8 @@ local function usemodule(name,hassheme) end function support.usemodules(prefix,askedname,truename) - local status = modstatus[truename] + local hashname = prefix .. "-" .. truename + local status = modstatus[hashname] if status == 0 then -- not found elseif status == 1 then @@ -251,7 +252,7 @@ function support.usemodules(prefix,askedname,truename) context.showmessage("systems",7,askedname) end end - modstatus[truename] = status + modstatus[hashname] = status end statistics.register("loaded tex modules", function() -- cgit v1.2.3