mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
Updated all plugins that are non-forked. Added some new plugins.
Added update_plugins.py which can fetch new plugins from GitHub. New plugins added: zencoding, vim-indent-object, taglist, nginx.vim
This commit is contained in:
@ -3,8 +3,8 @@
|
||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2008-11-25.
|
||||
" @Last Change: 2010-11-20.
|
||||
" @Revision: 0.0.79
|
||||
" @Last Change: 2012-09-26.
|
||||
" @Revision: 0.0.90
|
||||
|
||||
let s:prototype = tlib#Object#New({'_class': ['Filter_cnf'], 'name': 'cnf'}) "{{{2
|
||||
let s:prototype.highlight = g:tlib_inputlist_higroup
|
||||
@ -30,6 +30,14 @@ function! s:prototype.Init(world) dict "{{{3
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.Help(world) dict "{{{3
|
||||
call a:world.PushHelp(
|
||||
\ printf('"%s", "%s", "%sWORD"', g:tlib_inputlist_and, g:tlib_inputlist_or, g:tlib_inputlist_not),
|
||||
\ 'AND, OR, NOT')
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.AssessName(world, name) dict "{{{3
|
||||
let xa = 0
|
||||
@ -86,18 +94,22 @@ function! s:prototype.Match(world, text) dict "{{{3
|
||||
" set smartcase
|
||||
" endif
|
||||
" try
|
||||
if !empty(a:world.filter_neg)
|
||||
for rx in a:world.filter_neg
|
||||
" TLogVAR rx
|
||||
if a:text =~ rx
|
||||
return 0
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
if !empty(a:world.filter_pos)
|
||||
for rx in a:world.filter_pos
|
||||
" TLogVAR rx
|
||||
if a:text !~ rx
|
||||
return 0
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
" finally
|
||||
" let &smartcase = sc
|
||||
" let &ignorecase = ic
|
||||
@ -109,13 +121,14 @@ endf
|
||||
" :nodoc:
|
||||
function! s:prototype.DisplayFilter(filter) dict "{{{3
|
||||
let filter1 = deepcopy(a:filter)
|
||||
call map(filter1, '"(". join(reverse(s:Pretty(v:val)), " OR ") .")"')
|
||||
call map(filter1, '"(". join(reverse(self.Pretty(v:val)), " OR ") .")"')
|
||||
return join(reverse(filter1), ' AND ')
|
||||
endf
|
||||
|
||||
|
||||
function! s:Pretty(filter) "{{{3
|
||||
call map(a:filter, 'substitute(v:val, ''\\\.\\{-}'', ''__'', ''g'')')
|
||||
function! s:prototype.Pretty(filter) dict "{{{3
|
||||
" call map(a:filter, 'substitute(v:val, ''\\\.\\{-}'', ''=>'', ''g'')')
|
||||
call map(a:filter, 'self.CleanFilter(v:val)')
|
||||
return a:filter
|
||||
endf
|
||||
|
||||
|
@ -3,14 +3,14 @@
|
||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2008-11-25.
|
||||
" @Last Change: 2010-09-15.
|
||||
" @Revision: 0.0.35
|
||||
" @Last Change: 2012-09-20.
|
||||
" @Revision: 0.0.50
|
||||
|
||||
let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_cnfd'], 'name': 'cnfd'}) "{{{2
|
||||
let s:prototype.highlight = g:tlib_inputlist_higroup
|
||||
|
||||
|
||||
" The same as |tlib#FilterCNF#New()| but a dot is expanded to '\.\{-}'.
|
||||
" The same as |tlib#Filter_cnf#New()| but a dot is expanded to '\.\{-}'.
|
||||
" As a consequence, patterns cannot match dots.
|
||||
" The pattern is a '/\V' very no-'/magic' regexp pattern.
|
||||
function! tlib#Filter_cnfd#New(...) "{{{3
|
||||
@ -24,6 +24,19 @@ function! s:prototype.Init(world) dict "{{{3
|
||||
endf
|
||||
|
||||
|
||||
let s:Help = s:prototype.Help
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.Help(world) dict "{{{3
|
||||
call call(s:Help, [a:world], self)
|
||||
if self.name == 'cnfx'
|
||||
call a:world.PushHelp(g:tlib#Filter_cnfx#expander, 'Any characters')
|
||||
else
|
||||
call a:world.PushHelp('.', 'Any characters')
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3
|
||||
let pattern = substitute(a:pattern, '\.', '\\.\\{-}', 'g')
|
||||
|
42
sources_non_forked/tlib/autoload/tlib/Filter_cnfx.vim
Normal file
42
sources_non_forked/tlib/autoload/tlib/Filter_cnfx.vim
Normal file
@ -0,0 +1,42 @@
|
||||
" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
|
||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2008-11-25.
|
||||
" @Last Change: 2012-09-20.
|
||||
" @Revision: 0.0.61
|
||||
|
||||
let s:prototype = tlib#Filter_cnfd#New({'_class': ['Filter_cnfx'], 'name': 'cnfx'}) "{{{2
|
||||
let s:prototype.highlight = g:tlib_inputlist_higroup
|
||||
|
||||
|
||||
" A character that should be expanded to '\.\{-}'.
|
||||
TLet g:tlib#Filter_cnfx#expander = '+'
|
||||
|
||||
|
||||
" The same as |tlib#Filter_cnfd#New()| but a a customizable character
|
||||
" |see tlib#Filter_cnfx#expander| is expanded to '\.\{-}'.
|
||||
" The pattern is a '/\V' very no-'/magic' regexp pattern.
|
||||
function! tlib#Filter_cnfx#New(...) "{{{3
|
||||
let object = s:prototype.New(a:0 >= 1 ? a:1 : {})
|
||||
return object
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3
|
||||
let pattern = substitute(a:pattern, tlib#rx#Escape(g:tlib#Filter_cnfx#expander, 'V'), '\\.\\{-}', 'g')
|
||||
let a:world.filter[0] = reverse(split(pattern, '\s*|\s*')) + a:world.filter[0][1 : -1]
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.PushFrontFilter(world, char) dict "{{{3
|
||||
let a:world.filter[0][0] .= a:char == char2nr(g:tlib#Filter_cnfx#expander) ? '\.\{-}' : nr2char(a:char)
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.CleanFilter(filter) dict "{{{3
|
||||
return substitute(a:filter, '\\.\\{-}', g:tlib#Filter_cnfx#expander, 'g')
|
||||
endf
|
||||
|
@ -3,15 +3,15 @@
|
||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2008-11-25.
|
||||
" @Last Change: 2010-09-15.
|
||||
" @Revision: 0.0.38
|
||||
" @Last Change: 2012-09-20.
|
||||
" @Revision: 0.0.46
|
||||
|
||||
let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_fuzzy'], 'name': 'fuzzy'}) "{{{2
|
||||
let s:prototype.highlight = ''
|
||||
let s:prototype.highlight = g:tlib_inputlist_higroup
|
||||
|
||||
|
||||
" Support for "fuzzy" pattern matching in |tlib#input#List()|.
|
||||
" Characters are interpreted as if connected with '.\{-}'.
|
||||
" Patterns are interpreted as if characters were connected with '.\{-}'.
|
||||
"
|
||||
" In "fuzzy" mode, the pretty printing of filenames is disabled.
|
||||
function! tlib#Filter_fuzzy#New(...) "{{{3
|
||||
@ -23,7 +23,8 @@ endf
|
||||
" :nodoc:
|
||||
function! s:prototype.Init(world) dict "{{{3
|
||||
" TLogVAR a:world.display_format
|
||||
function! a:world.Set_display_format(value) dict "{{{3
|
||||
" :nodoc:
|
||||
function! a:world.Set_display_format(value) dict
|
||||
if a:value == 'filename'
|
||||
let self.display_format = ''
|
||||
else
|
||||
@ -33,6 +34,15 @@ function! s:prototype.Init(world) dict "{{{3
|
||||
endf
|
||||
|
||||
|
||||
let s:Help = s:prototype.Help
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.Help(world) dict "{{{3
|
||||
call call(s:Help, [a:world], self)
|
||||
call a:world.PushHelp('Patterns are interpreted as if characters were connected with .\{-}')
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.DisplayFilter(filter) dict "{{{3
|
||||
" TLogVAR a:filter
|
||||
|
@ -1,98 +0,0 @@
|
||||
" Filter_seq.vim
|
||||
" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
|
||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2008-11-25.
|
||||
" @Last Change: 2010-11-20.
|
||||
" @Revision: 0.0.30
|
||||
|
||||
let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_seq'], 'name': 'seq'}) "{{{2
|
||||
let s:prototype.highlight = g:tlib_inputlist_higroup
|
||||
|
||||
" The search pattern for |tlib#input#List()| is interpreted as a
|
||||
" disjunction of 'magic' regular expressions with the exception of a dot
|
||||
" ".", which is interpreted as ".\{-}".
|
||||
" The pattern is a '/magic' regexp pattern.
|
||||
function! tlib#Filter_seq#New(...) "{{{3
|
||||
let object = s:prototype.New(a:0 >= 1 ? a:1 : {})
|
||||
return object
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.Init(world) dict "{{{3
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.Match(world, text) dict "{{{3
|
||||
" TLogVAR a:text
|
||||
for rx in a:world.filter_neg
|
||||
if a:text !~ rx
|
||||
" TLogDBG "filter_neg ". rx
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
for rx in a:world.filter_pos
|
||||
if a:text =~ rx
|
||||
" TLogDBG "filter_pos ". rx
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
return 0
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.DisplayFilter(filter) dict "{{{3
|
||||
let filter1 = deepcopy(a:filter)
|
||||
call map(filter1, '"(". join(reverse(s:Pretty(v:val)), "_") .")"')
|
||||
return join(reverse(filter1), ' OR ')
|
||||
endf
|
||||
|
||||
|
||||
function! s:Pretty(filter) "{{{3
|
||||
call map(a:filter, 's:prototype.CleanFilter(v:val)')
|
||||
return a:filter
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3
|
||||
let a:world.filter[0] = map(reverse(split(a:pattern, '\s*|\s*')), 'join(split(v:val, ''\.''), ''.\{-}'')') + a:world.filter[0][1 : -1]
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.PushFrontFilter(world, char) dict "{{{3
|
||||
let cc = nr2char(a:char)
|
||||
if cc == '.'
|
||||
let a:world.filter[0][0] .= '.\{-}'
|
||||
else
|
||||
let a:world.filter[0][0] .= nr2char(a:char)
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.ReduceFrontFilter(world) dict "{{{3
|
||||
let flt = a:world.filter[0][0]
|
||||
if flt =~ '\.\\{-}$'
|
||||
let a:world.filter[0][0] = flt[0:-6]
|
||||
else
|
||||
let a:world.filter[0][0] = flt[0:-2]
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.FilterRxPrefix() dict "{{{3
|
||||
return ''
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.CleanFilter(filter) dict "{{{3
|
||||
return substitute(a:filter, '.\\{-}', '.', 'g')
|
||||
endf
|
||||
|
@ -3,8 +3,8 @@
|
||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2007-05-01.
|
||||
" @Last Change: 2011-04-01.
|
||||
" @Revision: 0.1.915
|
||||
" @Last Change: 2012-10-03.
|
||||
" @Revision: 0.1.1203
|
||||
|
||||
" :filedoc:
|
||||
" A prototype used by |tlib#input#List|.
|
||||
@ -24,6 +24,7 @@ let s:prototype = tlib#Object#New({
|
||||
\ 'fileencoding': &fileencoding,
|
||||
\ 'fmt_display': {},
|
||||
\ 'fmt_filter': {},
|
||||
\ 'fmt_options': {},
|
||||
\ 'filetype': '',
|
||||
\ 'filter': [['']],
|
||||
\ 'filter_format': '',
|
||||
@ -62,6 +63,7 @@ let s:prototype = tlib#Object#New({
|
||||
\ 'state': 'display',
|
||||
\ 'state_handlers': [],
|
||||
\ 'sticky': 0,
|
||||
\ 'temp_prompt': [],
|
||||
\ 'timeout': 0,
|
||||
\ 'timeout_resolution': 2,
|
||||
\ 'type': '',
|
||||
@ -94,71 +96,115 @@ endf
|
||||
" :nodoc:
|
||||
function! s:prototype.Set_highlight_filename() dict "{{{3
|
||||
let self.tlib_UseInputListScratch = 'call world.Highlight_filename()'
|
||||
" \ 'syntax match TLibMarker /\%>'. (1 + eval(g:tlib_inputlist_width_filename)) .'c |.\{-}| / | hi def link TLibMarker Special'
|
||||
" let self.tlib_UseInputListScratch .= '| syntax match TLibDir /\%>'. (4 + eval(g:tlib_inputlist_width_filename)) .'c\S\{-}[\/].*$/ | hi def link TLibDir Directory'
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.Highlight_filename() dict "{{{3
|
||||
" exec 'syntax match TLibDir /\%>'. (3 + eval(g:tlib_inputlist_width_filename)) .'c \(\S:\)\?[\/].*$/ contained containedin=TLibMarker'
|
||||
exec 'syntax match TLibDir /\(\a:\|\.\.\..\{-}\)\?[\/][^&<>*|]*$/ contained containedin=TLibMarker'
|
||||
exec 'syntax match TLibMarker /\%>'. (1 + eval(g:tlib_inputlist_width_filename)) .'c |\( \|[[:alnum:]%*+-]*\)| \S.*$/ contains=TLibDir'
|
||||
hi def link TLibMarker Special
|
||||
hi def link TLibDir Directory
|
||||
endf
|
||||
if g:tlib#input#format_filename == 'r'
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.Highlight_filename() dict "{{{3
|
||||
syntax match TLibDir /\s\+\zs.\{-}[\/]\ze[^\/]\+$/
|
||||
hi def link TLibDir Directory
|
||||
syntax match TLibFilename /[^\/]\+$/
|
||||
hi def link TLibFilename Normal
|
||||
endf
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.FormatFilename(file) dict "{{{3
|
||||
if !has_key(self.fmt_options, 'maxlen')
|
||||
let maxco = &co - len(len(self.base)) - eval(g:tlib#input#filename_padding_r)
|
||||
let maxfi = max(map(copy(self.base), 'len(v:val)'))
|
||||
let self.fmt_options.maxlen = min([maxco, maxfi])
|
||||
" TLogVAR maxco, maxfi, self.fmt_options.maxlen
|
||||
endif
|
||||
let max = self.fmt_options.maxlen
|
||||
if len(a:file) > max
|
||||
let filename = '...' . strpart(a:file, len(a:file) - max + 3)
|
||||
else
|
||||
let filename = printf('% '. max .'s', a:file)
|
||||
endif
|
||||
return filename
|
||||
endf
|
||||
|
||||
else
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.Highlight_filename() dict "{{{3
|
||||
" let self.width_filename = 1 + eval(g:tlib_inputlist_width_filename)
|
||||
" TLogVAR self.base
|
||||
let self.width_filename = min([
|
||||
\ get(self, 'width_filename', &co),
|
||||
\ empty(g:tlib#input#filename_max_width) ? &co : eval(g:tlib#input#filename_max_width),
|
||||
\ max(map(copy(self.base), 'len(fnamemodify(v:val, ":t"))'))
|
||||
\ ])
|
||||
" TLogVAR self.width_filename
|
||||
exec 'syntax match TLibFilename /[^\/]\+$/ contained containedin=TLibDir'
|
||||
exec 'syntax match TLibDir /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \zs\(\(\a:\|\.\.\..\{-}\)\?[\/][^&<>*|]\{-}\)\?[^\/]\+$/ contained containedin=TLibMarker contains=TLibFilename'
|
||||
exec 'syntax match TLibMarker /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \S.*$/ contains=TLibDir'
|
||||
hi def link TLibMarker Special
|
||||
hi def link TLibDir Directory
|
||||
hi def link TLibFilename NonText
|
||||
" :nodoc:
|
||||
function! self.Highlighter(rx) dict
|
||||
let rx = '/\c\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) .\{-}\zs'. escape(a:rx, '/') .'/'
|
||||
exec 'match' self.matcher.highlight rx
|
||||
endf
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.FormatFilename(file) dict "{{{3
|
||||
let width = eval(g:tlib_inputlist_width_filename)
|
||||
let split = match(a:file, '[/\\]\zs[^/\\]\+$')
|
||||
if split == -1
|
||||
let fname = ''
|
||||
let dname = a:file
|
||||
else
|
||||
let fname = strpart(a:file, split)
|
||||
let dname = strpart(a:file, 0, split - 1)
|
||||
endif
|
||||
" let fname = fnamemodify(a:file, ":p:t")
|
||||
" " let fname = fnamemodify(a:file, ":t")
|
||||
" " if isdirectory(a:file)
|
||||
" " let fname .='/'
|
||||
" " endif
|
||||
" let dname = fnamemodify(a:file, ":h")
|
||||
" let dname = pathshorten(fnamemodify(a:file, ":h"))
|
||||
let dnmax = &co - max([width, len(fname)]) - 11 - self.index_width - &fdc
|
||||
if len(dname) > dnmax
|
||||
let dname = '...'. strpart(dname, len(dname) - dnmax)
|
||||
endif
|
||||
let marker = []
|
||||
if g:tlib_inputlist_filename_indicators
|
||||
let bnr = bufnr(a:file)
|
||||
" TLogVAR a:file, bnr, self.bufnr
|
||||
if bnr != -1
|
||||
if bnr == self.bufnr
|
||||
call add(marker, '%')
|
||||
" :nodoc:
|
||||
function! s:prototype.FormatFilename(file) dict "{{{3
|
||||
let width = self.width_filename
|
||||
let split = match(a:file, '[/\\]\zs[^/\\]\+$')
|
||||
if split == -1
|
||||
let fname = ''
|
||||
let dname = a:file
|
||||
else
|
||||
let fname = strpart(a:file, split)
|
||||
" let dname = strpart(a:file, 0, split - 1)
|
||||
let dname = a:file
|
||||
endif
|
||||
if strwidth(fname) > width
|
||||
let fname = strpart(fname, 0, width - 3) .'...'
|
||||
endif
|
||||
let dnmax = &co - max([width, len(fname)]) - 10 - self.index_width - &fdc
|
||||
if g:tlib_inputlist_filename_indicators
|
||||
let dnmax -= 2
|
||||
endif
|
||||
if len(dname) > dnmax
|
||||
let dname = '...'. strpart(dname, len(dname) - dnmax)
|
||||
endif
|
||||
let marker = []
|
||||
if g:tlib_inputlist_filename_indicators
|
||||
call insert(marker, '[')
|
||||
let bnr = bufnr(a:file)
|
||||
" TLogVAR a:file, bnr, self.bufnr
|
||||
if bnr != -1
|
||||
if bnr == self.bufnr
|
||||
call add(marker, '%')
|
||||
else
|
||||
call add(marker, bnr)
|
||||
endif
|
||||
if getbufvar(bnr, '&modified')
|
||||
call add(marker, '+')
|
||||
endif
|
||||
if getbufvar(bnr, '&bufhidden') == 'hide'
|
||||
call add(marker, 'h')
|
||||
endif
|
||||
" if !buflisted(bnr)
|
||||
" call add(marker, 'u')
|
||||
" endif
|
||||
else
|
||||
call add(marker, ' ')
|
||||
" elseif buflisted(a:file)
|
||||
" if getbufvar(a:file, "&mod")
|
||||
" call add(marker, '+')
|
||||
" else
|
||||
" call add(marker, 'B')
|
||||
" endif
|
||||
" elseif bufloaded(a:file)
|
||||
" call add(marker, 'h')
|
||||
" else
|
||||
" call add(marker, 'u')
|
||||
endif
|
||||
call add(marker, ']')
|
||||
else
|
||||
call add(marker, ' ')
|
||||
call add(marker, '|')
|
||||
endif
|
||||
endif
|
||||
call insert(marker, '|')
|
||||
call add(marker, '|')
|
||||
return printf("%-". eval(g:tlib_inputlist_width_filename) ."s %s %s", fname, join(marker, ''), dname)
|
||||
endf
|
||||
return printf("%-". self.width_filename ."s %s %s", fname, join(marker, ''), dname)
|
||||
endf
|
||||
|
||||
endif
|
||||
|
||||
|
||||
" :nodoc:
|
||||
@ -312,7 +358,11 @@ endf
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.GetBaseIdx0(idx) dict "{{{3
|
||||
return self.GetBaseIdx(a:idx) - 1
|
||||
let idx0 = self.GetBaseIdx(a:idx) - 1
|
||||
if idx0 < 0
|
||||
call tlib#notify#Echo('TLIB: Internal Error: GetBaseIdx0: idx0 < 0', 'WarningMsg')
|
||||
endif
|
||||
return idx0
|
||||
endf
|
||||
|
||||
|
||||
@ -416,22 +466,25 @@ function! s:prototype.SetFilter() dict "{{{3
|
||||
let mrx = self.FilterRxPrefix() . self.filter_options
|
||||
let self.filter_pos = []
|
||||
let self.filter_neg = []
|
||||
" TLogVAR self.filter
|
||||
" TLogVAR mrx, self.filter
|
||||
for filter in self.filter
|
||||
" TLogVAR filter
|
||||
let rx = join(reverse(filter(copy(filter), '!empty(v:val)')), '\|')
|
||||
if rx =~ '\u'
|
||||
let mrx1 = mrx .'\C'
|
||||
else
|
||||
let mrx1 = mrx
|
||||
endif
|
||||
" TLogVAR rx
|
||||
if rx[0] == g:tlib_inputlist_not
|
||||
if len(rx) > 1
|
||||
call add(self.filter_neg, mrx1 .'\('. rx[1:-1] .'\)')
|
||||
if !empty(rx)
|
||||
if rx =~ '\u'
|
||||
let mrx1 = mrx .'\C'
|
||||
else
|
||||
let mrx1 = mrx
|
||||
endif
|
||||
" TLogVAR rx
|
||||
if rx[0] == g:tlib_inputlist_not
|
||||
if len(rx) > 1
|
||||
call add(self.filter_neg, mrx1 .'\('. rx[1:-1] .'\)')
|
||||
endif
|
||||
else
|
||||
call add(self.filter_pos, mrx1 .'\('. rx .'\)')
|
||||
endif
|
||||
else
|
||||
call add(self.filter_pos, mrx1 .'\('. rx .'\)')
|
||||
endif
|
||||
endfor
|
||||
" TLogVAR self.filter_pos, self.filter_neg
|
||||
@ -485,14 +538,22 @@ endf
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.BuildTableList() dict "{{{3
|
||||
" let time0 = str2float(reltimestr(reltime())) " DBG
|
||||
" TLogVAR time0
|
||||
call self.SetFilter()
|
||||
" TLogVAR self.filter_neg, self.filter_pos
|
||||
if empty(self.filter_pos) && empty(self.filter_neg)
|
||||
let self.table = range(1, len(self.base))
|
||||
let self.list = copy(self.base)
|
||||
else
|
||||
" let time1 = str2float(reltimestr(reltime())) " DBG
|
||||
" TLogVAR time1, time1 - time0
|
||||
let self.table = filter(range(1, len(self.base)), 'self.MatchBaseIdx(v:val)')
|
||||
" let time2 = str2float(reltimestr(reltime())) " DBG
|
||||
" TLogVAR time2, time2 - time0
|
||||
let self.list = map(copy(self.table), 'self.GetBaseItem(v:val)')
|
||||
" let time3 = str2float(reltimestr(reltime())) " DBG
|
||||
" TLogVAR time3, time3 - time0
|
||||
endif
|
||||
endf
|
||||
|
||||
@ -623,25 +684,32 @@ endf
|
||||
" :nodoc:
|
||||
function! s:prototype.UseInputListScratch() dict "{{{3
|
||||
let scratch = self.UseScratch()
|
||||
" TLogVAR scratch
|
||||
syntax match InputlListIndex /^\d\+:/
|
||||
syntax match InputlListCursor /^\d\+\* .*$/ contains=InputlListIndex
|
||||
syntax match InputlListSelected /^\d\+# .*$/ contains=InputlListIndex
|
||||
hi def link InputlListIndex Constant
|
||||
hi def link InputlListCursor Search
|
||||
hi def link InputlListSelected IncSearch
|
||||
" exec "au BufEnter <buffer> call tlib#input#Resume(". string(self.name) .")"
|
||||
setlocal nowrap
|
||||
" hi def link InputlListIndex Special
|
||||
" let b:tlibDisplayListMarks = {}
|
||||
let b:tlibDisplayListMarks = []
|
||||
let b:tlibDisplayListWorld = self
|
||||
call tlib#hook#Run('tlib_UseInputListScratch', self)
|
||||
if !exists('b:tlib_list_init')
|
||||
call tlib#autocmdgroup#Init()
|
||||
autocmd TLib VimResized <buffer> call feedkeys("\<c-j>", 't')
|
||||
let b:tlib_list_init = 1
|
||||
endif
|
||||
if !exists('w:tlib_list_init')
|
||||
" TLogVAR scratch
|
||||
syntax match InputlListIndex /^\d\+:/
|
||||
syntax match InputlListCursor /^\d\+\* .*$/ contains=InputlListIndex
|
||||
syntax match InputlListSelected /^\d\+# .*$/ contains=InputlListIndex
|
||||
hi def link InputlListIndex Constant
|
||||
hi def link InputlListCursor Search
|
||||
hi def link InputlListSelected IncSearch
|
||||
setlocal nowrap
|
||||
" hi def link InputlListIndex Special
|
||||
" let b:tlibDisplayListMarks = {}
|
||||
let b:tlibDisplayListMarks = []
|
||||
let b:tlibDisplayListWorld = self
|
||||
call tlib#hook#Run('tlib_UseInputListScratch', self)
|
||||
let w:tlib_list_init = 1
|
||||
endif
|
||||
return scratch
|
||||
endf
|
||||
|
||||
|
||||
" :def: function! s:prototype.Reset(?initial=0)
|
||||
" s:prototype.Reset(?initial=0)
|
||||
" :nodoc:
|
||||
function! s:prototype.Reset(...) dict "{{{3
|
||||
TVarArg ['initial', 0]
|
||||
@ -687,56 +755,158 @@ function! s:prototype.Retrieve(anyway) dict "{{{3
|
||||
endf
|
||||
|
||||
|
||||
function! s:FormatHelp(help) "{{{3
|
||||
" TLogVAR a:help
|
||||
let max = [0, 0]
|
||||
for item in a:help
|
||||
" TLogVAR item
|
||||
if type(item) == 3
|
||||
let itemlen = map(copy(item), 'strwidth(v:val)')
|
||||
" TLogVAR itemlen
|
||||
let max = map(range(2), 'max[v:val] >= itemlen[v:val] ? max[v:val] : itemlen[v:val]')
|
||||
endif
|
||||
unlet item
|
||||
endfor
|
||||
" TLogVAR max
|
||||
let cols = float2nr((winwidth(0) - &foldcolumn - 1) / (max[0] + max[1] + 2))
|
||||
if cols < 1
|
||||
let cols = 1
|
||||
endif
|
||||
let fmt = printf('%%%ds: %%-%ds', max[0], max[1])
|
||||
" TLogVAR cols, fmt
|
||||
let help = []
|
||||
let idx = -1
|
||||
let maxidx = len(a:help)
|
||||
while idx < maxidx
|
||||
let push_item = 0
|
||||
let accum = []
|
||||
for i in range(cols)
|
||||
let idx += 1
|
||||
if idx >= maxidx
|
||||
break
|
||||
endif
|
||||
let item = a:help[idx]
|
||||
if type(item) == 3
|
||||
call add(accum, item)
|
||||
else
|
||||
let push_item = 1
|
||||
break
|
||||
endif
|
||||
unlet item
|
||||
endfor
|
||||
if !empty(accum)
|
||||
call add(help, s:FormatHelpItem(accum, fmt))
|
||||
endif
|
||||
if push_item
|
||||
call add(help, a:help[idx])
|
||||
endif
|
||||
endwh
|
||||
" TLogVAR help
|
||||
return help
|
||||
endf
|
||||
|
||||
|
||||
function! s:FormatHelpItem(item, fmt) "{{{3
|
||||
let args = [join(repeat([a:fmt], len(a:item)), ' ')]
|
||||
for item in a:item
|
||||
" TLogVAR item
|
||||
let args += item
|
||||
endfor
|
||||
" TLogVAR args
|
||||
return call('printf', args)
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.InitHelp() dict "{{{3
|
||||
return []
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.PushHelp(...) dict "{{{3
|
||||
" TLogVAR a:000
|
||||
if a:0 == 1
|
||||
if type(a:1) == 3
|
||||
let self._help += a:1
|
||||
else
|
||||
call add(self._help, a:1)
|
||||
endif
|
||||
elseif a:0 == 2
|
||||
call add(self._help, a:000)
|
||||
else
|
||||
throw "TLIB: PushHelp: Wrong number of arguments: ". string(a:000)
|
||||
endif
|
||||
" TLogVAR helpstring
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.DisplayHelp() dict "{{{3
|
||||
" \ 'Help:',
|
||||
let help = [
|
||||
\ 'Mouse ... Pick an item Letter ... Filter the list',
|
||||
\ printf('<m-Number> ... Pick an item "%s", "%s", %sWORD ... AND, OR, NOT',
|
||||
\ g:tlib_inputlist_and, g:tlib_inputlist_or, g:tlib_inputlist_not),
|
||||
\ 'Enter ... Pick the current item <bs>, <c-bs> ... Reduce filter',
|
||||
\ '<c|m-r> ... Reset the display Up/Down ... Next/previous item',
|
||||
\ '<c|m-q> ... Edit top filter string Page Up/Down ... Scroll',
|
||||
\ '<Esc> ... Abort',
|
||||
\ ]
|
||||
let self._help = self.InitHelp()
|
||||
call self.PushHelp('<Esc>', self.key_mode == 'default' ? 'Abort' : 'Reset keymap')
|
||||
call self.PushHelp('Enter, <cr>', 'Pick the current item')
|
||||
call self.PushHelp('<M-Number>', 'Pick an item')
|
||||
call self.PushHelp('Mouse', 'L: Pick item, R: Show menu')
|
||||
call self.PushHelp('<BS>, <C-BS>', 'Reduce filter')
|
||||
call self.PushHelp('<S-Esc>, <F10>', 'Enter command')
|
||||
|
||||
if self.allow_suspend
|
||||
call add(help,
|
||||
\ '<c|m-z> ... Suspend/Resume <c-o> ... Switch to origin')
|
||||
if self.key_mode == 'default'
|
||||
call self.PushHelp('<C|M-r>', 'Reset the display')
|
||||
call self.PushHelp('Up/Down', 'Next/previous item')
|
||||
call self.PushHelp('<C|M-q>', 'Edit top filter string')
|
||||
call self.PushHelp('Page Up/Down', 'Scroll')
|
||||
if self.allow_suspend
|
||||
call self.PushHelp('<C|M-z>', 'Suspend/Resume')
|
||||
call self.PushHelp('<C-o>', 'Switch to origin')
|
||||
endif
|
||||
if stridx(self.type, 'm') != -1
|
||||
call self.PushHelp('<S-up/down>', '(Un)Select items')
|
||||
call self.PushHelp('#, <C-Space>', '(Un)Select the current item')
|
||||
call self.PushHelp('<C|M-a>', '(Un)Select all items')
|
||||
" \ '<c-\> ... Show only selected',
|
||||
endif
|
||||
endif
|
||||
|
||||
if stridx(self.type, 'm') != -1
|
||||
let help += [
|
||||
\ '#, <c-space> ... (Un)Select the current item',
|
||||
\ '<c|m-a> ... (Un)Select all currently visible items',
|
||||
\ '<s-up/down> ... (Un)Select items',
|
||||
\ ]
|
||||
" \ '<c-\> ... Show only selected',
|
||||
endif
|
||||
for handler in self.key_handlers
|
||||
" TLogVAR len(self._help)
|
||||
call self.matcher.Help(self)
|
||||
|
||||
" TLogVAR self.key_mode
|
||||
for handler in values(self.key_map[self.key_mode])
|
||||
" TLogVAR handler
|
||||
let key = get(handler, 'key_name', '')
|
||||
" TLogVAR key
|
||||
if !empty(key)
|
||||
let desc = get(handler, 'help', '')
|
||||
call add(help, printf('%-12s ... %s', key, desc))
|
||||
if empty(desc)
|
||||
let desc = get(handler, 'agent', '')
|
||||
endif
|
||||
call self.PushHelp(key, desc)
|
||||
endif
|
||||
endfor
|
||||
if !empty(self.help_extra)
|
||||
let help += self.help_extra
|
||||
|
||||
if !has_key(self.key_map[self.key_mode], 'unknown_key')
|
||||
call self.PushHelp('Letter', 'Filter the list')
|
||||
endif
|
||||
let help += [
|
||||
|
||||
if self.key_mode == 'default' && !empty(self.help_extra)
|
||||
call self.PushHelp(self.help_extra)
|
||||
endif
|
||||
|
||||
" TLogVAR len(self._help)
|
||||
call self.PushHelp([
|
||||
\ '',
|
||||
\ 'Exact matches and matches at word boundaries is given more weight.',
|
||||
\ 'Warning: Please don''t resize the window with the mouse.',
|
||||
\ '',
|
||||
\ 'Press any key to continue.',
|
||||
\ ]
|
||||
\ 'Matches at word boundaries are prioritized.',
|
||||
\ ])
|
||||
let self._help = s:FormatHelp(self._help)
|
||||
let self.temp_prompt = ['Press any key to continue.', 'Question']
|
||||
" call tlib#normal#WithRegister('gg"tdG', 't')
|
||||
call tlib#buffer#DeleteRange('1', '$')
|
||||
call append(0, help)
|
||||
call append(0, self._help)
|
||||
" call tlib#normal#WithRegister('G"tddgg', 't')
|
||||
call tlib#buffer#DeleteRange('$', '$')
|
||||
1
|
||||
call self.Resize(len(help), 0)
|
||||
call self.Resize(len(self._help), 0)
|
||||
endf
|
||||
|
||||
|
||||
@ -785,12 +955,13 @@ function! s:prototype.GetResize(size) dict "{{{3
|
||||
endf
|
||||
|
||||
|
||||
" function! s:prototype.DisplayList(query, ?list)
|
||||
" function! s:prototype.DisplayList(?query=self.Query(), ?list=[])
|
||||
" :nodoc:
|
||||
function! s:prototype.DisplayList(query, ...) dict "{{{3
|
||||
" TLogVAR a:query
|
||||
function! s:prototype.DisplayList(...) dict "{{{3
|
||||
" TLogVAR self.state
|
||||
let list = a:0 >= 1 ? a:1 : []
|
||||
let query = a:0 >= 1 ? a:1 : self.Query()
|
||||
let list = a:0 >= 2 ? a:2 : []
|
||||
" TLogVAR query, len(list)
|
||||
" TLogDBG 'len(list) = '. len(list)
|
||||
call self.UseScratch()
|
||||
" TLogVAR self.scratch
|
||||
@ -799,6 +970,7 @@ function! s:prototype.DisplayList(query, ...) dict "{{{3
|
||||
call self.ScrollToOffset()
|
||||
elseif self.state == 'help'
|
||||
call self.DisplayHelp()
|
||||
call self.SetStatusline(query)
|
||||
else
|
||||
" TLogVAR query
|
||||
" let ll = len(list)
|
||||
@ -832,7 +1004,7 @@ function! s:prototype.DisplayList(query, ...) dict "{{{3
|
||||
call add(b:tlibDisplayListMarks, base_pref)
|
||||
call self.DisplayListMark(x, base_pref, '*')
|
||||
call self.SetOffset()
|
||||
call self.SetStatusline(a:query)
|
||||
call self.SetStatusline(query)
|
||||
" TLogVAR self.offset
|
||||
call self.ScrollToOffset()
|
||||
let rx0 = self.GetRx0()
|
||||
@ -841,7 +1013,11 @@ function! s:prototype.DisplayList(query, ...) dict "{{{3
|
||||
if empty(rx0)
|
||||
match none
|
||||
elseif self.IsValidFilter()
|
||||
exec 'match '. self.matcher.highlight .' /\c'. escape(rx0, '/') .'/'
|
||||
if has_key(self, 'Highlighter')
|
||||
call self.Highlighter(rx0)
|
||||
else
|
||||
exec 'match '. self.matcher.highlight .' /\c'. escape(rx0, '/') .'/'
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
@ -849,22 +1025,51 @@ function! s:prototype.DisplayList(query, ...) dict "{{{3
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.SetStatusline(query) dict "{{{3
|
||||
let query = a:query
|
||||
let options = [self.matcher.name]
|
||||
if self.sticky
|
||||
call add(options, '#')
|
||||
" TLogVAR a:query
|
||||
if !empty(self.temp_prompt)
|
||||
let echo = get(self.temp_prompt, 0, '')
|
||||
let hl = get(self.temp_prompt, 1, 'Normal')
|
||||
let self.temp_prompt = []
|
||||
else
|
||||
let hl = 'Normal'
|
||||
let query = a:query
|
||||
let options = [self.matcher.name]
|
||||
if self.sticky
|
||||
call add(options, '#')
|
||||
endif
|
||||
if self.key_mode != 'default'
|
||||
call add(options, 'map:'. self.key_mode)
|
||||
endif
|
||||
if !empty(options)
|
||||
let sopts = printf('[%s]', join(options, ', '))
|
||||
" let echo = query . repeat(' ', &columns - len(sopts) - len(query) - 20) . sopts
|
||||
let echo = query . ' ' . sopts
|
||||
" let query .= '%%='. sopts .' '
|
||||
endif
|
||||
" TLogVAR &l:statusline, query
|
||||
" let &l:statusline = query
|
||||
endif
|
||||
if !empty(options)
|
||||
let sopts = printf('[%s]', join(options, ', '))
|
||||
" let echo = query . repeat(' ', &columns - len(sopts) - len(query) - 20) . sopts
|
||||
let echo = query . ' ' . sopts
|
||||
" let query .= '%%='. sopts .' '
|
||||
endif
|
||||
" TLogVAR &l:statusline, query
|
||||
" let &l:statusline = query
|
||||
echo
|
||||
echo echo
|
||||
if hl != 'Normal'
|
||||
exec 'echohl' hl
|
||||
echo echo
|
||||
echohl None
|
||||
else
|
||||
echo echo
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.Query() dict "{{{3
|
||||
if g:tlib_inputlist_shortmessage
|
||||
let query = 'Filter: '. self.DisplayFilter()
|
||||
else
|
||||
let query = self.query .' (filter: '. self.DisplayFilter() .'; press "?" for help)'
|
||||
endif
|
||||
return query
|
||||
endf
|
||||
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2007-06-24.
|
||||
" @Last Change: 2010-11-20.
|
||||
" @Revision: 0.1.185
|
||||
" @Last Change: 2012-10-03.
|
||||
" @Revision: 0.1.208
|
||||
|
||||
|
||||
" :filedoc:
|
||||
@ -14,11 +14,16 @@
|
||||
" General {{{1
|
||||
|
||||
function! tlib#agent#Exit(world, selected) "{{{3
|
||||
call a:world.CloseScratch()
|
||||
let a:world.state = 'exit empty escape'
|
||||
let a:world.list = []
|
||||
" let a:world.base = []
|
||||
call a:world.ResetSelected()
|
||||
if a:world.key_mode == 'default'
|
||||
call a:world.CloseScratch()
|
||||
let a:world.state = 'exit empty escape'
|
||||
let a:world.list = []
|
||||
" let a:world.base = []
|
||||
call a:world.ResetSelected()
|
||||
else
|
||||
let a:world.key_mode = 'default'
|
||||
let a:world.state = 'redisplay'
|
||||
endif
|
||||
return a:world
|
||||
endf
|
||||
|
||||
@ -156,17 +161,14 @@ function! tlib#agent#Suspend(world, selected) "{{{3
|
||||
" TLogDBG bufnr('%')
|
||||
let br = tlib#buffer#Set(a:world.scratch)
|
||||
" TLogVAR br, a:world.bufnr, a:world.scratch
|
||||
" TLogDBG bufnr('%')
|
||||
if bufnr('%') != a:world.scratch
|
||||
echohl WarningMsg
|
||||
echom "tlib#agent#Suspend: Internal error: Not a scratch buffer:" bufname('%')
|
||||
echohl NONE
|
||||
endif
|
||||
" TLogVAR bufnr('%'), bufname('%'), a:world.scratch
|
||||
call tlib#autocmdgroup#Init()
|
||||
autocmd TLib InsertEnter,InsertChange <buffer> call tlib#input#Resume("world", 0)
|
||||
let b:tlib_suspend = {
|
||||
\ '<m-z>': 0, '<c-z>': 0, '<space>': 0,
|
||||
\ '<cr>': 1,
|
||||
\ '<LeftMouse>': 1, '<MiddleMouse>': 0, '<RightMouse>': 0, '<c-LeftMouse>': 0,
|
||||
\ '<': 2}
|
||||
for [m, pick] in items(b:tlib_suspend)
|
||||
exec 'noremap <buffer> '. m .' :call tlib#input#Resume("world", '. pick .')<cr>'
|
||||
endfor
|
||||
exec 'autocmd TLib BufEnter <buffer='. a:world.scratch .'> call tlib#input#Resume("world", 0, '. a:world.scratch .')'
|
||||
let b:tlib_world = a:world
|
||||
exec br
|
||||
let a:world.state = 'exit suspend'
|
||||
@ -373,6 +375,7 @@ function! tlib#agent#ViewFile(world, selected) "{{{3
|
||||
let cmd1 = 'buffer'
|
||||
endif
|
||||
call tlib#file#With(cmd0, cmd1, a:selected, a:world)
|
||||
" TLogVAR &filetype
|
||||
exec back
|
||||
let a:world.state = 'display'
|
||||
endif
|
||||
@ -512,3 +515,49 @@ function! tlib#agent#Wildcard(world, selected) "{{{3
|
||||
return a:world
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#agent#Null(world, selected) "{{{3
|
||||
let a:world.state = 'redisplay'
|
||||
return a:world
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#agent#ExecAgentByName(world, selected) "{{{3
|
||||
let s:agent_names_world = a:world
|
||||
let agent_names = {}
|
||||
for def in values(a:world.key_map[a:world.key_mode])
|
||||
if has_key(def, 'help') && !empty(def.help) && has_key(def, 'agent') && !empty(def.agent)
|
||||
let agent_names[def.help] = def.agent
|
||||
endif
|
||||
endfor
|
||||
let s:agent_names = join(sort(keys(agent_names)), "\n")
|
||||
let command = input('Command: ', '', 'custom,tlib#agent#CompleteAgentNames')
|
||||
" TLogVAR command
|
||||
if !has_key(agent_names, command)
|
||||
" TLogVAR command
|
||||
silent! let matches = filter(keys(agent_names), 'v:val =~ command')
|
||||
" TLogVAR matches
|
||||
if len(matches) == 1
|
||||
let command = matches[0]
|
||||
endif
|
||||
endif
|
||||
if has_key(agent_names, command)
|
||||
let agent = agent_names[command]
|
||||
return call(agent, [a:world, a:selected])
|
||||
else
|
||||
if !empty(command)
|
||||
echohl WarningMsg
|
||||
echom "Unknown command:" command
|
||||
echohl NONE
|
||||
sleep 1
|
||||
endif
|
||||
let a:world.state = 'display'
|
||||
return a:world
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#agent#CompleteAgentNames(ArgLead, CmdLine, CursorPos)
|
||||
return s:agent_names
|
||||
endf
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2007-06-30.
|
||||
" @Last Change: 2010-09-23.
|
||||
" @Revision: 0.0.334
|
||||
" @Last Change: 2012-02-09.
|
||||
" @Revision: 0.0.351
|
||||
|
||||
|
||||
let s:bmru = []
|
||||
@ -351,6 +351,7 @@ function! tlib#buffer#InsertText(text, ...) "{{{3
|
||||
exec 'norm! '. posshift .'h'
|
||||
endif
|
||||
endif
|
||||
" TLogDBG getline(lineno)
|
||||
" TLogDBG string(getline(1, '$'))
|
||||
return grow
|
||||
endf
|
||||
|
@ -3,8 +3,8 @@
|
||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2007-06-30.
|
||||
" @Last Change: 2011-03-10.
|
||||
" @Revision: 0.1.182
|
||||
" @Last Change: 2012-05-11.
|
||||
" @Revision: 0.1.192
|
||||
|
||||
|
||||
" |tlib#cache#Purge()|: Remove cache files older than N days.
|
||||
@ -24,6 +24,10 @@ TLet g:tlib#cache#script_encoding = &enc
|
||||
" 2 ... Yes
|
||||
TLet g:tlib#cache#run_script = 1
|
||||
|
||||
" If non-nil, don't display a message that files were deleted from the
|
||||
" cache.
|
||||
TLet g:tlib#cache#silent = 0
|
||||
|
||||
" A list of regexps that are matched against partial filenames of the
|
||||
" cached files. If a regexp matches, the file won't be removed by
|
||||
" |tlib#cache#Purge()|.
|
||||
@ -42,10 +46,10 @@ function! tlib#cache#Dir(...) "{{{3
|
||||
endf
|
||||
|
||||
|
||||
" :def: function! tlib#cache#Filename(type, ?file=%, ?mkdir=0)
|
||||
" :def: function! tlib#cache#Filename(type, ?file=%, ?mkdir=0, ?dir='')
|
||||
function! tlib#cache#Filename(type, ...) "{{{3
|
||||
" TLogDBG 'bufname='. bufname('.')
|
||||
let dir = tlib#cache#Dir()
|
||||
let dir = a:0 >= 3 && !empty(a:3) ? a:3 : tlib#cache#Dir()
|
||||
if a:0 >= 1 && !empty(a:1)
|
||||
let file = a:1
|
||||
else
|
||||
@ -87,70 +91,64 @@ endf
|
||||
|
||||
|
||||
function! tlib#cache#Save(cfile, dictionary) "{{{3
|
||||
if !empty(a:cfile)
|
||||
" TLogVAR a:dictionary
|
||||
call writefile([string(a:dictionary)], a:cfile, 'b')
|
||||
endif
|
||||
call tlib#persistent#Save(a:cfile, a:dictionary)
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#cache#Get(cfile) "{{{3
|
||||
call tlib#cache#MaybePurge()
|
||||
if !empty(a:cfile) && filereadable(a:cfile)
|
||||
let val = readfile(a:cfile, 'b')
|
||||
return eval(join(val, "\n"))
|
||||
else
|
||||
return {}
|
||||
endif
|
||||
return tlib#persistent#Get(a:cfile)
|
||||
endf
|
||||
|
||||
|
||||
" Call |tlib#cache#Purge()| if the last purge was done before
|
||||
" |g:tlib#cache#purge_every_days|.
|
||||
function! tlib#cache#MaybePurge() "{{{3
|
||||
if g:tlib#cache#purge_every_days < 0
|
||||
return
|
||||
endif
|
||||
let dir = tlib#cache#Dir('g')
|
||||
let last_purge = tlib#file#Join([dir, '.last_purge'])
|
||||
let last_purge_exists = filereadable(last_purge)
|
||||
" |g:tlib#cache#purge_every_days|.
|
||||
function! tlib#cache#MaybePurge() "{{{3
|
||||
if g:tlib#cache#purge_every_days < 0
|
||||
return
|
||||
endif
|
||||
let dir = tlib#cache#Dir('g')
|
||||
let last_purge = tlib#file#Join([dir, '.last_purge'])
|
||||
let last_purge_exists = filereadable(last_purge)
|
||||
if last_purge_exists
|
||||
let threshold = localtime() - g:tlib#cache#purge_every_days * g:tlib#date#dayshift
|
||||
let should_purge = getftime(last_purge) < threshold
|
||||
else
|
||||
let should_purge = 0 " should ignore empty dirs, like the tmru one: !empty(glob(tlib#file#Join([dir, '**'])))
|
||||
endif
|
||||
if should_purge
|
||||
if last_purge_exists
|
||||
let threshold = localtime() - g:tlib#cache#purge_every_days * g:tlib#date#dayshift
|
||||
let should_purge = getftime(last_purge) < threshold
|
||||
let yn = 'y'
|
||||
else
|
||||
let should_purge = 0 " should ignore empty dirs, like the tmru one: !empty(glob(tlib#file#Join([dir, '**'])))
|
||||
let txt = "TLib: The cache directory '". dir ."' should be purged of old files.\nDelete files older than ". g:tlib#cache#purge_days ." days now?"
|
||||
let yn = tlib#input#Dialog(txt, ['yes', 'no'], 'no')
|
||||
endif
|
||||
if should_purge
|
||||
if last_purge_exists
|
||||
let yn = 'y'
|
||||
else
|
||||
let txt = "TLib: The cache directory '". dir ."' should be purged of old files.\nDelete files older than ". g:tlib#cache#purge_days ." days now?"
|
||||
let yn = tlib#input#Dialog(txt, ['yes', 'no'], 'no')
|
||||
if yn =~ '^y\%[es]$'
|
||||
call tlib#cache#Purge()
|
||||
else
|
||||
let g:tlib#cache#purge_every_days = -1
|
||||
if !last_purge_exists
|
||||
call s:PurgeTimestamp(dir)
|
||||
endif
|
||||
if yn =~ '^y\%[es]$'
|
||||
call tlib#cache#Purge()
|
||||
else
|
||||
let g:tlib#cache#purge_every_days = -1
|
||||
if !last_purge_exists
|
||||
call s:PurgeTimestamp(dir)
|
||||
endif
|
||||
echohl WarningMsg
|
||||
echom "TLib: Please run :call tlib#cache#Purge() to clean up ". dir
|
||||
echohl NONE
|
||||
endif
|
||||
elseif !last_purge_exists
|
||||
call s:PurgeTimestamp(dir)
|
||||
echohl WarningMsg
|
||||
echom "TLib: Please run :call tlib#cache#Purge() to clean up ". dir
|
||||
echohl NONE
|
||||
endif
|
||||
endf
|
||||
elseif !last_purge_exists
|
||||
call s:PurgeTimestamp(dir)
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
" Delete old files.
|
||||
function! tlib#cache#Purge() "{{{3
|
||||
let threshold = localtime() - g:tlib#cache#purge_days * g:tlib#date#dayshift
|
||||
let dir = tlib#cache#Dir('g')
|
||||
echohl WarningMsg
|
||||
echom "TLib: Delete files older than ". g:tlib#cache#purge_days ." days from ". dir
|
||||
echohl NONE
|
||||
if !g:tlib#cache#silent
|
||||
echohl WarningMsg
|
||||
echom "TLib: Delete files older than ". g:tlib#cache#purge_days ." days from ". dir
|
||||
echohl NONE
|
||||
endif
|
||||
let files = tlib#cache#ListFilesInCache()
|
||||
let deldir = []
|
||||
let newer = []
|
||||
@ -169,7 +167,6 @@ function! tlib#cache#Purge() "{{{3
|
||||
call add(msg, "TLib: Could not delete cache file: ". file)
|
||||
else
|
||||
call add(msg, "TLib: Delete cache file: ". file)
|
||||
" echo "TLib: Delete cache file: ". file
|
||||
endif
|
||||
else
|
||||
call add(newer, file)
|
||||
@ -179,7 +176,7 @@ function! tlib#cache#Purge() "{{{3
|
||||
finally
|
||||
let &more = more
|
||||
endtry
|
||||
if !empty(msg)
|
||||
if !empty(msg) && !g:tlib#cache#silent
|
||||
echo join(msg, "\n")
|
||||
endif
|
||||
if !empty(deldir)
|
||||
@ -206,11 +203,14 @@ function! tlib#cache#Purge() "{{{3
|
||||
call inputsave()
|
||||
if g:tlib#cache#run_script == 0
|
||||
echohl WarningMsg
|
||||
echom "TLib: Please review and execute ". scriptfile
|
||||
if g:tlib#cache#silent
|
||||
echom "TLib: Purged cache. Need to run script to delete directories"
|
||||
endif
|
||||
echom "TLib: Please review and execute: ". scriptfile
|
||||
echohl NONE
|
||||
else
|
||||
try
|
||||
let yn = g:tlib#cache#run_script == 2 ? 'y' : tlib#input#Dialog("TLib: Could not delete some directories.\nDirectory removal script: ". scriptfile ."\nRun script to delete directories now?", ['yes', 'no', 'edit'], 'no')
|
||||
let yn = g:tlib#cache#run_script == 2 ? 'y' : tlib#input#Dialog("TLib: About to delete directories by means of a shell script.\nDirectory removal script: ". scriptfile ."\nRun script to delete directories now?", ['yes', 'no', 'edit'], 'no')
|
||||
if yn =~ '^y\%[es]$'
|
||||
exec 'cd '. fnameescape(dir)
|
||||
exec '! ' &shell shellescape(scriptfile, 1)
|
||||
|
@ -3,8 +3,8 @@
|
||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2007-08-23.
|
||||
" @Last Change: 2011-04-28.
|
||||
" @Revision: 0.0.31
|
||||
" @Last Change: 2012-02-10.
|
||||
" @Revision: 0.0.35
|
||||
|
||||
if &cp || exists("loaded_tlib_cmd_autoload")
|
||||
finish
|
||||
@ -12,12 +12,18 @@ endif
|
||||
let loaded_tlib_cmd_autoload = 1
|
||||
|
||||
|
||||
let g:tlib#cmd#last_output = []
|
||||
|
||||
|
||||
function! tlib#cmd#OutputAsList(command) "{{{3
|
||||
" TLogVAR a:command
|
||||
" let lines = ''
|
||||
redir => lines
|
||||
silent! exec a:command
|
||||
redir END
|
||||
return split(lines, '\n')
|
||||
" TLogVAR lines
|
||||
let g:tlib#cmd#last_output = split(lines, '\n')
|
||||
return g:tlib#cmd#last_output
|
||||
endf
|
||||
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2007-06-30.
|
||||
" @Last Change: 2010-04-03.
|
||||
" @Revision: 0.0.74
|
||||
" @Last Change: 2012-03-23.
|
||||
" @Revision: 0.0.106
|
||||
|
||||
if &cp || exists("loaded_tlib_file_autoload")
|
||||
finish
|
||||
@ -97,22 +97,34 @@ endf
|
||||
function! tlib#file#With(fcmd, bcmd, files, ...) "{{{3
|
||||
" TLogVAR a:fcmd, a:bcmd, a:files
|
||||
exec tlib#arg#Let([['world', {}]])
|
||||
call tlib#autocmdgroup#Init()
|
||||
augroup TLibFileRead
|
||||
autocmd!
|
||||
augroup END
|
||||
for f in a:files
|
||||
let bn = bufnr('^'.f.'$')
|
||||
" TLogVAR f, bn
|
||||
let bufloaded = bufloaded(bn)
|
||||
let ok = 0
|
||||
let s:bufread = ""
|
||||
if bn != -1 && buflisted(bn)
|
||||
if !empty(a:bcmd)
|
||||
" TLogDBG a:bcmd .' '. bn
|
||||
exec a:bcmd .' '. bn
|
||||
let ok = 1
|
||||
call s:SetScrollBind(world)
|
||||
endif
|
||||
else
|
||||
if filereadable(f)
|
||||
if !empty(a:fcmd)
|
||||
" TLogDBG a:fcmd .' '. escape(f, '%#\ ')
|
||||
" exec a:fcmd .' '. escape(f, '%#\ ')
|
||||
" exec a:fcmd .' '. escape(f, '%# ')
|
||||
exec a:fcmd .' '. tlib#arg#Ex(f)
|
||||
" TLogDBG a:fcmd .' '. tlib#arg#Ex(f)
|
||||
exec 'autocmd TLibFileRead BufRead' escape(f, ' ') 'let s:bufread=expand("<afile>:p")'
|
||||
try
|
||||
exec a:fcmd .' '. tlib#arg#Ex(f)
|
||||
finally
|
||||
exec 'autocmd! TLibFileRead BufRead'
|
||||
endtry
|
||||
let ok = 1
|
||||
call s:SetScrollBind(world)
|
||||
endif
|
||||
else
|
||||
@ -121,7 +133,14 @@ function! tlib#file#With(fcmd, bcmd, files, ...) "{{{3
|
||||
echohl NONE
|
||||
endif
|
||||
endif
|
||||
" TLogVAR ok, bufloaded, &filetype
|
||||
if empty(s:bufread) && ok && !bufloaded && empty(&filetype)
|
||||
doautocmd BufRead
|
||||
endif
|
||||
endfor
|
||||
augroup! TLibFileRead
|
||||
unlet! s:bufread
|
||||
" TLogDBG "done"
|
||||
endf
|
||||
|
||||
|
||||
|
@ -3,14 +3,36 @@
|
||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2007-06-30.
|
||||
" @Last Change: 2011-03-31.
|
||||
" @Revision: 0.0.840
|
||||
" @Last Change: 2012-10-01.
|
||||
" @Revision: 0.0.966
|
||||
|
||||
|
||||
" :filedoc:
|
||||
" Input-related, select from a list etc.
|
||||
|
||||
|
||||
" If true, define a popup menu for |tlib#input#List()| and related
|
||||
" functions.
|
||||
TLet g:tlib#input#use_popup = has('menu') && (has('gui_gtk') || has('gui_gtk2') || has('gui_win32'))
|
||||
|
||||
|
||||
" How to format filenames:
|
||||
" l ... Show basenames on the left side, separated from the
|
||||
" directory names
|
||||
" r ... Show basenames on the right side
|
||||
TLet g:tlib#input#format_filename = 'l'
|
||||
|
||||
|
||||
" If g:tlib#input#format_filename == 'r', how much space should be kept
|
||||
" free on the right side.
|
||||
TLet g:tlib#input#filename_padding_r = '&co / 10'
|
||||
|
||||
|
||||
" If g:tlib#input#format_filename == 'l', an expression that
|
||||
" |eval()|uates to the maximum display width of filenames.
|
||||
TLet g:tlib#input#filename_max_width = '&co / 2'
|
||||
|
||||
|
||||
" Functions related to tlib#input#List(type, ...) "{{{2
|
||||
|
||||
" :def: function! tlib#input#List(type. ?query='', ?list=[], ?handlers=[], ?default="", ?timeout=0)
|
||||
@ -115,65 +137,39 @@ endf
|
||||
" (an instance of tlib#World as returned by |tlib#World#New|).
|
||||
function! tlib#input#ListW(world, ...) "{{{3
|
||||
TVarArg 'cmd'
|
||||
if a:world.pick_last_item >= 1 && stridx(a:world.type, 'e') == -1 && len(a:world.base) <= 1
|
||||
return get(a:world.base, 0, a:world.rv)
|
||||
endif
|
||||
" let time0 = str2float(reltimestr(reltime())) " DBG
|
||||
" TLogVAR time0
|
||||
let world = a:world
|
||||
let world.filetype = &filetype
|
||||
let world.fileencoding = &fileencoding
|
||||
call world.SetMatchMode(tlib#var#Get('tlib_inputlist_match', 'wb'))
|
||||
if world.pick_last_item >= 1 && stridx(world.type, 'e') == -1 && len(world.base) <= 1
|
||||
let rv = get(world.base, 0, world.rv)
|
||||
if stridx(world.type, 'm') != -1
|
||||
return [rv]
|
||||
else
|
||||
return rv
|
||||
endif
|
||||
endif
|
||||
call s:Init(world, cmd)
|
||||
" TLogVAR world.state, world.sticky, world.initial_index
|
||||
let key_agents = copy(g:tlib_keyagents_InputList_s)
|
||||
if stridx(world.type, 'm') != -1
|
||||
call extend(key_agents, g:tlib_keyagents_InputList_m, 'force')
|
||||
endif
|
||||
if has('menu')
|
||||
amenu ]TLibInputListPopupMenu.Pick\ selected\ item <cr>
|
||||
amenu ]TLibInputListPopupMenu.Select #
|
||||
amenu ]TLibInputListPopupMenu.Select\ all <c-a>
|
||||
amenu ]TLibInputListPopupMenu.Reset\ list <c-r>
|
||||
amenu ]TLibInputListPopupMenu.Cancel <esc>
|
||||
amenu ]TLibInputListPopupMenu.-StandardEntries- :
|
||||
endif
|
||||
for handler in world.key_handlers
|
||||
let k = get(handler, 'key', '')
|
||||
if !empty(k)
|
||||
let key_agents[k] = handler.agent
|
||||
if has('menu') && has_key(handler, 'help') && !empty(handler.help)
|
||||
exec 'amenu ]TLibInputListPopupMenu.'. escape(handler.help, ' .\')
|
||||
\ .' '. handler.key_name
|
||||
let world.has_menu = 1
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
" let statusline = &l:statusline
|
||||
" let laststatus = &laststatus
|
||||
let lastsearch = @/
|
||||
let scrolloff = &l:scrolloff
|
||||
let &l:scrolloff = 0
|
||||
let @/ = ''
|
||||
let dlist = []
|
||||
" let &laststatus = 2
|
||||
let world.initial_display = 1
|
||||
|
||||
try
|
||||
while !empty(world.state) && world.state !~ '^exit' && (world.show_empty || !empty(world.base))
|
||||
" TLogDBG 'while'
|
||||
" TLogVAR world.state
|
||||
" let time01 = str2float(reltimestr(reltime())) " DBG
|
||||
" TLogVAR time01, time01 - time0
|
||||
try
|
||||
for handler in world.state_handlers
|
||||
let eh = get(handler, 'state', '')
|
||||
if !empty(eh) && world.state =~ eh
|
||||
let ea = get(handler, 'exec', '')
|
||||
if !empty(ea)
|
||||
exec ea
|
||||
else
|
||||
let agent = get(handler, 'agent', '')
|
||||
let world = call(agent, [world, world.GetSelectedItems(world.CurrentItem())])
|
||||
call s:CheckAgentReturnValue(agent, world)
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
call s:RunStateHandlers(world)
|
||||
|
||||
" let time02 = str2float(reltimestr(reltime())) " DBG
|
||||
" TLogVAR time02, time02 - time0
|
||||
if world.state =~ '\<reset\>'
|
||||
" TLogDBG 'reset'
|
||||
" call world.Reset(world.state =~ '\<initial\>')
|
||||
@ -181,23 +177,21 @@ function! tlib#input#ListW(world, ...) "{{{3
|
||||
continue
|
||||
endif
|
||||
|
||||
let llenw = len(world.base) - winheight(0) + 1
|
||||
if world.offset > llenw
|
||||
let world.offset = llenw
|
||||
endif
|
||||
if world.offset < 1
|
||||
let world.offset = 1
|
||||
endif
|
||||
call s:SetOffset(world)
|
||||
|
||||
" let time02 = str2float(reltimestr(reltime())) " DBG
|
||||
" TLogVAR time02, time02 - time0
|
||||
" TLogDBG 1
|
||||
" TLogVAR world.state
|
||||
if world.state == 'scroll'
|
||||
let world.prefidx = world.offset
|
||||
let world.state = 'redisplay'
|
||||
endif
|
||||
|
||||
if world.state =~ '\<sticky\>'
|
||||
let world.sticky = 1
|
||||
endif
|
||||
|
||||
" TLogVAR world.filter
|
||||
" TLogVAR world.sticky
|
||||
if world.state =~ '\<pick\>'
|
||||
@ -206,9 +200,15 @@ function! tlib#input#ListW(world, ...) "{{{3
|
||||
throw 'pick'
|
||||
elseif world.state =~ 'display'
|
||||
if world.state =~ '^display'
|
||||
" let time03 = str2float(reltimestr(reltime())) " DBG
|
||||
" TLogVAR time03, time03 - time0
|
||||
if world.IsValidFilter()
|
||||
|
||||
" let time1 = str2float(reltimestr(reltime())) " DBG
|
||||
" TLogVAR time1, time1 - time0
|
||||
call world.BuildTableList()
|
||||
" let time2 = str2float(reltimestr(reltime())) " DBG
|
||||
" TLogVAR time2, time2 - time0
|
||||
" TLogDBG 2
|
||||
" TLogDBG len(world.table)
|
||||
" TLogVAR world.table
|
||||
@ -223,6 +223,8 @@ function! tlib#input#ListW(world, ...) "{{{3
|
||||
let dindex = world.index_table
|
||||
let world.index_width = len(max(dindex))
|
||||
endif
|
||||
" let time3 = str2float(reltimestr(reltime())) " DBG
|
||||
" TLogVAR time3, time3 - time0
|
||||
if world.llen == 0 && !world.show_empty
|
||||
call world.ReduceFilter()
|
||||
let world.offset = 1
|
||||
@ -241,6 +243,8 @@ function! tlib#input#ListW(world, ...) "{{{3
|
||||
let world.last_item = ''
|
||||
endif
|
||||
endif
|
||||
" let time4 = str2float(reltimestr(reltime())) " DBG
|
||||
" TLogVAR time4, time4 - time0
|
||||
" TLogDBG 4
|
||||
" TLogVAR world.idx, world.llen, world.state
|
||||
" TLogDBG world.FilterIsEmpty()
|
||||
@ -256,6 +260,8 @@ function! tlib#input#ListW(world, ...) "{{{3
|
||||
let world.prefidx = 1
|
||||
endif
|
||||
endif
|
||||
" let time5 = str2float(reltimestr(reltime())) " DBG
|
||||
" TLogVAR time5, time5 - time0
|
||||
" TLogVAR world.initial_index, world.prefidx
|
||||
" TLogDBG 5
|
||||
" TLogDBG len(world.list)
|
||||
@ -270,19 +276,30 @@ function! tlib#input#ListW(world, ...) "{{{3
|
||||
endif
|
||||
" TLogVAR world.prefidx
|
||||
" TLogDBG 6
|
||||
" let time6 = str2float(reltimestr(reltime())) " DBG
|
||||
" TLogVAR time6, time6 - time0
|
||||
if world.offset_horizontal > 0
|
||||
call map(dlist, 'v:val[world.offset_horizontal:-1]')
|
||||
endif
|
||||
" let time7 = str2float(reltimestr(reltime())) " DBG
|
||||
" TLogVAR time7, time7 - time0
|
||||
" TLogVAR dindex
|
||||
let dlist = map(range(0, world.llen - 1), 'printf("%0'. world.index_width .'d", dindex[v:val]) .": ". dlist[v:val]')
|
||||
" TLogVAR dlist
|
||||
" let time8 = str2float(reltimestr(reltime())) " DBG
|
||||
" TLogVAR time8, time8 - time0
|
||||
|
||||
else
|
||||
|
||||
let dlist = ['Malformed filter']
|
||||
|
||||
endif
|
||||
else
|
||||
if world.prefidx == 0
|
||||
let world.prefidx = 1
|
||||
endif
|
||||
endif
|
||||
" TLogVAR world.idx, world.prefidx
|
||||
|
||||
" TLogDBG 7
|
||||
" TLogVAR world.prefidx, world.offset
|
||||
@ -301,12 +318,7 @@ function! tlib#input#ListW(world, ...) "{{{3
|
||||
" TLogDBG 8
|
||||
if world.initial_display || !tlib#char#IsAvailable()
|
||||
" TLogDBG len(dlist)
|
||||
if g:tlib_inputlist_shortmessage
|
||||
let query = 'Filter: '. world.DisplayFilter()
|
||||
else
|
||||
let query = world.query .' (filter: '. world.DisplayFilter() .'; press "?" for help)'
|
||||
endif
|
||||
call world.DisplayList(query, dlist)
|
||||
call world.DisplayList(world.Query(), dlist)
|
||||
call world.FollowCursor()
|
||||
let world.initial_display = 0
|
||||
" TLogDBG 9
|
||||
@ -320,7 +332,7 @@ function! tlib#input#ListW(world, ...) "{{{3
|
||||
" if world.state == 'scroll'
|
||||
" let world.prefidx = world.offset
|
||||
" endif
|
||||
call world.DisplayList('')
|
||||
call world.DisplayList()
|
||||
if world.state == 'help'
|
||||
let world.state = 'display'
|
||||
else
|
||||
@ -344,21 +356,31 @@ function! tlib#input#ListW(world, ...) "{{{3
|
||||
|
||||
" TLogVAR world.timeout
|
||||
let c = tlib#char#Get(world.timeout, world.timeout_resolution)
|
||||
" TLogVAR c, has_key(world.key_map[world.key_mode],c)
|
||||
" TLogDBG string(sort(keys(world.key_map[world.key_mode])))
|
||||
if world.state != ''
|
||||
" continue
|
||||
elseif has_key(key_agents, c)
|
||||
elseif has_key(world.key_map[world.key_mode], c)
|
||||
let sr = @/
|
||||
silent! let @/ = lastsearch
|
||||
" TLogVAR c, key_agents[c]
|
||||
" TLog "Agent: ". string(key_agents[c])
|
||||
let world = call(key_agents[c], [world, world.GetSelectedItems(world.CurrentItem())])
|
||||
" TLogVAR c, world.key_map[world.key_mode][c]
|
||||
" TLog "Agent: ". string(world.key_map[world.key_mode][c])
|
||||
let handler = world.key_map[world.key_mode][c]
|
||||
" TLogVAR handler
|
||||
let world = call(handler.agent, [world, world.GetSelectedItems(world.CurrentItem())])
|
||||
call s:CheckAgentReturnValue(c, world)
|
||||
silent! let @/ = sr
|
||||
" continue
|
||||
elseif c == 13
|
||||
throw 'pick'
|
||||
elseif c == 27
|
||||
let world.state = 'exit empty'
|
||||
" TLogVAR c, world.key_mode
|
||||
if world.key_mode != 'default'
|
||||
let world.key_mode = 'default'
|
||||
let world.state = 'redisplay'
|
||||
else
|
||||
let world.state = 'exit empty'
|
||||
endif
|
||||
elseif c == "\<LeftMouse>"
|
||||
let world.prefidx = world.GetLineIdx(v:mouse_lnum)
|
||||
" let world.offset = world.prefidx
|
||||
@ -371,12 +393,12 @@ function! tlib#input#ListW(world, ...) "{{{3
|
||||
endif
|
||||
throw 'pick'
|
||||
elseif c == "\<RightMouse>"
|
||||
if has('menu')
|
||||
if g:tlib#input#use_popup && world.has_menu
|
||||
" if v:mouse_lnum != line('.')
|
||||
" endif
|
||||
let world.prefidx = world.GetLineIdx(v:mouse_lnum)
|
||||
let world.state = 'redisplay'
|
||||
call world.DisplayList('')
|
||||
call world.DisplayList()
|
||||
if line('w$') - v:mouse_lnum < 6
|
||||
popup ]TLibInputListPopupMenu
|
||||
else
|
||||
@ -386,6 +408,9 @@ function! tlib#input#ListW(world, ...) "{{{3
|
||||
let world.state = 'redisplay'
|
||||
endif
|
||||
" TLogVAR world.prefidx, world.state
|
||||
elseif has_key(world.key_map[world.key_mode], 'unknown_key')
|
||||
let agent = world.key_map[world.key_mode].unknown_key.agent
|
||||
let world = call(agent, [world, c])
|
||||
elseif c >= 32
|
||||
let world.state = 'display'
|
||||
let numbase = get(world.numeric_chars, c, -99999)
|
||||
@ -526,8 +551,10 @@ function! tlib#input#ListW(world, ...) "{{{3
|
||||
" let &l:statusline = statusline
|
||||
" let &laststatus = laststatus
|
||||
silent! let @/ = lastsearch
|
||||
if has('menu') && world.has_menu
|
||||
let &l:scrolloff = scrolloff
|
||||
if g:tlib#input#use_popup && world.has_menu
|
||||
silent! aunmenu ]TLibInputListPopupMenu
|
||||
let world.has_menu = 0
|
||||
endif
|
||||
|
||||
" TLogDBG 'finally 2'
|
||||
@ -568,6 +595,7 @@ endf
|
||||
|
||||
function! s:Init(world, cmd) "{{{3
|
||||
" TLogVAR a:cmd
|
||||
let a:world.initial_display = 1
|
||||
if a:cmd =~ '\<sticky\>'
|
||||
let a:world.sticky = 1
|
||||
endif
|
||||
@ -582,15 +610,117 @@ function! s:Init(world, cmd) "{{{3
|
||||
endif
|
||||
elseif !a:world.initialized
|
||||
" TLogVAR a:world.initialized, a:world.win_wnr, a:world.bufnr
|
||||
let a:world.filetype = &filetype
|
||||
let a:world.fileencoding = &fileencoding
|
||||
call a:world.SetMatchMode(tlib#var#Get('tlib_inputlist_match', 'wb'))
|
||||
call a:world.Initialize()
|
||||
if !has_key(a:world, 'key_mode')
|
||||
let a:world.key_mode = 'default'
|
||||
endif
|
||||
" TLogVAR has_key(a:world,'key_map')
|
||||
if has_key(a:world, 'key_map')
|
||||
" TLogVAR has_key(a:world.key_map,a:world.key_mode)
|
||||
if has_key(a:world.key_map, a:world.key_mode)
|
||||
let a:world.key_map[a:world.key_mode] = extend(
|
||||
\ a:world.key_map[a:world.key_mode],
|
||||
\ copy(g:tlib_keyagents_InputList_s),
|
||||
\ 'keep')
|
||||
else
|
||||
let a:world.key_map[a:world.key_mode] = copy(g:tlib_keyagents_InputList_s)
|
||||
endif
|
||||
else
|
||||
let a:world.key_map = {
|
||||
\ a:world.key_mode : copy(g:tlib_keyagents_InputList_s)
|
||||
\ }
|
||||
endif
|
||||
if stridx(a:world.type, 'm') != -1
|
||||
call extend(a:world.key_map[a:world.key_mode], g:tlib_keyagents_InputList_m, 'force')
|
||||
endif
|
||||
for key_mode in keys(a:world.key_map)
|
||||
let a:world.key_map[key_mode] = map(a:world.key_map[key_mode], 'type(v:val) == 4 ? v:val : {"agent": v:val}')
|
||||
endfor
|
||||
if type(a:world.key_handlers) == 3
|
||||
call s:ExtendKeyMap(a:world, a:world.key_mode, a:world.key_handlers)
|
||||
elseif type(a:world.key_handlers) == 4
|
||||
for [world_key_mode, world_key_handlers] in items(a:world.key_handlers)
|
||||
call s:ExtendKeyMap(a:world, world_key_mode, world_key_handlers)
|
||||
endfor
|
||||
else
|
||||
throw "tlib#input#ListW: key_handlers must be either a list or a dictionary"
|
||||
endif
|
||||
if !empty(a:cmd)
|
||||
let a:world.state .= ' '. a:cmd
|
||||
endif
|
||||
endif
|
||||
call s:BuildMenu(a:world)
|
||||
" TLogVAR a:world.state, a:world.sticky
|
||||
endf
|
||||
|
||||
|
||||
function! s:ExtendKeyMap(world, key_mode, key_handlers) "{{{3
|
||||
for handler in a:key_handlers
|
||||
let k = get(handler, 'key', '')
|
||||
if !empty(k)
|
||||
let a:world.key_map[a:key_mode][k] = handler
|
||||
endif
|
||||
endfor
|
||||
endf
|
||||
|
||||
|
||||
function! s:BuildMenu(world) "{{{3
|
||||
if g:tlib#input#use_popup
|
||||
if a:world.has_menu
|
||||
silent! aunmenu ]TLibInputListPopupMenu
|
||||
endif
|
||||
amenu ]TLibInputListPopupMenu.Pick\ selected\ item <cr>
|
||||
amenu ]TLibInputListPopupMenu.Select #
|
||||
amenu ]TLibInputListPopupMenu.Select\ all <c-a>
|
||||
amenu ]TLibInputListPopupMenu.Reset\ list <c-r>
|
||||
amenu ]TLibInputListPopupMenu.Cancel <esc>
|
||||
amenu ]TLibInputListPopupMenu.-StandardEntries- :
|
||||
let a:world.has_menu = 1
|
||||
for [key_mode, key_handlers] in items(a:world.key_map)
|
||||
let keys = sort(keys(key_handlers))
|
||||
for key in keys
|
||||
let handler = key_handlers[key]
|
||||
let k = get(handler, 'key', '')
|
||||
if !empty(k) && has_key(handler, 'help') && !empty(handler.help)
|
||||
if empty(key_mode) || key_mode == 'default'
|
||||
exec 'amenu ]TLibInputListPopupMenu.'. escape(handler.help, ' .\')
|
||||
\ .' '. handler.key_name
|
||||
else
|
||||
exec 'amenu ]TLibInputListPopupMenu'.
|
||||
\ '.'. escape(key_mode, ' .\')
|
||||
\ '.'. escape(handler.help, ' .\')
|
||||
\ .' '. handler.key_name
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
function! s:RunStateHandlers(world) "{{{3
|
||||
" Provide the variable "world" in the environment of an "exec"
|
||||
" handler (ea).
|
||||
let world = a:world
|
||||
for handler in a:world.state_handlers
|
||||
let eh = get(handler, 'state', '')
|
||||
if !empty(eh) && a:world.state =~ eh
|
||||
let ea = get(handler, 'exec', '')
|
||||
if !empty(ea)
|
||||
exec ea
|
||||
else
|
||||
let agent = get(handler, 'agent', '')
|
||||
let a:world = call(agent, [a:world, a:world.GetSelectedItems(a:world.CurrentItem())])
|
||||
call s:CheckAgentReturnValue(agent, a:world)
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
endf
|
||||
|
||||
|
||||
function! s:CheckAgentReturnValue(name, value) "{{{3
|
||||
if type(a:value) != 4 && !has_key(a:value, 'state')
|
||||
echoerr 'Malformed agent: '. a:name
|
||||
@ -599,6 +729,17 @@ function! s:CheckAgentReturnValue(name, value) "{{{3
|
||||
endf
|
||||
|
||||
|
||||
function! s:SetOffset(world) "{{{3
|
||||
let llenw = len(a:world.base) - winheight(0) + 1
|
||||
if a:world.offset > llenw
|
||||
let a:world.offset = llenw
|
||||
endif
|
||||
if a:world.offset < 1
|
||||
let a:world.offset = 1
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
" Functions related to tlib#input#EditList(type, ...) "{{{2
|
||||
|
||||
" :def: function! tlib#input#EditList(query, list, ?timeout=0)
|
||||
@ -622,26 +763,47 @@ function! tlib#input#EditList(query, list, ...) "{{{3
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#input#Resume(name, pick) "{{{3
|
||||
function! tlib#input#Resume(name, pick, bufnr) "{{{3
|
||||
" TLogVAR a:name, a:pick
|
||||
echo
|
||||
if exists('b:tlib_suspend')
|
||||
for [m, pick] in items(b:tlib_suspend)
|
||||
exec 'unmap <buffer> '. m
|
||||
endfor
|
||||
unlet b:tlib_suspend
|
||||
if bufnr('%') != a:bufnr
|
||||
if g:tlib_debug
|
||||
echohl WarningMsg
|
||||
echom "tlib#input#Resume: Internal error: Not in scratch buffer:" bufname('%')
|
||||
echohl NONE
|
||||
endif
|
||||
let br = tlib#buffer#Set(a:bufnr)
|
||||
endif
|
||||
call tlib#autocmdgroup#Init()
|
||||
autocmd! TLib InsertEnter,InsertChange <buffer>
|
||||
let b:tlib_{a:name}.state = 'display'
|
||||
" call tlib#input#List('resume '. a:name)
|
||||
let cmd = 'resume '. a:name
|
||||
if a:pick >= 1
|
||||
let cmd .= ' pick'
|
||||
if a:pick >= 2
|
||||
let cmd .= ' sticky'
|
||||
end
|
||||
if !exists('b:tlib_'. a:name)
|
||||
if g:tlib_debug
|
||||
echohl WarningMsg
|
||||
echom "tlib#input#Resume: Internal error: b:tlib_". a:name ." does not exist:" bufname('%')
|
||||
echohl NONE
|
||||
redir => varss
|
||||
silent let b:
|
||||
redir END
|
||||
let vars = split(varss, '\n')
|
||||
call filter(vars, 'v:val =~ "^b:tlib_"')
|
||||
echom "DEBUG tlib#input#Resume" string(vars)
|
||||
endif
|
||||
else
|
||||
call tlib#autocmdgroup#Init()
|
||||
autocmd! TLib BufEnter <buffer>
|
||||
if b:tlib_{a:name}.state =~ '\<suspend\>'
|
||||
let b:tlib_{a:name}.state = 'redisplay'
|
||||
else
|
||||
let b:tlib_{a:name}.state .= ' redisplay'
|
||||
endif
|
||||
" call tlib#input#List('resume '. a:name)
|
||||
let cmd = 'resume '. a:name
|
||||
if a:pick >= 1
|
||||
let cmd .= ' pick'
|
||||
if a:pick >= 2
|
||||
let cmd .= ' sticky'
|
||||
end
|
||||
endif
|
||||
call tlib#input#ListW(b:tlib_{a:name}, cmd)
|
||||
endif
|
||||
call tlib#input#ListW(b:tlib_{a:name}, cmd)
|
||||
endf
|
||||
|
||||
|
||||
|
@ -3,16 +3,17 @@
|
||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2008-09-19.
|
||||
" @Last Change: 2011-03-10.
|
||||
" @Revision: 0.0.15
|
||||
" @Last Change: 2012-01-02.
|
||||
" @Revision: 0.0.19
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
|
||||
" :display: tlib#notify#Echo(text, ?style='')
|
||||
" Print text in the echo area. Temporarily disable 'ruler' and 'showcmd'
|
||||
" in order to prevent |press-enter| messages.
|
||||
function! tlib#notify#Echo(text, ...) "{{{3
|
||||
function! tlib#notify#Echo(text, ...)
|
||||
TVarArg 'style'
|
||||
let ruler = &ruler
|
||||
let showcmd = &showcmd
|
||||
|
47
sources_non_forked/tlib/autoload/tlib/persistent.vim
Normal file
47
sources_non_forked/tlib/autoload/tlib/persistent.vim
Normal file
@ -0,0 +1,47 @@
|
||||
" persistent.vim -- Persistent data
|
||||
" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2012-05-11.
|
||||
" @Last Change: 2012-05-11.
|
||||
" @Revision: 6
|
||||
|
||||
" The directory for persistent data files. If empty, use
|
||||
" |tlib#dir#MyRuntime|.'/share'.
|
||||
TLet g:tlib_persistent = ''
|
||||
|
||||
|
||||
" :display: tlib#persistent#Dir(?mode = 'bg')
|
||||
" Return the full directory name for persistent data files.
|
||||
function! tlib#persistent#Dir() "{{{3
|
||||
TVarArg ['mode', 'bg']
|
||||
let dir = tlib#var#Get('tlib_persistent', mode)
|
||||
if empty(dir)
|
||||
let dir = tlib#file#Join([tlib#dir#MyRuntime(), 'share'])
|
||||
endif
|
||||
return dir
|
||||
endf
|
||||
|
||||
" :def: function! tlib#persistent#Filename(type, ?file=%, ?mkdir=0)
|
||||
function! tlib#persistent#Filename(type, ...) "{{{3
|
||||
" TLogDBG 'bufname='. bufname('.')
|
||||
let file = a:0 >= 1 ? a:1 : ''
|
||||
let mkdir = a:0 >= 2 ? a:2 : 0
|
||||
return tlib#cache#Filename(a:type, file, mkdir, tlib#persistent#Dir())
|
||||
endf
|
||||
|
||||
function! tlib#persistent#Get(cfile) "{{{3
|
||||
if !empty(a:cfile) && filereadable(a:cfile)
|
||||
let val = readfile(a:cfile, 'b')
|
||||
return eval(join(val, "\n"))
|
||||
else
|
||||
return {}
|
||||
endif
|
||||
endf
|
||||
|
||||
function! tlib#persistent#Save(cfile, dictionary) "{{{3
|
||||
if !empty(a:cfile)
|
||||
" TLogVAR a:dictionary
|
||||
call writefile([string(a:dictionary)], a:cfile, 'b')
|
||||
endif
|
||||
endf
|
||||
|
@ -3,8 +3,8 @@
|
||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2007-07-18.
|
||||
" @Last Change: 2011-03-10.
|
||||
" @Revision: 0.0.166
|
||||
" @Last Change: 2012-02-08.
|
||||
" @Revision: 0.0.167
|
||||
|
||||
if &cp || exists("loaded_tlib_scratch_autoload")
|
||||
finish
|
||||
@ -29,7 +29,7 @@ function! tlib#scratch#UseScratch(...) "{{{3
|
||||
" TLogDBG bufnr('%')
|
||||
if id =~ '^\d\+$' && bufwinnr(id) != -1
|
||||
if bufnr('%') != id
|
||||
exec 'buffer! '. id
|
||||
exec 'noautocmd buffer! '. id
|
||||
endif
|
||||
" let ft = &ft
|
||||
let ft = '*'
|
||||
@ -47,29 +47,29 @@ function! tlib#scratch#UseScratch(...) "{{{3
|
||||
let wn = bufwinnr(bn)
|
||||
if wn != -1
|
||||
" TLogVAR wn
|
||||
exec wn .'wincmd w'
|
||||
exec 'noautocmd' (wn .'wincmd w')
|
||||
else
|
||||
if scratch_split == 1
|
||||
let cmd = wpos.' sbuffer! '
|
||||
let cmd = wpos.' sbuffer!'
|
||||
elseif scratch_split == -1
|
||||
let cmd = wpos.' tab sbuffer! '
|
||||
let cmd = wpos.' tab sbuffer!'
|
||||
else
|
||||
let cmd = 'buffer! '
|
||||
let cmd = 'buffer!'
|
||||
endif
|
||||
" TLogVAR cmd
|
||||
silent exec cmd . bn
|
||||
silent exec 'noautocmd' cmd bn
|
||||
endif
|
||||
else
|
||||
" TLogVAR id
|
||||
if scratch_split == 1
|
||||
let cmd = wpos.' split '
|
||||
let cmd = wpos.' split'
|
||||
elseif scratch_split == -1
|
||||
let cmd = wpos.' tab split '
|
||||
let cmd = wpos.' tab split'
|
||||
else
|
||||
let cmd = 'edit '
|
||||
let cmd = 'edit'
|
||||
endif
|
||||
" TLogVAR cmd
|
||||
silent exec cmd . escape(id, '%#\ ')
|
||||
silent exec 'noautocmd' cmd escape(id, '%#\ ')
|
||||
" silent exec 'split '. id
|
||||
endif
|
||||
let ft = get(keyargs, 'scratch_filetype', '')
|
||||
|
@ -3,8 +3,8 @@
|
||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2007-11-01.
|
||||
" @Last Change: 2011-03-10.
|
||||
" @Revision: 0.0.53
|
||||
" @Last Change: 2011-08-11.
|
||||
" @Revision: 0.0.56
|
||||
|
||||
if &cp || exists("loaded_tlib_tag_autoload")
|
||||
finish
|
||||
@ -38,6 +38,7 @@ let loaded_tlib_tag_autoload = 1
|
||||
" < tags from the JDK will be included.
|
||||
function! tlib#tag#Retrieve(rx, ...) "{{{3
|
||||
TVarArg ['extra_tags', 0]
|
||||
" TLogVAR a:rx, extra_tags
|
||||
if extra_tags
|
||||
let tags_orig = &l:tags
|
||||
if empty(tags_orig)
|
||||
|
155
sources_non_forked/tlib/autoload/tlib/vcs.vim
Normal file
155
sources_non_forked/tlib/autoload/tlib/vcs.vim
Normal file
@ -0,0 +1,155 @@
|
||||
" vcs.vim
|
||||
" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2012-03-08.
|
||||
" @Last Change: 2012-09-10.
|
||||
" @Revision: 122
|
||||
|
||||
|
||||
" A dictionarie of supported VCS (currently: git, hg, svn, bzr).
|
||||
" :display: g:tlib#vcs#def {...}
|
||||
TLet g:tlib#vcs#def = {
|
||||
\ 'git': {
|
||||
\ 'dir': '.git',
|
||||
\ 'ls': 'git ls-files --full-name %s',
|
||||
\ 'diff': 'git diff --no-ext-diff -U0 %s'
|
||||
\ },
|
||||
\ 'hg': {
|
||||
\ 'dir': '.hg',
|
||||
\ 'diff': 'hg diff -U0 %s',
|
||||
\ 'ls': 'hg manifest'
|
||||
\ },
|
||||
\ 'svn': {
|
||||
\ 'dir': '.svn',
|
||||
\ 'diff': 'svn diff --diff-cmd diff --extensions -U0 %s',
|
||||
\ },
|
||||
\ 'bzr': {
|
||||
\ 'dir': '.bzr',
|
||||
\ 'diff': 'bzr diff --diff-options=-U0 %s',
|
||||
\ }
|
||||
\ }
|
||||
|
||||
|
||||
" A dictionary of custom executables for VCS commands. If the value is
|
||||
" empty, support for that VCS will be removed. If no key is present, it
|
||||
" is assumed that the VCS "type" is the name of the executable.
|
||||
" :display: g:tlib#vcs#executables {...}
|
||||
TLet g:tlib#vcs#executables = {}
|
||||
|
||||
|
||||
" If non-empty, use it as a format string to check whether a VCS is
|
||||
" installed on your computer.
|
||||
TLet g:tlib#vcs#check = has('win16') || has('win32') || has('win64') ? '%s.exe' : '%s'
|
||||
|
||||
|
||||
if !empty(g:tlib#vcs#check)
|
||||
for [s:cmd, s:def] in items(g:tlib#vcs#def)
|
||||
if !has_key(g:tlib#vcs#executables, s:cmd)
|
||||
let s:cmd1 = printf(g:tlib#vcs#check, s:cmd)
|
||||
let g:tlib#vcs#executables[s:cmd] = executable(s:cmd1) ? s:cmd1 : ''
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
|
||||
function! tlib#vcs#FindVCS(filename) "{{{3
|
||||
let type = ''
|
||||
let dir = ''
|
||||
" let path = escape(fnamemodify(a:filename, ':p'), ',:') .';'
|
||||
let filename = fnamemodify(a:filename, isdirectory(a:filename) ? ':p:h' : ':p')
|
||||
let path = escape(filename, ';') .';'
|
||||
" TLogVAR a:filename, path
|
||||
let depth = -1
|
||||
for vcs in keys(g:tlib#vcs#def)
|
||||
let subdir = g:tlib#vcs#def[vcs].dir
|
||||
let vcsdir = finddir(subdir, path)
|
||||
" TLogVAR vcs, subdir, vcsdir
|
||||
if !empty(vcsdir)
|
||||
let vcsdir_depth = len(split(fnamemodify(vcsdir, ':p'), '\/'))
|
||||
if vcsdir_depth > depth
|
||||
let depth = vcsdir_depth
|
||||
let type = vcs
|
||||
let dir = vcsdir
|
||||
" TLogVAR type, depth
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
" TLogVAR type, dir
|
||||
if empty(type)
|
||||
return ['', '']
|
||||
else
|
||||
return [type, dir]
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
function! s:GetCmd(vcstype, cmd)
|
||||
let vcsdef = get(g:tlib#vcs#def, a:vcstype, {})
|
||||
if has_key(vcsdef, a:cmd)
|
||||
let cmd = vcsdef[a:cmd]
|
||||
let bin = get(g:tlib#vcs#executables, a:vcstype, '')
|
||||
if empty(bin)
|
||||
let cmd = ''
|
||||
elseif bin != a:vcstype
|
||||
" let bin = escape(shellescape(bin), '\')
|
||||
let bin = escape(bin, '\')
|
||||
let cmd = substitute(cmd, '^.\{-}\zs'. escape(a:vcstype, '\'), bin, '')
|
||||
endif
|
||||
return cmd
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
" :display: tlib#vcs#Ls(?filename=bufname('%'), ?vcs=[type, dir])
|
||||
" Return the files under VCS.
|
||||
function! tlib#vcs#Ls(...) "{{{3
|
||||
if a:0 >= 2
|
||||
let vcs = a:2
|
||||
else
|
||||
let vcs = tlib#vcs#FindVCS(a:0 >= 1 ? a:1 : bufname('%'))
|
||||
endif
|
||||
" TLogVAR vcs
|
||||
if !empty(vcs)
|
||||
let [vcstype, vcsdir] = vcs
|
||||
if has_key(g:tlib#vcs#def, vcstype)
|
||||
let ls = s:GetCmd(vcstype, 'ls')
|
||||
" TLogVAR ls
|
||||
if !empty(ls)
|
||||
let rootdir = fnamemodify(vcsdir, ':p:h:h')
|
||||
" TLogVAR vcsdir, rootdir
|
||||
if ls =~ '%s'
|
||||
let cmd = printf(ls, shellescape(rootdir))
|
||||
else
|
||||
let cmd = ls
|
||||
endif
|
||||
" TLogVAR cmd
|
||||
let filess = system(cmd)
|
||||
" TLogVAR filess
|
||||
let files = split(filess, '\n')
|
||||
call map(files, 'join([rootdir, v:val], "/")')
|
||||
return files
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
return []
|
||||
endf
|
||||
|
||||
|
||||
" :display: tlib#vcs#Diff(filename, ?vcs=[type, dir])
|
||||
" Return the diff for "filename"
|
||||
function! tlib#vcs#Diff(filename, ...) "{{{3
|
||||
let vcs = a:0 >= 1 ? a:1 : tlib#vcs#FindVCS(a:filename)
|
||||
if !empty(vcs)
|
||||
let [vcstype, vcsdir] = vcs
|
||||
let diff = s:GetCmd(vcstype, 'diff')
|
||||
if !empty(diff)
|
||||
let cmd = printf(diff, shellescape(fnamemodify(a:filename, ':p')))
|
||||
let patch = system(cmd)
|
||||
return patch
|
||||
endif
|
||||
endif
|
||||
return []
|
||||
endf
|
||||
|
@ -3,8 +3,8 @@
|
||||
" @GIT: http://github.com/tomtom/tlib_vim/
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2010-07-19.
|
||||
" @Last Change: 2010-10-24.
|
||||
" @Revision: 24
|
||||
" @Last Change: 2012-06-08.
|
||||
" @Revision: 35
|
||||
|
||||
|
||||
let s:restoreframecmd = ''
|
||||
@ -13,14 +13,22 @@ let s:fullscreen = 0
|
||||
if has('win16') || has('win32') || has('win64')
|
||||
|
||||
if !exists('g:tlib#vim#simalt_maximize')
|
||||
" The alt-key for maximizing the window.
|
||||
" CAUTION: The value of this paramter depends on your locale and
|
||||
" maybe the windows version you are running.
|
||||
let g:tlib#vim#simalt_maximize = 'x' "{{{2
|
||||
endif
|
||||
|
||||
if !exists('g:tlib#vim#simalt_restore')
|
||||
" The alt-key for restoring the window.
|
||||
" CAUTION: The value of this paramter depends on your locale and
|
||||
" maybe the windows version you are running.
|
||||
let g:tlib#vim#simalt_restore = 'r' "{{{2
|
||||
endif
|
||||
|
||||
if !exists('g:tlib#vim#use_vimtweak')
|
||||
" If true, use the vimtweak.dll for windows. This will enable
|
||||
" tlib to remove the caption for fullscreen windows.
|
||||
let g:tlib#vim#use_vimtweak = 0 "{{{2
|
||||
endif
|
||||
|
||||
@ -54,6 +62,13 @@ if has('win16') || has('win32') || has('win64')
|
||||
else
|
||||
|
||||
if !exists('g:tlib#vim#use_wmctrl')
|
||||
" If true, use wmctrl for X windows to make a window
|
||||
" maximized/fullscreen.
|
||||
"
|
||||
" This is the preferred method for maximizing windows under X
|
||||
" windows. Some window managers have problem coping with the
|
||||
" default method of setting 'lines' and 'columns' to a large
|
||||
" value.
|
||||
let g:tlib#vim#use_wmctrl = executable('wmctrl') "{{{2
|
||||
endif
|
||||
|
||||
|
Reference in New Issue
Block a user