summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/third
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-08-12 23:14:03 +0000
committerKarl Berry <karl@freefriends.org>2011-08-12 23:14:03 +0000
commit3affad3394ee81c3f5ba136242d5d56949254515 (patch)
treea0a6e75f758b5c846182e833f658014df28cba23 /Master/texmf-dist/tex/context/third
parentc74165f3bdbaaefef4e594d6dbc2ad7b13292bbb (diff)
context-vim (11aug11)
git-svn-id: svn://tug.org/texlive/trunk@23523 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/third')
-rw-r--r--Master/texmf-dist/tex/context/third/vim/2context.vim37
-rw-r--r--Master/texmf-dist/tex/context/third/vim/t-syntax-highlight.tex41
-rw-r--r--Master/texmf-dist/tex/context/third/vim/t-vim.tex18
3 files changed, 82 insertions, 14 deletions
diff --git a/Master/texmf-dist/tex/context/third/vim/2context.vim b/Master/texmf-dist/tex/context/third/vim/2context.vim
index 0e29c46c5bf..ad41dc5c375 100644
--- a/Master/texmf-dist/tex/context/third/vim/2context.vim
+++ b/Master/texmf-dist/tex/context/third/vim/2context.vim
@@ -19,24 +19,41 @@ wincmd p
" If contextstartline and contextstartline are set, use them.
if exists("contextstartline")
- let s:lnum = max([1, min([line("$"), contextstartline]) ])
+ let s:lstart = max([1, min([line("$"), contextstartline]) ])
else
- let s:lnum = 1
+ let s:lstart = 1
endif
if exists("contextstopline")
if contextstopline <= 0
let contextstopline = line("$") + contextstopline
endif
- let s:end = min([line("$"), max([s:lnum, contextstopline]) ])
+ let s:lstop = min([line("$"), max([s:lstart, contextstopline]) ])
else
- let s:end = line("$")
+ let s:lstop = line("$")
endif
-let s:buffer_lnum = 1
+let s:strip = strlen( matchstr( getline(s:lstart), '^\s*' ) )
+
+" Find the smallest leading white space
+if exists("strip") && strip && (s:strip != 0)
+ echo "In the loop"
+ for s:lnum in range(s:lstart, s:lstop)
+ let s:line = getline(s:lnum)
+ let s:space = matchstr(s:line, '^\s*')
+ let s:len = strlen(s:space)
+ echo s:len
+ let s:strip = min(s:strip, s:len)
+ endfor
+else
+ let s:strip = 0
+endif
" Loop over all lines in the original text.
-while s:lnum <= s:end
+let s:buffer_lnum = 1
+let s:lnum = s:lstart
+
+while s:lnum <= s:lstop
" Get the current line
let s:line = getline(s:lnum)
let s:len = strlen(s:line)
@@ -90,6 +107,14 @@ while s:lnum <= s:end
let s:idx = stridx(strpart(s:line, s:start), "\t")
endwhile
+" Remove leading whitespace
+ let s:new = substitute(s:new, '^\s\{' . s:strip . '\}', "", "")
+
+" Highlight line, if needed.
+ if (index(highlight, s:lnum) != -1)
+ let s:new = '\HGL{' . s:new . '}'
+ endif
+
" Go back and paste the current line
wincmd p
call append (s:buffer_lnum-1, s:new)
diff --git a/Master/texmf-dist/tex/context/third/vim/t-syntax-highlight.tex b/Master/texmf-dist/tex/context/third/vim/t-syntax-highlight.tex
index 35f24c656d7..bd2d75cebf8 100644
--- a/Master/texmf-dist/tex/context/third/vim/t-syntax-highlight.tex
+++ b/Master/texmf-dist/tex/context/third/vim/t-syntax-highlight.tex
@@ -1,6 +1,6 @@
%D \module
%D [ file=t-syntax-highlight,
-%D version=2011.06.14,
+%D version=2011.08.10,
%D title=\CONTEXT\ User Module,
%D subtitle=Code syntax highlighting,
%D author=Aditya Mahajan,
@@ -20,6 +20,8 @@
\startinterface all
\setinterfaceconstant {syntax} {syntax}
+ \setinterfaceconstant {highlight} {highlight}
+ \setinterfaceconstant {highlightcolor} {highlightcolor}
\stopinterface
%D Name space
@@ -31,6 +33,10 @@
\installparameterhandler \syntaxhighlighting::namespace \syntaxhighlighting::id
\installsetuphandler \syntaxhighlighting::namespace \syntaxhighlighting::id
+%D Helper macro
+
+\def\syntaxhighlighting::yes{\v!yes,\v!on}
+
\def\definesyntaxhighlighting
{\dodoubleargument\syntaxhighlighting::define}
@@ -51,6 +57,7 @@
\edef\colorscheme::name{\externalfilterparameter\c!alternative}
\let\SYN\syntaxgroup
+ \let\HGL\syntaxhighlightline
\let\\\textbackslash
\let\{\textbraceleft
\let\}\textbraceright
@@ -92,7 +99,7 @@
{\newcount\syntaxhighlighting::linenumber}
\startsetups syntaxhighlighting::setup_line_number_mkii
-\doif{\externalfilterparameter\c!numbering}\v!yes
+\doifinset{\externalfilterparameter\c!numbering}\syntaxhighlighting::yes
{% setuplinenumbering resets \linenumber. So we save the value of linenumber and
% revert it back.
\syntaxhighlighting::linenumber=\linenumber
@@ -118,7 +125,7 @@
\startmode [\s!mkiv]
\starttexdefinition syntaxhighlighting::read_command #1
- \doifelse{\externalfilterparameter\c!numbering}\v!yes
+ \doifinsetelse{\externalfilterparameter\c!numbering}\syntaxhighlighting::yes
{\startlinenumbering
[\syntaxhighlighting::name]
[\c!continue=\externalfilterparameter{\c!number\c!continue}]
@@ -130,8 +137,8 @@
\startmode [\s!mkii]
\starttexdefinition syntaxhighlighting::read_command #1
- \doifelse{\externalfilterparameter\c!numbering}\v!yes
- {\doifelse{\externalfilterparameter{\c!number\c!continue}}\v!yes
+ \doifinsetelse{\externalfilterparameter\c!numbering}\syntaxhighlighting::yes
+ {\doifinsetelse{\externalfilterparameter{\c!number\c!continue}}\syntaxhighlighting::yes
{\startlinenumbering[\v!continue]}
{\startlinenumbering}
\syntaxhighlighting::read_command_aux{#1}
@@ -224,6 +231,30 @@
\installspacehandler {\syntaxhighlighting::namespace}
{\activatespacehandler {\syntaxhighlighting::namespace\v!off}}
+% Line highlighting
+% For MkIV, we can use the new bar mechanism to highlight a line.
+% For consistency, we use text background, which is slower but works for both
+% MkII and MkIV.
+
+% \startmode[*mkiv]
+% \definebar[syntaxhighlightline]
+% [\c!order=\v!background,
+% \c!rulethickness=2.5,
+% \c!offset=1.25,
+% \c!continue=\v!yes,
+% \c!color=\externalfilterparameter\c!highlightcolor,
+% ]
+% \stopmode
+
+\definetextbackground[syntaxhighlightline]
+ [\c!location=\v!paragraph,
+ \c!alternative=0,
+ \c!frame=\v!off,
+ \c!background=\v!color,
+ \c!backgroundcolor=\externalfilterparameter\c!highlightcolor,
+ ]
+
+
\protectmodulecatcodes
\stopmodule
diff --git a/Master/texmf-dist/tex/context/third/vim/t-vim.tex b/Master/texmf-dist/tex/context/third/vim/t-vim.tex
index f2713a0af1b..372219324dd 100644
--- a/Master/texmf-dist/tex/context/third/vim/t-vim.tex
+++ b/Master/texmf-dist/tex/context/third/vim/t-vim.tex
@@ -1,12 +1,12 @@
%D \module
%D [ file=t-vim,
-%D version=2011.06.14,
+%D version=2011.08.10,
%D title=\CONTEXT\ User Module,
%D subtitle=Vim syntax highlighting,
%D author=Aditya Mahajan,
%D date=\currentdate,
%D copyright=Aditya Mahajan,
-%D email=adityam <at> umich <dot> edu,
+%D email=adityam <at> ieee <dot> org,
%D license=Simplified BSD License]
\writestatus{loading}{ConTeXt User Module / Vim syntax highlighting}
@@ -38,7 +38,7 @@
\stoptexdefinition
% Mode to testing the dev version of 2context script.
-\doifmodeelse{vimtest}
+\doifmodeelse{vim-dev}
{\def\vimtyping::script_name{2context.vim}}
{\def\vimtyping::script_name{kpse:2context.vim}}
@@ -53,11 +53,20 @@
-c "set syntax=\externalfilterparameter\c!syntax" %
-c "let contextstartline=\externalfilterparameter\c!start" %
-c "let contextstopline=\externalfilterparameter\c!stop" %
+ -c "let strip=\getvalue{\vimtyping::id-\c!strip-\externalfilterparameter\c!strip}" %
+ -c "let highlight=[\externalfilterparameter\c!highlight]" %
-c "source \vimtyping::script_name" %
-c "qa" %
\externalfilterinputfile\space
\externalfilteroutputfile}
+\setvalue{\vimtyping::id-\c!strip-\v!off}{0}
+\setvalue{\vimtyping::id-\c!strip-\v!on}{1}
+
+% Undocumented ... but useful if the user makes a mistake
+\setvalue{\vimtyping::id-\c!strip-\v!no}{0}
+\setvalue{\vimtyping::id-\c!strip-\v!yes}{1}
+
\setupvimtyping
[% \c!tab=4,
% \c!start=1,
@@ -68,6 +77,9 @@
% \c!after=,
% \c!style=\tttf,
% \c!color=,
+ \c!strip=\v!off,
+ \c!highlight=,
+ \c!highlightcolor=lightgray,
\c!filtercommand=\vimtyping::filter_command,
% \c!continue=yes,
% \c!read=\v!yes,