Added GetLatestScript update plugin and updated all plugins

This commit is contained in:
Andrea Mistrali 2013-01-17 12:18:17 +00:00
parent d9013ec2da
commit 4873c64f28
54 changed files with 10380 additions and 4761 deletions

View File

@ -1,4 +1,7 @@
textformat.vba: call delete('/Users/andre/.vim/autoload/textformat.vim')|call delete('/Users/andre/.vim/doc/textformat.txt')|call delete('/Users/andre/.vim/plugin/textformat.vim')
conque_2.0.vba: call delete('/Users/andre/.vim/doc/conque_term.txt')|call delete('/Users/andre/.vim/syntax/conque_term.vim')|call delete('/Users/andre/.vim/autoload/conque_term/conque_screen.py')|call delete('/Users/andre/.vim/autoload/conque_term/conque_win32_util.py')|call delete('/Users/andre/.vim/autoload/conque_term/conque_sole_shared_memory.py')|call delete('/Users/andre/.vim/autoload/conque_term/conque.py')|call delete('/Users/andre/.vim/autoload/conque_term/conque_sole_wrapper.py')|call delete('/Users/andre/.vim/autoload/conque_term/conque_sole_communicator.py')|call delete('/Users/andre/.vim/autoload/conque_term/conque_sole.py')|call delete('/Users/andre/.vim/autoload/conque_term/conque_globals.py')|call delete('/Users/andre/.vim/autoload/conque_term/conque_subprocess.py')|call delete('/Users/andre/.vim/autoload/conque_term/conque_sole_subprocess.py')|call delete('/Users/andre/.vim/autoload/conque_term.vim')|call delete('/Users/andre/.vim/plugin/conque_term.vim')
conqueterm_2.2.vmb: call delete('/Users/andre/.vim/autoload/conque_term.vim')|call delete('/Users/andre/.vim/autoload/conque_term/conque_globals.py')|call delete('/Users/andre/.vim/autoload/conque_term/conque.py')|call delete('/Users/andre/.vim/autoload/conque_term/conque_screen.py')|call delete('/Users/andre/.vim/autoload/conque_term/conque_sole_communicator.py')|call delete('/Users/andre/.vim/autoload/conque_term/conque_sole.py')|call delete('/Users/andre/.vim/autoload/conque_term/conque_sole_shared_memory.py')|call delete('/Users/andre/.vim/autoload/conque_term/conque_sole_subprocess.py')|call delete('/Users/andre/.vim/autoload/conque_term/conque_sole_wrapper.py')|call delete('/Users/andre/.vim/autoload/conque_term/conque_subprocess.py')|call delete('/Users/andre/.vim/autoload/conque_term/conque_win32_util.py')|call delete('/Users/andre/.vim/doc/conque_term.txt')|call delete('/Users/andre/.vim/plugin/conque_term.vim')|call delete('/Users/andre/.vim/syntax/conque_term.vim')
Align.vba: call delete('/Users/andre/.vim/plugin/AlignPlugin.vim')|call delete('/Users/andre/.vim/plugin/AlignMapsPlugin.vim')|call delete('/Users/andre/.vim/plugin/cecutil.vim')|call delete('/Users/andre/.vim/doc/Align.txt')|call delete('/Users/andre/.vim/autoload/Align.vim')|call delete('/Users/andre/.vim/autoload/AlignMaps.vim')
cecutil.vba: call delete('/Users/andre/.vim/plugin/cecutil.vim')|call delete('/Users/andre/.vim/doc/cecutil.txt')
getscript.vba: call delete('/Users/andre/.vim/plugin/getscriptPlugin.vim')|call delete('/Users/andre/.vim/autoload/getscript.vim')|call delete('/Users/andre/.vim/GetLatest/GetLatestVimScripts.dist')|call delete('/Users/andre/.vim/doc/pi_getscript.txt')
textformat.vba: call delete('/Users/andre/.vim/autoload/textformat.vim')|call delete('/Users/andre/.vim/doc/textformat.txt')|call delete('/Users/andre/.vim/plugin/textformat.vim')
open_terminal.vba: call delete('/Users/andre/.vim/plugin/open_terminal.vim')|call delete('/Users/andre/.vim/doc/open_terminal.txt')

View File

@ -0,0 +1,12 @@
ScriptID SourceID Filename
--------------------------
910 18164 :AutoInstall: pydoc.vim
2771 16279 :AutoInstall: conque_term.vim
294 18148 :AutoInstall: Align.vim
1066 7618 :AutoInstall: cecutil.vim
642 15781 :AutoInstall: getscript.vim
2324 9247 :AutoInstall: TextFormat
1658 17123 :AutoInstall: NERD_tree.vim
1218 14455 :AutoInstall: NERD_commenter.vim
90 17031 :AutoInstall: vcscommand.vim
2896 11941 :AutoInstall: open_terminal.vim

View File

@ -0,0 +1,18 @@
ScriptID SourceID Filename
--------------------------
294 1 Align.vim
302 2 AnsiEsc.vim
122 3 astronaut.vim
104 4 blockhl.vim
120 5 decho.vim
40 6 DrawIt.tar.gz
451 7 EasyAccents.vim
195 8 engspchk.vim
642 9 GetLatestVimScripts.vim
489 10 Manpageview.vim
551 11 Mines.vim
514 12 mrswin.vim
670 13 visincr.vim
628 14 SeeTab.vim
508 15 ZoomWin.vim
877 16 gvcolor.vim

View File

@ -1,10 +1,10 @@
" Align: tool to align multiple fields based on one or more separators
" Author: Charles E. Campbell, Jr.
" Date: Mar 03, 2009
" Version: 35
" Date: Jun 18, 2012
" Version: 36
" GetLatestVimScripts: 294 1 :AutoInstall: Align.vim
" GetLatestVimScripts: 1066 1 :AutoInstall: cecutil.vim
" Copyright: Copyright (C) 1999-2007 Charles E. Campbell, Jr. {{{1
" Copyright: Copyright (C) 1999-2012 Charles E. Campbell, Jr. {{{1
" Permission is hereby granted to use and distribute this code,
" with or without modifications, provided that this copyright
" notice is copied with it. Like anything else that's free,
@ -18,13 +18,14 @@
" the power of God for salvation for everyone who believes; for the Jew first,
" and also for the Greek. For in it is revealed God's righteousness from
" faith to faith.
"redraw!|call DechoSep()|call inputsave()|call input("Press <cr> to continue")|call inputrestore()
" ---------------------------------------------------------------------
" Load Once: {{{1
if exists("g:loaded_Align") || &cp
finish
endif
let g:loaded_Align = "v35"
let g:loaded_Align = "v36"
if v:version < 700
echohl WarningMsg
echo "***warning*** this version of Align needs vim 7.0"
@ -84,14 +85,13 @@ endif
" | s:AlignSep
fun! Align#AlignCtrl(...)
" call Dfunc("AlignCtrl(...) a:0=".a:0)
" call Dfunc("Align#AlignCtrl(...) a:0=".a:0)
" save options that will be changed
let keep_search = @/
let keep_ic = &ic
" save options that may be changed later
call s:SaveUserOptions()
" turn ignorecase off
set noic
setlocal noic
" clear visual mode so that old visual-mode selections don't
" get applied to new invocations of Align().
@ -121,19 +121,20 @@ fun! Align#AlignCtrl(...)
let ipat= 2
while ipat <= A[0]
if "" =~ A[ipat]
echoerr "AlignCtrl: separator<".A[ipat]."> matches zero-length string"
let &ic= keep_ic
" call Dret("AlignCtrl")
echoerr "(AlignCtrl) separator<".A[ipat]."> matches zero-length string"
call s:RestoreUserOptions()
" call Dret("Align#AlignCtrl")
return
endif
let ipat= ipat + 1
endwhile
endif
endif
" call Decho("(AlignCtrl) passed bad-separator pattern check (no zero-length matches)")
" call Decho("AlignCtrl() A[0]=".A[0])
" call Decho("(AlignCtrl) A[0]=".A[0])
if !exists("s:AlignStyle")
let s:AlignStyle= "l"
let s:AlignStyle= 'l'
endif
if !exists("s:AlignPrePad")
let s:AlignPrePad= 0
@ -153,7 +154,7 @@ fun! Align#AlignCtrl(...)
let s:AlignPatQty= 0
endif
echo "AlignCtrl<".s:AlignCtrl."> qty=".s:AlignPatQty." AlignStyle<".s:AlignStyle."> Padding<".s:AlignPrePad."|".s:AlignPostPad."> LeadingWS=".s:AlignLeadKeep." AlignSep=".s:AlignSep
" call Decho("AlignCtrl<".s:AlignCtrl."> qty=".s:AlignPatQty." AlignStyle<".s:AlignStyle."> Padding<".s:AlignPrePad."|".s:AlignPostPad."> LeadingWS=".s:AlignLeadKeep." AlignSep=".s:AlignSep)
" call Decho("(AlignCtrl) AlignCtrl<".s:AlignCtrl."> qty=".s:AlignPatQty." AlignStyle<".s:AlignStyle."> Padding<".s:AlignPrePad."|".s:AlignPostPad."> LeadingWS=".s:AlignLeadKeep." AlignSep=".s:AlignSep)
if exists("s:AlignGPat") && !exists("s:AlignVPat")
echo "AlignGPat<".s:AlignGPat.">"
elseif !exists("s:AlignGPat") && exists("s:AlignVPat")
@ -164,7 +165,7 @@ fun! Align#AlignCtrl(...)
let ipat= 1
while ipat <= s:AlignPatQty
echo "Pat".ipat."<".s:AlignPat_{ipat}.">"
" call Decho("Pat".ipat."<".s:AlignPat_{ipat}.">")
" call Decho("(AlignCtrl) Pat".ipat."<".s:AlignPat_{ipat}.">")
let ipat= ipat + 1
endwhile
@ -190,9 +191,8 @@ fun! Align#AlignCtrl(...)
call Align#AlignCtrl("g")
call Align#AlignCtrl("v")
let s:dovisclear = 1
let &ic = keep_ic
let @/ = keep_search
" call Dret("AlignCtrl")
call s:RestoreUserOptions()
" call Dret("Align#AlignCtrl")
return
endif
@ -205,7 +205,7 @@ fun! Align#AlignCtrl(...)
endif
" = : record a list of alignment patterns that are equivalent
if style =~# "="
if style =~# "=" || (A[0] >= 2 && style !~# "C" && s:AlignCtrl =~# '=')
" call Decho("style case =: record list of equiv alignment patterns")
let s:AlignCtrl = '='
if A[0] >= 2
@ -221,7 +221,7 @@ fun! Align#AlignCtrl(...)
endif
"c : cycle through alignment pattern(s)
elseif style =~# 'C'
elseif style =~# 'C' || (A[0] >= 2 && s:AlignCtrl =~# '=')
" call Decho("style case C: cycle through alignment pattern(s)")
let s:AlignCtrl = 'C'
if A[0] >= 2
@ -239,10 +239,9 @@ fun! Align#AlignCtrl(...)
let s:AlignPrePad= substitute(style,'^.*p\(\d\+\).*$','\1','')
" call Decho("style case p".s:AlignPrePad.": pre-separator padding")
if s:AlignPrePad == ""
echoerr "AlignCtrl: 'p' needs to be followed by a numeric argument'
let @/ = keep_search
let &ic= keep_ic
" call Dret("AlignCtrl")
echoerr "(AlignCtrl) 'p' needs to be followed by a numeric argument'"
call s:RestoreUserOptions()
" call Dret("Align#AlignCtrl")
return
endif
endif
@ -251,10 +250,9 @@ fun! Align#AlignCtrl(...)
let s:AlignPostPad= substitute(style,'^.*P\(\d\+\).*$','\1','')
" call Decho("style case P".s:AlignPostPad.": post-separator padding")
if s:AlignPostPad == ""
echoerr "AlignCtrl: 'P' needs to be followed by a numeric argument'
let @/ = keep_search
let &ic= keep_ic
" call Dret("AlignCtrl")
echoerr "(AlignCtrl) 'P' needs to be followed by a numeric argument'"
call s:RestoreUserOptions()
" call Dret("Align#AlignCtrl")
return
endif
endif
@ -263,10 +261,10 @@ fun! Align#AlignCtrl(...)
" call Decho("style case w: ignore leading whitespace")
let s:AlignLeadKeep= 'w'
elseif style =~# 'W'
" call Decho("style case w: keep leading whitespace")
" call Decho("style case W: keep leading whitespace")
let s:AlignLeadKeep= 'W'
elseif style =~# 'I'
" call Decho("style case w: retain initial leading whitespace")
" call Decho("style case I: retain initial leading whitespace")
let s:AlignLeadKeep= 'I'
endif
@ -274,8 +272,8 @@ fun! Align#AlignCtrl(...)
" first list item is a "g" selector pattern
" call Decho("style case g: global selector pattern")
if A[0] < 2
if exists("s:AlignGPat")
unlet s:AlignGPat
if exists("s:AlignVPat")
unlet s:AlignVPat
" call Decho("unlet s:AlignGPat")
endif
else
@ -286,8 +284,8 @@ fun! Align#AlignCtrl(...)
" first list item is a "v" selector pattern
" call Decho("style case v: global selector anti-pattern")
if A[0] < 2
if exists("s:AlignVPat")
unlet s:AlignVPat
if exists("s:AlignGPat")
unlet s:AlignGPat
" call Decho("unlet s:AlignVPat")
endif
else
@ -297,9 +295,9 @@ fun! Align#AlignCtrl(...)
endif
"[-lrc+:] : set up s:AlignStyle
if style =~# '[-lrc+:]'
if style =~# '[-lrc+:*]'
" call Decho("style case [-lrc+:]: field justification")
let s:AlignStyle= substitute(style,'[^-lrc:+]','','g')
let s:AlignStyle= substitute(style,'[^-lrc:+*]','','g')
" call Decho("AlignStyle<".s:AlignStyle.">")
endif
@ -316,11 +314,9 @@ fun! Align#AlignCtrl(...)
let s:AlignCtrl= '='
endif
" restore search and options
let @/ = keep_search
let &ic= keep_ic
" call Dret("AlignCtrl ".s:AlignCtrl.'p'.s:AlignPrePad.'P'.s:AlignPostPad.s:AlignLeadKeep.s:AlignStyle)
" restore options and return
call s:RestoreUserOptions()
" call Dret("Align#AlignCtrl ".s:AlignCtrl.'p'.s:AlignPrePad.'P'.s:AlignPostPad.s:AlignLeadKeep.s:AlignStyle)
return s:AlignCtrl.'p'.s:AlignPrePad.'P'.s:AlignPostPad.s:AlignLeadKeep.s:AlignStyle
endfun
@ -355,6 +351,9 @@ fun! Align#Align(hasctrl,...) range
return
endif
" save user options
call s:SaveUserOptions()
" set up a list akin to an argument list
if a:0 > 0
let A= s:QArgSplitter(a:1)
@ -384,7 +383,8 @@ fun! Align#Align(hasctrl,...) range
let ipat= 1 + hasctrl
while ipat <= A[0]
if "" =~ A[ipat]
echoerr "Align: separator<".A[ipat]."> matches zero-length string"
echoerr "(Align) separator<".A[ipat]."> matches zero-length string"
call s:RestoreUserOptions()
" call Dret("Align#Align")
return
endif
@ -392,10 +392,8 @@ fun! Align#Align(hasctrl,...) range
endwhile
" record current search pattern for subsequent restoration
let keep_search= @/
let keep_ic = &ic
let keep_report= &report
set noic report=10000
" (these are all global-only options)
set noic report=10000 nohls
if A[0] > hasctrl
" Align will accept a list of separator regexps
@ -447,17 +445,32 @@ fun! Align#Align(hasctrl,...) range
let begline = a:lastline
let endline = a:firstline
endif
" Expand range to cover align-able lines when the given range is only the current line.
" Look for the first line above the current line that matches the first separator pattern, and
" look for the last line below the current line that matches the first separator pattern.
if begline == endline
" call Decho("case begline == endline")
if !exists("s:AlignPat_{1}")
echohl Error|echo "(Align) no separators specified!"|echohl None
call s:RestoreUserOptions()
" call Dret("Align#Align")
return
endif
let seppat = s:AlignPat_{1}
let begline= search('^\%(\%('.seppat.'\)\@!.\)*$',"bnW")
if begline == 0|let begline= 1|else|let begline= begline + 1|endif
let endline= search('^\%(\%('.seppat.'\)\@!.\)*$',"nW")
if endline == 0|let endline= line("$")|else|let endline= endline - 1|endif
" call Decho("begline=".begline." endline=".endline." curline#".line("."))
endif
" call Decho("begline=".begline." endline=".endline)
let fieldcnt = 0
if (begline == line("'>") && endline == line("'<")) || (begline == line("'<") && endline == line("'>"))
let vmode= visualmode()
" call Decho("vmode=".vmode)
if vmode == "\<c-v>"
if exists("g:Align_xstrlen") && g:Align_xstrlen
let ragged = ( col("'>") > s:Strlen(getline("'>")) || col("'<") > s:Strlen(getline("'<")) )
else
let ragged = ( col("'>") > strlen(getline("'>")) || col("'<") > strlen(getline("'<")) )
endif
else
let ragged= 1
endif
@ -469,10 +482,14 @@ fun! Align#Align(hasctrl,...) range
endif
" call Decho("lines[".begline.",".endline."] col[".begcol.",".endcol."] ragged=".ragged." AlignCtrl<".s:AlignCtrl.">")
" Keep user options
let etkeep = &l:et
let pastekeep= &l:paste
setlocal et paste
" record initial whitespace
if s:AlignLeadKeep == 'W'
let wskeep = map(getline(begline,endline),"substitute(v:val,'^\\(\\s*\\).\\{-}$','\\1','')")
endif
" Align needs these options
setl et
set paste
" convert selected range of lines to use spaces instead of tabs
" but if first line's initial white spaces are to be retained
@ -480,11 +497,30 @@ fun! Align#Align(hasctrl,...) range
if begcol <= 0 && s:AlignLeadKeep == 'I'
" retain first leading whitespace for all subsequent lines
let bgntxt= substitute(getline(begline),'^\(\s*\).\{-}$','\1','')
" exception: retain first leading whitespace predicated on g and v patterns
" if such a selected line exists
if exists("s:AlignGPat")
let firstgline= search(s:AlignGPat,"cnW",endline)
if firstgline > 0
let bgntxt= substitute(getline(firstgline),'^\(\s*\).\{-}$','\1','')
endif
elseif exists("s:AlignVPat")
let firstvline= search(s:AlignVPat,"cnW",endline)
if firstvline > 0
let bgntxt= substitute('^\%(\%('.getline(firstvline).')\@!\)*$','^\(\s*\).\{-}$','\1','')
endif
endif
" call Decho("retaining 1st leading whitespace: bgntxt<".bgntxt.">")
set noet
let &l:et= s:keep_et
endif
exe begline.",".endline."ret"
" record transformed to spaces leading whitespace
if s:AlignLeadKeep == 'W'
let wsblanks = map(getline(begline,endline),"substitute(v:val,'^\\(\\s*\\).\\{-}$','\\1','')")
endif
" Execute two passes
" First pass: collect alignment data (max field sizes)
" Second pass: perform alignment
@ -528,11 +564,7 @@ fun! Align#Align(hasctrl,...) range
endif
" Extract visual-block selected text (init bgntxt, endtxt)
if exists("g:Align_xstrlen") && g:Align_xstrlen
let txtlen= s:Strlen(txt)
else
let txtlen= strlen(txt)
endif
if begcol > 0
" Record text to left of selected area
let bgntxt= strpart(txt,0,begcol)
@ -557,7 +589,8 @@ fun! Align#Align(hasctrl,...) range
" call Decho("Pass".pass.": txt<". txt .">")
" call Decho("Pass".pass.": endtxt<".endtxt.">")
if !exists("s:AlignPat_{1}")
echohl Error|echo "no separators specified!"|echohl None
echohl Error|echo "(Align) no separators specified!"|echohl None
call s:RestoreUserOptions()
" call Dret("Align#Align")
return
endif
@ -575,7 +608,7 @@ fun! Align#Align(hasctrl,...) range
let alignpostpad= s:AlignPostPad
let alignsep = s:AlignSep
let alignophold = " "
let alignop = "l"
let alignop = 'l'
" call Decho("Pass".pass.": initial alignstyle<".alignstyle."> seppat<".seppat.">")
" Process each field on the line
@ -606,16 +639,34 @@ fun! Align#Align(hasctrl,...) range
endif
endif
" cylic separator alignment specification handling
" cyclic separator alignment specification handling
let alignsepop= strpart(alignsep,0,1)
let alignsep = strpart(alignsep,1).alignsepop
" ------------------------------------------------------
" mark end-of-field and the subsequent end-of-separator.
" Extend field if alignop is '-'
" ------------------------------------------------------
let endfield = match(txt,seppat,bgnfield)
let sepfield = matchend(txt,seppat,bgnfield)
let skipfield= sepfield
" call Decho("Pass".pass.": endfield=match(txt<".txt.">,seppat<".seppat.">,bgnfield=".bgnfield.")=".endfield)
" call Decho("Pass".pass.": endfield=match(txt<".txt.">,seppat<".seppat.">,bgnfield=".bgnfield.")=".endfield." alignop=".alignop)
" Mark eof: Extend field if alignop is '*' and AlignSkip() is true.
if alignop == '*' && exists("g:AlignSkip") && type(g:AlignSkip) == 2
" call Decho("Pass".pass.": endfield=match(txt<".txt.">,seppat<".seppat.">,bgnfield=".bgnfield.")=".endfield." alignop=".alignop)
" a '*' acts like a '-' while the g:AlignSkip function reference is true except that alignop doesn't advance
while g:AlignSkip(line,endfield) && endfield != -1
let endfield = match(txt,seppat,skipfield)
let sepfield = matchend(txt,seppat,skipfield)
let skipfield = sepfield
" call Decho("Pass".pass.": extend field: endfield<".strpart(txt,bgnfield,endfield-bgnfield)."> alignop<".alignop."> alignstyle<".alignstyle.">")
endwhile
let alignop = strpart(alignstyle,0,1)
let alignstyle= strpart(alignstyle,1).strpart(alignstyle,0,1)
" call Decho("Pass".pass.": endfield=match(txt<".txt.">,seppat<".seppat.">,bgnfield=".bgnfield.")=".endfield." alignop=".alignop." (after *)")
endif
" Mark eof: Extend field if alignop is '-'
while alignop == '-' && endfield != -1
let endfield = match(txt,seppat,skipfield)
let sepfield = matchend(txt,seppat,skipfield)
@ -637,11 +688,7 @@ fun! Align#Align(hasctrl,...) range
let field = bgntxt.field
let bgntxt= ""
endif
if exists("g:Align_xstrlen") && g:Align_xstrlen
let fieldlen = s:Strlen(field)
else
let fieldlen = strlen(field)
endif
let sFieldSize = "FieldSize_".ifield
if !exists(sFieldSize)
let FieldSize_{ifield}= fieldlen
@ -675,11 +722,7 @@ fun! Align#Align(hasctrl,...) range
let prepad = 0
let postpad= 0
endif
if exists("g:Align_xstrlen") && g:Align_xstrlen
let fieldlen = s:Strlen(field)
else
let fieldlen = strlen(field)
endif
let sep = s:MakeSpace(prepad).strpart(txt,endfield,sepfield-endfield).s:MakeSpace(postpad)
if seplen < SepSize_{ifield}
if alignsepop == "<"
@ -746,7 +789,7 @@ fun! Align#Align(hasctrl,...) range
" call Decho("Pass".pass.": bgntxt<".bgntxt."> line=".line)
" call Decho("Pass".pass.": newtxt<".newtxt.">")
" call Decho("Pass".pass.": endtxt<".endtxt.">")
call setline(line,bgntxt.newtxt.endtxt)
keepj call setline(line,bgntxt.newtxt.endtxt)
endif
let line = line + 1
@ -756,9 +799,18 @@ fun! Align#Align(hasctrl,...) range
endwhile " pass loop
" call Decho("end of two pass loop")
" Restore user options
let &l:et = etkeep
let &l:paste = pastekeep
" restore original leading whitespace
if s:AlignLeadKeep == 'W'
let iline= begline
let i = 0
" call Decho("restore original leading whitespace")
while iline <= endline
" call Decho("exe ".iline."s/^".wsblanks[i]."/".wskeep[i]."/")
exe "keepj ".iline."s/^".wsblanks[i]."/".wskeep[i]."/"
let iline= iline + 1
let i = i + 1
endwhile
endif
if exists("s:DoAlignPop")
" AlignCtrl Map support
@ -766,11 +818,8 @@ fun! Align#Align(hasctrl,...) range
unlet s:DoAlignPop
endif
" restore current search pattern
let @/ = keep_search
let &ic = keep_ic
let &report = keep_report
" restore user options and return
call s:RestoreUserOptions()
" call Dret("Align#Align")
return
endfun
@ -778,7 +827,7 @@ endfun
" ---------------------------------------------------------------------
" Align#AlignPush: this command/function pushes an alignment control string onto a stack {{{1
fun! Align#AlignPush()
" call Dfunc("AlignPush()")
" call Dfunc("Align#AlignPush()")
" initialize the stack
if !exists("s:AlignCtrlStackQty")
@ -806,7 +855,7 @@ fun! Align#AlignPush()
let s:AlignVPat_{s:AlignCtrlStackQty}= ""
endif
" call Dret("AlignPush")
" call Dret("Align#AlignPush")
endfun
" ---------------------------------------------------------------------
@ -817,13 +866,13 @@ fun! Align#AlignPop()
" sanity checks
if !exists("s:AlignCtrlStackQty")
echoerr "AlignPush needs to be used prior to AlignPop"
echoerr "(AlignPop) AlignPush needs to be used prior to AlignPop"
" call Dret("Align#AlignPop <> : AlignPush needs to have been called first")
return ""
endif
if s:AlignCtrlStackQty <= 0
unlet s:AlignCtrlStackQty
echoerr "AlignPush needs to be used prior to AlignPop"
echoerr "(AlignPop) AlignPush needs to be used prior to AlignPop"
" call Dret("Align#AlignPop <> : AlignPop needs to have been called first")
return ""
endif
@ -858,14 +907,10 @@ endfun
" ---------------------------------------------------------------------
" Align#AlignReplaceQuotedSpaces: {{{1
fun! Align#AlignReplaceQuotedSpaces()
" call Dfunc("AlignReplaceQuotedSpaces()")
" call Dfunc("Align#AlignReplaceQuotedSpaces()")
let l:line = getline(line("."))
if exists("g:Align_xstrlen") && g:Align_xstrlen
let l:linelen = s:Strlen(l:line)
else
let l:linelen = strlen(l:line)
endif
let l:startingPos = 0
let l:startQuotePos = 0
let l:endQuotePos = 0
@ -876,27 +921,27 @@ fun! Align#AlignReplaceQuotedSpaces()
while (1)
let l:startQuotePos = match(l:line, l:quoteRe, l:startingPos)
if (l:startQuotePos < 0)
" "call Decho("No more quotes to the end of line")
" call Decho("No more quotes to the end of line")
break
endif
let l:endQuotePos = match(l:line, l:quoteRe, l:startQuotePos + 1)
if (l:endQuotePos < 0)
" "call Decho("Mismatched quotes")
" call Decho("Mismatched quotes")
break
endif
let l:spaceReplaceRe = '^.\{' . (l:startQuotePos + 1) . '}.\{-}\zs\s\ze.*.\{' . (linelen - l:endQuotePos) . '}$'
" "call Decho('spaceReplaceRe="' . l:spaceReplaceRe . '"')
" call Decho('spaceReplaceRe="' . l:spaceReplaceRe . '"')
let l:newStr = substitute(l:line, l:spaceReplaceRe, '%', '')
while (l:newStr != l:line)
" "call Decho('newstr="' . l:newStr . '"')
" call Decho('newstr="' . l:newStr . '"')
let l:line = l:newStr
let l:newStr = substitute(l:line, l:spaceReplaceRe, '%', '')
endwhile
let l:startingPos = l:endQuotePos + 1
endwhile
call setline(line('.'), l:line)
keepj call setline(line('.'), l:line)
" call Dret("AlignReplaceQuotedSpaces")
" call Dret("Align#AlignReplaceQuotedSpaces")
endfun
" ---------------------------------------------------------------------
@ -923,19 +968,20 @@ fun! s:QArgSplitter(qarg)
while args != ""
let iarg = 0
let arglen = strlen(args)
" call Decho("args[".iarg."]<".args[iarg]."> arglen=".arglen)
" call Decho(".args[".iarg."]<".args[iarg]."> arglen=".arglen)
" find index to first not-escaped '"'
" call Decho("find index to first not-escaped \"")
while args[iarg] != '"' && iarg < arglen
if args[iarg] == '\'
let args= strpart(args,1)
endif
let iarg= iarg + 1
endwhile
" call Decho("args<".args."> iarg=".iarg." arglen=".arglen)
" call Decho(".args<".args."> iarg=".iarg." arglen=".arglen)
if iarg > 0
" handle left of quote or remaining section
" call Decho("handle left of quote or remaining section")
" call Decho(".handle left of quote or remaining section")
if args[iarg] == '"'
let qarglist= qarglist + split(strpart(args,0,iarg-1))
else
@ -946,7 +992,7 @@ fun! s:QArgSplitter(qarg)
elseif iarg < arglen && args[0] == '"'
" handle "quoted" section
" call Decho("handle quoted section")
" call Decho(".handle quoted section")
let iarg= 1
while args[iarg] != '"' && iarg < arglen
if args[iarg] == '\'
@ -954,7 +1000,7 @@ fun! s:QArgSplitter(qarg)
endif
let iarg= iarg + 1
endwhile
" call Decho("args<".args."> iarg=".iarg." arglen=".arglen)
" call Decho(".args<".args."> iarg=".iarg." arglen=".arglen)
if args[iarg] == '"'
call add(qarglist,strpart(args,1,iarg-1))
let args= strpart(args,iarg+1)
@ -963,12 +1009,14 @@ fun! s:QArgSplitter(qarg)
let args = ""
endif
endif
" call Decho("qarglist".string(qarglist)." iarg=".iarg." args<".args.">")
" call Decho(".qarglist".string(qarglist)." iarg=".iarg." args<".args.">")
endwhile
" call Decho("end of loop (handling quoted arguments)")
else
" split at all whitespace
let qarglist= split(a:qarg)
" call Decho("split at all whitespace")
let qarglist= split(a:qarg,"[ \t]")
endif
let qarglistlen= len(qarglist)
@ -984,8 +1032,13 @@ endfun
" nonzero value. Solution from Nicolai Weibull, vim docs
" (:help strlen()), Tony Mechelynck, and my own invention.
fun! s:Strlen(x)
" call Dfunc("s:Strlen(x<".a:x.">")
if g:Align_xstrlen == 1
" call Dfunc("s:Strlen(x<".a:x."> g:Align_xstrlen=".g:Align_xstrlen)
if type(g:Align_xstrlen) == 1
" allow user to specify a function to compute the string length
exe "let ret= ".g:Align_xstrlen."('".substitute(a:x,"'","''","g")."')"
elseif g:Align_xstrlen == 1
" number of codepoints (Latin a + combining circumflex is two codepoints)
" (comment from TM, solution from NW)
let ret= strlen(substitute(a:x,'.','c','g'))
@ -1010,12 +1063,58 @@ fun! s:Strlen(x)
else
" at least give a decent default
ret= strlen(a:x)
if v:version >= 703
let ret= strdisplaywidth(a:x)
else
let ret= strlen(a:x)
endif
endif
" call Dret("s:Strlen ".ret)
return ret
endfun
" ---------------------------------------------------------------------
" s:SaveUserOptions: {{{1
fun! s:SaveUserOptions()
" call Dfunc("s:SaveUserOptions() s:saved_user_options=".(exists("s:saved_user_options")? s:saved_user_options : 'n/a'))
if !exists("s:saved_user_options")
let s:saved_user_options = 1
let s:keep_search = @/
let s:keep_et = &l:et
let s:keep_hls = &hls
let s:keep_ic = &ic
let s:keep_paste = &paste
let s:keep_report = &report
else
let s:saved_user_options = s:saved_user_options + 1
endif
" call Dret("s:SaveUserOptions : s:saved_user_options=".s:saved_user_options)
endfun
" ---------------------------------------------------------------------
" s:RestoreUserOptions: {{{1
fun! s:RestoreUserOptions()
" call Dfunc("s:RestoreUserOptions() s:saved_user_options=".(exists("s:saved_user_options")? s:saved_user_options : 'n/a'))
if exists("s:saved_user_options") && s:saved_user_options == 1
let @/ = s:keep_search
let &l:et = s:keep_et
let &hls = s:keep_hls
let &ic = s:keep_ic
let &paste = s:keep_paste
let &report = s:keep_report
unlet s:keep_search
unlet s:keep_et
unlet s:keep_hls
unlet s:keep_ic
unlet s:keep_paste
unlet s:keep_report
unlet s:saved_user_options
elseif exists("s:saved_user_options")
let s:saved_user_options= s:saved_user_options - 1
endif
" call Dret("s:RestoreUserOptions : s:saved_user_options=".(exists("s:saved_user_options")? s:saved_user_options : 'n/a'))
endfun
" ---------------------------------------------------------------------
" Set up default values: {{{1
"call Decho("-- Begin AlignCtrl Initialization --")

View File

@ -1,15 +1,25 @@
" AlignMaps.vim : support functions for AlignMaps
" Author: Charles E. Campbell, Jr.
" Date: Mar 03, 2009
" Version: 41
" Date: Jun 18, 2012
" Version: 42
" Copyright: Copyright (C) 1999-2012 Charles E. Campbell, Jr. {{{1
" Permission is hereby granted to use and distribute this code,
" with or without modifications, provided that this copyright
" notice is copied with it. Like anything else that's free,
" Align.vim is provided *as is* and comes with no warranty
" of any kind, either expressed or implied. By using this
" plugin, you agree that in no event will the copyright
" holder be liable for any damages resulting from the use
"redraw!|call DechoSep()|call inputsave()|call input("Press <cr> to continue")|call inputrestore()
" ---------------------------------------------------------------------
" Load Once: {{{1
if &cp || exists("g:loaded_AlignMaps")
finish
endif
let g:loaded_AlignMaps= "v41"
let g:loaded_AlignMaps= "v42"
let s:keepcpo = &cpo
set cpo&vim
"DechoTabOn
" =====================================================================
" Functions: {{{1
@ -20,7 +30,7 @@ fun! AlignMaps#WrapperStart(vis) range
" call Dfunc("AlignMaps#WrapperStart(vis=".a:vis.")")
if a:vis
norm! '<ma'>
keepj norm! '<ma'>
endif
if line("'y") == 0 || line("'z") == 0 || !exists("s:alignmaps_wrapcnt") || s:alignmaps_wrapcnt <= 0
@ -34,22 +44,22 @@ fun! AlignMaps#WrapperStart(vis) range
let s:alignmaps_posn = SaveWinPosn(0)
" set up fencepost blank lines
put =''
norm! mz'a
keepj norm! mz'a
put! =''
ky
let s:alignmaps_zline = line("'z")
exe "'y,'zs/@/\177/ge"
exe "keepj 'y,'zs/@/\177/ge"
else
" call Decho("embedded wrapper")
let s:alignmaps_wrapcnt = s:alignmaps_wrapcnt + 1
norm! 'yjma'zk
keepj norm! 'yjma'zk
endif
" change some settings to align-standard values
set nogd
set ch=2
AlignPush
norm! 'zk
keepj norm! 'zk
" call Dret("AlignMaps#WrapperStart : alignmaps_wrapcnt=".s:alignmaps_wrapcnt." my=".line("'y")." mz=".line("'z"))
endfun
@ -59,7 +69,7 @@ fun! AlignMaps#WrapperEnd() range
" call Dfunc("AlignMaps#WrapperEnd() alignmaps_wrapcnt=".s:alignmaps_wrapcnt." my=".line("'y")." mz=".line("'z"))
" remove trailing white space introduced by whatever in the modification zone
'y,'zs/ \+$//e
keepj 'y,'zs/ \+$//e
" restore AlignCtrl settings
AlignPop
@ -67,14 +77,14 @@ fun! AlignMaps#WrapperEnd() range
let s:alignmaps_wrapcnt= s:alignmaps_wrapcnt - 1
if s:alignmaps_wrapcnt <= 0
" initial wrapper ending
exe "'y,'zs/\177/@/ge"
exe "keepj 'y,'zs/\177/@/ge"
" if the 'z line hasn't moved, then go ahead and restore window position
let zstationary= s:alignmaps_zline == line("'z")
" remove fencepost blank lines.
" restore 'a
norm! 'yjmakdd'zdd
keepj norm! 'yjmakdd'zdd
" restore original 'y, 'z, and window positioning
call RestoreMark(s:alignmaps_keepmy)
@ -135,10 +145,10 @@ fun! AlignMaps#CharJoiner(chr)
let aline = line("'a")
let rep = line(".") - aline
while rep > 0
norm! 'a
keepj norm! 'a
while match(getline(aline),a:chr . "\s*$") != -1 && rep >= 0
" while = at end-of-line, delete it and join with next
norm! 'a$
keepj norm! 'a$
j!
let rep = rep - 1
endwhile
@ -149,7 +159,7 @@ fun! AlignMaps#CharJoiner(chr)
break
endif
" prepare for next line
norm! jma
keepj norm! jma
let aline = line("'a")
endwhile
" call Dret("AlignMaps#CharJoiner")
@ -159,31 +169,32 @@ endfun
" AlignMaps#Equals: supports \t= and \T= {{{2
fun! AlignMaps#Equals() range
" call Dfunc("AlignMaps#Equals()")
'a,'zs/\s\+\([*/+\-%|&\~^]\==\)/ \1/e
'a,'zs@ \+\([*/+\-%|&\~^]\)=@\1=@ge
'a,'zs/==/\="\<Char-0x0f>\<Char-0x0f>"/ge
'a,'zs/\([!<>:]\)=/\=submatch(1)."\<Char-0x0f>"/ge
norm g'zk
keepj 'a,'zs/\s\+\([*/+\-%|&\~^]\==\)/ \1/e
keepj 'a,'zs@ \+\([*/+\-%|&\~^]\)=@\1=@ge
keepj 'a,'zs/==/\="\<Char-0x0f>\<Char-0x0f>"/ge
keepj 'a,'zs/\([!<>:]\)=/\=submatch(1)."\<Char-0x0f>"/ge
keepj norm g'zk
AlignCtrl mIp1P1=l =
AlignCtrl g =
'a,'z-1Align
'a,'z-1s@\([*/+\-%|&\~^!=]\)\( \+\)=@\2\1=@ge
'a,'z-1s/\( \+\);/;\1/ge
keepj 'a,'z-1Align
keepj 'a,'z-1s@\([*/%|&\~^!=]\)\( \+\)=@\2\1=@ge
keepj 'a,'z-1s@[^+\-]\zs\([+\-]\)\( \+\)=@\2\1=@ge
keepj 'a,'z-1s/\( \+\);/;\1/ge
if &ft == "c" || &ft == "cpp"
" call Decho("exception for ".&ft)
'a,'z-1v/^\s*\/[*/]/s/\/[*/]/@&@/e
'a,'z-1v/^\s*\/[*/]/s/\*\//@&/e
keepj 'a,'z-1v/^\s*\/[*/]/s/\/[*/]/@&@/e
keepj 'a,'z-1v/^\s*\/[*/]/s/\*\//@&/e
if exists("g:mapleader")
exe "norm 'zk"
exe "keepj norm 'zk"
call AlignMaps#StdAlign(1)
else
exe "norm 'zk"
exe "keepj norm 'zk"
call AlignMaps#StdAlign(1)
endif
'y,'zs/^\(\s*\) @/\1/e
keepj 'y,'zs/^\(\s*\) @/\1/e
endif
'a,'z-1s/\%x0f/=/ge
'y,'zs/ @//eg
keepj 'a,'z-1s/\%x0f/=/ge
keepj 'y,'zs/ @//eg
" call Dret("AlignMaps#Equals")
endfun
@ -194,10 +205,11 @@ fun! AlignMaps#Afnc()
" call Dfunc("AlignMaps#Afnc()")
" keep display quiet
let chkeep = &ch
let gdkeep = &gd
let vekeep = &ve
set ch=2 nogd ve=
let chkeep = &l:ch
let gdkeep = &l:gd
let wwkeep = &l:ww
let vekeep = &l:ve
setlocal ch=2 nogd ve= ww=b,s,<,>,[,]
" will use marks y,z ; save current values
let mykeep = SaveMark("'y")
@ -206,7 +218,7 @@ fun! AlignMaps#Afnc()
" Find beginning of function -- be careful to skip over comments
let cmmntid = synIDtrans(hlID("Comment"))
let stringid = synIDtrans(hlID("String"))
exe "norm! ]]"
exe "keepj norm! ]]"
while search(")","bW") != 0
" call Decho("line=".line(".")." col=".col("."))
let parenid= synIDtrans(synID(line("."),col("."),1))
@ -214,23 +226,23 @@ fun! AlignMaps#Afnc()
break
endif
endwhile
norm! %my
s/(\s*\(\S\)/(\r \1/e
exe "norm! `y%"
s/)\s*\(\/[*/]\)/)\r\1/e
exe "norm! `y%mz"
'y,'zs/\s\+$//e
'y,'zs/^\s\+//e
'y+1,'zs/^/ /
keepj norm! %my
keepj s/(\s*\(\S\)/(\r \1/e
exe "keepj norm! `y%"
keepj s/)\s*\(\/[*/]\)/)\r\1/e
exe "keepj norm! `y%mz"
keepj 'y,'zs/\s\+$//e
keepj 'y,'zs/^\s\+//e
keepj 'y+1,'zs/^/ /
" insert newline after every comma only one parenthesis deep
sil! exe "norm! `y\<right>h"
exe "sil! keepj norm! `y\<right>h"
let parens = 1
let cmmnt = 0
let cmmntline= -1
while parens >= 1
" call Decho("parens=".parens." @a=".@a)
exe 'norm! ma "ay`a '
exe 'keepj norm! ma "ay`a '
" call Decho("parens=".parens." cmmnt=".cmmnt." cmmntline=".cmmntline." line(.)=".line(".")." @a<".@a."> line<".getline(".").">")
if @a == "("
let parens= parens + 1
elseif @a == ")"
@ -261,41 +273,42 @@ fun! AlignMaps#Afnc()
endif
elseif @a == "," && parens == 1 && cmmnt == 0
exe "norm! i\<CR>\<Esc>"
exe "keepj norm! i\<CR>\<Esc>"
endif
endwhile
norm! `y%mz%
sil! 'y,'zg/^\s*$/d
sil! keepj norm! `y%mz%
sil! keepj 'y,'zg/^\s*$/d
" perform substitutes to mark fields for Align
sil! 'y+1,'zv/^\//s/^\s\+\(\S\)/ \1/e
sil! 'y+1,'zv/^\//s/\(\S\)\s\+/\1 /eg
sil! 'y+1,'zv/^\//s/\* \+/*/ge
sil! 'y+1,'zv/^\//s/\w\zs\s*\*/ */ge
sil! keepj 'y+1,'zv/^\//s/^\s\+\(\S\)/ \1/e
sil! keepj 'y+1,'zv/^\//s/\(\S\)\s\+/\1 /eg
sil! keepj 'y+1,'zv/^\//s/\* \+/*/ge
sil! keepj 'y+1,'zv/^\//s/\w\zs\s*\*/ */ge
" func
" ws <- declaration -> <-ptr -> <-var-> <-[array][] -> <-glop-> <-end->
sil! 'y+1,'zv/^\//s/^\s*\(\(\K\k*\s*\)\+\)\s\+\([(*]*\)\s*\(\K\k*\)\s*\(\(\[.\{-}]\)*\)\s*\(.\{-}\)\=\s*\([,)]\)\s*$/ \1@#\3@\4\5@\7\8/e
sil! 'y+1,'z+1g/^\s*\/[*/]/norm! kJ
sil! 'y+1,'z+1s%/[*/]%@&@%ge
sil! 'y+1,'z+1s%*/%@&%ge
sil! keepj 'y+1,'zv/^\//s/^\s*\(\(\K\k*\s*\)\+\)\s\+\([(*]*\)\s*\(\K\k*\)\s*\(\(\[.\{-}]\)*\)\s*\(.\{-}\)\=\s*\([,)]\)\s*$/ \1@#\3@\4\5@\7\8/e
sil! keepj 'y+1,'z+1g/^\s*\/[*/]/norm! kJ
sil! keepj 'y+1,'z+1s%/[*/]%@&@%ge
sil! keepj 'y+1,'z+1s%*/%@&%ge
AlignCtrl mIp0P0=l @
sil! 'y+1,'zAlign
sil! 'y,'zs%@\(/[*/]\)@%\t\1 %e
sil! 'y,'zs%@\*/% */%e
sil! 'y,'zs/@\([,)]\)/\1/
sil! 'y,'zs/@/ /
sil! keepj 'y+1,'zAlign
sil! keepj 'y,'zs%@\(/[*/]\)@%\t\1 %e
sil! keepj 'y,'zs%@\*/% */%e
sil! keepj 'y,'zs/@\([,)]\)/\1/
sil! keepj 'y,'zs/@/ /
AlignCtrl mIlrp0P0= # @
sil! 'y+1,'zAlign
sil! 'y+1,'zs/#/ /
sil! 'y+1,'zs/@//
sil! 'y+1,'zs/\(\s\+\)\([,)]\)/\2\1/e
sil! keepj 'y+1,'zAlign
sil! keepj 'y+1,'zs/#/ /
sil! keepj 'y+1,'zs/@//
sil! keepj 'y+1,'zs/\(\s\+\)\([,)]\)/\2\1/e
" Restore
call RestoreMark(mykeep)
call RestoreMark(mzkeep)
let &ch= chkeep
let &gd= gdkeep
let &ve= vekeep
let &l:ch= chkeep
let &l:gd= gdkeep
let &l:ww= wwkeep
let &l:ve= vekeep
" call Dret("AlignMaps#Afnc")
endfun
@ -310,12 +323,42 @@ fun! AlignMaps#FixMultiDec()
let curline = getline(".")
" call Decho("curline<".curline.">")
" " Attempt to ignore function calls (ie. double x=pow(2.,3.),...
" let leader= substitute(curline,'^\s*\([a-zA-Z_ \t][a-zA-Z0-9<>_ \t]*\)\s\+.*$','\1','')
" let i = strlen(leader)
" let paren = 0
" let fmd = strpart(curline,i)
" let ifmd = i
" call Decho("fmd<".fmd."> ifmd=".ifmd)
" while i < strlen(curline)
" if strpart(curline,i,1) == '('
" let paren= paren+1
" elseif strpart(curline,i,1) == ')' && paren > 0
" let paren= paren-1
" elseif strpart(curline,i,1) == '='
" let eq= 1
" elseif strpart(curline,i,1) == ';'
" let paren = 0
" let eq = 0
" let fmd = fmd.strpart(fmd,ifmd,i-ifmd).";\<cr>"
" let ifmd = i + 2
" let i = i + 1
" let leader= substitute(curline,'^\s*\([a-zA-Z_ \t][a-zA-Z0-9<>_ \t]*\)\s\+.*$','\1','')
" elseif strpart(curline,i,1) == ','
" if paren == 0
" let fmd = fmd.strpart(fmd,ifmd,i-ifmd).";\<cr>"
" let ifmd = i + 2
" let i = i + 1
" endif
" endif
" let i= i + 1
" endwhile
" Get the type. I'm assuming one type per line (ie. int x; double y; on one line will not be handled properly)
let @x=substitute(curline,'^\(\s*[a-zA-Z_ \t][a-zA-Z0-9_ \t]*\)\s\+[(*]*\h.*$','\1','')
let @x=substitute(curline,'^\(\s*[a-zA-Z_ \t][a-zA-Z0-9<>_ \t]*\)\s\+[(*]*\h.*$','\1','')
" call Decho("@x<".@x.">")
" transform line
exe 's/,/;\r'.@x.' /ge'
exe 'keepj s/,/;\r'.@x.' /ge'
"restore register x
let @x= xkeep
@ -323,6 +366,26 @@ fun! AlignMaps#FixMultiDec()
" call Dret("AlignMaps#FixMultiDec : my=".line("'y")." mz=".line("'z"))
endfun
" ---------------------------------------------------------------------
" AlignMaps#AlignMapsClean: this function removes the AlignMaps plugin {{{2
fun! AlignMaps#AlignMapsClean()
" call Dfunc("AlignMaps#AlignMapsClean()")
for home in split(&rtp,',') + ['']
" call Decho("considering home<".home.">")
if isdirectory(home)
if filereadable(home."/autoload/AlignMaps.vim")
" call Decho("deleting ".home."/autoload/AlignMaps.vim")
call delete(home."/autoload/AlignMaps.vim")
endif
if filereadable(home."/plugin/AlignMapsPlugin.vim")
" call Decho("deleting ".home."/plugin/AlignMapsPlugin.vim")
call delete(home."/plugin/AlignMapsPlugin.vim")
endif
endif
endfor
" call Dret("AlignMaps#AlignMapsClean")
endfun
" ---------------------------------------------------------------------
" Restore: {{{1
let &cpo= s:keepcpo

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,11 @@
# FILE: autoload/conque_term/conque.py {{{
# FILE: autoload/conque_term/conque.py
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
# WEBSITE: http://conque.googlecode.com
# MODIFIED: 2010-11-15
# VERSION: 2.0, for Vim 7.0
# MODIFIED: 2011-08-12
# VERSION: 2.2, for Vim 7.0
# LICENSE:
# Conque - Vim terminal/console emulator
# Copyright (C) 2009-2010 Nico Raffo
# Copyright (C) 2009-__YEAR__ Nico Raffo
#
# MIT License
#
@ -25,29 +25,33 @@
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE. }}}
# THE SOFTWARE.
"""
Vim terminal emulator.
The Conque does two things. First, it handles communication between Vim and
the terminal/console subprocess. For example, Vim uses the Conque.write()
method to send input, and Conque.read() to update the terminal buffer.
This class is the main interface between Vim and the terminal application. It
handles both updating the Vim buffer with new output and accepting new keyboard
input from the Vim user.
Second, the Conque class handles Unix terminal escape sequence parsing.
Although this class was originally designed for a Unix terminal environment, it
has been extended by the ConqueSole class for Windows.
Usage:
term = Conque()
term.open('/bin/bash', {'TERM': 'vt100'})
term.write("ls -lha\r")
term.read()
term.close()
"""
import vim
import re
import math
import time # DEBUG
class Conque:
# CLASS PROPERTIES {{{
# screen object
screen = None
@ -86,6 +90,12 @@ class Conque:
# color history
color_history = {}
# color highlight cache
highlight_groups = {}
# prune terminal colors
color_pruning = True
# don't wrap table output
unwrap_tables = True
@ -101,15 +111,23 @@ class Conque:
# used for auto_read actions
read_count = 0
# }}}
# input buffer, array of ordinals
input_buffer = []
# constructor
def __init__(self): # {{{
def open(self):
""" Start program and initialize this instance.
Arguments:
command -- Command string to execute, e.g. '/bin/bash --login'
options -- Dictionary of environment vars to set and other options.
"""
# get arguments
command = vim.eval('command')
options = vim.eval('options')
# create terminal screen instance
self.screen = ConqueScreen()
# }}}
# start program and initialize this instance
def open(self, command, options): # {{{
# int vars
self.columns = vim.current.window.width
@ -118,8 +136,12 @@ class Conque:
self.working_lines = vim.current.window.height
self.bottom = vim.current.window.height
# offset first line to make room for startup messages
if int(options['offset']) > 0:
self.l = int(options['offset'])
# init color
self.enable_colors = options['color']
self.enable_colors = options['color'] and not CONQUE_FAST_MODE
# init tabstops
self.init_tabstops()
@ -130,11 +152,15 @@ class Conque:
# send window size signal, in case LINES/COLUMNS is ignored
self.update_window_size(True)
# }}}
# write to pty
def write(self, input, set_cursor=True, read=True): # {{{
def write(self, input, set_cursor=True, read=True):
""" Write a unicode string to the subprocess.
set_cursor -- Position the cursor in the current buffer when finished
read -- Check program for new output when finished
"""
# check if window size has changed
if read:
self.update_window_size()
@ -146,11 +172,40 @@ class Conque:
if read:
self.read(1, set_cursor)
# }}}
# convert latin-1 input into utf-8
# XXX - this is a hack, to be removed soon
def write_latin1(self, input, set_cursor=True, read=True): # {{{
def write_ord(self, input, set_cursor=True, read=True):
""" Write a single character to the subprocess, using an unicode ordinal. """
if CONQUE_PYTHON_VERSION == 2:
self.write(unichr(input), set_cursor, read)
else:
self.write(chr(input), set_cursor, read)
def write_expr(self, expr, set_cursor=True, read=True):
""" Write the value of a Vim expression to the subprocess. """
if CONQUE_PYTHON_VERSION == 2:
try:
val = vim.eval(expr)
self.write(unicode(val, CONQUE_VIM_ENCODING, 'ignore'), set_cursor, read)
except:
pass
else:
try:
# XXX - Depending on Vim to deal with encoding, sadly
self.write(vim.eval(expr), set_cursor, read)
except:
pass
def write_latin1(self, input, set_cursor=True, read=True):
""" Write latin-1 string to conque. Very ugly, shood be removed. """
# XXX - this whole method is a hack, to be removed soon
if CONQUE_PYTHON_VERSION == 2:
try:
@ -161,19 +216,34 @@ class Conque:
else:
self.write(input, set_cursor, read)
# }}}
# read from pty, and update buffer
def read(self, timeout=1, set_cursor=True, return_output=False, update_buffer=True): # {{{
def write_buffered_ord(self, chr):
""" Add character ordinal to input buffer. In case we're not allowed to modify buffer a time of input. """
self.input_buffer.append(chr)
def read(self, timeout=1, set_cursor=True, return_output=False, update_buffer=True):
""" Read new output from the subprocess and update the Vim buffer.
Arguments:
timeout -- Milliseconds to wait before reading input
set_cursor -- Set the cursor position in the current buffer when finished
return_output -- Return new subprocess STDOUT + STDERR as a string
update_buffer -- Update the current Vim buffer with the new output
This method goes through the following rough steps:
1. Get new output from subprocess
2. Split output string into control codes, escape sequences, or plain text
3. Loop over and process each chunk, updating the Vim buffer as we go
"""
output = ''
# this may not actually work
try:
# read from subprocess
# read from subprocess and strip null characters
output = self.proc.read(timeout)
# and strip null chars
output = output.replace(chr(0), '')
if output == '':
return
@ -184,19 +254,19 @@ class Conque:
# strip null characters. I'm still not sure why they appear
output = output.replace(chr(0), '')
# split input into individual escape sequences, control codes, and text output
chunks = CONQUE_SEQ_REGEX.split(output)
# don't go through all the csi regex if length is one (no matches)
# if there were no escape sequences, skip processing and treat entire string as plain text
if len(chunks) == 1:
self.plain_text(chunks[0])
# loop through and process escape sequences
else:
for s in chunks:
if s == '':
@ -205,8 +275,7 @@ class Conque:
# Check for control character match {{{
# Check for control character match
if CONQUE_SEQ_REGEX_CTL.match(s[0]):
nr = ord(s[0])
@ -215,9 +284,8 @@ class Conque:
else:
pass
# }}}
# check for escape sequence match {{{
# check for escape sequence match
elif CONQUE_SEQ_REGEX_CSI.match(s):
if s[-1] in CONQUE_ESCAPE:
@ -227,15 +295,13 @@ class Conque:
else:
pass
# }}}
# check for title match {{{
# check for title match
elif CONQUE_SEQ_REGEX_TITLE.match(s):
self.change_title(s[2], s[4:-1])
# }}}
# check for hash match {{{
# check for hash match
elif CONQUE_SEQ_REGEX_HASH.match(s):
if s[-1] in CONQUE_ESCAPE_HASH:
@ -243,9 +309,8 @@ class Conque:
else:
pass
# }}}
# check for charset match {{{
# check for charset match
elif CONQUE_SEQ_REGEX_CHAR.match(s):
if s[-1] in CONQUE_ESCAPE_CHARSET:
@ -253,9 +318,8 @@ class Conque:
else:
pass
# }}}
# check for other escape match {{{
# check for other escape match
elif CONQUE_SEQ_REGEX_ESC.match(s):
if s[-1] in CONQUE_ESCAPE_PLAIN:
@ -263,23 +327,21 @@ class Conque:
else:
pass
# }}}
# else process plain text {{{
# else process plain text
else:
self.plain_text(s)
# }}}
# check window size
# set cusor position
if set_cursor:
self.screen.set_cursor(self.l, self.c)
# we need to set the cursor position
self.cursor_set = False
vim.command('redraw')
# redraw screen for immediate feedback
#if not CONQUE_FAST_MODE:
# vim.command('redraw')
except:
@ -290,19 +352,42 @@ class Conque:
if CONQUE_PYTHON_VERSION == 3:
return output
else:
return output.encode(vim.eval('&encoding'), 'replace')
# }}}
return output.encode(CONQUE_VIM_ENCODING, 'replace')
# for polling
def auto_read(self): # {{{
def auto_read(self):
""" Poll program for more output.
Since Vim doesn't have a reliable event system that can be triggered when new
output is available, we have to continually poll the subprocess instead. This
method is called many times a second when the terminal buffer is active, so it
needs to be very fast and efficient.
The feedkeys portion is required to reset Vim's timer system. The timer is used
to execute this command, typically set to go off after 50 ms of inactivity.
"""
# process buffered input if any
if len(self.input_buffer):
for chr in self.input_buffer:
self.write_ord(chr, set_cursor=False, read=False)
self.input_buffer = []
self.read(1)
# check subprocess status, but not every time since it's CPU expensive
if self.read_count == 10:
if self.read_count % 32 == 0:
if not self.proc.is_alive():
vim.command('call conque_term#get_instance().close()')
return
else:
if self.read_count > 512:
self.read_count = 0
# trim color history occasionally if desired
if self.enable_colors and self.color_pruning:
self.prune_colors()
# ++
self.read_count += 1
# read output
@ -327,17 +412,22 @@ class Conque:
pass
self.cursor_set = True
# }}}
###############################################################################################
# Plain text # {{{
def plain_text(self, input):
""" Write text output to Vim buffer.
# translate input into correct character set
This method writes a string of characters without any control characters or escape sequences
to the Vim buffer. In simple terms, it writes the input string to the buffer starting at the
current cursor position, wrapping the text to a new line if needed. It also triggers the
terminal coloring methods if needed.
"""
# translate input into graphics character set if needed
if self.character_set == 'graphics':
old_input = input
input = ''
input = u('')
for i in range(0, len(old_input)):
chrd = ord(old_input[i])
@ -347,19 +437,23 @@ class Conque:
input = input + old_input[i]
else:
input = input + unichr(CONQUE_GRAPHICS_SET[chrd])
input = input + uchr(CONQUE_GRAPHICS_SET[chrd])
except:
pass
# get current line from Vim buffer
current_line = self.screen[self.l]
if len(current_line) < self.working_columns:
# pad current line with spaces, if it's shorter than cursor position
if len(current_line) < self.c:
current_line = current_line + ' ' * (self.c - len(current_line))
# if line is wider than screen
if self.c + len(input) - 1 > self.working_columns:
# Table formatting hack
if self.unwrap_tables and CONQUE_TABLE_OUTPUT.match(input):
self.screen[self.l] = current_line[:self.c - 1] + input + current_line[self.c + len(input) - 1:]
@ -367,7 +461,9 @@ class Conque:
self.c += len(input)
return
diff = self.c + len(input) - self.working_columns - 1
# if autowrap is enabled
if self.autowrap:
self.screen[self.l] = current_line[:self.c - 1] + input[:-1 * diff]
@ -388,7 +484,21 @@ class Conque:
self.apply_color(self.c, self.c + len(input))
self.c += len(input)
def apply_color(self, start, end, line=0):
""" Apply terminal colors to buffer for a range of characters in a single line.
When a text attribute escape sequence is encountered during input processing, the
attributes are recorded in the dictionary self.color_changes. After those attributes
have been applied, the changes are recorded in a second dictionary self.color_history.
This method inspects both dictionaries to calculate any syntax highlighting
that needs to be executed to render the text attributes in the Vim buffer.
"""
# stop here if coloration is disabled
@ -397,16 +507,16 @@ class Conque:
# allow custom line nr to be passed
if line:
real_line = line
buffer_line = line
else:
real_line = self.screen.get_real_line(self.l)
buffer_line = self.get_buffer_line(self.l)
# check for previous overlapping coloration
to_del = []
if real_line in self.color_history:
for i in range(len(self.color_history[real_line])):
syn = self.color_history[real_line][i]
if buffer_line in self.color_history:
for i in range(len(self.color_history[buffer_line])):
syn = self.color_history[buffer_line][i]
if syn['start'] >= start and syn['start'] < end:
@ -415,7 +525,7 @@ class Conque:
# outside
if syn['end'] > end:
self.exec_highlight(real_line, end, syn['end'], syn['highlight'])
self.exec_highlight(buffer_line, end, syn['end'], syn['highlight'])
elif syn['end'] > start and syn['end'] <= end:
vim.command('syn clear ' + syn['name'])
@ -423,47 +533,83 @@ class Conque:
# outside
if syn['start'] < start:
self.exec_highlight(real_line, syn['start'], start, syn['highlight'])
self.exec_highlight(buffer_line, syn['start'], start, syn['highlight'])
# remove overlapped colors
if len(to_del) > 0:
to_del.reverse()
for di in to_del:
del self.color_history[real_line][di]
del self.color_history[buffer_line][di]
# if there are no new colors
if len(self.color_changes) == 0:
return
# build the color attribute string
highlight = ''
for attr in self.color_changes.keys():
highlight = highlight + ' ' + attr + '=' + self.color_changes[attr]
# execute the highlight
self.exec_highlight(real_line, start, end, highlight)
self.exec_highlight(buffer_line, start, end, highlight)
def exec_highlight(self, real_line, start, end, highlight):
unique_key = str(self.proc.pid)
syntax_name = 'EscapeSequenceAt_' + unique_key + '_' + str(self.l) + '_' + str(start) + '_' + str(len(self.color_history) + 1)
def exec_highlight(self, buffer_line, start, end, highlight):
""" Execute the Vim commands for a single syntax highlight """
syntax_name = 'ConqueHighLightAt_%d_%d_%d_%d' % (self.proc.pid, self.l, start, len(self.color_history) + 1)
syntax_options = 'contains=ALLBUT,ConqueString,MySQLString,MySQLKeyword oneline'
syntax_region = 'syntax match ' + syntax_name + ' /\%' + str(real_line) + 'l\%>' + str(start - 1) + 'c.*\%<' + str(end + 1) + 'c/' + syntax_options
syntax_highlight = 'highlight ' + syntax_name + highlight
syntax_region = 'syntax match %s /\%%%dl\%%>%dc.\{%d}\%%<%dc/ %s' % (syntax_name, buffer_line, start - 1, end - start, end + 1, syntax_options)
# check for cached highlight group
hgroup = 'ConqueHL_%d' % (abs(hash(highlight)))
if hgroup not in self.highlight_groups:
syntax_group = 'highlight %s %s' % (hgroup, highlight)
self.highlight_groups[hgroup] = hgroup
vim.command(syntax_group)
# link this syntax match to existing highlight group
syntax_highlight = 'highlight link %s %s' % (syntax_name, self.highlight_groups[hgroup])
vim.command(syntax_region)
vim.command(syntax_highlight)
# add syntax name to history
if not real_line in self.color_history:
self.color_history[real_line] = []
if not buffer_line in self.color_history:
self.color_history[buffer_line] = []
self.color_history[buffer_line].append({'name': syntax_name, 'start': start, 'end': end, 'highlight': highlight})
def prune_colors(self):
""" Remove old syntax highlighting from the Vim buffer
The kind of syntax highlighting required for terminal colors can make
Conque run slowly. The prune_colors() method will remove old highlight definitions
to keep the maximum number of highlight rules within a reasonable range.
"""
buffer_line = self.get_buffer_line(self.l)
ks = list(self.color_history.keys())
for line in ks:
if line < buffer_line - CONQUE_MAX_SYNTAX_LINES:
for syn in self.color_history[line]:
vim.command('syn clear ' + syn['name'])
del self.color_history[line]
self.color_history[real_line].append({'name': syntax_name, 'start': start, 'end': end, 'highlight': highlight})
# }}}
###############################################################################################
# Control functions {{{
# Control functions
def ctl_nl(self):
""" Process the newline control character. """
# if we're in a scrolling region, scroll instead of moving cursor down
if self.lines != self.working_lines and self.l == self.bottom:
del self.screen[self.top]
@ -476,24 +622,29 @@ class Conque:
self.color_changes = {}
def ctl_cr(self):
""" Process the carriage return control character. """
self.c = 1
self.color_changes = {}
def ctl_bs(self):
""" Process the backspace control character. """
if self.c > 1:
self.c += -1
def ctl_soh(self):
""" Process the start of heading control character. """
pass
def ctl_stx(self):
pass
def ctl_bel(self):
""" Process the bell control character. """
vim.command('call conque_term#bell()')
def ctl_tab(self):
""" Process the tab control character. """
# default tabstop location
ts = self.working_columns
@ -508,17 +659,20 @@ class Conque:
self.c = ts
def ctl_so(self):
""" Process the shift out control character. """
self.character_set = 'graphics'
def ctl_si(self):
""" Process the shift in control character. """
self.character_set = 'ascii'
# }}}
###############################################################################################
# CSI functions {{{
# CSI functions
def csi_font(self, csi): # {{{
def csi_font(self, csi):
""" Process the text attribute escape sequence. """
if not self.enable_colors:
return
@ -557,9 +711,10 @@ class Conque:
self.color_changes[attr] += ',' + CONQUE_FONT[val]['attributes'][attr]
else:
self.color_changes[attr] = CONQUE_FONT[val]['attributes'][attr]
# }}}
def csi_clear_line(self, csi): # {{{
def csi_clear_line(self, csi):
""" Process the line clear escape sequence. """
# this escape defaults to 0
@ -583,16 +738,17 @@ class Conque:
# clear colors
if csi['val'] == 2 or (csi['val'] == 0 and self.c == 1):
real_line = self.screen.get_real_line(self.l)
if real_line in self.color_history:
for syn in self.color_history[real_line]:
buffer_line = self.get_buffer_line(self.l)
if buffer_line in self.color_history:
for syn in self.color_history[buffer_line]:
vim.command('syn clear ' + syn['name'])
# }}}
def csi_cursor_right(self, csi): # {{{
def csi_cursor_right(self, csi):
""" Process the move cursor right escape sequence. """
# we use 1 even if escape explicitly specifies 0
if csi['val'] == 0:
csi['val'] = 1
@ -606,9 +762,10 @@ class Conque:
return
self.c = self.bound(self.c + csi['val'], 1, self.working_columns)
# }}}
def csi_cursor_left(self, csi): # {{{
def csi_cursor_left(self, csi):
""" Process the move cursor left escape sequence. """
# we use 1 even if escape explicitly specifies 0
if csi['val'] == 0:
csi['val'] = 1
@ -619,25 +776,29 @@ class Conque:
return
self.c = self.bound(self.c - csi['val'], 1, self.working_columns)
# }}}
def csi_cursor_to_column(self, csi): # {{{
def csi_cursor_to_column(self, csi):
""" Process the move cursor to column escape sequence. """
self.c = self.bound(csi['val'], 1, self.working_columns)
# }}}
def csi_cursor_up(self, csi): # {{{
def csi_cursor_up(self, csi):
""" Process the move cursor up escape sequence. """
self.l = self.bound(self.l - csi['val'], self.top, self.bottom)
self.color_changes = {}
# }}}
def csi_cursor_down(self, csi): # {{{
def csi_cursor_down(self, csi):
""" Process the move cursor down escape sequence. """
self.l = self.bound(self.l + csi['val'], self.top, self.bottom)
self.color_changes = {}
# }}}
def csi_clear_screen(self, csi): # {{{
def csi_clear_screen(self, csi):
""" Process the clear screen escape sequence. """
# default to 0
if len(csi['vals']) == 0:
csi['val'] = 0
@ -666,24 +827,24 @@ class Conque:
# clear coloration
if csi['val'] == 2 or csi['val'] == 0:
real_line = self.screen.get_real_line(self.l)
buffer_line = self.get_buffer_line(self.l)
for line in self.color_history.keys():
if line >= real_line:
if line >= buffer_line:
for syn in self.color_history[line]:
vim.command('syn clear ' + syn['name'])
self.color_changes = {}
# }}}
def csi_delete_chars(self, csi): # {{{
def csi_delete_chars(self, csi):
self.screen[self.l] = self.screen[self.l][:self.c] + self.screen[self.l][self.c + csi['val']:]
# }}}
def csi_add_spaces(self, csi): # {{{
def csi_add_spaces(self, csi):
self.screen[self.l] = self.screen[self.l][: self.c - 1] + ' ' * csi['val'] + self.screen[self.l][self.c:]
# }}}
def csi_cursor(self, csi): # {{{
def csi_cursor(self, csi):
if len(csi['vals']) == 2:
new_line = csi['vals'][0]
new_col = csi['vals'][1]
@ -700,9 +861,9 @@ class Conque:
if self.c > len(self.screen[self.l]):
self.screen[self.l] = self.screen[self.l] + ' ' * (self.c - len(self.screen[self.l]))
# }}}
def csi_set_coords(self, csi): # {{{
def csi_set_coords(self, csi):
if len(csi['vals']) == 2:
new_start = csi['vals'][0]
new_end = csi['vals'][1]
@ -721,9 +882,9 @@ class Conque:
self.l = self.bottom
self.color_changes = {}
# }}}
def csi_tab_clear(self, csi): # {{{
def csi_tab_clear(self, csi):
# this escape defaults to 0
if len(csi['vals']) == 0:
csi['val'] = 0
@ -735,9 +896,9 @@ class Conque:
elif csi['val'] == 3:
for i in range(0, self.columns + 1):
self.tabstops[i] = False
# }}}
def csi_set(self, csi): # {{{
def csi_set(self, csi):
# 132 cols
if csi['val'] == 3:
self.csi_clear_screen(self.parse_csi('2J'))
@ -753,9 +914,9 @@ class Conque:
self.color_changes = {}
# }}}
def csi_reset(self, csi): # {{{
def csi_reset(self, csi):
# 80 cols
if csi['val'] == 3:
self.csi_clear_screen(self.parse_csi('2J'))
@ -771,31 +932,31 @@ class Conque:
self.color_changes = {}
# }}}
# }}}
###############################################################################################
# ESC functions {{{
# ESC functions
def esc_scroll_up(self): # {{{
def esc_scroll_up(self):
self.ctl_nl()
self.color_changes = {}
# }}}
def esc_next_line(self): # {{{
def esc_next_line(self):
self.ctl_nl()
self.c = 1
# }}}
def esc_set_tab(self): # {{{
def esc_set_tab(self):
if self.c <= len(self.tabstops):
self.tabstops[self.c - 1] = True
# }}}
def esc_scroll_down(self): # {{{
def esc_scroll_down(self):
if self.l == self.top:
del self.screen[self.bottom]
self.screen.insert(self.top, '')
@ -803,24 +964,23 @@ class Conque:
self.l += -1
self.color_changes = {}
# }}}
# }}}
###############################################################################################
# HASH functions {{{
# HASH functions
def hash_screen_alignment_test(self): # {{{
def hash_screen_alignment_test(self):
self.csi_clear_screen(self.parse_csi('2J'))
self.working_lines = self.lines
for l in range(1, self.lines + 1):
self.screen[l] = 'E' * self.working_columns
# }}}
# }}}
###############################################################################################
# CHARSET functions {{{
# CHARSET functions
def charset_us(self):
self.character_set = 'ascii'
@ -831,15 +991,22 @@ class Conque:
def charset_graphics(self):
self.character_set = 'graphics'
# }}}
###############################################################################################
# Random stuff {{{
# Random stuff
def set_cursor(self, line, col):
""" Set cursor position in the Vim buffer.
Note: the line and column numbers are relative to the top left corner of the
visible screen. Not the line number in the Vim buffer.
"""
self.screen.set_cursor(line, col)
def change_title(self, key, val):
""" Change the Vim window title. """
if key == '0' or key == '2':
@ -850,17 +1017,14 @@ class Conque:
except:
pass
def paste(self):
input = vim.eval('@@')
input = input.replace("\n", "\r")
self.read(50)
def paste_selection(self):
input = vim.eval('@@')
input = input.replace("\n", "\r")
self.write(input)
def update_window_size(self, force=False):
""" Check and save the current buffer dimensions.
If the buffer size has changed, the update_window_size() method both updates
the Conque buffer size attributes as well as sending the new dimensions to the
subprocess pty.
"""
# resize if needed
if force or vim.current.window.width != self.columns or vim.current.window.height != self.lines:
@ -883,6 +1047,7 @@ class Conque:
self.proc.window_resize(self.lines, self.columns)
def insert_enter(self):
""" Run commands when user enters insert mode. """
# check window size
self.update_window_size()
@ -891,6 +1056,7 @@ class Conque:
self.cursor_set = False
def init_tabstops(self):
""" Intitialize terminal tabstop positions. """
for i in range(0, self.columns + 1):
if i % 8 == 0:
self.tabstops.append(True)
@ -898,23 +1064,30 @@ class Conque:
self.tabstops.append(False)
def idle(self):
""" Called when this terminal becomes idle. """
pass
def resume(self):
""" Called when this terminal is no longer idle. """
pass
pass
def close(self):
""" End the process running in the terminal. """
self.proc.close()
def abort(self):
""" Forcefully end the process running in the terminal. """
self.proc.signal(1)
# }}}
###############################################################################################
# Utility {{{
# Utility
def parse_csi(self, s):
""" Parse an escape sequence into it's meaningful values. """
def parse_csi(self, s): # {{{
attr = {'key': s[-1], 'flag': '', 'val': 1, 'vals': []}
if len(s) == 1:
@ -939,9 +1112,10 @@ class Conque:
attr['val'] = int(attr['vals'][0])
return attr
# }}}
def bound(self, val, min, max): # {{{
def bound(self, val, min, max):
""" TODO: This probably exists as a builtin function. """
if val > max:
return max
@ -949,9 +1123,10 @@ class Conque:
return min
return val
# }}}
def xterm_to_rgb(self, color_code): # {{{
def xterm_to_rgb(self, color_code):
""" Translate a terminal color number into a RGB string. """
if color_code < 16:
ascii_colors = ['000000', 'CD0000', '00CD00', 'CDCD00', '0000EE', 'CD00CD', '00CDCD', 'E5E5E5',
'7F7F7F', 'FF0000', '00FF00', 'FFFF00', '5C5CFF', 'FF00FF', '00FFFF', 'FFFFFF']
@ -968,8 +1143,12 @@ class Conque:
else:
grey_tone = "%02x" % math.floor((255 / 24) * (color_code - 232))
return grey_tone + grey_tone + grey_tone
# }}}
# }}}
# vim:foldmethod=marker
def get_buffer_line(self, line):
""" Get the buffer line number corresponding to the supplied screen line number. """
return self.screen.get_buffer_line(line)

View File

@ -1,11 +1,11 @@
# FILE: autoload/conque_term/conque_globals.py {{{
# FILE: autoload/conque_term/conque_globals.py
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
# WEBSITE: http://conque.googlecode.com
# MODIFIED: 2010-11-15
# VERSION: 2.0, for Vim 7.0
# MODIFIED: 2011-08-12
# VERSION: 2.2, for Vim 7.0
# LICENSE:
# Conque - Vim terminal/console emulator
# Copyright (C) 2009-2010 Nico Raffo
# Copyright (C) 2009-__YEAR__ Nico Raffo
#
# MIT License
#
@ -25,56 +25,32 @@
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE. }}}
# THE SOFTWARE.
"""Common global constants and functions for Conque."""
import sys
import os
import re
import os # DEBUG
# shared memory size
CONQUE_SOLE_BUFFER_LENGTH = 1000
CONQUE_SOLE_INPUT_SIZE = 1000
CONQUE_SOLE_STATS_SIZE = 1000
CONQUE_SOLE_COMMANDS_SIZE = 255
CONQUE_SOLE_RESCROLL_SIZE = 255
CONQUE_SOLE_RESIZE_SIZE = 255
# interval of screen redraw
# larger number means less frequent
CONQUE_SOLE_SCREEN_REDRAW = 100
# interval of full buffer redraw
# larger number means less frequent
CONQUE_SOLE_BUFFER_REDRAW = 500
# interval of full output bucket replacement
# larger number means less frequent, 1 = every time
CONQUE_SOLE_MEM_REDRAW = 1000
import traceback # DEBUG
# PYTHON VERSION
CONQUE_PYTHON_VERSION = sys.version_info[0]
# Encoding
def u(str_val, str_encoding='latin-1', errors='strict'):
"""foolhardy attempt to make unicode string syntax compatible with both python 2 and 3"""
try:
# Vim's character encoding
import vim
CONQUE_VIM_ENCODING = vim.eval('&encoding')
except:
CONQUE_VIM_ENCODING = 'utf-8'
def u(str_val, str_encoding='utf-8', errors='strict'):
""" Foolhardy attempt to make unicode string syntax compatible with both python 2 and 3. """
if not str_val:
str_val = ''
@ -85,7 +61,34 @@ def u(str_val, str_encoding='latin-1', errors='strict'):
else:
return unicode(str_val, str_encoding, errors)
# Escape sequence settings {{{
def uchr(str):
""" Foolhardy attempt to make unicode string syntax compatible with both python 2 and 3. """
if CONQUE_PYTHON_VERSION == 3:
return chr(str)
else:
return unichr(str)
# Unix escape sequence settings
CONQUE_CTL = {
1: 'soh', # start of heading
@ -209,7 +212,7 @@ CONQUE_GRAPHICS_SET = [
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF
]
# Font codes {{{
# Font codes
CONQUE_FONT = {
0: {'description': 'Normal (default)', 'attributes': {'cterm': 'NONE', 'ctermfg': 'NONE', 'ctermbg': 'NONE', 'gui': 'NONE', 'guifg': 'NONE', 'guibg': 'NONE'}, 'normal': True},
1: {'description': 'Bold', 'attributes': {'cterm': 'BOLD', 'gui': 'BOLD'}, 'normal': False},
@ -257,31 +260,60 @@ CONQUE_FONT = {
106: {'description': 'Set background color to Cyan', 'attributes': {'ctermbg': '14', 'guibg': '#009999'}, 'normal': False},
107: {'description': 'Set background color to White', 'attributes': {'ctermbg': '15', 'guibg': '#ffffff'}, 'normal': False}
}
# }}}
# regular expression matching (almost) all control sequences
CONQUE_SEQ_REGEX = re.compile(u("(\x1b\[?\??#?[0-9;]*[a-zA-Z0-9@=>]|\x1b\][0-9];.*?\x07|[\x01-\x0f]|\x1b\([AB0])"), re.UNICODE)
CONQUE_SEQ_REGEX_CTL = re.compile(u("^[\x01-\x0f]$"), re.UNICODE)
CONQUE_SEQ_REGEX_CSI = re.compile(u("^\x1b\["), re.UNICODE)
CONQUE_SEQ_REGEX_TITLE = re.compile(u("^\x1b\]"), re.UNICODE)
CONQUE_SEQ_REGEX_HASH = re.compile(u("^\x1b#"), re.UNICODE)
CONQUE_SEQ_REGEX_ESC = re.compile(u("^\x1b.$"), re.UNICODE)
CONQUE_SEQ_REGEX_CHAR = re.compile(u("^\x1b\("), re.UNICODE)
CONQUE_SEQ_REGEX = re.compile("(\x1b\[?\??#?[0-9;]*[a-zA-Z0-9@=>]|\x1b\][0-9];.*?\x07|[\x01-\x0f]|\x1b\([AB0])")
CONQUE_SEQ_REGEX_CTL = re.compile("^[\x01-\x0f]$")
CONQUE_SEQ_REGEX_CSI = re.compile("^\x1b\[")
CONQUE_SEQ_REGEX_TITLE = re.compile("^\x1b\]")
CONQUE_SEQ_REGEX_HASH = re.compile("^\x1b#")
CONQUE_SEQ_REGEX_ESC = re.compile("^\x1b.$")
CONQUE_SEQ_REGEX_CHAR = re.compile("^\x1b[()]")
# match table output
CONQUE_TABLE_OUTPUT = re.compile("^\s*\|\s.*\s\|\s*$|^\s*\+[=+-]+\+\s*$")
# }}}
# Windows subprocess config {{{
CONQUE_SEQ_REGEX_VK = re.compile(u("(\x1b\[\d{1,3}VK)"), re.UNICODE)
# }}}
# basic terminal colors
CONQUE_COLOR_SEQUENCE = (
'000', '009', '090', '099', '900', '909', '990', '999',
'000', '00f', '0f0', '0ff', 'f00', 'f0f', 'ff0', 'fff'
)
# vim:foldmethod=marker
# Windows subprocess constants
# shared memory size
CONQUE_SOLE_BUFFER_LENGTH = 1000
CONQUE_SOLE_INPUT_SIZE = 1000
CONQUE_SOLE_STATS_SIZE = 1000
CONQUE_SOLE_COMMANDS_SIZE = 255
CONQUE_SOLE_RESCROLL_SIZE = 255
CONQUE_SOLE_RESIZE_SIZE = 255
# interval of screen redraw
# larger number means less frequent
CONQUE_SOLE_SCREEN_REDRAW = 50
# interval of full buffer redraw
# larger number means less frequent
CONQUE_SOLE_BUFFER_REDRAW = 500
# interval of full output bucket replacement
# larger number means less frequent, 1 = every time
CONQUE_SOLE_MEM_REDRAW = 1000
# maximum number of lines with terminal colors
# ignored if g:ConqueTerm_Color = 2
CONQUE_MAX_SYNTAX_LINES = 200
# windows input splitting on special keys
CONQUE_WIN32_REGEX_VK = re.compile("(\x1b\[[0-9;]+VK)")
# windows attribute string splitting
CONQUE_WIN32_REGEX_ATTR = re.compile("((.)\\2*)", re.DOTALL)
# special key attributes
CONQUE_VK_ATTR_CTRL_PRESSED = u('1024')

View File

@ -1,11 +1,11 @@
# FILE: autoload/conque_term/conque_screen.py {{{
# FILE: autoload/conque_term/conque_screen.py
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
# WEBSITE: http://conque.googlecode.com
# MODIFIED: 2010-11-15
# VERSION: 2.0, for Vim 7.0
# MODIFIED: 2011-08-12
# VERSION: 2.2, for Vim 7.0
# LICENSE:
# Conque - Vim terminal/console emulator
# Copyright (C) 2009-2010 Nico Raffo
# Copyright (C) 2009-__YEAR__ Nico Raffo
#
# MIT License
#
@ -25,14 +25,19 @@
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE. }}}
# THE SOFTWARE.
"""
ConqueScreen is an extention of the vim.current.buffer object
It restricts the working indices of the buffer object to the scroll region
which pty is expecting. It also uses 1-based indexes, to match escape
sequence commands.
Unix terminal escape sequences usually reference line numbers relative to the
top of the visible screen. However the visible portion of the Vim buffer
representing the terminal probably doesn't start at the first line of the
buffer.
The ConqueScreen class allows access to the Vim buffer with screen-relative
line numbering. And handles a few other related tasks, such as setting the
correct cursor position.
E.g.:
s = ConqueScreen()
@ -40,6 +45,7 @@ sequence commands.
s[5] = 'Set 5th line in terminal to this line'
s.append('Add new line to terminal')
s[5] = 'Since previous append() command scrolled the terminal down, this is a different line than first cb[5] call'
"""
import vim
@ -47,8 +53,6 @@ import vim
class ConqueScreen(object):
# CLASS PROPERTIES {{{
# the buffer
buffer = None
@ -59,55 +63,66 @@ class ConqueScreen(object):
screen_width = 80
screen_height = 80
# }}}
# char encoding for vim buffer
screen_encoding = 'utf-8'
def __init__(self):
""" Initialize screen size and character encoding. """
def __init__(self): # {{{
self.buffer = vim.current.buffer
# initialize screen size
self.screen_top = 1
self.screen_width = vim.current.window.width
self.screen_height = vim.current.window.height
# }}}
###############################################################################################
# List overload {{{
# save screen character encoding type
self.screen_encoding = vim.eval('&fileencoding')
def __len__(self): # {{{
def __len__(self):
""" Define the len() function for ConqueScreen objects. """
return len(self.buffer)
# }}}
def __getitem__(self, key): # {{{
real_line = self.get_real_idx(key)
def __getitem__(self, key):
""" Define value access for ConqueScreen objects. """
buffer_line = self.get_real_idx(key)
# if line is past buffer end, add lines to buffer
if real_line >= len(self.buffer):
for i in range(len(self.buffer), real_line + 1):
self.append(' ' * self.screen_width)
if buffer_line >= len(self.buffer):
for i in range(len(self.buffer), buffer_line + 1):
self.append(' ')
return u(self.buffer[real_line], 'utf-8')
# }}}
return u(self.buffer[buffer_line], 'utf-8')
def __setitem__(self, key, value): # {{{
real_line = self.get_real_idx(key)
def __setitem__(self, key, value):
""" Define value assignments for ConqueScreen objects. """
buffer_line = self.get_real_idx(key)
if CONQUE_PYTHON_VERSION == 2:
val = value.encode('utf-8')
val = value.encode(self.screen_encoding)
else:
# XXX / Vim's python3 interface doesn't accept bytes object
val = str(value)
# if line is past end of screen, append
if real_line == len(self.buffer):
if buffer_line == len(self.buffer):
self.buffer.append(val)
else:
self.buffer[real_line] = val
# }}}
self.buffer[buffer_line] = val
def __delitem__(self, key): # {{{
def __delitem__(self, key):
""" Define value deletion for ConqueScreen objects. """
del self.buffer[self.screen_top + key - 2]
# }}}
def append(self, value): # {{{
def append(self, value):
""" Define value appending for ConqueScreen objects. """
if len(self.buffer) > self.screen_top + self.screen_height - 1:
self.buffer[len(self.buffer) - 1] = value
else:
@ -115,72 +130,83 @@ class ConqueScreen(object):
if len(self.buffer) > self.screen_top + self.screen_height - 1:
self.screen_top += 1
if vim.current.buffer.number == self.buffer.number:
vim.command('normal G')
# }}}
def insert(self, line, value): # {{{
if vim.current.buffer.number == self.buffer.number:
vim.command('normal! G')
def insert(self, line, value):
""" Define value insertion for ConqueScreen objects. """
l = self.screen_top + line - 2
self.buffer.append(value, l)
# }}}
# }}}
###############################################################################################
# Util {{{
def get_top(self): # {{{
def get_top(self):
""" Get the Vim line number representing the top of the visible terminal. """
return self.screen_top
# }}}
def get_real_idx(self, line): # {{{
def get_real_idx(self, line):
""" Get the zero index Vim line number corresponding to the provided screen line. """
return (self.screen_top + line - 2)
# }}}
def get_real_line(self, line): # {{{
def get_buffer_line(self, line):
""" Get the Vim line number corresponding to the provided screen line. """
return (self.screen_top + line - 1)
# }}}
def set_screen_width(self, width): # {{{
def set_screen_width(self, width):
""" Set the screen width. """
self.screen_width = width
# }}}
# }}}
###############################################################################################
def clear(self): # {{{
def clear(self):
""" Clear the screen. Does not clear the buffer, just scrolls down past all text. """
self.screen_width = width
self.buffer.append(' ')
vim.command('normal Gzt')
vim.command('normal! Gzt')
self.screen_top = len(self.buffer)
# }}}
def set_cursor(self, line, column): # {{{
def set_cursor(self, line, column):
""" Set cursor position. """
# figure out line
real_line = self.screen_top + line - 1
if real_line > len(self.buffer):
for l in range(len(self.buffer) - 1, real_line):
buffer_line = self.screen_top + line - 1
if buffer_line > len(self.buffer):
for l in range(len(self.buffer) - 1, buffer_line):
self.buffer.append('')
# figure out column
real_column = column
if len(self.buffer[real_line - 1]) < real_column:
self.buffer[real_line - 1] = self.buffer[real_line - 1] + ' ' * (real_column - len(self.buffer[real_line - 1]))
if len(self.buffer[buffer_line - 1]) < real_column:
self.buffer[buffer_line - 1] = self.buffer[buffer_line - 1] + ' ' * (real_column - len(self.buffer[buffer_line - 1]))
if not CONQUE_FAST_MODE:
# set cursor at byte index of real_column'th character
vim.command('call cursor(' + str(buffer_line) + ', byteidx(getline(' + str(buffer_line) + '), ' + str(real_column) + '))')
else:
# old version
# python version is occasionally grumpy
try:
vim.current.window.cursor = (real_line, real_column - 1)
vim.current.window.cursor = (buffer_line, real_column - 1)
except:
vim.command('call cursor(' + str(real_line) + ', ' + str(real_column) + ')')
# }}}
vim.command('call cursor(' + str(buffer_line) + ', ' + str(real_column) + ')')
def reset_size(self, line):
""" Change screen size """
def reset_size(self, line): # {{{
# save cursor line number
real_line = self.screen_top + line
buffer_line = self.screen_top + line
# reset screen size
self.screen_width = vim.current.window.width
@ -191,19 +217,14 @@ class ConqueScreen(object):
# align bottom of buffer to bottom of screen
vim.command('normal ' + str(self.screen_height) + 'kG')
vim.command('normal! ' + str(self.screen_height) + 'kG')
# return new relative line number
return (real_line - self.screen_top)
# }}}
return (buffer_line - self.screen_top)
def scroll_to_bottom(self): # {{{
vim.current.window.cursor = (len(self.buffer) - 1, 1)
# }}}
def align(self): # {{{
# align bottom of buffer to bottom of screen
vim.command('normal ' + str(self.screen_height) + 'kG')
# }}}
def align(self):
""" align bottom of buffer to bottom of screen """
vim.command('normal! ' + str(self.screen_height) + 'kG')
# vim:foldmethod=marker

View File

@ -1,11 +1,11 @@
# FILE: autoload/conque_term/conque_sole.py {{{
# FILE: autoload/conque_term/conque_sole.py
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
# WEBSITE: http://conque.googlecode.com
# MODIFIED: 2010-11-15
# VERSION: 2.0, for Vim 7.0
# MODIFIED: 2011-08-12
# VERSION: 2.2, for Vim 7.0
# LICENSE:
# Conque - Vim terminal/console emulator
# Copyright (C) 2009-2010 Nico Raffo
# Copyright (C) 2009-__YEAR__ Nico Raffo
#
# MIT License
#
@ -25,7 +25,14 @@
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE. }}}
# THE SOFTWARE.
"""
Windows Console Emulator
This is the main interface to the Windows emulator. It reads new output from the background console
and updates the Vim buffer.
"""
import vim
@ -36,19 +43,36 @@ class ConqueSole(Conque):
window_bottom = None
color_cache = {}
attribute_cache = {}
color_mode = None
color_conceals = {}
buffer = None
encoding = None
# counters for periodic rendering
buffer_redraw_ct = 0
screen_redraw_ct = 0
buffer_redraw_ct = 1
screen_redraw_ct = 1
# *********************************************************************************************
# start program and initialize this instance
# line offset, shifts output down
offset = 0
def open(self, command, options={}, python_exe='', communicator_py=''): # {{{
def open(self):
""" Start command and initialize this instance
Arguments:
command - Command string, e.g. "Powershell.exe"
options - Dictionary of config options
python_exe - Path to the python.exe executable. Usually C:\PythonXX\python.exe
communicator_py - Path to subprocess controller script in user's vimfiles directory
"""
# get arguments
command = vim.eval('command')
options = vim.eval('options')
python_exe = vim.eval('py_exe')
communicator_py = vim.eval('py_vim')
# init size
self.columns = vim.current.window.width
@ -56,22 +80,25 @@ class ConqueSole(Conque):
self.window_top = 0
self.window_bottom = vim.current.window.height - 1
# color mode
self.color_mode = vim.eval('g:ConqueTerm_ColorMode')
# line offset
self.offset = int(options['offset'])
# init color
self.enable_colors = options['color']
self.enable_colors = options['color'] and not CONQUE_FAST_MODE
# open command
self.proc = ConqueSoleWrapper()
self.proc.open(command, {'TERM': options['TERM'], 'CONQUE': '1', 'LINES': self.lines, 'COLUMNS': self.columns}, python_exe, communicator_py)
self.proc.open(command, self.lines, self.columns, python_exe, communicator_py, options)
self.buffer = vim.current.buffer
# }}}
self.screen_encoding = vim.eval('&fileencoding')
# *********************************************************************************************
# read and update screen
def read(self, timeout=1, set_cursor=True, return_output=False, update_buffer=True): # {{{
def read(self, timeout=1, set_cursor=True, return_output=False, update_buffer=True):
""" Read from console and update Vim buffer. """
try:
stats = self.proc.get_stats()
@ -79,6 +106,8 @@ class ConqueSole(Conque):
if not stats:
return
# disable screen and buffer redraws in fast mode
if not CONQUE_FAST_MODE:
self.buffer_redraw_ct += 1
self.screen_redraw_ct += 1
@ -87,39 +116,48 @@ class ConqueSole(Conque):
lines = []
# full buffer redraw, our favorite!
if self.buffer_redraw_ct == CONQUE_SOLE_BUFFER_REDRAW:
self.buffer_redraw_ct = 0
update_top = 0
update_bottom = stats['top_offset'] + self.lines
(lines, attributes) = self.proc.read(update_top, update_bottom)
if return_output:
output = self.get_new_output(lines, update_top, stats)
if update_buffer:
for i in range(update_top, update_bottom + 1):
self.plain_text(i, lines[i], attributes[i], stats)
#if self.buffer_redraw_ct == CONQUE_SOLE_BUFFER_REDRAW:
# self.buffer_redraw_ct = 0
# update_top = 0
# update_bottom = stats['top_offset'] + self.lines
# (lines, attributes) = self.proc.read(update_top, update_bottom)
# if return_output:
# output = self.get_new_output(lines, update_top, stats)
# if update_buffer:
# for i in range(update_top, update_bottom + 1):
# if CONQUE_FAST_MODE:
# self.plain_text(i, lines[i], None, stats)
# else:
# self.plain_text(i, lines[i], attributes[i], stats)
# full screen redraw
elif stats['cursor_y'] + 1 != self.l or stats['top_offset'] != self.window_top or self.screen_redraw_ct == CONQUE_SOLE_SCREEN_REDRAW:
if stats['cursor_y'] + 1 != self.l or stats['top_offset'] != self.window_top or self.screen_redraw_ct >= CONQUE_SOLE_SCREEN_REDRAW:
self.screen_redraw_ct = 0
update_top = self.window_top
update_bottom = stats['top_offset'] + self.lines + 1
update_bottom = max([stats['top_offset'] + self.lines + 1, stats['cursor_y']])
(lines, attributes) = self.proc.read(update_top, update_bottom - update_top + 1)
if return_output:
output = self.get_new_output(lines, update_top, stats)
if update_buffer:
for i in range(update_top, update_bottom + 1):
if CONQUE_FAST_MODE:
self.plain_text(i, lines[i - update_top], None, stats)
else:
self.plain_text(i, lines[i - update_top], attributes[i - update_top], stats)
# single line redraw
else:
update_top = stats['cursor_y']
update_bottom = stats['cursor_y']
(lines, attributes) = self.proc.read(update_top, 1)
if return_output:
output = self.get_new_output(lines, update_top, stats)
if update_buffer:
if lines[0].rstrip() != self.buffer[update_top].rstrip():
if lines[0].rstrip() != u(self.buffer[update_top].rstrip()):
if CONQUE_FAST_MODE:
self.plain_text(update_top, lines[0], None, stats)
else:
self.plain_text(update_top, lines[0], attributes[0], stats)
@ -138,12 +176,10 @@ class ConqueSole(Conque):
except:
pass
# }}}
#########################################################################
# Calculate the "new" output from this read. Fake but useful
def get_new_output(self, lines, update_top, stats): # {{{
def get_new_output(self, lines, update_top, stats):
""" Calculate the "new" output from this read. Fake but useful """
if not (stats['cursor_y'] + 1 > self.l or (stats['cursor_y'] + 1 == self.l and stats['cursor_x'] + 1 > self.c)):
return ""
@ -175,17 +211,18 @@ class ConqueSole(Conque):
return "\n".join(new_output)
# }}}
#########################################################################
# update the buffer
def plain_text(self, line_nr, text, attributes, stats): # {{{
def plain_text(self, line_nr, text, attributes, stats):
""" Write plain text to Vim buffer. """
# handle line offset
line_nr += self.offset
self.l = line_nr + 1
# remove trailing whitespace
@ -197,21 +234,28 @@ class ConqueSole(Conque):
text = self.add_conceal_color(text, attributes, stats, line_nr)
# deal with character encoding
if CONQUE_PYTHON_VERSION == 2:
val = text.encode(self.screen_encoding)
else:
# XXX / Vim's python3 interface doesn't accept bytes object
val = str(text)
# update vim buffer
if len(self.buffer) <= line_nr:
self.buffer.append(text)
self.buffer.append(val)
else:
self.buffer[line_nr] = text
self.buffer[line_nr] = val
if not self.color_mode == 'conceal':
self.do_color(attributes=attributes, stats=stats)
if self.enable_colors and not self.color_mode == 'conceal' and line_nr > self.l - CONQUE_MAX_SYNTAX_LINES:
relevant = attributes[0:len(text)]
if line_nr not in self.attribute_cache or self.attribute_cache[line_nr] != relevant:
self.do_color(attributes=relevant, stats=stats)
self.attribute_cache[line_nr] = relevant
# }}}
#########################################################################
# add conceal color
def add_conceal_color(self, text, attributes, stats, line_nr): # {{{
def add_conceal_color(self, text, attributes, stats, line_nr):
""" Add 'conceal' color strings to output text """
# stop here if coloration is disabled
if not self.enable_colors:
@ -222,71 +266,42 @@ class ConqueSole(Conque):
return text
new_text = ''
# if text attribute is different, call add_color()
attr = None
start = 0
self.color_conceals[line_nr] = []
attribute_chunks = CONQUE_WIN32_REGEX_ATTR.findall(attributes)
offset = 0
ends = []
for i in range(0, len(attributes)):
c = ord(attributes[i])
for attr in attribute_chunks:
attr_num = ord(attr[1])
ends = []
if attr_num != stats['default_attribute']:
if c != attr:
if attr and attr != stats['default_attribute']:
color = self.translate_color(attr)
color = self.translate_color(attr_num)
new_text += chr(27) + 'sf' + color['fg_code'] + ';'
ends.append(chr(27) + 'ef' + color['fg_code'] + ';')
self.color_conceals[line_nr].append(start)
self.color_conceals[line_nr].append(offset)
if c > 15:
new_text += chr(27) + 'sf' + color['bg_code'] + ';'
ends.append(chr(27) + 'ef' + color['bg_code'] + ';')
self.color_conceals[line_nr].append(start)
if attr_num > 15:
new_text += chr(27) + 'sb' + color['bg_code'] + ';'
ends.append(chr(27) + 'eb' + color['bg_code'] + ';')
self.color_conceals[line_nr].append(offset)
new_text += text[start:i]
# close color regions
ends.reverse()
for j in range(0, len(ends)):
new_text += ends[j]
self.color_conceals[line_nr].append(i)
ends = []
start = i
attr = c
if attr and attr != stats['default_attribute']:
color = self.translate_color(attr)
new_text += chr(27) + 'sf' + color['fg_code'] + ';'
ends.append(chr(27) + 'ef' + color['fg_code'] + ';')
if c > 15:
new_text += chr(27) + 'sf' + color['bg_code'] + ';'
ends.append(chr(27) + 'ef' + color['bg_code'] + ';')
new_text += text[start:]
new_text += text[offset:offset + len(attr[0])]
# close color regions
ends.reverse()
for i in range(0, len(ends)):
self.color_conceals[line_nr].append(len(new_text))
new_text += ends[i]
offset += len(attr[0])
return new_text
# }}}
#########################################################################
def do_color(self, start=0, end=0, attributes='', stats=None): # {{{
# stop here if coloration is disabled
if not self.enable_colors:
return
def do_color(self, start=0, end=0, attributes='', stats=None):
""" Convert Windows console attributes into Vim syntax highlighting """
# if no colors for this line, clear everything out
if len(attributes) == 0 or attributes == u(chr(stats['default_attribute'])) * len(attributes):
@ -294,29 +309,18 @@ class ConqueSole(Conque):
self.apply_color(1, len(attributes), self.l)
return
# if text attribute is different, call add_color()
attr = None
start = 0
for i in range(0, len(attributes)):
c = ord(attributes[i])
if c != attr:
if attr and attr != stats['default_attribute']:
self.color_changes = self.translate_color(attr)
self.apply_color(start + 1, i + 1, self.l)
start = i
attr = c
if attr and attr != stats['default_attribute']:
self.color_changes = self.translate_color(attr)
self.apply_color(start + 1, len(attributes), self.l)
attribute_chunks = CONQUE_WIN32_REGEX_ATTR.findall(attributes)
offset = 0
for attr in attribute_chunks:
attr_num = ord(attr[1])
if attr_num != stats['default_attribute']:
self.color_changes = self.translate_color(attr_num)
self.apply_color(offset + 1, offset + len(attr[0]) + 1, self.l)
offset += len(attr[0])
# }}}
#########################################################################
def translate_color(self, attr): # {{{
def translate_color(self, attr):
""" Convert Windows console attributes into RGB colors """
# check for cached color
if attr in self.color_cache:
@ -363,24 +367,20 @@ class ConqueSole(Conque):
return color
# }}}
#########################################################################
# write virtual key code to shared memory using proprietary escape seq
def write_vk(self, vk_code): # {{{
def write_vk(self, vk_code):
""" write virtual key code to shared memory using proprietary escape seq """
self.proc.write_vk(vk_code)
# }}}
# *********************************************************************************************
# resize if needed
def update_window_size(self): # {{{
def update_window_size(self):
""" Resize underlying console if Vim buffer size has changed """
if vim.current.window.width != self.columns or vim.current.window.height != self.lines:
# reset all window size attributes to default
self.columns = vim.current.window.width
self.lines = vim.current.window.height
@ -390,12 +390,14 @@ class ConqueSole(Conque):
self.proc.window_resize(vim.current.window.height, vim.current.window.width)
# }}}
# *********************************************************************************************
# resize if needed
def set_cursor(self, line, column):
""" Update cursor position in Vim buffer """
def set_cursor(self, line, column): # {{{
# handle offset
line += self.offset
# shift cursor position to handle concealed text
if self.enable_colors and self.color_mode == 'conceal':
@ -406,54 +408,51 @@ class ConqueSole(Conque):
else:
break
# figure out line
real_line = line
if real_line > len(self.buffer):
for l in range(len(self.buffer) - 1, real_line):
buffer_line = line
if buffer_line > len(self.buffer):
for l in range(len(self.buffer) - 1, buffer_line):
self.buffer.append('')
# figure out column
real_column = column
if len(self.buffer[real_line - 1]) < real_column:
self.buffer[real_line - 1] = self.buffer[real_line - 1] + ' ' * (real_column - len(self.buffer[real_line - 1]))
if len(self.buffer[buffer_line - 1]) < real_column:
self.buffer[buffer_line - 1] = self.buffer[buffer_line - 1] + ' ' * (real_column - len(self.buffer[buffer_line - 1]))
# python version is occasionally grumpy
try:
vim.current.window.cursor = (real_line, real_column - 1)
vim.current.window.cursor = (buffer_line, real_column - 1)
except:
vim.command('call cursor(' + str(real_line) + ', ' + str(real_column) + ')')
# }}}
vim.command('call cursor(' + str(buffer_line) + ', ' + str(real_column) + ')')
# *********************************************************************************************
# go into idle mode
def idle(self): # {{{
def idle(self):
""" go into idle mode """
self.proc.idle()
# }}}
# *********************************************************************************************
# resume from idle mode
def resume(self): # {{{
def resume(self):
""" resume from idle mode """
self.proc.resume()
# }}}
# *********************************************************************************************
# end subprocess
def close(self):
""" end console subprocess """
self.proc.close()
# *********************************************************************************************
# end subprocess forcefully
def abort(self):
""" end subprocess forcefully """
self.proc.close()
def get_buffer_line(self, line):
""" get buffer line """
return line
# vim:foldmethod=marker

View File

@ -1,11 +1,11 @@
# FILE: autoload/conque_term/conque_sole_communicator.py {{{
# FILE: autoload/conque_term/conque_sole_communicator.py
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
# WEBSITE: http://conque.googlecode.com
# MODIFIED: 2010-11-15
# VERSION: 2.0, for Vim 7.0
# MODIFIED: 2011-08-12
# VERSION: 2.2, for Vim 7.0
# LICENSE:
# Conque - Vim terminal/console emulator
# Copyright (C) 2009-2010 Nico Raffo
# Copyright (C) 2009-__YEAR__ Nico Raffo
#
# MIT License
#
@ -25,17 +25,20 @@
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE. }}}
# THE SOFTWARE.
"""
ConqueSoleCommunicator
Script to transfer communications between python being run in Vim and a
subprocess run inside a Windows console. This is required since interactive
programs in Windows appear to require a console, and python run in Vim is
not attached to any console. So a console version of python must be initiated
for the subprocess. Communication is then done with the use of shared memory
objects. Good times!
This script will create a new Windows console and start the requested program
inside of it. This process is launched independently from the parent Vim
program, so it has no access to the vim module.
The main loop in this script reads data from the console and syncs it onto
blocks of memory shared with the Vim process. In this way the Vim process
and this script can communicate with each other.
"""
import time
@ -54,17 +57,12 @@ if __name__ == '__main__':
# attempt to catch ALL exceptions to fend of zombies
try:
# startup and config {{{
# simple arg validation
if len(sys.argv) < 5:
exit()
# shared memory size
CONQUE_SOLE_COMMANDS_SIZE = 255
# maximum time this thing reads. 0 means no limit. Only for testing.
max_loops = 0
@ -86,12 +84,18 @@ if __name__ == '__main__':
# console height
console_height = int(sys.argv[3])
# code page
code_page = int(sys.argv[4])
# code page
fast_mode = int(sys.argv[5])
# the actual subprocess to run
cmd_line = " ".join(sys.argv[4:])
cmd_line = " ".join(sys.argv[6:])
# width and height
options = {'LINES': console_height, 'COLUMNS': console_width}
options = {'LINES': console_height, 'COLUMNS': console_width, 'CODE_PAGE': code_page, 'FAST_MODE': fast_mode}
@ -106,12 +110,10 @@ if __name__ == '__main__':
is_idle = True
shm_command.clear()
# }}}
##############################################################
# Create the subprocess
# {{{
proc = ConqueSoleSubprocess()
res = proc.open(cmd_line, mem_key, options)
@ -119,8 +121,6 @@ if __name__ == '__main__':
exit()
# }}}
##############################################################
# main loop!
@ -135,7 +135,7 @@ if __name__ == '__main__':
if not proc.is_alive():
proc.close()
exit()
break
# check for change in buffer focus
cmd = shm_command.read()

View File

@ -1,11 +1,11 @@
# FILE: autoload/conque_term/conque_sole_shared_memory.py {{{
# FILE: autoload/conque_term/conque_sole_shared_memory.py
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
# WEBSITE: http://conque.googlecode.com
# MODIFIED: 2010-11-15
# VERSION: 2.0, for Vim 7.0
# MODIFIED: 2011-08-12
# VERSION: 2.2, for Vim 7.0
# LICENSE:
# Conque - Vim terminal/console emulator
# Copyright (C) 2009-2010 Nico Raffo
# Copyright (C) 2009-__YEAR__ Nico Raffo
#
# MIT License
#
@ -25,17 +25,20 @@
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE. }}}
# THE SOFTWARE.
"""Wrapper class for shared memory between Windows python processes"""
"""
Wrapper class for shared memory between Windows python processes
Adds a small amount of functionality to the standard mmap module.
"""
import mmap
import sys
if sys.version_info[0] == 2:
CONQUE_PYTHON_VERSION = 2
else:
CONQUE_PYTHON_VERSION = 3
# PYTHON VERSION
CONQUE_PYTHON_VERSION = sys.version_info[0]
if CONQUE_PYTHON_VERSION == 2:
import cPickle as pickle
@ -45,16 +48,14 @@ else:
class ConqueSoleSharedMemory():
# ****************************************************************************
# class properties
# {{{
# is the data being stored not fixed length
fixed_length = False
# maximum number of bytes per character, for fixed width blocks
char_width = 1
# fill memory with this character when clearing and fixed_length is true
fill_char = ' '
FILL_CHAR = None
# serialize and unserialize data automatically
serialize = False
@ -72,18 +73,25 @@ class ConqueSoleSharedMemory():
shm = None
# character encoding, dammit
encoding = 'ascii'
encoding = 'utf-8'
# pickle terminator
TERMINATOR = None
# }}}
# ****************************************************************************
# constructor I guess
def __init__(self, mem_size, mem_type, mem_key, fixed_length=False, fill_char=' ', serialize=False, encoding='utf-8'):
""" Initialize new shared memory block instance
def __init__(self, mem_size, mem_type, mem_key, fixed_length=False, fill_char=' ', serialize=False, encoding='ascii'): # {{{
Arguments:
mem_size -- Memory size in characters, depends on encoding argument to calcuate byte size
mem_type -- Label to identify what will be stored
mem_key -- Unique, probably random key to identify this block
fixed_length -- If set to true, assume the data stored will always fill the memory size
fill_char -- Initialize memory block with this character, only really helpful with fixed_length blocks
serialize -- Automatically serialize data passed to write. Allows storing non-byte data
encoding -- Character encoding to use when storing character data
"""
self.mem_size = mem_size
self.mem_type = mem_type
self.mem_key = mem_key
@ -93,12 +101,17 @@ class ConqueSoleSharedMemory():
self.encoding = encoding
self.TERMINATOR = str(chr(0)).encode(self.encoding)
# }}}
if CONQUE_PYTHON_VERSION == 3:
self.FILL_CHAR = fill_char
else:
self.FILL_CHAR = unicode(fill_char)
# ****************************************************************************
# create memory block
if fixed_length and encoding == 'utf-8':
self.char_width = 4
def create(self, access='write'): # {{{
def create(self, access='write'):
""" Create a new block of shared memory using the mmap module. """
if access == 'write':
mmap_access = mmap.ACCESS_WRITE
@ -107,28 +120,28 @@ class ConqueSoleSharedMemory():
name = "conque_%s_%s" % (self.mem_type, self.mem_key)
self.shm = mmap.mmap(0, self.mem_size, name, mmap_access)
self.shm = mmap.mmap(0, self.mem_size * self.char_width, name, mmap_access)
if not self.shm:
return False
else:
return True
# }}}
# ****************************************************************************
# read data
def read(self, chars=1, start=0):
""" Read data from shared memory.
def read(self, chars=1, start=0): # {{{
# invalid reads
if self.fixed_length and (chars == 0 or start + chars > self.mem_size):
return ''
If this is a fixed length block, read 'chars' characters from memory.
Otherwise read up until the TERMINATOR character (null byte).
If this memory is serialized, unserialize it automatically.
"""
# go to start position
self.shm.seek(start)
self.shm.seek(start * self.char_width)
if not self.fixed_length:
if self.fixed_length:
chars = chars * self.char_width
else:
chars = self.shm.find(self.TERMINATOR)
if chars == 0:
@ -150,13 +163,15 @@ class ConqueSoleSharedMemory():
return shm_str
# }}}
# ****************************************************************************
# write data
def write(self, text, start=0):
""" Write data to memory.
def write(self, text, start=0): # {{{
If memory is fixed length, simply write the 'text' characters at 'start' position.
Otherwise write 'text' characters and append a null character.
If memory is serializable, do so first.
"""
# simple scenario, let pickle create bytes
if self.serialize:
if CONQUE_PYTHON_VERSION == 3:
@ -167,36 +182,29 @@ class ConqueSoleSharedMemory():
else:
tb = text.encode(self.encoding, 'replace')
self.shm.seek(start)
# write to memory
self.shm.seek(start * self.char_width)
if self.fixed_length:
self.shm.write(tb)
else:
self.shm.write(tb + self.TERMINATOR)
# }}}
# ****************************************************************************
# clear
def clear(self, start=0): # {{{
def clear(self, start=0):
""" Clear memory block using self.fill_char. """
self.shm.seek(start)
if self.fixed_length:
self.shm.write(str(self.fill_char * self.mem_size).encode(self.encoding))
self.shm.write(str(self.fill_char * self.mem_size * self.char_width).encode(self.encoding))
else:
self.shm.write(self.TERMINATOR)
# }}}
# ****************************************************************************
# close
def close(self):
""" Close/destroy memory block. """
self.shm.close()
# vim:foldmethod=marker

View File

@ -1,11 +1,11 @@
# FILE: autoload/conque_term/conque_sole_subprocess.py {{{
# FILE: autoload/conque_term/conque_sole_subprocess.py
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
# WEBSITE: http://conque.googlecode.com
# MODIFIED: 2010-11-15
# VERSION: 2.0, for Vim 7.0
# MODIFIED: 2011-08-12
# VERSION: 2.2, for Vim 7.0
# LICENSE:
# Conque - Vim terminal/console emulator
# Copyright (C) 2009-2010 Nico Raffo
# Copyright (C) 2009-__YEAR__ Nico Raffo
#
# MIT License
#
@ -25,9 +25,9 @@
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE. }}}
# THE SOFTWARE.
""" ConqueSoleSubprocess {{{
""" ConqueSoleSubprocess
Creates a new subprocess with it's own (hidden) console window.
@ -47,12 +47,7 @@ Sample Usage:
shm_in.write("dir\r")
output = shm_out.read(...)
Requirements:
* Python for Windows extensions. Available at http://sourceforge.net/projects/pywin32/
* Must be run from process attached to an existing console.
}}} """
"""
import time
import re
@ -66,9 +61,7 @@ from conque_sole_shared_memory import *
class ConqueSoleSubprocess():
# Class properties {{{
#window = None
# subprocess handle and pid
handle = None
pid = None
@ -117,25 +110,16 @@ class ConqueSoleSubprocess():
# are we still a valid process?
is_alive = True
# running in fast mode
fast_mode = 0
# used for periodic execution of screen and memory redrawing
screen_redraw_ct = 0
mem_redraw_ct = 0
# }}}
# ****************************************************************************
# initialize class instance
def __init__(self): # {{{
pass
# }}}
# ****************************************************************************
# Create proccess cmd
def open(self, cmd, mem_key, options={}): # {{{
def open(self, cmd, mem_key, options={}):
""" Create subproccess running in hidden console window. """
@ -156,6 +140,9 @@ class ConqueSoleSubprocess():
self.window_height = options['LINES']
self.buffer_width = options['COLUMNS']
# fast mode
self.fast_mode = options['FAST_MODE']
# console window options
si = STARTUPINFO()
@ -178,15 +165,18 @@ class ConqueSoleSubprocess():
# process info
self.pid = pi.dwProcessId
self.handle = pi.hProcess
# attach ourselves to the new console
# console is not immediately available
for i in range(10):
time.sleep(1)
time.sleep(0.25)
try:
res = ctypes.windll.kernel32.AttachConsole(self.pid)
@ -221,6 +211,13 @@ class ConqueSoleSubprocess():
# set window size
self.set_window_size(self.window_width, self.window_height)
# set utf-8 code page
if 'CODE_PAGE' in options and options['CODE_PAGE'] > 0:
if ctypes.windll.kernel32.IsValidCodePage(ctypes.c_uint(options['CODE_PAGE'])):
ctypes.windll.kernel32.SetConsoleCP(ctypes.c_uint(options['CODE_PAGE']))
ctypes.windll.kernel32.SetConsoleOutputCP(ctypes.c_uint(options['CODE_PAGE']))
# init shared memory
self.init_shared_memory(mem_key)
@ -234,17 +231,9 @@ class ConqueSoleSubprocess():
return False
# }}}
# ****************************************************************************
# create shared memory objects
def init_shared_memory(self, mem_key): # {{{
buf_info = self.get_buffer_info()
def init_shared_memory(self, mem_key):
""" Create shared memory objects. """
self.shm_input = ConqueSoleSharedMemory(CONQUE_SOLE_INPUT_SIZE, 'input', mem_key)
self.shm_input.create('write')
@ -254,6 +243,8 @@ class ConqueSoleSubprocess():
self.shm_output.create('write')
self.shm_output.clear()
if not self.fast_mode:
buf_info = self.get_buffer_info()
self.shm_attributes = ConqueSoleSharedMemory(self.buffer_height * self.buffer_width, 'attributes', mem_key, True, chr(buf_info.wAttributes), encoding='latin-1')
self.shm_attributes.create('write')
self.shm_attributes.clear()
@ -276,12 +267,9 @@ class ConqueSoleSubprocess():
return True
# }}}
# ****************************************************************************
# check for and process commands
def check_commands(self): # {{{
def check_commands(self):
""" Check for and process commands from Vim. """
cmd = self.shm_command.read()
@ -320,12 +308,9 @@ class ConqueSoleSubprocess():
buf_info = self.get_buffer_info()
self.reset_console(buf_info, add_block=False)
# }}}
# ****************************************************************************
# read from windows console and update output buffer
def read(self, timeout=0): # {{{
def read(self):
""" Read from windows console and update shared memory blocks. """
# no point really
if self.screen_redraw_ct == 0 and not self.is_alive():
@ -337,12 +322,6 @@ class ConqueSoleSubprocess():
# check for commands
self.check_commands()
# emulate timeout by sleeping timeout time
if timeout > 0:
read_timeout = float(timeout) / 1000
time.sleep(read_timeout)
# get cursor position
buf_info = self.get_buffer_info()
curs_line = buf_info.dwCursorPosition.Y
@ -353,12 +332,15 @@ class ConqueSoleSubprocess():
self.screen_redraw_ct = 0
read_start = self.top
read_end = buf_info.srWindow.Bottom + 1
read_end = max([buf_info.srWindow.Bottom + 1, curs_line + 1])
else:
read_start = curs_line
read_end = curs_line + 1
# vars used in for loop
coord = COORD(0, 0)
chars_read = ctypes.c_int(0)
@ -369,38 +351,54 @@ class ConqueSoleSubprocess():
coord.Y = i
res = ctypes.windll.kernel32.ReadConsoleOutputCharacterW(self.stdout, ctypes.byref(self.tc), self.buffer_width, coord, ctypes.byref(chars_read))
if not self.fast_mode:
ctypes.windll.kernel32.ReadConsoleOutputAttribute(self.stdout, ctypes.byref(self.ac), self.buffer_width, coord, ctypes.byref(chars_read))
t = self.tc.value
if not self.fast_mode:
a = self.ac.value
# add data
if i >= len(self.data):
self.data.append(t)
self.attributes.append(a)
else:
for j in range(len(self.data), i + 1):
self.data.append('')
if not self.fast_mode:
self.attributes.append('')
self.data[i] = t
if not self.fast_mode:
self.attributes[i] = a
#for i in range(0, len(t)):
# write new output to shared memory
try:
if self.mem_redraw_ct == CONQUE_SOLE_MEM_REDRAW:
self.mem_redraw_ct = 0
self.shm_output.write(''.join(self.data))
self.shm_attributes.write(''.join(self.attributes))
for i in range(0, len(self.data)):
self.shm_output.write(text=self.data[i], start=self.buffer_width * i)
if not self.fast_mode:
self.shm_attributes.write(text=self.attributes[i], start=self.buffer_width * i)
else:
self.shm_output.write(text=''.join(self.data[read_start:read_end]), start=read_start * self.buffer_width)
self.shm_attributes.write(text=''.join(self.attributes[read_start:read_end]), start=read_start * self.buffer_width)
for i in range(read_start, read_end):
self.shm_output.write(text=self.data[i], start=self.buffer_width * i)
if not self.fast_mode:
self.shm_attributes.write(text=self.attributes[i], start=self.buffer_width * i)
#self.shm_output.write(text=''.join(self.data[read_start:read_end]), start=read_start * self.buffer_width)
#self.shm_attributes.write(text=''.join(self.attributes[read_start:read_end]), start=read_start * self.buffer_width)
# write cursor position to shared memory
stats = {'top_offset': buf_info.srWindow.Top, 'default_attribute': buf_info.wAttributes, 'cursor_x': curs_col, 'cursor_y': curs_line, 'is_alive': 1}
self.shm_stats.write(stats)
# adjust screen position
self.top = buf_info.srWindow.Top
self.cursor_line = curs_line
@ -409,18 +407,22 @@ class ConqueSoleSubprocess():
if curs_line > buf_info.dwSize.Y - 200:
self.reset_console(buf_info)
except:
pass
# increment redraw counters
self.screen_redraw_ct += 1
self.mem_redraw_ct += 1
return None
# }}}
# ****************************************************************************
# clear the console and set cursor at home position
def reset_console(self, buf_info, add_block=True): # {{{
def reset_console(self, buf_info, add_block=True):
""" Extend the height of the current console if the cursor postion gets within 200 lines of the current size. """
# sometimes we just want to change the buffer width,
# in which case no need to add another block
@ -431,6 +433,7 @@ class ConqueSoleSubprocess():
self.shm_output.close()
self.shm_output = None
if not self.fast_mode:
self.shm_attributes.close()
self.shm_attributes = None
@ -448,6 +451,7 @@ class ConqueSoleSubprocess():
self.data[i] = self.data[i] + ' ' * (self.buffer_width - len(self.data[i]))
self.shm_output.write(''.join(self.data))
if not self.fast_mode:
self.shm_attributes = ConqueSoleSharedMemory(self.buffer_height * self.buffer_width * self.output_blocks, 'attributes', mem_key, True, chr(buf_info.wAttributes), encoding='latin-1')
self.shm_attributes.create('write')
self.shm_attributes.clear()
@ -456,6 +460,7 @@ class ConqueSoleSubprocess():
if len(self.attributes[0]) < self.buffer_width:
for i in range(0, len(self.attributes)):
self.attributes[i] = self.attributes[i] + chr(buf_info.wAttributes) * (self.buffer_width - len(self.attributes[i]))
if not self.fast_mode:
self.shm_attributes.write(''.join(self.attributes))
# notify wrapper of new output block
@ -481,19 +486,20 @@ class ConqueSoleSubprocess():
self.tc = ctypes.create_unicode_buffer(self.buffer_width)
self.ac = ctypes.create_unicode_buffer(self.buffer_width)
# }}}
# ****************************************************************************
# write text to console. this function just parses out special sequences for
# special key events and passes on the text to the plain or virtual key functions
def write(self): # {{{
def write(self):
""" Write text to console.
This function just parses out special sequences for special key events
and passes on the text to the plain or virtual key functions.
"""
# get input from shared mem
text = self.shm_input.read()
# nothing to do here
if text == '':
if text == u(''):
return
@ -502,7 +508,7 @@ class ConqueSoleSubprocess():
self.shm_input.clear()
# split on VK codes
chunks = CONQUE_SEQ_REGEX_VK.split(text)
chunks = CONQUE_WIN32_REGEX_VK.split(text)
# if len() is one then no vks
if len(chunks) == 1:
@ -517,45 +523,48 @@ class ConqueSoleSubprocess():
if t == '':
continue
if CONQUE_SEQ_REGEX_VK.match(t):
if CONQUE_WIN32_REGEX_VK.match(t):
self.write_vk(t[2:-2])
else:
self.write_plain(t)
# }}}
# ****************************************************************************
def write_plain(self, text): # {{{
def write_plain(self, text):
""" Write simple text to subprocess. """
li = INPUT_RECORD * len(text)
list_input = li()
for i in range(0, len(text)):
# create keyboard input
ke = KEY_EVENT_RECORD()
ke.bKeyDown = ctypes.c_byte(1)
ke.wRepeatCount = ctypes.c_short(1)
cnum = ord(text[i])
ke.wVirtualKeyCode = ctypes.windll.user32.VkKeyScanW(cnum)
ke.wVirtualScanCode = ctypes.c_short(ctypes.windll.user32.MapVirtualKeyW(int(cnum), 0))
if cnum > 31:
ke.uChar.UnicodeChar = u(chr(cnum))
ke.uChar.UnicodeChar = uchr(cnum)
elif cnum == 3:
ctypes.windll.kernel32.GenerateConsoleCtrlEvent(0, self.pid)
ke.uChar.UnicodeChar = u(chr(cnum))
ke.uChar.UnicodeChar = uchr(cnum)
ke.wVirtualKeyCode = ctypes.windll.user32.VkKeyScanW(cnum + 96)
ke.dwControlKeyState = LEFT_CTRL_PRESSED
ke.dwControlKeyState |= LEFT_CTRL_PRESSED
else:
ke.uChar.UnicodeChar = u(chr(cnum))
ke.uChar.UnicodeChar = uchr(cnum)
if cnum in CONQUE_WINDOWS_VK_INV:
ke.wVirtualKeyCode = cnum
else:
ke.wVirtualKeyCode = ctypes.windll.user32.VkKeyScanW(cnum + 96)
ke.dwControlKeyState = LEFT_CTRL_PRESSED
ke.dwControlKeyState |= LEFT_CTRL_PRESSED
kc = INPUT_RECORD(KEY_EVENT)
kc.Event.KeyEvent = ke
@ -574,27 +583,41 @@ class ConqueSoleSubprocess():
# }}}
def write_vk(self, vk_code):
""" Write special characters to console subprocess. """
# ****************************************************************************
def write_vk(self, vk_code): # {{{
code = None
ctrl_pressed = False
# this could be made more generic when more attributes
# other than ctrl_pressed are available
vk_attributes = vk_code.split(';')
for attr in vk_attributes:
if attr == CONQUE_VK_ATTR_CTRL_PRESSED:
ctrl_pressed = True
else:
code = attr
li = INPUT_RECORD * 1
# create keyboard input
ke = KEY_EVENT_RECORD()
ke.uChar.UnicodeChar = u(chr(0))
ke.wVirtualKeyCode = ctypes.c_short(int(vk_code))
ke.wVirtualScanCode = ctypes.c_short(ctypes.windll.user32.MapVirtualKeyW(int(vk_code), 0))
ke.uChar.UnicodeChar = uchr(0)
ke.wVirtualKeyCode = ctypes.c_short(int(code))
ke.wVirtualScanCode = ctypes.c_short(ctypes.windll.user32.MapVirtualKeyW(int(code), 0))
ke.bKeyDown = ctypes.c_byte(1)
ke.wRepeatCount = ctypes.c_short(1)
# set enhanced key mode for arrow keys
if vk_code in CONQUE_WINDOWS_VK_ENHANCED:
if code in CONQUE_WINDOWS_VK_ENHANCED:
ke.dwControlKeyState = ENHANCED_KEY
ke.dwControlKeyState |= ENHANCED_KEY
if ctrl_pressed:
ke.dwControlKeyState |= LEFT_CTRL_PRESSED
kc = INPUT_RECORD(KEY_EVENT)
kc.Event.KeyEvent = ke
@ -610,11 +633,8 @@ class ConqueSoleSubprocess():
# }}}
# ****************************************************************************
def close(self): # {{{
def close(self):
""" Close all running subproccesses """
# record status
self.is_alive = False
@ -656,18 +676,18 @@ class ConqueSoleSubprocess():
pass
def close_pid(self, pid):
""" Terminate a single process. """
handle = ctypes.windll.kernel32.OpenProcess(PROCESS_TERMINATE, 0, pid)
ctypes.windll.kernel32.TerminateProcess(handle, -1)
ctypes.windll.kernel32.CloseHandle(handle)
# }}}
# ****************************************************************************
# check process health
def is_alive(self): # {{{
def is_alive(self):
""" Check process health. """
status = ctypes.windll.kernel32.WaitForSingleObject(self.handle, 1)
@ -677,21 +697,15 @@ class ConqueSoleSubprocess():
return self.is_alive
# }}}
# ****************************************************************************
# return screen data as string
def get_screen_text(self): # {{{
def get_screen_text(self):
""" Return screen data as string. """
return "\n".join(self.data)
# }}}
# ****************************************************************************
def set_window_size(self, width, height): # {{{
def set_window_size(self, width, height):
""" Change Windows console size. """
@ -735,19 +749,14 @@ class ConqueSoleSubprocess():
self.window_width = buf_info.srWindow.Right + 1
self.window_height = buf_info.srWindow.Bottom + 1
# }}}
# ****************************************************************************
# get buffer info, used a lot
def get_buffer_info(self): # {{{
def get_buffer_info(self):
""" Retrieve commonly-used buffer information. """
buf_info = CONSOLE_SCREEN_BUFFER_INFO()
ctypes.windll.kernel32.GetConsoleScreenBufferInfo(self.stdout, ctypes.byref(buf_info))
return buf_info
# }}}
# vim:foldmethod=marker

View File

@ -1,11 +1,11 @@
# FILE: autoload/conque_term/conque_sole_wrapper.py {{{
# FILE: autoload/conque_term/conque_sole_wrapper.py
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
# WEBSITE: http://conque.googlecode.com
# MODIFIED: 2010-11-15
# VERSION: 2.0, for Vim 7.0
# MODIFIED: 2011-08-12
# VERSION: 2.2, for Vim 7.0
# LICENSE:
# Conque - Vim terminal/console emulator
# Copyright (C) 2009-2010 Nico Raffo
# Copyright (C) 2009-__YEAR__ Nico Raffo
#
# MIT License
#
@ -25,15 +25,17 @@
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE. }}}
# THE SOFTWARE.
""" ConqueSoleSubprocessWrapper {{{
"""
ConqueSoleSubprocessWrapper
Subprocess wrapper to deal with Windows insanity. Launches console based python,
which in turn launches originally requested command. Communicates with cosole
python through shared memory objects.
}}} """
"""
import ctypes
import time
@ -41,8 +43,7 @@ import time
class ConqueSoleWrapper():
# class properties {{{
# unique key used for shared memory block names
shm_key = ''
# process info
@ -53,7 +54,6 @@ class ConqueSoleWrapper():
bucket = None
# console size
# NOTE: columns should never change after open() is called
lines = 24
columns = 80
@ -69,33 +69,31 @@ class ConqueSoleWrapper():
# console python process
proc = None
# }}}
#########################################################################
# unused
def open(self, cmd, lines, columns, python_exe='python.exe', communicator_py='conque_sole_communicator.py', options={}):
""" Launch python.exe subprocess which will in turn launch the user's program.
def __init__(self): # {{{
Arguments:
cmd -- The user's command to run. E.g. "Powershell.exe" or "C:\Python27\Scripts\ipython.bat"
lines, columns -- The size of the console, also the size of the Vim buffer
python.exe -- The path to the python executable, typically C:\PythonXX\python.exe
communicator_py -- The path to the subprocess controller script in the user's vimfiles directory
options -- optional configuration
"""
self.lines = lines
self.columns = columns
self.bucket = u('')
# }}}
#########################################################################
# run communicator process which will in turn run cmd
def open(self, cmd, options={}, python_exe='python.exe', communicator_py='conque_sole_communicator.py'): # {{{
self.lines = options['LINES']
self.columns = options['COLUMNS']
# create a shm key
self.shm_key = 'mk' + str(time.time())
# python command
cmd_line = '%s "%s" %s %d %d %s' % (python_exe, communicator_py, self.shm_key, int(self.columns), int(self.lines), cmd)
cmd_line = '%s "%s" %s %d %d %d %d %s' % (python_exe, communicator_py, self.shm_key, int(self.columns), int(self.lines), int(options['CODE_PAGE']), int(CONQUE_FAST_MODE), cmd)
# console window attributes
flags = NORMAL_PRIORITY_CLASS | DETACHED_PROCESS
flags = NORMAL_PRIORITY_CLASS | DETACHED_PROCESS | CREATE_UNICODE_ENVIRONMENT
si = STARTUPINFO()
pi = PROCESS_INFORMATION()
@ -114,13 +112,13 @@ class ConqueSoleWrapper():
# init shared memory objects
self.init_shared_memory(self.shm_key)
# }}}
#########################################################################
# read output from shared memory
def read(self, start_line, num_lines, timeout=0):
""" Read a range of console lines from shared memory.
def read(self, start_line, num_lines, timeout=0): # {{{
Returns a pair of lists containing the console text and console text attributes.
"""
# emulate timeout by sleeping timeout time
if timeout > 0:
read_timeout = float(timeout) / 1000
@ -133,16 +131,14 @@ class ConqueSoleWrapper():
# get output
for i in range(start_line, start_line + num_lines + 1):
output.append(self.shm_output.read(self.columns, i * self.columns))
if not CONQUE_FAST_MODE:
attributes.append(self.shm_attributes.read(self.columns, i * self.columns))
return (output, attributes)
# }}}
#########################################################################
# get current cursor/scroll position
def get_stats(self): # {{{
def get_stats(self):
""" Return a dictionary with current console cursor and scrolling information. """
try:
rescroll = self.shm_rescroll.read()
@ -156,6 +152,7 @@ class ConqueSoleWrapper():
self.shm_output.close()
self.shm_output = None
if not CONQUE_FAST_MODE:
self.shm_attributes.close()
self.shm_attributes = None
@ -164,6 +161,7 @@ class ConqueSoleWrapper():
self.shm_output = ConqueSoleSharedMemory(CONQUE_SOLE_BUFFER_LENGTH * self.columns * rescroll['data']['blocks'], 'output', rescroll['data']['mem_key'], True)
self.shm_output.create('read')
if not CONQUE_FAST_MODE:
self.shm_attributes = ConqueSoleSharedMemory(CONQUE_SOLE_BUFFER_LENGTH * self.columns * rescroll['data']['blocks'], 'attributes', rescroll['data']['mem_key'], True, encoding='latin-1')
self.shm_attributes.create('read')
@ -178,12 +176,10 @@ class ConqueSoleWrapper():
return self.stats
# }}}
#########################################################################
# get process status
def is_alive(self):
""" Get process status. """
def is_alive(self): # {{{
if not self.shm_stats:
return True
@ -192,16 +188,12 @@ class ConqueSoleWrapper():
return (stats_str['is_alive'])
else:
return True
# }}}
#########################################################################
# write input to shared memory
def write(self, text): # {{{
self.bucket += u(text, 'ascii', 'replace')
def write(self, text):
""" Write input to shared memory. """
self.bucket += text
istr = self.shm_input.read()
@ -210,51 +202,36 @@ class ConqueSoleWrapper():
self.shm_input.write(self.bucket[:500])
self.bucket = self.bucket[500:]
# }}}
#########################################################################
# write virtual key code to shared memory using proprietary escape seq
def write_vk(self, vk_code):
""" Write virtual key code to shared memory using proprietary escape sequences. """
def write_vk(self, vk_code): # {{{
seq = "\x1b[" + str(vk_code) + "VK"
seq = u("\x1b[") + u(str(vk_code)) + u("VK")
self.write(seq)
# }}}
#########################################################################
# idle
def idle(self): # {{{
def idle(self):
""" Write idle command to shared memory block, so subprocess controller can hibernate. """
self.shm_command.write({'cmd': 'idle', 'data': {}})
# }}}
#########################################################################
# resume
def resume(self): # {{{
def resume(self):
""" Write resume command to shared memory block, so subprocess controller can wake up. """
self.shm_command.write({'cmd': 'resume', 'data': {}})
# }}}
#########################################################################
# shut it all down
def close(self): # {{{
def close(self):
""" Shut it all down. """
self.shm_command.write({'cmd': 'close', 'data': {}})
time.sleep(0.2)
# }}}
#########################################################################
# resize console window
def window_resize(self, lines, columns): # {{{
def window_resize(self, lines, columns):
""" Resize console window. """
self.lines = lines
@ -264,12 +241,9 @@ class ConqueSoleWrapper():
self.shm_resize.write({'cmd': 'resize', 'data': {'width': columns, 'height': lines}})
# }}}
# ****************************************************************************
# create shared memory objects
def init_shared_memory(self, mem_key): # {{{
def init_shared_memory(self, mem_key):
""" Create shared memory objects. """
self.shm_input = ConqueSoleSharedMemory(CONQUE_SOLE_INPUT_SIZE, 'input', mem_key)
self.shm_input.create('write')
@ -278,6 +252,7 @@ class ConqueSoleWrapper():
self.shm_output = ConqueSoleSharedMemory(CONQUE_SOLE_BUFFER_LENGTH * self.columns, 'output', mem_key, True)
self.shm_output.create('write')
if not CONQUE_FAST_MODE:
self.shm_attributes = ConqueSoleSharedMemory(CONQUE_SOLE_BUFFER_LENGTH * self.columns, 'attributes', mem_key, True, encoding='latin-1')
self.shm_attributes.create('write')
@ -299,6 +274,5 @@ class ConqueSoleWrapper():
return True
# }}}
# vim:foldmethod=marker

View File

@ -1,11 +1,11 @@
# FILE: autoload/conque_term/conque_subprocess.py {{{
# FILE: autoload/conque_term/conque_subprocess.py
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
# WEBSITE: http://conque.googlecode.com
# MODIFIED: 2010-11-15
# VERSION: 2.0, for Vim 7.0
# MODIFIED: 2011-08-12
# VERSION: 2.2, for Vim 7.0
# LICENSE:
# Conque - Vim terminal/console emulator
# Copyright (C) 2009-2010 Nico Raffo
# Copyright (C) 2009-__YEAR__ Nico Raffo
#
# MIT License
#
@ -25,7 +25,7 @@
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE. }}}
# THE SOFTWARE.
"""
ConqueSubprocess
@ -43,7 +43,6 @@ Usage:
p.close()
"""
if CONQUE_PLATFORM == 'nix':
import os
import signal
import pty
@ -52,6 +51,7 @@ if CONQUE_PLATFORM == 'nix':
import fcntl
import termios
import struct
import shlex
class ConqueSubprocess:
@ -62,16 +62,12 @@ class ConqueSubprocess:
# stdout+stderr file descriptor
fd = None
# constructor
def __init__(self): # {{{
self.pid = 0
# }}}
# create pty + subprocess
def open(self, command, env={}): # {{{
def open(self, command, env={}):
""" Create subprocess using forkpty() """
# parse command
command_arr = command.split()
command_arr = shlex.split(command)
executable = command_arr[0]
args = command_arr
@ -90,7 +86,7 @@ class ConqueSubprocess:
for k in env.keys():
os.environ[k] = env[k]
# set some attributes
# set tty attributes
try:
attrs = tty.tcgetattr(1)
attrs[0] = attrs[0] ^ tty.IGNBRK
@ -111,14 +107,13 @@ class ConqueSubprocess:
else:
pass
# }}}
# read from pty
# XXX - select.poll() doesn't work in OS X!!!!!!!
def read(self, timeout=1): # {{{
def read(self, timeout=1):
""" Read from subprocess and return new output """
output = ''
read_timeout = float(timeout) / 1000
read_ct = 0
try:
# read from fd until no more output
@ -128,49 +123,59 @@ class ConqueSubprocess:
lines = ''
for s_fd in s_read:
try:
# increase read buffer so huge reads don't slow down
if read_ct < 10:
lines = os.read(self.fd, 32)
elif read_ct < 50:
lines = os.read(self.fd, 512)
else:
lines = os.read(self.fd, 2048)
read_ct += 1
except:
pass
output = output + lines.decode('utf-8')
if lines == '':
if lines == '' or read_ct > 100:
break
except:
pass
return output
# }}}
# I guess this one's not bad
def write(self, input): # {{{
def write(self, input):
""" Write new input to subprocess """
try:
if CONQUE_PYTHON_VERSION == 2:
os.write(self.fd, input)
os.write(self.fd, input.encode('utf-8', 'ignore'))
else:
os.write(self.fd, bytes(input, 'utf-8'))
except:
pass
# }}}
# signal process
def signal(self, signum): # {{{
def signal(self, signum):
""" signal process """
try:
os.kill(self.pid, signum)
except:
pass
# }}}
# close process
def close(self): # {{{
def close(self):
""" close process with sigterm signal """
self.signal(15)
# }}}
# get process status
def is_alive(self): #{{{
def is_alive(self):
""" get process status """
p_status = True
try:
if os.waitpid(self.pid, os.WNOHANG)[0]:
p_status = False
@ -179,17 +184,15 @@ class ConqueSubprocess:
return p_status
# }}}
# update window size in kernel, then send SIGWINCH to fg process
def window_resize(self, lines, columns): # {{{
def window_resize(self, lines, columns):
""" update window size in kernel, then send SIGWINCH to fg process """
try:
fcntl.ioctl(self.fd, termios.TIOCSWINSZ, struct.pack("HHHH", lines, columns, 0, 0))
os.kill(self.pid, signal.SIGWINCH)
except:
pass
# }}}
# vim:foldmethod=marker

View File

@ -1,11 +1,11 @@
# FILE: autoload/conque_term/conque_win32_util.py {{{
# FILE: autoload/conque_term/conque_win32_util.py
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
# WEBSITE: http://conque.googlecode.com
# MODIFIED: 2010-11-15
# VERSION: 2.0, for Vim 7.0
# MODIFIED: 2011-08-12
# VERSION: 2.2, for Vim 7.0
# LICENSE:
# Conque - Vim terminal/console emulator
# Copyright (C) 2009-2010 Nico Raffo
# Copyright (C) 2009-__YEAR__ Nico Raffo
#
# MIT License
#
@ -25,15 +25,15 @@
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE. }}}
# THE SOFTWARE.
"""Python structures used for ctypes interaction"""
""" Python constants and structures used for ctypes interaction. """
from ctypes import *
# Constants
# create process flag constants {{{
# create process flag constants
CREATE_BREAKAWAY_FROM_JOB = 0x01000000
CREATE_DEFAULT_ERROR_MODE = 0x04000000
@ -46,15 +46,14 @@ CREATE_SEPARATE_WOW_VDM = 0x00000800
CREATE_SHARED_WOW_VDM = 0x00001000
CREATE_SUSPENDED = 0x00000004
CREATE_UNICODE_ENVIRONMENT = 0x00000400
DEBUG_ONLY_THIS_PROCESS = 0x00000002
DEBUG_PROCESS = 0x00000001
DETACHED_PROCESS = 0x00000008
EXTENDED_STARTUPINFO_PRESENT = 0x00080000
INHERIT_PARENT_AFFINITY = 0x00010000
# }}}
# process priority constants {{{
# process priority constants
ABOVE_NORMAL_PRIORITY_CLASS = 0x00008000
BELOW_NORMAL_PRIORITY_CLASS = 0x00004000
@ -63,9 +62,8 @@ IDLE_PRIORITY_CLASS = 0x00000040
NORMAL_PRIORITY_CLASS = 0x00000020
REALTIME_PRIORITY_CLASS = 0x00000100
# }}}
# startup info constants {{{
# startup info constants
STARTF_FORCEONFEEDBACK = 0x00000040
STARTF_FORCEOFFFEEDBACK = 0x00000080
@ -81,9 +79,8 @@ STARTF_USESHOWWINDOW = 0x00000001
STARTF_USESIZE = 0x00000002
STARTF_USESTDHANDLES = 0x00000100
# }}}
# show window constants {{{
# show window constants
SW_FORCEMINIMIZE = 11
SW_HIDE = 0
@ -99,9 +96,8 @@ SW_SHOWNA = 8
SW_SHOWNOACTIVATE = 4
SW_SHOWNORMAL = 1
# }}}
# input event types {{{
# input event types
FOCUS_EVENT = 0x0010
KEY_EVENT = 0x0001
@ -109,9 +105,8 @@ MENU_EVENT = 0x0008
MOUSE_EVENT = 0x0002
WINDOW_BUFFER_SIZE_EVENT = 0x0004
# }}}
# key event modifiers {{{
# key event modifiers
CAPSLOCK_ON = 0x0080
ENHANCED_KEY = 0x0100
@ -123,9 +118,8 @@ RIGHT_CTRL_PRESSED = 0x0004
SCROLLLOCK_ON = 0x0040
SHIFT_PRESSED = 0x0010
# }}}
# process access {{{
# process access
PROCESS_CREATE_PROCESS = 0x0080
PROCESS_CREATE_THREAD = 0x0002
@ -140,17 +134,15 @@ PROCESS_VM_OPERATION = 0x0008
PROCESS_VM_READ = 0x0010
PROCESS_VM_WRITE = 0x0020
# }}}
# input / output handles {{{
# input / output handles
STD_INPUT_HANDLE = c_ulong(-10)
STD_OUTPUT_HANDLE = c_ulong(-11)
STD_ERROR_HANDLE = c_ulong(-12)
# }}}
CONQUE_WINDOWS_VK = { # {{{
CONQUE_WINDOWS_VK = {
'VK_LBUTTON': 0x0001,
'VK_RBUTTON': 0x0002,
'VK_CANCEL': 0x0003,
@ -280,19 +272,16 @@ CONQUE_WINDOWS_VK_ENHANCED = {
str(int(CONQUE_WINDOWS_VK['VK_END'])): 1
}
# }}}
# structures used for CreateProcess
# Odd types {{{
# Odd types
LPBYTE = POINTER(c_ubyte)
LPTSTR = POINTER(c_char)
# }}}
class STARTUPINFO(Structure): # {{{
class STARTUPINFO(Structure):
_fields_ = [("cb", c_ulong),
("lpReserved", LPTSTR),
("lpDesktop", LPTSTR),
@ -315,9 +304,8 @@ class STARTUPINFO(Structure): # {{{
def to_str(self):
return ''
# }}}
class PROCESS_INFORMATION(Structure): # {{{
class PROCESS_INFORMATION(Structure):
_fields_ = [("hProcess", c_void_p),
("hThread", c_void_p),
("dwProcessId", c_ulong),
@ -326,9 +314,8 @@ class PROCESS_INFORMATION(Structure): # {{{
def to_str(self):
return ''
# }}}
class MEMORY_BASIC_INFORMATION(Structure): # {{{
class MEMORY_BASIC_INFORMATION(Structure):
_fields_ = [("BaseAddress", c_void_p),
("AllocationBase", c_void_p),
("AllocationProtect", c_ulong),
@ -340,9 +327,8 @@ class MEMORY_BASIC_INFORMATION(Structure): # {{{
def to_str(self):
return ''
# }}}
class SECURITY_ATTRIBUTES(Structure): # {{{
class SECURITY_ATTRIBUTES(Structure):
_fields_ = [("Length", c_ulong),
("SecDescriptor", c_void_p),
("InheritHandle", c_bool)]
@ -350,18 +336,16 @@ class SECURITY_ATTRIBUTES(Structure): # {{{
def to_str(self):
return ''
# }}}
class COORD(Structure): # {{{
class COORD(Structure):
_fields_ = [("X", c_short),
("Y", c_short)]
def to_str(self):
return ''
# }}}
class SMALL_RECT(Structure): # {{{
class SMALL_RECT(Structure):
_fields_ = [("Left", c_short),
("Top", c_short),
("Right", c_short),
@ -370,9 +354,8 @@ class SMALL_RECT(Structure): # {{{
def to_str(self):
return ''
# }}}
class CONSOLE_SCREEN_BUFFER_INFO(Structure): # {{{
class CONSOLE_SCREEN_BUFFER_INFO(Structure):
_fields_ = [("dwSize", COORD),
("dwCursorPosition", COORD),
("wAttributes", c_short),
@ -382,27 +365,24 @@ class CONSOLE_SCREEN_BUFFER_INFO(Structure): # {{{
def to_str(self):
return ''
# }}}
class CHAR_UNION(Union): # {{{
class CHAR_UNION(Union):
_fields_ = [("UnicodeChar", c_wchar),
("AsciiChar", c_char)]
def to_str(self):
return ''
# }}}
class CHAR_INFO(Structure): # {{{
class CHAR_INFO(Structure):
_fields_ = [("Char", CHAR_UNION),
("Attributes", c_short)]
def to_str(self):
return ''
# }}}
class KEY_EVENT_RECORD(Structure): # {{{
class KEY_EVENT_RECORD(Structure):
_fields_ = [("bKeyDown", c_byte),
("pad2", c_byte),
('pad1', c_short),
@ -415,9 +395,8 @@ class KEY_EVENT_RECORD(Structure): # {{{
def to_str(self):
return ''
# }}}
class MOUSE_EVENT_RECORD(Structure): # {{{
class MOUSE_EVENT_RECORD(Structure):
_fields_ = [("dwMousePosition", COORD),
("dwButtonState", c_int),
("dwControlKeyState", c_int),
@ -426,32 +405,29 @@ class MOUSE_EVENT_RECORD(Structure): # {{{
def to_str(self):
return ''
# }}}
class WINDOW_BUFFER_SIZE_RECORD(Structure): # {{{
class WINDOW_BUFFER_SIZE_RECORD(Structure):
_fields_ = [("dwSize", COORD)]
def to_str(self):
return ''
# }}}
class MENU_EVENT_RECORD(Structure): # {{{
class MENU_EVENT_RECORD(Structure):
_fields_ = [("dwCommandId", c_uint)]
def to_str(self):
return ''
# }}}
class FOCUS_EVENT_RECORD(Structure): # {{{
class FOCUS_EVENT_RECORD(Structure):
_fields_ = [("bSetFocus", c_byte)]
def to_str(self):
return ''
# }}}
class INPUT_UNION(Union): # {{{
class INPUT_UNION(Union):
_fields_ = [("KeyEvent", KEY_EVENT_RECORD),
("MouseEvent", MOUSE_EVENT_RECORD),
("WindowBufferSizeEvent", WINDOW_BUFFER_SIZE_RECORD),
@ -460,14 +436,13 @@ class INPUT_UNION(Union): # {{{
def to_str(self):
return ''
# }}}
class INPUT_RECORD(Structure): # {{{
class INPUT_RECORD(Structure):
_fields_ = [("EventType", c_short),
("Event", INPUT_UNION)]
def to_str(self):
return ''
# }}}
# vim:foldmethod=marker

650
vim/autoload/getscript.vim Normal file
View File

@ -0,0 +1,650 @@
" ---------------------------------------------------------------------
" getscript.vim
" Author: Charles E. Campbell, Jr.
" Date: May 31, 2011
" Version: 33
" Installing: :help glvs-install
" Usage: :help glvs
"
" GetLatestVimScripts: 642 1 :AutoInstall: getscript.vim
"redraw!|call inputsave()|call input("Press <cr> to continue")|call inputrestore()
" ---------------------------------------------------------------------
" Initialization: {{{1
" if you're sourcing this file, surely you can't be
" expecting vim to be in its vi-compatible mode!
if exists("g:loaded_getscript")
finish
endif
let g:loaded_getscript= "v33"
if &cp
echoerr "GetLatestVimScripts is not vi-compatible; not loaded (you need to set nocp)"
finish
endif
if v:version < 702
echohl WarningMsg
echo "***warning*** this version of getscript needs vim 7.2"
echohl Normal
finish
endif
let s:keepcpo = &cpo
set cpo&vim
"DechoTabOn
" ---------------------------
" Global Variables: {{{1
" ---------------------------
" Cygwin Detection ------- {{{2
if !exists("g:getscript_cygwin")
if has("win32") || has("win95") || has("win64") || has("win16")
if &shell =~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$'
let g:getscript_cygwin= 1
else
let g:getscript_cygwin= 0
endif
else
let g:getscript_cygwin= 0
endif
endif
" wget vs curl {{{2
if !exists("g:GetLatestVimScripts_wget")
if executable("wget")
let g:GetLatestVimScripts_wget= "wget"
elseif executable("curl")
let g:GetLatestVimScripts_wget= "curl"
else
let g:GetLatestVimScripts_wget = 'echo "GetLatestVimScripts needs wget or curl"'
let g:GetLatestVimScripts_options = ""
endif
endif
" options that wget and curl require:
if !exists("g:GetLatestVimScripts_options")
if g:GetLatestVimScripts_wget == "wget"
let g:GetLatestVimScripts_options= "-q -O"
elseif g:GetLatestVimScripts_wget == "curl"
let g:GetLatestVimScripts_options= "-s -O"
else
let g:GetLatestVimScripts_options= ""
endif
endif
" by default, allow autoinstall lines to work
if !exists("g:GetLatestVimScripts_allowautoinstall")
let g:GetLatestVimScripts_allowautoinstall= 1
endif
"" For debugging:
"let g:GetLatestVimScripts_wget = "echo"
"let g:GetLatestVimScripts_options = "options"
" ---------------------------------------------------------------------
" Check If AutoInstall Capable: {{{1
let s:autoinstall= ""
if g:GetLatestVimScripts_allowautoinstall
if (has("win32") || has("gui_win32") || has("gui_win32s") || has("win16") || has("win64") || has("win32unix") || has("win95")) && &shell != "bash"
" windows (but not cygwin/bash)
let s:dotvim= "vimfiles"
if !exists("g:GetLatestVimScripts_mv")
let g:GetLatestVimScripts_mv= "ren"
endif
else
" unix
let s:dotvim= ".vim"
if !exists("g:GetLatestVimScripts_mv")
let g:GetLatestVimScripts_mv= "mv"
endif
endif
if exists("g:GetLatestVimScripts_autoinstalldir") && isdirectory(g:GetLatestVimScripts_autoinstalldir)
let s:autoinstall= g:GetLatestVimScripts_autoinstalldir"
elseif exists('$HOME') && isdirectory(expand("$HOME")."/".s:dotvim)
let s:autoinstall= $HOME."/".s:dotvim
endif
" call Decho("s:autoinstall<".s:autoinstall.">")
"else "Decho
" call Decho("g:GetLatestVimScripts_allowautoinstall=".g:GetLatestVimScripts_allowautoinstall.": :AutoInstall: disabled")
endif
" ---------------------------------------------------------------------
" Public Interface: {{{1
com! -nargs=0 GetLatestVimScripts call getscript#GetLatestVimScripts()
com! -nargs=0 GetScript call getscript#GetLatestVimScripts()
silent! com -nargs=0 GLVS call getscript#GetLatestVimScripts()
" ---------------------------------------------------------------------
" GetLatestVimScripts: this function gets the latest versions of {{{1
" scripts based on the list in
" (first dir in runtimepath)/GetLatest/GetLatestVimScripts.dat
fun! getscript#GetLatestVimScripts()
" call Dfunc("GetLatestVimScripts() autoinstall<".s:autoinstall.">")
" insure that wget is executable
if executable(g:GetLatestVimScripts_wget) != 1
echoerr "GetLatestVimScripts needs ".g:GetLatestVimScripts_wget." which apparently is not available on your system"
" call Dret("GetLatestVimScripts : wget not executable/availble")
return
endif
" insure that fnameescape() is available
if !exists("*fnameescape")
echoerr "GetLatestVimScripts needs fnameescape() (provided by 7.1.299 or later)"
return
endif
" Find the .../GetLatest subdirectory under the runtimepath
for datadir in split(&rtp,',') + ['']
if isdirectory(datadir."/GetLatest")
" call Decho("found directory<".datadir.">")
let datadir= datadir . "/GetLatest"
break
endif
if filereadable(datadir."GetLatestVimScripts.dat")
" call Decho("found ".datadir."/GetLatestVimScripts.dat")
break
endif
endfor
" Sanity checks: readability and writability
if datadir == ""
echoerr 'Missing "GetLatest/" on your runtimepath - see :help glvs-dist-install'
" call Dret("GetLatestVimScripts : unable to find a GetLatest subdirectory")
return
endif
if filewritable(datadir) != 2
echoerr "(getLatestVimScripts) Your ".datadir." isn't writable"
" call Dret("GetLatestVimScripts : non-writable directory<".datadir.">")
return
endif
let datafile= datadir."/GetLatestVimScripts.dat"
if !filereadable(datafile)
echoerr "Your data file<".datafile."> isn't readable"
" call Dret("GetLatestVimScripts : non-readable datafile<".datafile.">")
return
endif
if !filewritable(datafile)
echoerr "Your data file<".datafile."> isn't writable"
" call Dret("GetLatestVimScripts : non-writable datafile<".datafile.">")
return
endif
" --------------------
" Passed sanity checks
" --------------------
" call Decho("datadir <".datadir.">")
" call Decho("datafile <".datafile.">")
" don't let any event handlers interfere (like winmanager's, taglist's, etc)
let eikeep = &ei
let hlskeep = &hls
let acdkeep = &acd
set ei=all hls&vim noacd
" Edit the datafile (ie. GetLatestVimScripts.dat):
" 1. record current directory (origdir),
" 2. change directory to datadir,
" 3. split window
" 4. edit datafile
let origdir= getcwd()
" call Decho("exe cd ".fnameescape(substitute(datadir,'\','/','ge')))
exe "cd ".fnameescape(substitute(datadir,'\','/','ge'))
split
" call Decho("exe e ".fnameescape(substitute(datafile,'\','/','ge')))
exe "e ".fnameescape(substitute(datafile,'\','/','ge'))
res 1000
let s:downloads = 0
let s:downerrors= 0
" Check on dependencies mentioned in plugins
" call Decho(" ")
" call Decho("searching plugins for GetLatestVimScripts dependencies")
let lastline = line("$")
" call Decho("lastline#".lastline)
let firstdir = substitute(&rtp,',.*$','','')
let plugins = split(globpath(firstdir,"plugin/*.vim"),'\n')
let plugins = plugins + split(globpath(firstdir,"AsNeeded/*.vim"),'\n')
let foundscript = 0
" this loop updates the GetLatestVimScripts.dat file
" with dependencies explicitly mentioned in the plugins
" via GetLatestVimScripts: ... lines
" It reads the plugin script at the end of the GetLatestVimScripts.dat
" file, examines it, and then removes it.
for plugin in plugins
" call Decho(" ")
" call Decho("plugin<".plugin.">")
" read plugin in
" evidently a :r creates a new buffer (the "#" buffer) that is subsequently unused -- bwiping it
$
" call Decho(".dependency checking<".plugin."> line$=".line("$"))
" call Decho("..exe silent r ".fnameescape(plugin))
exe "silent r ".fnameescape(plugin)
exe "silent bwipe ".bufnr("#")
while search('^"\s\+GetLatestVimScripts:\s\+\d\+\s\+\d\+','W') != 0
let depscript = substitute(getline("."),'^"\s\+GetLatestVimScripts:\s\+\d\+\s\+\d\+\s\+\(.*\)$','\1','e')
let depscriptid = substitute(getline("."),'^"\s\+GetLatestVimScripts:\s\+\(\d\+\)\s\+.*$','\1','')
let llp1 = lastline+1
" call Decho("..depscript<".depscript.">")
" found a "GetLatestVimScripts: # #" line in the script;
" check if its already in the datafile by searching backwards from llp1,
" the (prior to reading in the plugin script) last line plus one of the GetLatestVimScripts.dat file,
" for the script-id with no wrapping allowed.
let curline = line(".")
let noai_script = substitute(depscript,'\s*:AutoInstall:\s*','','e')
exe llp1
let srchline = search('^\s*'.depscriptid.'\s\+\d\+\s\+.*$','bW')
if srchline == 0
" this second search is taken when, for example, a 0 0 scriptname is to be skipped over
let srchline= search('\<'.noai_script.'\>','bW')
endif
" call Decho("..noai_script<".noai_script."> depscriptid#".depscriptid." srchline#".srchline." curline#".line(".")." lastline#".lastline)
if srchline == 0
" found a new script to permanently include in the datafile
let keep_rega = @a
let @a = substitute(getline(curline),'^"\s\+GetLatestVimScripts:\s\+','','')
echomsg "Appending <".@a."> to ".datafile." for ".depscript
" call Decho("..Appending <".@a."> to ".datafile." for ".depscript)
exe lastline."put a"
let @a = keep_rega
let lastline = llp1
let curline = curline + 1
let foundscript = foundscript + 1
" else " Decho
" call Decho("..found <".noai_script."> (already in datafile at line#".srchline.")")
endif
let curline = curline + 1
exe curline
endwhile
" llp1: last line plus one
let llp1= lastline + 1
" call Decho(".deleting lines: ".llp1.",$d")
exe "silent! ".llp1.",$d"
endfor
" call Decho("--- end dependency checking loop --- foundscript=".foundscript)
" call Decho(" ")
" call Dredir("BUFFER TEST (GetLatestVimScripts 1)","ls!")
if foundscript == 0
setlocal nomod
endif
" --------------------------------------------------------------------
" Check on out-of-date scripts using GetLatest/GetLatestVimScripts.dat
" --------------------------------------------------------------------
" call Decho("begin: checking out-of-date scripts using datafile<".datafile.">")
setlocal lz
1
" /^-----/,$g/^\s*\d/call Decho(getline("."))
1
/^-----/,$g/^\s*\d/call s:GetOneScript()
" call Decho("--- end out-of-date checking --- ")
" Final report (an echomsg)
try
silent! ?^-------?
catch /^Vim\%((\a\+)\)\=:E114/
" call Dret("GetLatestVimScripts : nothing done!")
return
endtry
exe "norm! kz\<CR>"
redraw!
let s:msg = ""
if s:downloads == 1
let s:msg = "Downloaded one updated script to <".datadir.">"
elseif s:downloads == 2
let s:msg= "Downloaded two updated scripts to <".datadir.">"
elseif s:downloads > 1
let s:msg= "Downloaded ".s:downloads." updated scripts to <".datadir.">"
else
let s:msg= "Everything was already current"
endif
if s:downerrors > 0
let s:msg= s:msg." (".s:downerrors." downloading errors)"
endif
echomsg s:msg
" save the file
if &mod
silent! w!
endif
q
" restore events and current directory
exe "cd ".fnameescape(substitute(origdir,'\','/','ge'))
let &ei = eikeep
let &hls = hlskeep
let &acd = acdkeep
setlocal nolz
" call Dredir("BUFFER TEST (GetLatestVimScripts 2)","ls!")
" call Dret("GetLatestVimScripts : did ".s:downloads." downloads")
endfun
" ---------------------------------------------------------------------
" GetOneScript: (Get Latest Vim Script) this function operates {{{1
" on the current line, interpreting two numbers and text as
" ScriptID, SourceID, and Filename.
" It downloads any scripts that have newer versions from vim.sourceforge.net.
fun! s:GetOneScript(...)
" call Dfunc("GetOneScript()")
" set options to allow progress to be shown on screen
let rega= @a
let t_ti= &t_ti
let t_te= &t_te
let rs = &rs
set t_ti= t_te= nors
" put current line on top-of-screen and interpret it into
" a script identifer : used to obtain webpage
" source identifier : used to identify current version
" and an associated comment: used to report on what's being considered
if a:0 >= 3
let scriptid = a:1
let srcid = a:2
let fname = a:3
let cmmnt = ""
" call Decho("scriptid<".scriptid.">")
" call Decho("srcid <".srcid.">")
" call Decho("fname <".fname.">")
else
let curline = getline(".")
if curline =~ '^\s*#'
let @a= rega
" call Dret("GetOneScript : skipping a pure comment line")
return
endif
let parsepat = '^\s*\(\d\+\)\s\+\(\d\+\)\s\+\(.\{-}\)\(\s*#.*\)\=$'
try
let scriptid = substitute(curline,parsepat,'\1','e')
catch /^Vim\%((\a\+)\)\=:E486/
let scriptid= 0
endtry
try
let srcid = substitute(curline,parsepat,'\2','e')
catch /^Vim\%((\a\+)\)\=:E486/
let srcid= 0
endtry
try
let fname= substitute(curline,parsepat,'\3','e')
catch /^Vim\%((\a\+)\)\=:E486/
let fname= ""
endtry
try
let cmmnt= substitute(curline,parsepat,'\4','e')
catch /^Vim\%((\a\+)\)\=:E486/
let cmmnt= ""
endtry
" call Decho("curline <".curline.">")
" call Decho("parsepat<".parsepat.">")
" call Decho("scriptid<".scriptid.">")
" call Decho("srcid <".srcid.">")
" call Decho("fname <".fname.">")
endif
" plugin author protection from downloading his/her own scripts atop their latest work
if scriptid == 0 || srcid == 0
" When looking for :AutoInstall: lines, skip scripts that have 0 0 scriptname
let @a= rega
" call Dret("GetOneScript : skipping a scriptid==srcid==0 line")
return
endif
let doautoinstall= 0
if fname =~ ":AutoInstall:"
" call Decho("case AutoInstall: fname<".fname.">")
let aicmmnt= substitute(fname,'\s\+:AutoInstall:\s\+',' ','')
" call Decho("aicmmnt<".aicmmnt."> s:autoinstall=".s:autoinstall)
if s:autoinstall != ""
let doautoinstall = g:GetLatestVimScripts_allowautoinstall
endif
else
let aicmmnt= fname
endif
" call Decho("aicmmnt<".aicmmnt.">: doautoinstall=".doautoinstall)
exe "norm z\<CR>"
redraw!
" call Decho('considering <'.aicmmnt.'> scriptid='.scriptid.' srcid='.srcid)
echo 'considering <'.aicmmnt.'> scriptid='.scriptid.' srcid='.srcid
" grab a copy of the plugin's vim.sourceforge.net webpage
let scriptaddr = 'http://vim.sourceforge.net/script.php?script_id='.scriptid
let tmpfile = tempname()
let v:errmsg = ""
" make up to three tries at downloading the description
let itry= 1
while itry <= 3
" call Decho(".try#".itry." to download description of <".aicmmnt."> with addr=".scriptaddr)
if has("win32") || has("win16") || has("win95")
" call Decho(".new|exe silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(tmpfile).' '.shellescape(scriptaddr)."|bw!")
new|exe "silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(tmpfile).' '.shellescape(scriptaddr)|bw!
else
" call Decho(".exe silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(tmpfile)." ".shellescape(scriptaddr))
exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(tmpfile)." ".shellescape(scriptaddr)
endif
if itry == 1
exe "silent vsplit ".fnameescape(tmpfile)
else
silent! e %
endif
setlocal bh=wipe
" find the latest source-id in the plugin's webpage
silent! 1
let findpkg= search('Click on the package to download','W')
if findpkg > 0
break
endif
let itry= itry + 1
endwhile
" call Decho(" --- end downloading tries while loop --- itry=".itry)
" testing: did finding "Click on the package..." fail?
if findpkg == 0 || itry >= 4
silent q!
call delete(tmpfile)
" restore options
let &t_ti = t_ti
let &t_te = t_te
let &rs = rs
let s:downerrors = s:downerrors + 1
" call Decho("***warning*** couldn'".'t find "Click on the package..." in description page for <'.aicmmnt.">")
echomsg "***warning*** couldn'".'t find "Click on the package..." in description page for <'.aicmmnt.">"
" call Dret("GetOneScript : srch for /Click on the package/ failed")
let @a= rega
return
endif
" call Decho('found "Click on the package to download"')
let findsrcid= search('src_id=','W')
if findsrcid == 0
silent q!
call delete(tmpfile)
" restore options
let &t_ti = t_ti
let &t_te = t_te
let &rs = rs
let s:downerrors = s:downerrors + 1
" call Decho("***warning*** couldn'".'t find "src_id=" in description page for <'.aicmmnt.">")
echomsg "***warning*** couldn'".'t find "src_id=" in description page for <'.aicmmnt.">"
let @a= rega
" call Dret("GetOneScript : srch for /src_id/ failed")
return
endif
" call Decho('found "src_id=" in description page')
let srcidpat = '^\s*<td class.*src_id=\(\d\+\)">\([^<]\+\)<.*$'
let latestsrcid= substitute(getline("."),srcidpat,'\1','')
let sname = substitute(getline("."),srcidpat,'\2','') " script name actually downloaded
" call Decho("srcidpat<".srcidpat."> latestsrcid<".latestsrcid."> sname<".sname.">")
silent q!
call delete(tmpfile)
" convert the strings-of-numbers into numbers
let srcid = srcid + 0
let latestsrcid = latestsrcid + 0
" call Decho("srcid=".srcid." latestsrcid=".latestsrcid." sname<".sname.">")
" has the plugin's most-recent srcid increased, which indicates that it has been updated
if latestsrcid > srcid
" call Decho("[latestsrcid=".latestsrcid."] <= [srcid=".srcid."]: need to update <".sname.">")
let s:downloads= s:downloads + 1
if sname == bufname("%")
" GetLatestVimScript has to be careful about downloading itself
let sname= "NEW_".sname
endif
" -----------------------------------------------------------------------------
" the plugin has been updated since we last obtained it, so download a new copy
" -----------------------------------------------------------------------------
" call Decho(".downloading new <".sname.">")
echomsg ".downloading new <".sname.">"
if has("win32") || has("win16") || has("win95")
" call Decho(".new|exe silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(sname)." ".shellescape('http://vim.sourceforge.net/scripts/download_script.php?src_id='.latestsrcid)."|q")
new|exe "silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(sname)." ".shellescape('http://vim.sourceforge.net/scripts/download_script.php?src_id='.latestsrcid)|q
else
" call Decho(".exe silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(sname)." ".shellescape('http://vim.sourceforge.net/scripts/download_script.php?src_id='))
exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(sname)." ".shellescape('http://vim.sourceforge.net/scripts/download_script.php?src_id=').latestsrcid
endif
" --------------------------------------------------------------------------
" AutoInstall: only if doautoinstall has been requested by the plugin itself
" --------------------------------------------------------------------------
" call Decho("checking if plugin requested autoinstall: doautoinstall=".doautoinstall)
if doautoinstall
" call Decho(" ")
" call Decho("Autoinstall: getcwd<".getcwd()."> filereadable(".sname.")=".filereadable(sname))
if filereadable(sname)
" call Decho("<".sname."> is readable")
" call Decho("exe silent !".g:GetLatestVimScripts_mv." ".shellescape(sname)." ".shellescape(s:autoinstall))
exe "silent !".g:GetLatestVimScripts_mv." ".shellescape(sname)." ".shellescape(s:autoinstall)
let curdir = fnameescape(substitute(getcwd(),'\','/','ge'))
let installdir= curdir."/Installed"
if !isdirectory(installdir)
call mkdir(installdir)
endif
" call Decho("curdir<".curdir."> installdir<".installdir.">")
" call Decho("exe cd ".fnameescape(s:autoinstall))
exe "cd ".fnameescape(s:autoinstall)
" determine target directory for moves
let firstdir= substitute(&rtp,',.*$','','')
let pname = substitute(sname,'\..*','.vim','')
" call Decho("determine tgtdir: is <".firstdir.'/AsNeeded/'.pname." readable?")
if filereadable(firstdir.'/AsNeeded/'.pname)
let tgtdir= "AsNeeded"
else
let tgtdir= "plugin"
endif
" call Decho("tgtdir<".tgtdir."> pname<".pname.">")
" decompress
if sname =~ '\.bz2$'
" call Decho("decompress: attempt to bunzip2 ".sname)
exe "silent !bunzip2 ".shellescape(sname)
let sname= substitute(sname,'\.bz2$','','')
" call Decho("decompress: new sname<".sname."> after bunzip2")
elseif sname =~ '\.gz$'
" call Decho("decompress: attempt to gunzip ".sname)
exe "silent !gunzip ".shellescape(sname)
let sname= substitute(sname,'\.gz$','','')
" call Decho("decompress: new sname<".sname."> after gunzip")
elseif sname =~ '\.xz$'
" call Decho("decompress: attempt to unxz ".sname)
exe "silent !unxz ".shellescape(sname)
let sname= substitute(sname,'\.xz$','','')
" call Decho("decompress: new sname<".sname."> after unxz")
else
" call Decho("no decompression needed")
endif
" distribute archive(.zip, .tar, .vba) contents
if sname =~ '\.zip$'
" call Decho("dearchive: attempt to unzip ".sname)
exe "silent !unzip -o ".shellescape(sname)
elseif sname =~ '\.tar$'
" call Decho("dearchive: attempt to untar ".sname)
exe "silent !tar -xvf ".shellescape(sname)
elseif sname =~ '\.vba$'
" call Decho("dearchive: attempt to handle a vimball: ".sname)
silent 1split
if exists("g:vimball_home")
let oldvimballhome= g:vimball_home
endif
let g:vimball_home= s:autoinstall
exe "silent e ".fnameescape(sname)
silent so %
silent q
if exists("oldvimballhome")
let g:vimball_home= oldvimballhome
else
unlet g:vimball_home
endif
else
" call Decho("no dearchiving needed")
endif
" ---------------------------------------------
" move plugin to plugin/ or AsNeeded/ directory
" ---------------------------------------------
if sname =~ '.vim$'
" call Decho("dearchive: attempt to simply move ".sname." to ".tgtdir)
exe "silent !".g:GetLatestVimScripts_mv." ".shellescape(sname)." ".tgtdir
else
" call Decho("dearchive: move <".sname."> to installdir<".installdir.">")
exe "silent !".g:GetLatestVimScripts_mv." ".shellescape(sname)." ".installdir
endif
if tgtdir != "plugin"
" call Decho("exe silent !".g:GetLatestVimScripts_mv." plugin/".shellescape(pname)." ".tgtdir)
exe "silent !".g:GetLatestVimScripts_mv." plugin/".shellescape(pname)." ".tgtdir
endif
" helptags step
let docdir= substitute(&rtp,',.*','','e')."/doc"
" call Decho("helptags: docdir<".docdir.">")
exe "helptags ".fnameescape(docdir)
exe "cd ".fnameescape(curdir)
endif
if fname !~ ':AutoInstall:'
let modline=scriptid." ".latestsrcid." :AutoInstall: ".fname.cmmnt
else
let modline=scriptid." ".latestsrcid." ".fname.cmmnt
endif
else
let modline=scriptid." ".latestsrcid." ".fname.cmmnt
endif
" update the data in the <GetLatestVimScripts.dat> file
call setline(line("."),modline)
" call Decho("update data in ".expand("%")."#".line(".").": modline<".modline.">")
" else " Decho
" call Decho("[latestsrcid=".latestsrcid."] <= [srcid=".srcid."], no need to update")
endif
" restore options
let &t_ti = t_ti
let &t_te = t_te
let &rs = rs
let @a = rega
" call Dredir("BUFFER TEST (GetOneScript)","ls!")
" call Dret("GetOneScript")
endfun
" ---------------------------------------------------------------------
" Restore Options: {{{1
let &cpo= s:keepcpo
unlet s:keepcpo
" ---------------------------------------------------------------------
" Modelines: {{{1
" vim: ts=8 sts=2 fdm=marker nowrap

View File

@ -0,0 +1,89 @@
" Vim color file
" Maintainer: John Kaul
" Created On: 2003 Mar 19
" Last Change: 2013 Jan 16
" Notes:
" This started as a fadded version of of the 'Chocolate Liquor', but
" soon took on a life of its own. Easy on the eyes, but still has good
" contrast. I dont think there is any 'Chocolate Liquor' left in this
" file, but there is prolly an entry or two left in there somewhere.
"
" Only values that differ from defaults are specified.
"
" 01.07.05 update: Tweeked a few colors and added terminal colors.
" Please note that I didnt go thru the terminal colors very well. (I
" just added a few ''dif. then normal'' colors) If you use the terminal
" alot I would make an attempt to fix anything you dont like about this
" color scheme if I were you. :)~ Other than that, I just called it it
" good 'nuff.
"
" 01.16.13 update: Changed a few more colors (still havent looked at the
" terminal colors).
"
" I hope you enjoy...
set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
let g:colors_name = "faded-black"
" Vim >= 7.0 specific colors
if version >= 700
hi CursorLine ctermbg=236 ctermfg=NONE guibg=#2d2d2d guifg=NONE term=NONE gui=NONE
hi CursorColumn ctermbg=236 ctermfg=NONE guibg=#2d2d2d guifg=NONE term=NONE gui=NONE
hi MatchParen ctermbg=237 ctermfg=157 guibg=#2f2f2f guifg=#d0ffc0 term=bold gui=bold
hi Pmenu ctermbg=238 ctermfg=255 guibg=#444444 guifg=#ffffff term=NONE gui=NONE
hi PmenuSel ctermbg=148 ctermfg=0 guibg=#b1d631 guifg=#000000 term=NONE gui=NONE
endif
" //-- Stuff --//
hi Cursor ctermbg=Red ctermfg=NONE guibg=#8b3a3a guifg=#e3e3e3 gui=NONE
hi Normal ctermbg=NONE ctermfg=LightGrey guibg=#03080F guifg=#958a73 gui=NONE
" hi Normal ctermbg=NONE ctermfg=LightGrey guibg=#03080F guifg=#a69d89 gui=NONE
" The text color between the above two are tough to decide; I leave it up to you.
hi NonText ctermbg=NONE ctermfg=Black guibg=#03080F guifg=#000030 gui=NONE
hi DiffDelete ctermbg=DarkRed ctermfg=White guibg=DarkRed guifg=White gui=NONE
hi DiffAdd ctermbg=DarkGreen ctermfg=White guibg=DarkGreen guifg=White gui=NONE
hi DiffText ctermbg=LightCyan ctermfg=Yellow guibg=Lightblue guifg=Yellow gui=NONE
hi DiffChange ctermbg=LightBlue ctermfg=White guibg=LightBlue3 guifg=White gui=NONE
hi Constant ctermbg=NONE ctermfg=Red guibg=NONE guifg=#872e30 gui=NONE
hi StatusLine ctermbg=DarkGrey ctermfg=Red guibg=DarkGrey guifg=LightRed gui=italic
hi StatusLineNC ctermbg=Darkgrey ctermfg=black guibg=DarkGrey guifg=Black gui=NONE
hi VertSplit ctermbg=NONE ctermfg=NONE guibg=NONE guifg=Grey gui=NONE
hi Visual ctermbg=DarkRed ctermfg=Red guibg=#6b6b6b guifg=#431818 term=reverse
hi Search ctermbg=NONE ctermfg=LightGrey guibg=#80363a guifg=#a69c89 gui=NONE
hi Label ctermbg=NONE ctermfg=NONE guibg=NONE guifg=#ffc0c0 gui=NONE
hi LineNr ctermbg=NONE ctermfg=Red guibg=NONE guifg=#A39274 gui=NONE
" //-- Messages --//
hi MoreMsg ctermbg=NONE ctermfg=DarkGreen guibg=NONE guifg=SeaGreen term=bold,italic gui=bold
hi question ctermbg=NONE ctermfg=DarkGreen guibg=NONE guifg=SeaGreen term=standout gui=bold
" //-- Syntax group --//
hi Comment ctermbg=NONE ctermfg=DarkGreen guibg=NONE guifg=#545f3a gui=italic
hi PreProc ctermbg=NONE ctermfg=NONE guibg=NONE guifg=#bbaccc gui=NONE
hi Statement ctermbg=NONE ctermfg=Yellow guibg=NONE guifg=#ab952b gui=NONE
hi Type ctermbg=NONE ctermfg=darkmagenta guibg=NONE guifg=#ba5bdb gui=NONE
hi Identifier ctermbg=NONE ctermfg=Yellow guibg=NONE guifg=#737d95 gui=NONE
hi Special ctermbg=NONE ctermfg=Green guibg=NONE guifg=#5b5646 gui=NONE
hi Todo ctermbg=NONE ctermfg=NONE guibg=NONE guifg=LightBlue gui=bold,italic
hi Number ctermbg=NONE ctermfg=NONE guibg=NONE guifg=lightblue gui=NONE
"
" Lisp stuff
hi lispAtomMark ctermbg=NONE ctermfg=cyan guifg=darkcyan guibg=NONE gui=NONE
hi lispNumber ctermbg=NONE ctermfg=DarkGreen guifg=lightblue guibg=NONE gui=NONE
"
" hi Constant
" hi Error
" hi Ignore
" hi Underlined
" //-- Fold --//
hi Folded ctermbg=NONE ctermfg=NONE guibg=#001a33 guifg=#a69c89 gui=italic
hi FoldColumn ctermbg=NONE ctermfg=Yellow guibg=#6699CC guifg=#0000EE gui=NONE

View File

@ -1,8 +1,8 @@
*align.txt* The Alignment Tool Mar 04, 2009
*align.txt* The Alignment Tool Jun 18, 2012
Author: Charles E. Campbell, Jr. <NdrOchip@ScampbellPfamily.AbizM>
Author: Charles E. Campbell <NdrOchip@ScampbellPfamily.AbizM>
(remove NOSPAM from Campbell's email first)
Copyright: (c) 2004-2008 by Charles E. Campbell, Jr. *Align-copyright*
Copyright: (c) 2004-2012 by Charles E. Campbell *Align-copyright*
The VIM LICENSE applies to Align.vim, AlignMaps.vim, and Align.txt
(see |copyright|) except use "Align and AlignMaps" instead of "Vim"
NO WARRANTY, EXPRESS OR IMPLIED. USE AT-YOUR-OWN-RISK.
@ -26,6 +26,7 @@ Copyright: (c) 2004-2008 by Charles E. Campbell, Jr. *Align-copyright*
Temporary Settings.....: |alignctrl-m|
Padding................: |alignctrl-p| |alignctrl-P|
Current Options........: |alignctrl-settings| |alignctrl-|
Alignment Control Init...: |alignctrl-init|
Alignment................: |align-align|
4. Alignment Maps...........: |align-maps|
\a,....................: |alignmap-a,|
@ -91,6 +92,7 @@ Copyright: (c) 2004-2008 by Charles E. Campbell, Jr. *Align-copyright*
|| | | - skip this separator ||
|| | | + re-use last justification method ||
|| | | : treat rest of text as a field ||
|| | | * use AlignSkip() function (to skip or not) ||
|| | | ||
|| | p1 | p### pad separator on left by # blanks ||
|| | P1 | P### pad separator on right by # blanks ||
@ -176,12 +178,14 @@ ALIGNMENT CONCEPTS *align-concept* *align-concepts* {{{2
< Note how each "=" sign is surrounded by a single space; the
default padding is p1P1 (p1 means one space before the separator,
and P1 means one space after it). If you wish to change the
padding, say to no padding, use (see |alignctrl-p|) >
padding, say, to no padding, use (see |alignctrl-p|) >
:AlignCtrl lp0P0
< Next, note how each field is left justified; that's what the "l"
(a small letter "ell") does. If right-justification of the fields
had been desired, an "r" could've been used: >
in the AlignCtrl parameters (a small letter "ell") does. If
right-justification of the fields had been desired, an "r"
could've been used: >
:AlignCtrl r
< yielding >
x = y = z = 3;
@ -196,10 +200,10 @@ ALIGNMENT CONCEPTS *align-concept* *align-concepts* {{{2
justify, right justify, or center them, too (see |alignctrl-<|).
Assume that for some reason a left-right-left-right-... justification
sequence was wished. This wish is simply achieved with >
sequence was desired. This wish is simply achieved with >
:AlignCtrl lr
:1,4Align =
< because the justification commands are considered to be "cylic"; ie.
< because the justification commands are considered to be "cyclic"; ie.
lr is the same as lrlrlrlrlrlrlr...
There's a lot more discussed under |alignctrl|; hopefully the examples
@ -261,7 +265,7 @@ ALIGNMENT COMMANDS *align-command* *align-commands* {{{2
< Also see |alignctrl-m| for a way to automatically do
an AlignPop after an Align (primarily this is for maps).
ALIGNMENT OPTIONS *align-option* *align-options* {{{2
ALIGNMENT OPTIONS *align-option* *align-options* *align-xstrlen* {{{2
*align-utf8* *align-utf* *align-codepoint* *align-strlen* *align-multibyte*
For those of you who are using 2-byte (or more) characters such as are
@ -279,7 +283,7 @@ ALIGNMENT OPTIONS *align-option* *align-options* {{{2
vim compiled without multi-byte support
$LANG is en_US.UTF-8 (assuming USA english)
Number of codepoints (Latin a + combining circumflex is two codepoints)~
Number of codepoints (Latin a + combining circumflex are two codepoints)~
>
let g:Align_xstrlen= 1 (default)
<
@ -295,13 +299,20 @@ ALIGNMENT OPTIONS *align-option* *align-options* {{{2
>
let g:Align_xstrlen= 3
<
User may specify a function to compute the string length~
>
let g:Align_xstrlen= "strlen"
< This method will cause Align to call upon the named function returning
string length. it should resemble the |strlen()| function, taking one
argument (the string) for input and returning the string length.
By putting one of these settings into your <.vimrc>, Align will use an
internal (interpreted) function to determine a string's length instead
of the Vim's built-in |strlen()| function. Since the function is
of Vim's built-in |strlen()| function. Since the function is
interpreted, Align will run a bit slower but will handle such strings
correctly. The last setting (g:Align_xstrlen= 3) probably will run
the slowest but be the most accurate. (thanks to Tony Mechelynck for
these)
correctly. The last settings (g:Align_xstrlen= 3 and
g:Align_xstrlen="userfuncname") probably will run the slowest but be
the most accurate. (thanks to Tony Mechelynck for these)
ALIGNMENT CONTROL *alignctrl* *align-control* {{{2
@ -337,10 +348,11 @@ ALIGNMENT CONTROL *alignctrl* *align-control* {{{2
(ie. @), and then perform a substitute to revert the separators back
to their desired condition (ie. s/@/ :: /g).
The Align#Align() function will first convert tabs over the region into
spaces and then apply alignment control. Except for initial white
space, white space surrounding the fields is ignored. One has three
options just for handling initial white space:
The Align#Align() function (which is invoked by the :Align command)
will first convert tabs over the region into spaces and then apply
alignment control. Except for initial white space, white space
surrounding the fields is ignored. One has three options just for
handling initial white space:
--- *alignctrl-w*
@ -397,17 +409,19 @@ ALIGNMENT CONTROL *alignctrl* *align-control* {{{2
cycle only consists of one character (the "l").
Every time left-justification is used for fields.
AlignCtrl r : The = separator is repeatedly re-used, as the
cycle only consists of one character (the "l").
cycle only consists of one character (the "r").
Every time right-justification is used for fields
AlignCtrl lr: Again, the "=" separator is repeatedly re-used,
but the fields are justified alternately between
left and right.
Even more separator control is available. With "-+:":
Even more separator control is available! With "-+:":
- : skip treating the separator as a separator. *alignctrl--*
+ : repeat use of the last "lrc" justification *alignctrl-+*
: : treat the rest of the line as a single field *alignctrl-:*
* : like -, but only if g:AlignSkip() returns true *alignctrl-star*
(see |alignctrl-alignskip|)
Example: More justification options: Align = >
+------------+---------------+--------------------+---------------+
@ -452,6 +466,35 @@ ALIGNMENT CONTROL *alignctrl* *align-control* {{{2
3rd separator only: AlignCtrl --l:
etc.
*g:AlignSkip*
Align Skip Control *alignctrl-alignskip*
The separator control '*' permits a function to decide whether or
not a character which matches the current separator pattern should
instead be skipped.
1. Define a function; example: >
fun! AlignSkipString(lineno,indx)
let synid = synID(a:lineno,a:indx+1,1)
let synname = synIDattr(synIDtrans(synid),"name")
let ret= (synname == "String")? 1 : 0
return ret
endfun
<
Input: lineno: current line number
indx : index to character; leftmost character
in the line has an indx of 0 (like |strpart()|)
Output: 0 : if separator is ok
1 : skip separator like it was a '-'
2. Set up |g:AlignSkip| as a function reference (see |Funcref|): >
let g:AlignSkip= function("AlignSkipString")
<
3. Use * as a separator control where a separator potentially should
be skipped over.
--- *alignctrl-=*
=C CYCLIC VS ALL-ACTIVE SEPARATORS *alignctrl-C* {{{3
@ -465,8 +508,10 @@ ALIGNMENT CONTROL *alignctrl* *align-control* {{{2
constructed: >
AlignCtrl ... pat1 pat2 pat3
< becomes >
\(pat1\|pat2\|pat3\)
<
< (ie. pat1 -or- pat2 -or- pat3; see |/bar|)
Each separator pattern is thus equivalent and simultaneously active.
The cyclic separator AlignCtrl option stores a list of patterns, only
one of which is active for each field at a time.
@ -606,11 +651,11 @@ ALIGNMENT CONTROL *alignctrl* *align-control* {{{2
|five= 6; |five = 6; |five = 6; |
+----------------+------------------+----------------+
<
The first "Align =" aligned with all "="s, including that one in the
"skip=this" comment.
The first "Align =" aligned with all "="s, including the one in the
"/* skip=this */" comment.
The second "Align =" had a AlignCtrl v-pattern which caused it to skip
(ignore) the "skip=this" line when aligning.
(ignore) the "/* skip=this */" line when aligning.
To remove AlignCtrl's g and v patterns, use (as appropriate) >
@ -697,7 +742,19 @@ ALIGNMENT CONTROL *alignctrl* *align-control* {{{2
however: >
:let alignctrl= Align#AlignCtrl("d")
<
ALIGNMENT CONTROL INITIALIZATION *alignctrl-init* *alignctrl-initialization* {{{2
If you'd like to have your own default AlignCtrl, you'll be wanting to
put it in a file such as: >
$HOME/.vim/after/plugin/AlignPlugin.vim
< Anything in that file would be sourced at startup, but after your
.vimrc and after $HOME/.vim/plugin/AlignPlugin.vim; hence, :Align
and :AlignCtrl will then be defined.
ALIGNMENT *align-align* {{{2
@ -758,23 +815,31 @@ ALIGNMENT *align-align* {{{2
==============================================================================
4. Alignment Maps *alignmaps* *align-maps* {{{1
There are a number of maps using Align#AlignCtrl() and Align#Align()
in the <AlignMapsPlugin.vim> file. This file may also be put into the
plugins subdirectory. Since AlignCtrl and Align supercede textab and
its <ttalign.vim> file, the maps either have a leading "t" (for
"textab") or the more complicated ones an "a" (for "alignment") for
backwards compatibility.
There are a number of maps provided in the AlignMaps plugin which
depend upon the Align plugin. The maps provided by AlignMaps
typically start with a leading "t" (for the older "textab" program
which Align supercedes) or with an "a" for the more complicated
alignment maps.
The maps are shown below with a leading backslash (\). Actually, the
<Leader> construct is used (see |mapleader|), so the maps' leading
kick-off character is easily customized.
The AlignMaps plugin, although provided in the vimball containing
Align.vim, is really a separate plugin (Align doesn't depend on
AlignMaps). Consequently, if you'd rather not have AlignMaps's
mappings, just use the *:AlignMapsClean* command to remove its
components. The :AlignMapsClean command does not remove any maps
generated by AlignMaps in the current instance of vim.
Furthermore, all AlignMapsPlugin.vim maps use the <Plug> construct (see
|<Plug>|and |usr_41.txt|). Hence, if one wishes to override the
mapping entirely, one may do that, too. As an example: >
The maps are shown below with a leading backslash (\). However, the
actual maps use the <Leader> construct (see |mapleader|), so the maps'
leading kick-off character is easily customized.
Furthermore, all the maps specified by the AlignMaps plugin use the
<Plug> construct (see |<Plug>|and |usr_41.txt|). Hence, if one wishes
to override the mapping(s) entirely, one may do that, too. As an
example: >
map <Leader>ACOM <Plug>AM_acom
< would have \ACOM do what \acom previously did (assuming that the
mapleader has been left at its default value of a backslash).
< would have \ACOM do
what \acom previously did (assuming that the mapleader has been left
at its default value of a backslash).
\a, : useful for breaking up comma-separated
declarations prior to \adec |alignmap-a,|
@ -831,9 +896,9 @@ ALIGNMENT *align-align* {{{2
character "x" where "x" is: ,:<=@# |alignmap-T=|
\m= : like \t= but aligns with %... style comments
The leading backslash is actually <leader> (see |mapleader| for how to
customize the leader to be whatever you like). These maps use the
<Align.vim> package and are defined in the <AlignMaps.vim> file.
The leading backslash is actually <leader> (see |mapleader| to learn
how to customize the leader to be whatever you like). These maps use
the <Align.vim> package and are defined in the <AlignMaps.vim> file.
Although the maps use AlignCtrl options, they typically use the "m"
option which pushes the options (AlignPush). The associated Align
call which follows will then AlignPop the user's original options
@ -847,6 +912,18 @@ ALIGNMENT *align-align* {{{2
Alternatively, one may select the text with the "V" visual mode
command.
If you want to use visual-block mode (ctrl-v), I suggest using
an AlignMap with the vis.vim plugin, available at either
stable: http://vim.sourceforge.net/scripts/script.php?script_id=1195
devel : http://mysite.verizon.net/astronaut/vim/index.html#VIS
Use it with commands such as >
ctrl-v (move)
:B norm \alignmap_sequence
<
ALIGNMENT MAP USE WITH MENUS~
One may use the mark-and-move style (ma, move, use the menu) or
the visual mode style (use the V visual mode, move, then select
@ -862,7 +939,6 @@ ALIGNMENT *align-align* {{{2
must be included).
COMPLEX ALIGNMENT MAP METHOD~
For those complex alignment maps which do alignment on constructs
(e.g. \acom, \adec, etc), a series of substitutes is used to insert
"@" symbols in appropriate locations. Align#Align() is then used to
@ -981,6 +1057,17 @@ ALIGNMENT *align-align* {{{2
Alignment Map Examples: \anum *alignmap-anum* {{{3
---------------------------
First, note that the behavior of the \anum map depends on the existence
of either the vim variable >
g:alignmaps_usanumber
< or >
g:alignmaps_euronumber
< when AlignMaps is loaded.
Essentially, "usa" numbers use "."s and "euro" numbers use ","s to
separate the integer from the fractional portion of a number.
"Usa" numbers are default.
Original: illustrates how to get numbers lined up >
-1.234 .5678 -.901e-4
1.234 5.678 9.01e-4
@ -1012,7 +1099,8 @@ ALIGNMENT *align-align* {{{2
12,34 56,78 90,1e-4
123,4 567,8 901,e-4
<
Becomes: Go to first line, ma. Go to last line, press \anum >
Becomes: (assuming g:alignmaps_euronumber exists)
Go to first line, ma. Go to last line, press \anum >
-1,234 ,5678 -,901e-4
1,234 5,678 9,01e-4
12,34 56,78 90,1e-4
@ -1022,9 +1110,10 @@ ALIGNMENT *align-align* {{{2
\aenum is provided to support European-style numbers
\aunum is provided to support USA-style numbers
One may get \aenum behavior for \anum >
*g:alignmaps_usanumber* *g:alignmaps_euronumber*
One may get \aenum behavior for \anum by putting >
let g:alignmaps_euronumber= 1
< or \aunum behavior for \anum if one puts >
< or \aunum behavior for \anum by putting >
let g:alignmaps_usanumber= 1
< in one's <.vimrc>.
@ -1311,6 +1400,33 @@ ALIGNMENT *align-align* {{{2
4. Alignment Tools' History *align-history* {{{1
ALIGN HISTORY {{{2
36 : May 20, 2009 * Previously, the "W" AlignCtrl setting, intended
to retain initial white space, did so by convert-
ing any leading tabs into an equivalent quantity
of blanks (using the current tabstop setting).
Align will now retain leading tabs.
Nov 24, 2009 * QArgSplitter() used split(), intending to split
on white space only. However, the \tab map
uses ctrl-o as a separator instead of tabs; the
split() function treated the ctrl-o as a whitespace
character, too. Solution: give split() an explicit
pattern matching blanks and tabs, only. \tab now
works again!
Jun 29, 2010 * included |g:AlignSkip| and |alignctrl-star| support
May 10, 2011 * if the range is only one line, then Align will
automatically grow the range to accommodate all
lines containing the first separator pattern
surrounding the current line.
Aug 05, 2011 * g:Align_xstrlen usage extended to permit users to
specify a function by name which computes string
length.
Oct 27, 2011 * (reported by Fco Javier) reported a problem with
the default s:Strlen() result; there was a missing
"let". Fixed.
Nov 10, 2011 * (Lewis Thompson) Align was doing "set noet" when
it should've been doing "setlocal noet".
Dec 22, 2011 * modifed s:Strlen() to use |strdisplaywidth()| when
g:Align_xstrlen is zero.
35 : Nov 02, 2008 * g:loaded_AlignPlugin testing to prevent re-loading
installed
Nov 19, 2008 * new sanity check for an AlignStyle of just ":"
@ -1382,6 +1498,15 @@ ALIGN HISTORY {{{2
9 : Jun 25, 2002 : implemented cyclic padding
ALIGNMENT MAP HISTORY *alignmap-history* {{{2
v42 Jan 06, 2010 * new maps for \anum, \aenum, \aunum
Feb 16, 2010 * map for \t=, \T= now handles x++ = something;
for c, c++ correctly.
Oct 29, 2010 * added a note on having one's own default
AlignCtrl (see |alignctrl-init|)
Feb 22, 2011 * for menus, &go =~# used to insure correct case
Jun 10, 2011 * |:AlignMapsClean| command provided to make it
easy for those who would prefer not to have
AlignMaps' maps not to have them.
v41 Nov 02, 2008 * g:loaded_AlignMapsPlugin testing to prevent
re-loading installed
* AlignMaps now use 0x0f (ctrl-p) for special

View File

@ -11,37 +11,37 @@
CONTENTS *NERDCommenterContents*
1.Intro...................................|NERDCommenter|
2.Functionality provided..................|NERDComFunctionality|
2.1 Functionality Summary.............|NERDComFunctionalitySummary|
2.2 Functionality Details.............|NERDComFunctionalityDetails|
2.2.1 Comment map.................|NERDComComment|
2.2.2 Nested comment map..........|NERDComNestedComment|
2.2.3 Toggle comment map..........|NERDComToggleComment|
2.2.4 Minimal comment map.........|NERDComMinimalComment|
2.2.5 Invert comment map..........|NERDComInvertComment|
2.2.6 Sexy comment map............|NERDComSexyComment|
2.2.7 Yank comment map............|NERDComYankComment|
2.2.8 Comment to EOL map..........|NERDComEOLComment|
2.2.9 Append com to line map......|NERDComAppendComment|
2.2.10 Insert comment map.........|NERDComInsertComment|
2.2.11 Use alternate delims map...|NERDComAltDelim|
2.2.12 Comment aligned maps.......|NERDComAlignedComment|
2.2.13 Uncomment line map.........|NERDComUncommentLine|
2.3 Supported filetypes...............|NERDComFiletypes|
2.4 Sexy Comments.....................|NERDComSexyComments|
2.5 The NERDComment function..........|NERDComNERDComment|
3.Options.................................|NERDComOptions|
3.1 Options summary...................|NERDComOptionsSummary|
3.2 Options details...................|NERDComOptionsDetails|
3.3 Default delimiter Options.........|NERDComDefaultDelims|
4. Customising key mappings...............|NERDComMappings|
5. Issues with the script.................|NERDComIssues|
5.1 Delimiter detection heuristics....|NERDComHeuristics|
5.2 Nesting issues....................|NERDComNesting|
6.About.. ............................|NERDComAbout|
7.Changelog...............................|NERDComChangelog|
8.Credits.................................|NERDComCredits|
9.License.................................|NERDComLicense|
2.Installation............................|NERDComInstallation|
3.Functionality provided..................|NERDComFunctionality|
3.1 Functionality Summary.............|NERDComFunctionalitySummary|
3.2 Functionality Details.............|NERDComFunctionalityDetails|
3.2.1 Comment map.................|NERDComComment|
3.2.2 Nested comment map..........|NERDComNestedComment|
3.2.3 Toggle comment map..........|NERDComToggleComment|
3.2.4 Minimal comment map.........|NERDComMinimalComment|
3.2.5 Invert comment map..........|NERDComInvertComment|
3.2.6 Sexy comment map............|NERDComSexyComment|
3.2.7 Yank comment map............|NERDComYankComment|
3.2.8 Comment to EOL map..........|NERDComEOLComment|
3.2.9 Append com to line map......|NERDComAppendComment|
3.2.10 Insert comment map.........|NERDComInsertComment|
3.2.11 Use alternate delims map...|NERDComAltDelim|
3.2.12 Comment aligned maps.......|NERDComAlignedComment|
3.2.13 Uncomment line map.........|NERDComUncommentLine|
3.4 Sexy Comments.....................|NERDComSexyComments|
3.5 The NERDComment function..........|NERDComNERDComment|
4.Options.................................|NERDComOptions|
4.1 Options summary...................|NERDComOptionsSummary|
4.2 Options details...................|NERDComOptionsDetails|
4.3 Default delimiter Options.........|NERDComDefaultDelims|
5. Customising key mappings...............|NERDComMappings|
6. Issues with the script.................|NERDComIssues|
6.1 Delimiter detection heuristics....|NERDComHeuristics|
6.2 Nesting issues....................|NERDComNesting|
7.About.. ............................|NERDComAbout|
8.Changelog...............................|NERDComChangelog|
9.Credits.................................|NERDComCredits|
10.License................................|NERDComLicense|
==============================================================================
1. Intro *NERDCommenter*
@ -54,48 +54,69 @@ There are also options that allow to tweak the commenting engine to your
taste.
==============================================================================
2. Functionality provided *NERDComFunctionality*
2. Installation *NERDComInstallation*
The NERD Commenter requires Vim 7 or higher.
Extract the plugin files in your ~/.vim (*nix) or ~/vimfiles (Windows). You
should have 2 files: >
plugin/NERD_commenter.vim
doc/NERD_commenter.txt
<
Next, to finish installing the help file run: >
:helptags ~/.vim/doc
<
See |add-local-help| for more details.
Make sure that you have filetype plugins enabled, as the script makes use of
|'commentstring'| where possible (which is usually set in a filetype plugin).
See |filetype-plugin-on| for details, but basically, stick this in your vimrc >
filetype plugin on
<
==============================================================================
3. Functionality provided *NERDComFunctionality*
------------------------------------------------------------------------------
2.1 Functionality summary *NERDComFunctionalitySummary*
3.1 Functionality summary *NERDComFunctionalitySummary*
The following key mappings are provided by default (there is also a menu
with items corresponding to all the mappings below):
[count],cc |NERDComComment|
[count]<leader>cc |NERDComComment|
Comment out the current line or text selected in visual mode.
[count],cn |NERDComNestedComment|
Same as ,cc but forces nesting.
[count]<leader>cn |NERDComNestedComment|
Same as <leader>cc but forces nesting.
[count],c<space> |NERDComToggleComment|
[count]<leader>c<space> |NERDComToggleComment|
Toggles the comment state of the selected line(s). If the topmost selected
line is commented, all selected lines are uncommented and vice versa.
[count],cm |NERDComMinimalComment|
[count]<leader>cm |NERDComMinimalComment|
Comments the given lines using only one set of multipart delimiters.
[count],ci |NERDComInvertComment|
[count]<leader>ci |NERDComInvertComment|
Toggles the comment state of the selected line(s) individually.
[count],cs |NERDComSexyComment|
[count]<leader>cs |NERDComSexyComment|
Comments out the selected lines ``sexily''
[count],cy |NERDComYankComment|
Same as ,cc except that the commented line(s) are yanked first.
[count]<leader>cy |NERDComYankComment|
Same as <leader>cc except that the commented line(s) are yanked first.
,c$ |NERDComEOLComment|
<leader>c$ |NERDComEOLComment|
Comments the current line from the cursor to the end of line.
,cA |NERDComAppendComment|
<leader>cA |NERDComAppendComment|
Adds comment delimiters to the end of line and goes into insert mode between
them.
@ -105,26 +126,26 @@ Adds comment delimiters at the current cursor position and inserts between.
Disabled by default.
,ca |NERDComAltDelim|
<leader>ca |NERDComAltDelim|
Switches to the alternative set of delimiters.
[count],cl
[count],cb |NERDComAlignedComment|
[count]<leader>cl
[count]<leader>cb |NERDComAlignedComment|
Same as |NERDComComment| except that the delimiters are aligned down the
left side (,cl) or both sides (,cb).
left side (<leader>cl) or both sides (<leader>cb).
[count],cu |NERDComUncommentLine|
[count]<leader>cu |NERDComUncommentLine|
Uncomments the selected line(s).
------------------------------------------------------------------------------
2.2 Functionality details *NERDComFunctionalityDetails*
3.2 Functionality details *NERDComFunctionalityDetails*
------------------------------------------------------------------------------
2.2.1 Comment map *NERDComComment*
3.2.1 Comment map *NERDComComment*
Default mapping: [count],cc
Default mapping: [count]<leader>cc
Mapped to: <plug>NERDCommenterComment
Applicable modes: normal visual visual-line visual-block.
@ -138,14 +159,14 @@ If a [count] is given in normal mode, the mapping works as though that many
lines were selected in visual-line mode.
------------------------------------------------------------------------------
2.2.2 Nested comment map *NERDComNestedComment*
3.2.2 Nested comment map *NERDComNestedComment*
Default mapping: [count],cn
Default mapping: [count]<leader>cn
Mapped to: <plug>NERDCommenterNest
Applicable modes: normal visual visual-line visual-block.
Performs nested commenting. Works the same as ,cc except that if a line is
already commented then it will be commented again.
Performs nested commenting. Works the same as <leader>cc except that if a line
is already commented then it will be commented again.
If |'NERDUsePlaceHolders'| is set then the previous comment delimiters will
be replaced by place-holder delimiters if needed. Otherwise the nested
@ -159,9 +180,9 @@ Related options:
|'NERDDefaultNesting'|
------------------------------------------------------------------------------
2.2.3 Toggle comment map *NERDComToggleComment*
3.2.3 Toggle comment map *NERDComToggleComment*
Default mapping: [count],c<space>
Default mapping: [count]<leader>c<space>
Mapped to: <plug>NERDCommenterToggle
Applicable modes: normal visual-line.
@ -176,17 +197,17 @@ If a [count] is given in normal mode, the mapping works as though that many
lines were selected in visual-line mode.
------------------------------------------------------------------------------
2.2.4 Minimal comment map *NERDComMinimalComment*
3.2.4 Minimal comment map *NERDComMinimalComment*
Default mapping: [count],cm
Default mapping: [count]<leader>cm
Mapped to: <plug>NERDCommenterMinimal
Applicable modes: normal visual-line.
Comments the selected lines using one set of multipart delimiters if possible.
For example: if you are programming in c and you select 5 lines and press ,cm
then a '/*' will be placed at the start of the top line and a '*/' will be
placed at the end of the last line.
For example: if you are programming in c and you select 5 lines and press
<leader>cm then a '/*' will be placed at the start of the top line and a '*/'
will be placed at the end of the last line.
Sets of multipart comment delimiters that are between the top and bottom
selected lines are replaced with place holders (see |'NERDLPlace'|) if
@ -198,9 +219,9 @@ If a [count] is given in normal mode, the mapping works as though that many
lines were selected in visual-line mode.
------------------------------------------------------------------------------
2.2.5 Invert comment map *NERDComInvertComment*
3.2.5 Invert comment map *NERDComInvertComment*
Default mapping: ,ci
Default mapping: <leader>ci
Mapped to: <plug>NERDCommenterInvert
Applicable modes: normal visual-line.
@ -215,9 +236,9 @@ If a [count] is given in normal mode, the mapping works as though that many
lines were selected in visual-line mode.
------------------------------------------------------------------------------
2.2.6 Sexy comment map *NERDComSexyComment*
3.2.6 Sexy comment map *NERDComSexyComment*
Default mapping: [count],cs
Default mapping: [count]<leader>cs
Mapped to: <plug>NERDCommenterSexy
Applicable modes: normal, visual-line.
@ -235,18 +256,18 @@ Related options:
|'NERDCompactSexyComs'|
------------------------------------------------------------------------------
2.2.7 Yank comment map *NERDComYankComment*
3.2.7 Yank comment map *NERDComYankComment*
Default mapping: [count],cy
Default mapping: [count]<leader>cy
Mapped to: <plug>NERDCommenterYank
Applicable modes: normal visual visual-line visual-block.
Same as ,cc except that it yanks the line(s) that are commented first.
Same as <leader>cc except that it yanks the line(s) that are commented first.
------------------------------------------------------------------------------
2.2.8 Comment to EOL map *NERDComEOLComment*
3.2.8 Comment to EOL map *NERDComEOLComment*
Default mapping: ,c$
Default mapping: <leader>c$
Mapped to: <plug>NERDCommenterToEOL
Applicable modes: normal.
@ -254,9 +275,9 @@ Comments the current line from the current cursor position up to the end of
the line.
------------------------------------------------------------------------------
2.2.9 Append com to line map *NERDComAppendComment*
3.2.9 Append com to line map *NERDComAppendComment*
Default mapping: ,cA
Default mapping: <leader>cA
Mapped to: <plug>NERDCommenterAppend
Applicable modes: normal.
@ -264,7 +285,7 @@ Appends comment delimiters to the end of the current line and goes
to insert mode between the new delimiters.
------------------------------------------------------------------------------
2.2.10 Insert comment map *NERDComInsertComment*
3.2.10 Insert comment map *NERDComInsertComment*
Default mapping: disabled by default.
Map it to: <plug>NERDCommenterInInsert
@ -280,37 +301,37 @@ mapping add >
to your vimrc.
------------------------------------------------------------------------------
2.2.11 Use alternate delims map *NERDComAltDelim*
3.2.11 Use alternate delims map *NERDComAltDelim*
Default mapping: ,ca
Default mapping: <leader>ca
Mapped to: <plug>NERDCommenterAltDelims
Applicable modes: normal.
Changes to the alternative commenting style if one is available. For example,
if the user is editing a c++ file using // comments and they hit ,ca
if the user is editing a c++ file using // comments and they hit <leader>ca
then they will be switched over to /**/ comments.
See also |NERDComDefaultDelims|
------------------------------------------------------------------------------
2.2.12 Comment aligned maps *NERDComAlignedComment*
3.2.12 Comment aligned maps *NERDComAlignedComment*
Default mappings: [count],cl [count],cb
Default mappings: [count]<leader>cl [count]<leader>cb
Mapped to: <plug>NERDCommenterAlignLeft
<plug>NERDCommenterAlignBoth
Applicable modes: normal visual-line.
Same as ,cc except that the comment delimiters are aligned on the left side or
both sides respectively. These comments are always nested if the line(s) are
already commented.
Same as <leader>cc except that the comment delimiters are aligned on the left
side or both sides respectively. These comments are always nested if the
line(s) are already commented.
If a [count] is given in normal mode, the mapping works as though that many
lines were selected in visual-line mode.
------------------------------------------------------------------------------
2.2.13 Uncomment line map *NERDComUncommentLine*
3.2.13 Uncomment line map *NERDComUncommentLine*
Default mapping: [count],cu
Default mapping: [count]<leader>cu
Mapped to: <plug>NERDCommenterUncomment
Applicable modes: normal visual visual-line visual-block.
@ -331,41 +352,7 @@ Related options:
|'NERDRemoveExtraSpaces'|
------------------------------------------------------------------------------
2.3 Supported filetypes *NERDComFiletypes*
Filetypes that can be commented by this plugin:
abaqus abc acedb ada ahdl amiga aml ampl ant apache apachestyle asm68k asm asn
aspvbs atlas autohotkey autoit automake ave awk basic b bc bdf bib bindzone
bst btm caos catalog c cfg cg ch changelog cl clean clipper cmake conf config
context cpp crontab cs csc csp css cterm cupl csv cvs dcl debchangelog
debcontrol debsources def diff django docbk dns dosbatch dosini dot dracula
dsl dtd dtml dylan ecd eiffel elf elmfilt erlang eruby eterm expect exports
fetchmail fgl focexec form fortran foxpro fstab fvwm fx gdb gdmo geek
gentoo-package-keywords' gentoo-package-mask' gentoo-package-use' gnuplot
gtkrc haskell hb h help hercules hog html htmldjango htmlos ia64 icon idlang
idl indent inform inittab ishd iss ist jam java javascript jess jgraph
jproperties jproperties jsp kconfig kix kscript lace lex lftp lifelines lilo
lisp lite lotos lout lprolog lscript lss lua lynx m4 mail make maple masm
master matlab mel mf mib mma model moduala. modula2 modula3 monk mush muttrc
named nasm nastran natural ncf netdict netrw nqc nroff nsis objc ocaml occam
omlet omnimark openroad opl ora otl ox pascal passwd pcap pccts perl pfmain
php phtml pic pike pilrc pine plaintex plm plsql po postscr pov povini ppd
ppwiz procmail progress prolog psf ptcap python python qf radiance ratpoison r
rc readline rebol registry remind rexx robots rpl rtf ruby sa samba sas sass
sather scheme scilab screen scsh sdl sed selectbuf sgml sgmldecl sgmllnx sh
sicad simula sinda skill slang sl slrnrc sm smarty smil smith sml snnsnet
snnspat snnsres snobol4 spec specman spice sql sqlforms sqlj sqr squid st stp
strace svn systemverilog tads taglist tags tak tasm tcl terminfo tex text
plaintex texinfo texmf tf tidy tli trasys tsalt tsscl tssgm uc uil vb verilog
verilog_systemverilog vgrindefs vhdl vim viminfo virata vo_base vrml vsejcl
webmacro wget winbatch wml wvdial xdefaults xf86conf xhtml xkb xmath xml
xmodmap xpm2 xpm xslt yacc yaml z8a
If a language is not in the list of hardcoded supported filetypes then the
&commentstring vim option is used.
------------------------------------------------------------------------------
2.4 Sexy Comments *NERDComSexyComments*
3.3 Sexy Comments *NERDComSexyComments*
These are comments that use one set of multipart comment delimiters as well as
one other marker symbol. For example: >
/*
@ -380,7 +367,7 @@ one other marker symbol. For example: >
Here the multipart delimiters are /* and */ and the marker is *.
------------------------------------------------------------------------------
2.5 The NERDComment function *NERDComNERDComment*
3.4 The NERDComment function *NERDComNERDComment*
All of the NERD commenter mappings and menu items invoke a single function
which delegates the commenting work to other functions. This function is
@ -404,10 +391,10 @@ then the script would do a sexy comment on the last visual selection.
==============================================================================
3. Options *NERDComOptions*
4. Options *NERDComOptions*
------------------------------------------------------------------------------
3.1 Options summary *NERDComOptionsSummary*
4.1 Options summary *NERDComOptionsSummary*
|'loaded_nerd_comments'| Turns off the script.
|'NERDAllowAnyVisualDelims'| Allows multipart alternative delims to
@ -444,7 +431,7 @@ then the script would do a sexy comment on the last visual selection.
style sexy comments.
------------------------------------------------------------------------------
3.3 Options details *NERDComOptionsDetails*
4.3 Options details *NERDComOptionsDetails*
To enable any of the below options you should put the given line in your
~/.vimrc
@ -581,7 +568,7 @@ this option tells the script whether to look for, and remove, comment
delimiters of the alternative style.
For example, if you are editing a c++ file using // style comments and you go
,cu on this line: >
<leader>cu on this line: >
/* This is a c++ comment baby! */
<
It will not be uncommented if the NERDRemoveAltComs is set to 0.
@ -633,7 +620,7 @@ To set these options use lines like: >
Following the above example, if we have line of c code: >
/* int horse */
<
and we comment it with ,cn it will be changed to: >
and we comment it with <leader>cn it will be changed to: >
/*FOO int horse BAR*/
<
When we uncomment this line it will go back to what it was.
@ -698,7 +685,8 @@ Values: 0 or 1.
Default 1.
When this option is set to 1, comments are nested automatically. That is, if
you hit ,cc on a line that is already commented it will be commented again
you hit <leader>cc on a line that is already commented it will be commented
again.
------------------------------------------------------------------------------
3.3 Default delimiter customisation *NERDComDefaultDelims*
@ -715,7 +703,7 @@ Example: java uses // style comments by default, but you want it to default to
See |NERDComAltDelim| for switching commenting styles at runtime.
==============================================================================
4. Key mapping customisation *NERDComMappings*
5. Key mapping customisation *NERDComMappings*
To change a mapping just map another key combo to the internal <plug> mapping.
For example, to remap the |NERDComComment| mapping to ",omg" you would put
@ -730,11 +718,11 @@ map to.
See also |'NERDCreateDefaultMappings'|.
==============================================================================
5. Issues with the script *NERDComIssues*
6. Issues with the script *NERDComIssues*
------------------------------------------------------------------------------
5.1 Delimiter detection heuristics *NERDComHeuristics*
6.1 Delimiter detection heuristics *NERDComHeuristics*
Heuristics are used to distinguish the real comment delimiters
@ -754,7 +742,7 @@ string. These heuristics, while usually pretty accurate, will not work for all
cases.
------------------------------------------------------------------------------
5.2 Nesting issues *NERDComNesting*
6.2 Nesting issues *NERDComNesting*
If we have some line of code like this: >
/*int foo */ = /*5 + 9;*/
@ -774,7 +762,7 @@ will become: >
for simplicity)
==============================================================================
6. About *NERDComAbout*
7. About *NERDComAbout*
The author of the NERD commenter is Martyzillatron --- the half robot, half
dinosaur bastard son of Megatron and Godzilla. He enjoys destroying
@ -793,6 +781,15 @@ The latest dev versions are on github
==============================================================================
8. Changelog *NERDComChangelog*
2.3.0
- remove all filetypes which have a &commentstring in the standard vim
runtime for vim > 7.0 unless the script stores an alternate set of
delimiters
- make the script complain if the user doesnt have filetype plugins enabled
- use <leader> instead of comma to start the default mappings
- fix a couple of bugs with sexy comments - thanks to Tim Smart
- lots of refactoring
2.2.2
- remove the NERDShutup option and the message is suppresses, this makes
the plugin silently rely on &commentstring for unknown filetypes.
@ -848,7 +845,7 @@ The latest dev versions are on github
NERDComInsertComment if you wish to restore it
==============================================================================
8. Credits *NERDComCredits*
9. Credits *NERDComCredits*
Thanks to the follow people for suggestions and patches:
@ -985,7 +982,7 @@ Matt Tolton javacc
Ivan Devat javascript.jquery
tpope cucumber,pdf
==============================================================================
9. License *NERDComLicense*
10. License *NERDComLicense*
The NERD commenter is released under the wtfpl.
See http://sam.zoy.org/wtfpl/COPYING.

View File

@ -27,11 +27,13 @@ CONTENTS *NERDTree-contents*
2.2.2.Bookmark commands...........|NERDTreeBookmarkCommands|
2.2.3.Invalid bookmarks...........|NERDTreeInvalidBookmarks|
2.3.NERD tree mappings................|NERDTreeMappings|
2.4.The filesystem menu...............|NERDTreeFilesysMenu|
2.4.The NERD tree menu................|NERDTreeMenu|
3.Options.................................|NERDTreeOptions|
3.1.Option summary....................|NERDTreeOptionSummary|
3.2.Option details....................|NERDTreeOptionDetails|
4.Hacking the NERD tree...................|NERDTreeHacking|
4.The NERD tree API.......................|NERDTreeAPI|
4.1.Key map API.......................|NERDTreeKeymapAPI|
4.2.Menu API..........................|NERDTreeMenuAPI|
5.About...................................|NERDTreeAbout|
6.Changelog...............................|NERDTreeChangelog|
7.Credits.................................|NERDTreeCredits|
@ -68,9 +70,6 @@ The following features and functionality are provided by the NERD tree:
* custom file filters to prevent e.g. vim backup files being displayed
* optional displaying of hidden files (. files)
* files can be "turned off" so that only directories are displayed
* A textual filesystem menu is provided which allows you to
create/delete/move file and directory nodes as well as copy (for
supported OSs)
* The position and size of the NERD tree window can be customised
* The order in which the nodes in the tree are listed can be customised.
* A model of your filesystem is created/maintained as you explore it. This
@ -87,6 +86,12 @@ The following features and functionality are provided by the NERD tree:
* By default the script overrides the default file browser (netw), so if
you :edit a directory a (slighly modified) NERD tree will appear in the
current window
* A programmable menu system is provided (simulates right clicking on a
node)
* one default menu plugin is provided to perform basic filesytem
operations (create/delete/move/copy files/directories)
* There's an API for adding your own keymappings
==============================================================================
2. Functionality provided *NERDTreeFunctionality*
@ -123,6 +128,15 @@ The following features and functionality are provided by the NERD tree:
:NERDTreeClose *:NERDTreeClose*
Close the NERD tree in this tab.
:NERDTreeFind *:NERDTreeFind*
Find the current file in the tree.
If not tree exists and the current file is under vim's CWD, then init a
tree at the CWD and reveal the file. Otherwise init a tree in the current
file's directory.
In any case, the current file is revealed and the cursor is placed on it.
------------------------------------------------------------------------------
2.2. Bookmarks *NERDTreeBookmarks*
@ -145,6 +159,8 @@ Note that the following commands are only available in the NERD tree buffer.
:Bookmark <name>
Bookmark the current node as <name>. If there is already a <name>
bookmark, it is overwritten. <name> must not contain spaces.
If <name> is not provided, it defaults to the file or directory name.
For directories, a trailing slash is present.
:BookmarkToRoot <bookmark>
Make the directory corresponding to <bookmark> the new root. If a treenode
@ -205,12 +221,12 @@ i.......Open selected file in a split window.....................|NERDTree-i|
gi......Same as i, but leave the cursor on the NERDTree..........|NERDTree-gi|
s.......Open selected file in a new vsplit.......................|NERDTree-s|
gs......Same as s, but leave the cursor on the NERDTree..........|NERDTree-gs|
!.......Execute the current file.................................|NERDTree-!|
O.......Recursively open the selected directory..................|NERDTree-O|
x.......Close the current nodes parent...........................|NERDTree-x|
X.......Recursively close all children of the current node.......|NERDTree-X|
e.......Edit the current dif.....................................|NERDTree-e|
<CR>...............same as |NERDTree-o|.
double-click.......same as the |NERDTree-o| map.
middle-click.......same as |NERDTree-i| for files, same as
|NERDTree-e| for dirs.
@ -221,15 +237,15 @@ P.......Jump to the root node....................................|NERDTree-P|
p.......Jump to current nodes parent.............................|NERDTree-p|
K.......Jump up inside directories at the current tree depth.....|NERDTree-K|
J.......Jump down inside directories at the current tree depth...|NERDTree-J|
<C-j>...Jump down to the next sibling of the current directory...|NERDTree-c-j|
<C-k>...Jump up to the previous sibling of the current directory.|NERDTree-c-k|
<C-J>...Jump down to the next sibling of the current directory...|NERDTree-C-J|
<C-K>...Jump up to the previous sibling of the current directory.|NERDTree-C-K|
C.......Change the tree root to the selected dir.................|NERDTree-C|
u.......Move the tree root up one directory......................|NERDTree-u|
U.......Same as 'u' except the old root node is left open........|NERDTree-U|
r.......Recursively refresh the current directory................|NERDTree-r|
R.......Recursively refresh the current root.....................|NERDTree-R|
m.......Display the filesystem menu..............................|NERDTree-m|
m.......Display the NERD tree menu...............................|NERDTree-m|
cd......Change the CWD to the dir of the selected node...........|NERDTree-cd|
I.......Toggle whether hidden files displayed....................|NERDTree-I|
@ -238,6 +254,7 @@ F.......Toggle whether files are displayed.......................|NERDTree-F|
B.......Toggle whether the bookmark table is displayed...........|NERDTree-B|
q.......Close the NERDTree window................................|NERDTree-q|
A.......Zoom (maximize/minimize) the NERDTree window.............|NERDTree-A|
?.......Toggle the display of the quick help.....................|NERDTree-?|
------------------------------------------------------------------------------
@ -330,14 +347,6 @@ The same as |NERDTree-s| except that the cursor is not moved.
The key combo for this mapping is always "g" + NERDTreeMapOpenVSplit (see
|NERDTree-s|).
------------------------------------------------------------------------------
*NERDTree-!*
Default key: !
Map option: NERDTreeMapExecute
Applies to: files.
Executes the selected file, prompting for arguments first.
------------------------------------------------------------------------------
*NERDTree-O*
Default key: O
@ -430,16 +439,16 @@ If the cursor is already on the last node then do the following:
* go to the last child of that node
------------------------------------------------------------------------------
*NERDTree-c-j*
Default key: <C-j>
*NERDTree-C-J*
Default key: <C-J>
Map option: NERDTreeMapJumpNextSibling
Applies to: files and directories.
Jump to the next sibling of the selected node.
------------------------------------------------------------------------------
*NERDTree-c-k*
Default key: <C-k>
*NERDTree-C-K*
Default key: <C-K>
Map option: NERDTreeMapJumpPrevSibling
Applies to: files and directories.
@ -492,10 +501,18 @@ Recursively refresh the tree root.
------------------------------------------------------------------------------
*NERDTree-m*
Default key: m
Map option: NERDTreeMapFilesystemMenu
Map option: NERDTreeMapMenu
Applies to: files and directories.
Display the filesystem menu. See |NERDTreeFilesysMenu| for details.
Display the NERD tree menu. See |NERDTreeMenu| for details.
------------------------------------------------------------------------------
*NERDTree-cd*
Default key: cd
Map option: NERDTreeMapChdir
Applies to: files and directories.
Change vims current working directory to that of the selected node.
------------------------------------------------------------------------------
*NERDTree-I*
@ -537,6 +554,14 @@ Applies to: no restrictions.
Closes the NERDtree window.
------------------------------------------------------------------------------
*NERDTree-A*
Default key: A
Map option: NERDTreeMapToggleZoom
Applies to: no restrictions.
Maximize (zoom) and minimize the NERDtree window.
------------------------------------------------------------------------------
*NERDTree-?*
Default key: ?
@ -546,44 +571,18 @@ Applies to: no restrictions.
Toggles whether the quickhelp is displayed.
------------------------------------------------------------------------------
2.3. The filesystem menu *NERDTreeFilesysMenu*
2.3. The NERD tree menu *NERDTreeMenu*
The purpose of the filesystem menu is to allow you to perform basic filesystem
operations quickly from the NERD tree rather than the console.
The NERD tree has a menu that can be programmed via the an API (see
|NERDTreeMenuAPI|). The idea is to simulate the "right click" menus that most
file explorers have.
The filesystem menu can be accessed with 'm' mapping and has four supported
operations: >
1. Adding nodes.
2. Move nodes.
3. Deleting nodes.
3. Copying nodes.
<
1. Adding nodes:
To add a node move the cursor onto (or anywhere inside) the directory you wish
to create the new node inside. Select the 'add node' option from the
filesystem menu and type a filename. If the filename you type ends with a '/'
character then a directory will be created. Once the operation is completed,
the cursor is placed on the new node.
The script comes with two default menu plugins: exec_menuitem.vim and
fs_menu.vim. fs_menu.vim adds some basic filesystem operations to the menu for
creating/deleting/moving/copying files and dirs. exec_menuitem.vim provides a
menu item to execute executable files.
2. Move nodes:
To move/rename a node, put the cursor on it and select the 'move' option from
the filesystem menu. Enter the new location for the node and it will be
moved. If the old file is open in a buffer, you will be asked if you wish to
delete that buffer. Once the operation is complete the cursor will be placed
on the renamed node.
3. Deleting nodes:
To delete a node put the cursor on it and select the 'delete' option from the
filesystem menu. After confirmation the node will be deleted. If a file is
deleted but still exists as a buffer you will be given the option to delete
that buffer.
4. Copying nodes:
To copy a node put the cursor on it and select the 'copy' option from the
filesystem menu. Enter the new location and you're done. Note: copying is
currently only supported for *nix operating systems. If someone knows a
one line copying command for windows that doesnt require user confirmation
then id be grateful if you'd email me.
Related tags: |NERDTree-m| |NERDTreeApi|
==============================================================================
3. Customisation *NERDTreeOptions*
@ -649,6 +648,12 @@ NERD tree. These options should be set in your vimrc.
|'NERDTreeWinSize'| Sets the window size when the NERD tree is
opened.
|'NERDTreeMinimalUI'| Disables display of the 'Bookmarks' label and
'Press ? for help' text.
|'NERDTreeDirArrows'| Tells the NERD tree to use arrows instead of
+ ~ chars when displaying directories.
------------------------------------------------------------------------------
3.2. Customisation details *NERDTreeOptionDetails*
@ -679,7 +684,7 @@ If set to 1, the NERD tree window will center around the cursor if it moves to
within |'NERDTreeAutoCenterThreshold'| lines of the top/bottom of the window.
This is ONLY done in response to tree navigation mappings,
i.e. |NERDTree-J| |NERDTree-K| |NERDTree-C-J| |NERDTree-c-K| |NERDTree-p|
i.e. |NERDTree-J| |NERDTree-K| |NERDTree-C-J| |NERDTree-C-K| |NERDTree-p|
|NERDTree-P|
The centering is done with a |zz| operation.
@ -742,7 +747,7 @@ Values: 0 or 1.
Default: 1.
If set to 1, the current cursor line in the NERD tree buffer will be
highlighted. This is done using the |cursorline| option.
highlighted. This is done using the |'cursorline'| option.
------------------------------------------------------------------------------
*'NERDTreeHijackNetrw'*
@ -815,7 +820,7 @@ Values: 0 or 1.
Default: 0
If set to 1, the NERD tree window will close after opening a file with the
|NERDTree-o| or |NERDTree-i| mappings.
|NERDTree-o|, |NERDTree-i|, |NERDTree-t| and |NERDTree-T| mappings.
------------------------------------------------------------------------------
*'NERDTreeShowBookmarks'*
@ -928,44 +933,167 @@ Default: 31.
This option is used to change the size of the NERD tree when it is loaded.
==============================================================================
4. Hacking the NERD tree *NERDTreeHacking*
------------------------------------------------------------------------------
*'NERDTreeMinimalUI'*
Values: 0 or 1
Default: 0
Public functions ~
The script provides 2 public functions for your hacking pleasure. Their
signatures are: >
function! NERDTreeGetCurrentNode()
function! NERDTreeGetCurrentPath()
This options disables the 'Bookmarks' label 'Press ? for help' text. Use one
of the following lines to set this option: >
let NERDTreeMinimalUI=0
let NERDTreeMinimalUI=1
<
The first returns the node object that the cursor is currently on, while the
second returns the corresponding path object.
This is probably a good time to mention that the script implements prototype
style OO. To see the functions that each class provides you can read look at
the code.
------------------------------------------------------------------------------
*'NERDTreeDirArrows'*
Values: 0 or 1
Default: 0.
Use the node objects to manipulate the structure of the tree. Use the path
objects to access the files/directories the tree nodes represent.
This option is used to change the default look of directory nodes displayed in
the tree. When set to 0 it shows old-school bars (|), + and ~ chars. If set to
1 it shows right and down arrows. Use one of the follow lines to set this
option: >
let NERDTreeDirArrows=0
let NERDTreeDirArrows=1
<
The NERD tree filetype ~
==============================================================================
4. The NERD tree API *NERDTreeAPI*
NERD tree buffers have a filetype of "nerdtree". You can use this to hack the
NERD tree via autocommands (on |FileType|) or via an ftplugin.
The NERD tree script allows you to add custom key mappings and menu items via
a set of API calls. Any scripts that use this API should be placed in
~/.vim/nerdtree_plugin/ (*nix) or ~/vimfiles/nerdtree_plugin (windows).
For example, putting this code in ~/.vim/ftplugin/nerdtree.vim would override
the o mapping, making it open the selected node in a new gvim instance. >
The script exposes some prototype objects that can be used to manipulate the
tree and/or get information from it: >
g:NERDTreePath
g:NERDTreeDirNode
g:NERDTreeFileNode
g:NERDTreeBookmark
<
See the code/comments in NERD_tree.vim to find how to use these objects. The
following code conventions are used:
* class members start with a capital letter
* instance members start with a lower case letter
* private members start with an underscore
nnoremap <silent> <buffer> o :call <sid>openInNewVimInstance()<cr>
function! s:openInNewVimInstance()
let p = NERDTreeGetCurrentPath()
if p != {}
silent exec "!gvim " . p.strForOS(1) . "&"
See this blog post for more details:
http://got-ravings.blogspot.com/2008/09/vim-pr0n-prototype-based-objects.html
------------------------------------------------------------------------------
4.1. Key map API *NERDTreeKeymapAPI*
NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()*
Adds a new keymapping for all NERD tree buffers.
{options} must be a dictionary, and must contain the following keys:
"key" - the trigger key for the new mapping
"callback" - the function the new mapping will be bound to
"quickhelpText" - the text that will appear in the quickhelp (see
|NERDTree-?|)
Example: >
call NERDTreeAddKeyMap({
\ 'key': 'b',
\ 'callback': 'NERDTreeEchoCurrentNode',
\ 'quickhelpText': 'echo full path of current node' })
function! NERDTreeEchoCurrentNode()
let n = g:NERDTreeFileNode.GetSelected()
if n != {}
echomsg 'Current node: ' . n.path.str()
endif
endfunction
<
This way you can add new mappings or :commands or override any existing
mapping.
This code should sit in a file like ~/.vim/nerdtree_plugin/mymapping.vim.
It adds a (rather useless) mapping on 'b' which echos the full path to the
current node.
------------------------------------------------------------------------------
4.2. Menu API *NERDTreeMenuAPI*
NERDTreeAddSubmenu({options}) *NERDTreeAddSubmenu()*
Creates and returns a new submenu.
{options} must be a dictionary and must contain the following keys:
"text" - the text of the submenu that the user will see
"shortcut" - a shortcut key for the submenu (need not be unique)
The following keys are optional:
"isActiveCallback" - a function that will be called to determine whether
this submenu item will be displayed or not. The callback function must return
0 or 1.
"parent" - the parent submenu of the new submenu (returned from a previous
invocation of NERDTreeAddSubmenu()). If this key is left out then the new
submenu will sit under the top level menu.
See below for an example.
NERDTreeAddMenuItem({options}) *NERDTreeAddMenuItem()*
Adds a new menu item to the NERD tree menu (see |NERDTreeMenu|).
{options} must be a dictionary and must contain the
following keys:
"text" - the text of the menu item which the user will see
"shortcut" - a shortcut key for the menu item (need not be unique)
"callback" - the function that will be called when the user activates the
menu item.
The following keys are optional:
"isActiveCallback" - a function that will be called to determine whether
this menu item will be displayed or not. The callback function must return
0 or 1.
"parent" - if the menu item belongs under a submenu then this key must be
specified. This value for this key will be the object that
was returned when the submenu was created with |NERDTreeAddSubmenu()|.
See below for an example.
NERDTreeAddMenuSeparator([{options}]) *NERDTreeAddMenuSeparator()*
Adds a menu separator (a row of dashes).
{options} is an optional dictionary that may contain the following keys:
"isActiveCallback" - see description in |NERDTreeAddMenuItem()|.
Below is an example of the menu API in action. >
call NERDTreeAddMenuSeparator()
call NERDTreeAddMenuItem({
\ 'text': 'a (t)op level menu item',
\ 'shortcut': 't',
\ 'callback': 'SomeFunction' })
let submenu = NERDTreeAddSubmenu({
\ 'text': 'a (s)ub menu',
\ 'shortcut': 's' })
call NERDTreeAddMenuItem({
\ 'text': '(n)ested item 1',
\ 'shortcut': 'n',
\ 'callback': 'SomeFunction',
\ 'parent': submenu })
call NERDTreeAddMenuItem({
\ 'text': '(n)ested item 2',
\ 'shortcut': 'n',
\ 'callback': 'SomeFunction',
\ 'parent': submenu })
<
This will create the following menu: >
--------------------
a (t)op level menu item
a (s)ub menu
<
Where selecting "a (s)ub menu" will lead to a second menu: >
(n)ested item 1
(n)ested item 2
<
When any of the 3 concrete menu items are selected the function "SomeFunction"
will be called.
------------------------------------------------------------------------------
NERDTreeRender() *NERDTreeRender()*
Re-renders the NERD tree buffer. Useful if you change the state of the
tree and you want to it to be reflected in the UI.
==============================================================================
5. About *NERDTreeAbout*
@ -973,10 +1101,10 @@ mapping.
The author of the NERD tree is a terrible terrible monster called Martyzilla
who gobbles up small children with milk and sugar for breakfast.
He can be reached at martin_grenfell at msn.com. He would love to hear from
you, so feel free to send him suggestions and/or comments about this plugin.
Don't be shy --- the worst he can do is slaughter you and stuff you in the
fridge for later ;)
He can be reached at martin.grenfell at gmail dot com. He would love to hear
from you, so feel free to send him suggestions and/or comments about this
plugin. Don't be shy --- the worst he can do is slaughter you and stuff you in
the fridge for later ;)
The latest stable versions can be found at
http://www.vim.org/scripts/script.php?script_id=1658
@ -988,6 +1116,65 @@ The latest dev versions are on github
==============================================================================
6. Changelog *NERDTreeChangelog*
4.2.0
- Add NERDTreeDirArrows option to make the UI use pretty arrow chars
instead of the old +~| chars to define the tree structure (sickill)
- shift the syntax highlighting out into its own syntax file (gnap)
- add some mac specific options to the filesystem menu - for macvim
only (andersonfreitas)
- Add NERDTreeMinimalUI option to remove some non functional parts of the
nerdtree ui (camthompson)
- tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the
new behaviour (benjamingeiger)
- if no name is given to :Bookmark, make it default to the name of the
target file/dir (minyoung)
- use 'file' completion when doing copying, create, and move
operations (EvanDotPro)
- lots of misc bug fixes (paddyoloughlin, sdewald, camthompson, Vitaly
Bogdanov, AndrewRadev, mathias, scottstvnsn, kml, wycats, me RAWR!)
4.1.0
features:
- NERDTreeFind to reveal the node for the current buffer in the tree,
see |NERDTreeFind|. This effectively merges the FindInNERDTree plugin (by
Doug McInnes) into the script.
- make NERDTreeQuitOnOpen apply to the t/T keymaps too. Thanks to Stefan
Ritter and Rémi Prévost.
- truncate the root node if wider than the tree window. Thanks to Victor
Gonzalez.
bugfixes:
- really fix window state restoring
- fix some win32 path escaping issues. Thanks to Stephan Baumeister, Ricky,
jfilip1024, and Chris Chambers
4.0.0
- add a new programmable menu system (see :help NERDTreeMenu).
- add new APIs to add menus/menu-items to the menu system as well as
custom key mappings to the NERD tree buffer (see :help NERDTreeAPI).
- removed the old API functions
- added a mapping to maximize/restore the size of nerd tree window, thanks
to Guillaume Duranceau for the patch. See :help NERDTree-A for details.
- fix a bug where secondary nerd trees (netrw hijacked trees) and
NERDTreeQuitOnOpen didnt play nicely, thanks to Curtis Harvey.
- fix a bug where the script ignored directories whose name ended in a dot,
thanks to Aggelos Orfanakos for the patch.
- fix a bug when using the x mapping on the tree root, thanks to Bryan
Venteicher for the patch.
- fix a bug where the cursor position/window size of the nerd tree buffer
wasnt being stored on closing the window, thanks to Richard Hart.
- fix a bug where NERDTreeMirror would mirror the wrong tree
3.1.1
- fix a bug where a non-listed no-name buffer was getting created every
time the tree windows was created, thanks to Derek Wyatt and owen1
- make <CR> behave the same as the 'o' mapping
- some helptag fixes in the doc, thanks strull
- fix a bug when using :set nohidden and opening a file where the previous
buf was modified. Thanks iElectric
- other minor fixes
3.1.0
New features:
- add mappings to open files in a vsplit, see :help NERDTree-s and :help
@ -1069,6 +1256,33 @@ just downloaded pr0n instead.
Frederic Chanal (nach)
Alf Mikula
Lucas S. Buchala
Curtis Harvey
Guillaume Duranceau
Richard Hart (hates)
Doug McInnes
Stefan Ritter
Rémi Prévost
Victor Gonzalez
Stephan Baumeister
Ricky
jfilip1024
Chris Chambers
Vitaly Bogdanov
Patrick O'Loughlin (paddyoloughlin)
Cam Thompson (camthompson)
Marcin Kulik (sickill)
Steve DeWald (sdewald)
Ivan Necas (iNecas)
George Ang (gnap)
Evan Coury (EvanDotPro)
Andrew Radev (AndrewRadev)
Matt Gauger (mathias)
Scott Stevenson (scottstvnsn)
Anderson Freitas (andersonfreitas)
Kamil K. Lemański (kml)
Yehuda Katz (wycats)
Min-Young Wu (minyoung)
Benjamin Geiger (benjamingeiger)
==============================================================================
8. License *NERDTreeLicense*

204
vim/doc/cecutil.txt Normal file
View File

@ -0,0 +1,204 @@
*cecutil.txt* DrChip's Utilities Sep 04, 2007
Author: Charles E. Campbell, Jr. <NdrOchip@ScampbellPfamily.AbizM>
(remove NOSPAM from Campbell's email first)
Copyright: (c) 2004-2006 by Charles E. Campbell, Jr. *cecutil-copyright*
The VIM LICENSE applies to cecutil.vim and cecutil.txt
(see |copyright|) except use "cecutil" instead of "Vim"
No warranty, express or implied. Use At-Your-Own-Risk.
==============================================================================
1. Contents *cecutil* *cecutil-contents*
1. Contents.................: |cecutil-contents|
2. Positioning..............: |cecutil-posn|
3. Marks....................: |cecutil-marks|
4. Maps.....................: |cecutil-maps|
5. History..................: |cecutil-history|
==============================================================================
2. Positioning *cecutil-posn* *cecutil-position*
let winposn= SaveWinPosn() *cecutil-savewinposn*
This operation will save window position in winposn variable and
on a (buffer local) b:winposn{} stack.
call SaveWinPosn()
This function will save window position in b:winposn{b:iwinposn}
let winposn= SaveWinPosn(0)
This operation will _only_ save the window position in winposn variable.
Ie. the window position will not appear on the b:winposn{} stack. You
will then need to use RestoreWinPosn(winposn) to restore to this window
position.
call RestoreWinPosn() *cecutil-restorewinposn*
This function call will use the local buffer b:winposn{} stack to
restore the last window position saved therein. It will also
pop the stack.
call RestoreWinPosn(winposn)
This function call will use the winposn variable and restore
the window position accordingly. It will also search the
stack and remove any similar entry from the stack.
*cecutil-map* *cecutil-cmd* *cecutil-swp* *cecutil-rwp*
\swp : save current window position (uses the b:winposn{} stack)
:SWP like \swp, but provided as a command
\rwp : restore window position (uses the b:winposn{} stack)
:RWP like \rwp, but provided as a command
==============================================================================
3. Marks *cecutil-marks*
call SaveMark(markname) *cecutil-savemark*
let savemark= SaveMark(markname)
SM markname >
ex. call SaveMark("a")
let savemarkb= SaveMark("b")
:SM a
<
This function saves a string in the global variable g:savemark_{markname}
which contains sufficient information to completely restore the position
of a mark. It also returns that string.
call RestoreMark(markname) *cecutil-restoremark*
call RestoreMark(savemark)
This function either takes a single-character string (ex. "a") and uses
g:savemark_{markname} to restore the mark position or assumes that
the string passed to it is a SaveMark() string (and uses it to restore
the mark). >
ex. call RestoreMark("a")
call RestoreMark(savemarkb)
:RM a
<
call DestroyMark(markname) *cecutil-destroymark*
The DestroyMark() function completely removes a mark. It does this
by saving the window position, copying line one, putting the
to-be-destroyed mark on that new line, deleting the new line, and
then restoring the window position. The windows' modified status
is preserved. >
ex. call DestroyMark("a")
:DM a
<
==============================================================================
4.Maps *cecutil-maps*
*cecutil-saveusermaps*
call SaveUserMaps(mapmode,maplead,mapchx,suffix)
This function sets up a script-variable (ie. a variable that can
generally be accessed only from within cecutil's own functions;
see |s:|) called s:restoremap. The selected user's maps are appended
to this variable; the RestoreUserMaps() (|cecutil-restoreusermaps|)
function uses the contents of this variable to restore user maps.
mapmode - see :help maparg for its list (see |maparg()|) >
ex. "n" = Normal
< Will now accept an optional leading "u"; if present,
SaveUserMaps() will save and unmap (otherwise, it
will save only)
mapchx - "<something>" handled as a single map item. >
ex. "<left>"
< - "string" a string of single letters which are actually
multiple two-letter maps
maplead - the maps are assumed to have the form >
maplead . each_character_in_string
< ex. maplead="\" and mapchx="abc" saves mappings for >
\a, \b, and \c
< Of course, if maplead is "", then for mapchx="abc",
mappings for just a, b, and c are saved.
- :something handled as a single map item, w/o the ":" >
ex. mapchx= ":abc"
< will save the user mapping for "abc"
suffix - a string unique to your plugin >
ex. suffix= "DrawIt"
<
Some examples follow: >
call SaveUserMaps("n","","webWEBjklh$0%;,nN","HiMtchBrkt")
< normal mode maps for w, e, b, W, E, B, j, k, l, etc
(if any) are all saved in the variable
s:restoremaps_HiMtchBrkt >
call SaveUserMaps("n","","<up>","DrawIt")
< the normal mode map (if any) for the <up> key is saved in
the variable s:restoremaps_DrawIt >
call SaveUserMaps("n","",":F(","HiMtchBrkt")
< the normal mode map for F( (if any) is saved in the
variable s:restoremaps_HiMtchBrkt
call RestoreUserMaps(suffix)
The usermaps saved by SaveUserMaps() with the given suffix will be
restored (ie. s:restoremaps_{suffix}). Example: >
call RestoreUserMaps("HiMtchBrkt")
< will restore all user maps redefined for the HiMtchBrkt plugin
==============================================================================
5. History *cecutil-history* {{{1
v17 Sep 04, 2007 : * new function, QArgSplitter(), included
v16 Oct 30, 2006 : * com -> com! so AsNeeded is happier
Feb 12, 2007 * fixed a bug where :somemap (a map of "somemap")
did not use the optional mapleader (so it'd be
a map of "\somemap", if "\" is the mapleader).
(problem pointed out by Michael Zhang)
v15 Jan 25, 2006 : * bypass for report option for DestroyMark() included
* SaveWinPosn() and RestoreWinPosn() now handle an
empty buffer
* b:(varname) now use b:cecutil_(varname)
* map restoration improved
v14 Jan 23, 2006 : * bypasses for si, so, and siso options included
Jan 25, 2006 * SaveUserMaps' mapmode argument, heretofore just
a single letter (see |maparg()|), now accepts a
leading "u". If present, SaveUserMaps() will
do an unmap.
v13 Jan 12, 2006 : * SaveUserMaps() was saving user maps but then also
unmap'ing them. HiMtchBrkt needed to append a
function call to maps, not overwrite them. So
the new SaveUserMaps() just saves user maps,
leaving their definitions in place.
Jan 18, 2006 * keepjumps used to avoid jumplist changes when
using SaveWinPosn() and RestoreWinPosn()
v12 Dec 29, 2005 : * bugfix (affected Mines.vim)
v11 Dec 29, 2005 : * two new functions (SaveUserMaps() and
RestoreUserMaps() )
v10 Nov 22, 2005 : * SaveWinPosn bugfix
v9 Jun 02, 2005 : * <q-args> produces a "" argument when there are
no arguments, which caused difficulties. Fixed.
v8 Apr 22, 2005 : * <q-args> used to handle marknames with commands
Thus, :DM a will delete mark a
v7 Mar 10, 2005 : * removed zO from saved window position; caused
problems with ftplugin/currfunc.vim
* doing a SWP and RWP on an empty buffer produced
"empty buffer" messages; now these are ignored
Apr 13, 2005 * command (SWP RWP MP SP etc) now have -bar so
that the "|" can be used to chain such commands
v6 Feb 17, 2005 : * improved SaveMark() and RestoreMark()
v5 Jan 18, 2005 : * s:loaded_winposn changed to g:loaded_cecutil
v4 Oct 25, 2004 : * changed com! to com so that error messages will
be given when there's a command-name conflict
v3 May 19, 2004 : * bugfix: the sequence \swp\rwp wasn't working right
* bugfix: \swp...\rwp was echoing the current
line when the \rwp should've been silent
* improved Dfunc/Decho/Dret debugging
==============================================================================
vim:tw=78:ts=8:ft=help:fdm=marker

View File

@ -3,15 +3,60 @@
The ConqueTerm plugin will turn a Vim buffer into a terminal emulator, allowing
you to run and interact with a shell or shell application inside the buffer.
1. Installation |conque-term-installation|
1. Installation |conque-term-setup|
1.1 Requirements for Unix |conque-term-requirements|
1.2 Requirements for Windows |conque-term-windows|
1.3 Installation |conque-term-installation|
2. Usage |conque-term-usage|
3. Config Options |conque-term-options|
2.1 General Usage |conque-term-gen-usage|
2.2 Special keys |conque-term-special-keys|
2.2.1 Send text to Conque |conque-term-send|
2.2.2 Toggle terminal input mode |conque-term-input-mode|
2.2.3 Sending the <Esc> key press |conque-term-esc|
3. Configuration |conque-term-options|
3.1 General |conque-config-general|
3.1.1 Python version |ConqueTerm_PyVersion|
3.1.2 Fast mode |ConqueTerm_FastMode|
3.1.3 Color support |ConqueTerm_Color|
3.1.4 Session Support |ConqueTerm_SessionSupport|
3.1.5 Keep updating terminal buffer |ConqueTerm_ReadUnfocused|
3.1.6 Insert mode when entering buffer |ConqueTerm_InsertOnEnter|
3.1.7 Close buffer when program exits |ConqueTerm_CloseOnEnd|
3.1.8 Hide start messages |ConqueTerm_StartMessages|
3.1.9 Regex for highlighting your prompt |ConqueTerm_PromptRegex|
3.1.10 Syntax type |ConqueTerm_Syntax|
3.2 Keyboard |conque-config-keyboard|
3.2.1 The <Esc> key |ConqueTerm_EscKey|
3.2.2 Toggle terminal input mode |ConqueTerm_ToggleKey|
3.2.3 Enable <C-w> in insert mode |ConqueTerm_CWInsert|
3.2.4 Execute current file in Conque |ConqueTerm_ExecFileKey|
3.2.5 Send current file contents to Conque|ConqueTerm_SendFileKey|
3.2.6 Send selected text to Conque |ConqueTerm_SendVisKey|
3.2.7 Function Keys |ConqueTerm_SendFunctionKeys|
3.3 Unix |conque-config-unix|
3.3.1 Choose your terminal type |ConqueTerm_TERM|
3.4 Windows |conque-config-windows|
3.4.1 Python executable |ConqueTerm_PyExe|
3.4.2 Windows character code page |ConqueTerm_CodePage|
3.4.3 Terminal color method |ConqueTerm_ColorMode|
4. VimScript API |conque-term-api|
4.1 conque_term#open() |conque-term-open|
4.2 conque_term#subprocess() |conque-term-subprocess|
4.3 conque_term#get_instance() |conque-term-get-instance|
4.4 CONQUE_OBJECT.write() |conque-term-write|
4.5 CONQUE_OBJECT.writeln() |conque-term-writeln|
4.6 CONQUE_OBJECT.read() |conque-term-read|
4.7 CONQUE_OBJECT.set_callback() |conque-term-set-callback|
4.8 CONQUE_OBJECT.close() |conque-term-close|
4.9 Registering functions |conque-term-events|
5. Misc |conque-term-misc|
5.1 Known bugs |conque-term-bugs|
5.2 Contribute |conque-term-contribute|
5.3 Feedback |conque-term-feedback|
==============================================================================
1. Installation *conque-term-installation*
1. Installation *conque-term-setup*
Conque is designed for both Unix and Windows operating systems, however the
requirements are slightly different. Please check section below corresponding
@ -49,7 +94,7 @@ If you are compiling Vim + Python from source on Windows, the requirements
become only Vim 7.3+ and Python 2.7+.
1.3 Installation *conque-term-installation-instructions*
1.3 Installation *conque-term-installation*
Download the latest vimball from http://conque.googlecode.com
@ -66,6 +111,8 @@ installed.
2. Usage *conque-term-usage*
2.1 General Usage *conque-term-gen-usage*
Type :ConqueTerm <command> to launch an application in the current buffer. Eg:
>
:ConqueTerm bash
@ -85,21 +132,30 @@ scroll back through the history. Most all Vim functionality will work, such
as searching, yanking or highlighting text.
2.1 Special keys *conque-term-special-keys*
2.2 Special keys *conque-term-special-keys*
There are several keys which can be configured to have special behavior with
Conque.
Send text to Conque *conque-term-F9*
2.2.1 Send text to Conque *conque-term-send*
If you want to send some text from a file you are editing in another buffer
to be run in Conque, select the desired text visually then press the <F9>
key. If you have multiple Conque buffers, the text will be sent to the most
recently created buffer. Alternatively you can yank the text, switch to your
terminal, then paste it with the normal 'p' key. This feature can be
configured to use a different key with the |ConqueTerm_SendVisKey| option.
Conque gives you three different commands to send text from a different
buffer, probably a source code file, to the Conque terminal buffer. All three
are configurable to use your choice of key combinations.
Toggle terminal input mode *conque-term-F8*
To send a visually selected range of text to an existing terminal buffer,
press the <F9> key.
To send the entire contents of the file you are editing to an existing
terminal buffer, press the <F10> key.
Finally, to execute the current file in a new terminal buffer press the <F11>
key. This will split the screen with a new Conque buffer. The file you are
editing must be executable for this command to work.
See |conque-term-options| for information about configuring these commands.
2.2.2 Toggle terminal input mode *conque-term-input-mode*
If you want to use insert mode to edit the terminal screen, press <F8>. You
will now be able to edit the terminal output freely without your cursor
@ -112,17 +168,22 @@ until you press <F8> again to resume.
You can configure Conque to use a different key with the |ConqueTerm_ToggleKey|
option.
Sending the <Esc> key press *conque-term-Esc*
2.2.3 Sending the <Esc> key press *conque-term-esc*
By default if you press the <Esc> key in a Conque buffer you will leave insert
mode. But what if you want the key press to be sent to your terminal? There
are two options. By default, pressing <Esc> twice will send one <Esc> key
press to the terminal, while pressing it once will leave insert mode.
mode. But what if you want the <Esc> character to be sent to your terminal?
There are two options. By default, pressing <Esc> twice will send one <Esc>
character to the terminal and you will remain in insert mode, while pressing
it once will leave insert mode.
Alternatively you can use the |ConqueTerm_EscKey| option to choose a
different key for leaving insert mode. If a custom key is set, then all <Esc>
key presses will be sent to the terminal.
2.3 Registering functions *conque-term-register*
Conque allows you to write your own VimScript functions which will be called
at certain events. See the API section |conque-term-events| for more.
==============================================================================
@ -130,8 +191,75 @@ key presses will be sent to the terminal.
You can set the following options in your .vimrc (default values shown)
3.1 General *conque-config-general*
3.1 Insert mode when entering buffer *ConqueTerm_InsertOnEnter*
3.1.1 Python version *ConqueTerm_PyVersion*
Conque will work with either Python 2.x or 3.x, assuming the interfaces have
been installed. By default it will try to use Python 2 first, then will try
Python 3. If you want Conque to use Python 3, set this variable to 3.
Note: even if you set this to 3, if you don't have the python3 interface
Conque will fall back to using Python 2.
>
let g:ConqueTerm_PyVersion = 2
<
3.1.2 Fast Mode *ConqueTerm_FastMode*
Disable features which could make Conque run slowly. This includes most
terminal colors and some unicode support. Set this to 1 to enable fast mode.
>
let g:ConqueTerm_FastMode = 0
<
3.1.3 Color support *ConqueTerm_Color*
Terminal colors have the potential to slow down terminal screen rendering,
depending on how many colors are used and how fast the computer is. This
option allows you to choose how much color support will be enabled.
If set to 0, terminal colors will be disabled. This will allow the terminal to
render most quickly. Syntax highlighting will still work. For example
highlighting quoted strings or MySQL output.
If set to 1, terminal colors will be enabled, but only for the most recent 200
lines of terminal output. Older output will be periodically stripped of color
highlighting to keep the display responsive.
If set to 2, terminal colors will always be enabled. If your programs don't
use color output very frequently this is a good choice.
Note: Color support is automatically disabled in "fast mode".
>
let g:ConqueTerm_Color = 1
<
3.1.4 Session Support *ConqueTerm_SessionSupport*
Vim's :mksession command allows you to save your current buffer configuration
to a file, which can be loaded at a later time after you've closed Vim.
By default, Conque buffers are not restored. This is mostly for safety
reasons; you may not want Vim to automatically re-run a destructive command.
However, if you're not working with missile launch code, and want Vim to
restart your Conque buffers when you load a session file, set this variable
to 1. Note your original subprocess and shell output will not be restored, but
the same command will be started in your buffer.
>
let g:ConqueTerm_SessionSupport = 0
<
3.1.5 Keep updating terminal buffer *ConqueTerm_ReadUnfocused*
If set to 1 then your Conque buffers will continue to update after you've
switched to another buffer.
Note: Conque buffers may continue to update, but they will not scroll down as
new lines are added beyond the bottom of the visible buffer area. This is a
limitation of the Vim scripting language for which I haven't found a
workaround.
>
let g:ConqueTerm_ReadUnfocused = 1
<
3.1.6 Insert mode when entering buffer *ConqueTerm_InsertOnEnter*
If set to 1 then you will automatically go into insert mode when you enter the
buffer. This diverges from normal Vim behavior. If 0 you will still be in
@ -139,17 +267,41 @@ normal mode.
>
let g:ConqueTerm_InsertOnEnter = 0
<
3.2 Enable <C-w> in insert mode *ConqueTerm_CWInsert*
3.1.7 Close buffer when program exits *ConqueTerm_CloseOnEnd*
If set to 1 then you can leave the Conque buffer using the <C-w> commands
while you're still in insert mode. If set to 0 then the <C-w> character will
be sent to the terminal. If both this option and ConqueTerm_InsertOnEnter are
set you can go in and out of the terminal buffer while never leaving insert
mode.
If you want your terminal buffer to be closed and permanently deleted when the
program running inside of it exits, set this option to 1. Otherwise the buffer
will become a simple text buffer after the program exits, and you can edit the
program output in insert mode.
>
let g:ConqueTerm_CWInsert = 0
let g:ConqueTerm_CloseOnEnd = 0
<
3.3 Use a custom key for leaving insert mode *ConqueTerm_EscKey*
3.1.8 Show start messages *ConqueTerm_StartMessages*
Display warning messages when starting up ConqueTerm if your system is
configured incorrectly.
>
let g:ConqueTerm_StartMessages = 1
<
3.1.9 Regex for highlighting your prompt *ConqueTerm_PromptRegex*
Use this regular expression for sytax highlighting your terminal prompt. Your
terminal will generally run faster if you use Vim highlighting instead of
terminal colors for your prompt. You can also use it to do more advanced
syntax highlighting for the prompt line.
>
let g:ConqueTerm_PromptRegex = '^\w\+@[0-9A-Za-z_.-]\+:[0-9A-Za-z_./\~,:-]\+\$'
<
3.1.10 Choose Vim syntax type *ConqueTerm_Syntax*
Set the buffer syntax. The default 'conque' has highlighting for MySQL, but
not much else.
>
let g:ConqueTerm_Syntax = 'conque'
<
3.2 Keyboard *conque-config-keyboard*
3.2.1 The <Esc> key *ConqueTerm_EscKey*
If a custom key is set, then all <Esc> key presses will be sent to the
terminal and you must use this custom key to leave insert mode. If left to the
@ -162,14 +314,7 @@ Picking a control key, such as <C-k> will be your best bet.
>
let g:ConqueTerm_EscKey = '<Esc>'
<
3.4 Send selected text to Conque *ConqueTerm_SendVisKey*
Use this key to send the currently selected text to the most recently created
Conque buffer.
>
let g:ConqueTerm_SendVisKey = '<F9>'
<
3.5 Toggle terminal input mode *ConqueTerm_ToggleKey*
3.2.2 Toggle terminal input mode *ConqueTerm_ToggleKey*
Press this key to pause terminal input and output display. You will then be
able to edit the terminal screen as if it were a normal text buffer. Press
@ -177,15 +322,52 @@ this key again to resume terminal mode.
>
let g:ConqueTerm_ToggleKey = '<F8>'
<
3.6 Enable or disable colors *ConqueTerm_Color*
3.2.3 Enable <C-w> in insert mode *ConqueTerm_CWInsert*
Set to 1 to enable colors, 0 to disable. Syntax highlighting in Vim can be
slow if your terminal is color intensive. Disabling color can make the
terminal render significantly faster.
If set to 1 then you can leave the Conque buffer using the <C-w> commands
while you're still in insert mode. If set to 0 then the <C-w> character will
be sent to the terminal. If both this option and ConqueTerm_InsertOnEnter are
set you can go in and out of the terminal buffer while never leaving insert
mode.
>
let g:ConqueTerm_Color = 1
let g:ConqueTerm_CWInsert = 0
<
3.7 Choose your terminal type, Unix ONLY *ConqueTerm_TERM*
3.2.4 Execute current file in Conque *ConqueTerm_ExecFileKey*
Press this key to execute the file you're currently editing in a Conque
buffer. Is equivelent to running the command :ConqueTermSplit YOUR_FILE. Your
file must be executable for this command to work correctly.
>
let g:ConqueTerm_ExecFileKey = '<F11>'
<
3.2.5 Send current file contents to Conque *ConqueTerm_SendFileKey*
Press this key to send your entire file contents to the most recently opened
Conque buffer as keyboard input.
>
let g:ConqueTerm_SendFileKey = '<F10>'
<
3.2.6 Send selected text to Conque *ConqueTerm_SendVisKey*
Use this key to send the currently selected text to the most recently created
Conque buffer.
>
let g:ConqueTerm_SendVisKey = '<F9>'
<
3.2.7 Function Keys *ConqueTerm_SendFunctionKeys*
By default, function keys (the F1-F12 row at the top of your keyboard) are not
passed to the terminal. Set this option to 1 to send these key events.
Note: Unless you configured |ConqueTerm_SendVisKey| and |ConqueTerm_ToggleKey|
to use different keys, <F8> and <F9> will not be sent to the terminal even if
you set this option to 1.
>
let g:ConqueTerm_SendFunctionKeys = 0
<
3.3 Unix *conque-config-unix*
3.3.1 Choose your terminal type, Unix ONLY *ConqueTerm_TERM*
Use this option to tell Conque what type of terminal it should identify itself
as. Conque officially uses the more limited VT100 terminal type for
@ -197,55 +379,9 @@ results may vary depending on which programs you're running.
>
let g:ConqueTerm_TERM = 'vt100'
<
3.8 Choose Vim syntax type *ConqueTerm_Syntax*
3.4 Windows *conque-config-windows*
Set the buffer syntax. The default 'conque' has highlighting for MySQL, but
not much else.
>
let g:ConqueTerm_Syntax = 'conque'
<
3.9 Keep updating terminal buffer *ConqueTerm_ReadUnfocused*
If set to 1 then your Conque buffers will continue to update after you've
switched to another buffer.
Note: Conque buffers may continue to update, but they will not scroll down as
new lines are added beyond the bottom of the visible buffer area. This is a
limitation of the Vim scripting language for which I haven't found a
workaround.
>
let g:ConqueTerm_ReadUnfocused = 1
<
3.10 Regex for highlighting your prompt *ConqueTerm_PromptRegex*
Use this regular expression for sytax highlighting your terminal prompt. Your
terminal will generally run faster if you use Vim highlighting instead of
terminal colors for your prompt. You can also use it to do more advanced
syntax highlighting for the prompt line.
>
let g:ConqueTerm_PromptRegex = '^\w\+@[0-9A-Za-z_.-]\+:[0-9A-Za-z_./\~,:-]\+\$'
<
3.11 Close buffer when program exits *ConqueTerm_CloseOnEnd*
If you want your terminal buffer to be closed and permanently deleted when the
program running inside of it exits, set this option to 1. Otherwise the buffer
will become a simple text buffer after the program exits, and you can edit the
program output in insert mode.
>
let g:ConqueTerm_CloseOnEnd = 0
<
3.12 Python version *ConqueTerm_PyVersion*
Conque will work with either Python 2.x or 3.x, assuming the interfaces have
been installed. By default it will try to use Python 2 first, then will try
Python 3. If you want Conque to use Python 3, set this variable to 3.
Note: even if you set this to 3, if you don't have the python3 interface
Conque will fall back to using Python 2.
>
let g:ConqueTerm_PyVersion = 2
<
3.13 Python executable, Windows ONLY *ConqueTerm_PyExe*
3.4.1 Python executable, Windows ONLY *ConqueTerm_PyExe*
The Windows version of Conque needs to know the path to the python.exe
executable for the version of Python Conque is using. If you installed Python
@ -256,18 +392,27 @@ For example, you might set this to 'C:\Program Files\Python27\python.exe'
>
let g:ConqueTerm_PyExe = ''
<
3.14 Function Keys *ConqueTerm_SendFunctionKeys*
3.4.2 Windows character code page *ConqueTerm_CodePage*
By default, function keys (the F1-F12 row at the top of your keyboard) are not
passed to the terminal. Set this option to 1 to send these key events.
Set the "code page" Windows will use for your console. Leave this value set to
zero to use the environment code page.
Note: Unless you configured |ConqueTerm_SendVisKey| and |ConqueTerm_ToggleKey|
to use different keys, <F8> and <F9> will not be sent to the terminal even if
you set this option to 1.
Note: Displaying unicode characters on Conque for Windows needs work.
>
let g:ConqueTerm_SendFunctionKeys = 0
let g:ConqueTerm_CodePage = 0
<
3.4.3 Terminal color method, Windows ONLY *ConqueTerm_ColorMode*
Vim syntax highlighting by coordinate (e.g. the 3-7th characters on the 42nd
line) can be very slow. If you set this variable to 'conceal', you can use
the new conceal feature to render terminal colors. Requires Vim 7.3 and only
works on the Windows version of Conque. This will make colors render faster,
however it will also add hidden characters to the screen, which may be
annoying if you're copying and pasting terminal output out of the Conque
buffer. Set this to an empty string '' to disable concealed highlighting.
>
let g:ConqueTerm_ColorMode = 'conceal'
<
==============================================================================
4. VimScript API (Beta) *conque-term-api*
@ -329,7 +474,7 @@ Example:
>
nnoremap <F4> :call conque_term#get_instance().writeln('clear')<CR>
<
4.4 CONQUE_OBJECT.write(text) *conque-term-write*
4.4 CONQUE_OBJECT.write({text}) *conque-term-write*
Once you have a terminal object from open(), subprocess() or get_instance()
you can send text input to it with the write() method.
@ -341,7 +486,7 @@ Examples:
call my_terminal.write("whoami\n")
call my_terminal.write("\<C-c>")
<
4.5 CONQUE_OBJECT.writeln(text) *conque-term-writeln*
4.5 CONQUE_OBJECT.writeln({text}) *conque-term-writeln*
The same as write() except adds a \n character to the end if your input.
@ -418,6 +563,45 @@ Example:
call term.read(5000)
call term.close()
<
4.9 Registering functions *conque-term-events*
Conque provides the option to register callback functions which will be
executed at several different events. The currently available events are:
after_startup After your application has loaded into the buffer.
buffer_enter When you switch to a Conque buffer.
buffer_leave When you leave a Conque buffer.
You may use the function conque_term#register_function(event, function_name)
to add additional hooks at a particular event. The second argument should be
the name of a callback function which has one parameter, the current
terminal object (see|conque-term-api|for more about terminal objects).
For example:
>
function MyConqueStartup(term)
" set buffer syntax using the name of the program currently running
let syntax_associations = { 'ipython': 'python', 'irb': 'ruby' }
if has_key(syntax_associations, a:term.program_name)
execute 'setlocal syntax=' . syntax_associations[a:term.program_name]
else
execute 'setlocal syntax=' . a:term.program_name
endif
" shrink window height to 10 rows
resize 10
" silly example of terminal api usage
if a:term.program_name == 'bash'
call a:term.writeln('svn up ~/projects/*')
endif
endfunction
call conque_term#register_function('after_startup', 'MyConqueStartup')
<
==============================================================================

461
vim/doc/pi_getscript.txt Normal file
View File

@ -0,0 +1,461 @@
*pi_getscript.txt* For Vim version 7.0. Last change: 2011 May 31
>
GETSCRIPT REFERENCE MANUAL by Charles E. Campbell, Jr.
<
Authors: Charles E. Campbell, Jr. <NdrOchip@ScampbellPfamilyA.Mbiz>
(remove NOSPAM from the email address)
*GetLatestVimScripts-copyright*
Copyright: (c) 2004-2010 by Charles E. Campbell, Jr. *glvs-copyright*
The VIM LICENSE applies to getscript.vim and
pi_getscript.txt (see |copyright|) except use
"getscript" instead of "Vim". No warranty, express or implied.
Use At-Your-Own-Risk.
Getscript is a plugin that simplifies retrieval of the latest versions of the
scripts that you yourself use! Typing |:GLVS| will invoke getscript; it will
then use the <GetLatestVimScripts.dat> (see |GetLatestVimScripts_dat|) file to
get the latest versions of scripts listed therein from http://vim.sf.net/.
==============================================================================
1. Contents *glvs-contents* *glvs* *getscript*
*GetLatestVimScripts*
1. Contents........................................: |glvs-contents|
2. GetLatestVimScripts -- Getting Started..........: |glvs-install|
3. GetLatestVimScripts Usage.......................: |glvs-usage|
4. GetLatestVimScripts Data File...................: |glvs-data|
5. GetLatestVimScripts Friendly Plugins............: |glvs-plugins|
6. GetLatestVimScripts AutoInstall.................: |glvs-autoinstall|
7. GetLatestViMScripts Options.....................: |glvs-options|
8. GetLatestVimScripts Algorithm...................: |glvs-alg|
9. GetLatestVimScripts History.....................: |glvs-hist|
==============================================================================
2. GetLatestVimScripts -- Getting Started *getscript-start*
*getlatestvimscripts-install*
VERSION FROM VIM DISTRIBUTION *glvs-dist-install*
Vim 7.0 does not include the GetLatestVimScripts.dist file which
serves as an example and a template. So, you'll need to create
your own! See |GetLatestVimScripts_dat|.
VERSION FROM VIM SF NET *glvs-install*
NOTE: The last step, that of renaming/moving the GetLatestVimScripts.dist
file, is for those who have just downloaded GetLatestVimScripts.tar.bz2 for
the first time.
The GetLatestVimScripts.dist file serves as an example and a template for your
own personal list. Feel free to remove all the scripts mentioned within it;
the "important" part of it is the first two lines.
Your computer needs to have wget or curl for GetLatestVimScripts to do its work.
1. if compressed: gunzip getscript.vba.gz
2. Unix:
vim getscript.vba
:so %
:q
cd ~/.vim/GetLatest
mv GetLatestVimScripts.dist GetLatestVimScripts.dat
(edit GetLatestVimScripts.dat to install your own personal
list of desired plugins -- see |GetLatestVimScripts_dat|)
3. Windows:
vim getscript.vba
:so %
:q
cd **path-to-vimfiles**/GetLatest
mv GetLatestVimScripts.dist GetLatestVimScripts.dat
(edit GetLatestVimScripts.dat to install your own personal
list of desired plugins -- see |GetLatestVimScripts_dat|)
==============================================================================
3. GetLatestVimScripts Usage *glvs-usage* *:GLVS*
Unless it has been defined elsewhere, >
:GLVS
will invoke GetLatestVimScripts(). If some other plugin has defined that
command, then you may type
>
:GetLatestVimScripts
<
The script will attempt to update and, if permitted, will automatically
install scripts from http://vim.sourceforge.net/. To do so it will peruse a
file,
>
.vim/GetLatest/GetLatestVimScripts.dat (unix)
<
or >
..wherever..\vimfiles\GetLatest\GetLatestVimScripts.dat (windows)
(see |glvs-data|), and examine plugins in your [.vim|vimfiles]/plugin
directory (see |glvs-plugins|).
Scripts which have been downloaded will appear in the
~/.vim/GetLatest (unix) or ..wherever..\vimfiles\GetLatest (windows)
subdirectory. GetLatestVimScripts will attempt to automatically
install them if you have the following line in your <.vimrc>: >
let g:GetLatestVimScripts_allowautoinstall=1
The <GetLatestVimScripts.dat> file will be automatically be updated to
reflect the latest version of script(s) so downloaded.
(also see |glvs-options|)
==============================================================================
4. GetLatestVimScripts Data File *getscript-data* *glvs-data*
*:GetLatestVimScripts_dat*
The data file <GetLatestVimScripts.dat> must have for its first two lines
the following text:
>
ScriptID SourceID Filename
--------------------------
<
Following those two lines are three columns; the first two are numeric
followed by a text column. The GetLatest/GetLatestVimScripts.dist file
contains an example of such a data file. Anything following a #... is
ignored, so you may embed comments in the file.
The first number on each line gives the script's ScriptID. When you're about
to use a web browser to look at scripts on http://vim.sf.net/, just before you
click on the script's link, you'll see a line resembling
http://vim.sourceforge.net/scripts/script.php?script_id=40
The "40" happens to be a ScriptID that GetLatestVimScripts needs to
download the associated page, and is assigned by vim.sf.net itself
during initial uploading of the plugin.
The second number on each line gives the script's SourceID. The SourceID
records the count of uploaded scripts as determined by vim.sf.net; hence it
serves to indicate "when" a script was uploaded. Setting the SourceID to 1
insures that GetLatestVimScripts will assume that the script it has is
out-of-date.
The SourceID is extracted by GetLatestVimScripts from the script's page on
vim.sf.net; whenever it is greater than the one stored in the
GetLatestVimScripts.dat file, the script will be downloaded
(see |GetLatestVimScripts_dat|).
If your script's author has included a special comment line in his/her plugin,
the plugin itself will be used by GetLatestVimScripts to build your
<GetLatestVimScripts.dat> file, including any dependencies on other scripts it
may have. As an example, consider: >
" GetLatestVimScripts: 884 1 :AutoInstall: AutoAlign.vim
This comment line tells getscript.vim to check vimscript #884 and that the
script is automatically installable. Getscript will also use this line to
help build the GetLatestVimScripts.dat file, by including a line such as: >
884 1 :AutoInstall: AutoAlign.vim
<
assuming that such a line isn't already in GetLatestVimScripts.dat file.
See |glvs-plugins| for more. Thus, GetLatestVimScripts thus provides a
comprehensive ability to keep your plugins up-to-date!
In summary:
* Optionally tell getscript that it is allowed to build/append a
GetLatestVimScripts.dat file based upon already installed plugins: >
let g:GetLatestVimScripts_allowautoinstall=1
<
* A line such as >
" GetLatestVimScripts: 884 1 :AutoInstall: AutoAlign.vim
< in an already-downloaded plugin constitutes the concurrence of the
plugin author that getscript may do AutoInstall. Not all plugins
may be AutoInstall-able, and the plugin's author is best situated
to know whether or not his/her plugin will AutoInstall properly.
* A line such as >
884 1 :AutoInstall: AutoAlign.vim
< in your GetLatestVimScripts.dat file constitutes your permission
to getscript to do AutoInstall. AutoInstall requires both your
and the plugin author's permission. See |GetLatestVimScripts_dat|.
*GetLatestVimScripts_dat*
As an example of a <GetLatestVimScripts.dat> file:
>
ScriptID SourceID Filename
--------------------------
294 1 :AutoInstall: Align.vim
120 2 Decho.vim
40 3 DrawIt.tar.gz
451 4 EasyAccents.vim
195 5 engspchk.vim
642 6 GetLatestVimScripts.vim
489 7 Manpageview.vim
<
Note: the first two lines are required, but essentially act as comments.
==============================================================================
5. GetLatestVimScripts Friendly Plugins *getscript-plugins* *glvs-plugins*
(this section is for plugin authors)~
If a plugin author includes the following comment anywhere in their plugin,
GetLatestVimScripts will find it and use it to automatically build the user's
GetLatestVimScripts.dat files:
>
src_id
v
" GetLatestVimScripts: ### ### yourscriptname
^
scriptid
<
As an author, you should include such a line in to refer to your own script
plus any additional lines describing any plugin dependencies it may have.
Same format, of course!
If your command is auto-installable (see |glvs-autoinstall|), and most scripts
are, then you may include :AutoInstall: just before "yourscriptname":
>
src_id
v
" GetLatestVimScripts: ### ### :AutoInstall: yourscriptname
^
scriptid
<
NOTE: The :AutoInstall: feature requires both the plugin author's and~
the user's permission to operate!~
GetLatestVimScripts commands for those scripts are then appended, if not
already present, to the user's GetLatest/GetLatestVimScripts.dat file. It is
a relatively painless way to automate the acquisition of any scripts your
plugins depend upon.
Now, as an author, you probably don't want GetLatestVimScripts to download
your own scripts atop your own copy, thereby overwriting your not-yet-released
hard work. GetLatestVimScripts provides a solution for this: put
>
0 0 yourscriptname
<
into your <GetLatestVimScripts.dat> file and GetLatestVimScripts will skip
examining the "yourscriptname" scripts for those GetLatestVimScripts comment
lines. As a result, those lines won't be inadvertently installed into your
<GetLatestVimScripts.dat> file and subsequently used to download your own
scripts. This is especially important to do if you've included the
:AutoInstall: option.
Be certain to use the same "yourscriptname" in the "0 0 yourscriptname" line
as you've used in your GetLatestVimScripts comment!
==============================================================================
6. GetLatestVimScripts AutoInstall *getscript-autoinstall*
*glvs-autoinstall*
GetLatestVimScripts now supports "AutoInstall". Not all scripts are
supportive of auto-install, as they may have special things you need to do to
install them (please refer to the script's "install" directions). On the
other hand, most scripts will be auto-installable.
To let GetLatestVimScripts do an autoinstall, the data file's comment field
should begin with (surrounding blanks are ignored): >
:AutoInstall:
<
Both colons are needed, and it should begin the comment (yourscriptname)
field.
One may prevent any autoinstalling by putting the following line in your
<.vimrc>: >
let g:GetLatestVimScripts_allowautoinstall= 0
<
With :AutoInstall: enabled, as it is by default, files which end with
---.tar.bz2 : decompressed & untarred in .vim/ directory
---.vba.bz2 : decompressed in .vim/ directory, then vimball handles it
---.vim.bz2 : decompressed & moved into .vim/plugin directory
---.tar.gz : decompressed & untarred in .vim/ directory
---.vba.gz : decompressed in .vim/ directory, then vimball handles it
---.vim.gz : decompressed & moved into .vim/plugin directory
---.vba : unzipped in .vim/ directory
---.vim : moved to .vim/plugin directory
---.zip : unzipped in .vim/ directory
and which merely need to have their components placed by the untar/gunzip or
move-to-plugin-directory process should be auto-installable. Vimballs, of
course, should always be auto-installable.
When is a script not auto-installable? Let me give an example:
.vim/after/syntax/blockhl.vim
The <blockhl.vim> script provides block highlighting for C/C++ programs; it is
available at:
http://vim.sourceforge.net/scripts/script.php?script_id=104
Currently, vim's after/syntax only supports by-filetype scripts (in
blockhl.vim's case, that's after/syntax/c.vim). Hence, auto-install would
possibly overwrite the current user's after/syntax/c.vim file.
In my own case, I use <aftersyntax.vim> (renamed to after/syntax/c.vim) to
allow a after/syntax/c/ directory:
http://vim.sourceforge.net/scripts/script.php?script_id=1023
The script allows multiple syntax files to exist separately in the
after/syntax/c subdirectory. I can't bundle aftersyntax.vim in and build an
appropriate tarball for auto-install because of the potential for the
after/syntax/c.vim contained in it to overwrite a user's c.vim.
==============================================================================
7. GetLatestVimScripts Options *glvs-options*
>
g:GetLatestVimScripts_wget
< default= "wget"
This variable holds the name of the command for obtaining
scripts.
>
g:GetLatestVimScripts_options
< default= "-q -O"
This variable holds the options to be used with the
g:GetLatestVimScripts_wget command.
>
g:GetLatestVimScripts_allowautoinstall
< default= 1
This variable indicates whether GetLatestVimScripts is allowed
to attempt to automatically install scripts. Furthermore, the
plugin author has to have explicitly indicated that his/her
plugin is automatically installable (via the :AutoInstall:
keyword in the GetLatestVimScripts comment line).
>
g:GetLatestVimScripts_autoinstalldir
< default= $HOME/.vim (linux)
default= $HOME/vimfiles (windows)
Override where :AutoInstall: scripts will be installed.
Doesn't override vimball installation.
==============================================================================
8. GetLatestVimScripts Algorithm *glvs-algorithm* *glvs-alg*
The Vim sourceforge page dynamically creates a page by keying off of the
so-called script-id. Within the webpage of
http://vim.sourceforge.net/scripts/script.php?script_id=40
is a line specifying the latest source-id (src_id). The source identifier
numbers are always increasing, hence if the src_id is greater than the one
recorded for the script in GetLatestVimScripts then it's time to download a
newer copy of that script.
GetLatestVimScripts will then download the script and update its internal
database of script ids, source ids, and scriptnames.
The AutoInstall process will:
Move the file from GetLatest/ to the following directory
Unix : $HOME/.vim
Windows: $HOME\vimfiles
if the downloaded file ends with ".bz2"
bunzip2 it
else if the downloaded file ends with ".gz"
gunzip it
if the resulting file ends with ".zip"
unzip it
else if the resulting file ends with ".tar"
tar -oxvf it
else if the resulting file ends with ".vim"
move it to the plugin subdirectory
==============================================================================
9. GetLatestVimScripts History *getscript-history* *glvs-hist* {{{1
v33 May 31, 2011 : * using fnameescape() instead of escape()
* *.xz support
v32 Jun 19, 2010 : * (Jan Steffens) added support for xz compression
v31 Jun 29, 2008 : * (Bill McCarthy) fixed having hls enabled with getscript
* (David Schaefer) the acd option interferes with vimballs
Solution: bypass the acd option
v30 Jun 13, 2008 : * GLVS now checks for existence of fnameescape() and will
issue an error message if it is not supported
v29 Jan 07, 2008 : * Bram M pointed out that cpo is a global option and that
getscriptPlugin.vim was setting it but not restoring it.
v28 Jan 02, 2008 : * improved shell quoting character handling, cygwin
interface, register-a bypass
Oct 29, 2007 * Bill McCarthy suggested a change to getscript that avoids
creating pop-up windows
v24 Apr 16, 2007 : * removed save&restore of the fo option during script
loading
v23 Nov 03, 2006 : * ignores comments (#...)
* handles vimballs
v22 Oct 13, 2006 : * supports automatic use of curl if wget is not
available
v21 May 01, 2006 : * now takes advantage of autoloading.
v20 Dec 23, 2005 : * Eric Haarbauer found&fixed a bug with unzip use;
unzip needs the -o flag to overwrite.
v19 Nov 28, 2005 : * v18's GetLatestVimScript line accessed the wrong
script! Fixed.
v18 Mar 21, 2005 : * bugfix to automatic database construction
* bugfix - nowrapscan caused an error
(tnx to David Green for the fix)
Apr 01, 2005 * if shell is bash, "mv" instead of "ren" used in
:AutoInstall:s, even though its o/s is windows
Apr 01, 2005 * when downloading errors occurred, GLVS was
terminating early. It now just goes on to trying
the next script (after trying three times to
download a script description page)
Apr 20, 2005 * bugfix - when a failure to download occurred,
GetLatestVimScripts would stop early and claim that
everything was current. Fixed.
v17 Aug 25, 2004 : * g:GetLatestVimScripts_allowautoinstall, which
defaults to 1, can be used to prevent all
:AutoInstall:
v16 Aug 25, 2004 : * made execution of bunzip2/gunzip/tar/zip silent
* fixed bug with :AutoInstall: use of helptags
v15 Aug 24, 2004 : * bugfix: the "0 0 comment" download prevention wasn't
always preventing downloads (just usually). Fixed.
v14 Aug 24, 2004 : * bugfix -- helptags was using dotvim, rather than
s:dotvim. Fixed.
v13 Aug 23, 2004 : * will skip downloading a file if its scriptid or srcid
is zero. Useful for script authors; that way their
own GetLatestVimScripts activity won't overwrite
their scripts.
v12 Aug 23, 2004 : * bugfix - a "return" got left in the distribution that
was intended only for testing. Removed, now works.
* :AutoInstall: implemented
v11 Aug 20, 2004 : * GetLatestVimScripts is now a plugin:
* :GetLatestVimScripts command
* (runtimepath)/GetLatest/GetLatestVimScripts.dat
now holds scripts that need updating
v10 Apr 19, 2004 : * moved history from script to doc
v9 Jan 23, 2004 : windows (win32/win16/win95) will use
double quotes ("") whereas other systems will use
single quotes ('') around the urls in calls via wget
v8 Dec 01, 2003 : makes three tries at downloading
v7 Sep 02, 2003 : added error messages if "Click on..." or "src_id="
not found in downloaded webpage
Uses t_ti, t_te, and rs to make progress visible
v6 Aug 06, 2003 : final status messages now display summary of work
( "Downloaded someqty scripts" or
"Everything was current")
Now GetLatestVimScripts is careful about downloading
GetLatestVimScripts.vim itself!
(goes to <NEW_GetLatestVimScripts.vim>)
v5 Aug 04, 2003 : missing an endif near bottom
v4 Jun 17, 2003 : redraw! just before each "considering" message
v3 May 27, 2003 : Protects downloaded files from errant shell
expansions with single quotes: '...'
v2 May 14, 2003 : extracts name of item to be obtained from the
script file. Uses it instead of comment field
for output filename; comment is used in the
"considering..." line and is now just a comment!
* Fixed a bug: a string-of-numbers is not the
same as a number, so I added zero to them
and they became numbers. Fixes comparison.
==============================================================================
vim:tw=78:ts=8:ft=help:fdm=marker

View File

@ -16,9 +16,11 @@
'NERDTreeBookmarksFile' NERD_tree.txt /*'NERDTreeBookmarksFile'*
'NERDTreeCaseSensitiveSort' NERD_tree.txt /*'NERDTreeCaseSensitiveSort'*
'NERDTreeChDirMode' NERD_tree.txt /*'NERDTreeChDirMode'*
'NERDTreeDirArrows' NERD_tree.txt /*'NERDTreeDirArrows'*
'NERDTreeHighlightCursorline' NERD_tree.txt /*'NERDTreeHighlightCursorline'*
'NERDTreeHijackNetrw' NERD_tree.txt /*'NERDTreeHijackNetrw'*
'NERDTreeIgnore' NERD_tree.txt /*'NERDTreeIgnore'*
'NERDTreeMinimalUI' NERD_tree.txt /*'NERDTreeMinimalUI'*
'NERDTreeMouseMode' NERD_tree.txt /*'NERDTreeMouseMode'*
'NERDTreeQuitOnOpen' NERD_tree.txt /*'NERDTreeQuitOnOpen'*
'NERDTreeShowBookmarks' NERD_tree.txt /*'NERDTreeShowBookmarks'*
@ -60,6 +62,7 @@
:AlignCenter textformat.txt /*:AlignCenter*
:AlignJustify textformat.txt /*:AlignJustify*
:AlignLeft textformat.txt /*:AlignLeft*
:AlignMapsClean Align.txt /*:AlignMapsClean*
:AlignRight textformat.txt /*:AlignRight*
:CVSEdit vcscommand.txt /*:CVSEdit*
:CVSEditors vcscommand.txt /*:CVSEditors*
@ -70,8 +73,11 @@
:CVSWatchOn vcscommand.txt /*:CVSWatchOn*
:CVSWatchRemove vcscommand.txt /*:CVSWatchRemove*
:CVSWatchers vcscommand.txt /*:CVSWatchers*
:GLVS pi_getscript.txt /*:GLVS*
:GetLatestVimScripts_dat pi_getscript.txt /*:GetLatestVimScripts_dat*
:NERDTree NERD_tree.txt /*:NERDTree*
:NERDTreeClose NERD_tree.txt /*:NERDTreeClose*
:NERDTreeFind NERD_tree.txt /*:NERDTreeFind*
:NERDTreeFromBookmark NERD_tree.txt /*:NERDTreeFromBookmark*
:NERDTreeMirror NERD_tree.txt /*:NERDTreeMirror*
:NERDTreeToggle NERD_tree.txt /*:NERDTreeToggle*
@ -152,18 +158,28 @@ Align-copyright Align.txt /*Align-copyright*
ConqueTerm conque_term.txt /*ConqueTerm*
ConqueTerm_CWInsert conque_term.txt /*ConqueTerm_CWInsert*
ConqueTerm_CloseOnEnd conque_term.txt /*ConqueTerm_CloseOnEnd*
ConqueTerm_CodePage conque_term.txt /*ConqueTerm_CodePage*
ConqueTerm_Color conque_term.txt /*ConqueTerm_Color*
ConqueTerm_ColorMode conque_term.txt /*ConqueTerm_ColorMode*
ConqueTerm_EscKey conque_term.txt /*ConqueTerm_EscKey*
ConqueTerm_ExecFileKey conque_term.txt /*ConqueTerm_ExecFileKey*
ConqueTerm_FastMode conque_term.txt /*ConqueTerm_FastMode*
ConqueTerm_InsertOnEnter conque_term.txt /*ConqueTerm_InsertOnEnter*
ConqueTerm_PromptRegex conque_term.txt /*ConqueTerm_PromptRegex*
ConqueTerm_PyExe conque_term.txt /*ConqueTerm_PyExe*
ConqueTerm_PyVersion conque_term.txt /*ConqueTerm_PyVersion*
ConqueTerm_ReadUnfocused conque_term.txt /*ConqueTerm_ReadUnfocused*
ConqueTerm_SendFileKey conque_term.txt /*ConqueTerm_SendFileKey*
ConqueTerm_SendFunctionKeys conque_term.txt /*ConqueTerm_SendFunctionKeys*
ConqueTerm_SendVisKey conque_term.txt /*ConqueTerm_SendVisKey*
ConqueTerm_SessionSupport conque_term.txt /*ConqueTerm_SessionSupport*
ConqueTerm_StartMessages conque_term.txt /*ConqueTerm_StartMessages*
ConqueTerm_Syntax conque_term.txt /*ConqueTerm_Syntax*
ConqueTerm_TERM conque_term.txt /*ConqueTerm_TERM*
ConqueTerm_ToggleKey conque_term.txt /*ConqueTerm_ToggleKey*
GetLatestVimScripts pi_getscript.txt /*GetLatestVimScripts*
GetLatestVimScripts-copyright pi_getscript.txt /*GetLatestVimScripts-copyright*
GetLatestVimScripts_dat pi_getscript.txt /*GetLatestVimScripts_dat*
NERDComAbout NERD_commenter.txt /*NERDComAbout*
NERDComAlignedComment NERD_commenter.txt /*NERDComAlignedComment*
NERDComAltDelim NERD_commenter.txt /*NERDComAltDelim*
@ -173,12 +189,12 @@ NERDComComment NERD_commenter.txt /*NERDComComment*
NERDComCredits NERD_commenter.txt /*NERDComCredits*
NERDComDefaultDelims NERD_commenter.txt /*NERDComDefaultDelims*
NERDComEOLComment NERD_commenter.txt /*NERDComEOLComment*
NERDComFiletypes NERD_commenter.txt /*NERDComFiletypes*
NERDComFunctionality NERD_commenter.txt /*NERDComFunctionality*
NERDComFunctionalityDetails NERD_commenter.txt /*NERDComFunctionalityDetails*
NERDComFunctionalitySummary NERD_commenter.txt /*NERDComFunctionalitySummary*
NERDComHeuristics NERD_commenter.txt /*NERDComHeuristics*
NERDComInsertComment NERD_commenter.txt /*NERDComInsertComment*
NERDComInstallation NERD_commenter.txt /*NERDComInstallation*
NERDComInvertComment NERD_commenter.txt /*NERDComInvertComment*
NERDComIssues NERD_commenter.txt /*NERDComIssues*
NERDComLicense NERD_commenter.txt /*NERDComLicense*
@ -198,10 +214,12 @@ NERDComYankComment NERD_commenter.txt /*NERDComYankComment*
NERDCommenter NERD_commenter.txt /*NERDCommenter*
NERDCommenterContents NERD_commenter.txt /*NERDCommenterContents*
NERDTree NERD_tree.txt /*NERDTree*
NERDTree-! NERD_tree.txt /*NERDTree-!*
NERDTree-? NERD_tree.txt /*NERDTree-?*
NERDTree-A NERD_tree.txt /*NERDTree-A*
NERDTree-B NERD_tree.txt /*NERDTree-B*
NERDTree-C NERD_tree.txt /*NERDTree-C*
NERDTree-C-J NERD_tree.txt /*NERDTree-C-J*
NERDTree-C-K NERD_tree.txt /*NERDTree-C-K*
NERDTree-D NERD_tree.txt /*NERDTree-D*
NERDTree-F NERD_tree.txt /*NERDTree-F*
NERDTree-I NERD_tree.txt /*NERDTree-I*
@ -213,8 +231,7 @@ NERDTree-R NERD_tree.txt /*NERDTree-R*
NERDTree-T NERD_tree.txt /*NERDTree-T*
NERDTree-U NERD_tree.txt /*NERDTree-U*
NERDTree-X NERD_tree.txt /*NERDTree-X*
NERDTree-c-j NERD_tree.txt /*NERDTree-c-j*
NERDTree-c-k NERD_tree.txt /*NERDTree-c-k*
NERDTree-cd NERD_tree.txt /*NERDTree-cd*
NERDTree-contents NERD_tree.txt /*NERDTree-contents*
NERDTree-e NERD_tree.txt /*NERDTree-e*
NERDTree-f NERD_tree.txt /*NERDTree-f*
@ -231,22 +248,29 @@ NERDTree-s NERD_tree.txt /*NERDTree-s*
NERDTree-t NERD_tree.txt /*NERDTree-t*
NERDTree-u NERD_tree.txt /*NERDTree-u*
NERDTree-x NERD_tree.txt /*NERDTree-x*
NERDTreeAPI NERD_tree.txt /*NERDTreeAPI*
NERDTreeAbout NERD_tree.txt /*NERDTreeAbout*
NERDTreeAddKeyMap() NERD_tree.txt /*NERDTreeAddKeyMap()*
NERDTreeAddMenuItem() NERD_tree.txt /*NERDTreeAddMenuItem()*
NERDTreeAddMenuSeparator() NERD_tree.txt /*NERDTreeAddMenuSeparator()*
NERDTreeAddSubmenu() NERD_tree.txt /*NERDTreeAddSubmenu()*
NERDTreeBookmarkCommands NERD_tree.txt /*NERDTreeBookmarkCommands*
NERDTreeBookmarkTable NERD_tree.txt /*NERDTreeBookmarkTable*
NERDTreeBookmarks NERD_tree.txt /*NERDTreeBookmarks*
NERDTreeChangelog NERD_tree.txt /*NERDTreeChangelog*
NERDTreeCredits NERD_tree.txt /*NERDTreeCredits*
NERDTreeFilesysMenu NERD_tree.txt /*NERDTreeFilesysMenu*
NERDTreeFunctionality NERD_tree.txt /*NERDTreeFunctionality*
NERDTreeGlobalCommands NERD_tree.txt /*NERDTreeGlobalCommands*
NERDTreeHacking NERD_tree.txt /*NERDTreeHacking*
NERDTreeInvalidBookmarks NERD_tree.txt /*NERDTreeInvalidBookmarks*
NERDTreeKeymapAPI NERD_tree.txt /*NERDTreeKeymapAPI*
NERDTreeLicense NERD_tree.txt /*NERDTreeLicense*
NERDTreeMappings NERD_tree.txt /*NERDTreeMappings*
NERDTreeMenu NERD_tree.txt /*NERDTreeMenu*
NERDTreeMenuAPI NERD_tree.txt /*NERDTreeMenuAPI*
NERDTreeOptionDetails NERD_tree.txt /*NERDTreeOptionDetails*
NERDTreeOptionSummary NERD_tree.txt /*NERDTreeOptionSummary*
NERDTreeOptions NERD_tree.txt /*NERDTreeOptions*
NERDTreeRender() NERD_tree.txt /*NERDTreeRender()*
NERD_commenter.txt NERD_commenter.txt /*NERD_commenter.txt*
NERD_tree.txt NERD_tree.txt /*NERD_tree.txt*
OpenFilemanager open_terminal.txt /*OpenFilemanager*
@ -270,10 +294,13 @@ VCSCommandDiffSplit vcscommand.txt /*VCSCommandDiffSplit*
VCSCommandDisableAll vcscommand.txt /*VCSCommandDisableAll*
VCSCommandDisableExtensionMappings vcscommand.txt /*VCSCommandDisableExtensionMappings*
VCSCommandDisableMappings vcscommand.txt /*VCSCommandDisableMappings*
VCSCommandDisableMenu vcscommand.txt /*VCSCommandDisableMenu*
VCSCommandEdit vcscommand.txt /*VCSCommandEdit*
VCSCommandEnableBufferSetup vcscommand.txt /*VCSCommandEnableBufferSetup*
VCSCommandMapPrefix vcscommand.txt /*VCSCommandMapPrefix*
VCSCommandMappings vcscommand.txt /*VCSCommandMappings*
VCSCommandMenuPriority vcscommand.txt /*VCSCommandMenuPriority*
VCSCommandMenuRoot vcscommand.txt /*VCSCommandMenuRoot*
VCSCommandResultBufferNameExtension vcscommand.txt /*VCSCommandResultBufferNameExtension*
VCSCommandResultBufferNameFunction vcscommand.txt /*VCSCommandResultBufferNameFunction*
VCSCommandSVKExec vcscommand.txt /*VCSCommandSVKExec*
@ -282,6 +309,7 @@ VCSCommandSVNDiffOpt vcscommand.txt /*VCSCommandSVNDiffOpt*
VCSCommandSVNExec vcscommand.txt /*VCSCommandSVNExec*
VCSCommandSplit vcscommand.txt /*VCSCommandSplit*
VCSCommandVCSTypeOverride vcscommand.txt /*VCSCommandVCSTypeOverride*
VCSCommandVCSTypePreference vcscommand.txt /*VCSCommandVCSTypePreference*
akmap-commenter akmap.txt /*akmap-commenter*
akmap-dev akmap.txt /*akmap-dev*
akmap-intro akmap.txt /*akmap-intro*
@ -311,6 +339,7 @@ align-usage Align.txt /*align-usage*
align-userguide Align.txt /*align-userguide*
align-utf Align.txt /*align-utf*
align-utf8 Align.txt /*align-utf8*
align-xstrlen Align.txt /*align-xstrlen*
align.txt Align.txt /*align.txt*
alignctrl Align.txt /*alignctrl*
alignctrl- Align.txt /*alignctrl-*
@ -324,8 +353,11 @@ alignctrl-C Align.txt /*alignctrl-C*
alignctrl-I Align.txt /*alignctrl-I*
alignctrl-P Align.txt /*alignctrl-P*
alignctrl-W Align.txt /*alignctrl-W*
alignctrl-alignskip Align.txt /*alignctrl-alignskip*
alignctrl-c Align.txt /*alignctrl-c*
alignctrl-g Align.txt /*alignctrl-g*
alignctrl-init Align.txt /*alignctrl-init*
alignctrl-initialization Align.txt /*alignctrl-initialization*
alignctrl-l Align.txt /*alignctrl-l*
alignctrl-m Align.txt /*alignctrl-m*
alignctrl-no-option Align.txt /*alignctrl-no-option*
@ -333,6 +365,7 @@ alignctrl-p Align.txt /*alignctrl-p*
alignctrl-r Align.txt /*alignctrl-r*
alignctrl-separators Align.txt /*alignctrl-separators*
alignctrl-settings Align.txt /*alignctrl-settings*
alignctrl-star Align.txt /*alignctrl-star*
alignctrl-v Align.txt /*alignctrl-v*
alignctrl-w Align.txt /*alignctrl-w*
alignman Align.txt /*alignman*
@ -388,23 +421,49 @@ bufexplorer-todo bufexplorer.txt /*bufexplorer-todo*
bufexplorer-usage bufexplorer.txt /*bufexplorer-usage*
bufexplorer.txt bufexplorer.txt /*bufexplorer.txt*
buffer-explorer bufexplorer.txt /*buffer-explorer*
conque-term-Esc conque_term.txt /*conque-term-Esc*
conque-term-F8 conque_term.txt /*conque-term-F8*
conque-term-F9 conque_term.txt /*conque-term-F9*
cecutil cecutil.txt /*cecutil*
cecutil-cmd cecutil.txt /*cecutil-cmd*
cecutil-contents cecutil.txt /*cecutil-contents*
cecutil-copyright cecutil.txt /*cecutil-copyright*
cecutil-destroymark cecutil.txt /*cecutil-destroymark*
cecutil-history cecutil.txt /*cecutil-history*
cecutil-map cecutil.txt /*cecutil-map*
cecutil-maps cecutil.txt /*cecutil-maps*
cecutil-marks cecutil.txt /*cecutil-marks*
cecutil-position cecutil.txt /*cecutil-position*
cecutil-posn cecutil.txt /*cecutil-posn*
cecutil-restoremark cecutil.txt /*cecutil-restoremark*
cecutil-restorewinposn cecutil.txt /*cecutil-restorewinposn*
cecutil-rwp cecutil.txt /*cecutil-rwp*
cecutil-savemark cecutil.txt /*cecutil-savemark*
cecutil-saveusermaps cecutil.txt /*cecutil-saveusermaps*
cecutil-savewinposn cecutil.txt /*cecutil-savewinposn*
cecutil-swp cecutil.txt /*cecutil-swp*
cecutil.txt cecutil.txt /*cecutil.txt*
conque-config-general conque_term.txt /*conque-config-general*
conque-config-keyboard conque_term.txt /*conque-config-keyboard*
conque-config-unix conque_term.txt /*conque-config-unix*
conque-config-windows conque_term.txt /*conque-config-windows*
conque-term-api conque_term.txt /*conque-term-api*
conque-term-bugs conque_term.txt /*conque-term-bugs*
conque-term-close conque_term.txt /*conque-term-close*
conque-term-contribute conque_term.txt /*conque-term-contribute*
conque-term-esc conque_term.txt /*conque-term-esc*
conque-term-events conque_term.txt /*conque-term-events*
conque-term-feedback conque_term.txt /*conque-term-feedback*
conque-term-gen-usage conque_term.txt /*conque-term-gen-usage*
conque-term-get-instance conque_term.txt /*conque-term-get-instance*
conque-term-input-mode conque_term.txt /*conque-term-input-mode*
conque-term-installation conque_term.txt /*conque-term-installation*
conque-term-installation-instructions conque_term.txt /*conque-term-installation-instructions*
conque-term-misc conque_term.txt /*conque-term-misc*
conque-term-open conque_term.txt /*conque-term-open*
conque-term-options conque_term.txt /*conque-term-options*
conque-term-read conque_term.txt /*conque-term-read*
conque-term-register conque_term.txt /*conque-term-register*
conque-term-requirements conque_term.txt /*conque-term-requirements*
conque-term-send conque_term.txt /*conque-term-send*
conque-term-set-callback conque_term.txt /*conque-term-set-callback*
conque-term-setup conque_term.txt /*conque-term-setup*
conque-term-special-keys conque_term.txt /*conque-term-special-keys*
conque-term-subprocess conque_term.txt /*conque-term-subprocess*
conque-term-usage conque_term.txt /*conque-term-usage*
@ -412,6 +471,9 @@ conque-term-windows conque_term.txt /*conque-term-windows*
conque-term-write conque_term.txt /*conque-term-write*
conque-term-writeln conque_term.txt /*conque-term-writeln*
cvscommand-changes vcscommand.txt /*cvscommand-changes*
g:AlignSkip Align.txt /*g:AlignSkip*
g:alignmaps_euronumber Align.txt /*g:alignmaps_euronumber*
g:alignmaps_usanumber Align.txt /*g:alignmaps_usanumber*
g:bufExplorerDefaultHelp bufexplorer.txt /*g:bufExplorerDefaultHelp*
g:bufExplorerDetailedHelp bufexplorer.txt /*g:bufExplorerDetailedHelp*
g:bufExplorerFindActive bufexplorer.txt /*g:bufExplorerFindActive*
@ -423,6 +485,26 @@ g:bufExplorerSortBy bufexplorer.txt /*g:bufExplorerSortBy*
g:bufExplorerSplitBelow bufexplorer.txt /*g:bufExplorerSplitBelow*
g:bufExplorerSplitOutPathName bufexplorer.txt /*g:bufExplorerSplitOutPathName*
g:bufExplorerSplitRight bufexplorer.txt /*g:bufExplorerSplitRight*
getlatestvimscripts-install pi_getscript.txt /*getlatestvimscripts-install*
getscript pi_getscript.txt /*getscript*
getscript-autoinstall pi_getscript.txt /*getscript-autoinstall*
getscript-data pi_getscript.txt /*getscript-data*
getscript-history pi_getscript.txt /*getscript-history*
getscript-plugins pi_getscript.txt /*getscript-plugins*
getscript-start pi_getscript.txt /*getscript-start*
glvs pi_getscript.txt /*glvs*
glvs-alg pi_getscript.txt /*glvs-alg*
glvs-algorithm pi_getscript.txt /*glvs-algorithm*
glvs-autoinstall pi_getscript.txt /*glvs-autoinstall*
glvs-contents pi_getscript.txt /*glvs-contents*
glvs-copyright pi_getscript.txt /*glvs-copyright*
glvs-data pi_getscript.txt /*glvs-data*
glvs-dist-install pi_getscript.txt /*glvs-dist-install*
glvs-hist pi_getscript.txt /*glvs-hist*
glvs-install pi_getscript.txt /*glvs-install*
glvs-options pi_getscript.txt /*glvs-options*
glvs-plugins pi_getscript.txt /*glvs-plugins*
glvs-usage pi_getscript.txt /*glvs-usage*
open-terminal open_terminal.txt /*open-terminal*
open-terminal-about open_terminal.txt /*open-terminal-about*
open-terminal-changelog open_terminal.txt /*open-terminal-changelog*
@ -430,6 +512,7 @@ open-terminal-commands open_terminal.txt /*open-terminal-commands*
open-terminal-introduction open_terminal.txt /*open-terminal-introduction*
open-terminal-keymap open_terminal.txt /*open-terminal-keymap*
open-terminal-requires open_terminal.txt /*open-terminal-requires*
pi_getscript.txt pi_getscript.txt /*pi_getscript.txt*
taglist-commands taglist.txt /*taglist-commands*
taglist-debug taglist.txt /*taglist-debug*
taglist-extend taglist.txt /*taglist-extend*

View File

@ -1,5 +1,5 @@
*vcscommand.txt* vcscommand
Copyright (c) 2007 Bob Hiestand
Copyright (c) Bob Hiestand
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
@ -149,9 +149,8 @@ will cause the above behavior to change. Instead of annotating the version on
the current line, the parent revision is used instead, crossing branches if
necessary.
The filetype of the vcscommand scratch buffer is set to one of 'CVSAnnotate',
'SVNAnnotate', 'SVKAnnotate' or 'gitAnnotate' as appropriate, to take advantage of the
bundled syntax files.
With no arguments the cursor will jump to the line in the annotated buffer
corresponding to the current line in the source buffer.
:VCSBlame[!] *:VCSBlame*
@ -433,10 +432,13 @@ The following variables are available:
|VCSCommandDisableAll|
|VCSCommandDisableMappings|
|VCSCommandDisableExtensionMappings|
|VCSCommandDisableMenu|
|VCSCommandEdit|
|VCSCommandEnableBufferSetup|
|VCSCommandMappings|
|VCSCommandMapPrefix|
|VCSCommandMenuPriority|
|VCSCommandMenuRoot|
|VCSCommandResultBufferNameExtension|
|VCSCommandResultBufferNameFunction|
|VCSCommandSplit|
@ -445,6 +447,7 @@ The following variables are available:
|VCSCommandSVNDiffOpt|
|VCSCommandSVNExec|
|VCSCommandVCSTypeOverride|
|VCSCommandVCSTypePreference|
VCSCommandCommitOnWrite *VCSCommandCommitOnWrite*
@ -495,6 +498,11 @@ VCSCommandEdit *VCSCommandEdit*
This variable controls whether the original buffer is replaced ('edit') or
split ('split'). If not set, it defaults to 'split'.
VCSCommandDisableMenu *VCSCommandDisableMenu*
This variable, if set to a non-zero value, prevents the default command menu
from being set.
VCSCommandEnableBufferSetup *VCSCommandEnableBufferSetup*
This variable, if set to a non-zero value, activates VCS buffer management
@ -516,6 +524,14 @@ This variable, if set, overrides the default mapping prefix ('<Leader>c').
This allows customization of the mapping space used by the vcscommand
shortcuts.
VCSCommandMenuPriority *VCSCommandMenuPriority*
This variable, if set, overrides the default menu priority '' (empty)
VCSCommandMenuRoot *VCSCommandMenuRoot*
This variable, if set, overrides the default menu root 'Plugin.VCS'
VCSCommandResultBufferNameExtension *VCSCommandResultBufferNameExtension*
This variable, if set to a non-blank value, is appended to the name of the VCS
@ -578,6 +594,13 @@ element is a regular expression that will be matched against the full file
name of a given buffer. If it matches, the second element will be used as the
VCS type.
VCSCommandVCSTypePreference *VCSCommandVCSTypePreference*
This variable allows the VCS type detection to be weighted towards a specific
VCS, in case more than one potential VCS is detected as useable. The format
of the variable is either a list or a space-separated string containing the
ordered-by-preference abbreviations of the preferred VCS types.
5.2 VCSCommand events *vcscommand-events*
For additional customization, vcscommand can trigger user-defined events.

View File

@ -0,0 +1,41 @@
" ============================================================================
" File: exec_menuitem.vim
" Description: plugin for NERD Tree that provides an execute file menu item
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
" Last Change: 22 July, 2009
" License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
" ============================================================================
if exists("g:loaded_nerdtree_exec_menuitem")
finish
endif
let g:loaded_nerdtree_exec_menuitem = 1
call NERDTreeAddMenuItem({
\ 'text': '(!)Execute file',
\ 'shortcut': '!',
\ 'callback': 'NERDTreeExecFile',
\ 'isActiveCallback': 'NERDTreeExecFileActive' })
function! NERDTreeExecFileActive()
let node = g:NERDTreeFileNode.GetSelected()
return !node.path.isDirectory && node.path.isExecutable
endfunction
function! NERDTreeExecFile()
let treenode = g:NERDTreeFileNode.GetSelected()
echo "==========================================================\n"
echo "Complete the command to execute (add arguments etc):\n"
let cmd = treenode.path.str({'escape': 1})
let cmd = input(':!', cmd . ' ')
if cmd != ''
exec ':!' . cmd
else
echo "Aborted"
endif
endfunction

View File

@ -0,0 +1,224 @@
" ============================================================================
" File: fs_menu.vim
" Description: plugin for the NERD Tree that provides a file system menu
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
" Last Change: 17 July, 2009
" License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
" ============================================================================
if exists("g:loaded_nerdtree_fs_menu")
finish
endif
let g:loaded_nerdtree_fs_menu = 1
call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'})
call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'})
call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'})
if has("gui_mac") || has("gui_macvim")
call NERDTreeAddMenuItem({'text': '(r)eveal in Finder the current node', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'})
call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFile'})
call NERDTreeAddMenuItem({'text': '(q)uicklook the current node', 'shortcut': 'q', 'callback': 'NERDTreeQuickLook'})
endif
if g:NERDTreePath.CopyingSupported()
call NERDTreeAddMenuItem({'text': '(c)copy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'})
endif
"FUNCTION: s:echo(msg){{{1
function! s:echo(msg)
redraw
echomsg "NERDTree: " . a:msg
endfunction
"FUNCTION: s:echoWarning(msg){{{1
function! s:echoWarning(msg)
echohl warningmsg
call s:echo(a:msg)
echohl normal
endfunction
"FUNCTION: s:promptToDelBuffer(bufnum, msg){{{1
"prints out the given msg and, if the user responds by pushing 'y' then the
"buffer with the given bufnum is deleted
"
"Args:
"bufnum: the buffer that may be deleted
"msg: a message that will be echoed to the user asking them if they wish to
" del the buffer
function! s:promptToDelBuffer(bufnum, msg)
echo a:msg
if nr2char(getchar()) ==# 'y'
exec "silent bdelete! " . a:bufnum
endif
endfunction
"FUNCTION: NERDTreeAddNode(){{{1
function! NERDTreeAddNode()
let curDirNode = g:NERDTreeDirNode.GetSelected()
let newNodeName = input("Add a childnode\n".
\ "==========================================================\n".
\ "Enter the dir/file name to be created. Dirs end with a '/'\n" .
\ "", curDirNode.path.str() . g:NERDTreePath.Slash(), "file")
if newNodeName ==# ''
call s:echo("Node Creation Aborted.")
return
endif
try
let newPath = g:NERDTreePath.Create(newNodeName)
let parentNode = b:NERDTreeRoot.findNode(newPath.getParent())
let newTreeNode = g:NERDTreeFileNode.New(newPath)
if parentNode.isOpen || !empty(parentNode.children)
call parentNode.addChild(newTreeNode, 1)
call NERDTreeRender()
call newTreeNode.putCursorHere(1, 0)
endif
catch /^NERDTree/
call s:echoWarning("Node Not Created.")
endtry
endfunction
"FUNCTION: NERDTreeMoveNode(){{{1
function! NERDTreeMoveNode()
let curNode = g:NERDTreeFileNode.GetSelected()
let newNodePath = input("Rename the current node\n" .
\ "==========================================================\n" .
\ "Enter the new path for the node: \n" .
\ "", curNode.path.str(), "file")
if newNodePath ==# ''
call s:echo("Node Renaming Aborted.")
return
endif
try
let bufnum = bufnr(curNode.path.str())
call curNode.rename(newNodePath)
call NERDTreeRender()
"if the node is open in a buffer, ask the user if they want to
"close that buffer
if bufnum != -1
let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)"
call s:promptToDelBuffer(bufnum, prompt)
endif
call curNode.putCursorHere(1, 0)
redraw
catch /^NERDTree/
call s:echoWarning("Node Not Renamed.")
endtry
endfunction
" FUNCTION: NERDTreeDeleteNode() {{{1
function! NERDTreeDeleteNode()
let currentNode = g:NERDTreeFileNode.GetSelected()
let confirmed = 0
if currentNode.path.isDirectory
let choice =input("Delete the current node\n" .
\ "==========================================================\n" .
\ "STOP! To delete this entire directory, type 'yes'\n" .
\ "" . currentNode.path.str() . ": ")
let confirmed = choice ==# 'yes'
else
echo "Delete the current node\n" .
\ "==========================================================\n".
\ "Are you sure you wish to delete the node:\n" .
\ "" . currentNode.path.str() . " (yN):"
let choice = nr2char(getchar())
let confirmed = choice ==# 'y'
endif
if confirmed
try
call currentNode.delete()
call NERDTreeRender()
"if the node is open in a buffer, ask the user if they want to
"close that buffer
let bufnum = bufnr(currentNode.path.str())
if buflisted(bufnum)
let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)"
call s:promptToDelBuffer(bufnum, prompt)
endif
redraw
catch /^NERDTree/
call s:echoWarning("Could not remove node")
endtry
else
call s:echo("delete aborted")
endif
endfunction
" FUNCTION: NERDTreeCopyNode() {{{1
function! NERDTreeCopyNode()
let currentNode = g:NERDTreeFileNode.GetSelected()
let newNodePath = input("Copy the current node\n" .
\ "==========================================================\n" .
\ "Enter the new path to copy the node to: \n" .
\ "", currentNode.path.str(), "file")
if newNodePath != ""
"strip trailing slash
let newNodePath = substitute(newNodePath, '\/$', '', '')
let confirmed = 1
if currentNode.path.copyingWillOverwrite(newNodePath)
call s:echo("Warning: copying may overwrite files! Continue? (yN)")
let choice = nr2char(getchar())
let confirmed = choice ==# 'y'
endif
if confirmed
try
let newNode = currentNode.copy(newNodePath)
if !empty(newNode)
call NERDTreeRender()
call newNode.putCursorHere(0, 0)
endif
catch /^NERDTree/
call s:echoWarning("Could not copy node")
endtry
endif
else
call s:echo("Copy aborted.")
endif
redraw
endfunction
function! NERDTreeQuickLook()
let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {}
call system("qlmanage -p 2>/dev/null '" . treenode.path.str() . "'")
endif
endfunction
function! NERDTreeRevealInFinder()
let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {}
let x = system("open -R '" . treenode.path.str() . "'")
endif
endfunction
function! NERDTreeExecuteFile()
let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {}
let x = system("open '" . treenode.path.str() . "'")
endif
endfunction
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -1,11 +1,9 @@
" AlignMapsPlugin: Alignment maps based upon <Align.vim> and <AlignMaps.vim>
" Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz>
" Date: Mar 03, 2009
" Date: Jun 18, 2012
"
" NOTE: the code herein needs vim 6.0 or later
" needs <Align.vim> v6 or later
" needs <cecutil.vim> v5 or later
" Copyright: Copyright (C) 1999-2008 Charles E. Campbell, Jr. {{{1
" NOTE: the code herein needs vim 7.0 or later
" Copyright: Copyright (C) 1999-2012 Charles E. Campbell, Jr. {{{1
" Permission is hereby granted to use and distribute this code,
" with or without modifications, provided that this copyright
" notice is copied with it. Like anything else that's free,
@ -14,7 +12,12 @@
" plugin, you agree that in no event will the copyright
" holder be liable for any damages resulting from the use
" of this software.
"
" Romans 1:20 For the invisible things of Him since the creation of the {{{1
" world are clearly seen, being perceived through the things that are
" made, even His everlasting power and divinity; that they may be
" without excuse.
" ---------------------------------------------------------------------
" Usage: {{{1
" Use 'a to mark beginning of to-be-aligned region, Alternative: use V
" move cursor to end of region, and execute map. (linewise visual mode) to
@ -29,20 +32,18 @@
"
" Note: these maps all use <Align.vim>.
"
" Romans 1:20 For the invisible things of Him since the creation of the {{{1
" world are clearly seen, being perceived through the things that are
" made, even His everlasting power and divinity; that they may be
" without excuse.
" ---------------------------------------------------------------------
" Load Once: {{{1
if &cp || exists("g:loaded_AlignMapsPlugin")
finish
endif
let s:keepcpo = &cpo
let g:loaded_AlignMapsPlugin = "v41"
let g:loaded_AlignMapsPlugin = "v42"
set cpo&vim
" =====================================================================
" Public Interface: {{{1
com! AlignMapsClean :call AlignMaps#AlignMapsClean()
" =====================================================================
" Maps: {{{1
@ -79,14 +80,17 @@ if !hasmapto('<Plug>AM_adec') |map <unique> <Leader>adec <Plug>AM_adec|endif
if !hasmapto('<Plug>AM_adef') |map <unique> <Leader>adef <Plug>AM_adef|endif
if !hasmapto('<Plug>AM_afnc') |map <unique> <Leader>afnc <Plug>AM_afnc|endif
if !hasmapto('<Plug>AM_afnc') |map <unique> <Leader>afnc <Plug>AM_afnc|endif
if !hasmapto('<Plug>AM_aunum')|map <unique> <Leader>aunum <Plug>AM_aenum|endif
if !hasmapto('<Plug>AM_aenum')|map <unique> <Leader>aenum <Plug>AM_aunum|endif
" Number alignment maps: {{{2
if !hasmapto('<Plug>AM_aunum')|map <unique> <Leader>aunum <Plug>AM_aunum|endif
if !hasmapto('<Plug>AM_aenum')|map <unique> <Leader>aenum <Plug>AM_aenum|endif
if exists("g:alignmaps_euronumber") && !exists("g:alignmaps_usanumber")
if !hasmapto('<Plug>AM_anum')|map <unique> <Leader>anum <Plug>AM_aenum|endif
else
if !hasmapto('<Plug>AM_anum')|map <unique> <Leader>anum <Plug>AM_aunum|endif
endif
" Plug maps: (the real thing) {{{2
map <silent> <script> <Plug>AM_a? <SID>WS:AlignCtrl mIp1P1lC ? : : : : <CR>:'a,.Align<CR>:'a,'z-1s/\(\s\+\)? /?\1/e<CR><SID>WE
map <silent> <script> <Plug>AM_a, <SID>WS:'y,'zs/\(\S\)\s\+/\1 /ge<CR>'yjma'zk:call AlignMaps#CharJoiner(",")<cr>:silent 'y,'zg/,/call AlignMaps#FixMultiDec()<CR>'z:exe "norm \<Plug>AM_adec"<cr><SID>WE
map <silent> <script> <Plug>AM_a< <SID>WS:AlignCtrl mIp1P1=l << >><CR>:'a,.Align<CR><SID>WE
@ -97,12 +101,11 @@ map <silent> <script> <Plug>AM_acom <SID>WS:'a,.s/\/[*/]\/\=/@&@/e<CR>:'a,.s/\*
map <silent> <script> <Plug>AM_adcom <SID>WS:'a,.v/^\s*\/[/*]/s/\/[*/]\*\=/@&@/e<CR>:'a,.v/^\s*\/[/*]/s/\*\//@&/e<CR>:'y,'zv/^\s*\/[/*]/s/^\( *\) @/\1@/e<CR>'zk:call AlignMaps#StdAlign(3)<cr>:'y,'zv/^\s*\/[/*]/s/^\(\s*\) @/\1/e<CR>:'y,'zs/ @//eg<CR><SID>WE
map <silent> <script> <Plug>AM_aocom <SID>WS:AlignPush<CR>:AlignCtrl g /[*/]<CR>:exe "norm \<Plug>AM_acom"<cr>:AlignPop<CR><SID>WE
map <silent> <script> <Plug>AM_ascom <SID>WS:'a,.s/\/[*/]/@&@/e<CR>:'a,.s/\*\//@&/e<CR>:silent! 'a,.g/^\s*@\/[*/]/s/@//ge<CR>:AlignCtrl v ^\s*\/[*/]<CR>:AlignCtrl g \/[*/]<CR>'zk:call AlignMaps#StdAlign(2)<cr>:'y,'zs/^\(\s*\) @/\1/e<CR>:'y,'zs/ @//eg<CR><SID>WE
map <silent> <script> <Plug>AM_adec <SID>WS:'a,'zs/\([^ \t/(]\)\([*&]\)/\1 \2/e<CR>:'y,'zv/^\//s/\([^ \t]\)\s\+/\1 /ge<CR>:'y,'zv/^\s*[*/]/s/\([^/][*&]\)\s\+/\1/ge<CR>:'y,'zv/^\s*[*/]/s/^\(\s*\%(\K\k*\s\+\%([a-zA-Z_*(&]\)\@=\)\+\)\([*(&]*\)\s*\([a-zA-Z0-9_()]\+\)\s*\(\(\[.\{-}]\)*\)\s*\(=\)\=\s*\(.\{-}\)\=\s*;/\1@\2#@\3\4@\6@\7;@/e<CR>:'y,'zv/^\s*[*/]/s/\*\/\s*$/@*\//e<CR>:'y,'zv/^\s*[*/]/s/^\s\+\*/@@@@@* /e<CR>:'y,'zv/^\s*[*/]/s/^@@@@@\*\(.*[^*/]\)$/&@*/e<CR>'yjma'zk:AlignCtrl v ^\s*[*/#]<CR>:call AlignMaps#StdAlign(1)<cr>:'y,'zv/^\s*[*/]/s/@ //ge<CR>:'y,'zv/^\s*[*/]/s/\(\s*\);/;\1/e<CR>:'y,'zv/^#/s/# //e<CR>:'y,'zv/^\s\+[*/#]/s/\([^/*]\)\(\*\+\)\( \+\)/\1\3\2/e<CR>:'y,'zv/^\s\+[*/#]/s/\((\+\)\( \+\)\*/\2\1*/e<CR>:'y,'zv/^\s\+[*/#]/s/^\(\s\+\) \*/\1*/e<CR>:'y,'zv/^\s\+[*/#]/s/[ \t@]*$//e<CR>:'y,'zs/^[*]/ */e<CR><SID>WE
map <silent> <script> <Plug>AM_adec <SID>WS:'a,'zs/\([^ \t/(]\)\([*&]\)/\1 \2/e<CR>:'y,'zv/^\//s/\([^ \t]\)\s\+/\1 /ge<CR>:'y,'zv/^\s*[*/]/s/\([^/][*&]\)\s\+/\1/ge<CR>:'y,'zv/^\s*[*/]/s/^\(\s*\%([a-zA-Z_][a-zA-Z_0-9<>:]*\s\+\%([a-zA-Z_*(&]\)\@=\)\+\)\([*(&]*\)\s*\([a-zA-Z0-9_()<>:]\+\)\s*\(\(\[.\{-}]\)*\)\s*\(=\)\=\s*\(.\{-}\)\=\s*;/\1@\2#@\3\4@\6@\7;@/e<CR>:'y,'zv/^\s*[*/]/s/\*\/\s*$/@*\//e<CR>:'y,'zv/^\s*[*/]/s/^\s\+\*/@@@@@* /e<CR>:'y,'zv/^\s*[*/]/s/^@@@@@\*\(.*[^*/]\)$/&@*/e<CR>'yjma'zk:AlignCtrl v ^\s*[*/#]<CR>:call AlignMaps#StdAlign(1)<cr>:'y,'zv/^\s*[*/]/s/@ //ge<CR>:'y,'zv/^\s*[*/]/s/\(\s*\);/;\1/e<CR>:'y,'zv/^#/s/# //e<CR>:'y,'zv/^\s\+[*/#]/s/\([^/*]\)\(\*\+\)\( \+\)/\1\3\2/e<CR>:'y,'zv/^\s\+[*/#]/s/\((\+\)\( \+\)\*/\2\1*/e<CR>:'y,'zv/^\s\+[*/#]/s/^\(\s\+\) \*/\1*/e<CR>:'y,'zv/^\s\+[*/#]/s/[ \t@]*$//e<CR>:'y,'zs/^[*]/ */e<CR><SID>WE
map <silent> <script> <Plug>AM_adef <SID>WS:AlignPush<CR>:AlignCtrl v ^\s*\(\/\*\<bar>\/\/\)<CR>:'a,.v/^\s*\(\/\*\<bar>\/\/\)/s/^\(\s*\)#\(\s\)*define\s*\(\I[a-zA-Z_0-9(),]*\)\s*\(.\{-}\)\($\<Bar>\/\*\)/#\1\2define @\3@\4@\5/e<CR>:'a,.v/^\s*\(\/\*\<bar>\/\/\)/s/\($\<Bar>\*\/\)/@&/e<CR>'zk:call AlignMaps#StdAlign(1)<cr>'yjma'zk:'a,.v/^\s*\(\/\*\<bar>\/\/\)/s/ @//g<CR><SID>WE
map <silent> <script> <Plug>AM_afnc :<c-u>set lz<CR>:silent call AlignMaps#Afnc()<CR>:set nolz<CR>
map <silent> <script> <Plug>AM_aunum <SID>WS:'a,'zs/\%([0-9.]\)\s\+\zs\([-+.]\=\d\)/@\1/ge<CR>:'a,'zs/\(\(^\|\s\)\d\+\)\(\s\+\)@/\1@\3@/ge<CR>:'a,'zs/\.@/\.0@/ge<CR>:AlignCtrl wmp0P0r<CR>:'a,'zAlign [.@]<CR>:'a,'zs/@/ /ge<CR>:'a,'zs/\(\.\)\(\s\+\)\([0-9.,eE+]\+\)/\1\3\2/ge<CR>:'a,'zs/\([eE]\)\(\s\+\)\([0-9+\-+]\+\)/\1\3\2/ge<CR><SID>WE
map <silent> <script> <Plug>AM_aenum <SID>WS:'a,'zs/\%([0-9.]\)\s\+\([-+]\=\d\)/\1@\2/ge<CR>:'a,'zs/\.@/\.0@/ge<CR>:AlignCtrl wmp0P0r<CR>:'a,'zAlign [,@]<CR>:'a,'zs/@/ /ge<CR>:'a,'zs/\(,\)\(\s\+\)\([-0-9.,eE+]\+\)/\1\3\2/ge<CR>:'a,'zs/\([eE]\)\(\s\+\)\([0-9+\-+]\+\)/\1\3\2/ge<CR><SID>WE
map <silent> <script> <Plug>AM_aunum <SID>WS:'a,'zs/\([-+]\=\d\+\)\([eE][-+]\d\+\)\=/\1#\2/ge<CR>:'a,'zs/\([.eE][-+]\=\d\+\)#/\1/ge<CR>:'a,'zs/#\././ge<CR>:'a,'zs/[-+]\=\%(\d\+\%([.#]\d*\)\=\<bar>[.#]\d\+\)\%([eE][-+]\=\d\+\)\=/@&@/ge<CR>:AlignCtrl Imp0P0r<CR>:'a,'zAlign [@#.]<CR>:'a,'zs/\([.#]\)\(\s\+\)\(\d*\%([eE][-+]\=\d\+\)\=\)@/\1\3\2@/ge<CR>:'a,'zs/@//<CR>:'a,'zs/[#@]/ /ge<CR><SID>WE
map <silent> <script> <Plug>AM_aenum <SID>WS:'a,'zs/\([-+]\=\d\+\)\([eE][-+]\d\+\)\=/\1#\2/ge<CR>:'a,'zs/\([,eE][-+]\=\d\+\)#/\1/ge<CR>:'a,'zs/#,/,/ge<CR>:'a,'zs/[-+]\=\%(\d\+\%([,#]\d*\)\=\<bar>[,#]\d\+\)\%([eE][-+]\=\d\+\)\=/@&@/ge<CR>:AlignCtrl Imp0P0r<CR>:'a,'zAlign [@#,]<CR>:'a,'zs/\([,#]\)\(\s\+\)\(\d*\%([eE][-+]\=\d\+\)\=\)@/\1\3\2@/ge<CR>:'a,'zs/@//<CR>:'a,'zs/[#@]/ /ge<CR><SID>WE
" ---------------------------------------------------------------------
" html table alignment {{{2
if !hasmapto('<Plug>AM_Htd')|map <unique> <Leader>Htd <Plug>AM_Htd|endif
@ -120,6 +123,7 @@ if !hasmapto('<Plug>AM_T<') |map <unique> <Leader>T< <Plug>AM_T<|endif
if !hasmapto('<Plug>AM_T=') |map <unique> <Leader>T= <Plug>AM_T=|endif
if !hasmapto('<Plug>AM_T?') |map <unique> <Leader>T? <Plug>AM_T?|endif
if !hasmapto('<Plug>AM_T@') |map <unique> <Leader>T@ <Plug>AM_T@|endif
if !hasmapto('<Plug>AM_TW@') |map <unique> <Leader>TW@ <Plug>AM_TW@|endif
if !hasmapto('<Plug>AM_Tab') |map <unique> <Leader>Tab <Plug>AM_Tab|endif
if !hasmapto('<Plug>AM_Tsp') |map <unique> <Leader>Tsp <Plug>AM_Tsp|endif
if !hasmapto('<Plug>AM_T~') |map <unique> <Leader>T~ <Plug>AM_T~|endif
@ -134,6 +138,7 @@ map <silent> <script> <Plug>AM_T< <SID>WS:AlignCtrl mIp0P0=r <<CR>:'a,.Align<C
map <silent> <script> <Plug>AM_T= <SID>WS:'a,'z-1s/\s\+\([*/+\-%<Bar>&\~^]\==\)/ \1/e<CR>:'a,'z-1s@ \+\([*/+\-%<Bar>&\~^]\)=@\1=@ge<CR>:'a,'z-1s/; */;@/e<CR>:'a,'z-1s/==/\="\<Char-0x0f>\<Char-0x0f>"/ge<CR>:'a,'z-1s/!=/\x="!\<Char-0x0f>"/ge<CR>:AlignCtrl mIp1P1=r = @<CR>:AlignCtrl g =<CR>:'a,'z-1Align<CR>:'a,'z-1s/; *@/;/e<CR>:'a,'z-1s/; *$/;/e<CR>:'a,'z-1s@\([*/+\-%<Bar>&\~^]\)\( \+\)=@\2\1=@ge<CR>:'a,'z-1s/\( \+\);/;\1/ge<CR>:'a,'z-1s/\xff/=/ge<CR><SID>WE:exe "norm <Plug>acom"
map <silent> <script> <Plug>AM_T? <SID>WS:AlignCtrl mIp0P0=r ?<CR>:'a,.Align<CR>:'y,'zs/ \( *\);/;\1/ge<CR><SID>WE
map <silent> <script> <Plug>AM_T@ <SID>WS:AlignCtrl mIp0P0=r @<CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_TW@ <SID>WS:AlignCtrl mWp0P0=r @<CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_Tab <SID>WS:'a,.s/^\(\t*\)\(.*\)/\=submatch(1).escape(substitute(submatch(2),'\t','@','g'),'\')/<CR>:AlignCtrl mI=r @<CR>:'a,.Align<CR>:'y+1,'z-1s/@/ /g<CR><SID>WE
map <silent> <script> <Plug>AM_Tsp <SID>WS:'a,.s/^\(\s*\)\(.*\)/\=submatch(1).escape(substitute(submatch(2),'\s\+','@','g'),'\')/<CR>:AlignCtrl mI=r @<CR>:'a,.Align<CR>:'y+1,'z-1s/@/ /g<CR><SID>WE
map <silent> <script> <Plug>AM_T~ <SID>WS:AlignCtrl mIp0P0=r ~<CR>:'a,.Align<CR>:'y,'zs/ \( *\);/;\1/ge<CR><SID>WE
@ -156,12 +161,13 @@ if !hasmapto('<Plug>AM_w=') |map <unique> <Leader>w= <Plug>AM_w=|endif
if !hasmapto('<Plug>AM_t?') |map <unique> <Leader>t? <Plug>AM_t?|endif
if !hasmapto('<Plug>AM_t~') |map <unique> <Leader>t~ <Plug>AM_t~|endif
if !hasmapto('<Plug>AM_t@') |map <unique> <Leader>t@ <Plug>AM_t@|endif
if !hasmapto('<Plug>AM_tW@') |map <unique> <Leader>tW@ <Plug>AM_tW@|endif
if !hasmapto('<Plug>AM_m=') |map <unique> <Leader>m= <Plug>AM_m=|endif
if !hasmapto('<Plug>AM_tab') |map <unique> <Leader>tab <Plug>AM_tab|endif
if !hasmapto('<Plug>AM_tml') |map <unique> <Leader>tml <Plug>AM_tml|endif
if !hasmapto('<Plug>AM_tsp') |map <unique> <Leader>tsp <Plug>AM_tsp|endif
if !hasmapto('<Plug>AM_tsq') |map <unique> <Leader>tsq <Plug>AM_tsq|endif
" if !hasmapto('<Plug>AM_tt') |map <unique> <Leader>tt <Plug>AM_tt|endif
if !hasmapto('<Plug>AM_tt') |map <unique> <Leader>tt <Plug>AM_tt|endif
map <silent> <script> <Plug>AM_t| <SID>WS:AlignCtrl mIp0P0=l <Bar><CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_t# <SID>WS:AlignCtrl mIp0P0=l #<CR>:'a,.Align<CR><SID>WE
@ -170,28 +176,29 @@ map <silent> <script> <Plug>AM_t: <SID>WS:AlignCtrl mIp1P1=l :<CR>:'a,.Align<CR
map <silent> <script> <Plug>AM_t; <SID>WS:AlignCtrl mIp0P1=l ;<CR>:'a,.Align<CR>:sil 'y,'zs/\( *\);/;\1/ge<CR><SID>WE
map <silent> <script> <Plug>AM_t< <SID>WS:AlignCtrl mIp0P0=l <<CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_t= <SID>WS:call AlignMaps#Equals()<CR><SID>WE
map <silent> <script> <Plug>AM_ts, <SID>WS:AlignCtrl mIp0P1=l #<CR>:'a,.Align<CR>:sil 'y+1,'z-1s/\(\s*\)#/,\1/ge<CR><SID>WE
map <silent> <script> <Plug>AM_ts, <SID>WS:AlignCtrl mIp0P1=l ,<CR>:'a,.Align<CR>:sil 'y+1,'z-1s/\(\s*\),/,\1/ge<CR><SID>WE
map <silent> <script> <Plug>AM_ts: <SID>WS:AlignCtrl mIp1P1=l :<CR>:'a,.Align<CR>:sil 'y+1,'z-1s/\(\s*\):/:\1/ge<CR><SID>WE
map <silent> <script> <Plug>AM_ts; <SID>WS:AlignCtrl mIp1P1=l ;<CR>:'a,.Align<CR>:sil 'y+1,'z-1s/\(\s*\);/;\1/ge<CR><SID>WE
map <silent> <script> <Plug>AM_ts< <SID>WS:AlignCtrl mIp1P1=l <<CR>:'a,.Align<CR>:sil 'y+1,'z-1s/\(\s*\)</<\1/ge<CR><SID>WE
map <silent> <script> <Plug>AM_ts= <SID>WS:AlignCtrl mIp1P1=l =<CR>:'a,.Align<CR>:sil 'y+1,'z-1s/\(\s*\)=/=\1/ge<CR><SID>WE
map <silent> <script> <Plug>AM_ts, <SID>WS:AlignCtrl mIp0P1=l #\zs<CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_ts, <SID>WS:AlignCtrl mIp0P1=l ,\zs<CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_ts: <SID>WS:AlignCtrl mIp1P1=l :\zs<CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_ts; <SID>WS:AlignCtrl mIp1P1=l ;\zs<CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_ts< <SID>WS:AlignCtrl mIp1P1=l <\zs<CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_ts= <SID>WS:AlignCtrl mIp1P1=l =\zs<CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_w= <SID>WS:'a,'zg/=/s/\s\+\([*/+\-%<Bar>&\~^]\==\)/ \1/e<CR>:'a,'zg/=/s@ \+\([*/+\-%<Bar>&\~^]\)=@\1=@ge<CR>:'a,'zg/=/s/==/\="\<Char-0x0f>\<Char-0x0f>"/ge<CR>:'a,'zg/=/s/!=/\="!\<Char-0x0f>"/ge<CR>'zk:AlignCtrl mWp1P1=l =<CR>:AlignCtrl g =<CR>:'a,'z-1g/=/Align<CR>:'a,'z-1g/=/s@\([*/+\-%<Bar>&\~^!=]\)\( \+\)=@\2\1=@ge<CR>:'a,'z-1g/=/s/\( \+\);/;\1/ge<CR>:'a,'z-1v/^\s*\/[*/]/s/\/[*/]/@&@/e<CR>:'a,'z-1v/^\s*\/[*/]/s/\*\//@&/e<CR>'zk:call AlignMaps#StdAlign(1)<cr>:'y,'zs/^\(\s*\) @/\1/e<CR>:'a,'z-1g/=/s/\xff/=/ge<CR>:'y,'zg/=/s/ @//eg<CR><SID>WE
map <silent> <script> <Plug>AM_t? <SID>WS:AlignCtrl mIp0P0=l ?<CR>:'a,.Align<CR>:.,'zs/ \( *\);/;\1/ge<CR><SID>WE
map <silent> <script> <Plug>AM_t~ <SID>WS:AlignCtrl mIp0P0=l ~<CR>:'a,.Align<CR>:'y,'zs/ \( *\);/;\1/ge<CR><SID>WE
map <silent> <script> <Plug>AM_t@ <SID>WS::call AlignMaps#StdAlign(1)<cr>:<SID>WE
map <silent> <script> <Plug>AM_t@ <SID>WS:call AlignMaps#StdAlign(1)<cr><SID>WE
map <silent> <script> <Plug>AM_tW@ <SID>WS:call AlignMaps#StdAlign(2)<cr><SID>WE
map <silent> <script> <Plug>AM_m= <SID>WS:'a,'zs/\s\+\([*/+\-%<Bar>&\~^]\==\)/ \1/e<CR>:'a,'zs@ \+\([*/+\-%<Bar>&\~^]\)=@\1=@ge<CR>:'a,'zs/==/\="\<Char-0x0f>\<Char-0x0f>"/ge<CR>:'a,'zs/!=/\="!\<Char-0x0f>"/ge<CR>'zk:AlignCtrl mIp1P1=l =<CR>:AlignCtrl g =<CR>:'a,'z-1Align<CR>:'a,'z-1s@\([*/+\-%<Bar>&\~^!=]\)\( \+\)=@\2\1=@ge<CR>:'a,'z-1s/\( \+\);/;\1/ge<CR>:'a,'z-s/%\ze[^=]/ @%@ /e<CR>'zk:call AlignMaps#StdAlign(1)<cr>:'y,'zs/^\(\s*\) @/\1/e<CR>:'a,'z-1s/\xff/=/ge<CR>:'y,'zs/ @//eg<CR><SID>WE
map <silent> <script> <Plug>AM_tab <SID>WS:'a,.s/^\(\t*\)\(.*\)$/\=submatch(1).escape(substitute(submatch(2),'\t',"\<Char-0x0f>",'g'),'\')/<CR>:if &ts == 1<bar>exe "AlignCtrl mI=lp0P0 \<Char-0x0f>"<bar>else<bar>exe "AlignCtrl mI=l \<Char-0x0f>"<bar>endif<CR>:'a,.Align<CR>:exe "'y+1,'z-1s/\<Char-0x0f>/".((&ts == 1)? '\t' : ' ')."/g"<CR><SID>WE
map <silent> <script> <Plug>AM_tab <SID>WS:'a,.s/^\(\t*\)\(.*\)$/\=submatch(1).escape(substitute(submatch(2),'\t',"\<Char-0x0f>",'g'),'\')/<CR>:if &ts == 1<bar>exe "AlignCtrl mI=lp0P0 \<Char-0x0f>"<bar>else<bar>exe "AlignCtrl mI=l"<bar>endif<CR>:'a,.Align <Char-0x0f><CR>:exe "'y+1,'z-1s/\<Char-0x0f>/".((&ts == 1)? '\t' : ' ')."/g"<CR><SID>WE
map <silent> <script> <Plug>AM_tml <SID>WS:AlignCtrl mWp1P0=l \\\@<!\\\s*$<CR>:'a,.Align<CR><SID>WE
map <silent> <script> <Plug>AM_tsp <SID>WS:'a,.s/^\(\s*\)\(.*\)/\=submatch(1).escape(substitute(submatch(2),'\s\+','@','g'),'\')/<CR>:AlignCtrl mI=lp0P0 @<CR>:'a,.Align<CR>:'y+1,'z-1s/@/ /g<CR><SID>WE
map <silent> <script> <Plug>AM_tsq <SID>WS:'a,.AlignReplaceQuotedSpaces<CR>:'a,.s/^\(\s*\)\(.*\)/\=submatch(1).substitute(submatch(2),'\s\+','@','g')/<CR>:AlignCtrl mIp0P0=l @<CR>:'a,.Align<CR>:'y+1,'z-1s/[%@]/ /g<CR><SID>WE
map <silent> <script> <Plug>AM_tsp <SID>WS:keepj 'a,.s/^\(\s*\)\(.*\)/\=submatch(1).escape(substitute(submatch(2),'\s\+','@','g'),'\')/<CR>:AlignCtrl mI=lp0P0 @<CR>:'a,.Align<CR>:keepj 'y+1,'z-1s/@/ /g<CR><SID>WE
map <silent> <script> <Plug>AM_tsq <SID>WS:'a,.AlignReplaceQuotedSpaces<CR>:keepj 'a,.s/^\(\s*\)\(.*\)/\=submatch(1).substitute(submatch(2),'\s\+','@','g')/<CR>:AlignCtrl mIp0P0=l @<CR>:'a,.Align<CR>:keepj 'y+1,'z-1s/[%@]/ /g<CR><SID>WE
map <silent> <script> <Plug>AM_tt <SID>WS:AlignCtrl mIp1P1=l \\\@<!& \\\\<CR>:'a,.Align<CR><SID>WE
" =====================================================================
" Menu Support: {{{1
" ma ..move.. use menu
" v V or ctrl-v ..move.. use menu
if has("menu") && has("gui_running") && &go =~ 'm' && !exists("s:firstmenu")
if has("menu") && has("gui_running") && &go =~# 'm' && !exists("s:firstmenu")
let s:firstmenu= 1
if !exists("g:DrChipTopLvlMenu")
let g:DrChipTopLvlMenu= "DrChip."

View File

@ -3,7 +3,7 @@
" Date: Nov 02, 2008
" GetLatestVimScripts: 294 1 :AutoInstall: Align.vim
" GetLatestVimScripts: 1066 1 :AutoInstall: cecutil.vim
" Copyright: Copyright (C) 1999-2007 Charles E. Campbell, Jr. {{{1
" Copyright: Copyright (C) 1999-2012 Charles E. Campbell, Jr. {{{1
" Permission is hereby granted to use and distribute this code,
" with or without modifications, provided that this copyright
" notice is copied with it. Like anything else that's free,
@ -22,7 +22,7 @@
if &cp || exists("g:loaded_AlignPlugin")
finish
endif
let g:loaded_AlignPlugin = "v35"
let g:loaded_AlignPlugin = "v36"
let s:keepcpo = &cpo
set cpo&vim

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

482
vim/plugin/cecutil.vim Normal file
View File

@ -0,0 +1,482 @@
" cecutil.vim : save/restore window position
" save/restore mark position
" save/restore selected user maps
" Author: Charles E. Campbell, Jr.
" Version: 17
" Date: Sep 04, 2007
"
" Saving Restoring Destroying Marks: {{{1
" call SaveMark(markname) let savemark= SaveMark(markname)
" call RestoreMark(markname) call RestoreMark(savemark)
" call DestroyMark(markname)
" commands: SM RM DM
"
" Saving Restoring Destroying Window Position: {{{1
" call SaveWinPosn() let winposn= SaveWinPosn()
" call RestoreWinPosn() call RestoreWinPosn(winposn)
" \swp : save current window/buffer's position
" \rwp : restore current window/buffer's previous position
" commands: SWP RWP
"
" Saving And Restoring User Maps: {{{1
" call SaveUserMaps(mapmode,maplead,mapchx,suffix)
" call RestoreUserMaps(suffix)
"
" GetLatestVimScripts: 1066 1 :AutoInstall: cecutil.vim
"
" You believe that God is one. You do well. The demons also {{{1
" believe, and shudder. But do you want to know, vain man, that
" faith apart from works is dead? (James 2:19,20 WEB)
" Load Once: {{{1
if &cp || exists("g:loaded_cecutil")
finish
endif
let g:loaded_cecutil = "v17"
let s:keepcpo = &cpo
set cpo&vim
"DechoVarOn
" -----------------------
" Public Interface: {{{1
" -----------------------
" Map Interface: {{{2
if !hasmapto('<Plug>SaveWinPosn')
map <unique> <Leader>swp <Plug>SaveWinPosn
endif
if !hasmapto('<Plug>RestoreWinPosn')
map <unique> <Leader>rwp <Plug>RestoreWinPosn
endif
nmap <silent> <Plug>SaveWinPosn :call SaveWinPosn()<CR>
nmap <silent> <Plug>RestoreWinPosn :call RestoreWinPosn()<CR>
" Command Interface: {{{2
com! -bar -nargs=0 SWP call SaveWinPosn()
com! -bar -nargs=0 RWP call RestoreWinPosn()
com! -bar -nargs=1 SM call SaveMark(<q-args>)
com! -bar -nargs=1 RM call RestoreMark(<q-args>)
com! -bar -nargs=1 DM call DestroyMark(<q-args>)
if v:version < 630
let s:modifier= "sil "
else
let s:modifier= "sil keepj "
endif
" ---------------------------------------------------------------------
" SaveWinPosn: {{{1
" let winposn= SaveWinPosn() will save window position in winposn variable
" call SaveWinPosn() will save window position in b:cecutil_winposn{b:cecutil_iwinposn}
" let winposn= SaveWinPosn(0) will *only* save window position in winposn variable (no stacking done)
fun! SaveWinPosn(...)
" call Dfunc("SaveWinPosn() a:0=".a:0)
if line(".") == 1 && getline(1) == ""
" call Dfunc("SaveWinPosn : empty buffer")
return ""
endif
let so_keep = &so
let siso_keep = &siso
let ss_keep = &ss
set so=0 siso=0 ss=0
let swline = line(".")
let swcol = col(".")
let swwline = winline() - 1
let swwcol = virtcol(".") - wincol()
let savedposn = "call GoWinbufnr(".winbufnr(0).")|silent ".swline
let savedposn = savedposn."|".s:modifier."norm! 0z\<cr>"
if swwline > 0
let savedposn= savedposn.":".s:modifier."norm! ".swwline."\<c-y>\<cr>"
endif
if swwcol > 0
let savedposn= savedposn.":".s:modifier."norm! 0".swwcol."zl\<cr>"
endif
let savedposn = savedposn.":".s:modifier."call cursor(".swline.",".swcol.")\<cr>"
" save window position in
" b:cecutil_winposn_{iwinposn} (stack)
" only when SaveWinPosn() is used
if a:0 == 0
if !exists("b:cecutil_iwinposn")
let b:cecutil_iwinposn= 1
else
let b:cecutil_iwinposn= b:cecutil_iwinposn + 1
endif
" call Decho("saving posn to SWP stack")
let b:cecutil_winposn{b:cecutil_iwinposn}= savedposn
endif
let &so = so_keep
let &siso = siso_keep
let &ss = ss_keep
" if exists("b:cecutil_iwinposn") " Decho
" call Decho("b:cecutil_winpos{".b:cecutil_iwinposn."}[".b:cecutil_winposn{b:cecutil_iwinposn}."]")
" else " Decho
" call Decho("b:cecutil_iwinposn doesn't exist")
" endif " Decho
" call Dret("SaveWinPosn [".savedposn."]")
return savedposn
endfun
" ---------------------------------------------------------------------
" RestoreWinPosn: {{{1
fun! RestoreWinPosn(...)
" call Dfunc("RestoreWinPosn() a:0=".a:0)
" call Decho("getline(1)<".getline(1).">")
" call Decho("line(.)=".line("."))
if line(".") == 1 && getline(1) == ""
" call Dfunc("RestoreWinPosn : empty buffer")
return ""
endif
let so_keep = &so
let siso_keep = &siso
let ss_keep = &ss
set so=0 siso=0 ss=0
if a:0 == 0 || a:1 == ""
" use saved window position in b:cecutil_winposn{b:cecutil_iwinposn} if it exists
if exists("b:cecutil_iwinposn") && exists("b:cecutil_winposn{b:cecutil_iwinposn}")
" call Decho("using stack b:cecutil_winposn{".b:cecutil_iwinposn."}<".b:cecutil_winposn{b:cecutil_iwinposn}.">")
try
exe "silent! ".b:cecutil_winposn{b:cecutil_iwinposn}
catch /^Vim\%((\a\+)\)\=:E749/
" ignore empty buffer error messages
endtry
" normally drop top-of-stack by one
" but while new top-of-stack doesn't exist
" drop top-of-stack index by one again
if b:cecutil_iwinposn >= 1
unlet b:cecutil_winposn{b:cecutil_iwinposn}
let b:cecutil_iwinposn= b:cecutil_iwinposn - 1
while b:cecutil_iwinposn >= 1 && !exists("b:cecutil_winposn{b:cecutil_iwinposn}")
let b:cecutil_iwinposn= b:cecutil_iwinposn - 1
endwhile
if b:cecutil_iwinposn < 1
unlet b:cecutil_iwinposn
endif
endif
else
echohl WarningMsg
echomsg "***warning*** need to SaveWinPosn first!"
echohl None
endif
else " handle input argument
" call Decho("using input a:1<".a:1.">")
" use window position passed to this function
exe "silent ".a:1
" remove a:1 pattern from b:cecutil_winposn{b:cecutil_iwinposn} stack
if exists("b:cecutil_iwinposn")
let jwinposn= b:cecutil_iwinposn
while jwinposn >= 1 " search for a:1 in iwinposn..1
if exists("b:cecutil_winposn{jwinposn}") " if it exists
if a:1 == b:cecutil_winposn{jwinposn} " and the pattern matches
unlet b:cecutil_winposn{jwinposn} " unlet it
if jwinposn == b:cecutil_iwinposn " if at top-of-stack
let b:cecutil_iwinposn= b:cecutil_iwinposn - 1 " drop stacktop by one
endif
endif
endif
let jwinposn= jwinposn - 1
endwhile
endif
endif
" seems to be something odd: vertical motions after RWP
" cause jump to first column. Following fixes that
if wincol() > 1
silent norm! hl
elseif virtcol(".") < virtcol("$")
silent norm! lh
endif
let &so = so_keep
let &siso = siso_keep
let &ss = ss_keep
" call Dret("RestoreWinPosn")
endfun
" ---------------------------------------------------------------------
" GoWinbufnr: go to window holding given buffer (by number) {{{1
" Prefers current window; if its buffer number doesn't match,
" then will try from topleft to bottom right
fun! GoWinbufnr(bufnum)
" call Dfunc("GoWinbufnr(".a:bufnum.")")
if winbufnr(0) == a:bufnum
" call Dret("GoWinbufnr : winbufnr(0)==a:bufnum")
return
endif
winc t
let first=1
while winbufnr(0) != a:bufnum && (first || winnr() != 1)
winc w
let first= 0
endwhile
" call Dret("GoWinbufnr")
endfun
" ---------------------------------------------------------------------
" SaveMark: sets up a string saving a mark position. {{{1
" For example, SaveMark("a")
" Also sets up a global variable, g:savemark_{markname}
fun! SaveMark(markname)
" call Dfunc("SaveMark(markname<".a:markname.">)")
let markname= a:markname
if strpart(markname,0,1) !~ '\a'
let markname= strpart(markname,1,1)
endif
" call Decho("markname=".markname)
let lzkeep = &lz
set lz
if 1 <= line("'".markname) && line("'".markname) <= line("$")
let winposn = SaveWinPosn(0)
exe s:modifier."norm! `".markname
let savemark = SaveWinPosn(0)
let g:savemark_{markname} = savemark
let savemark = markname.savemark
call RestoreWinPosn(winposn)
else
let g:savemark_{markname} = ""
let savemark = ""
endif
let &lz= lzkeep
" call Dret("SaveMark : savemark<".savemark.">")
return savemark
endfun
" ---------------------------------------------------------------------
" RestoreMark: {{{1
" call RestoreMark("a") -or- call RestoreMark(savemark)
fun! RestoreMark(markname)
" call Dfunc("RestoreMark(markname<".a:markname.">)")
if strlen(a:markname) <= 0
" call Dret("RestoreMark : no such mark")
return
endif
let markname= strpart(a:markname,0,1)
if markname !~ '\a'
" handles 'a -> a styles
let markname= strpart(a:markname,1,1)
endif
" call Decho("markname=".markname." strlen(a:markname)=".strlen(a:markname))
let lzkeep = &lz
set lz
let winposn = SaveWinPosn(0)
if strlen(a:markname) <= 2
if exists("g:savemark_{markname}") && strlen(g:savemark_{markname}) != 0
" use global variable g:savemark_{markname}
" call Decho("use savemark list")
call RestoreWinPosn(g:savemark_{markname})
exe "norm! m".markname
endif
else
" markname is a savemark command (string)
" call Decho("use savemark command")
let markcmd= strpart(a:markname,1)
call RestoreWinPosn(markcmd)
exe "norm! m".markname
endif
call RestoreWinPosn(winposn)
let &lz = lzkeep
" call Dret("RestoreMark")
endfun
" ---------------------------------------------------------------------
" DestroyMark: {{{1
" call DestroyMark("a") -- destroys mark
fun! DestroyMark(markname)
" call Dfunc("DestroyMark(markname<".a:markname.">)")
" save options and set to standard values
let reportkeep= &report
let lzkeep = &lz
set lz report=10000
let markname= strpart(a:markname,0,1)
if markname !~ '\a'
" handles 'a -> a styles
let markname= strpart(a:markname,1,1)
endif
" call Decho("markname=".markname)
let curmod = &mod
let winposn = SaveWinPosn(0)
1
let lineone = getline(".")
exe "k".markname
d
put! =lineone
let &mod = curmod
call RestoreWinPosn(winposn)
" restore options to user settings
let &report = reportkeep
let &lz = lzkeep
" call Dret("DestroyMark")
endfun
" ---------------------------------------------------------------------
" QArgSplitter: to avoid \ processing by <f-args>, <q-args> is needed. {{{1
" However, <q-args> doesn't split at all, so this one returns a list
" with splits at all whitespace (only!), plus a leading length-of-list.
" The resulting list: qarglist[0] corresponds to a:0
" qarglist[i] corresponds to a:{i}
fun! QArgSplitter(qarg)
" call Dfunc("QArgSplitter(qarg<".a:qarg.">)")
let qarglist = split(a:qarg)
let qarglistlen = len(qarglist)
let qarglist = insert(qarglist,qarglistlen)
" call Dret("QArgSplitter ".string(qarglist))
return qarglist
endfun
" ---------------------------------------------------------------------
" ListWinPosn:
"fun! ListWinPosn() " Decho
" if !exists("b:cecutil_iwinposn") || b:cecutil_iwinposn == 0 " Decho
" call Decho("nothing on SWP stack") " Decho
" else " Decho
" let jwinposn= b:cecutil_iwinposn " Decho
" while jwinposn >= 1 " Decho
" if exists("b:cecutil_winposn{jwinposn}") " Decho
" call Decho("winposn{".jwinposn."}<".b:cecutil_winposn{jwinposn}.">") " Decho
" else " Decho
" call Decho("winposn{".jwinposn."} -- doesn't exist") " Decho
" endif " Decho
" let jwinposn= jwinposn - 1 " Decho
" endwhile " Decho
" endif " Decho
"endfun " Decho
"com! -nargs=0 LWP call ListWinPosn() " Decho
" ---------------------------------------------------------------------
" SaveUserMaps: this function sets up a script-variable (s:restoremap) {{{1
" which can be used to restore user maps later with
" call RestoreUserMaps()
"
" mapmode - see :help maparg for its list
" ex. "n" = Normal
" If the first letter is u, then unmapping will be done
" ex. "un" = Normal + unmapping
" maplead - see mapchx
" mapchx - "<something>" handled as a single map item.
" ex. "<left>"
" - "string" a string of single letters which are actually
" multiple two-letter maps (using the maplead:
" maplead . each_character_in_string)
" ex. maplead="\" and mapchx="abc" saves user mappings for
" \a, \b, and \c
" Of course, if maplead is "", then for mapchx="abc",
" mappings for a, b, and c are saved.
" - :something handled as a single map item, w/o the ":"
" ex. mapchx= ":abc" will save a mapping for "abc"
" suffix - a string unique to your plugin
" ex. suffix= "DrawIt"
fun! SaveUserMaps(mapmode,maplead,mapchx,suffix)
" call Dfunc("SaveUserMaps(mapmode<".a:mapmode."> maplead<".a:maplead."> mapchx<".a:mapchx."> suffix<".a:suffix.">)")
if !exists("s:restoremap_{a:suffix}")
" initialize restoremap_suffix to null string
let s:restoremap_{a:suffix}= ""
endif
" set up dounmap: if 1, then save and unmap (a:mapmode leads with a "u")
" if 0, save only
if a:mapmode =~ '^u'
let dounmap= 1
let mapmode= strpart(a:mapmode,1)
else
let dounmap= 0
let mapmode= a:mapmode
endif
" save single map :...something...
if strpart(a:mapchx,0,1) == ':'
let amap= strpart(a:mapchx,1)
if amap == "|" || amap == "\<c-v>"
let amap= "\<c-v>".amap
endif
let amap = a:maplead.amap
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|:silent! ".mapmode."unmap ".amap
if maparg(amap,mapmode) != ""
let maprhs = substitute(maparg(amap,mapmode),'|','<bar>','ge')
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|:".mapmode."map ".amap." ".maprhs
endif
if dounmap
exe "silent! ".mapmode."unmap ".amap
endif
" save single map <something>
elseif strpart(a:mapchx,0,1) == '<'
let amap = a:mapchx
if amap == "|" || amap == "\<c-v>"
let amap= "\<c-v>".amap
endif
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|silent! ".mapmode."unmap ".amap
if maparg(a:mapchx,mapmode) != ""
let maprhs = substitute(maparg(amap,mapmode),'|','<bar>','ge')
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|".mapmode."map ".amap." ".maprhs
endif
if dounmap
exe "silent! ".mapmode."unmap ".amap
endif
" save multiple maps
else
let i= 1
while i <= strlen(a:mapchx)
let amap= a:maplead.strpart(a:mapchx,i-1,1)
if amap == "|" || amap == "\<c-v>"
let amap= "\<c-v>".amap
endif
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|silent! ".mapmode."unmap ".amap
if maparg(amap,mapmode) != ""
let maprhs = substitute(maparg(amap,mapmode),'|','<bar>','ge')
let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|".mapmode."map ".amap." ".maprhs
endif
if dounmap
exe "silent! ".mapmode."unmap ".amap
endif
let i= i + 1
endwhile
endif
" call Dret("SaveUserMaps : restoremap_".a:suffix.": ".s:restoremap_{a:suffix})
endfun
" ---------------------------------------------------------------------
" RestoreUserMaps: {{{1
" Used to restore user maps saved by SaveUserMaps()
fun! RestoreUserMaps(suffix)
" call Dfunc("RestoreUserMaps(suffix<".a:suffix.">)")
if exists("s:restoremap_{a:suffix}")
let s:restoremap_{a:suffix}= substitute(s:restoremap_{a:suffix},'|\s*$','','e')
if s:restoremap_{a:suffix} != ""
" call Decho("exe ".s:restoremap_{a:suffix})
exe "silent! ".s:restoremap_{a:suffix}
endif
unlet s:restoremap_{a:suffix}
endif
" call Dret("RestoreUserMaps")
endfun
" ---------------------------------------------------------------------
" Restore: {{{1
let &cpo= s:keepcpo
unlet s:keepcpo
" ---------------------------------------------------------------------
" Modelines: {{{1
" vim: ts=4 fdm=marker

View File

@ -1,11 +1,11 @@
" FILE: plugin/conque_term.vim {{{
" AUTHOR: Nico Raffo <nicoraffo@gmail.com>
" WEBSITE: http://conque.googlecode.com
" MODIFIED: 2010-11-15
" VERSION: 2.0, for Vim 7.0
" MODIFIED: 2011-08-12
" VERSION: 2.2, for Vim 7.0
" LICENSE:
" Conque - Vim terminal/console emulator
" Copyright (C) 2009-2010 Nico Raffo
" Copyright (C) 2009-__YEAR__ Nico Raffo
"
" MIT License
"
@ -28,18 +28,26 @@
" THE SOFTWARE.
" }}}
" See docs/conque_term.txt for help or type :help conque_term
" See docs/conque_term.txt for help or type :help ConqueTerm
if exists('g:ConqueTerm_Loaded') || v:version < 700
finish
endif
" **********************************************************************************************************
" **** CONFIG **********************************************************************************************
" **** CONFIGURATION ***************************************************************************************
" **********************************************************************************************************
" {{{
" Fast mode {{{
" Disables all features which could cause Conque to run slowly, including:
" * Disables terminal colors
" * Disables some multi-byte character handling
if !exists('g:ConqueTerm_FastMode')
let g:ConqueTerm_FastMode = 0
endif " }}}
" automatically go into insert mode when entering buffer {{{
if !exists('g:ConqueTerm_InsertOnEnter')
let g:ConqueTerm_InsertOnEnter = 0
@ -57,22 +65,46 @@ if !exists('g:ConqueTerm_EscKey')
let g:ConqueTerm_EscKey = '<Esc>'
endif " }}}
" Use this key to execute the current file in a split window. {{{
" THIS IS A GLOBAL KEY MAPPING
if !exists('g:ConqueTerm_ExecFileKey')
let g:ConqueTerm_ExecFileKey = '<F11>'
endif " }}}
" Use this key to send the current file contents to conque. {{{
" THIS IS A GLOBAL KEY MAPPING
if !exists('g:ConqueTerm_SendFileKey')
let g:ConqueTerm_SendFileKey = '<F10>'
endif " }}}
" Use this key to send selected text to conque. {{{
" THIS IS A GLOBAL KEY MAPPING
if !exists('g:ConqueTerm_SendVisKey')
let g:ConqueTerm_SendVisKey = '<F9>'
endif " }}}
" Use this key to toggle terminal key mappings. {{{
" Only mapped inside of Conque buffers.
if !exists('g:ConqueTerm_ToggleKey')
let g:ConqueTerm_ToggleKey = '<F8>'
endif " }}}
" Enable color. {{{
" If your apps use a lot of color it will slow down the shell.
" 0 - no terminal colors. You still will see Vim syntax highlighting.
" 1 - limited terminal colors (recommended). Past terminal color history cleared regularly.
" 2 - all terminal colors. Terminal color history never cleared.
if !exists('g:ConqueTerm_Color')
let g:ConqueTerm_Color = 1
endif " }}}
" Color mode. Windows ONLY {{{
" Set this variable to 'conceal' to use Vim's conceal mode for terminal colors.
" This makes colors render much faster, but has some odd baggage.
if !exists('g:ConqueTerm_ColorMode')
let g:ConqueTerm_ColorMode = ''
endif " }}}
" TERM environment setting {{{
if !exists('g:ConqueTerm_TERM')
let g:ConqueTerm_TERM = 'vt100'
@ -117,6 +149,32 @@ if !exists('g:ConqueTerm_SendFunctionKeys')
let g:ConqueTerm_SendFunctionKeys = 0
endif " }}}
" Session support {{{
if !exists('g:ConqueTerm_SessionSupport')
let g:ConqueTerm_SessionSupport = 0
endif " }}}
" hide Conque startup messages {{{
" messages should only appear the first 3 times you start Vim with a new version of Conque
" and include important Conque feature and option descriptions
" TODO - disabled and unused for now
if !exists('g:ConqueTerm_StartMessages')
let g:ConqueTerm_StartMessages = 1
endif " }}}
" Windows character code page {{{
" Leave at 0 to use current environment code page.
" Use 65001 for utf-8, although many console apps do not support it.
if !exists('g:ConqueTerm_CodePage')
let g:ConqueTerm_CodePage = 0
endif " }}}
" InsertCharPre support {{{
" Disable this feature by default, still in Beta
if !exists('g:ConqueTerm_InsertCharPre')
let g:ConqueTerm_InsertCharPre = 0
endif " }}}
" }}}
" **********************************************************************************************************
@ -127,7 +185,7 @@ endif " }}}
let g:ConqueTerm_Loaded = 1
let g:ConqueTerm_Idx = 0
let g:ConqueTerm_Version = 200
let g:ConqueTerm_Version = 210
command! -nargs=+ -complete=shellcmd ConqueTerm call conque_term#open(<q-args>)
command! -nargs=+ -complete=shellcmd ConqueTermSplit call conque_term#open(<q-args>, ['belowright split'])
@ -136,4 +194,20 @@ command! -nargs=+ -complete=shellcmd ConqueTermTab call conque_term#open(<q-args
" }}}
" **********************************************************************************************************
" **** Global Mappings & Autocommands **********************************************************************
" **********************************************************************************************************
" Startup {{{
if exists('g:ConqueTerm_SessionSupport') && g:ConqueTerm_SessionSupport == 1
autocmd SessionLoadPost * call conque_term#resume_session()
endif
if maparg(g:ConqueTerm_ExecFileKey, 'n') == ''
exe 'nnoremap <silent> ' . g:ConqueTerm_ExecFileKey . ' :call conque_term#exec_file()<CR>'
endif
" }}}
" vim:foldmethod=marker

View File

@ -0,0 +1,38 @@
" ---------------------------------------------------------------------
" getscriptPlugin.vim
" Author: Charles E. Campbell, Jr.
" Date: Jan 07, 2008
" Installing: :help glvs-install
" Usage: :help glvs
"
" GetLatestVimScripts: 642 1 :AutoInstall: getscript.vim
"
" (Rom 15:11 WEB) Again, "Praise the Lord, all you Gentiles! Let
" all the peoples praise Him."
" ---------------------------------------------------------------------
" Initialization: {{{1
" if you're sourcing this file, surely you can't be
" expecting vim to be in its vi-compatible mode
if &cp || exists("g:loaded_getscriptPlugin")
if &verbose
echo "GetLatestVimScripts is not vi-compatible; not loaded (you need to set nocp)"
endif
finish
endif
let g:loaded_getscriptPlugin = "v33"
let s:keepcpo = &cpo
set cpo&vim
" ---------------------------------------------------------------------
" Public Interface: {{{1
com! -nargs=0 GetLatestVimScripts call getscript#GetLatestVimScripts()
com! -nargs=0 GetScripts call getscript#GetLatestVimScripts()
silent! com -nargs=0 GLVS call getscript#GetLatestVimScripts()
" ---------------------------------------------------------------------
" Restore Options: {{{1
let &cpo= s:keepcpo
unlet s:keepcpo
" ---------------------------------------------------------------------
" vim: ts=8 sts=2 fdm=marker nowrap

View File

@ -1,78 +0,0 @@
"pydoc.vim: pydoc integration for vim
"performs searches and can display the documentation of python modules
"Author: André Kelpe <fs111 at web dot de>
"http://www.vim.org/scripts/script.php?script_id=910
"This plugin integrates the pydoc into vim. You can view the
"documentation of a module by using :Pydoc foo.bar.baz or search
"a word (uses pydoc -k) in the documentation by typing PydocSearch
"foobar. You can also view the documentation of the word under the
"cursor by pressing <leader>pw or the WORD (see :help WORD) by pressing
"<leader>pW. "This is very useful if you want to jump to a module which was found by
"PydocSearch. To have a browser like feeling you can use u and CTRL-R to
"go back and forward, just like editing normal text.
"If you want to use the script and pydoc is not in your PATH, just put a
"line like
" let g:pydoc_cmd = \"/usr/bin/pydoc" (without the backslash!!)
"in your .vimrc
"pydoc.vim is free software, you can redistribute or modify
"it under the terms of the GNU General Public License Version 2 or any
"later Version (see http://www.gnu.org/copyleft/gpl.html for details).
"Please feel free to contact me.
set switchbuf=useopen
function! ShowPyDoc(name, type)
if !exists('g:pydoc_cmd')
let g:pydoc_cmd = 'pydoc'
endif
if bufnr("__doc__") >0
exe "sb __doc__"
else
exe 'split __doc__'
endif
setlocal noswapfile
set buftype=nofile
setlocal modifiable
normal ggdG
let s:name2 = substitute(a:name, '(.*', '', 'g' )
if a:type==1
execute "silent read ! " g:pydoc_cmd . " " . s:name2
else
execute "silent read ! ".g:pydoc_cmd. " -k " . s:name2
endif
setlocal nomodified
set filetype=man
normal 1G
if !exists('g:pydoc_highlight')
let g:pydoc_highlight = 1
endif
if g:pydoc_highlight ==1
call Highlight(s:name2)
endif
endfunction
function! Highlight(name)
exe "sb __doc__"
set filetype=man
syn on
exe 'syntax keyword pydoc '.s:name2
hi pydoc gui=reverse
endfunction
"mappings
map <leader>pw :call ShowPyDoc('<C-R><C-W>', 1)<CR>
map <leader>pW :call ShowPyDoc('<C-R><C-A>', 1)<CR>
"commands
command -nargs=1 Pydoc :call ShowPyDoc('<args>', 1)
command -nargs=* PydocSearch :call ShowPyDoc('<args>', 0)

196
vim/plugin/python_pydoc.vim Normal file
View File

@ -0,0 +1,196 @@
" Vim ftplugin file
" Language: Python
" Authors: André Kelpe <efeshundertelf at googlemail dot com>
" Romain Chossart <romainchossat at gmail dot com>
" Matthias Vogelgesang
" Ricardo Catalinas Jiménez <jimenezrick at gmail dot com>
" Patches and suggestions from all sorts of fine people
"
" More info and updates at:
"
" http://www.vim.org/scripts/script.php?script_id=910
"
"
" This plugin integrates the Python documentation view and search tool pydoc
" into Vim. It allows you to view the documentation of a Python module or class
" by typing:
"
" :Pydoc foo.bar.baz (e.g. :Pydoc re.compile)
"
" Or search a word (uses pydoc -k) in the documentation by typing:
"
" :PydocSearch foobar (e.g. :PydocSearch socket)
"
" Vim will split the current window to show the Python documentation found by
" pydoc (the buffer will be called '__doc__', Pythonic, isn't it ;-) ). The
" name may cause problems if you have a file with the same name, but usually
" this should not happen.
"
" pydoc.vim also allows you to view the documentation of the 'word' (see :help
" word) under the cursor by pressing <Leader>pw or the 'WORD' (see :help WORD)
" under the cursor by pressing <Leader>pW. This is very useful if you want to
" jump to the docs of a module or class found by 'PydocSearch' or if you want
" to see the docs of a module/class in your source code. Additionally K is
" mapped to show invoke pydoc as well, when you are editing python files.
"
" The script is developed in GitHub at:
"
" http://github.com/fs111/pydoc.vim
"
"
" If you want to use the script and pydoc is not in your PATH, just put a
" line like this in your .vimrc:
"
" let g:pydoc_cmd = '/usr/bin/pydoc'
"
" or more portable
"
" let g:pydoc_cmd = 'python -m pydoc'
"
" If you want to open pydoc files in vertical splits or tabs, give the
" appropriate command in your .vimrc with:
"
" let g:pydoc_open_cmd = 'vsplit'
"
" or
"
" let g:pydoc_open_cmd = 'tabnew'
"
" The script will highlight the search term by default. To disable this behaviour
" put in your .vimrc:
"
" let g:pydoc_highlight=0
"
"
" In order to install pydoc.vim download it from vim.org or clone the repository
" on githubi and put it in your .vim/ftplugin directory. pydoc.vim is also fully
" compatible with pathogen, so cloning the repository into your bundle directory
" is also a valid way to install it. (I do this myself. see
" https://github.com/fs111/dotvim).
"
" pydoc.vim is free software; you can redistribute it and/or
" modify it under the terms of the GNU General Public License
" as published by the Free Software Foundation; either version 2
" of the License, or (at your option) any later version.
"
" Please feel free to contact me and follow me on twitter (@fs111).
" IMPORTANT: We don't use here the `exists("b:did_ftplugin")' guard becase we
" want to let the Python filetype script that comes with Vim to execute as
" normal.
" Don't redefine the functions if this ftplugin has been executed previously
" and before finish create the local mappings in the current buffer
if exists('*s:ShowPyDoc') && g:pydoc_perform_mappings
call s:PerformMappings()
finish
endif
if !exists('g:pydoc_perform_mappings')
let g:pydoc_perform_mappings = 1
endif
if !exists('g:pydoc_highlight')
let g:pydoc_highlight = 1
endif
if !exists('g:pydoc_cmd')
let g:pydoc_cmd = 'pydoc'
endif
if !exists('g:pydoc_open_cmd')
let g:pydoc_open_cmd = 'split'
endif
setlocal switchbuf=useopen
highlight pydoc cterm=reverse gui=reverse
function s:ShowPyDoc(name, type)
if a:name == ''
return
endif
if g:pydoc_open_cmd == 'split'
let l:pydoc_wh = 10
endif
if bufloaded("__doc__")
let l:buf_is_new = 0
if bufname("%") == "__doc__"
" The current buffer is __doc__, thus do not
" recreate nor resize it
let l:pydoc_wh = -1
else
" If the __doc__ buffer is open, jump to it
silent execute "sbuffer" bufnr("__doc__")
let l:pydoc_wh = -1
endif
else
let l:buf_is_new = 1
silent execute g:pydoc_open_cmd '__doc__'
if g:pydoc_perform_mappings
call s:PerformMappings()
endif
endif
setlocal modifiable
setlocal noswapfile
setlocal buftype=nofile
setlocal bufhidden=delete
setlocal syntax=man
silent normal ggdG
" Remove function/method arguments
let s:name2 = substitute(a:name, '(.*', '', 'g' )
" Remove all colons
let s:name2 = substitute(s:name2, ':', '', 'g' )
if a:type == 1
execute "silent read !" g:pydoc_cmd s:name2
else
execute "silent read !" g:pydoc_cmd "-k" s:name2
endif
normal 1G
if exists('l:pydoc_wh') && l:pydoc_wh != -1
execute "silent resize" l:pydoc_wh
end
if g:pydoc_highlight == 1
execute 'syntax match pydoc' "'" . s:name2 . "'"
endif
let l:line = getline(2)
if l:line =~ "^no Python documentation found for.*$"
if l:buf_is_new
execute "bdelete!"
else
normal u
setlocal nomodified
setlocal nomodifiable
endif
redraw
echohl WarningMsg | echo l:line | echohl None
else
setlocal nomodified
setlocal nomodifiable
endif
endfunction
" Mappings
function s:PerformMappings()
nnoremap <silent> <buffer> <Leader>pw :call <SID>ShowPyDoc('<C-R><C-W>', 1)<CR>
nnoremap <silent> <buffer> <Leader>pW :call <SID>ShowPyDoc('<C-R><C-A>', 1)<CR>
nnoremap <silent> <buffer> <Leader>pk :call <SID>ShowPyDoc('<C-R><C-W>', 0)<CR>
nnoremap <silent> <buffer> <Leader>pK :call <SID>ShowPyDoc('<C-R><C-A>', 0)<CR>
" remap the K (or 'help') key
nnoremap <silent> <buffer> K :call <SID>ShowPyDoc(expand("<cword>"), 1)<CR>
endfunction
if g:pydoc_perform_mappings
call s:PerformMappings()
endif
" Commands
command -nargs=1 Pydoc :call s:ShowPyDoc('<args>', 1)
command -nargs=* PydocSearch :call s:ShowPyDoc('<args>', 0)

File diff suppressed because it is too large Load Diff

View File

@ -2,10 +2,9 @@
"
" BZR extension for VCSCommand.
"
" Version: VCS development
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" License:
" Copyright (c) 2009 Bob Hiestand
" Copyright (c) Bob Hiestand
"
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to
@ -44,7 +43,9 @@ if v:version < 700
finish
endif
if !exists('g:loaded_VCSCommand')
runtime plugin/vcscommand.vim
endif
if !executable(VCSCommandGetOption('VCSCommandBZRExec', 'bzr'))
" BZR is not installed
@ -64,7 +65,7 @@ let s:bzrFunctions = {}
" Returns the executable used to invoke bzr suitable for use in a shell
" command.
function! s:Executable()
return shellescape(VCSCommandGetOption('VCSCommandBZRExec', 'bzr'))
return VCSCommandGetOption('VCSCommandBZRExec', 'bzr')
endfunction
" Function: s:DoCommand(cmd, cmdName, statusText) {{{2
@ -84,7 +85,13 @@ endfunction
" Function: s:bzrFunctions.Identify(buffer) {{{2
function! s:bzrFunctions.Identify(buffer)
let fileName = resolve(bufname(a:buffer))
let l:save_bzr_log=$BZR_LOG
try
let $BZR_LOG=has("win32") || has("win95") || has("win64") || has("win16") ? "nul" : "/dev/null"
let statusText = s:VCSCommandUtility.system(s:Executable() . ' info -- "' . fileName . '"')
finally
let $BZR_LOG=l:save_bzr_log
endtry
if(v:shell_error)
return 0
else
@ -100,7 +107,7 @@ endfunction
" Function: s:bzrFunctions.Annotate(argList) {{{2
function! s:bzrFunctions.Annotate(argList)
if len(a:argList) == 0
if &filetype == 'BZRAnnotate'
if &filetype ==? 'bzrannotate'
" Perform annotation of the version indicated by the current line.
let caption = matchstr(getline('.'),'\v^\s+\zs\d+')
let options = ' -r' . caption
@ -118,8 +125,7 @@ function! s:bzrFunctions.Annotate(argList)
let resultBuffer = s:DoCommand('blame' . options, 'annotate', caption, {})
if resultBuffer > 0
normal 1G2dd
set filetype=BZRAnnotate
normal! 1G2dd
endif
return resultBuffer
endfunction
@ -151,13 +157,7 @@ function! s:bzrFunctions.Diff(argList)
let revOptions = a:argList
endif
let resultBuffer = s:DoCommand(join(['diff'] + revOptions), 'diff', caption, {'allowNonZeroExit': 1})
if resultBuffer > 0
set filetype=diff
else
echomsg 'No differences found'
endif
return resultBuffer
return s:DoCommand(join(['diff'] + revOptions), 'diff', caption, {'allowNonZeroExit': 1})
endfunction
" Function: s:bzrFunctions.GetBufferInfo() {{{2
@ -234,17 +234,13 @@ function! s:bzrFunctions.Review(argList)
let versionOption = ' -r ' . versiontag . ' '
endif
let resultBuffer = s:DoCommand('cat' . versionOption, 'review', versiontag, {})
if resultBuffer > 0
let &filetype=getbufvar(b:VCSCommandOriginalBuffer, '&filetype')
endif
return resultBuffer
return s:DoCommand('cat' . versionOption, 'review', versiontag, {})
endfunction
" Function: s:bzrFunctions.Status(argList) {{{2
function! s:bzrFunctions.Status(argList)
let options = ['-S']
if len(a:argList) == 0
if len(a:argList) != 0
let options = a:argList
endif
return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {})

View File

@ -5,7 +5,7 @@
"
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" License:
" Copyright (c) 2008 Bob Hiestand
" Copyright (c) Bob Hiestand
"
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to
@ -204,6 +204,10 @@
" This variable, if set to a non-zero value, prevents the default command
" mappings from being set for commands specific to an individual VCS.
"
" VCSCommandDisableMenu
" This variable, if set to a non-zero value, prevents the default command
" menu from being set.
"
" VCSCommandEdit
" This variable controls whether to split the current window to display a
" scratch buffer ('split'), or to display it in the current buffer ('edit').
@ -226,6 +230,12 @@
" This allows customization of the mapping space used by the vcscommand
" shortcuts.
"
" VCSCommandMenuPriority
" This variable, if set, overrides the default menu priority '' (empty)
"
" VCSCommandMenuRoot
" This variable, if set, overrides the default menu root 'Plugin.VCS'
"
" VCSCommandResultBufferNameExtension
" This variable, if set to a non-blank value, is appended to the name of the
" VCS command output buffers. For example, '.vcs'. Using this option may
@ -262,6 +272,13 @@
" full file name of a given buffer. If it matches, the second element will
" be used as the VCS type.
"
" VCSCommandVCSTypePreference
" This variable allows the VCS type detection to be weighted towards a
" specific VCS, in case more than one potential VCS is detected as useable.
" The format of the variable is either a list or a space-separated string
" containing the ordered-by-preference abbreviations of the preferred VCS
" types.
"
" Event documentation {{{2
" For additional customization, VCSCommand.vim uses User event autocommand
" hooks. Each event is in the VCSCommand group, and different patterns
@ -340,21 +357,12 @@ let s:VCSCommandUtility = {}
" plugin-specific information: {vcs -> [script, {command -> function}, {key -> mapping}]}
let s:plugins = {}
" temporary values of overridden configuration variables
let s:optionOverrides = {}
" Stack of dictionaries representing nested options
let s:executionContext = []
" state flag used to vary behavior of certain automated actions
let s:isEditFileRunning = 0
" commands needed to restore diff buffers to their original state
unlet! s:vimDiffRestoreCmd
" original buffer currently reflected in vimdiff windows
unlet! s:vimDiffSourceBuffer
"
unlet! s:vimDiffScratchList
" Section: Utility functions {{{1
" Function: s:ReportError(mapping) {{{2
@ -365,7 +373,7 @@ function! s:ReportError(error)
echohl WarningMsg|echomsg 'VCSCommand: ' . a:error|echohl None
endfunction
" Function s:VCSCommandUtility.system(...) {{{2
" Function: s:VCSCommandUtility.system(...) {{{2
" Replacement for system() function. This version protects the quoting in the
" command line on Windows systems.
@ -375,12 +383,58 @@ function! s:VCSCommandUtility.system(...)
set sxq=\"
endif
try
return call('system', a:000)
let output = call('system', a:000)
if exists('*iconv') && has('multi_byte')
if(strlen(&tenc) && &tenc != &enc)
let output = iconv(output, &tenc, &enc)
else
let originalBuffer = VCSCommandGetOriginalBuffer(VCSCommandGetOption('VCSCommandEncodeAsFile', 0))
if originalBuffer
let fenc = getbufvar(originalBuffer, '&fenc')
if fenc != &enc
let output = iconv(output, fenc, &enc)
endif
endif
endif
endif
finally
if exists("save_sxq")
let &sxq = save_sxq
endif
endtry
return output
endfunction
" Function: s:VCSCommandUtility.addMenuItem(shortcut, command) {{{2
" Adds the given menu item.
function! s:VCSCommandUtility.addMenuItem(shortcut, command)
if s:menuEnabled
exe 'amenu <silent> '.s:menuPriority.' '.s:menuRoot.'.'.a:shortcut.' '.a:command
endif
endfunction
" Function: s:VCSCommandUtility.pushContext(context) {{{2
" Adds a dictionary containing current options to the stack.
function! s:VCSCommandUtility.pushContext(context)
call insert(s:executionContext, a:context)
endfunction
" Function: s:VCSCommandUtility.popContext() {{{2
" Removes a dictionary containing current options from the stack.
function! s:VCSCommandUtility.popContext()
call remove(s:executionContext, 0)
endfunction
" Function: s:ClearMenu() {{{2
" Removes all VCSCommand menu items
function! s:ClearMenu()
if s:menuEnabled
execute 'aunmenu' s:menuRoot
endif
endfunction
" Function: s:CreateMapping(shortcut, expansion, display) {{{2
@ -416,7 +470,7 @@ function! s:ExecuteExtensionMapping(mapping)
if !has_key(s:plugins[vcsType][2], a:mapping)
throw 'This extended mapping is not defined for ' . vcsType
endif
silent execute 'normal' ':' . s:plugins[vcsType][2][a:mapping] . "\<CR>"
silent execute 'normal!' ':' . s:plugins[vcsType][2][a:mapping] . "\<CR>"
endfunction
" Function: s:ExecuteVCSCommand(command, argList) {{{2
@ -469,7 +523,7 @@ function! s:GenerateResultBufferName(command, originalBuffer, vcsType, statusTex
let bufferName .= ' ' . fileName
let counter = 0
let versionedBufferName = bufferName
while buflisted(versionedBufferName)
while bufexists(versionedBufferName)
let counter += 1
let versionedBufferName = bufferName . ' (' . counter . ')'
endwhile
@ -489,7 +543,7 @@ function! s:GenerateResultBufferNameWithExtension(command, originalBuffer, vcsTy
let bufferName .= ' ' . fileName . VCSCommandGetOption('VCSCommandResultBufferNameExtension', '.vcs')
let counter = 0
let versionedBufferName = bufferName
while buflisted(versionedBufferName)
while bufexists(versionedBufferName)
let counter += 1
let versionedBufferName = '(' . counter . ') ' . bufferName
endwhile
@ -524,6 +578,64 @@ function! s:EditFile(command, originalBuffer, statusText)
endtry
endfunction
" Function: s:IdentifyVCSType() {{{2
" This function implements the non-cached identification strategy for
" VcsCommandGetVCSType().
"
" Returns: VCS type name identified for the given buffer; an exception is
" thrown in case no type can be identified.
function! s:IdentifyVCSType(buffer)
if exists("g:VCSCommandVCSTypeOverride")
let fullpath = fnamemodify(bufname(a:buffer), ':p')
for [path, vcsType] in g:VCSCommandVCSTypeOverride
if match(fullpath, path) > -1
return vcsType
endif
endfor
endif
let matches = []
let exactMatch = ''
let exactMatchCount = 0
for vcsType in keys(s:plugins)
let identified = s:plugins[vcsType][1].Identify(a:buffer)
if identified
if identified == g:VCSCOMMAND_IDENTIFY_EXACT
let exactMatch = vcsType
let exactMatchCount += 1
endif
call add(matches, [vcsType, identified])
endif
endfor
if len(matches) == 1
return matches[0][0]
elseif len(matches) == 0
throw 'No suitable plugin'
else
let preferences = VCSCommandGetOption("VCSCommandVCSTypePreference", [])
if len(preferences) > 0
if type(preferences) == 1
let listPreferences = split(preferences, '\W\+')
unlet preferences
let preferences = listPreferences
endif
for preferred in preferences
for [vcsType, identified] in matches
if vcsType ==? preferred
return vcsType
endif
endfor
endfor
endif
if exactMatchCount == 1
return exactMatch
endif
throw 'can''t identify VCS type for current buffer due to too many matching VCS: ' . join(map(matches, 'v:val[0]'))
endif
endfunction
" Function: s:SetupScratchBuffer(command, vcsType, originalBuffer, statusText) {{{2
" Creates convenience buffer variables and the name of a vcscommand result
" buffer.
@ -548,7 +660,7 @@ function! s:SetupScratchBuffer(command, vcsType, originalBuffer, statusText)
setlocal buftype=nofile
setlocal noswapfile
let &filetype = a:vcsType . a:command
let &filetype = tolower(a:vcsType . a:command)
if VCSCommandGetOption('VCSCommandDeleteOnHide', 0)
setlocal bufhidden=delete
@ -604,21 +716,6 @@ function! s:MarkOrigBufferForSetup(buffer)
return a:buffer
endfunction
" Function: s:OverrideOption(option, [value]) {{{2
" Provides a temporary override for the given VCS option. If no value is
" passed, the override is disabled.
function! s:OverrideOption(option, ...)
if a:0 == 0
call remove(s:optionOverrides[a:option], -1)
else
if !has_key(s:optionOverrides, a:option)
let s:optionOverrides[a:option] = []
endif
call add(s:optionOverrides[a:option], a:1)
endif
endfunction
" Function: s:WipeoutCommandBuffers() {{{2
" Clears all current VCS output buffers of the specified type for a given source.
@ -642,30 +739,30 @@ endfunction
function! s:VimDiffRestore(vimDiffBuff)
let s:isEditFileRunning += 1
try
if exists('s:vimDiffSourceBuffer')
if a:vimDiffBuff == s:vimDiffSourceBuffer
if exists('t:vcsCommandVimDiffSourceBuffer')
if a:vimDiffBuff == t:vcsCommandVimDiffSourceBuffer
" Original file is being removed.
unlet! s:vimDiffSourceBuffer
unlet! s:vimDiffRestoreCmd
unlet! s:vimDiffScratchList
unlet! t:vcsCommandVimDiffSourceBuffer
unlet! t:vcsCommandVimDiffRestoreCmd
unlet! t:vcsCommandVimDiffScratchList
else
let index = index(s:vimDiffScratchList, a:vimDiffBuff)
let index = index(t:vcsCommandVimDiffScratchList, a:vimDiffBuff)
if index >= 0
call remove(s:vimDiffScratchList, index)
if len(s:vimDiffScratchList) == 0
if exists('s:vimDiffRestoreCmd')
call remove(t:vcsCommandVimDiffScratchList, index)
if len(t:vcsCommandVimDiffScratchList) == 0
if exists('t:vcsCommandVimDiffRestoreCmd')
" All scratch buffers are gone, reset the original.
" Only restore if the source buffer is still in Diff mode
let sourceWinNR = bufwinnr(s:vimDiffSourceBuffer)
let sourceWinNR = bufwinnr(t:vcsCommandVimDiffSourceBuffer)
if sourceWinNR != -1
" The buffer is visible in at least one window
let currentWinNR = winnr()
while winbufnr(sourceWinNR) != -1
if winbufnr(sourceWinNR) == s:vimDiffSourceBuffer
if winbufnr(sourceWinNR) == t:vcsCommandVimDiffSourceBuffer
execute sourceWinNR . 'wincmd w'
if getwinvar(0, '&diff')
execute s:vimDiffRestoreCmd
execute t:vcsCommandVimDiffRestoreCmd
endif
endif
let sourceWinNR = sourceWinNR + 1
@ -675,18 +772,18 @@ function! s:VimDiffRestore(vimDiffBuff)
" The buffer is hidden. It must be visible in order to set the
" diff option.
let currentBufNR = bufnr('')
execute 'hide buffer' s:vimDiffSourceBuffer
execute 'hide buffer' t:vcsCommandVimDiffSourceBuffer
if getwinvar(0, '&diff')
execute s:vimDiffRestoreCmd
execute t:vcsCommandVimDiffRestoreCmd
endif
execute 'hide buffer' currentBufNR
endif
unlet s:vimDiffRestoreCmd
unlet t:vcsCommandVimDiffRestoreCmd
endif
" All buffers are gone.
unlet s:vimDiffSourceBuffer
unlet s:vimDiffScratchList
unlet t:vcsCommandVimDiffSourceBuffer
unlet t:vcsCommandVimDiffScratchList
endif
endif
endif
@ -700,7 +797,12 @@ endfunction
" Function: s:VCSAnnotate(...) {{{2
function! s:VCSAnnotate(bang, ...)
call s:VCSCommandUtility.pushContext({'VCSCommandEncodeAsFile': bufnr('%')})
try
let line = line('.')
let currentBuffer = bufnr('%')
let originalBuffer = VCSCommandGetOriginalBuffer(currentBuffer)
let annotateBuffer = s:ExecuteVCSCommand('Annotate', a:000)
if annotateBuffer == -1
return -1
@ -716,22 +818,50 @@ function! s:VCSAnnotate(bang, ...)
if splitRegex == ''
return annotateBuffer
endif
let originalBuffer = VCSCommandGetOriginalBuffer(annotateBuffer)
wincmd J
let originalFileType = getbufvar(originalBuffer, '&ft')
let annotateFileType = getbufvar(annotateBuffer, '&ft')
execute "normal 0zR\<c-v>G/" . splitRegex . "/e\<cr>d"
let saveselection = &selection
set selection=inclusive
try
execute "normal! 0zR\<c-v>G/" . splitRegex . "/e\<cr>d"
finally
let &selection = saveselection
endtry
call setbufvar('%', '&filetype', getbufvar(originalBuffer, '&filetype'))
set scrollbind
leftabove vert new
normal 0P
execute "normal" . col('$') . "\<c-w>|"
normal! 0P
execute "normal!" . (col('$') + (&number ? &numberwidth : 0)). "\<c-w>|"
call s:SetupScratchBuffer('annotate', vcsType, originalBuffer, 'header')
wincmd l
endif
if currentBuffer == originalBuffer
" Starting from the original source buffer, so the
" current line is relevant.
if a:0 == 0
" No argument list means that we're annotating
" the current version, so jumping to the same
" line is the expected action.
execute "normal!" line . 'G'
if has('folding')
" The execution of the buffer created autocommand
" re-folds the buffer. Display the current line
" unfolded.
normal! zv
endif
endif
endif
return annotateBuffer
catch
call s:ReportError(v:exception)
return -1
finally
call s:VCSCommandUtility.popContext()
endtry
endfunction
@ -773,6 +903,7 @@ function! s:VCSCommit(bang, message)
silent put ='VCS: ----------------------------------------------------------------------'
$
setlocal nomodified
silent do VCSCommand User VCSBufferCreated
catch
call s:ReportError(v:exception)
return -1
@ -797,10 +928,12 @@ endfunction
" Function: s:VCSFinishCommit(logMessageList, originalBuffer) {{{2
function! s:VCSFinishCommit(logMessageList, originalBuffer)
let shellSlashBak = &shellslash
try
set shellslash
let messageFileName = tempname()
if exists('*iconv') && has('multi_byte')
if(strlen(&tenc) && &tenc != &enc)
call map(a:logMessageList, 'iconv(v:val, &enc, &tenc)')
endif
endif
call writefile(a:logMessageList, messageFileName)
try
let resultBuffer = s:ExecuteVCSCommand('Commit', [messageFileName])
@ -811,9 +944,6 @@ function! s:VCSFinishCommit(logMessageList, originalBuffer)
finally
call delete(messageFileName)
endtry
finally
let &shellslash = shellSlashBak
endtry
endfunction
" Function: s:VCSGotoOriginal(bang) {{{2
@ -839,6 +969,34 @@ function! s:VCSGotoOriginal(bang)
endif
endfunction
function! s:VCSDiff(...) "{{{2
call s:VCSCommandUtility.pushContext({'VCSCommandEncodeAsFile': bufnr('%')})
try
let resultBuffer = s:ExecuteVCSCommand('Diff', a:000)
if resultBuffer > 0
let &filetype = 'diff'
elseif resultBuffer == 0
echomsg 'No differences found'
endif
return resultBuffer
finally
call s:VCSCommandUtility.popContext()
endtry
endfunction
function! s:VCSReview(...) "{{{2
call s:VCSCommandUtility.pushContext({'VCSCommandEncodeAsFile': bufnr('%')})
try
let resultBuffer = s:ExecuteVCSCommand('Review', a:000)
if resultBuffer > 0
let &filetype = getbufvar(b:VCSCommandOriginalBuffer, '&filetype')
endif
return resultBuffer
finally
call s:VCSCommandUtility.popContext()
endtry
endfunction
" Function: s:VCSVimDiff(...) {{{2
function! s:VCSVimDiff(...)
try
@ -852,9 +1010,9 @@ function! s:VCSVimDiff(...)
" If there's already a VimDiff'ed window, restore it.
" There may only be one VCSVimDiff original window at a time.
if exists('s:vimDiffSourceBuffer') && s:vimDiffSourceBuffer != originalBuffer
if exists('t:vcsCommandVimDiffSourceBuffer') && t:vcsCommandVimDiffSourceBuffer != originalBuffer
" Clear the existing vimdiff setup by removing the result buffers.
call s:WipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff')
call s:WipeoutCommandBuffers(t:vcsCommandVimDiffSourceBuffer, 'vimdiff')
endif
let orientation = &diffopt =~ 'horizontal' ? 'horizontal' : 'vertical'
@ -864,23 +1022,23 @@ function! s:VCSVimDiff(...)
" Split and diff
if(a:0 == 2)
" Reset the vimdiff system, as 2 explicit versions were provided.
if exists('s:vimDiffSourceBuffer')
call s:WipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff')
if exists('t:vcsCommandVimDiffSourceBuffer')
call s:WipeoutCommandBuffers(t:vcsCommandVimDiffSourceBuffer, 'vimdiff')
endif
let resultBuffer = s:plugins[vcsType][1].Review([a:1])
let resultBuffer = s:VCSReview(a:1)
if resultBuffer < 0
echomsg 'Can''t open revision ' . a:1
return resultBuffer
endif
let b:VCSCommandCommand = 'vimdiff'
diffthis
let s:vimDiffScratchList = [resultBuffer]
let t:vcsCommandVimDiffScratchList = [resultBuffer]
" If no split method is defined, cheat, and set it to vertical.
call s:VCSCommandUtility.pushContext({'VCSCommandSplit': orientation})
try
call s:OverrideOption('VCSCommandSplit', orientation)
let resultBuffer = s:plugins[vcsType][1].Review([a:2])
let resultBuffer = s:VCSReview(a:2)
finally
call s:OverrideOption('VCSCommandSplit')
call s:VCSCommandUtility.popContext()
endtry
if resultBuffer < 0
echomsg 'Can''t open revision ' . a:1
@ -888,24 +1046,18 @@ function! s:VCSVimDiff(...)
endif
let b:VCSCommandCommand = 'vimdiff'
diffthis
let s:vimDiffScratchList += [resultBuffer]
let t:vcsCommandVimDiffScratchList += [resultBuffer]
else
" Add new buffer
call s:OverrideOption('VCSCommandEdit', 'split')
try
" Force splitting behavior, otherwise why use vimdiff?
call s:OverrideOption('VCSCommandSplit', orientation)
" Add new buffer. Force splitting behavior, otherwise why use vimdiff?
call s:VCSCommandUtility.pushContext({'VCSCommandEdit': 'split', 'VCSCommandSplit': orientation})
try
if(a:0 == 0)
let resultBuffer = s:plugins[vcsType][1].Review([])
let resultBuffer = s:VCSReview()
else
let resultBuffer = s:plugins[vcsType][1].Review([a:1])
let resultBuffer = s:VCSReview(a:1)
endif
finally
call s:OverrideOption('VCSCommandSplit')
endtry
finally
call s:OverrideOption('VCSCommandEdit')
call s:VCSCommandUtility.popContext()
endtry
if resultBuffer < 0
echomsg 'Can''t open current revision'
@ -914,16 +1066,16 @@ function! s:VCSVimDiff(...)
let b:VCSCommandCommand = 'vimdiff'
diffthis
if !exists('s:vimDiffSourceBuffer')
if !exists('t:vcsCommandVimDiffSourceBuffer')
" New instance of vimdiff.
let s:vimDiffScratchList = [resultBuffer]
let t:vcsCommandVimDiffScratchList = [resultBuffer]
" This could have been invoked on a VCS result buffer, not the
" original buffer.
wincmd W
execute 'buffer' originalBuffer
" Store info for later original buffer restore
let s:vimDiffRestoreCmd =
let t:vcsCommandVimDiffRestoreCmd =
\ 'call setbufvar('.originalBuffer.', ''&diff'', '.getbufvar(originalBuffer, '&diff').')'
\ . '|call setbufvar('.originalBuffer.', ''&foldcolumn'', '.getbufvar(originalBuffer, '&foldcolumn').')'
\ . '|call setbufvar('.originalBuffer.', ''&foldenable'', '.getbufvar(originalBuffer, '&foldenable').')'
@ -931,16 +1083,19 @@ function! s:VCSVimDiff(...)
\ . '|call setbufvar('.originalBuffer.', ''&foldlevel'', '''.getbufvar(originalBuffer, '&foldlevel').''')'
\ . '|call setbufvar('.originalBuffer.', ''&scrollbind'', '.getbufvar(originalBuffer, '&scrollbind').')'
\ . '|call setbufvar('.originalBuffer.', ''&wrap'', '.getbufvar(originalBuffer, '&wrap').')'
\ . '|if &foldmethod==''manual''|execute ''normal zE''|endif'
if has('cursorbind')
let t:vcsCommandVimDiffRestoreCmd .= '|call setbufvar('.originalBuffer.', ''&cursorbind'', '.getbufvar(originalBuffer, '&cursorbind').')'
endif
let t:vcsCommandVimDiffRestoreCmd .= '|if &foldmethod==''manual''|execute ''normal! zE''|endif'
diffthis
wincmd w
else
" Adding a window to an existing vimdiff
let s:vimDiffScratchList += [resultBuffer]
let t:vcsCommandVimDiffScratchList += [resultBuffer]
endif
endif
let s:vimDiffSourceBuffer = originalBuffer
let t:vcsCommandVimDiffSourceBuffer = originalBuffer
" Avoid executing the modeline in the current buffer after the autocommand.
@ -965,49 +1120,31 @@ endfunction
" Section: Public functions {{{1
" Function: VCSCommandGetVCSType() {{{2
" Sets the b:VCSCommandVCSType variable in the given buffer to the
" appropriate source control system name.
" This function sets the b:VCSCommandVCSType variable in the given buffer to the
" appropriate source control system name and returns the same name.
"
" This uses the Identify extension function to test the buffer. If the
" Identify function returns VCSCOMMAND_IDENTIFY_EXACT, the match is considered
" exact. If the Identify function returns VCSCOMMAND_IDENTIFY_INEXACT, the
" match is considered inexact, and is only applied if no exact match is found.
" Multiple inexact matches is currently considered an error.
" Returns: VCS type name identified for the given buffer. An exception is
" thrown if no type can be identified.
"
" Rules for determining type:
" 1. use previously-cached value
" 2. use value from 'VCSCommandVCSTypeOverride'
" 3. use single match
" 4. use first matching value from 'VCSCommandTypePreference'
" 5. use single exact match
" 6. error if multiple matching types
" 7. error if no matching types
function! VCSCommandGetVCSType(buffer)
let vcsType = VCSCommandGetOption('VCSCommandVCSTypeExplicitOverride', '')
if len(vcsType) == 0
let vcsType = getbufvar(a:buffer, 'VCSCommandVCSType')
if strlen(vcsType) > 0
return vcsType
endif
if exists("g:VCSCommandVCSTypeOverride")
let fullpath = fnamemodify(bufname(a:buffer), ':p')
for [path, vcsType] in g:VCSCommandVCSTypeOverride
if match(fullpath, path) > -1
if strlen(vcsType) == 0
let vcsType = s:IdentifyVCSType(a:buffer)
call setbufvar(a:buffer, 'VCSCommandVCSType', vcsType)
endif
endif
return vcsType
endif
endfor
endif
let matches = []
for vcsType in keys(s:plugins)
let identified = s:plugins[vcsType][1].Identify(a:buffer)
if identified
if identified == g:VCSCOMMAND_IDENTIFY_EXACT
let matches = [vcsType]
break
else
let matches += [vcsType]
endif
endif
endfor
if len(matches) == 1
call setbufvar(a:buffer, 'VCSCommandVCSType', matches[0])
return matches[0]
elseif len(matches) == 0
throw 'No suitable plugin'
else
throw 'Too many matching VCS: ' . join(matches)
endif
endfunction
" Function: VCSCommandChdir(directory) {{{2
@ -1018,7 +1155,11 @@ function! VCSCommandChdir(directory)
if exists("*haslocaldir") && haslocaldir()
let command = 'lcd'
endif
if exists("*fnameescape")
execute command fnameescape(a:directory)
else
execute command escape(a:directory, ' ')
endif
endfunction
" Function: VCSCommandChangeToCurrentFileDir() {{{2
@ -1058,6 +1199,7 @@ endfunction
function! VCSCommandRegisterModule(name, path, commandMap, mappingMap)
let s:plugins[a:name] = [a:path, a:commandMap, a:mappingMap]
if !empty(a:mappingMap)
\ && !exists("g:no_plugin_maps")
\ && !VCSCommandGetOption('VCSCommandDisableMappings', 0)
\ && !VCSCommandGetOption('VCSCommandDisableExtensionMappings', 0)
for shortcut in keys(a:mappingMap)
@ -1105,7 +1247,7 @@ function! VCSCommandDoCommand(cmd, cmdName, statusText, options)
if match(a:cmd, '<VCSCOMMANDFILE>') > 0
let fullCmd = substitute(a:cmd, '<VCSCOMMANDFILE>', fileName, 'g')
else
let fullCmd = a:cmd . ' -- "' . fileName . '"'
let fullCmd = a:cmd . ' -- ' . shellescape(fileName)
endif
" Change to the directory of the current buffer. This is done for CVS, but
@ -1152,7 +1294,7 @@ function! VCSCommandDoCommand(cmd, cmdName, statusText, options)
" within a fold, but I prefer to simply unfold the result buffer altogether.
if has('folding')
normal zR
normal! zR
endif
$d
@ -1169,9 +1311,12 @@ endfunction
" searched in the window, buffer, then global spaces.
function! VCSCommandGetOption(name, default)
if has_key(s:optionOverrides, a:name) && len(s:optionOverrides[a:name]) > 0
return s:optionOverrides[a:name][-1]
elseif exists('w:' . a:name)
for context in s:executionContext
if has_key(context, a:name)
return context[a:name]
endif
endfor
if exists('w:' . a:name)
return w:{a:name}
elseif exists('b:' . a:name)
return b:{a:name}
@ -1229,6 +1374,14 @@ function! VCSCommandGetStatusLine()
endif
endfunction
function! VCSCommandSetVCSType(type)
if exists('b:VCSCommandBufferSetup')
unlet b:VCSCommandBufferSetup
endif
let b:VCSCommandVCSType = a:type
call s:SetupBuffer()
endfunction
" Section: Command definitions {{{1
" Section: Primary commands {{{2
com! -nargs=* VCSAdd call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Add', [<f-args>]))
@ -1236,14 +1389,14 @@ com! -nargs=* -bang VCSAnnotate call s:VCSAnnotate(<q-bang>, <f-args>)
com! -nargs=* -bang VCSBlame call s:VCSAnnotate(<q-bang>, <f-args>)
com! -nargs=? -bang VCSCommit call s:VCSCommit(<q-bang>, <q-args>)
com! -nargs=* VCSDelete call s:ExecuteVCSCommand('Delete', [<f-args>])
com! -nargs=* VCSDiff call s:ExecuteVCSCommand('Diff', [<f-args>])
com! -nargs=* VCSDiff call s:VCSDiff(<f-args>)
com! -nargs=0 -bang VCSGotoOriginal call s:VCSGotoOriginal(<q-bang>)
com! -nargs=* VCSInfo call s:ExecuteVCSCommand('Info', [<f-args>])
com! -nargs=* VCSLock call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Lock', [<f-args>]))
com! -nargs=* VCSLog call s:ExecuteVCSCommand('Log', [<f-args>])
com! -nargs=* VCSRemove call s:ExecuteVCSCommand('Delete', [<f-args>])
com! -nargs=0 VCSRevert call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Revert', []))
com! -nargs=? VCSReview call s:ExecuteVCSCommand('Review', [<f-args>])
com! -nargs=? VCSReview call s:VCSReview(<f-args>)
com! -nargs=* VCSStatus call s:ExecuteVCSCommand('Status', [<f-args>])
com! -nargs=* VCSUnlock call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Unlock', [<f-args>]))
com! -nargs=0 VCSUpdate call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Update', []))
@ -1254,9 +1407,10 @@ com! VCSCommandDisableBufferSetup call VCSCommandDisableBufferSetup()
com! VCSCommandEnableBufferSetup call VCSCommandEnableBufferSetup()
" Allow reloading VCSCommand.vim
com! VCSReload let savedPlugins = s:plugins|let s:plugins = {}|aunmenu Plugin.VCS|unlet! g:loaded_VCSCommand|runtime plugin/vcscommand.vim|for plugin in values(savedPlugins)|execute 'source' plugin[0]|endfor|unlet savedPlugins
com! VCSReload let savedPlugins = s:plugins|let s:plugins = {}|call s:ClearMenu()|unlet! g:loaded_VCSCommand|runtime plugin/vcscommand.vim|for plugin in values(savedPlugins)|execute 'source' plugin[0]|endfor|unlet savedPlugins
" Section: Plugin command mappings {{{1
if !exists("no_plugin_maps")
nnoremap <silent> <Plug>VCSAdd :VCSAdd<CR>
nnoremap <silent> <Plug>VCSAnnotate :VCSAnnotate<CR>
nnoremap <silent> <Plug>VCSCommit :VCSCommit<CR>
@ -1274,6 +1428,7 @@ nnoremap <silent> <Plug>VCSStatus :VCSStatus<CR>
nnoremap <silent> <Plug>VCSUnlock :VCSUnlock<CR>
nnoremap <silent> <Plug>VCSUpdate :VCSUpdate<CR>
nnoremap <silent> <Plug>VCSVimDiff :VCSVimDiff<CR>
endif
" Section: Default mappings {{{1
@ -1297,25 +1452,37 @@ let s:defaultMappings = [
\['v', 'VCSVimDiff'],
\]
if !VCSCommandGetOption('VCSCommandDisableMappings', 0)
for [shortcut, vcsFunction] in VCSCommandGetOption('VCSCommandMappings', s:defaultMappings)
call s:CreateMapping(shortcut, '<Plug>' . vcsFunction, '''' . vcsFunction . '''')
if !exists("g:no_plugin_maps") && !VCSCommandGetOption('VCSCommandDisableMappings', 0)
for [s:shortcut, s:vcsFunction] in VCSCommandGetOption('VCSCommandMappings', s:defaultMappings)
call s:CreateMapping(s:shortcut, '<Plug>' . s:vcsFunction, '''' . s:vcsFunction . '''')
endfor
unlet s:shortcut s:vcsFunction
endif
unlet s:defaultMappings
" Section: Menu items {{{1
amenu <silent> &Plugin.VCS.&Add <Plug>VCSAdd
amenu <silent> &Plugin.VCS.A&nnotate <Plug>VCSAnnotate
amenu <silent> &Plugin.VCS.&Commit <Plug>VCSCommit
amenu <silent> &Plugin.VCS.Delete <Plug>VCSDelete
amenu <silent> &Plugin.VCS.&Diff <Plug>VCSDiff
amenu <silent> &Plugin.VCS.&Info <Plug>VCSInfo
amenu <silent> &Plugin.VCS.&Log <Plug>VCSLog
amenu <silent> &Plugin.VCS.Revert <Plug>VCSRevert
amenu <silent> &Plugin.VCS.&Review <Plug>VCSReview
amenu <silent> &Plugin.VCS.&Status <Plug>VCSStatus
amenu <silent> &Plugin.VCS.&Update <Plug>VCSUpdate
amenu <silent> &Plugin.VCS.&VimDiff <Plug>VCSVimDiff
let s:menuEnabled = !VCSCommandGetOption('VCSCommandDisableMenu', 0)
let s:menuRoot = VCSCommandGetOption('VCSCommandMenuRoot', '&Plugin.VCS')
let s:menuPriority = VCSCommandGetOption('VCSCommandMenuPriority', '')
for [s:shortcut, s:command] in [
\['&Add', '<Plug>VCSAdd'],
\['A&nnotate', '<Plug>VCSAnnotate'],
\['&Commit', '<Plug>VCSCommit'],
\['Delete', '<Plug>VCSDelete'],
\['&Diff', '<Plug>VCSDiff'],
\['&Info', '<Plug>VCSInfo'],
\['&Log', '<Plug>VCSLog'],
\['Revert', '<Plug>VCSRevert'],
\['&Review', '<Plug>VCSReview'],
\['&Status', '<Plug>VCSStatus'],
\['&Update', '<Plug>VCSUpdate'],
\['&VimDiff', '<Plug>VCSVimDiff']
\]
call s:VCSCommandUtility.addMenuItem(s:shortcut, s:command)
endfor
unlet s:shortcut s:command
" Section: Autocommands to restore vimdiff state {{{1
augroup VimDiffRestore

View File

@ -2,10 +2,9 @@
"
" CVS extension for VCSCommand.
"
" Version: VCS development
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" License:
" Copyright (c) 2007 Bob Hiestand
" Copyright (c) Bob Hiestand
"
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to
@ -90,7 +89,9 @@ if v:version < 700
finish
endif
if !exists('g:loaded_VCSCommand')
runtime plugin/vcscommand.vim
endif
if !executable(VCSCommandGetOption('VCSCommandCVSExec', 'cvs'))
" CVS is not installed
@ -110,7 +111,7 @@ let s:cvsFunctions = {}
" Returns the executable used to invoke cvs suitable for use in a shell
" command.
function! s:Executable()
return shellescape(VCSCommandGetOption('VCSCommandCVSExec', 'cvs'))
return VCSCommandGetOption('VCSCommandCVSExec', 'cvs')
endfunction
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
@ -181,7 +182,7 @@ endfunction
" Function: s:cvsFunctions.Annotate(argList) {{{2
function! s:cvsFunctions.Annotate(argList)
if len(a:argList) == 0
if &filetype == 'CVSAnnotate'
if &filetype ==? 'cvsannotate'
" This is a CVSAnnotate buffer. Perform annotation of the version
" indicated by the current line.
let caption = matchstr(getline('.'),'\v^[0-9.]+')
@ -216,7 +217,6 @@ function! s:cvsFunctions.Annotate(argList)
let resultBuffer = s:DoCommand(join(['-q', 'annotate'] + options), 'annotate', caption, {})
if resultBuffer > 0
set filetype=CVSAnnotate
" Remove header lines from standard error
silent v/^\d\+\%(\.\d\+\)\+/d
endif
@ -266,13 +266,7 @@ function! s:cvsFunctions.Diff(argList)
let diffOptions = ['-' . cvsDiffOpt]
endif
let resultBuffer = s:DoCommand(join(['diff'] + diffOptions + revOptions), 'diff', caption, {'allowNonZeroExit': 1})
if resultBuffer > 0
set filetype=diff
else
echomsg 'No differences found'
endif
return resultBuffer
return s:DoCommand(join(['diff'] + diffOptions + revOptions), 'diff', caption, {'allowNonZeroExit': 1})
endfunction
" Function: s:cvsFunctions.GetBufferInfo() {{{2
@ -338,11 +332,7 @@ function! s:cvsFunctions.Log(argList)
let caption = join(a:argList, ' ')
endif
let resultBuffer=s:DoCommand(join(['log'] + options), 'log', caption, {})
if resultBuffer > 0
set filetype=rcslog
endif
return resultBuffer
return s:DoCommand(join(['log'] + options), 'log', caption, {})
endfunction
" Function: s:cvsFunctions.Revert(argList) {{{2
@ -360,11 +350,7 @@ function! s:cvsFunctions.Review(argList)
let versionOption = ' -r ' . versiontag . ' '
endif
let resultBuffer = s:DoCommand('-q update -p' . versionOption, 'review', versiontag, {})
if resultBuffer > 0
let &filetype=getbufvar(b:VCSCommandOriginalBuffer, '&filetype')
endif
return resultBuffer
return s:DoCommand('-q update -p' . versionOption, 'review', versiontag, {})
endfunction
" Function: s:cvsFunctions.Status(argList) {{{2
@ -426,6 +412,7 @@ com! CVSWatchers call s:CVSWatchers()
" Section: Plugin command mappings {{{1
let s:cvsExtensionMappings = {}
if !exists("no_plugin_maps")
let mappingInfo = [
\['CVSEdit', 'CVSEdit', 'e'],
\['CVSEditors', 'CVSEditors', 'E'],
@ -443,18 +430,24 @@ for [pluginName, commandText, shortCut] in mappingInfo
let s:cvsExtensionMappings[shortCut] = commandText
endif
endfor
" Section: Menu items {{{1
amenu <silent> &Plugin.VCS.CVS.&Edit <Plug>CVSEdit
amenu <silent> &Plugin.VCS.CVS.Ed&itors <Plug>CVSEditors
amenu <silent> &Plugin.VCS.CVS.Unedi&t <Plug>CVSUnedit
amenu <silent> &Plugin.VCS.CVS.&Watchers <Plug>CVSWatchers
amenu <silent> &Plugin.VCS.CVS.WatchAdd <Plug>CVSWatchAdd
amenu <silent> &Plugin.VCS.CVS.WatchOn <Plug>CVSWatchOn
amenu <silent> &Plugin.VCS.CVS.WatchOff <Plug>CVSWatchOff
amenu <silent> &Plugin.VCS.CVS.WatchRemove <Plug>CVSWatchRemove
endif
" Section: Plugin Registration {{{1
let s:VCSCommandUtility = VCSCommandRegisterModule('CVS', expand('<sfile>'), s:cvsFunctions, s:cvsExtensionMappings)
" Section: Menu items {{{1
for [s:shortcut, s:command] in [
\['CVS.&Edit', '<Plug>CVSEdit'],
\['CVS.Ed&itors', '<Plug>CVSEditors'],
\['CVS.Unedi&t', '<Plug>CVSUnedit'],
\['CVS.&Watchers', '<Plug>CVSWatchers'],
\['CVS.WatchAdd', '<Plug>CVSWatchAdd'],
\['CVS.WatchOn', '<Plug>CVSWatchOn'],
\['CVS.WatchOff', '<Plug>CVSWatchOff'],
\['CVS.WatchRemove', '<Plug>CVSWatchRemove']
\]
call s:VCSCommandUtility.addMenuItem(s:shortcut, s:command)
endfor
unlet s:shortcut s:command
let &cpo = s:save_cpo

View File

@ -2,10 +2,9 @@
"
" git extension for VCSCommand.
"
" Version: VCS development
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" License:
" Copyright (c) 2008 Bob Hiestand
" Copyright (c) Bob Hiestand
"
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to
@ -49,7 +48,9 @@ if v:version < 700
finish
endif
if !exists('g:loaded_VCSCommand')
runtime plugin/vcscommand.vim
endif
if !executable(VCSCommandGetOption('VCSCommandGitExec', 'git'))
" git is not installed
@ -69,7 +70,7 @@ let s:gitFunctions = {}
" Returns the executable used to invoke git suitable for use in a shell
" command.
function! s:Executable()
return shellescape(VCSCommandGetOption('VCSCommandGitExec', 'git'))
return VCSCommandGetOption('VCSCommandGitExec', 'git')
endfunction
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
@ -111,7 +112,7 @@ endfunction
" Function: s:gitFunctions.Annotate(argList) {{{2
function! s:gitFunctions.Annotate(argList)
if len(a:argList) == 0
if &filetype == 'gitAnnotate'
if &filetype == 'gitannotate'
" Perform annotation of the version indicated by the current line.
let options = matchstr(getline('.'),'^\x\+')
else
@ -123,21 +124,16 @@ function! s:gitFunctions.Annotate(argList)
let options = join(a:argList, ' ')
endif
let resultBuffer = s:DoCommand('blame ' . options, 'annotate', options, {})
if resultBuffer > 0
normal 1G
set filetype=gitAnnotate
endif
return resultBuffer
return s:DoCommand('blame ' . options, 'annotate', options, {})
endfunction
" Function: s:gitFunctions.Commit(argList) {{{2
function! s:gitFunctions.Commit(argList)
let resultBuffer = s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {})
if resultBuffer == 0
try
return s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {})
catch /\m^Version control command failed.*nothing\%( added\)\? to commit/
echomsg 'No commit needed.'
endif
return resultBuffer
endtry
endfunction
" Function: s:gitFunctions.Delete() {{{2
@ -165,13 +161,7 @@ function! s:gitFunctions.Diff(argList)
endfor
endif
let resultBuffer = s:DoCommand(join(['diff'] + diffOptions + a:argList), 'diff', join(a:argList), {})
if resultBuffer > 0
set filetype=diff
else
echomsg 'No differences found'
endif
return resultBuffer
return s:DoCommand(join(['diff'] + diffOptions + a:argList), 'diff', join(a:argList), {})
endfunction
" Function: s:gitFunctions.GetBufferInfo() {{{2
@ -212,11 +202,7 @@ endfunction
" Function: s:gitFunctions.Log() {{{2
function! s:gitFunctions.Log(argList)
let resultBuffer=s:DoCommand(join(['log'] + a:argList), 'log', join(a:argList, ' '), {})
if resultBuffer > 0
set filetype=gitlog
endif
return resultBuffer
return s:DoCommand(join(['log'] + a:argList), 'log', join(a:argList, ' '), {})
endfunction
" Function: s:gitFunctions.Revert(argList) {{{2
@ -241,11 +227,7 @@ function! s:gitFunctions.Review(argList)
let prefix = substitute(prefix, '\n$', '', '')
let blob = '"' . revision . ':' . prefix . '<VCSCOMMANDFILE>"'
let resultBuffer = s:DoCommand('show ' . blob, 'review', revision, {})
if resultBuffer > 0
let &filetype=getbufvar(b:VCSCommandOriginalBuffer, '&filetype')
endif
return resultBuffer
return s:DoCommand('show ' . blob, 'review', revision, {})
endfunction
" Function: s:gitFunctions.Status(argList) {{{2

View File

@ -2,10 +2,9 @@
"
" Mercurial extension for VCSCommand.
"
" Version: VCS development
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" License:
" Copyright (c) 2009 Bob Hiestand
" Copyright (c) Bob Hiestand
"
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to
@ -51,7 +50,9 @@ if v:version < 700
finish
endif
if !exists('g:loaded_VCSCommand')
runtime plugin/vcscommand.vim
endif
if !executable(VCSCommandGetOption('VCSCommandHGExec', 'hg'))
" HG is not installed
@ -71,7 +72,7 @@ let s:hgFunctions = {}
" Returns the executable used to invoke hg suitable for use in a shell
" command.
function! s:Executable()
return shellescape(VCSCommandGetOption('VCSCommandHGExec', 'hg'))
return VCSCommandGetOption('VCSCommandHGExec', 'hg')
endfunction
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
@ -105,16 +106,16 @@ endfunction
" Function: s:hgFunctions.Add() {{{2
function! s:hgFunctions.Add(argList)
return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
return s:DoCommand(join(['add -v'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
endfunction
" Function: s:hgFunctions.Annotate(argList) {{{2
function! s:hgFunctions.Annotate(argList)
if len(a:argList) == 0
if &filetype == 'HGAnnotate'
if &filetype ==? 'hgannotate'
" Perform annotation of the version indicated by the current line.
let caption = matchstr(getline('.'),'\v^\s+\zs\d+')
let options = ' -r' . caption
let caption = matchstr(getline('.'),'\v^\s*\w+\s+\zs\d+')
let options = ' -un -r' . caption
else
let caption = ''
let options = ' -un'
@ -127,19 +128,16 @@ function! s:hgFunctions.Annotate(argList)
let options = ' ' . caption
endif
let resultBuffer = s:DoCommand('blame' . options, 'annotate', caption, {})
if resultBuffer > 0
set filetype=HGAnnotate
endif
return resultBuffer
return s:DoCommand('blame' . options, 'annotate', caption, {})
endfunction
" Function: s:hgFunctions.Commit(argList) {{{2
function! s:hgFunctions.Commit(argList)
let resultBuffer = s:DoCommand('commit -l "' . a:argList[0] . '"', 'commit', '', {})
if resultBuffer == 0
try
return s:DoCommand('commit -v -l "' . a:argList[0] . '"', 'commit', '', {})
catch /Version control command failed.*nothing changed/
echomsg 'No commit needed.'
endif
endtry
endfunction
" Function: s:hgFunctions.Delete() {{{2
@ -175,15 +173,7 @@ function! s:hgFunctions.Diff(argList)
let diffOptions = ['-x -' . hgDiffOpt]
endif
let resultBuffer = s:DoCommand(join(['diff'] + diffExt + diffOptions + revOptions), 'diff', caption, {})
if resultBuffer > 0
set filetype=diff
else
if hgDiffExt == ''
echomsg 'No differences found'
endif
endif
return resultBuffer
return s:DoCommand(join(['diff'] + diffExt + diffOptions + revOptions), 'diff', caption, {})
endfunction
" Function: s:hgFunctions.Info(argList) {{{2
@ -259,18 +249,13 @@ function! s:hgFunctions.Review(argList)
let versionOption = ' -r ' . versiontag . ' '
endif
" let resultBuffer = s:DoCommand('cat --non-interactive' . versionOption, 'review', versiontag, {})
let resultBuffer = s:DoCommand('cat' . versionOption, 'review', versiontag, {})
if resultBuffer > 0
let &filetype = getbufvar(b:VCSCommandOriginalBuffer, '&filetype')
endif
return resultBuffer
return s:DoCommand('cat' . versionOption, 'review', versiontag, {})
endfunction
" Function: s:hgFunctions.Status(argList) {{{2
function! s:hgFunctions.Status(argList)
let options = ['-u', '-v']
if len(a:argList) == 0
let options = ['-A', '-v']
if len(a:argList) != 0
let options = a:argList
endif
return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {})

View File

@ -2,10 +2,9 @@
"
" SVK extension for VCSCommand.
"
" Version: VCS development
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" License:
" Copyright (c) 2007 Bob Hiestand
" Copyright (c) Bob Hiestand
"
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to
@ -44,7 +43,9 @@ if v:version < 700
finish
endif
if !exists('g:loaded_VCSCommand')
runtime plugin/vcscommand.vim
endif
if !executable(VCSCommandGetOption('VCSCommandSVKExec', 'svk'))
" SVK is not installed
@ -64,7 +65,7 @@ let s:svkFunctions = {}
" Returns the executable used to invoke SVK suitable for use in a shell
" command.
function! s:Executable()
return shellescape(VCSCommandGetOption('VCSCommandSVKExec', 'svk'))
return VCSCommandGetOption('VCSCommandSVKExec', 'svk')
endfunction
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
@ -105,7 +106,7 @@ endfunction
" Function: s:svkFunctions.Annotate(argList) {{{2
function! s:svkFunctions.Annotate(argList)
if len(a:argList) == 0
if &filetype == 'SVKAnnotate'
if &filetype ==? 'svkannotate'
" Perform annotation of the version indicated by the current line.
let caption = matchstr(getline('.'),'\v^\s+\zs\d+')
let options = ' -r' . caption
@ -123,8 +124,7 @@ function! s:svkFunctions.Annotate(argList)
let resultBuffer = s:DoCommand('blame' . options, 'annotate', caption, {})
if resultBuffer > 0
normal 1G2dd
set filetype=SVKAnnotate
normal! 1G2dd
endif
return resultBuffer
endfunction
@ -156,13 +156,7 @@ function! s:svkFunctions.Diff(argList)
let revOptions = a:argList
endif
let resultBuffer = s:DoCommand(join(['diff'] + revOptions), 'diff', caption, {})
if resultBuffer > 0
set filetype=diff
else
echomsg 'No differences found'
endif
return resultBuffer
return s:DoCommand(join(['diff'] + revOptions), 'diff', caption, {})
endfunction
" Function: s:svkFunctions.GetBufferInfo() {{{2
@ -238,17 +232,13 @@ function! s:svkFunctions.Review(argList)
let versionOption = ' -r ' . versiontag . ' '
endif
let resultBuffer = s:DoCommand('cat' . versionOption, 'review', versiontag, {})
if resultBuffer > 0
let &filetype=getbufvar(b:VCSCommandOriginalBuffer, '&filetype')
endif
return resultBuffer
return s:DoCommand('cat' . versionOption, 'review', versiontag, {})
endfunction
" Function: s:svkFunctions.Status(argList) {{{2
function! s:svkFunctions.Status(argList)
let options = ['-v']
if len(a:argList) == 0
if len(a:argList) != 0
let options = a:argList
endif
return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {})

View File

@ -2,10 +2,9 @@
"
" SVN extension for VCSCommand.
"
" Version: VCS development
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" License:
" Copyright (c) 2007 Bob Hiestand
" Copyright (c) Bob Hiestand
"
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to
@ -51,7 +50,9 @@ if v:version < 700
finish
endif
if !exists('g:loaded_VCSCommand')
runtime plugin/vcscommand.vim
endif
if !executable(VCSCommandGetOption('VCSCommandSVNExec', 'svn'))
" SVN is not installed
@ -71,7 +72,7 @@ let s:svnFunctions = {}
" Returns the executable used to invoke git suitable for use in a shell
" command.
function! s:Executable()
return shellescape(VCSCommandGetOption('VCSCommandSVNExec', 'svn'))
return VCSCommandGetOption('VCSCommandSVNExec', 'svn')
endfunction
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
@ -90,22 +91,17 @@ endfunction
" Function: s:svnFunctions.Identify(buffer) {{{2
function! s:svnFunctions.Identify(buffer)
let fileName = resolve(bufname(a:buffer))
if isdirectory(fileName)
let directoryName = fileName
else
let directoryName = fnamemodify(fileName, ':h')
endif
if strlen(directoryName) > 0
let svnDir = directoryName . '/.svn'
else
let svnDir = '.svn'
endif
if isdirectory(svnDir)
return 1
else
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(a:buffer)))
try
call s:VCSCommandUtility.system(s:Executable() . ' info .')
if(v:shell_error)
return 0
else
return g:VCSCOMMAND_IDENTIFY_EXACT
endif
finally
call VCSCommandChdir(oldCwd)
endtry
endfunction
" Function: s:svnFunctions.Add() {{{2
@ -116,7 +112,7 @@ endfunction
" Function: s:svnFunctions.Annotate(argList) {{{2
function! s:svnFunctions.Annotate(argList)
if len(a:argList) == 0
if &filetype == 'SVNAnnotate'
if &filetype ==? 'svnannotate'
" Perform annotation of the version indicated by the current line.
let caption = matchstr(getline('.'),'\v^\s+\zs\d+')
let options = ' -r' . caption
@ -132,11 +128,7 @@ function! s:svnFunctions.Annotate(argList)
let options = ' ' . caption
endif
let resultBuffer = s:DoCommand('blame --non-interactive' . options, 'annotate', caption, {})
if resultBuffer > 0
set filetype=SVNAnnotate
endif
return resultBuffer
return s:DoCommand('blame --non-interactive' . options, 'annotate', caption, {})
endfunction
" Function: s:svnFunctions.Commit(argList) {{{2
@ -180,15 +172,7 @@ function! s:svnFunctions.Diff(argList)
let diffOptions = ['-x -' . svnDiffOpt]
endif
let resultBuffer = s:DoCommand(join(['diff --non-interactive'] + diffExt + diffOptions + revOptions), 'diff', caption, {})
if resultBuffer > 0
set filetype=diff
else
if svnDiffExt == ''
echomsg 'No differences found'
endif
endif
return resultBuffer
return s:DoCommand(join(['diff --non-interactive'] + diffExt + diffOptions + revOptions), 'diff', caption, {})
endfunction
" Function: s:svnFunctions.GetBufferInfo() {{{2
@ -200,7 +184,7 @@ endfunction
function! s:svnFunctions.GetBufferInfo()
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
let fileName = bufname(originalBuffer)
let statusText = s:VCSCommandUtility.system(s:Executable() . ' status --non-interactive -vu -- "' . fileName . '"')
let statusText = s:VCSCommandUtility.system(s:Executable() . ' status --non-interactive -v -- "' . fileName . '"')
if(v:shell_error)
return []
endif
@ -210,12 +194,14 @@ function! s:svnFunctions.GetBufferInfo()
return ['Unknown']
endif
let [flags, revision, repository] = matchlist(statusText, '^\(.\{8}\)\s\+\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)\s')[1:3]
let [flags, revision, repository] = matchlist(statusText, '^\(.\{9}\)\s*\(\d\+\)\s\+\(\d\+\)')[1:3]
if revision == ''
" Error
return ['Unknown']
elseif flags =~ '^A'
return ['New', 'New']
elseif flags =~ '*'
return [revision, repository, '*']
else
return [revision, repository]
endif
@ -264,17 +250,13 @@ function! s:svnFunctions.Review(argList)
let versionOption = ' -r ' . versiontag . ' '
endif
let resultBuffer = s:DoCommand('cat --non-interactive' . versionOption, 'review', versiontag, {})
if resultBuffer > 0
let &filetype = getbufvar(b:VCSCommandOriginalBuffer, '&filetype')
endif
return resultBuffer
return s:DoCommand('cat --non-interactive' . versionOption, 'review', versiontag, {})
endfunction
" Function: s:svnFunctions.Status(argList) {{{2
function! s:svnFunctions.Status(argList)
let options = ['-u', '-v']
if len(a:argList) == 0
if len(a:argList) != 0
let options = a:argList
endif
return s:DoCommand(join(['status --non-interactive'] + options, ' '), 'status', join(options, ' '), {})

View File

@ -1,11 +1,11 @@
" FILE: syntax/conque_term.vim {{{
" AUTHOR: Nico Raffo <nicoraffo@gmail.com>
" WEBSITE: http://conque.googlecode.com
" MODIFIED: 2010-11-15
" VERSION: 2.0, for Vim 7.0
" MODIFIED: 2011-08-12
" VERSION: 2.2, for Vim 7.0
" LICENSE:
" Conque - Vim terminal/console emulator
" Copyright (C) 2009-2010 Nico Raffo
" Copyright (C) 2009-__YEAR__ Nico Raffo
"
" MIT License
"

View File

@ -0,0 +1,45 @@
" Vim syntax file
" Language: CVS annotate output
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" Remark: Used by the cvscommand plugin. Originally written by Mathieu
" Clabaut
" License:
" Copyright (c) Bob Hiestand
"
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to
" deal in the Software without restriction, including without limitation the
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
" sell copies of the Software, and to permit persons to whom the Software is
" furnished to do so, subject to the following conditions:
"
" The above copyright notice and this permission notice shall be included in
" all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
" IN THE SOFTWARE.
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
syn match cvsDate /\d\d-...-\d\d/ contained
syn match cvsName /(\S* /hs=s+1,he=e-1 contained nextgroup=cvsDate
syn match cvsVer /^\d\+\(\.\d\+\)\+/ contained nextgroup=cvsName
syn region cvsHead start="^\d\+\.\d\+" end="):" contains=cvsVer,cvsName,cvsDate
if !exists("did_cvsannotate_syntax_inits")
let did_cvsannotate_syntax_inits = 1
hi link cvsDate Comment
hi link cvsName Type
hi link cvsVer Statement
endif
let b:current_syntax="CVSAnnotate"

View File

@ -0,0 +1,44 @@
" Vim syntax file
" Language: git annotate output
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" Remark: Used by the vcscommand plugin.
" License:
" Copyright (c) Bob Hiestand
"
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to
" deal in the Software without restriction, including without limitation the
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
" sell copies of the Software, and to permit persons to whom the Software is
" furnished to do so, subject to the following conditions:
"
" The above copyright notice and this permission notice shall be included in
" all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
" IN THE SOFTWARE.
if exists("b:current_syntax")
finish
endif
syn region gitName start="(\@<=" end="\( \d\d\d\d-\)\@=" contained
syn match gitCommit /^\^\?\x\+/ contained
syn match gitDate /\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d [+-]\d\d\d\d/ contained
syn match gitLineNumber /\d\+)\@=/ contained
syn region gitAnnotation start="^" end=") " oneline keepend contains=gitCommit,gitLineNumber,gitDate,gitName
if !exists("did_gitannotate_syntax_inits")
let did_gitannotate_syntax_inits = 1
hi link gitName Type
hi link gitCommit Statement
hi link gitDate Comment
hi link gitLineNumber Label
endif
let b:current_syntax="gitAnnotate"

40
vim/syntax/hgannotate.vim Normal file
View File

@ -0,0 +1,40 @@
" Vim syntax file
" Language: HG annotate output
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" Remark: Used by the vcscommand plugin.
" License:
" Copyright (c) Bob Hiestand
"
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to
" deal in the Software without restriction, including without limitation the
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
" sell copies of the Software, and to permit persons to whom the Software is
" furnished to do so, subject to the following conditions:
"
" The above copyright notice and this permission notice shall be included in
" all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
" IN THE SOFTWARE.
if exists("b:current_syntax")
finish
endif
syn match hgVer /\d\+/ contained
syn match hgName /^\s*\S\+/ contained
syn match hgHead /^\s*\S\+\s\+\d\+:/ contains=hgVer,hgName
if !exists("did_hgannotate_syntax_inits")
let did_hgannotate_syntax_inits = 1
hi link hgName Type
hi link hgVer Statement
endif
let b:current_syntax="hgAnnotate"

88
vim/syntax/nerdtree.vim Normal file
View File

@ -0,0 +1,88 @@
let s:tree_up_dir_line = '.. (up a dir)'
"NERDTreeFlags are syntax items that should be invisible, but give clues as to
"how things should be highlighted
syn match NERDTreeFlag #\~#
syn match NERDTreeFlag #\[RO\]#
"highlighting for the .. (up dir) line at the top of the tree
execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#"
"highlighting for the ~/+ symbols for the directory nodes
syn match NERDTreeClosable #\~\<#
syn match NERDTreeClosable #\~\.#
syn match NERDTreeOpenable #+\<#
syn match NERDTreeOpenable #+\.#he=e-1
"highlighting for the tree structural parts
syn match NERDTreePart #|#
syn match NERDTreePart #`#
syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart
"quickhelp syntax elements
syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#hs=s+2,he=e-1
syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#hs=s+2,he=e-1
syn match NERDTreeHelpTitle #" .*\~#hs=s+2,he=e-1 contains=NERDTreeFlag
syn match NERDTreeToggleOn #".*(on)#hs=e-2,he=e-1 contains=NERDTreeHelpKey
syn match NERDTreeToggleOff #".*(off)#hs=e-3,he=e-1 contains=NERDTreeHelpKey
syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3
syn match NERDTreeHelp #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTreeFlag,NERDTreeToggleOff,NERDTreeToggleOn,NERDTreeHelpCommand
"highlighting for readonly files
syn match NERDTreeRO #.*\[RO\]#hs=s+2 contains=NERDTreeFlag,NERDTreeBookmark,NERDTreePart,NERDTreePartFile
"highlighting for sym links
syn match NERDTreeLink #[^-| `].* -> # contains=NERDTreeBookmark,NERDTreeOpenable,NERDTreeClosable,NERDTreeDirSlash
"highlighing for directory nodes and file nodes
syn match NERDTreeDirSlash #/#
syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeDirSlash,NERDTreeOpenable,NERDTreeClosable
syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark
syn match NERDTreeFile #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
syn match NERDTreeCWD #^[</].*$#
"highlighting for bookmarks
syn match NERDTreeBookmark # {.*}#hs=s+1
"highlighting for the bookmarks table
syn match NERDTreeBookmarksLeader #^>#
syn match NERDTreeBookmarksHeader #^>-\+Bookmarks-\+$# contains=NERDTreeBookmarksLeader
syn match NERDTreeBookmarkName #^>.\{-} #he=e-1 contains=NERDTreeBookmarksLeader
syn match NERDTreeBookmark #^>.*$# contains=NERDTreeBookmarksLeader,NERDTreeBookmarkName,NERDTreeBookmarksHeader
if exists("g:NERDChristmasTree") && g:NERDChristmasTree
hi def link NERDTreePart Special
hi def link NERDTreePartFile Type
hi def link NERDTreeFile Normal
hi def link NERDTreeExecFile Title
hi def link NERDTreeDirSlash Identifier
hi def link NERDTreeClosable Type
else
hi def link NERDTreePart Normal
hi def link NERDTreePartFile Normal
hi def link NERDTreeFile Normal
hi def link NERDTreeClosable Title
endif
hi def link NERDTreeBookmarksHeader statement
hi def link NERDTreeBookmarksLeader ignore
hi def link NERDTreeBookmarkName Identifier
hi def link NERDTreeBookmark normal
hi def link NERDTreeHelp String
hi def link NERDTreeHelpKey Identifier
hi def link NERDTreeHelpCommand Identifier
hi def link NERDTreeHelpTitle Macro
hi def link NERDTreeToggleOn Question
hi def link NERDTreeToggleOff WarningMsg
hi def link NERDTreeDir Directory
hi def link NERDTreeUp Directory
hi def link NERDTreeCWD Statement
hi def link NERDTreeLink Macro
hi def link NERDTreeOpenable Title
hi def link NERDTreeFlag ignore
hi def link NERDTreeRO WarningMsg
hi def link NERDTreeBookmark Statement
hi def link NERDTreeCurrentNode Search

View File

@ -0,0 +1,42 @@
" Vim syntax file
" Language: SVK annotate output
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" Remark: Used by the vcscommand plugin.
" License:
" Copyright (c) Bob Hiestand
"
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to
" deal in the Software without restriction, including without limitation the
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
" sell copies of the Software, and to permit persons to whom the Software is
" furnished to do so, subject to the following conditions:
"
" The above copyright notice and this permission notice shall be included in
" all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
" IN THE SOFTWARE.
if exists("b:current_syntax")
finish
endif
syn match svkDate /\d\{4}-\d\{1,2}-\d\{1,2}/ skipwhite contained
syn match svkName /(\s*\zs\S\+/ contained nextgroup=svkDate skipwhite
syn match svkVer /^\s*\d\+/ contained nextgroup=svkName skipwhite
syn region svkHead start=/^/ end="):" contains=svkVer,svkName,svkDate oneline
if !exists("did_svkannotate_syntax_inits")
let did_svkannotate_syntax_inits = 1
hi link svkName Type
hi link svkDate Comment
hi link svkVer Statement
endif
let b:current_syntax="svkAnnotate"

View File

@ -0,0 +1,40 @@
" Vim syntax file
" Language: SVN annotate output
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" Remark: Used by the vcscommand plugin.
" License:
" Copyright (c) Bob Hiestand
"
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to
" deal in the Software without restriction, including without limitation the
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
" sell copies of the Software, and to permit persons to whom the Software is
" furnished to do so, subject to the following conditions:
"
" The above copyright notice and this permission notice shall be included in
" all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
" IN THE SOFTWARE.
if exists("b:current_syntax")
finish
endif
syn match svnName /\S\+/ contained
syn match svnVer /^\s*\zs\d\+/ contained nextgroup=svnName skipwhite
syn match svnHead /^\s*\d\+\s\+\S\+/ contains=svnVer,svnName
if !exists("did_svnannotate_syntax_inits")
let did_svnannotate_syntax_inits = 1
hi link svnName Type
hi link svnVer Statement
endif
let b:current_syntax="svnAnnotate"

View File

@ -2,7 +2,7 @@
" Language: VCS commit file
" Maintainer: Bob Hiestand (bob.hiestand@gmail.com)
" License:
" Copyright (c) 2007 Bob Hiestand
" Copyright (c) Bob Hiestand
"
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to

View File

@ -133,6 +133,10 @@ let NERDChristmasTree = 1
let NERDSpaceDelims=1
let NERDCreateDefaultMappings=1
" """"""""""""""
" GetLastestScript
" """"""""""""""
" """""""""""
" Keymappings
" """""""""""
@ -148,7 +152,7 @@ nnoremap <silent> <Leader>N :set number!<CR>
nnoremap <silent> da "_dd
nnoremap <silent> <Leader>ts :ConqueTermSplit zsh<CR>
nnoremap <silent> <Leader>tt :ConqueTermTab zsh<CR>
nnoremap <silent> <Leader>tT :ConqueTermTab zsh<CR>
map <silent> <Leader>c <plug>NERDCommenterToggle