From 79d53c0a828babfb0935f98aee0fd82a39dbd220 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Mon, 3 Oct 2011 12:59:00 +0200 Subject: beta 2011.10.03 12:59 --- .../data/scite/lexers/scite-context-lexer-cld.lua | 13 +- .../data/scite/lexers/scite-context-lexer-lua.lua | 22 ++- .../data/scite/lexers/scite-context-lexer-tex.lua | 10 +- context/data/scite/lexers/scite-context-lexer.lua | 215 +++++++++++---------- .../data/scite/scite-context-external.properties | 4 + context/data/scite/scite-context.properties | 6 + scripts/context/lua/mtxrun.lua | 89 +++------ scripts/context/stubs/mswin/mtxrun.lua | 89 +++------ scripts/context/stubs/unix/mtxrun | 89 +++------ tex/context/base/cont-new.mkii | 2 +- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4096 -> 4095 bytes tex/context/base/context-version.png | Bin 105062 -> 105125 bytes tex/context/base/context.mkii | 2 +- tex/context/base/context.mkiv | 2 +- tex/context/base/data-exp.lua | 35 ---- tex/context/base/lang-lab.lua | 3 + tex/context/base/lang-lab.mkiv | 15 ++ tex/context/base/status-files.pdf | Bin 23947 -> 23920 bytes tex/context/base/status-lua.pdf | Bin 162869 -> 162873 bytes tex/context/base/strc-ref.lua | 20 +- tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 22 files changed, 285 insertions(+), 335 deletions(-) diff --git a/context/data/scite/lexers/scite-context-lexer-cld.lua b/context/data/scite/lexers/scite-context-lexer-cld.lua index f81119adf..642c469a9 100644 --- a/context/data/scite/lexers/scite-context-lexer-cld.lua +++ b/context/data/scite/lexers/scite-context-lexer-cld.lua @@ -7,13 +7,16 @@ local info = { } local lexer = lexer +local token = lexer.token module(...) -local cldlexer = lexer.load('scite-context-lexer-lua') +local cldlexer = _M +local lualexer = lexer.load('scite-context-lexer-lua') -_rules = cldlexer._rules_cld -_tokenstyles = cldlexer._tokenstyles -_foldsymbols = cldlexer._foldsymbols +_rules = lualexer._rules_cld +_tokenstyles = lualexer._tokenstyles +_foldsymbols = lualexer._foldsymbols +_directives = lualexer._directives -_directives = cldlexer._directives +-- _rules[1] = { "whitespace", token(cldlexer.WHITESPACE, lexer.space^1) } diff --git a/context/data/scite/lexers/scite-context-lexer-lua.lua b/context/data/scite/lexers/scite-context-lexer-lua.lua index 1b55be55f..e10f49ff3 100644 --- a/context/data/scite/lexers/scite-context-lexer-lua.lua +++ b/context/data/scite/lexers/scite-context-lexer-lua.lua @@ -16,7 +16,7 @@ local global = _G module(...) -local cldlexer = _M +local lualexer = _M _directives = { } -- communication channel @@ -83,7 +83,7 @@ local longcomment = Cmt(#('[[' + ('[' * C(P('=')^0) * '[')), function(input,ind return stop and stop + 1 or #input + 1 end) -local whitespace = cldlexer.WHITESPACE -- triggers states +local whitespace = lualexer.WHITESPACE -- triggers states local space = lexer.space -- S(" \n\r\t\f\v") local any = lexer.any @@ -147,9 +147,10 @@ _rules = { { 'constant', constant }, { 'identifier', identifier }, { 'string', string }, + { 'number', number }, { 'longcomment', longcomment }, { 'shortcomment', shortcomment }, - { 'number', number }, +-- { 'number', number }, { 'operator', operator }, { 'rest', rest }, } @@ -159,9 +160,10 @@ _tokenstyles = lexer.context.styleset _foldsymbols = { _patterns = { '%l+', - '[%({%)}%[%]]', + -- '[%({%)}%[%]]', + '[{}%[%]]', }, - ['keyword'] = { + ['keyword'] = { -- challenge: if=0 then=1 else=-1 elseif=-1 ['if'] = 1, ['end'] = -1, ['do'] = 1, @@ -176,7 +178,7 @@ _foldsymbols = { ['['] = 1, [']'] = -1, }, ['special'] = { - ['('] = 1, [')'] = -1, + -- ['('] = 1, [')'] = -1, ['{'] = 1, ['}'] = -1, }, } @@ -184,7 +186,7 @@ _foldsymbols = { -- embedded in tex: local cstoken = R("az","AZ","\127\255") + S("@!?_") -local csnametex = P("\\") * cstoken^1 +local texcsname = P("\\") * cstoken^1 local commentline = P('%') * (1-S("\n\r"))^0 local texcomment = token('comment', Cmt(commentline, function() return _directives.cld_inline end)) @@ -197,8 +199,9 @@ local texstring = token("quote", longthreestart) * token("string", longthreestring) * token("quote", longthreestop) --- local texcommand = token("user", csnametex) --- +-- local texcommand = token("user", texcsname) +local texcommand = token("warning", texcsname) + -- local texstring = token("quote", longthreestart) -- * (texcommand + token("string",P(1-texcommand-longthreestop)^1) - longthreestop)^0 -- we match long non-\cs sequences -- * token("quote", longthreestop) @@ -207,6 +210,7 @@ _rules_cld = { { 'whitespace', spacing }, { 'texstring', texstring }, { 'texcomment', texcomment }, + { 'texcommand', texcommand }, { 'keyword', keyword }, { 'function', builtin }, { 'csname', csname }, diff --git a/context/data/scite/lexers/scite-context-lexer-tex.lua b/context/data/scite/lexers/scite-context-lexer-tex.lua index 8204ae3a0..2c82454d4 100644 --- a/context/data/scite/lexers/scite-context-lexer-tex.lua +++ b/context/data/scite/lexers/scite-context-lexer-tex.lua @@ -329,7 +329,7 @@ local function startinlinelua(_,i,s) cldlexer._directives.cld_inline = true lualevel = 1 return true - else + else-- if luastatus == "inline" then lualevel = lualevel + 1 return true end @@ -351,7 +351,7 @@ local function stopinlinelua_e(_,i,s) -- } return false elseif luastatus == "inline" then lualevel = lualevel - 1 - local ok = lualevel <= 0 + local ok = lualevel <= 0 -- was 0 if ok then cldlexer._directives.cld_inline = false luastatus = false @@ -362,6 +362,12 @@ local function stopinlinelua_e(_,i,s) -- } end end +contextlexer._reset_parser = function() + luastatus = false + luatag = nil + lualevel = 0 +end + local luaenvironment = P("luacode") local inlinelua = P("\\") * ( diff --git a/context/data/scite/lexers/scite-context-lexer.lua b/context/data/scite/lexers/scite-context-lexer.lua index 13b8d77a8..8573d331c 100644 --- a/context/data/scite/lexers/scite-context-lexer.lua +++ b/context/data/scite/lexers/scite-context-lexer.lua @@ -321,128 +321,149 @@ setmetatable(n_table, { __index = function(t,level) local v = { level -- end -- line_num = line_num + 1 -- end --- --- -- not that much faster but less memory: - -local action_y, action_n -local newline = P("\r\n") + S("\r\n") -local splitlines = ( ( - (Cp() * Cs((1-newline)^1) * newline^-1) / function(p,l) action_y(p,l) end - + ( newline ) / function() action_n() end -) )^0 +local newline = P("\r\n") + S("\r\n") +local p_yes = Cp() * Cs((1-newline)^1) * newline^-1 +local p_nop = newline -function context.fold(text, start_pos, start_line, start_level) - if text == '' then +local function fold_by_parsing(text,start_pos,start_line,start_level,lexer) + local foldsymbols = lexer._foldsymbols + if not foldsymbols then return { } end - local lexer = global._LEXER - if lexer._fold then - return lexer._fold(text, start_pos, start_line, start_level) + local patterns = foldsymbols._patterns + if not patterns then + return { } + end + local nofpatterns = #patterns + if nofpatterns == 0 then + return { } end local folds = { } - if lexer._foldsymbols then - local fold_symbols = lexer._foldsymbols - local line_num = start_line - local prev_level = start_level - local current_level = prev_level - local patterns = fold_symbols._patterns - local nofpatterns = #patterns - local hash = fold_symbols._hash - if not hash then - hash = { } - for symbol, matches in next, fold_symbols do - if not find(symbol,"^_") then - for s, _ in next, matches do - hash[s] = true - end + local line_num = start_line + local prev_level = start_level + local current_level = prev_level + local validmatches = foldsymbols._validmatches + if not validmatches then + validmatches = { } + for symbol, matches in next, foldsymbols do -- whatever = { start = 1, stop = -1 } + if not find(symbol,"^_") then -- brrr + for s, _ in next, matches do + validmatches[s] = true end end - fold_symbols._hash = hash end - action_y = function(pos,line) -- we can consider moving this one outside the function - for i=1,nofpatterns do - for s, m in gmatch(line,patterns[i]) do - if hash[m] then - local symbols = fold_symbols[get_style_at(start_pos + pos + s - 1)] - if symbols then - local l = symbols[m] - if l then - local t = type(l) - if t == 'number' then - current_level = current_level + l - if current_level < FOLD_BASE then -- can this happen? - current_level = FOLD_BASE - end - elseif t == 'function' then - current_level = current_level + l(text, pos, line, s, match) - if current_level < FOLD_BASE then - current_level = FOLD_BASE - end - end + foldsymbols._validmatches = validmatches + end + local function action_y(pos,line) -- we can consider moving the local functions outside (drawback: folds is kept) + for i=1,nofpatterns do + for s, m in gmatch(line,patterns[i]) do + if validmatches[m] then + local symbols = foldsymbols[get_style_at(start_pos + pos + s - 1)] + if symbols then + local action = symbols[m] + if action then + if type(action) == 'number' then -- we could store this in validmatches if there was only one symbol category + current_level = current_level + action + else + current_level = current_level + action(text,pos,line,s,m) + end + if current_level < FOLD_BASE then + current_level = FOLD_BASE end end end end end - if current_level > prev_level then - folds[line_num] = h_table[prev_level] -- { prev_level, FOLD_HEADER } - else - folds[line_num] = n_table[prev_level] -- { prev_level } - end - prev_level = current_level - line_num = line_num + 1 end - action_n = function() -- we can consider moving this one outside the function - folds[line_num] = b_table[prev_level] -- { prev_level, FOLD_BLANK } - line_num = line_num + 1 + if current_level > prev_level then + folds[line_num] = h_table[prev_level] -- { prev_level, FOLD_HEADER } + else + folds[line_num] = n_table[prev_level] -- { prev_level } end - local lines = lpegmatch(splitlines,text) - elseif get_property('fold.by.indentation',1) == 1 then - local current_line = start_line - local prev_level = start_level - for _, line in gmatch(text,'([\t ]*)(.-)\r?\n') do - if line ~= "" then - local current_level = FOLD_BASE + get_indent_amount(current_line) - if current_level > prev_level then -- next level - local i = current_line - 1 - while true do - local f = folds[i] - if f and f[2] == FOLD_BLANK then - i = i - 1 - else - break - end - end + prev_level = current_level + line_num = line_num + 1 + end + local function action_n() + folds[line_num] = b_table[prev_level] -- { prev_level, FOLD_BLANK } + line_num = line_num + 1 + end + if lexer._reset_parser then + lexer._reset_parser() + end + local lpegpattern = (p_yes/action_y + p_nop/action_n)^0 -- not too efficient but indirect function calls are neither but + lpegmatch(lpegpattern,text) -- keys are not pressed that fast ... large files are slow anyway + return folds +end + +local function fold_by_indentation(text,start_pos,start_line,start_level) + local folds = { } + local current_line = start_line + local prev_level = start_level + for _, line in gmatch(text,'([\t ]*)(.-)\r?\n') do + if line ~= "" then + local current_level = FOLD_BASE + get_indent_amount(current_line) + if current_level > prev_level then -- next level + local i = current_line - 1 + while true do local f = folds[i] - if f then - f[2] = FOLD_HEADER - end -- low indent - folds[current_line] = n_table[current_level] -- { current_level } -- high indent - elseif current_level < prev_level then -- prev level - local f = folds[current_line - 1] - if f then - f[1] = prev_level -- high indent + if f and f[2] == FOLD_BLANK then + i = i - 1 + else + break end - folds[current_line] = n_table[current_level] -- { current_level } -- low indent - else -- same level - folds[current_line] = n_table[prev_level] -- { prev_level } end - prev_level = current_level - else - folds[current_line] = b_table[prev_level] -- { prev_level, FOLD_BLANK } + local f = folds[i] + if f then + f[2] = FOLD_HEADER + end -- low indent + folds[current_line] = n_table[current_level] -- { current_level } -- high indent + elseif current_level < prev_level then -- prev level + local f = folds[current_line - 1] + if f then + f[1] = prev_level -- high indent + end + folds[current_line] = n_table[current_level] -- { current_level } -- low indent + else -- same level + folds[current_line] = n_table[prev_level] -- { prev_level } end - current_line = current_line + 1 - end - else - for _ in gmatch(text,".-\r?\n") do - folds[start_line] = n_table[start_level] -- { start_level } - start_line = start_line + 1 + prev_level = current_level + else + folds[current_line] = b_table[prev_level] -- { prev_level, FOLD_BLANK } end + current_line = current_line + 1 + end + return folds +end + +local function fold_by_line(text,start_pos,start_line,start_level) + local folds = { } + for _ in gmatch(text,".-\r?\n") do + folds[start_line] = n_table[start_level] -- { start_level } + start_line = start_line + 1 end return folds end +function context.fold(text,start_pos,start_line,start_level) + if text == '' then + return { } + end + local lexer = global._LEXER + local fold_by_lexer = lexer._fold + if fold_by_lexer then + return fold_by_lexer(text,start_pos,start_line,start_level,lexer) + elseif get_property('fold.by.parsing',1) > 0 then + return fold_by_parsing(text,start_pos,start_line,start_level,lexer) + elseif get_property('fold.by.indentation',1) > 0 then -- not that usefull + return fold_by_indentation(text,start_pos,start_line,start_level,lexer) + elseif get_property('fold.by.line',1) > 0 then -- rather useless + return fold_by_line(text,start_pos,start_line,start_level,lexer) + else + return { } + end +end + function context.lex(text,init_style) local lexer = global._LEXER local grammar = lexer._GRAMMAR diff --git a/context/data/scite/scite-context-external.properties b/context/data/scite/scite-context-external.properties index 021c72133..723f19889 100644 --- a/context/data/scite/scite-context-external.properties +++ b/context/data/scite/scite-context-external.properties @@ -6,7 +6,11 @@ lexer.lpeg.home=$(SciteDefaultHome)/lexers lexer.lpeg.script=$(lexer.lpeg.home)/scite-context-lexer.lua lexer.lpeg.color.theme=$(lexer.lpeg.home)/themes/scite-context-theme.lua +# alas, only a few properties are passed (only indentation) + +fold.by.parsing=1 fold.by.indentation=0 +fold.by.line=0 if PLAT_WIN lexerpath.*.lpeg=$(lexer.lpeg.home)/LexLPeg.dll diff --git a/context/data/scite/scite-context.properties b/context/data/scite/scite-context.properties index 5e57d8fcd..4abd2ee29 100644 --- a/context/data/scite/scite-context.properties +++ b/context/data/scite/scite-context.properties @@ -320,6 +320,8 @@ Ctrl+F12|IDM_BUILD|\ Shift+F12|IDM_GO|\ Alt+F12|IDM_STOPEXECUTE|\ +os.x.home.end.keys=0 + # Editor: fonts if PLAT_WIN @@ -330,6 +332,10 @@ if PLAT_GTK font.monospace=font:!Dejavu Sans Mono,size:14 font.errorfont=font:!Dejavu Sans Mono,size:8 +if PLAT_MAC + font.monospace=font:Dejavu Sans Mono,size:14 + font.errorfont=font:Dejavu Sans Mono,size:8 + font.base=$(font.monospace) font.comment=$(font.monospace) font.text=$(font.monospace) diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index b8c1cc587..a4731ad06 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -10602,41 +10602,6 @@ end -- {a,b,c/{p,q/{x,y,z},w}v,d/{p,q,r}} -- {$SELFAUTODIR,$SELFAUTOPARENT}{,{/share,}/texmf{-local,.local,}/web2c} --- local cleanup = lpeg.replacer { --- { "!" , "" }, --- { "\\" , "/" }, --- } --- --- local homedir --- --- function resolvers.cleanpath(str) -- tricky, maybe only simple paths --- if not homedir then --- homedir = lpegmatch(cleanup,environment.homedir or "") --- if homedir == char(127) or homedir == "" or not lfs.isdir(homedir) then --- if trace_expansions then --- report_expansions("no home dir set, ignoring dependent paths") --- end --- function resolvers.cleanpath(str) --- if find(str,"~") then --- return "" -- special case --- else --- return str and lpegmatch(cleanup,str) --- end --- end --- else --- cleanup = lpeg.replacer { --- { "!" , "" }, --- { "\\" , "/" }, --- { "~" , homedir }, --- } --- function resolvers.cleanpath(str) --- return str and lpegmatch(cleanup,str) --- end --- end --- end --- return resolvers.cleanpath(str) --- end - local cleanup = lpeg.replacer { { "!" , "" }, { "\\" , "/" }, @@ -15128,7 +15093,7 @@ end -- End of hack. -local format, gsub, gmatch, match = string.format, string.gsub, string.gmatch, string.match +local format, gsub, gmatch, match, find = string.format, string.gsub, string.gmatch, string.match, string.find local concat = table.concat own.name = (environment and environment.ownname) or arg[0] or 'mtxrun.lua' @@ -15409,11 +15374,11 @@ function runners.execute_script(fullname,internal,nosplit) if path ~= "" then result = fullname elseif name then - name = name:gsub("^int[%a]*:",function() + name = gsub(name,"^int[%a]*:",function() internal = true return "" end ) - name = name:gsub("^script:","") + name = gsub(name,"^script:","") if suffix == "" and runners.registered[name] and runners.registered[name][1] then name = runners.registered[name][1] suffix = file.extname(name) @@ -15496,7 +15461,7 @@ function runners.execute_program(fullname) local before, after = environment.splitarguments(fullname) for k=1,#after do after[k] = resolvers.resolve(after[k]) end environment.initializearguments(after) - fullname = fullname:gsub("^bin:","") + fullname = gsub(fullname,"^bin:","") local command = fullname .. " " .. (environment.reconstructcommandline(after or "",noquote) or "") report() report("executing: %s",command) @@ -15678,6 +15643,11 @@ function runners.launch_file(filename) end end +local mtxprefixes = { + { "^mtx%-", "mtx-" }, + { "^mtx%-t%-", "mtx-t-" }, +} + function runners.find_mtx_script(filename) local function found(name) local path = file.dirname(name) @@ -15703,24 +15673,27 @@ function runners.find_mtx_script(filename) return fullname end -- mtx- prefix checking - local mtxprefix = (filename:find("^mtx%-") and "") or "mtx-" - -- context namespace, mtx- - fullname = mtxprefix .. filename - fullname = found(fullname) or resolvers.findfile(fullname) - if fullname and fullname ~= "" then - return fullname - end - -- context namespace, mtx-s - fullname = mtxprefix .. basename .. "s" .. "." .. suffix - fullname = found(fullname) or resolvers.findfile(fullname) - if fullname and fullname ~= "" then - return fullname - end - -- context namespace, mtx- - fullname = mtxprefix .. basename:gsub("s$","") .. "." .. suffix - fullname = found(fullname) or resolvers.findfile(fullname) - if fullname and fullname ~= "" then - return fullname + for i=1,#mtxprefixes do + local mtxprefix = mtxprefixes[i] + mtxprefix = find(filename,mtxprefix[1]) and "" or mtxprefix[2] + -- context namespace, mtx- + fullname = mtxprefix .. filename + fullname = found(fullname) or resolvers.findfile(fullname) + if fullname and fullname ~= "" then + return fullname + end + -- context namespace, mtx-s + fullname = mtxprefix .. basename .. "s" .. "." .. suffix + fullname = found(fullname) or resolvers.findfile(fullname) + if fullname and fullname ~= "" then + return fullname + end + -- context namespace, mtx- + fullname = mtxprefix .. gsub(basename,"s$","") .. "." .. suffix + fullname = found(fullname) or resolvers.findfile(fullname) + if fullname and fullname ~= "" then + return fullname + end end -- context namespace, just fullname = resolvers.findfile(filename) @@ -16206,7 +16179,7 @@ elseif e_argument("help") or filename=='help' or filename == "" then application.help() -elseif filename:find("^bin:") then +elseif find(filename,"^bin:") then runners.loadbase() ok = runners.execute_program(filename) diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index b8c1cc587..a4731ad06 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -10602,41 +10602,6 @@ end -- {a,b,c/{p,q/{x,y,z},w}v,d/{p,q,r}} -- {$SELFAUTODIR,$SELFAUTOPARENT}{,{/share,}/texmf{-local,.local,}/web2c} --- local cleanup = lpeg.replacer { --- { "!" , "" }, --- { "\\" , "/" }, --- } --- --- local homedir --- --- function resolvers.cleanpath(str) -- tricky, maybe only simple paths --- if not homedir then --- homedir = lpegmatch(cleanup,environment.homedir or "") --- if homedir == char(127) or homedir == "" or not lfs.isdir(homedir) then --- if trace_expansions then --- report_expansions("no home dir set, ignoring dependent paths") --- end --- function resolvers.cleanpath(str) --- if find(str,"~") then --- return "" -- special case --- else --- return str and lpegmatch(cleanup,str) --- end --- end --- else --- cleanup = lpeg.replacer { --- { "!" , "" }, --- { "\\" , "/" }, --- { "~" , homedir }, --- } --- function resolvers.cleanpath(str) --- return str and lpegmatch(cleanup,str) --- end --- end --- end --- return resolvers.cleanpath(str) --- end - local cleanup = lpeg.replacer { { "!" , "" }, { "\\" , "/" }, @@ -15128,7 +15093,7 @@ end -- End of hack. -local format, gsub, gmatch, match = string.format, string.gsub, string.gmatch, string.match +local format, gsub, gmatch, match, find = string.format, string.gsub, string.gmatch, string.match, string.find local concat = table.concat own.name = (environment and environment.ownname) or arg[0] or 'mtxrun.lua' @@ -15409,11 +15374,11 @@ function runners.execute_script(fullname,internal,nosplit) if path ~= "" then result = fullname elseif name then - name = name:gsub("^int[%a]*:",function() + name = gsub(name,"^int[%a]*:",function() internal = true return "" end ) - name = name:gsub("^script:","") + name = gsub(name,"^script:","") if suffix == "" and runners.registered[name] and runners.registered[name][1] then name = runners.registered[name][1] suffix = file.extname(name) @@ -15496,7 +15461,7 @@ function runners.execute_program(fullname) local before, after = environment.splitarguments(fullname) for k=1,#after do after[k] = resolvers.resolve(after[k]) end environment.initializearguments(after) - fullname = fullname:gsub("^bin:","") + fullname = gsub(fullname,"^bin:","") local command = fullname .. " " .. (environment.reconstructcommandline(after or "",noquote) or "") report() report("executing: %s",command) @@ -15678,6 +15643,11 @@ function runners.launch_file(filename) end end +local mtxprefixes = { + { "^mtx%-", "mtx-" }, + { "^mtx%-t%-", "mtx-t-" }, +} + function runners.find_mtx_script(filename) local function found(name) local path = file.dirname(name) @@ -15703,24 +15673,27 @@ function runners.find_mtx_script(filename) return fullname end -- mtx- prefix checking - local mtxprefix = (filename:find("^mtx%-") and "") or "mtx-" - -- context namespace, mtx- - fullname = mtxprefix .. filename - fullname = found(fullname) or resolvers.findfile(fullname) - if fullname and fullname ~= "" then - return fullname - end - -- context namespace, mtx-s - fullname = mtxprefix .. basename .. "s" .. "." .. suffix - fullname = found(fullname) or resolvers.findfile(fullname) - if fullname and fullname ~= "" then - return fullname - end - -- context namespace, mtx- - fullname = mtxprefix .. basename:gsub("s$","") .. "." .. suffix - fullname = found(fullname) or resolvers.findfile(fullname) - if fullname and fullname ~= "" then - return fullname + for i=1,#mtxprefixes do + local mtxprefix = mtxprefixes[i] + mtxprefix = find(filename,mtxprefix[1]) and "" or mtxprefix[2] + -- context namespace, mtx- + fullname = mtxprefix .. filename + fullname = found(fullname) or resolvers.findfile(fullname) + if fullname and fullname ~= "" then + return fullname + end + -- context namespace, mtx-s + fullname = mtxprefix .. basename .. "s" .. "." .. suffix + fullname = found(fullname) or resolvers.findfile(fullname) + if fullname and fullname ~= "" then + return fullname + end + -- context namespace, mtx- + fullname = mtxprefix .. gsub(basename,"s$","") .. "." .. suffix + fullname = found(fullname) or resolvers.findfile(fullname) + if fullname and fullname ~= "" then + return fullname + end end -- context namespace, just fullname = resolvers.findfile(filename) @@ -16206,7 +16179,7 @@ elseif e_argument("help") or filename=='help' or filename == "" then application.help() -elseif filename:find("^bin:") then +elseif find(filename,"^bin:") then runners.loadbase() ok = runners.execute_program(filename) diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index b8c1cc587..a4731ad06 100755 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -10602,41 +10602,6 @@ end -- {a,b,c/{p,q/{x,y,z},w}v,d/{p,q,r}} -- {$SELFAUTODIR,$SELFAUTOPARENT}{,{/share,}/texmf{-local,.local,}/web2c} --- local cleanup = lpeg.replacer { --- { "!" , "" }, --- { "\\" , "/" }, --- } --- --- local homedir --- --- function resolvers.cleanpath(str) -- tricky, maybe only simple paths --- if not homedir then --- homedir = lpegmatch(cleanup,environment.homedir or "") --- if homedir == char(127) or homedir == "" or not lfs.isdir(homedir) then --- if trace_expansions then --- report_expansions("no home dir set, ignoring dependent paths") --- end --- function resolvers.cleanpath(str) --- if find(str,"~") then --- return "" -- special case --- else --- return str and lpegmatch(cleanup,str) --- end --- end --- else --- cleanup = lpeg.replacer { --- { "!" , "" }, --- { "\\" , "/" }, --- { "~" , homedir }, --- } --- function resolvers.cleanpath(str) --- return str and lpegmatch(cleanup,str) --- end --- end --- end --- return resolvers.cleanpath(str) --- end - local cleanup = lpeg.replacer { { "!" , "" }, { "\\" , "/" }, @@ -15128,7 +15093,7 @@ end -- End of hack. -local format, gsub, gmatch, match = string.format, string.gsub, string.gmatch, string.match +local format, gsub, gmatch, match, find = string.format, string.gsub, string.gmatch, string.match, string.find local concat = table.concat own.name = (environment and environment.ownname) or arg[0] or 'mtxrun.lua' @@ -15409,11 +15374,11 @@ function runners.execute_script(fullname,internal,nosplit) if path ~= "" then result = fullname elseif name then - name = name:gsub("^int[%a]*:",function() + name = gsub(name,"^int[%a]*:",function() internal = true return "" end ) - name = name:gsub("^script:","") + name = gsub(name,"^script:","") if suffix == "" and runners.registered[name] and runners.registered[name][1] then name = runners.registered[name][1] suffix = file.extname(name) @@ -15496,7 +15461,7 @@ function runners.execute_program(fullname) local before, after = environment.splitarguments(fullname) for k=1,#after do after[k] = resolvers.resolve(after[k]) end environment.initializearguments(after) - fullname = fullname:gsub("^bin:","") + fullname = gsub(fullname,"^bin:","") local command = fullname .. " " .. (environment.reconstructcommandline(after or "",noquote) or "") report() report("executing: %s",command) @@ -15678,6 +15643,11 @@ function runners.launch_file(filename) end end +local mtxprefixes = { + { "^mtx%-", "mtx-" }, + { "^mtx%-t%-", "mtx-t-" }, +} + function runners.find_mtx_script(filename) local function found(name) local path = file.dirname(name) @@ -15703,24 +15673,27 @@ function runners.find_mtx_script(filename) return fullname end -- mtx- prefix checking - local mtxprefix = (filename:find("^mtx%-") and "") or "mtx-" - -- context namespace, mtx- - fullname = mtxprefix .. filename - fullname = found(fullname) or resolvers.findfile(fullname) - if fullname and fullname ~= "" then - return fullname - end - -- context namespace, mtx-s - fullname = mtxprefix .. basename .. "s" .. "." .. suffix - fullname = found(fullname) or resolvers.findfile(fullname) - if fullname and fullname ~= "" then - return fullname - end - -- context namespace, mtx- - fullname = mtxprefix .. basename:gsub("s$","") .. "." .. suffix - fullname = found(fullname) or resolvers.findfile(fullname) - if fullname and fullname ~= "" then - return fullname + for i=1,#mtxprefixes do + local mtxprefix = mtxprefixes[i] + mtxprefix = find(filename,mtxprefix[1]) and "" or mtxprefix[2] + -- context namespace, mtx- + fullname = mtxprefix .. filename + fullname = found(fullname) or resolvers.findfile(fullname) + if fullname and fullname ~= "" then + return fullname + end + -- context namespace, mtx-s + fullname = mtxprefix .. basename .. "s" .. "." .. suffix + fullname = found(fullname) or resolvers.findfile(fullname) + if fullname and fullname ~= "" then + return fullname + end + -- context namespace, mtx- + fullname = mtxprefix .. gsub(basename,"s$","") .. "." .. suffix + fullname = found(fullname) or resolvers.findfile(fullname) + if fullname and fullname ~= "" then + return fullname + end end -- context namespace, just fullname = resolvers.findfile(filename) @@ -16206,7 +16179,7 @@ elseif e_argument("help") or filename=='help' or filename == "" then application.help() -elseif filename:find("^bin:") then +elseif find(filename,"^bin:") then runners.loadbase() ok = runners.execute_program(filename) diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index d24e2d4f8..b3a6e6616 100644 --- a/tex/context/base/cont-new.mkii +++ b/tex/context/base/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2011.10.02 22:44} +\newcontextversion{2011.10.03 12:59} %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/cont-new.mkiv b/tex/context/base/cont-new.mkiv index bd35fb34c..5e78ffb75 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{2011.10.02 22:44} +\newcontextversion{2011.10.03 12:59} %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-version.pdf b/tex/context/base/context-version.pdf index 49e28803e..ab813a18b 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-version.png b/tex/context/base/context-version.png index d22f76b85..259d4f188 100644 Binary files a/tex/context/base/context-version.png and b/tex/context/base/context-version.png differ diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index 53ec5343b..ca149be97 100644 --- a/tex/context/base/context.mkii +++ b/tex/context/base/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2011.10.02 22:44} +\edef\contextversion{2011.10.03 12:59} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 265181292..d2d91489b 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2011.10.02 22:44} +\edef\contextversion{2011.10.03 12:59} %D For those who want to use this: diff --git a/tex/context/base/data-exp.lua b/tex/context/base/data-exp.lua index 82fedcf6e..52368f8a8 100644 --- a/tex/context/base/data-exp.lua +++ b/tex/context/base/data-exp.lua @@ -130,41 +130,6 @@ end -- {a,b,c/{p,q/{x,y,z},w}v,d/{p,q,r}} -- {$SELFAUTODIR,$SELFAUTOPARENT}{,{/share,}/texmf{-local,.local,}/web2c} --- local cleanup = lpeg.replacer { --- { "!" , "" }, --- { "\\" , "/" }, --- } --- --- local homedir --- --- function resolvers.cleanpath(str) -- tricky, maybe only simple paths --- if not homedir then --- homedir = lpegmatch(cleanup,environment.homedir or "") --- if homedir == char(127) or homedir == "" or not lfs.isdir(homedir) then --- if trace_expansions then --- report_expansions("no home dir set, ignoring dependent paths") --- end --- function resolvers.cleanpath(str) --- if find(str,"~") then --- return "" -- special case --- else --- return str and lpegmatch(cleanup,str) --- end --- end --- else --- cleanup = lpeg.replacer { --- { "!" , "" }, --- { "\\" , "/" }, --- { "~" , homedir }, --- } --- function resolvers.cleanpath(str) --- return str and lpegmatch(cleanup,str) --- end --- end --- end --- return resolvers.cleanpath(str) --- end - local cleanup = lpeg.replacer { { "!" , "" }, { "\\" , "/" }, diff --git a/tex/context/base/lang-lab.lua b/tex/context/base/lang-lab.lua index 91b843beb..64d102768 100644 --- a/tex/context/base/lang-lab.lua +++ b/tex/context/base/lang-lab.lua @@ -153,3 +153,6 @@ end --~ --~ languages.labels.check() +-- function commands.setstrippedtextprefix(str) +-- context(string.strip(str)) +-- end diff --git a/tex/context/base/lang-lab.mkiv b/tex/context/base/lang-lab.mkiv index db15308e6..31ad760d0 100644 --- a/tex/context/base/lang-lab.mkiv +++ b/tex/context/base/lang-lab.mkiv @@ -82,6 +82,8 @@ \def\dododefinelabelclass#1#2#3#4#5#6#7#8#9% {\setuvalue{setup#1text}{\protecttextprefixes#2\def\currenttextprefixclass{#1}\dodoubleempty\dosetupsometextprefix}% \setuvalue{preset#1text}{\protecttextprefixes1\def\currenttextprefixclass{#1}\dodoubleempty\dosetupsometextprefix}% + \setuvalue{start#1text}{\protecttextprefixes1\def\currenttextprefixclass{#1}\dotripleempty\dostartsometextprefix[#1]}% + \letvalue{stop#1text}\relax \def#4{\reallanguagetag{\defaultlanguage\currentmainlanguage}}% \ifnum#2=\plustwo \def#3{#5#4}% @@ -169,6 +171,19 @@ \let\currenttextprefixtag \s!unknown \let\currenttextprefixclass\s!unknown +\def\dostartsometextprefix[#1][#2][#3]% class language name + {\ifthirdargument + \edef\currenttextprefixtag{\reallanguagetag{#2}}% + \edef\currenttextprefixname{#3}% + \else + \edef\currenttextprefixtag{\reallanguagetag\currentmainlanguage}% + \edef\currenttextprefixname{#2}% + \fi + \grabuntil{stop#1text}\dodostartsometextprefix} + +\def\dodostartsometextprefix#1% text (not special checking done here yet, only for long texts anyway) + {\expandafter\edef\csname\??ml:\currenttextprefixclass:\currenttextprefixtag:\currenttextprefixname\endcsname{{\ctxlua{context(string.strip(\!!bs#1\!!es))}}\empty}} + \def\dosetupsometextprefix[#1][#2]% {\ifsecondargument \edef\currenttextprefixtag{\reallanguagetag{#1}}% diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index ac3caf0cb..179300e49 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 f0d58bf2c..1cba3622d 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-ref.lua b/tex/context/base/strc-ref.lua index 8e3a3db82..da0549bb9 100644 --- a/tex/context/base/strc-ref.lua +++ b/tex/context/base/strc-ref.lua @@ -389,13 +389,6 @@ references.files.data = references.files.data or { } local files = references.files.data -table.setmetatableindex(files, function(t,k) - -- we assume that it's a file anyway - local v = { k, k } - files[k] = v - return v -end) - function references.files.define(name,file,description) if name and name ~= "" then files[name] = { file or "", description or file or "" } @@ -711,8 +704,19 @@ local function loadexternalreferences(name,utilitydata) end end +local externalfiles = { } + +table.setmetatableindex(externalfiles, function(t,k) + local v = files[k] + if not v then + v = { k, k } + end + externalfiles[k] = v + return v +end) + table.setmetatableindex(externals,function(t,k) -- either or not automatically - local filename = files[k][1] -- filename + local filename = externalfiles[k][1] -- filename local fullname = file.replacesuffix(filename,"tuc") if lfs.isfile(fullname) then -- todo: use other locator local utilitydata = job.loadother(fullname) diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index ba34077c9..7371dcfc9 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 : 10/02/11 22:44:18 +-- merge date : 10/03/11 12:59:24 do -- begin closure to overcome local limits and interference -- cgit v1.2.3