diff options
22 files changed, 707 insertions, 171 deletions
diff --git a/context/data/scite/lexers/scite-context-lexer-lua.lua b/context/data/scite/lexers/scite-context-lexer-lua.lua index 55bc30999..248672b06 100644 --- a/context/data/scite/lexers/scite-context-lexer-lua.lua +++ b/context/data/scite/lexers/scite-context-lexer-lua.lua @@ -6,7 +6,7 @@ local info = { license = "see context related readme files", } -if not lexer._CONTEXTEXTENSIONS then dofile(_LEXERHOME .. "/scite-context-lexer.lua") end +if not lexer._CONTEXTEXTENSIONS then require("scite-context-lexer") end local lexer = lexer local token, style, colors, exact_match, no_style = lexer.token, lexer.style, lexer.colors, lexer.exact_match, lexer.style_nothing diff --git a/context/data/scite/lexers/scite-context-lexer-mps.lua b/context/data/scite/lexers/scite-context-lexer-mps.lua index 00cc7f8ba..4dd498b53 100644 --- a/context/data/scite/lexers/scite-context-lexer-mps.lua +++ b/context/data/scite/lexers/scite-context-lexer-mps.lua @@ -6,7 +6,7 @@ local info = { license = "see context related readme files", } -if not lexer._CONTEXTEXTENSIONS then dofile(_LEXERHOME .. "/scite-context-lexer.lua") end +if not lexer._CONTEXTEXTENSIONS then require("scite-context-lexer") end local lexer = lexer local global, string, table, lpeg = _G, string, table, lpeg diff --git a/context/data/scite/lexers/scite-context-lexer-pdf.lua b/context/data/scite/lexers/scite-context-lexer-pdf.lua index 05517bb64..61cf819f0 100644 --- a/context/data/scite/lexers/scite-context-lexer-pdf.lua +++ b/context/data/scite/lexers/scite-context-lexer-pdf.lua @@ -6,7 +6,7 @@ local info = { license = "see context related readme files", } -if not lexer._CONTEXTEXTENSIONS then dofile(_LEXERHOME .. "/scite-context-lexer.lua") end +if not lexer._CONTEXTEXTENSIONS then require("scite-context-lexer") end local lexer = lexer local token = lexer.token diff --git a/context/data/scite/lexers/scite-context-lexer-tex.lua b/context/data/scite/lexers/scite-context-lexer-tex.lua index 812dfbb05..3408d1eb4 100644 --- a/context/data/scite/lexers/scite-context-lexer-tex.lua +++ b/context/data/scite/lexers/scite-context-lexer-tex.lua @@ -33,7 +33,7 @@ local info = { ]]-- -if not lexer._CONTEXTEXTENSIONS then dofile(_LEXERHOME .. "/scite-context-lexer.lua") end +if not lexer._CONTEXTEXTENSIONS then require("scite-context-lexer") end local lexer = lexer local global, string, table, lpeg = _G, string, table, lpeg diff --git a/context/data/scite/lexers/scite-context-lexer-txt.lua b/context/data/scite/lexers/scite-context-lexer-txt.lua index d92be8ed7..2f476a6a8 100644 --- a/context/data/scite/lexers/scite-context-lexer-txt.lua +++ b/context/data/scite/lexers/scite-context-lexer-txt.lua @@ -6,16 +6,13 @@ local info = { license = "see context related readme files", } -if not lexer._CONTEXTEXTENSIONS then dofile(_LEXERHOME .. "/scite-context-lexer.lua") end +if not lexer._CONTEXTEXTENSIONS then require("scite-context-lexer") end local lexer = lexer local token = lexer.token local P, S, Cmt = lpeg.P, lpeg.S, lpeg.Cmt local find, match = string.find, string.match --- local textlexer = (_VERSION == "Lua 5.1" and (module(...) or true) and _M) or { } --- (_VERSION == "Lua 5.1" and (module(...) or true) and _M) or { } - local textlexer = { _NAME = "text" } local context = lexer.context @@ -31,6 +28,12 @@ local checkedword = context.checkedword local setwordlist = context.setwordlist local validwords = false +-- local styleset = context.newstyleset { +-- "default", +-- "text", "okay", "error", "warning", +-- "preamble", +-- } + -- [#!-%] language=uk local p_preamble = Cmt(#(S("#!-%") * P(" ")), function(input,i,_) -- todo: utf bomb @@ -48,7 +51,7 @@ local p_preamble = Cmt(#(S("#!-%") * P(" ")), function(input,i,_) -- todo: utf b end) local t_preamble = - token('preamble', p_preamble) + token("preamble", p_preamble) local t_word = Cmt(wordpattern, function(_,i,s) @@ -76,6 +79,6 @@ textlexer._rules = { { "rest", t_rest }, } -textlexer._tokenstyles = lexer.context.styleset +textlexer._tokenstyles = context.styleset return textlexer diff --git a/context/data/scite/lexers/scite-context-lexer-xml.lua b/context/data/scite/lexers/scite-context-lexer-xml.lua index 2ca814fef..89b20f3a4 100644 --- a/context/data/scite/lexers/scite-context-lexer-xml.lua +++ b/context/data/scite/lexers/scite-context-lexer-xml.lua @@ -12,7 +12,7 @@ local info = { -- todo: parse entities in attributes -if not lexer._CONTEXTEXTENSIONS then dofile(_LEXERHOME .. "/scite-context-lexer.lua") end +if not lexer._CONTEXTEXTENSIONS then require("scite-context-lexer") end local lexer = lexer local global, string, table, lpeg = _G, string, table, lpeg diff --git a/context/data/scite/lexers/scite-context-lexer.lua b/context/data/scite/lexers/scite-context-lexer.lua index 166ee96d6..04eb8400c 100644 --- a/context/data/scite/lexers/scite-context-lexer.lua +++ b/context/data/scite/lexers/scite-context-lexer.lua @@ -17,12 +17,20 @@ local info = { -- installation issue). The loading takes place with: -- -- if not lexer._CONTEXTEXTENSIONS then --- dofile(_LEXERHOME .. "/scite-context-lexer.lua") +-- dofile(_LEXERHOME .. "/scite-context-lexer.lua") -- end -- --- So, where pre 3.03 we loaded that file and in that file th eoriginal lexing code, we +-- So, where pre 3.03 we loaded that file and in that file the original lexing code, we -- now do the reverse. -- +-- Another change has been that _LEXERHOME is no longer available. It looks like more and +-- more functionality gets dropped so maybe at some point we need to ship our own dll/so +-- files. +-- +-- An increase in the number of built in styles made our own crash (probably due to some +-- maximum being reached) so some measures has been taken. We now get pretty close to +-- replacing the main lexer.lua file. +-- -- Also needed: preamble scan once. Can be handled in caller below and _M.preamble. -- -- For huge files folding can be pretty slow and I do have some large ones that I keep @@ -37,10 +45,10 @@ local info = { -- is used to revert to a parent lexer we need to make sure that we load children as late -- as possible in order not to get the wrong whitespace trigger. This took me quite a while -- to figure out (not being that familiar with the internals). The lex and fold functions --- hav ebeen optimized. It is a pitty that there is no proper print available. +-- have been optimized. It is a pitty that there is no proper print available. -- Maybe it's safer to copy the other methods here so that we have no dependencies, apart --- from the the library. +-- from the c library. -- Something is wrong with folds in combination with scite 3.00. @@ -51,8 +59,12 @@ local concat = table.concat local global = _G local type, next, setmetatable, rawset = type, next, setmetatable, rawset -if not lexer then +if lexer then + -- we're ok +elseif _LEXERHOME then dofile(_LEXERHOME .. '/lexer.lua') -- pre 3.03 situation +else + dofile('lexer.lua') -- whatever end lexer.context = lexer.context or { } @@ -65,48 +77,23 @@ lexer._CONTEXTEXTENSIONS = true local locations = { -- lexer.context.path, - _LEXERHOME .. "/data", -- optional data directory - _LEXERHOME .. "/..", -- regular scite directory + "data", -- optional data directory + "..", -- regular scite directory } local function collect(name) - local definitions = loadfile(name .. ".luc") or loadfile(name .. ".lua") - if type(definitions) == "function" then - definitions = definitions() - end - if type(definitions) == "table" then - return definitions - else - return nil +-- local definitions = loadfile(name .. ".luc") or loadfile(name .. ".lua") + local okay, definitions = pcall(function () return require(name) end) + if okay then + if type(definitions) == "function" then + definitions = definitions() + end + if type(definitions) == "table" then + return definitions + end end end --- local function exists(name) --- local f = global.io.open(name) --- return f and true or false --- end --- --- local function collect(name) --- local f = global.io.open(name .. ".properties") --- if f then --- local result = { } --- local data = gsub(f:read("*all") or "","\\ *[\n\r]+"," ") --- for name, words in gmatch(data,".-([^%.]-)=(.-)\n") do --- if name ~= "all" then --- local list = { } --- for word in gmatch(words,"([^ ]+)") do --- list[#list+1] = word --- end --- result[name] = list --- end --- end --- f:close() --- if next(result) then --- return result --- end --- end --- end - function context.loaddefinitions(name) for i=1,#locations do local data = collect(locations[i] .. "/" .. name) @@ -719,3 +706,9 @@ patterns.invisibles = lpeg.utfchartabletopattern { patterns.iwordtoken = patterns.wordtoken - patterns.invisibles patterns.iwordpattern = patterns.iwordtoken^3 + +-- require("themes/scite-context-theme") + +-- In order to deal with some bug in additional styles (I have no cue what is +-- wrong, but additional styles get ignored and clash somehow) I just copy the +-- original lexer code ... see original for comments. diff --git a/context/data/scite/lexers/themes/scite-context-theme-keep.lua b/context/data/scite/lexers/themes/scite-context-theme-keep.lua new file mode 100644 index 000000000..7f9423d9a --- /dev/null +++ b/context/data/scite/lexers/themes/scite-context-theme-keep.lua @@ -0,0 +1,233 @@ +local info = { + version = 1.002, + comment = "theme for scintilla lpeg lexer for context/metafun", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files", +} + +-- context_path = string.split(os.resultof("mtxrun --find-file context.mkiv"))[1] or "" +-- global.trace("OEPS") -- how do we get access to the regular lua extensions + +-- The regular styles set the main lexer styles table but we avoid that in order not +-- to end up with updating issues. We just use another table. + +-- if not lexer._CONTEXTEXTENSIONS then require("scite-context-lexer") end + +local context_path = "t:/sources" -- c:/data/tex-context/tex/texmf-context/tex/base +local font_name = 'Dejavu Sans Mono' +local font_size = 14 + +if not WIN32 then + font_name = '!' .. font_name +end + +local color = lexer.color +local style = lexer.style + +lexer.context = lexer.context or { } +local context = lexer.context + +context.path = context_path + +colors = { + red = color('7F', '00', '00'), + green = color('00', '7F', '00'), + blue = color('00', '00', '7F'), + cyan = color('00', '7F', '7F'), + magenta = color('7F', '00', '7F'), + yellow = color('7F', '7F', '00'), + orange = color('B0', '7F', '00'), + -- + white = color('FF', 'FF', 'FF'), + light = color('CF', 'CF', 'CF'), + grey = color('80', '80', '80'), + dark = color('4F', '4F', '4F'), + black = color('00', '00', '00'), + -- + selection = color('F7', 'F7', 'F7'), + logpanel = color('E7', 'E7', 'E7'), + textpanel = color('CF', 'CF', 'CF'), + linepanel = color('A7', 'A7', 'A7'), + tippanel = color('44', '44', '44'), + -- + right = color('00', '00', 'FF'), + wrong = color('FF', '00', '00'), +} + +colors.teal = colors.cyan +colors.purple = colors.magenta + +-- to be set: +-- +-- style_nothing +-- style_class +-- style_comment +-- style_constant +-- style_definition +-- style_error +-- style_function +-- style_keyword +-- style_number +-- style_operator +-- style_string +-- style_preproc +-- style_tag +-- style_type +-- style_variable +-- style_embedded +-- style_label +-- style_regex +-- style_identifier +-- +-- style_line_number +-- style_bracelight +-- style_bracebad +-- style_controlchar +-- style_indentguide +-- style_calltip + +style_default = style { + font = font_name, + size = font_size, + fore = colors.black, + back = colors.textpanel, +} + +style_nothing = style { + -- empty +} + +style_number = style { fore = colors.cyan } +style_comment = style { fore = colors.yellow } +style_string = style { fore = colors.magenta } +style_keyword = style { fore = colors.blue, bold = true } + +style_quote = style { fore = colors.blue, bold = true } +style_special = style { fore = colors.blue } +style_extra = style { fore = colors.yellow } + +style_embedded = style { fore = colors.black, bold = true } + +style_char = style { fore = colors.magenta } +style_reserved = style { fore = colors.magenta, bold = true } +style_class = style { fore = colors.black, bold = true } +style_constant = style { fore = colors.cyan, bold = true } +style_definition = style { fore = colors.black, bold = true } +style_okay = style { fore = colors.dark } +style_error = style { fore = colors.red } +style_warning = style { fore = colors.orange } +style_invisible = style { back = colors.orange } +style_function = style { fore = colors.black, bold = true } +style_operator = style { fore = colors.blue } +style_preproc = style { fore = colors.yellow, bold = true } +style_tag = style { fore = colors.cyan } +style_type = style { fore = colors.blue } +style_variable = style { fore = colors.black } +style_identifier = style_nothing + +style_standout = style { fore = colors.orange, bold = true } + +style_line_number = style { back = colors.linepanel } +style_bracelight = style_standout +style_bracebad = style_standout +style_indentguide = style { fore = colors.linepanel, back = colors.white } +style_calltip = style { fore = colors.white, back = colors.tippanel } +style_controlchar = style_nothing + +style_label = style { fore = colors.red, bold = true } -- style { fore = colors.cyan, bold = true } +style_regex = style_string + +style_command = style { fore = colors.green, bold = true } + +-- only bold seems to work + +lexer.style_nothing = style_nothing +lexer.style_class = style_class +lexer.style_comment = style_comment +lexer.style_constant = style_constant +lexer.style_definition = style_definition +lexer.style_error = style_error +lexer.style_function = style_function +lexer.style_keyword = style_keyword +lexer.style_number = style_number +lexer.style_operator = style_operator +lexer.style_string = style_string +lexer.style_preproc = style_preproc +lexer.style_tag = style_tag +lexer.style_type = style_type +lexer.style_variable = style_variable +lexer.style_embedded = style_embedded +lexer.style_label = style_label +lexer.style_regex = style_regex +lexer.style_identifier = style_nothing + +local styles = { -- as we have globals we could do with less + + -- ["whitespace"] = style_whitespace, -- not to be set! + +["default"] = style_nothing, +["number"] = style_number, +["comment"] = style_comment, +["keyword"] = style_keyword, +["string"] = style_string, +["preproc"] = style_preproc, + + ["reserved"] = style_reserved, + ["internal"] = style_standout, + + ["command"] = style_command, + ["preamble"] = style_comment, + ["embedded"] = style_embedded, + ["grouping"] = style { fore = colors.red }, +["label"] = style_label, + ["primitive"] = style_keyword, + ["plain"] = style { fore = colors.dark, bold = true }, + ["user"] = style { fore = colors.green }, + ["data"] = style_constant, + ["special"] = style_special, + ["extra"] = style_extra, + ["quote"] = style_quote, + + ["okay"] = style_okay, + ["warning"] = style_warning, + ["invisible"] = style_invisible, +["error"] = style_error, + +} + +-- Old method (still available): + +local styleset = { } + +for k, v in next, styles do + styleset[#styleset+1] = { k, v } +end + +context.styles = styles +context.styleset = styleset + +-- We need to be sparse due to some limitation (and the number of built in styles +-- growing). + +-- function context.newstyleset(list) +-- local t = { } +-- if list then +-- for i=1,#list do +-- t[list[i]] = true +-- end +-- end +-- return t +-- end + +-- function context.usestyle(set,name) +-- set[name] = true +-- return name +-- end + +-- function context.usestyleset(set) +-- local t = { } +-- for k, _ in next, set do +-- t[#t+1] = { k, styles[k] or styles.default } +-- end +-- end diff --git a/context/data/scite/lexers/themes/scite-context-theme.lua b/context/data/scite/lexers/themes/scite-context-theme.lua index 240755382..fed7b0853 100644 --- a/context/data/scite/lexers/themes/scite-context-theme.lua +++ b/context/data/scite/lexers/themes/scite-context-theme.lua @@ -9,6 +9,11 @@ local info = { -- context_path = string.split(os.resultof("mtxrun --find-file context.mkiv"))[1] or "" -- global.trace("OEPS") -- how do we get access to the regular lua extensions +-- The regular styles set the main lexer styles table but we avoid that in order not +-- to end up with updating issues. We just use another table. + +if not lexer._CONTEXTEXTENSIONS then require("scite-context-lexer") end + local context_path = "t:/sources" -- c:/data/tex-context/tex/texmf-context/tex/base local font_name = 'Dejavu Sans Mono' local font_size = 14 @@ -17,17 +22,15 @@ if not WIN32 then font_name = '!' .. font_name end --- dofile(_LEXERHOME .. '/themes/scite.lua') -- starting point so we miss nothing +local color = lexer.color +local style = lexer.style --- module('lexer', package.seeall) +lexer.context = lexer.context or { } +local context = lexer.context -local color = lexer.color -local style = lexer.style +context.path = context_path -lexer.context = lexer.context or { } -lexer.context.path = context_path - -colors = { +local colors = { red = color('7F', '00', '00'), green = color('00', '7F', '00'), blue = color('00', '00', '7F'), @@ -55,87 +58,155 @@ colors = { colors.teal = colors.cyan colors.purple = colors.magenta -style_default = style { - font = font_name, - size = font_size, - fore = colors.black, - back = colors.textpanel, -} - -style_nothing = style { - -- empty -} - -style_number = style { fore = colors.cyan } -style_comment = style { fore = colors.yellow } -style_string = style { fore = colors.magenta } -style_keyword = style { fore = colors.blue, bold = true } - -style_char = style { fore = colors.magenta } -style_reserved = style { fore = colors.magenta, bold = true } -style_class = style { fore = colors.black, bold = true } -style_constant = style { fore = colors.cyan, bold = true } -style_definition = style { fore = colors.black, bold = true } -style_okay = style { fore = colors.dark } -style_error = style { fore = colors.red } -style_warning = style { fore = colors.orange } -style_invisible = style { back = colors.orange } -style_function = style { fore = colors.black, bold = true } -style_operator = style { fore = colors.blue } -style_preproc = style { fore = colors.yellow, bold = true } -style_tag = style { fore = colors.cyan } -style_type = style { fore = colors.blue } -style_variable = style { fore = colors.black } -style_identifier = style_nothing - -style_standout = style { fore = colors.orange, bold = true } - -style_line_number = style { back = colors.linepanel } -style_bracelight = style_standout -style_bracebad = style_standout -style_indentguide = style { fore = colors.linepanel, back = colors.white } -style_calltip = style { fore = colors.white, back = colors.tippanel } -style_controlchar = style_nothing - --- only bold seems to work - -lexer.context.styles = { - - -- ["whitespace"] = style_whitespace, - - ["default"] = style_nothing, - ["number"] = style_number, - ["comment"] = style_comment, - ["keyword"] = style_keyword, - ["string"] = style_string, +lexer.colors = colors + +-- defaults: + +local style_nothing = style { } +----- style_whitespace = style { } +local style_comment = style { fore = colors.yellow } +local style_string = style { fore = colors.magenta } +local style_number = style { fore = colors.cyan } +local style_keyword = style { fore = colors.blue, bold = true } +local style_identifier = style_nothing +local style_operator = style { fore = colors.blue } +local style_error = style { fore = colors.red } +local style_preproc = style { fore = colors.yellow, bold = true } +local style_constant = style { fore = colors.cyan, bold = true } +local style_variable = style { fore = colors.black } +local style_function = style { fore = colors.black, bold = true } +local style_class = style { fore = colors.black, bold = true } +local style_type = style { fore = colors.blue } +local style_label = style { fore = colors.red, bold = true } +local style_regex = style { fore = colors.magenta } + +-- reserved: + +local style_default = style { font = font_name, size = font_size, fore = colors.black, back = colors.textpanel } +local style_line_number = style { back = colors.linepanel } +local style_bracelight = style { fore = colors.orange, bold = true } +local style_bracebad = style { fore = colors.orange, bold = true } +local style_indentguide = style { fore = colors.linepanel, back = colors.white } +local style_calltip = style { fore = colors.white, back = colors.tippanel } +local style_controlchar = style_nothing + +-- extras: + +local style_quote = style { fore = colors.blue, bold = true } +local style_special = style { fore = colors.blue } +local style_extra = style { fore = colors.yellow } +local style_embedded = style { fore = colors.black, bold = true } +----- style_char = style { fore = colors.magenta } +local style_reserved = style { fore = colors.magenta, bold = true } +local style_definition = style { fore = colors.black, bold = true } +local style_okay = style { fore = colors.dark } +local style_warning = style { fore = colors.orange } +local style_invisible = style { back = colors.orange } +local style_tag = style { fore = colors.cyan } +----- style_standout = style { fore = colors.orange, bold = true } +local style_command = style { fore = colors.green, bold = true } +local style_internal = style { fore = colors.orange, bold = true } +local style_internal = style { fore = colors.orange, bold = true } + +local style_preamble = style { fore = colors.yellow } +local style_grouping = style { fore = colors.red } +local style_primitive = style { fore = colors.blue, bold = true } +local style_plain = style { fore = colors.dark, bold = true } +local style_user = style { fore = colors.green } +local style_data = style { fore = colors.cyan, bold = true } + + +-- used by the generic lexer: + +lexer.style_nothing = style_nothing -- 0 +-----.whitespace = style_whitespace -- 1 +lexer.style_comment = style_comment -- 2 +lexer.style_string = style_string -- 3 +lexer.style_number = style_number -- 4 +lexer.style_keyword = style_keyword -- 5 +lexer.style_identifier = style_nothing -- 6 +lexer.style_operator = style_operator -- 7 +lexer.style_error = style_error -- 8 +lexer.style_preproc = style_preproc -- 9 +lexer.style_constant = style_constant -- 10 +lexer.style_variable = style_variable -- 11 +lexer.style_function = style_function -- 12 +lexer.style_class = style_class -- 13 +lexer.style_type = style_type -- 14 +lexer.style_label = style_label -- 15 +lexer.style_regex = style_regexp -- 16 + +lexer.style_default = style_default -- 32 +lexer.style_line_number = style_line_number -- 33 +lexer.style_bracelight = style_bracelight -- 34 +lexer.style_bracebad = style_bracebad -- 35 +lexer.style_indentguide = style_indentguide -- 36 +lexer.style_calltip = style_calltip -- 37 +lexer.style_controlchar = style_controlchar -- 38 + +local styles = { -- as we have globals we could do with less + + -- ["whitespace"] = style_whitespace, -- not to be set! + -- ["default"] = style_nothing, + -- ["number"] = style_number, + -- ["comment"] = style_comment, + -- ["keyword"] = style_keyword, + -- ["string"] = style_string, + -- ["preproc"] = style_preproc, + -- ["error"] = style_error, + -- ["label"] = style_label, + + ["quote"] = style_quote, + ["special"] = style_special, + ["extra"] = style_extra, + ["embedded"] = style_embedded, + -- ["char"] = style_char, ["reserved"] = style_reserved, - ["preproc"] = style_preproc, - ["internal"] = style_standout, - - ["command"] = style { fore = colors.green, bold = true }, - ["preamble"] = style_comment, - ["embedded"] = style { fore = colors.black, bold = true }, - ["grouping"] = style { fore = colors.red }, - ["label"] = style { fore = colors.red, bold = true }, - ["primitive"] = style_keyword, - ["plain"] = style { fore = colors.dark, bold = true }, - ["user"] = style { fore = colors.green }, - ["data"] = style_constant, - ["special"] = style { fore = colors.blue }, - ["extra"] = style { fore = colors.yellow }, - ["quote"] = style { fore = colors.blue, bold = true }, - + -- ["definition"] = style_definition, ["okay"] = style_okay, ["warning"] = style_warning, ["invisible"] = style_invisible, - ["error"] = style_error, + -- ["standout"] = style_standout, + ["command"] = style_command, + ["internal"] = style_internal, + ["preamble"] = style_preamble, + ["grouping"] = style_grouping, + ["primitive"] = style_primitive, + ["plain"] = style_plain, + ["user"] = style_user, + ["data"] = style_data, } local styleset = { } -for k, v in next, lexer.context.styles do +for k, v in next, styles do styleset[#styleset+1] = { k, v } end -lexer.context.styleset = styleset +context.styles = styles +context.styleset = styleset + +-- We can be sparse if needed: + +-- function context.newstyleset(list) +-- local t = { } +-- if list then +-- for i=1,#list do +-- t[list[i]] = true +-- end +-- end +-- return t +-- end + +-- function context.usestyle(set,name) +-- set[name] = true +-- return name +-- end + +-- function context.usestyleset(set) +-- local t = { } +-- for k, _ in next, set do +-- t[#t+1] = { k, styles[k] or styles.default } +-- end +-- end diff --git a/context/data/scite/scite-context-external.properties b/context/data/scite/scite-context-external.properties index b492e2932..d0e6fc9c5 100644 --- a/context/data/scite/scite-context-external.properties +++ b/context/data/scite/scite-context-external.properties @@ -6,7 +6,7 @@ lexer.lpeg.home=$(SciteDefaultHome)/lexers # # pre 3.03: # -# lexer.lpeg.script=$(lexer.lpeg.home)/scite-context-lexer.lua +#~ lexer.lpeg.script=$(lexer.lpeg.home)/scite-context-lexer.lua # # # post 3.03: # diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 248c0107b..400da4681 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{2012.04.10 19:46} +\newcontextversion{2012.04.13 09:31} %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 f448ff2bc..bb8c36d80 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{2012.04.10 19:46} +\newcontextversion{2012.04.13 09:31} %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 Binary files differindex 780c1383e..9a4d50823 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png Binary files differindex 65b97446a..b77a96efd 100644 --- a/tex/context/base/context-version.png +++ b/tex/context/base/context-version.png diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index 928349049..3f9fd06a1 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{2012.04.10 19:46} +\edef\contextversion{2012.04.13 09:31} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 7cfadf849..45f470307 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -23,7 +23,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2012.04.10 19:46} +\edef\contextversion{2012.04.13 09:31} %D For those who want to use this: diff --git a/tex/context/base/spac-ali.mkiv b/tex/context/base/spac-ali.mkiv index 6bfba019f..93f00249c 100644 --- a/tex/context/base/spac-ali.mkiv +++ b/tex/context/base/spac-ali.mkiv @@ -831,21 +831,17 @@ \installcorenamespace{alignline} -\letvalue{\??alignline\v!middle }\midaligned -\letvalue{\??alignline\v!center }\midaligned -\letvalue{\??alignline\v!max }\maxaligned +\letvalue{\??alignline\v!middle}\midaligned +\letvalue{\??alignline\v!center}\midaligned +\letvalue{\??alignline\v!max }\maxaligned +\letvalue{\??alignline\v!left }\leftaligned +\letvalue{\??alignline\v!right }\rightaligned -% was wrong +% not here, as here we use a location % -% \letvalue{\??alignline\v!left }\leftaligned -% \letvalue{\??alignline\v!right }\rightaligned % \letvalue{\??alignline\v!flushleft }\rightaligned % \letvalue{\??alignline\v!flushright}\leftaligned -\letvalue{\??alignline\v!left }\rightaligned -\letvalue{\??alignline\v!right }\leftaligned -\letvalue{\??alignline\v!flushleft }\leftaligned -\letvalue{\??alignline\v!flushright}\rightaligned \def\doalignedline#1{\resetrealignsignal\csname\??alignline#1\endcsname} diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex 71a070346..9a71e6cee 100644 --- a/tex/context/base/status-files.pdf +++ b/tex/context/base/status-files.pdf diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf Binary files differindex c3da827ec..bef2e3e96 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/x-pfs-01.mkiv b/tex/context/base/x-pfs-01.mkiv index 57f1f1b3d..8b06bd873 100644 --- a/tex/context/base/x-pfs-01.mkiv +++ b/tex/context/base/x-pfs-01.mkiv @@ -1,6 +1,12 @@ % pfsense status info, work in progress % +% usage: +% % context --environment=x-pfs-01 filename.xml +% +% or +% +% <?context-directive job ctxfile x-pfsense.ctx ?> \setupbodyfont [dejavu,10pt] @@ -8,9 +14,14 @@ \setuplayout [topspace=1cm, backspace=1cm, + footer=0pt, + header=1cm, width=middle, height=middle] +\setupheader + [style=bold] + \setuphead [section] [style=\bfb] @@ -24,6 +35,145 @@ \dontcomplain +% todo: show all values and map keys onto longer names via labels + +\startxmlsetups xml:system + + \startsection[title={System}] + + \startsubsection[title={Properties}] + + \starttabulate[|B|T|] + \NC hostname \NC \xmlfirst{#1}{hostname} \NC \NR + \NC domain \NC \xmlfirst{#1}{domain} \NC \NR + \NC timezone \NC \xmlfirst{#1}{timezone} \NC \NR + \NC timeservers \NC \xmlfirst{#1}{timeservers} \NC \NR + \NC dnsserver \NC \xmlfirst{#1}{dnsserver} \NC \NR + \stoptabulate + + \stopsubsection + + \startsubsection[title={Groups}] + \xmlfilter{#1}{group/command(xml:system:group)} + \stopsubsection + + \startsubsection[title={Users}] + \xmlfilter{#1}{user/command(xml:system:user)} + \stopsubsection + + \stopsection + +\stopxmlsetups + +\startxmlsetups xml:system:group + + \starttabulate[|B|T|] + \NC name \NC \xmlfirst{#1}{/name} \NC \NR + \NC description \NC \xmlfirst{#1}{/descr} \NC \NR + \NC scope \NC \xmlfirst{#1}{/scope} \NC \NR + \NC gid \NC \xmlfirst{#1}{/gid} \NC \NR + \NC privilege \NC \xmlfirst{#1}{/priv} \NC \NR + \NC members \NC \xmlconcat{#1}{/member}{ } \NC \NR + \stoptabulate + +\stopxmlsetups + +\startxmlsetups xml:system:user + + \starttabulate[|B|T|] + \NC name \NC \xmlfirst{#1}{/name} \NC \NR + \NC description \NC \xmlfirst{#1}{/descr} \NC \NR + \NC scope \NC \xmlfirst{#1}{/scope} \NC \NR + \NC uid \NC \xmlfirst{#1}{/uid} \NC \NR + \NC group \NC \xmlfirst{#1}{/groupname} \NC \NR + \NC privilege \NC \xmlfirst{#1}{/priv} \NC \NR + \NC password \NC \xmldoifelsetext{#1}{/password}{set}{unset} \NC \NR + \NC ipsec psk \NC \xmldoifelsetext{#1}{/ipsecpsk}{set}{unset} \NC \NR + \NC certificate \NC \xmldoifelsetext{#1}{/cert} {set}{unset} \NC \NR + \stoptabulate + +\stopxmlsetups + +\startxmlsetups xml:interfaces + + \startsection[title={Interfaces}] + + \xmlfilter{#1}{*/command(xml:interfaces:network)} + + \stopsection + +\stopxmlsetups + +\startxmlsetups xml:interfaces:network + + \startsubsection[title={\xmltag{#1}}] + + % <blockpriv/> <blockbogons/> <spoofmac/> <enable/> + + \starttabulate[|B|T|] + \NC interface \NC \xmlfirst{#1}{/if} \NC \NR + \NC block private \NC \xmldoifelse{#1}{/blockpriv} {yes}{no} \NC \NR + \NC block bogons \NC \xmldoifelse{#1}{/blockbogons}{yes}{no} \NC \NR + \NC spoof mac address \NC \xmldoifelse{#1}{/spoofmac} {yes}{no} \NC \NR + \NC enable interface \NC \xmldoifelse{#1}{/enable} {yes}{no} \NC \NR + \NC ipaddress \NC \xmlfirst{#1}{/ipaddr} \NC \NR + \NC subnet \NC \xmlfirst{#1}{/subnet} \NC \NR + \NC gateway \NC \xmlfirst{#1}{/gateway} \NC \NR + \NC description \NC \xmlfirst{#1}{/descr} \NC \NR + \stoptabulate + + \stopsubsection + +\stopxmlsetups + +\startxmlsetups xml:gateways + + \startsection[title={Gateways}] + + \xmlfilter{#1}{*/command(xml:gateways:entry)} + + \stopsection + +\stopxmlsetups + +\startxmlsetups xml:gateways:entry + + \starttabulate[|B|T|] + \NC interface \NC \xmlfirst{#1}{/interface} \NC \NR + \NC gateway \NC \xmlfirst{#1}{/gateway} \NC \NR + \NC name \NC \xmlfirst{#1}{/name} \NC \NR + \NC weight \NC \xmlfirst{#1}{/weight} \NC \NR + \NC interval \NC \xmlfirst{#1}{/interval} \NC \NR + \NC description \NC \xmlfirst{#1}{/descr} \NC \NR + \NC disable monitor \NC \xmlfirst{#1}{/monitor_disable} \NC \NR + \NC default gateway \NC \xmlfirst{#1}{/defaultgw} \NC \NR + \stoptabulate + +\stopxmlsetups + +\startxmlsetups xml:virtualips + + \startsection[title={Virtual ipadresses}] + + \xmlfilter{#1}{*/command(xml:virtualips:entry)} + + \stopsection + +\stopxmlsetups + +\startxmlsetups xml:virtualips:entry + + \starttabulate[|B|T|] + \NC interface \NC \xmlfirst{#1}{/interface} \NC \NR + \NC type \NC \xmlfirst{#1}{/type} \NC \NR + \NC mode \NC \xmlfirst{#1}{/mode} \NC \NR + \NC subnet \NC \xmlfirst{#1}{/subnet} + /\xmlfirst{#1}{/subnet_bits} \NC \NR + \NC description \NC \xmlfirst{#1}{/descr} \NC \NR + \stoptabulate + +\stopxmlsetups + \startxmlsetups xml:dhcp \startsection[title={DHCP}] @@ -38,17 +188,17 @@ \startsubsection[title={\xmltag{#1}}] - \starttabulate[||T|] - \NC \bf range \NC \xmlfirst{#1}{/range/from} \endash\ \xmlfirst{#1}{/range/to} \NC \NR - \NC \bf domain \NC \xmlfirst{#1}{/domain} \NC \NR - \NC \bf dnsserver \NC \xmlfirst{#1}{/dnsserver} \NC \NR - \NC \bf gateway \NC \xmlfirst{#1}{/gateway} \NC \NR - \NC \bf ddnsdomain \NC \xmlfirst{#1}{/ddnsdomain} \NC \NR + \starttabulate[|B|T|] + \NC range \NC \xmlfirst{#1}{/range/from} \endash\ \xmlfirst{#1}{/range/to} \NC \NR + \NC domain \NC \xmlfirst{#1}{/domain} \NC \NR + \NC dnsserver \NC \xmlfirst{#1}{/dnsserver} \NC \NR + \NC gateway \NC \xmlfirst{#1}{/gateway} \NC \NR + \NC ddnsdomain \NC \xmlfirst{#1}{/ddnsdomain} \NC \NR \stoptabulate \xmldoif {#1} {/staticmap} { - \starttabulate[|T|T|T|P|] + \starttabulate[|T|T|T|p|] \NC \rm\bf macaddress \NC \rm\bf ipaddress \NC \rm\bf hostname @@ -78,7 +228,7 @@ \startsection[title={DNS MASQ}] - \starttabulate[|T|T|T|P|] + \starttabulate[|T|T|T|p|] \NC \rm\bf host \NC \rm\bf domain \NC \rm\bf ipaddress @@ -107,26 +257,44 @@ \startsection[title={NAT}] - \starttabulate[|T|T|T|T|T|P|] - \NC \rm\bf interface - \NC \rm\bf protocol - \NC \rm\bf source - \NC \rm\bf destination - \NC \rm\bf target - \NC \rm\bf description - \NC \NR - \HL - \xmlfilter{#1}{/rule/command(xml:nat:rule)} - \stoptabulate + \startsubsection[title={Rules}] - \stopsection + \starttabulate[|T|T|T|T|T|p|] + \NC \rm\bf interface + \NC \rm\bf protocol + \NC \rm\bf source + \NC \rm\bf destination + \NC \rm\bf target + \NC \rm\bf description + \NC \NR + \HL + \xmlfilter{#1}{/rule/command(xml:nat:rule)} + \stoptabulate + + \stopsubsection + + \startsubsection[title={One to one}] + + \starttabulate[|T|T|T|T|T|p|] + \NC \rm\bf interface + \NC \rm\bf protocol + \NC \rm\bf source + \NC \rm\bf destination + \NC \rm\bf external + \NC \rm\bf description + \NC \NR + \HL + \xmlfilter{#1}{/onetoone/command(xml:nat:onetoone)} + \stoptabulate + + \stopsubsection + +\stopsection \stopxmlsetups \startxmlsetups xml:nat:rule - % any - \NC \xmlfilter{#1}{/interface/command(xml:checked)} \NC \xmlfilter{#1}{/protocol/command(xml:checked)} \NC \xmlfilter{#1}{/source/command(xml:checked)} @@ -139,6 +307,20 @@ \stopxmlsetups +\startxmlsetups xml:nat:onetoone + + \NC \xmlfilter{#1}{/interface/command(xml:checked)} + \NC \xmlfilter{#1}{/protocol/command(xml:checked)} + \NC \xmlfilter{#1}{/source/command(xml:checked)} + \NC \xmlfilter{#1}{/destination/(address|any)/command(xml:checked)} + :\xmlfilter{#1}{/destination/port/command(xml:checked)} + \NC \xmlfilter{#1}{/external/command(xml:checked)} + :\xmlfilter{#1}{/local-port/command(xml:checked)} + \NC \xmlfirst {#1}{/descr} + \NC \NR + +\stopxmlsetups + \startxmlsetups xml:checked \xmldoifelse {#1} {/any} { * @@ -151,6 +333,44 @@ } \stopxmlsetups +\startxmlsetups xml:filter + + \startsection[title={Filter}] + + \startsubsection[title={Rules}] + + \starttabulate[|T|T|T|T|T|p|] + \NC \rm\bf type + \NC \rm\bf interface + \NC \rm\bf protocol + \NC \rm\bf source + \NC \rm\bf destination + \NC \rm\bf description + \NC \NR + \HL + \xmlfilter{#1}{/rule/command(xml:filter:rule)} + \stoptabulate + + \stopsubsection + + \stopsubsection + +\stopxmlsetups + +\startxmlsetups xml:filter:rule + + \NC \xmlfilter{#1}{/type/command(xml:checked)} + \NC \xmlfilter{#1}{/interface/command(xml:checked)} + \NC \xmlfilter{#1}{/protocol/command(xml:checked)} + \NC \xmlfilter{#1}{/source/(address|any)/command(xml:checked)}: + :\xmlfilter{#1}{/source/port/command(xml:checked)} + \NC \xmlfilter{#1}{/destination/(address|any)/command(xml:checked)} + :\xmlfilter{#1}{/destination/port/command(xml:checked)} + \NC \xmlfirst {#1}{/descr} + \NC \NR + +\stopxmlsetups + \starttext \doifelse {\inputfilename} {x-pfs-01.mkiv} { @@ -163,12 +383,17 @@ \xmlloadonly{main}{\inputfilename}{} - \setupheadertexts[router.xml][\pagenumber] + \setupheadertexts[\inputfilename][\pagenumber] } + \xmlfilter{main}{/pfsense/system/command(xml:system)} + \xmlfilter{main}{/pfsense/interfaces/command(xml:interfaces)} + \xmlfilter{main}{/pfsense/gateways/command(xml:gateways)} + \xmlfilter{main}{/pfsense/virtualip/command(xml:virtualips)} \xmlfilter{main}{/pfsense/dhcpd/command(xml:dhcp)} \xmlfilter{main}{/pfsense/dnsmasq/command(xml:dnsmasq)} \xmlfilter{main}{/pfsense/nat/command(xml:nat)} + \xmlfilter{main}{/pfsense/filter/command(xml:filter)} \stoptext diff --git a/tex/context/base/x-pfsense.ctx b/tex/context/base/x-pfsense.ctx new file mode 100644 index 000000000..8d7087cf2 --- /dev/null +++ b/tex/context/base/x-pfsense.ctx @@ -0,0 +1,15 @@ +<?xml version='1.0' standalone='yes'?> + +<!-- this is also a demo of using the xml interface --> + +<ctx:job> + <ctx:message>pfsense configuration listing</ctx:message> + <ctx:process> + <ctx:flags> + <ctx:flag>purge</ctx:flag> + </ctx:flags> + <ctx:resources> + <ctx:environment>x-pfs-01.mkiv</ctx:environment> + </ctx:resources> + </ctx:process> +</ctx:job> diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 85a03be6c..360cd67c0 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/10/12 19:46:21 +-- merge date : 04/13/12 09:31:06 do -- begin closure to overcome local limits and interference |