diff options
Diffstat (limited to 'tex/context/base/strc-ref.lua')
-rw-r--r-- | tex/context/base/strc-ref.lua | 127 |
1 files changed, 24 insertions, 103 deletions
diff --git a/tex/context/base/strc-ref.lua b/tex/context/base/strc-ref.lua index ab2d366cc..092babfae 100644 --- a/tex/context/base/strc-ref.lua +++ b/tex/context/base/strc-ref.lua @@ -29,12 +29,6 @@ local trace_analyzing = false trackers.register("structures.referencing.anal local trace_identifying = false trackers.register("structures.referencing.identifying", function(v) trace_identifying = v end) local trace_importing = false trackers.register("structures.referencing.importing", function(v) trace_importing = v end) -local check_duplicates = true - -directives.register("structures.referencing.checkduplicates", function(v) - check_duplicates = v -end) - local report_references = logs.reporter("references") local report_unknown = logs.reporter("unknown") local report_identifying = logs.reporter("references","identifying") @@ -44,12 +38,6 @@ local variables = interfaces.variables local constants = interfaces.constants local context = context -local v_default = variables.default -local v_url = variables.url -local v_file = variables.file -local v_unknown = variables.unknown -local v_yes = variables.yes - local texcount = tex.count local texconditionals = tex.conditionals @@ -249,13 +237,11 @@ references.setnextorder = setnextorder function references.setnextinternal(kind,name) setnextorder(kind,name) -- always incremented with internal - local n = texcount.locationcount + 1 - texsetcount("global","locationcount",n) - return n + texsetcount("global","locationcount",texcount.locationcount + 1) end function references.currentorder(kind,name) - return orders[kind] and orders[kind][name] or lastorder + context(orders[kind] and orders[kind][name] or lastorder) end local function setcomponent(data) @@ -271,12 +257,6 @@ local function setcomponent(data) -- but for the moment we do it here (experiment) end -commands.setnextinternalreference = references.setnextinternal - -function commands.currentreferenceorder(kind,name) - context(references.currentorder(kind,name)) -end - references.setcomponent = setcomponent function references.set(kind,prefix,tag,data) @@ -289,7 +269,7 @@ function references.set(kind,prefix,tag,data) local n = 0 for ref in gmatch(tag,"[^,]+") do if ref ~= "" then - if check_duplicates and pd[ref] then + if pd[ref] then if prefix and prefix ~= "" then report_references("redundant reference: %q in namespace %q",ref,prefix) else @@ -312,8 +292,6 @@ function references.enhance(prefix,tag) end end -commands.enhancereference = references.enhance - -- -- -- related to strc-ini.lua -- -- -- references.resolvers = references.resolvers or { } @@ -422,9 +400,7 @@ function references.urls.define(name,url,file,description) end end -local pushcatcodes = context.pushcatcodes -local popcatcodes = context.popcatcodes -local txtcatcodes = catcodes.numbers.txtcatcodes -- or just use "txtcatcodes" +local pushcatcodes, popcatcodes, txtcatcodes = context.pushcatcodes, context.popcatcodes, tex.txtcatcodes function references.urls.get(name) local u = urls[name] @@ -550,7 +526,9 @@ end function references.programs.get(name) local f = programs[name] - return f and f[1] + if f then + context(f[1]) + end end function references.checkedprogram(whatever) -- return whatever if not resolved @@ -564,19 +542,10 @@ function references.checkedprogram(whatever) -- return whatever if not resolved end end -commands.defineprogram = references.programs.define - -function commands.getprogram(name) - local f = programs[name] - if f then - context(f[1]) - end -end - -- shared by urls and files function references.whatfrom(name) - context((urls[name] and v_url) or (files[name] and v_file) or v_unknown) + context((urls[name] and variables.url) or (files[name] and variables.file) or variables.unknown) end function references.from(name) @@ -584,31 +553,6 @@ function references.from(name) if u then local url, file, description = u[1], u[2], u[3] if description ~= "" then - return description - -- ok - elseif file and file ~= "" then - return url .. "/" .. file - else - return url - end - else - local f = files[name] - if f then - local file, description = f[1], f[2] - if description ~= "" then - return description - else - return file - end - end - end -end - -function commands.from(name) - local u = urls[name] - if u then - local url, file, description = u[1], u[2], u[3] - if description ~= "" then context.dofromurldescription(description) -- ok elseif file and file ~= "" then @@ -634,6 +578,10 @@ function references.define(prefix,reference,list) d[reference] = { "defined", list } end +--~ function references.registerspecial(name,action,...) +--~ specials[name] = { action, ... } +--~ end + function references.reset(prefix,reference) local d = defined[prefix] if d then @@ -641,9 +589,6 @@ function references.reset(prefix,reference) end end -commands.definereference = references.define -commands.resetreference = references.reset - -- \primaryreferencefoundaction -- \secondaryreferencefoundaction -- \referenceunknownaction @@ -754,8 +699,6 @@ function references.expandcurrent() -- todo: two booleans: o_has_tex& a_has_tex end end -commands.expandcurrentreference = references.expandcurrent -- for the moment the same - local externals = { } -- we have prefixes but also components: @@ -1571,7 +1514,7 @@ references.identify = identify local unknowns, nofunknowns = { }, 0 -function references.valid(prefix,reference,highlight,newwindow,layer) +function references.doifelse(prefix,reference,highlight,newwindow,layer) local set, bug = identify(prefix,reference) local unknown = bug or #set == 0 if unknown then @@ -1590,11 +1533,7 @@ function references.valid(prefix,reference,highlight,newwindow,layer) currentreference = set[1] end -- we can do the expansion here which saves a call - return not unknown -end - -function commands.doifelsereference(prefix,reference,highlight,newwindow,layer) - commands.doifelse(references.valid(prefix,reference,highlight,newwindow,layer)) + commands.doifelse(not unknown) end function references.reportproblems() -- might become local @@ -1624,7 +1563,7 @@ function references.setinnermethod(m) if m then if m == "page" or m == "mixed" or m == "names" then innermethod = m - elseif m == true or m == v_yes then + elseif m == true or m == variables.yes then innermethod = "page" end end @@ -1673,13 +1612,13 @@ function references.setinternalreference(prefix,tag,internal,view) -- needs chec end function references.setandgetattribute(kind,prefix,tag,data,view) -- maybe do internal automatically here - local attr = references.set(kind,prefix,tag,data) and references.setinternalreference(prefix,tag,nil,view) or unsetvalue - texcount.lastdestinationattribute = attr - return attr + if references.set(kind,prefix,tag,data) then + texcount.lastdestinationattribute = references.setinternalreference(prefix,tag,nil,view) or unsetvalue + else + texcount.lastdestinationattribute = unsetvalue + end end -commands.setreferenceattribute = references.setandgetattribute - function references.getinternalreference(n) -- n points into list (todo: registers) local l = lists.collected[n] return l and l.references.internal or n @@ -1698,11 +1637,7 @@ end function references.getcurrentmetadata(tag) local data = currentreference and currentreference.i - return data and data.metadata and data.metadata[tag] -end - -function commands.getcurrentreferencemetadata(tag) - local data = references.getcurrentmetadata(tag) + data = data and data.metadata and data.metadata[tag] if data then context(data) end @@ -1715,15 +1650,8 @@ end references.currentmetadata = currentmetadata -local function getcurrentprefixspec(default) - -- todo: message - return currentmetadata("kind") or "?", currentmetadata("name") or "?", default or "?" -end - -references.getcurrentprefixspec = getcurrentprefixspec - -function commands.getcurrentprefixspec(default) - context.getreferencestructureprefix(getcurrentprefixspec(default)) +function references.getcurrentprefixspec(default) -- todo: message + context.getreferencestructureprefix(currentmetadata("kind") or "?",currentmetadata("name") or "?",default or "?") end function references.filter(name,...) -- number page title ... @@ -1754,10 +1682,6 @@ function references.filter(name,...) -- number page title ... end end -function references.filterdefault() - return references.filter("default",getcurrentprefixspec(v_default)) -end - filters.generic = { } function filters.generic.title(data) @@ -2125,13 +2049,10 @@ end -- needs a better split ^^^ -commands.filterreference = references.filter -commands.filterdefaultreference = references.filterdefault +commands.filterreference = references.filter -- done differently now: function references.export(usedname) end function references.import(usedname) end function references.load (usedname) end - -commands.exportreferences = references.export |