diff options
author | Karl Berry <karl@freefriends.org> | 2017-04-19 23:04:15 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-04-19 23:04:15 +0000 |
commit | f74161ca4e7eb3c5af9afcbe92522ae3b58987c1 (patch) | |
tree | 3c30a13df5ac7968195c85070a2b074578e669d2 /Master/texmf-dist/tex/context/modules/mkiv/m-scite.mkiv | |
parent | 1d5a55ac8f5506a7ae9cfca52f4b588182e199d4 (diff) |
context beta/cont-tmf.zip (Apr 16 12:55)
git-svn-id: svn://tug.org/texlive/trunk@43931 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/modules/mkiv/m-scite.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/modules/mkiv/m-scite.mkiv | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/m-scite.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/m-scite.mkiv index e033235c313..a7d9f8b5c3e 100644 --- a/Master/texmf-dist/tex/context/modules/mkiv/m-scite.mkiv +++ b/Master/texmf-dist/tex/context/modules/mkiv/m-scite.mkiv @@ -56,12 +56,14 @@ buffers.scite = scite -- context output: -local f_def_color = formatters["\\definecolor[slxc%s][h=%s%s%s]%%"] -local f_fore_none = formatters["\\def\\slx%s#1{{\\slxc%s#1}}%%"] -local f_fore_bold = formatters["\\def\\slx%s#1{{\\slxc%s\\bf#1}}%%"] -local f_none_bold = formatters["\\def\\slx%s#1{{\\bf#1}}%%"] -local f_none_none = formatters["\\def\\slx%s#1{{#1}}%%"] +local f_def_color = formatters["\\definecolor[slxc%s][h=%02X%02X%02X]%%"] +local f_fore_none = formatters["\\unexpanded\\def\\slx%s#1{{\\slxc%s#1}}%%"] +local f_fore_bold = formatters["\\unexpanded\\def\\slx%s#1{{\\slxc%s\\bf#1}}%%"] +local f_none_bold = formatters["\\unexpanded\\def\\slx%s#1{{\\bf#1}}%%"] +local f_none_none = formatters["\\unexpanded\\def\\slx%s#1{{#1}}%%"] local f_texstyled = formatters["\\slx%s{%s}"] +local f_hanging = formatters["\\slxb{%s}%s\\slxe"] + local f_mapping = [[ \let\string\slxL\string\letterleftbrace @@ -88,7 +90,7 @@ local replacer = lpeg.replacer { ["\\"] = "\\slxB ", ["%"] = "\\slxP ", ["~"] = "\\slxT ", - [" "] = "\\slxS ", + [" "] = "\\slxS ", -- can be made more efficient: \\slxF{n} } local colors = nil @@ -97,14 +99,14 @@ local function exportcolors() if not colors then scite.loadscitelexer() local function black(f) - return (f[1] == f[2]) and (f[2] == f[3]) and (f[3] == '00') + return (f[1] == f[2]) and (f[2] == f[3]) and (f[3] == 0) end local result, r = { f_mapping }, 1 for k, v in table.sortedhash(lexer.context.styles) do local fore = v.fore if fore and not black(fore) then r = r + 1 - result[r] = f_def_color(k,fore[1],fore[2],fore[3]) + result[r] = f_def_color(k,fore[1],fore[2] or fore[1],fore[3] or fore[1]) end end r = r + 1 @@ -165,20 +167,28 @@ function scite.installcommands() context(exportcolors()) end -local p = lpeg.P("\\slxS ")^1 +local p1 = lpeg.tsplitat(lpeg.patterns.newline) +local p2 = lpeg.P("\\slxS ")^1 +local p3 = lpeg.Cs((lpeg.Cp() * lpeg.P(" ") * lpeg.Cp() / function(b,e) return "\\slxF{" .. (e-b-1) .. "}" end + + (1-lpeg.P(" "))^1)^0) + +-- slxb could have a \hskip so then we can replace the slxS's local function indent(str) - local l = string.split(str,"\n") + local l = lpegmatch(p1,str) for i=1,#l do local s = l[i] if #s > 0 then - local n = lpegmatch(p,s) + local n = lpegmatch(p2,s) if n then n = (n-1)/6 else n = 0 end - l[i] = formatters["\\slxb{%s}%s\\slxe"](n,s) +s = lpegmatch(p3,s) -- can be combined + l[i] = f_hanging(n,s) -- "\\slxb{%s}%s\\slxe " +-- print(">",s) +-- print("<",l[i]) end end return concat(l,"\n") @@ -208,10 +218,12 @@ end \unprotect +\newdimen\scitespaceskip + \unexpanded\def\buff_scite_slxb#1% {%\begingroup - \hangindent\dimexpr\numexpr#1+1\relax\emwidth\relax - \hangafter \numexpr\numexpr#1+1\relax} + \hangindent\numexpr#1+2\relax\scitespaceskip + \hangafter 1\relax} \unexpanded\def\buff_scite_slxe {\par @@ -220,7 +232,9 @@ end \unexpanded\def\installscitecommands {\ctxlua{buffers.scite.installcommands()}% \let\installscitecommands\relax - \def\slxS{\fixedspace\allowbreak}% + \scitespaceskip\fontcharwd\font`0\relax + \unexpanded\def\slxS{\hskip\scitespaceskip}% + \unexpanded\def\slxF##1{\hskip##1\scitespaceskip\relax}% \let\slxb\buff_scite_slxb \let\slxe\buff_scite_slxe} @@ -248,7 +262,7 @@ end \raggedright \startcontextcode \startlines - \getbuffer[lex]% + \getbuffer[lex] \stoplines \stopcontextcode \stop} |