diff options
Diffstat (limited to 'tex/context/modules')
-rw-r--r-- | tex/context/modules/common/s-abbreviations-mixed.mkiv | 28 | ||||
-rw-r--r-- | tex/context/modules/common/s-abbreviations-pseudocaps.mkiv | 30 | ||||
-rw-r--r-- | tex/context/modules/common/s-abbreviations-smallcaps.mkiv | 31 | ||||
-rw-r--r-- | tex/context/modules/common/s-abbreviations-words.mkiv | 28 | ||||
-rw-r--r-- | tex/context/modules/mkiv/s-abbreviations-extras.tex (renamed from tex/context/modules/common/s-abbreviations-extras.tex) | 0 | ||||
-rw-r--r-- | tex/context/modules/mkiv/s-abbreviations-logos.tex (renamed from tex/context/modules/common/s-abbreviations-logos.tex) | 0 | ||||
-rw-r--r-- | tex/context/modules/mkiv/s-obsolete-tokens.mkiv (renamed from tex/context/modules/common/s-obsolete-tokens.mkiv) | 0 | ||||
-rw-r--r-- | tex/context/modules/mkiv/s-physics-units.lua | 86 | ||||
-rw-r--r-- | tex/context/modules/mkiv/s-version.mkiv | 123 | ||||
-rw-r--r-- | tex/context/modules/mkxl/s-system-tokens.lmt | 247 | ||||
-rw-r--r-- | tex/context/modules/mkxl/s-system-tokens.mkxl | 47 |
11 files changed, 458 insertions, 162 deletions
diff --git a/tex/context/modules/common/s-abbreviations-mixed.mkiv b/tex/context/modules/common/s-abbreviations-mixed.mkiv deleted file mode 100644 index d5294fd56..000000000 --- a/tex/context/modules/common/s-abbreviations-mixed.mkiv +++ /dev/null @@ -1,28 +0,0 @@ -%D \module -%D [ file=s-abbreviations-mixed, % was: s-abr-04 -%D version=1996.01.01, -%D title=\CONTEXT\ Style File, -%D subtitle=General Abbreviations Mixed, -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -\unprotect - -\setupsorting - [logo] - [\c!style=\font_style_pseudoMixedCapped] - -\protect - -\startmodule[abbreviations-mixed] - -\usemodule[abbreviations-logos] -\usemodule[abbreviations-extras] - -\stopmodule - diff --git a/tex/context/modules/common/s-abbreviations-pseudocaps.mkiv b/tex/context/modules/common/s-abbreviations-pseudocaps.mkiv deleted file mode 100644 index fa8606a7b..000000000 --- a/tex/context/modules/common/s-abbreviations-pseudocaps.mkiv +++ /dev/null @@ -1,30 +0,0 @@ -%D \module -%D [ file= s-abbreviations-pseudocaps, % was: s-abr-01 -%D version=1996.01.01, -%D title=\CONTEXT\ Style File, -%D subtitle=General Abbreviations Pseudocaps, -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -\unprotect - -\setupsorting - [logo] - [\c!style=\v!capital] - -\setupcapitals - [\c!title=\v!no] - -\protect - -\startmodule[abbreviations-pseudocaps] - -\usemodule[abbreviations-logos] -\usemodule[abbreviations-extras] - -\stopmodule diff --git a/tex/context/modules/common/s-abbreviations-smallcaps.mkiv b/tex/context/modules/common/s-abbreviations-smallcaps.mkiv deleted file mode 100644 index 2ce86ca33..000000000 --- a/tex/context/modules/common/s-abbreviations-smallcaps.mkiv +++ /dev/null @@ -1,31 +0,0 @@ -%D \module -%D [ file= s-abbreviations-smallcaps, % was: s-abr-02 -%D version=1996.01.01, -%D title=\CONTEXT\ Style File, -%D subtitle=General Abbreviations Smallcaps, -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -\unprotect - -\setupsorting - [logo] - [\c!style=\v!smallcaps] - -\setupcapitals - [\c!title=\v!no] - -\protect - -\startmodule[abbreviations-smallcaps] - -\usemodule[abbreviations-logos] -\usemodule[abbreviations-extras] - -\stopmodule - diff --git a/tex/context/modules/common/s-abbreviations-words.mkiv b/tex/context/modules/common/s-abbreviations-words.mkiv deleted file mode 100644 index 2b7d7cedc..000000000 --- a/tex/context/modules/common/s-abbreviations-words.mkiv +++ /dev/null @@ -1,28 +0,0 @@ -%D \module -%D [ file= s-abbreviations-words, % was: s-abr-32 -%D version=1998.08.10, -%D title=\CONTEXT\ Style File, -%D subtitle=General Abbreviations Words, -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -\unprotect - -\setupsorting - [logo] - [\c!style=\v!WORD] - -\protect - -\startmodule[abbreviations-words] - -\usemodule[abbreviations-logos] -\usemodule[abbreviations-extras] - -\stopmodule - diff --git a/tex/context/modules/common/s-abbreviations-extras.tex b/tex/context/modules/mkiv/s-abbreviations-extras.tex index 7ee6e1553..7ee6e1553 100644 --- a/tex/context/modules/common/s-abbreviations-extras.tex +++ b/tex/context/modules/mkiv/s-abbreviations-extras.tex diff --git a/tex/context/modules/common/s-abbreviations-logos.tex b/tex/context/modules/mkiv/s-abbreviations-logos.tex index dfac57f0a..dfac57f0a 100644 --- a/tex/context/modules/common/s-abbreviations-logos.tex +++ b/tex/context/modules/mkiv/s-abbreviations-logos.tex diff --git a/tex/context/modules/common/s-obsolete-tokens.mkiv b/tex/context/modules/mkiv/s-obsolete-tokens.mkiv index 117282a60..117282a60 100644 --- a/tex/context/modules/common/s-obsolete-tokens.mkiv +++ b/tex/context/modules/mkiv/s-obsolete-tokens.mkiv diff --git a/tex/context/modules/mkiv/s-physics-units.lua b/tex/context/modules/mkiv/s-physics-units.lua new file mode 100644 index 000000000..008320858 --- /dev/null +++ b/tex/context/modules/mkiv/s-physics-units.lua @@ -0,0 +1,86 @@ +if not modules then modules = { } end modules ['s-physics-units'] = { + version = 1.001, + comment = "companion to s-physics-units.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +moduledata.physics = moduledata.physics or { } +moduledata.physics.units = moduledata.physics.units or { } + +local tables = physics.units.tables +local units = tables.units +local shortcuts = tables.shortcuts + +local HL = context.HL +local NC = context.NC +local NR = context.NR + +local function typeset(list,followup,name,category) + if list then + if followup then + context.TB() + end + if category then + HL() + NC() + context.rlap(category .. ":" .. name) + NC() + NC() + NR() + HL() + end + for k, v in table.sortedhash(list) do + NC() + context(k) + NC() + if isunit then + context(v) + else + context.type(v) + end + NC() + if name == "units" or name == "symbols" or name == "packaged" then + context.unittext(v) + elseif name == "prefixes" then + context.prefixtext(v) + elseif name == "operators" then + context.operatortext(v) + elseif name == "suffixes" then + context.suffixtext(v) + end + NC() + NR() + end + if category and name then + HL() + end + end +end + +function moduledata.physics.units.showlist(name) + specification = interfaces.checkedspecification(specification) + context.starttabulate { "|lT|l|c|" } + local name = specification.name + if name and name ~= "" then + local first, second = string.match(name,"(.-):(.-)") -- [units|shortcuts]:[units|...] + if first then + typeset(tables[first] and tables[first][second],false) + else + typeset(units[name],false) + typeset(shortcuts[name],true) + end + else + local done = false + for what, list in table.sortedhash(units) do + typeset(list,done,what,"units") + done = true + end + for what, list in table.sortedhash(shortcuts) do + typeset(list,done,what,"shortcuts") + done = true + end + end + context.stoptabulate() +end diff --git a/tex/context/modules/mkiv/s-version.mkiv b/tex/context/modules/mkiv/s-version.mkiv new file mode 100644 index 000000000..63005aa33 --- /dev/null +++ b/tex/context/modules/mkiv/s-version.mkiv @@ -0,0 +1,123 @@ +%D \module +%D [ file=s-version, +%D version=2011.07.28, +%D title=\CONTEXT\ Version Pictogram, +%D subtitle=Basics, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D This is an oldie that we use to generate a pictogram that reflects the current +%D version. + +\startMPextensions +vardef context_version(expr variant, mark, year, month, day, hours, minutes, seconds) = + + image ( + + interim overloadmode := 0; + + save angle, min, max, mk, yr, mo, da, ho, mi, se, max_mk, max_yr, max_mo, max_da, max_ho, max_mi, max_se ; + + numeric angle, delta ; pair min, max ; angle := 360/7.25 ; delta := (360-7*angle)/7 ; min := (0,10) ; max := (0,100) ; + + numeric mk, max_mk ; max_mk := 8 ; mk := if (mark <= 0) or (mark > max_mk) : max_mk else : mark fi ; + numeric yr, max_yr ; max_yr := 2050 ; yr := if (year <= 2000) or (year > max_yr) : max_yr else : year fi ; + numeric mo, max_mo ; max_mo := 12 ; mo := if (month <= 0) or (month > max_mo) : max_mo else : month fi ; + numeric da, max_da ; max_da := 31 ; da := if (day <= 0) or (day > max_da) : max_da else : day fi ; + numeric ho, max_ho ; max_ho := 24 ; ho := if (hours <= 0) or (hours > max_ho) : max_ho else : hours fi ; + numeric mi, max_mi ; max_mi := 60 ; mi := if (minutes <= 0) or (minutes > max_mi) : max_mi else : minutes fi ; + numeric se, max_se ; max_se := 60 ; se := if (seconds <= 0) or (seconds > max_se) : max_se else : seconds fi ; + + max_da := if (mo = 2) : 28 elseif (mo = 4) or (mo = 6) or (mo = 9) or (mo = 11) : 30 else : 31 fi ; + + if da > max_da : da := max_da fi ; yr := yr - 2000 ; max_yr := max_yr - 2000 ; + + if (variant = 2) or (variant = 3) : + fill fullcircle scaled 205 withcolor .7white ; + fi ; + + color colorant[] ; + + vardef do_context_version(expr i, amount) = + fill (min/2 rotated (-angle/2) -- max { dir -40 } .. max rotated -angle -- cycle) rotated -(i*(angle+delta)) withcolor .3colorant[i] ; + fill (min rotated (-angle/2) -- max { dir -(45+45*amount) } .. max rotated -angle -- cycle) rotated -(i*(angle+delta)) withcolor .7colorant[i] ; + enddef ; + + color orange ; orange := (1,.62,.06) ; % .5white + + colorant[0] := red ; colorant[1] := green ; colorant[2] := blue ; colorant[3] := orange ; + colorant[4] := cyan ; colorant[5] := magenta ; colorant[6] := yellow ; + + do_context_version(0, (yr-1)/max_yr) ; + do_context_version(1, (mo-1)/max_mo) ; + do_context_version(2, (da-1)/max_da) ; + do_context_version(3, (mk-1)/max_mk) ; + do_context_version(4, (ho-1)/max_ho) ; + do_context_version(5, (mi-1)/max_mi) ; + do_context_version(6, (se-1)/max_se) ; + + currentpicture := currentpicture slanted .15 ; + + if (variant = 3) : + setbounds currentpicture to boundingbox currentpicture enlarged 10 ; + addbackground withcolor .3white ; + setbounds currentpicture to boundingbox currentpicture enlarged -5 ; + fi ; + + ) + +enddef ; + +% draw context_version(4,2011,07,28,14,50,30) ; +% draw context_version(4,01,01,01,01,01,01) ; +% draw context_version(4,99,12,31,24,60,60) ; + +\stopMPextensions + +\startluacode + moduledata.versions = moduledata.versions or { } + + function moduledata.versions.drawcontextversion(variant, mark, year, month, day, hours, minutes, seconds) + if not variant then + variant = 3 + end + if not mark then + mark = 4 + year, month, day, hours, minutes, seconds = string.match(environment.version,"(....).(..).(..) (..).(..)") + seconds = 30 + end + context.startMPcode() + context("draw context_version(%s,%s,%s,%s,%s,%s,%s,%s) ;", + variant or 1, + mark or 4, + year or os.date("%y"), + month or os.date("%m"), + day or os.date("%d"), + hours or os.date("%H"), + minutes or os.date("%M"), + seconds or os.date("%S") + ) + context.stopMPcode() + end +\stopluacode + +\continueifinputfile{s-version.mkiv} + +\starttext + +\startluacode + context.startTEXpage() + moduledata.versions.drawcontextversion() + context.stopTEXpage() +\stopluacode + +\stoptext + +% d:\imagemagick\convert.exe -geometry 256x256 s-version.pdf context-version.png +% d:\imagemagick\convert.exe -geometry 72x72 s-version.pdf context-version.ico +% d:\imagemagick\convert.exe -geometry 128x128 s-version.pdf context-version.icns diff --git a/tex/context/modules/mkxl/s-system-tokens.lmt b/tex/context/modules/mkxl/s-system-tokens.lmt new file mode 100644 index 000000000..39258d637 --- /dev/null +++ b/tex/context/modules/mkxl/s-system-tokens.lmt @@ -0,0 +1,247 @@ +if not modules then modules = { } end modules['s-system-tokens'] = { + version = 1.001, + comment = "companion to s-system-tokens.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local context = context +local ctx_NC = context.NC +local ctx_BC = context.BC +local ctx_NR = context.NR +local ctx_FL = context.FL +local ctx_ML = context.ML +local ctx_LL = context.LL +local gsub = string.gsub +local find = string.find +local concat = table.concat + +moduledata.system = moduledata.system or { } +moduledata.system.tokens = moduledata.system.tokens or { } + +local getrange = token.get_range +local getcmdchrcs = token.get_cmdchrcs +local whatever = { [1] = true, [4] = true, [8] = true } + +local collected = nil -- at some point we might have this one preloaded + +function moduledata.system.tokens.collect() + + if not collected then + + local allcommands = tokens.commands + local primitives = tex.primitives() + collected = { } + + for i=0,#allcommands do + local codes = { } + local kind, min, max, fixedvalue = getrange(i) + if min and whatever[kind] and max >= 0 and max <= 256 then + for i=min,max do + codes[i] = false + end + end + collected[i] = codes + collected[allcommands[i]] = codes + end + + for i=1,#primitives do + local prm = primitives[i] + local cmd, chr = getcmdchrcs("normal"..prm) + local codes = collected[cmd] + if codes and codes[chr] == false then + codes[chr] = prm + codes[prm] = chr + else + -- print(cmd,chr) + end + end + + collected.undefined_cs = nil + + -- table.save("whatever.lua",collected) + -- local p = token.getprimitives() + -- table.sort(p,function(a,b) if a[1] == b[1] then return a[2] < b[2] else return a[1] < b[1] end end) + -- table.save("moreever.lua",p) + + -- local p = token.getprimitives() + -- for i=1,#p do + -- local t = p[i] + -- pi[i] = { t[1], t[2], t[3], getrange(t[1]) } + -- end + + -- inspect(collected) + + end + + return collected + +end + +function moduledata.system.tokens.showlist() + + local l = tokens.commands + local t = moduledata.system.tokens.collect() + + context.starttabulate { "|cT|rT|lT|rT|rT|pTA{flushleft,verytolerant,stretch}|" } + ctx_FL() + ctx_BC() context("") + ctx_BC() context("cmd") + ctx_BC() context("name") + ctx_BC() context("min") + ctx_BC() context("max") + ctx_BC() context("default or subcommands") + ctx_BC() ctx_NR() + ctx_ML() + for i=0,#l do + local kind, min, max, fixedvalue = getrange(i) + local what = whatever[kind] + ctx_NC() context(kind) + ctx_NC() context(i) + ctx_NC() context(l[i]) + ctx_NC() if min then if what or min == 0 then context(min) else context("-0x%X",-min) end end + ctx_NC() if max then if what or max == 0 then context(max) else context("0x%X",max) end end + ctx_NC() + if min and what and max >= 0 and max <= 256 then + local l = { } + local c = t[i] + if c then + for j=min, max do + local s = c[j] + if s == " " then + s = "<space>" + elseif not s then + s = "<unavailable>" + end + l[#l+1] = j .. "=" .. s + end + if (#l > 0) then + context(table.concat(l," ")) + elseif fixedvalue ~= 0 then + context("0x%X",fixedvalue) + end + else + print("weird") + end + elseif fixedvalue and fixedvalue ~= 0 then + context("0x%X",fixedvalue) + end + ctx_NC() ctx_NR() + end + ctx_LL() + context.stoptabulate() + +end + +function moduledata.system.tokens.table(t) + local t = t or token.peek_next() -- local t = token.scan_next() token.put_back(t) + local n = "" + local w = "" + local c = t.cmdname + if c == "left_brace" then + w = "given token list" + t = token.scan_toks(false) + elseif c == "register_toks" then + token.scan_next() + w = "token register" + n = t.csname or t.index + t = tex.gettoks(n,true) + elseif c == "internal_toks" then + token.scan_next() + w = "internal token variable" + n = t.csname or t.index + t = tex.gettoks(n,true) + else + n = token.scan_csname() + local r = { } + local m = token.get_meaning(n,true) + if t.frozen then r[#r+1] = "frozen" end + if t.permanent then r[#r+1] = "permanent" end + if t.immutable then r[#r+1] = "immutable" end + if t.primitive then r[#r+1] = "primitive" end + if t.mutable then r[#r+1] = "mutable" end + if t.noaligned then r[#r+1] = "noaligned" end + if t.instance then r[#r+1] = "instance" end + if t.tolerant then r[#r+1] = "tolerant" end + if t.protected then r[#r+1] = "protected" end + r[#r+1] = "control sequence" + if type(m) == "table" then + t = m + else + t = { t } + end + w = concat(r, " ") + end + if type(t) == "table" then + context.starttabulate { "|l|r|r|l|c|l|l|" } + ctx_FL() + ctx_NC() context.formatted.rlap("\\bold %s: %s",w,n) + ctx_NC() ctx_NC() ctx_NC() ctx_NC() ctx_NC() ctx_NC() ctx_NC() + ctx_NC() ctx_NR() + ctx_ML() + for i=1,#t do + local ti = t[i] + local cs = ti.csname + local id = ti.id + local ix = ti.index + local cd = ti.command + local cn = gsub(ti.cmdname,"_"," ") + ctx_NC() context(id) + ctx_NC() context(cd) + ctx_NC() context("%3i",ix) + ctx_NC() context(cn) + if cs then + ctx_NC() + ctx_NC() + ctx_NC() context(cs) + ctx_NC() ctx_NR() + elseif cn == "letter" or cn == "other char" then + ctx_NC() context.char(ix) + ctx_NC() context("%U",ix) + ctx_NC() + ctx_NC() ctx_NR() + elseif cn == "match" then + ctx_NC() + ctx_NC() + if ix == 32 then context("optional spacer") -- space + elseif ix == 43 then context("keep braces") -- "+" + elseif ix == 45 then context("thrash") -- "-" + elseif ix == 61 then context("mandate braces") -- "=" + elseif ix == 94 then context("keep spaces") -- "^" + elseif ix == 95 then context("keep mandate braces") -- "_" + else context("argument %c",ix) + end + ctx_NC() + ctx_NC() ctx_NR() + else + ctx_NC() + ctx_NC() + ctx_NC() + ctx_NC() ctx_NR() + if cn == "end match" then + context.ML() + end + end + end + context.LL() + context.stoptabulate() + else + context.starttabulate { "|l|" } + ctx_FL() + ctx_NC() context("%s: %s",w,n) + ctx_NC() ctx_NR() + ctx_ML() + ctx_NC() context("<no tokens>") + ctx_NC() ctx_NR() + ctx_LL() + context.stoptabulate() + end +end + +interfaces.implement { + name = "luatokentable", + public = true, + protected = true, + actions = moduledata.system.tokens.table, +} diff --git a/tex/context/modules/mkxl/s-system-tokens.mkxl b/tex/context/modules/mkxl/s-system-tokens.mkxl index b83a4f47b..584fcf82f 100644 --- a/tex/context/modules/mkxl/s-system-tokens.mkxl +++ b/tex/context/modules/mkxl/s-system-tokens.mkxl @@ -31,54 +31,11 @@ \starttext - \showsystemtokens - - Some tokens cannot be created yet because they are more complex but eventually the creator will - deal with them. The indices are sometimes the same as internal but in most cases nicely start - at zero. When they start at another value, then there is an internal token or state that is not - user accessible. You always need to use symbolic constants as the numbers can change. - - The first column is a classifier (which is experimental and categories might change when we feel - the need). - - \startcolumns[n=5] - \starttabulate[|T||] - \NC 0 \NC unused \NC \NR - \NC 1 \NC regular \NC \NR - \NC 2 \NC character \NC \NR - \NC 3 \NC register \NC \NR - \NC 4 \NC internal \NC \NR - \NC 5 \NC reference \NC \NR - \NC 6 \NC data \NC \NR - \NC 7 \NC token \NC \NR - \NC 8 \NC node \NC \NR - \stoptabulate - \stopcolumns - - \page - - Here is a typeset table of \type {\startframed} using \type {\luatokentable\startframed}: - \luatokentable\startframed - which calls \type {\pack_framed_start_framed} where \type {\luatokentable\pack_framed_start_framed} gives: - - - \unprotect - \luatokentable\pack_framed_start_framed - \protect - - So you can guess what generates this: - - \unprotect - \luatokentable\pack_framed_start_framed_nop - \protect - - And this: + \page - \unprotect - \luatokentable\pack_framed_start_framed_yes - \protect + \showsystemtokens \stoptext |