diff options
author | Karl Berry <karl@freefriends.org> | 2016-04-22 22:14:39 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-04-22 22:14:39 +0000 |
commit | fc4466b32ed330a956ac603b00fd145524cff49a (patch) | |
tree | 2c50e2b8de13aa9233b2c76dffe201558f169e86 /Master/texmf-dist/tex/context/base/syst-lua.lua | |
parent | 50e2368597d5f6fe2057195d0ae6a9f2044923e4 (diff) |
context (22apr16)
git-svn-id: svn://tug.org/texlive/trunk@40691 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/syst-lua.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/syst-lua.lua | 243 |
1 files changed, 0 insertions, 243 deletions
diff --git a/Master/texmf-dist/tex/context/base/syst-lua.lua b/Master/texmf-dist/tex/context/base/syst-lua.lua deleted file mode 100644 index a6665f4104a..00000000000 --- a/Master/texmf-dist/tex/context/base/syst-lua.lua +++ /dev/null @@ -1,243 +0,0 @@ -if not modules then modules = { } end modules ['syst-lua'] = { - version = 1.001, - comment = "companion to syst-lua.mkiv", - author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", - copyright = "PRAGMA ADE / ConTeXt Development Team", - license = "see context related readme files" -} - -local find, match = string.find, string.match -local tonumber = tonumber -local S, C, P, lpegmatch, lpegtsplitat = lpeg.S, lpeg.C, lpeg.P, lpeg.match, lpeg.tsplitat - - -commands = commands or { } -local commands = commands - -local implement = interfaces.implement - -local two_strings = interfaces.strings[2] - -local context = context -local csprint = context.sprint - -local prtcatcodes = tex.prtcatcodes - -implement { -- will b eoverloaded later - name = "writestatus", - arguments = two_strings, - actions = logs.status, -} - -local ctx_firstoftwoarguments = context.firstoftwoarguments -- context.constructcsonly("firstoftwoarguments" ) -local ctx_secondoftwoarguments = context.secondoftwoarguments -- context.constructcsonly("secondoftwoarguments") -local ctx_firstofoneargument = context.firstofoneargument -- context.constructcsonly("firstofoneargument" ) -local ctx_gobbleoneargument = context.gobbleoneargument -- context.constructcsonly("gobbleoneargument" ) - --- contextsprint(prtcatcodes,[[\ui_fo]]) -- ctx_firstofonearguments --- contextsprint(prtcatcodes,[[\ui_go]]) -- ctx_gobbleonearguments --- contextsprint(prtcatcodes,[[\ui_ft]]) -- ctx_firstoftwoarguments --- contextsprint(prtcatcodes,[[\ui_st]]) -- ctx_secondoftwoarguments - -function commands.doifelse(b) - if b then - ctx_firstoftwoarguments() --- csprint(prtcatcodes,[[\ui_ft]]) -- ctx_firstoftwoarguments - else - ctx_secondoftwoarguments() --- csprint(prtcatcodes,[[\ui_st]]) -- ctx_secondoftwoarguments - end -end - -function commands.doifelsesomething(b) - if b and b ~= "" then - ctx_firstoftwoarguments() --- csprint(prtcatcodes,[[\ui_ft]]) -- ctx_firstoftwoarguments - else - ctx_secondoftwoarguments() --- csprint(prtcatcodes,[[\ui_st]]) -- ctx_secondoftwoarguments - end -end - -function commands.doif(b) - if b then - ctx_firstofoneargument() --- context.__flushdirect(prtcatcodes,[[\ui_fo]]) -- ctx_firstofonearguments - else - ctx_gobbleoneargument() --- context.__flushdirect(prtcatcodes,[[\ui_go]]) -- ctx_gobbleonearguments - end -end - -function commands.doifsomething(b) - if b and b ~= "" then - ctx_firstofoneargument() --- context.__flushdirect(prtcatcodes,[[\ui_fo]]) -- ctx_firstofonearguments - else - ctx_gobbleoneargument() --- context.__flushdirect(prtcatcodes,[[\ui_go]]) -- ctx_gobbleonearguments - end -end - -function commands.doifnot(b) - if b then - ctx_gobbleoneargument() --- csprint(prtcatcodes,[[\ui_go]]) -- ctx_gobbleonearguments - else - ctx_firstofoneargument() --- csprint(prtcatcodes,[[\ui_fo]]) -- ctx_firstofonearguments - end -end - -function commands.doifnotthing(b) - if b and b ~= "" then - ctx_gobbleoneargument() --- csprint(prtcatcodes,[[\ui_go]]) -- ctx_gobbleonearguments - else - ctx_firstofoneargument() --- csprint(prtcatcodes,[[\ui_fo]]) -- ctx_firstofonearguments - end -end - -commands.testcase = commands.doifelse -- obsolete - -function commands.boolcase(b) - context(b and 1 or 0) -end - -function commands.doifelsespaces(str) - if find(str,"^ +$") then - ctx_firstoftwoarguments() - else - ctx_secondoftwoarguments() - end -end - -local s = lpegtsplitat(",") -local h = { } - -local function doifelsecommon(a,b) -- often the same test - local ha = h[a] - local hb = h[b] - if not ha then - ha = lpegmatch(s,a) - h[a] = ha - end - if not hb then - hb = lpegmatch(s,b) - h[b] = hb - end - local na = #ha - local nb = #hb - for i=1,na do - for j=1,nb do - if ha[i] == hb[j] then - ctx_firstoftwoarguments() - return - end - end - end - ctx_secondoftwoarguments() -end - -local function doifelseinset(a,b) - local hb = h[b] - if not hb then hb = lpegmatch(s,b) h[b] = hb end - for i=1,#hb do - if a == hb[i] then - ctx_firstoftwoarguments() - return - end - end - ctx_secondoftwoarguments() -end - -implement { - name = "doifelsecommon", - arguments = two_strings, - actions = doifelsecommon -} - -implement { - name = "doifelseinset", - arguments = two_strings, - actions = doifelseinset -} - -local pattern = lpeg.patterns.validdimen - -function commands.doifelsedimenstring(str) - if lpegmatch(pattern,str) then - ctx_firstoftwoarguments() - else - ctx_secondoftwoarguments() - end -end - -local p_first = C((1-P(",")-P(-1))^0) - -implement { - name = "firstinset", - arguments = "string", - actions = function(str) context(lpegmatch(p_first,str or "")) end -} - -implement { - name = "ntimes", - arguments = { "string", "integer" }, - actions = { string.rep, context } -} - -implement { - name = "execute", - arguments = "string", - actions = os.execute -- wrapped in sandbox -} - --- function commands.write(n,str) --- if n == 18 then --- os.execute(str) --- elseif n == 16 then --- -- immediate --- logs.report(str) --- else --- -- at the tex end we can still drop the write / also delayed vs immediate --- context.writeviatex(n,str) --- end --- end - -implement { - name = "doifelsesame", - arguments = two_strings, - actions = function(a,b) - if a == b then - ctx_firstoftwoarguments() - else - ctx_secondoftwoarguments() - end - end -} - -implement { - name = "doifsame", - arguments = two_strings, - actions = function(a,b) - if a == b then - ctx_firstofoneargument() - else - ctx_gobbleoneargument() - end - end -} - -implement { - name = "doifnotsame", - arguments = two_strings, - actions = function(a,b) - if a == b then - ctx_gobbleoneargument() - else - ctx_firstofoneargument() - end - end -} |