From 0345d11594248a6dc9934602933a4cb19988fb00 Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Thu, 16 Apr 2015 16:15:05 +0200 Subject: 2015-04-16 15:16:00 --- tex/context/base/buff-ver.mkiv | 4 + tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4181 -> 4186 bytes tex/context/base/context.mkiv | 2 +- tex/context/base/data-res.lua | 237 +++++---------------- tex/context/base/file-job.lua | 28 +++ tex/context/base/file-job.mkvi | 20 ++ tex/context/base/l-math.lua | 4 + tex/context/base/mlib-lua.lua | 3 +- tex/context/base/mlib-pps.lua | 17 +- tex/context/base/node-ltp.lua | 10 +- tex/context/base/page-lin.lua | 2 +- tex/context/base/page-lin.mkvi | 28 +-- tex/context/base/publ-imp-apa.mkvi | 16 +- tex/context/base/publ-imp-list.mkvi | 4 +- tex/context/base/publ-ini.mkiv | 12 +- tex/context/base/status-files.pdf | Bin 24489 -> 24483 bytes tex/context/base/status-lua.pdf | Bin 249882 -> 250255 bytes tex/context/base/strc-syn.lua | 94 ++++++-- tex/context/base/strc-syn.mkiv | 224 +++++++++++++++++-- tex/context/base/tabl-xtb.lua | 3 + tex/context/base/tabl-xtb.mkvi | 12 +- tex/generic/context/luatex/luatex-fonts-merged.lua | 5 +- 23 files changed, 451 insertions(+), 276 deletions(-) (limited to 'tex') diff --git a/tex/context/base/buff-ver.mkiv b/tex/context/base/buff-ver.mkiv index 1581973d1..67f861ba0 100644 --- a/tex/context/base/buff-ver.mkiv +++ b/tex/context/base/buff-ver.mkiv @@ -80,6 +80,8 @@ \usetypestyleandcolor\c!style\c!color \else\ifx\p_buff_option\empty \usetypestyleandcolor\c!style\c!color + \else + \usetypestyleparameter\c!style % no color \fi\fi \setcatcodetable\vrbcatcodes} @@ -124,6 +126,8 @@ \usetypingstyleandcolor\c!style\c!color \else\ifx\p_buff_option\empty \usetypingstyleandcolor\c!style\c!color + \else + \usetypingstyleparameter\c!style % no color ! \fi\fi \usealignparameter\typingparameter} diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index c84ac47c9..943259fb8 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{2015.04.15 01:44} +\newcontextversion{2015.04.16 15:14} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf index 876060740..4fae8a382 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index c74f81ba7..9e54f89a7 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -39,7 +39,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2015.04.15 01:44} +\edef\contextversion{2015.04.16 15:14} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/data-res.lua b/tex/context/base/data-res.lua index 26cfe673a..cbda21ce2 100644 --- a/tex/context/base/data-res.lua +++ b/tex/context/base/data-res.lua @@ -803,49 +803,72 @@ function resolvers.registerextrapath(paths,subpaths) if newn > 0 then instance.extra_paths = ep -- register paths end - if newn > oldn then + if newn ~= oldn then reset_caches() end end +function resolvers.pushextrapath(path) + local paths = settings_to_array(path) + if instance.extra_stack then + insert(instance.extra_stack,1,paths) + else + instance.extra_stack = { paths } + end + reset_caches() +end + +function resolvers.popextrapath() + if instance.extra_stack then + reset_caches() + return remove(instance.extra_stack,1) + end +end + local function made_list(instance,list,extra_too) - local done, new, newn = { }, { }, 0 - -- honour . .. ../.. but only when at the start - for k=1,#list do - local v = list[k] - if not done[v] then - if find(v,"^[%.%/]$") then + local done = { } + local new = { } + local newn = 0 + -- a helper + local function add(p) + for k=1,#p do + local v = p[k] + if not done[v] then done[v] = true newn = newn + 1 new[newn] = v - else - break - end - end - end - -- first the extra paths - if extra_too then - local ep = instance.extra_paths - if ep and #ep > 0 then - for k=1,#ep do - local v = ep[k] - if not done[v] then - done[v] = true - newn = newn + 1 - new[newn] = v - end end end end - -- next the formal paths + -- honour . .. ../.. but only when at the start for k=1,#list do local v = list[k] - if not done[v] then + if done[v] then + -- skip + elseif find(v,"^[%.%/]$") then done[v] = true newn = newn + 1 new[newn] = v + else + break + end + end + if extra_too then + -- first the stacked paths + local es = instance.extra_stack + if es and #es > 0 then + for k=1,#es do + add(es[k]) + end + end + -- then the extra paths + local ep = instance.extra_paths + if ep and #ep > 0 then + add(ep) end end + -- last the formal paths + add(list) return new end @@ -1191,170 +1214,6 @@ local function check_subpath(fname) end end --- old one / keep as reference - --- local function find_intree(filename,filetype,wantedfiles,allresults) --- local typespec = resolvers.variableofformat(filetype) --- local pathspec = pathspecs[filetype] --- local pathlist = resolvers.expandedpathlist(typespec,filetype and usertypes[filetype]) -- only extra path with user files --- local method = "intree" --- if pathlist and #pathlist > 0 then --- -- list search --- local filelist = collect_files(wantedfiles) -- okay, a bit over the top when we just look relative to the current path --- local dirlist = { } --- if filelist then --- for i=1,#filelist do --- dirlist[i] = filedirname(filelist[i][3]) .. "/" -- was [2] .. gamble --- end --- end --- if trace_detail then --- report_resolving("checking filename %a in tree",filename) --- end --- local result = { } --- -- pathlist : resolved --- -- dirlist : unresolved or resolved --- -- filelist : unresolved --- for k=1,#pathlist do --- local path = pathlist[k] --- local pathname = lpegmatch(inhibitstripper,path) --- local doscan = path == pathname -- no ^!! --- if not find (pathname,'//$') then --- doscan = false -- we check directly on the path --- end --- local done = false --- -- using file list --- if filelist then -- database --- -- compare list entries with permitted pattern -- /xx /xx// --- local expression = makepathexpression(pathname) --- if trace_detail then --- report_resolving("using pattern %a for path %a",expression,pathname) --- end --- for k=1,#filelist do --- local fl = filelist[k] --- local f = fl[2] --- local d = dirlist[k] --- -- resolve is new: --- if find(d,expression) or find(resolveprefix(d),expression) then --- -- todo, test for readable --- result[#result+1] = resolveprefix(fl[3]) -- no shortcut --- done = true --- if allresults then --- if trace_detail then --- report_resolving("match to %a in hash for file %a and path %a, continue scanning",expression,f,d) --- end --- else --- if trace_detail then --- report_resolving("match to %a in hash for file %a and path %a, quit scanning",expression,f,d) --- end --- break --- end --- elseif trace_detail then --- report_resolving("no match to %a in hash for file %a and path %a",expression,f,d) --- end --- end --- end --- if done then --- method = "database" --- else --- method = "filesystem" -- bonus, even when !! is specified --- pathname = gsub(pathname,"/+$","") --- pathname = resolveprefix(pathname) --- local scheme = url.hasscheme(pathname) --- if not scheme or scheme == "file" then --- local pname = gsub(pathname,"%.%*$",'') --- if not find(pname,"*",1,true) then --- if can_be_dir(pname) then --- -- hm, rather useless as we don't go deeper and if we would we could also --- -- auto generate the file database .. however, we need this for extra paths --- -- that are not hashed (like sources on my machine) .. so, this is slightly --- -- out of order but at least fast (and we seldom end up here, only when a file --- -- is not already found --- if trace_detail then --- report_resolving("quick root scan for %a",pname) --- end --- for k=1,#wantedfiles do --- local w = wantedfiles[k] --- local fname = check_subpath(filejoin(pname,w)) --- if fname then --- result[#result+1] = fname --- done = true --- if not allresults then --- break --- end --- end --- end --- if not done and doscan then --- -- collect files in path (and cache the result) --- if trace_detail then --- report_resolving("scanning filesystem for %a",pname) --- end --- local files = resolvers.simplescanfiles(pname,false,true) --- for k=1,#wantedfiles do --- local w = wantedfiles[k] --- local subpath = files[w] --- if not subpath or subpath == "" then --- -- rootscan already done --- elseif type(subpath) == "string" then --- local fname = check_subpath(filejoin(pname,subpath,w)) --- if fname then --- result[#result+1] = fname --- done = true --- if not allresults then --- break --- end --- end --- else --- for i=1,#subpath do --- local sp = subpath[i] --- if sp == "" then --- -- roottest already done --- else --- local fname = check_subpath(filejoin(pname,sp,w)) --- if fname then --- result[#result+1] = fname --- done = true --- if not allresults then --- break --- end --- end --- end --- end --- if done and not allresults then --- break --- end --- end --- end --- end --- end --- else --- -- no access needed for non existing path, speedup (esp in large tree with lots of fake) --- end --- else --- -- we can have extra_paths that are urls --- for k=1,#wantedfiles do --- -- independent url scanner --- local fname = methodhandler('finders',pathname .. "/" .. wantedfiles[k]) --- if fname then --- result[#result+1] = fname --- done = true --- if not allresults then --- break --- end --- end --- end --- end --- end --- -- todo recursive scanning --- if done and not allresults then --- break --- end --- end --- if #result > 0 then --- return method, result --- end --- end --- end - -- this caching is not really needed (seldom accessed) but more readable -- we could probably move some to a higher level but then we need to adapt -- more code ... maybe some day diff --git a/tex/context/base/file-job.lua b/tex/context/base/file-job.lua index 9bf43bbdc..3a034f0a3 100644 --- a/tex/context/base/file-job.lua +++ b/tex/context/base/file-job.lua @@ -54,6 +54,9 @@ local hasscheme = url.hasscheme local jobresolvers = resolvers.jobs local registerextrapath = resolvers.registerextrapath +local resetextrapath = resolvers.resetextrapath +local pushextrapath = resolvers.pushextrapath +local popextrapath = resolvers.popextrapath local v_outer = variables.outer local v_text = variables.text @@ -113,6 +116,23 @@ implement { end } +implement { + name = "pushpath", + arguments = "string", + actions = function(paths) + report_jobfiles("pushing path: %s",paths) + pushextrapath(paths) + end +} + +implement { + name = "poppath", + actions = function(paths) + popextrapath() + report_jobfiles("popping path") + end +} + implement { name = "usesubpath", arguments = "string", @@ -122,6 +142,14 @@ implement { end } +implement { + name = "resetpath", + actions = function() + report_jobfiles("resetting path") + resetextrapath() + end +} + implement { name = "allinputpaths", actions = function() diff --git a/tex/context/base/file-job.mkvi b/tex/context/base/file-job.mkvi index bd10c59e0..7814aba3f 100644 --- a/tex/context/base/file-job.mkvi +++ b/tex/context/base/file-job.mkvi @@ -31,12 +31,32 @@ % path control +%D In the following example the lookup order is \type {.}, {/foo}, \type +%D {foo/bar} as one can always explicitly prefix a wanted file. +%D +%D \starttyping +%D \pushpath[foo] +%D \pushpath[foo/bar] +%D \input test +%D \poppath +%D \poppath +%D \stoptyping + \unexpanded\def\usepath[#path]% {\clf_usepath{#path}} \unexpanded\def\usesubpath[#path]% {\clf_usesubpath{#path}} +\unexpanded\def\pushpath[#path]% + {\clf_pushpath{#path}} + +\unexpanded\def\poppath + {\clf_poppath} + +\unexpanded\def\resetpath % not the pushed paths + {\clf_resetpath} + \def\allinputpaths {\clf_allinputpaths} diff --git a/tex/context/base/l-math.lua b/tex/context/base/l-math.lua index 43f60b56b..ec62919b4 100644 --- a/tex/context/base/l-math.lua +++ b/tex/context/base/l-math.lua @@ -8,6 +8,10 @@ if not modules then modules = { } end modules ['l-math'] = { local floor, sin, cos, tan = math.floor, math.sin, math.cos, math.tan +if not math.ceiling then + math.ceiling = math.ceil +end + if not math.round then function math.round(x) return floor(x + 0.5) end end diff --git a/tex/context/base/mlib-lua.lua b/tex/context/base/mlib-lua.lua index 392fc1a3c..7e0568463 100644 --- a/tex/context/base/mlib-lua.lua +++ b/tex/context/base/mlib-lua.lua @@ -373,8 +373,9 @@ end -- end function mp.tt_dimensions(n) - local box = textexts and textexts[n] + local box = textexts[n] if box then + -- could be made faster with nuts but not critical mptriplet(box.width/factor,box.height/factor,box.depth/factor) else mptriplet(0,0,0) diff --git a/tex/context/base/mlib-pps.lua b/tex/context/base/mlib-pps.lua index 8f7a3df10..ab56699b9 100644 --- a/tex/context/base/mlib-pps.lua +++ b/tex/context/base/mlib-pps.lua @@ -576,10 +576,23 @@ local do_safeguard = ";" -- end function metapost.textextsdata() - local top = metapost.getjobdata() - mp.tt_initialize(top and top.textexts) + local textexts = top.textexts + local collected = { } + for k, data in sortedhash(top.texdata) do -- sort is nicer in trace + local texorder = data.texorder + for n=1,#texorder do + local box = textexts[texorder[n]] + if box then + collected[n] = box + else + break + end + end + end + mp.tt_initialize(collected) end + metapost.intermediate = metapost.intermediate or { } metapost.intermediate.actions = metapost.intermediate.actions or { } diff --git a/tex/context/base/node-ltp.lua b/tex/context/base/node-ltp.lua index 3e77bc167..9529213fc 100644 --- a/tex/context/base/node-ltp.lua +++ b/tex/context/base/node-ltp.lua @@ -406,13 +406,13 @@ end -- resolvers -- -local whatsiters = { +local whatsitters = { get_width = { }, get_dimensions = { }, } -local get_whatsit_width = whatsiters.get_width -local get_whatsit_dimensions = whatsiters.get_dimensions +local get_whatsit_width = whatsitters.get_width +local get_whatsit_dimensions = whatsitters.get_dimensions local function get_width (n,dir) return getfield(n,"width") end local function get_dimensions(n,dir) return getfield(n,"width"), getfield(n,"height"), getfield(n,"depth") end @@ -423,6 +423,8 @@ get_whatsit_width[pdfrefxform_code ] = get_width get_whatsit_dimensions[pdfrefximage_code] = get_dimensions get_whatsit_dimensions[pdfrefxform_code ] = get_dimensions +nodes.whatsitters = whatsitters + -- expansion etc -- local function calculate_fraction(x,n,d,max_answer) @@ -3155,6 +3157,8 @@ end xpack_nodes = hpack -- comment this for old fashioned expansion (we need to fix float mess) +constructors.methods.hpack = hpack + local function common_message(hlist,line,str) write_nl("") if status.output_active then -- unset diff --git a/tex/context/base/page-lin.lua b/tex/context/base/page-lin.lua index 8c8f9d425..5a447c458 100644 --- a/tex/context/base/page-lin.lua +++ b/tex/context/base/page-lin.lua @@ -199,7 +199,7 @@ end implement { name = "setuplinenumbering", - actions = { boxed.setup, context }, + actions = boxed.setup, arguments = { "integer", { diff --git a/tex/context/base/page-lin.mkvi b/tex/context/base/page-lin.mkvi index 6204cb40c..dd13a98c3 100644 --- a/tex/context/base/page-lin.mkvi +++ b/tex/context/base/page-lin.mkvi @@ -73,33 +73,35 @@ \unexpanded\def\page_postprocessors_linenumbers_deepbox#tag{\page_lines_add_numbers_to_box{#tag}\plusone \plusone \plusone } \unexpanded\def\page_postprocessors_linenumbers_column #tag{\page_lines_add_numbers_to_box{#tag}\currentcolumn\nofcolumns\zerocount} -\def\page_lines_parameters_regular - {continue {\ifnum\c_page_lines_mode=\zerocount\v!yes\else\v!no\fi}% - start \linenumberingparameter\c!start - step \linenumberingparameter\c!step - method {\linenumberingparameter\c!method} - tag {\currentlinenumbering}} - -\def\page_lines_parameters_update - {continue {\ifnum\c_page_lines_mode=\zerocount\v!yes\else\v!no\fi}} - \def\page_lines_start_define {\setxvalue{\??linenumberinginstance\currentlinenumbering}% {\clf_registerlinenumbering - \page_lines_parameters_regular + continue {\ifnum\c_page_lines_mode=\zerocount\v!yes\else\v!no\fi}% + start \linenumberingparameter\c!start + step \linenumberingparameter\c!step + method {\linenumberingparameter\c!method}% + tag {\currentlinenumbering}% }} \def\page_lines_start_update {\clf_setuplinenumbering \csname\??linenumberinginstance\currentlinenumbering\endcsname - {\page_lines_parameters_update}% + {% + continue {\ifnum\c_page_lines_mode=\zerocount\v!yes\else\v!no\fi}% + }% \relax} \def\page_lines_setup {\ifcsname \??linenumberinginstance\currentlinenumbering\endcsname \clf_setuplinenumbering \csname\??linenumberinginstance\currentlinenumbering\endcsname - {\page_lines_parameters_regular}% + {% + continue {\ifnum\c_page_lines_mode=\zerocount\v!yes\else\v!no\fi}% + start \linenumberingparameter\c!start + step \linenumberingparameter\c!step + method {\linenumberingparameter\c!method}% + tag {\currentlinenumbering}% + }% \relax \fi} diff --git a/tex/context/base/publ-imp-apa.mkvi b/tex/context/base/publ-imp-apa.mkvi index 3052eab3c..648c82d8c 100644 --- a/tex/context/base/publ-imp-apa.mkvi +++ b/tex/context/base/publ-imp-apa.mkvi @@ -248,8 +248,8 @@ \definebtx [apa:cite:authoryear] [apa:cite:author] - [\c!left={(}, - \c!right={)}, + [\c!left={\removeunwantedspaces\pushpunctuation\btxspace(}, + \c!right={)\poppunctuation}, \c!inbetween={,\space}] \definebtx @@ -266,8 +266,8 @@ \definebtx [apa:cite:authornum] [apa:cite:author] - [\c!left={(}, - \c!right={)}, + [\c!left={\removeunwantedspaces\pushpunctuation\btxspace(}, + \c!right={)\poppunctuation}, \c!sorttype=authornum] \definebtx @@ -277,8 +277,8 @@ \definebtx [apa:cite:author:num] % todo [apa:cite:authornum] - [\c!left={[}, - \c!right={]}] + [\c!left={\removeunwantedspaces\pushpunctuation\btxspace[}, + \c!right={]\poppunctuation}] \definebtx [apa:cite:author:year] % todo @@ -318,8 +318,8 @@ \definebtx [apa:cite:tag] [apa:cite] - [\c!left={[}, - \c!right={]}] + [\c!left={\removeunwantedspaces\pushpunctuation\btxspace[}, + \c!right={]\poppunctuation}] \definebtx [apa:cite:key] diff --git a/tex/context/base/publ-imp-list.mkvi b/tex/context/base/publ-imp-list.mkvi index 8c8d9014f..4c238aa95 100644 --- a/tex/context/base/publ-imp-list.mkvi +++ b/tex/context/base/publ-imp-list.mkvi @@ -53,12 +53,12 @@ \startsetups \s!btx:\s!list:yes \btxstartstyleandcolor [\currentbtxspecification:list:yes] \btxusecommand[\currentbtxspecification:list:yes] { - %\btxparameter\c!left + \btxparameter\c!left \texdefinition {\s!btx:\s!list:inject} { \currentbtxfirst \btxparameter\c!stopper } - %\btxparameter\c!right + \btxparameter\c!right } \btxstopstyleandcolor \stopsetups diff --git a/tex/context/base/publ-ini.mkiv b/tex/context/base/publ-ini.mkiv index b24da5985..e26813280 100644 --- a/tex/context/base/publ-ini.mkiv +++ b/tex/context/base/publ-ini.mkiv @@ -847,7 +847,7 @@ % nothing \else \usebtxstyleandcolor\c!style\c!color % new, needed? - \btxparameter\c!left + % \btxparameter\c!left \ifconditional\c_publ_prefixed\btxlistprefixednumber\fi \clf_btxlistvariant % some can go {\currentbtxdataset}% @@ -856,7 +856,7 @@ {\currentbtxnumbering}% {\currentbtxnumber}% \relax - \btxparameter\c!right + % \btxparameter\c!right \fi\fi \endgroup} @@ -1418,12 +1418,12 @@ \def\currentbtxcitealternative{#1}% \setbtxparameterset\s!cite\currentbtxcitealternative \usebtxstyleandcolor\c!style\c!color - \btxparameter\c!left + % \btxparameter\c!left \relax} \unexpanded\def\btxstopsubcite {\relax - \btxparameter\c!right + % \btxparameter\c!right \endgroup} \unexpanded\def\btxstartciterendering[#1]% @@ -1431,12 +1431,12 @@ \edef\currentbtxcitealternative{#1}% \setbtxparameterset\s!cite\currentbtxcitealternative \usebtxstyleandcolor\c!style\c!color - \btxparameter\c!left + % \btxparameter\c!left \relax} \unexpanded\def\btxstopciterendering {\relax - \btxparameter\c!right + % \btxparameter\c!right \endgroup} \let\btxstartcite \begingroup diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index 35c093351..43c8d8898 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index c9dd4bb96..1ea18d299 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/context/base/strc-syn.lua b/tex/context/base/strc-syn.lua index 22a4ff9fd..5f3557a69 100644 --- a/tex/context/base/strc-syn.lua +++ b/tex/context/base/strc-syn.lua @@ -66,11 +66,18 @@ function synonyms.define(class,kind) end function synonyms.register(class,kind,spec) - local data = tobesaved[class] - local hash = data.hash - local tag = spec.definition.tag or "" + local data = tobesaved[class] + local hash = data.hash + local definition = spec.definition + local tag = definition.tag or "" data.metadata.kind = kind -- runtime, not saved in format (yet) if not hash[tag] then + if definition.used == nil then + definition.used = false + end + if definition.shown == nil then + definition.shown = false + end local entries = data.entries entries[#entries+1] = spec hash[tag] = spec @@ -81,7 +88,43 @@ function synonyms.registerused(class,tag) local data = tobesaved[class] local okay = data.hash[tag] if okay then - okay.definition.used = true + local definition = okay.definition + definition.used = true + definition.list = true + end +end + +function synonyms.registershown(class,tag) + local data = tobesaved[class] + local okay = data.hash[tag] + if okay then + local definition = okay.definition + definition.shown = true + definition.list = true + end +end + +function synonyms.isused(class,tag) + local data = tobesaved[class] + local okay = data.hash[tag] + return okay and okay.definition.used +end + +function synonyms.isshown(class,tag) + local data = tobesaved[class] + local okay = data.hash[tag] + return okay and okay.definition.shown +end + +function synonyms.resetused(class) + for tag, data in next, tobesaved[class].hash do + data.definition.used = false + end +end + +function synonyms.resetshown(class) + for tag, data in next, tobesaved[class].hash do + data.definition.shown = false end end @@ -91,6 +134,7 @@ function synonyms.synonym(class,tag) if okay then local definition = okay.definition definition.used = true + definition.list = true context(definition.synonym) end end @@ -100,26 +144,14 @@ function synonyms.meaning(class,tag) local okay = data.hash[tag] if okay then local definition = okay.definition - definition.used = true + definition.shown = true + definition.list = true context(definition.meaning) end end synonyms.compare = sorters.comparers.basic -- (a,b) -function synonyms.filter(data,options) - local result = { } - local entries = data.entries - local all = options and options.criterium == interfaces.variables.all - for i=1,#entries do - local entry = entries[i] - if all or entry.definition.used then - result[#result+1] = entry - end - end - data.result = result -end - function synonyms.filter(data,options) local result = { } local entries = data.entries @@ -130,8 +162,9 @@ function synonyms.filter(data,options) end else for i=1,#entries do - local entry = entries[i] - if entry.definition.used then + local entry = entries[i] + local definition = entry.definition + if definition.list then result[#result+1] = entry end end @@ -227,9 +260,24 @@ end -- todo: local higher up -implement { name = "registerusedsynonym", actions = synonyms.registerused, arguments = { "string", "string" } } -implement { name = "synonymmeaning", actions = synonyms.meaning, arguments = { "string", "string" } } -implement { name = "synonymname", actions = synonyms.synonym, arguments = { "string", "string" } } +implement { name = "registerusedsynonym", actions = synonyms.registerused, arguments = { "string", "string" } } +implement { name = "registershownsynonym", actions = synonyms.registershown, arguments = { "string", "string" } } +implement { name = "synonymmeaning", actions = synonyms.meaning, arguments = { "string", "string" } } +implement { name = "synonymname", actions = synonyms.synonym, arguments = { "string", "string" } } +implement { name = "resetusedsynonyms", actions = synonyms.resetused, arguments = "string" } +implement { name = "resetshownsynonyms", actions = synonyms.resetshown, arguments = "string" } + +implement { + name = "doifelsesynonymused", + actions = { synonyms.isused, commands.doifelse }, + arguments = { "string", "string" } +} + +implement { + name = "doifelsesynonymshown", + actions = { synonyms.isshown, commands.doifelse }, + arguments = { "string", "string" } +} implement { name = "registersynonym", diff --git a/tex/context/base/strc-syn.mkiv b/tex/context/base/strc-syn.mkiv index 22198aa7d..0c132a602 100644 --- a/tex/context/base/strc-syn.mkiv +++ b/tex/context/base/strc-syn.mkiv @@ -15,6 +15,93 @@ \registerctxluafile{strc-syn}{1.001} +%D Although we could nowadays build this on top of regular lists we keep this +%D more efficient variant around. Eventually we can add some options to lists +%D that also provide such functionality but at the cost of much more overhead. +%D +%D We show a usage of both synonyms and sorts, which are deep down variants of +%D so called simple lists. A definition looks like this: +%D +%D \startbuffer +%D \definesynonyms +%D [myabbreviation] +%D +%D \setupsynonyms +%D [myabbreviation] +%D [headstyle=bold, +%D headcolor=darkred, +%D synonymstyle=boldslanted, +%D synonymcolor=darkblue, +%D textstyle=slanted, +%D textcolor=darkgreen, +%D style=normal, +%D color=darkyellow] +%D +%D \definesorting +%D [mylogo] +%D +%D \setupsorting +%D [mylogo] +%D [style=bold, +%D color=darkmagenta] +%D \stopbuffer +%D +%D \typebuffer \getbuffer +%D +%D More complex definitions involves commands to call up meanings and such. The +%D use of the defined commands is as follows: \ +%D +%D \startbuffer +%D \myabbreviation [FIRST] {TheFirst} {The First Words} +%D \myabbreviation [SECOND] {TheSecond} {The Second Words} +%D \myabbreviation [THIRD] {TheThird} {The Third Words} +%D +%D \mylogo [FOURTH] {TheFourth} +%D \stopbuffer +%D +%D \typebuffer \getbuffer +%D +%D By default a synonym is just typeset and flagges as being used, so that in +%D a list it wil be shows with its meaning. You can however also expand the +%D meaning automatically at first use: +%D +%D \startbuffer +%D \setupsynonyms[myabbreviation][alternative=first] +%D +%D We have \FIRST, \SECOND\ and also \THIRD\ but no \FOURTH. +%D +%D We have \FIRST, \SECOND\ and also \THIRD\ but no \FOURTH. +%D \stopbuffer +%D +%D \typebuffer \getbuffer +%D +%D We can change the order, as demonstrated in: +%D +%D \startbuffer +%D \resetshownsynonyms[myabbreviation] +%D +%D \setupsynonyms[myabbreviation][alternative=last] +%D +%D We have \FIRST\ and \THIRD\ or \FOURTH. +%D +%D We have \FIRST\ and \THIRD\ or \FOURTH. +%D \stopbuffer +%D +%D \typebuffer \getbuffer +%D +%D A list is called up with: +%D +%D \startbuffer +%D \placelistofsynonyms[myabbreviation] +%D +%D \placelistofsorts[mylogo] +%D \stopbuffer +%D +%D \typebuffer \getbuffer +%D +%D The lists are constructions (like descriptions are) and can be set up +%D likewise. + % todo: add 'define only' option to descriptions, then add sorting (also based on key) % and call to definition -> replaces this module @@ -176,7 +263,7 @@ % \presetheadtext[#2=\Word{#2}]% changes the \if...argument % - \setvalue{\e!setup #2\e!endsetup}{\setupsynonym[#1]}% obsolete definition + \setvalue{\e!setup #2\e!endsetup}{\setupsynonyms[#1]}% obsolete definition \setvalue{\e!place \e!listof#2}{\placelistofsynonyms[#1]}% accepts extra argument \setvalue{\e!complete\e!listof#2}{\completelistofsynonyms[#1]}} @@ -195,8 +282,8 @@ % todo: error message \else \edef\currentsynonymexpansion{\simplelistparameter\c!expansion}% - \preprocessexpansion\currentsynonymexpansion\currentsynonymtext \currentsynonymcoding{#4}% - \preprocessexpansion\currentsynonymexpansion\currentsynonymmeaning\currentsynonymcoding{#5}% + \preprocessexpansion\currentsynonymexpansion\m_synonyms_text \currentsynonymcoding{#4}% + \preprocessexpansion\currentsynonymexpansion\m_synonyms_meaning\currentsynonymcoding{#5}% \clf_registersynonym {\currentsynonym}% {synonym}% @@ -210,9 +297,9 @@ }% definition {% tag {\currentsynonymtag}% - synonym {\currentsynonymtext}% - meaning {\currentsynonymmeaning}% - used false + synonym {\m_synonyms_text}% + meaning {\m_synonyms_meaning}% + % used false }% }% \relax @@ -226,25 +313,97 @@ \def\strc_synonyms_register[#1][#2]% {\clf_registerusedsynonym{#1}{#2}} +\unexpanded\def\currentsynonymname {\clf_synonymname {\currentsimplelist}{\currentsynonymtag}} +\unexpanded\def\currentsynonymmeaning {\clf_synonymmeaning {\currentsimplelist}{\currentsynonymtag}} +\unexpanded\def\doifelsecurrentsynonymused {\clf_doifelsesynonymused {\currentsimplelist}{\currentsynonymtag}} +\unexpanded\def\doifelsecurrentsynonymshown{\clf_doifelsesynonymshown{\currentsimplelist}{\currentsynonymtag}} +\unexpanded\def\resetusedsynonyms [#1]{\clf_resetusedsynonyms {#1}} +\unexpanded\def\resetshownsynonyms [#1]{\clf_resetshownsynonyms {#1}} + +\installcorenamespace{simplelistalternative} % specific ways of rendering a list +\installcorenamespace{simplelistrenderings} % a namespace for setups (rather local) + +\installcommandhandler \??simplelistalternative {simplelistalternative} \??simplelistalternative + +\setupsimplelist + [\v!synonym] + [\c!alternative=\v!normal] + \unexpanded\def\strc_synonyms_insert_meaning#1#2% name tag {\begingroup \def\currentsimplelist{#1}% - \usesimpleliststyleandcolor\c!textstyle\c!textcolor - \simplelistparameter\c!textcommand{\clf_synonymmeaning{#1}{#2}}% + \fastsetup{\??simplelistrenderings:\v!text}% \endgroup} \unexpanded\def\strc_synonyms_insert#1#2% name tag {\begingroup \edef\currentsimplelist{#1}% - \let\currentsynonym\currentsimplelist % for a while - \def\currentsynonymtag{#2}% - \dostarttaggedchained\t!synonym\currentsynonym\??simplelist - \dotagsynonym - \usesimpleliststyleandcolor\c!synonymstyle\c!synonymcolor - \simplelistparameter\c!synonymcommand{\clf_synonymname{#1}{#2}}% - \dostoptagged + \let \currentsynonym\currentsimplelist % for a while + \def \currentsynonymtag{#2}% + \edef\currentsimplelistalternative{\simplelistparameter\c!alternative}% + \fastsetup{\??simplelistrenderings:\v!synonym:\currentsimplelistalternative}% \normalexpanded{\endgroup\simplelistparameter\c!next}} +% \setupsimplelistalternative +% [\c!command=\strictsimplelistparameter\c!command] + +\definesimplelistalternative + [\v!normal] + [\c!inbetween=\space, + \c!left=(, + \c!right=)] + +\definesimplelistalternative + [\v!first] + [\v!normal] + +\definesimplelistalternative + [\v!last] + [\v!normal] + +\startsetups[\??simplelistrenderings::\v!synonym] + \begingroup + \dostarttaggedchained\t!synonym\currentsynonym\??simplelist + \dotagsynonym + \usesimpleliststyleandcolor\c!synonymstyle\c!synonymcolor + \simplelistparameter\c!synonymcommand{\currentsynonymname}% + \dostoptagged + \endgroup +\stopsetups + +\startsetups[\??simplelistrenderings::\v!text] + \begingroup + \usesimpleliststyleandcolor\c!textstyle\c!textcolor + \simplelistparameter\c!textcommand{\currentsynonymmeaning}% + \endgroup +\stopsetups + +\startsetups[\??simplelistrenderings:\v!synonym:\v!normal] + \fastsetup{\??simplelistrenderings::\v!synonym} +\stopsetups + +\startsetups[\??simplelistrenderings:\v!synonym:\v!first] + \fastsetup{\??simplelistrenderings::\v!synonym} + \doifelsecurrentsynonymshown \donothing { + \simplelistalternativeparameter\c!inbetween + \simplelistalternativeparameter\c!left + \fastsetup{\??simplelistrenderings::\v!text} + \simplelistalternativeparameter\c!right + } +\stopsetups + +\startsetups[\??simplelistrenderings:\v!synonym:\v!last] + \doifelsecurrentsynonymshown { + \fastsetup{\??simplelistrenderings::\v!synonym} + } { + \fastsetup{\??simplelistrenderings::\v!text} + \simplelistalternativeparameter\c!inbetween + \simplelistalternativeparameter\c!left + \fastsetup{\??simplelistrenderings::\v!synonym} + \simplelistalternativeparameter\c!right + } +\stopsetups + \unexpanded\def\placelistofsynonyms {\dodoubleempty\strc_synonyms_place_list} @@ -365,7 +524,7 @@ definition {% tag {\currentsortingtag}% synonym {\currentsortingtext}% - % used false + % used false }% }% \relax @@ -373,19 +532,38 @@ \fi \endgroup} +\unexpanded\def\currentsortingname {\clf_synonymname {\currentsimplelist}{\currentsortingtag}} +\unexpanded\def\doifelsecurrentsortingused {\clf_doifelsesynonymused {\currentsimplelist}{\currentsortingtag}} +\unexpanded\def\resetusedsortings [#1]{\clf_resetusedsynonyms {#1}} + +\setupsimplelist + [\v!sorting] + [\c!alternative=\v!normal] + \unexpanded\def\strc_sorting_insert#1#2% name tag {\begingroup % no kap currently, of .. we need to map cap onto WORD \edef\currentsorting{#1}% - \def\currentsortingtag{#2}% - \let\currentsimplelist\currentsorting - \dostarttaggedchained\t!sorting\currentsorting\??simplelist - \dotagsorting - \usesimpleliststyleandcolor\c!style\c!color - \clf_synonymname{#1}{#2}% - \dostoptagged + \def \currentsortingtag{#2}% + \let \currentsimplelist\currentsorting + \edef\currentsimplelistalternative{\simplelistparameter\c!alternative}% + \fastsetup{\??simplelistrenderings:\v!sorting:\currentsimplelistalternative}% \normalexpanded{\endgroup\simplelistparameter\c!next}} +\startsetups [\??simplelistrenderings:\v!sorting:\v!normal] + \fastsetup{\??simplelistrenderings::\v!sorting}% +\stopsetups + +\startsetups [\??simplelistrenderings::\v!sorting] + \begingroup + \dostarttaggedchained\t!sorting\currentsorting\??simplelist + \dotagsorting + \usesimpleliststyleandcolor\c!style\c!color + \currentsortingname + \dostoptagged + \endgroup +\stopsetups + \unexpanded\def\registersort {\dodoubleargument\strc_sorting_register} diff --git a/tex/context/base/tabl-xtb.lua b/tex/context/base/tabl-xtb.lua index c3076ca68..bddd627ad 100644 --- a/tex/context/base/tabl-xtb.lua +++ b/tex/context/base/tabl-xtb.lua @@ -673,6 +673,8 @@ function xtables.reflow_width() -- data.currentrow = 0 data.currentcolumn = 0 + -- +-- inspect(data) end function xtables.reflow_height() @@ -733,6 +735,7 @@ function xtables.reflow_height() end end -- +-- inspect(data) end local function showspans(data) diff --git a/tex/context/base/tabl-xtb.mkvi b/tex/context/base/tabl-xtb.mkvi index b5ab0a5dc..876abef8c 100644 --- a/tex/context/base/tabl-xtb.mkvi +++ b/tex/context/base/tabl-xtb.mkvi @@ -500,8 +500,16 @@ % Although this becomes kind of messy. It saves already time that we only check % for it when we have settings. -\def\tabl_x_set_hsize - {\hsize.25\maxdimen} % let's be reasonable +% \def\tabl_x_set_hsize +% {\hsize.25\maxdimen} % let's be reasonable + +% \def\tabl_x_set_hsize +% {\edef\p_width{\xtableparameter\c!width}% +% \ifx\p_width\empty +% \hsize.25\maxdimen % is this really needed +% \fi} + +\let\tabl_x_set_hsize\relax \unexpanded\def\tabl_x_start_cell_reflow_width_yes[#settings]% {\setbox\b_tabl_x\hbox\bgroup diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 7ab0c9be3..3b472bcb5 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 : 04/15/15 01:44:50 +-- merge date : 04/16/15 15:14:10 do -- begin closure to overcome local limits and interference @@ -2713,6 +2713,9 @@ if not modules then modules={} end modules ['l-math']={ license="see context related readme files" } local floor,sin,cos,tan=math.floor,math.sin,math.cos,math.tan +if not math.ceiling then + math.ceiling=math.ceil +end if not math.round then function math.round(x) return floor(x+0.5) end end -- cgit v1.2.3