mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
Updated all the plugins. Removed powerline. Added vim-airline (replacement for powerline). Added vim-fugitive.
This commit is contained in:
@ -3,10 +3,9 @@
|
||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2007-07-17.
|
||||
" @Last Change: 2010-01-03.
|
||||
" @Revision: 0.0.7
|
||||
" @Last Change: 2013-09-25.
|
||||
" @Revision: 0.0.12
|
||||
|
||||
" call tlog#Log('Load: '. expand('<sfile>')) " vimtlib-sfile
|
||||
|
||||
" Dummy file for backwards compatibility.
|
||||
" :nodefault:
|
||||
TLet g:tlib#debug = 0
|
||||
|
||||
|
@ -3,11 +3,11 @@
|
||||
" @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-26.
|
||||
" @Revision: 0.0.90
|
||||
" @Last Change: 2013-09-25.
|
||||
" @Revision: 0.0.92
|
||||
|
||||
let s:prototype = tlib#Object#New({'_class': ['Filter_cnf'], 'name': 'cnf'}) "{{{2
|
||||
let s:prototype.highlight = g:tlib_inputlist_higroup
|
||||
let s:prototype.highlight = g:tlib#input#higroup
|
||||
|
||||
" The search pattern for |tlib#input#List()| is in conjunctive normal
|
||||
" form: (P1 OR P2 ...) AND (P3 OR P4 ...) ...
|
||||
@ -33,7 +33,7 @@ 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),
|
||||
\ printf('"%s", "%s", "%sWORD"', g:tlib#input#and, g:tlib#input#or, g:tlib#input#not),
|
||||
\ 'AND, OR, NOT')
|
||||
endf
|
||||
|
||||
|
@ -3,11 +3,11 @@
|
||||
" @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.50
|
||||
" @Last Change: 2013-09-25.
|
||||
" @Revision: 0.0.51
|
||||
|
||||
let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_cnfd'], 'name': 'cnfd'}) "{{{2
|
||||
let s:prototype.highlight = g:tlib_inputlist_higroup
|
||||
let s:prototype.highlight = g:tlib#input#higroup
|
||||
|
||||
|
||||
" The same as |tlib#Filter_cnf#New()| but a dot is expanded to '\.\{-}'.
|
||||
|
@ -2,11 +2,11 @@
|
||||
" @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
|
||||
" @Last Change: 2013-09-25.
|
||||
" @Revision: 0.0.62
|
||||
|
||||
let s:prototype = tlib#Filter_cnfd#New({'_class': ['Filter_cnfx'], 'name': 'cnfx'}) "{{{2
|
||||
let s:prototype.highlight = g:tlib_inputlist_higroup
|
||||
let s:prototype.highlight = g:tlib#input#higroup
|
||||
|
||||
|
||||
" A character that should be expanded to '\.\{-}'.
|
||||
|
@ -3,11 +3,11 @@
|
||||
" @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.46
|
||||
" @Last Change: 2013-09-25.
|
||||
" @Revision: 0.0.47
|
||||
|
||||
let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_fuzzy'], 'name': 'fuzzy'}) "{{{2
|
||||
let s:prototype.highlight = g:tlib_inputlist_higroup
|
||||
let s:prototype.highlight = g:tlib#input#higroup
|
||||
|
||||
|
||||
" Support for "fuzzy" pattern matching in |tlib#input#List()|.
|
||||
|
@ -3,14 +3,34 @@
|
||||
" @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: 2012-10-03.
|
||||
" @Revision: 0.1.1203
|
||||
" @Last Change: 2013-09-26.
|
||||
" @Revision: 0.1.1297
|
||||
|
||||
" :filedoc:
|
||||
" A prototype used by |tlib#input#List|.
|
||||
" Inherits from |tlib#Object#New|.
|
||||
|
||||
|
||||
" Size of the input list window (in percent) from the main size (of &lines).
|
||||
" See |tlib#input#List()|.
|
||||
TLet g:tlib_inputlist_pct = 50
|
||||
|
||||
" Size of filename columns when listing filenames.
|
||||
" See |tlib#input#List()|.
|
||||
TLet g:tlib_inputlist_width_filename = '&co / 3'
|
||||
" TLet g:tlib_inputlist_width_filename = 25
|
||||
|
||||
" If true, |tlib#input#List()| will show some indicators about the
|
||||
" status of a filename (e.g. buflisted(), bufloaded() etc.).
|
||||
" This is disabled by default because vim checks also for the file on
|
||||
" disk when doing this.
|
||||
TLet g:tlib_inputlist_filename_indicators = 0
|
||||
|
||||
" If not null, display only a short info about the filter.
|
||||
TLet g:tlib_inputlist_shortmessage = 0
|
||||
|
||||
|
||||
|
||||
" Known keys & values:
|
||||
" scratch_split ... See |tlib#scratch#UseScratch()|
|
||||
let s:prototype = tlib#Object#New({
|
||||
@ -19,6 +39,7 @@ let s:prototype = tlib#Object#New({
|
||||
\ 'allow_suspend': 1,
|
||||
\ 'base': [],
|
||||
\ 'bufnr': -1,
|
||||
\ 'buffer_local': 1,
|
||||
\ 'cache_var': '',
|
||||
\ 'display_format': '',
|
||||
\ 'fileencoding': &fileencoding,
|
||||
@ -40,22 +61,26 @@ let s:prototype = tlib#Object#New({
|
||||
\ 'key_handlers': [],
|
||||
\ 'list': [],
|
||||
\ 'matcher': {},
|
||||
\ 'next_agent': '',
|
||||
\ 'next_eval': '',
|
||||
\ 'next_state': '',
|
||||
\ 'numeric_chars': tlib#var#Get('tlib_numeric_chars', 'bg'),
|
||||
\ 'numeric_chars': g:tlib#input#numeric_chars,
|
||||
\ 'offset': 1,
|
||||
\ 'offset_horizontal': 0,
|
||||
\ 'on_leave': [],
|
||||
\ 'pick_last_item': tlib#var#Get('tlib_pick_last_item', 'bg'),
|
||||
\ 'pick_last_item': tlib#var#Get('tlib#input#pick_last_item', 'bg'),
|
||||
\ 'post_handlers': [],
|
||||
\ 'query': '',
|
||||
\ 'resize': 0,
|
||||
\ 'resize_vertical': 0,
|
||||
\ 'restore_from_cache': [],
|
||||
\ 'filtered_items': [],
|
||||
\ 'retrieve_eval': '',
|
||||
\ 'return_agent': '',
|
||||
\ 'rv': '',
|
||||
\ 'scratch': '__InputList__',
|
||||
\ 'scratch_filetype': 'tlibInputList',
|
||||
\ 'scratch_hidden': g:tlib#scratch#hidden,
|
||||
\ 'scratch_vertical': 0,
|
||||
\ 'scratch_split': 1,
|
||||
\ 'sel_idx': [],
|
||||
@ -63,6 +88,7 @@ let s:prototype = tlib#Object#New({
|
||||
\ 'state': 'display',
|
||||
\ 'state_handlers': [],
|
||||
\ 'sticky': 0,
|
||||
\ 'temp_lines': [],
|
||||
\ 'temp_prompt': [],
|
||||
\ 'timeout': 0,
|
||||
\ 'timeout_resolution': 2,
|
||||
@ -77,7 +103,7 @@ let s:prototype = tlib#Object#New({
|
||||
|
||||
function! tlib#World#New(...)
|
||||
let object = s:prototype.New(a:0 >= 1 ? a:1 : {})
|
||||
call object.SetMatchMode(tlib#var#Get('tlib_inputlist_match', 'g', 'cnf'))
|
||||
call object.SetMatchMode(tlib#var#Get('tlib#input#filter_mode', 'g', 'cnf'))
|
||||
return object
|
||||
endf
|
||||
|
||||
@ -113,7 +139,7 @@ if g:tlib#input#format_filename == 'r'
|
||||
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 maxfi = max(map(copy(self.base), 'strwidth(v:val)'))
|
||||
let self.fmt_options.maxlen = min([maxco, maxfi])
|
||||
" TLogVAR maxco, maxfi, self.fmt_options.maxlen
|
||||
endif
|
||||
@ -135,11 +161,11 @@ else
|
||||
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"))'))
|
||||
\ max(map(copy(self.base), 'strwidth(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 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
|
||||
@ -154,10 +180,11 @@ else
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.FormatFilename(file) dict "{{{3
|
||||
" TLogVAR a:file
|
||||
let width = self.width_filename
|
||||
let split = match(a:file, '[/\\]\zs[^/\\]\+$')
|
||||
if split == -1
|
||||
let fname = ''
|
||||
let fname = a:file
|
||||
let dname = a:file
|
||||
else
|
||||
let fname = strpart(a:file, split)
|
||||
@ -167,15 +194,17 @@ else
|
||||
if strwidth(fname) > width
|
||||
let fname = strpart(fname, 0, width - 3) .'...'
|
||||
endif
|
||||
let dnmax = &co - max([width, len(fname)]) - 10 - self.index_width - &fdc
|
||||
let dnmax = &co - max([width, strwidth(fname)]) - 10 - self.index_width - &fdc
|
||||
if g:tlib_inputlist_filename_indicators
|
||||
let dnmax -= 2
|
||||
endif
|
||||
if len(dname) > dnmax
|
||||
if strwidth(dname) > dnmax
|
||||
let dname = '...'. strpart(dname, len(dname) - dnmax)
|
||||
endif
|
||||
let marker = []
|
||||
if g:tlib_inputlist_filename_indicators
|
||||
let use_indicators = g:tlib_inputlist_filename_indicators || has_key(self, 'filename_indicators')
|
||||
" TLogVAR use_indicators
|
||||
if use_indicators
|
||||
call insert(marker, '[')
|
||||
let bnr = bufnr(a:file)
|
||||
" TLogVAR a:file, bnr, self.bufnr
|
||||
@ -194,14 +223,24 @@ else
|
||||
" if !buflisted(bnr)
|
||||
" call add(marker, 'u')
|
||||
" endif
|
||||
else
|
||||
" echom "DBG" a:file string(get(self,'filename_indicators'))
|
||||
endif
|
||||
if has_key(self, 'filename_indicators') && has_key(self.filename_indicators, a:file)
|
||||
if len(marker) > 1
|
||||
call add(marker, '|')
|
||||
endif
|
||||
call add(marker, self.filename_indicators[a:file])
|
||||
endif
|
||||
if len(marker) <= 1
|
||||
call add(marker, ' ')
|
||||
endif
|
||||
call add(marker, ']')
|
||||
else
|
||||
call add(marker, '|')
|
||||
endif
|
||||
return printf("%-". self.width_filename ."s %s %s", fname, join(marker, ''), dname)
|
||||
return printf("%-*s %s %s",
|
||||
\ self.width_filename + len(fname) - strwidth(fname),
|
||||
\ fname, join(marker, ''), dname)
|
||||
endf
|
||||
|
||||
endif
|
||||
@ -250,6 +289,26 @@ function! s:InsertSelectedItems(rv, current) "{{{3
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.SelectItemsByNames(mode, items) dict "{{{3
|
||||
for item in a:items
|
||||
let bi = index(self.base, item) + 1
|
||||
" TLogVAR item, bi
|
||||
if bi > 0
|
||||
let si = index(self.sel_idx, bi)
|
||||
" TLogVAR self.sel_idx
|
||||
" TLogVAR si
|
||||
if si == -1
|
||||
call add(self.sel_idx, bi)
|
||||
elseif a:mode == 'toggle'
|
||||
call remove(self.sel_idx, si)
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
return 1
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.SelectItem(mode, index) dict "{{{3
|
||||
let bi = self.GetBaseIdx(a:index)
|
||||
@ -292,7 +351,7 @@ function! s:prototype.GetRx0(...) dict "{{{3
|
||||
" TLogVAR filter
|
||||
let rx = join(reverse(filter(copy(filter), '!empty(v:val)')), '\|')
|
||||
" TLogVAR rx
|
||||
if !empty(rx) && (negative ? rx[0] == g:tlib_inputlist_not : rx[0] != g:tlib_inputlist_not)
|
||||
if !empty(rx) && (negative ? rx[0] == g:tlib#input#not : rx[0] != g:tlib#input#not)
|
||||
call add(rx0, rx)
|
||||
endif
|
||||
endfor
|
||||
@ -478,7 +537,7 @@ function! s:prototype.SetFilter() dict "{{{3
|
||||
let mrx1 = mrx
|
||||
endif
|
||||
" TLogVAR rx
|
||||
if rx[0] == g:tlib_inputlist_not
|
||||
if rx[0] == g:tlib#input#not
|
||||
if len(rx) > 1
|
||||
call add(self.filter_neg, mrx1 .'\('. rx[1:-1] .'\)')
|
||||
endif
|
||||
@ -513,7 +572,7 @@ function! s:prototype.SetMatchMode(match_mode) dict "{{{3
|
||||
let self.matcher = tlib#Filter_{a:match_mode}#New()
|
||||
call self.matcher.Init(self)
|
||||
catch /^Vim\%((\a\+)\)\=:E117/
|
||||
throw 'tlib: Unknown mode for tlib_inputlist_match: '. a:match_mode
|
||||
throw 'tlib: Unknown mode for tlib#input#filter_mode: '. a:match_mode
|
||||
endtry
|
||||
endif
|
||||
endf
|
||||
@ -542,18 +601,21 @@ function! s:prototype.BuildTableList() dict "{{{3
|
||||
" 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.table = range(1, len(self.base))
|
||||
" TLogVAR self.filtered_items
|
||||
let copy_base = 1
|
||||
if !empty(self.filtered_items)
|
||||
let self.table = filter(self.table, 'index(self.filtered_items, v:val) != -1')
|
||||
let copy_base = 0
|
||||
endif
|
||||
if !empty(self.filter_pos) || !empty(self.filter_neg)
|
||||
let self.table = filter(self.table, 'self.MatchBaseIdx(v:val)')
|
||||
let copy_base = 0
|
||||
endif
|
||||
if copy_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
|
||||
|
||||
@ -634,7 +696,18 @@ endf
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.UseScratch() dict "{{{3
|
||||
keepalt return tlib#scratch#UseScratch(self)
|
||||
" if type(self.scratch) != 0 && get(self, 'buffer_local', 1)
|
||||
" if self.scratch != fnamemodify(self.scratch, ':p')
|
||||
" let self.scratch = tlib#file#Join([expand('%:p:h'), self.scratch])
|
||||
" " TLogVAR self.scratch
|
||||
" endif
|
||||
" " let self.scratch_hidden = 'wipe'
|
||||
" endif
|
||||
keepjumps keepalt let rv = tlib#scratch#UseScratch(self)
|
||||
" if expand('%:t') == self.scratch
|
||||
let b:tlib_world = self
|
||||
" endif
|
||||
return rv
|
||||
endf
|
||||
|
||||
|
||||
@ -828,12 +901,12 @@ function! s:prototype.PushHelp(...) dict "{{{3
|
||||
" TLogVAR a:000
|
||||
if a:0 == 1
|
||||
if type(a:1) == 3
|
||||
let self._help += a:1
|
||||
let self.temp_lines += a:1
|
||||
else
|
||||
call add(self._help, a:1)
|
||||
call add(self.temp_lines, a:1)
|
||||
endif
|
||||
elseif a:0 == 2
|
||||
call add(self._help, a:000)
|
||||
call add(self.temp_lines, a:000)
|
||||
else
|
||||
throw "TLIB: PushHelp: Wrong number of arguments: ". string(a:000)
|
||||
endif
|
||||
@ -843,7 +916,7 @@ endf
|
||||
|
||||
" :nodoc:
|
||||
function! s:prototype.DisplayHelp() dict "{{{3
|
||||
let self._help = self.InitHelp()
|
||||
let self.temp_lines = 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')
|
||||
@ -861,14 +934,15 @@ function! s:prototype.DisplayHelp() dict "{{{3
|
||||
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('<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')
|
||||
call self.PushHelp('<F9>', '(Un)Restrict view to selection')
|
||||
" \ '<c-\> ... Show only selected',
|
||||
endif
|
||||
endif
|
||||
|
||||
" TLogVAR len(self._help)
|
||||
" TLogVAR len(self.temp_lines)
|
||||
call self.matcher.Help(self)
|
||||
|
||||
" TLogVAR self.key_mode
|
||||
@ -893,20 +967,24 @@ function! s:prototype.DisplayHelp() dict "{{{3
|
||||
call self.PushHelp(self.help_extra)
|
||||
endif
|
||||
|
||||
" TLogVAR len(self._help)
|
||||
" TLogVAR len(self.temp_lines)
|
||||
call self.PushHelp([
|
||||
\ '',
|
||||
\ 'Matches at word boundaries are prioritized.',
|
||||
\ ])
|
||||
let self._help = s:FormatHelp(self._help)
|
||||
let self.temp_lines = s:FormatHelp(self.temp_lines)
|
||||
call self.PrintLines()
|
||||
endf
|
||||
|
||||
|
||||
function! s:prototype.PrintLines() dict "{{{3
|
||||
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, self._help)
|
||||
" call tlib#normal#WithRegister('G"tddgg', 't')
|
||||
call append(0, self.temp_lines)
|
||||
call tlib#buffer#DeleteRange('$', '$')
|
||||
1
|
||||
call self.Resize(len(self._help), 0)
|
||||
call self.Resize(len(self.temp_lines), 0)
|
||||
let self.temp_lines = []
|
||||
endf
|
||||
|
||||
|
||||
@ -914,12 +992,14 @@ endf
|
||||
function! s:prototype.Resize(hsize, vsize) dict "{{{3
|
||||
" TLogVAR self.scratch_vertical, a:hsize, a:vsize
|
||||
let world_resize = ''
|
||||
let winpos = ''
|
||||
let scratch_split = get(self, 'scratch_split', 1)
|
||||
" TLogVAR scratch_split
|
||||
if scratch_split > 0
|
||||
if self.scratch_vertical
|
||||
if a:vsize
|
||||
let world_resize = 'vert resize '. a:vsize
|
||||
let winpos = tlib#fixes#Winpos()
|
||||
" let w:winresize = {'v': a:vsize}
|
||||
setlocal winfixwidth
|
||||
endif
|
||||
@ -932,8 +1012,11 @@ function! s:prototype.Resize(hsize, vsize) dict "{{{3
|
||||
endif
|
||||
endif
|
||||
if !empty(world_resize)
|
||||
" TLogVAR world_resize
|
||||
" TLogVAR world_resize, winpos
|
||||
exec world_resize
|
||||
if !empty(winpos)
|
||||
exec winpos
|
||||
endif
|
||||
" redraw!
|
||||
endif
|
||||
endf
|
||||
@ -971,6 +1054,9 @@ function! s:prototype.DisplayList(...) dict "{{{3
|
||||
elseif self.state == 'help'
|
||||
call self.DisplayHelp()
|
||||
call self.SetStatusline(query)
|
||||
elseif self.state == 'printlines'
|
||||
call self.PrintLines()
|
||||
call self.SetStatusline(query)
|
||||
else
|
||||
" TLogVAR query
|
||||
" let ll = len(list)
|
||||
@ -1042,6 +1128,13 @@ function! s:prototype.SetStatusline(query) dict "{{{3
|
||||
if self.key_mode != 'default'
|
||||
call add(options, 'map:'. self.key_mode)
|
||||
endif
|
||||
if !empty(self.filtered_items)
|
||||
if g:tlib_inputlist_shortmessage
|
||||
call add(options, 'R')
|
||||
else
|
||||
call add(options, 'restricted')
|
||||
endif
|
||||
endif
|
||||
if !empty(options)
|
||||
let sopts = printf('[%s]', join(options, ', '))
|
||||
" let echo = query . repeat(' ', &columns - len(sopts) - len(query) - 20) . sopts
|
||||
|
@ -3,13 +3,16 @@
|
||||
" @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: 2012-10-03.
|
||||
" @Revision: 0.1.208
|
||||
" @Last Change: 2013-09-26.
|
||||
" @Revision: 0.1.240
|
||||
|
||||
|
||||
" :filedoc:
|
||||
" Various agents for use as key handlers in tlib#input#List()
|
||||
|
||||
" Number of items to move when pressing <c-up/down> in the input list window.
|
||||
TLet g:tlib_scroll_lines = 10
|
||||
|
||||
|
||||
" General {{{1
|
||||
|
||||
@ -111,6 +114,36 @@ function! tlib#agent#Reset(world, selected) "{{{3
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#agent#ToggleRestrictView(world, selected) "{{{3
|
||||
if empty(a:world.filtered_items)
|
||||
return tlib#agent#RestrictView(a:world, a:selected)
|
||||
else
|
||||
return tlib#agent#UnrestrictView(a:world, a:selected)
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#agent#RestrictView(world, selected) "{{{3
|
||||
" TLogVAR a:selected
|
||||
let filtered_items = map(copy(a:selected), 'index(a:world.base, v:val) + 1')
|
||||
" TLogVAR 1, filtered_items
|
||||
let filtered_items = filter(filtered_items, 'v:val > 0')
|
||||
" TLogVAR 2, filtered_items
|
||||
if !empty(filtered_items)
|
||||
let a:world.filtered_items = filtered_items
|
||||
endif
|
||||
let a:world.state = 'display'
|
||||
return a:world
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#agent#UnrestrictView(world, selected) "{{{3
|
||||
let a:world.filtered_items = []
|
||||
let a:world.state = 'display'
|
||||
return a:world
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#agent#Input(world, selected) "{{{3
|
||||
let flt0 = a:world.CleanFilter(a:world.filter[0][0])
|
||||
let flt1 = input('Filter: ', flt0)
|
||||
@ -401,7 +434,11 @@ function! tlib#agent#EditFileInVSplit(world, selected) "{{{3
|
||||
call a:world.CloseScratch()
|
||||
" call tlib#file#With('edit', 'buffer', a:selected[0:0], a:world)
|
||||
" call tlib#file#With('vertical split', 'vertical sbuffer', a:selected[1:-1], a:world)
|
||||
let winpos = tlib#fixes#Winpos()
|
||||
call tlib#file#With('vertical split', 'vertical sbuffer', a:selected, a:world)
|
||||
if !empty(winpos)
|
||||
exec winpos
|
||||
endif
|
||||
return tlib#agent#Exit(a:world, a:selected)
|
||||
endf
|
||||
|
||||
@ -419,19 +456,18 @@ function! tlib#agent#ToggleScrollbind(world, selected) "{{{3
|
||||
return a:world
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#agent#ShowInfo(world, selected)
|
||||
let lines = []
|
||||
for f in a:selected
|
||||
if filereadable(f)
|
||||
let desc = [getfperm(f), strftime('%c', getftime(f)), getfsize(f) .' bytes', getftype(f)]
|
||||
echo fnamemodify(f, ':t') .':'
|
||||
echo ' '. join(desc, '; ')
|
||||
call add(lines, fnamemodify(f, ':t') .':')
|
||||
call add(lines, ' '. join(desc, '; '))
|
||||
endif
|
||||
endfor
|
||||
echohl MoreMsg
|
||||
echo 'Press any key to continue'
|
||||
echohl NONE
|
||||
call getchar()
|
||||
let a:world.state = 'redisplay'
|
||||
let a:world.temp_lines = lines
|
||||
let a:world.state = 'printlines'
|
||||
return a:world
|
||||
endf
|
||||
|
||||
@ -530,8 +566,8 @@ function! tlib#agent#ExecAgentByName(world, selected) "{{{3
|
||||
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')
|
||||
let s:agent_names = sort(keys(agent_names))
|
||||
let command = input('Command: ', '', 'customlist,tlib#agent#CompleteAgentNames')
|
||||
" TLogVAR command
|
||||
if !has_key(agent_names, command)
|
||||
" TLogVAR command
|
||||
@ -558,6 +594,6 @@ endf
|
||||
|
||||
|
||||
function! tlib#agent#CompleteAgentNames(ArgLead, CmdLine, CursorPos)
|
||||
return s:agent_names
|
||||
return filter(copy(s:agent_names), 'stridx(v:val, a:ArgLead) != -1')
|
||||
endf
|
||||
|
||||
|
@ -2,13 +2,7 @@
|
||||
" @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-08-19.
|
||||
" @Last Change: 2010-01-05.
|
||||
" @Revision: 0.0.6
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" @Revision: 7
|
||||
|
||||
augroup TLib
|
||||
autocmd!
|
||||
@ -18,6 +12,3 @@ augroup END
|
||||
function! tlib#autocmdgroup#Init() "{{{3
|
||||
endf
|
||||
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
@ -4,7 +4,7 @@
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2010-08-30.
|
||||
" @Last Change: 2010-09-05.
|
||||
" @Revision: 23
|
||||
" @Revision: 27
|
||||
|
||||
|
||||
function! tlib#balloon#Register(expr) "{{{3
|
||||
@ -37,10 +37,12 @@ endf
|
||||
|
||||
|
||||
function! tlib#balloon#Expr() "{{{3
|
||||
" TLogVAR exists('b:tlib_balloons')
|
||||
if !exists('b:tlib_balloons')
|
||||
return ''
|
||||
endif
|
||||
let text = map(copy(b:tlib_balloons), 'eval(v:val)')
|
||||
" TLogVAR b:tlib_balloons, text
|
||||
call filter(text, '!empty(v:val)')
|
||||
if has('balloon_multiline')
|
||||
return join(text, "\n----------------------------------\n")
|
||||
|
141
sources_non_forked/tlib/autoload/tlib/bitwise.vim
Normal file
141
sources_non_forked/tlib/autoload/tlib/bitwise.vim
Normal file
@ -0,0 +1,141 @@
|
||||
" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Revision: 124
|
||||
|
||||
|
||||
function! tlib#bitwise#Num2Bits(num) "{{{3
|
||||
if type(a:num) <= 1 || type(a:num) == 5
|
||||
let bits = reverse(tlib#number#ConvertBase(a:num, 2, 'list'))
|
||||
elseif type(a:num) == 3
|
||||
let bits = copy(a:num)
|
||||
else
|
||||
throw "tlib#bitwise#Num2Bits: Must be number of list: ". string(a:num)
|
||||
endif
|
||||
return bits
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#bitwise#Bits2Num(bits, ...) "{{{3
|
||||
let base = a:0 >= 1 ? a:1 : 10
|
||||
" TLogVAR a:bits
|
||||
let num = 0.0
|
||||
for i in range(len(a:bits))
|
||||
if get(a:bits, i, 0)
|
||||
let num += pow(2, i)
|
||||
endif
|
||||
endfor
|
||||
" TLogVAR num
|
||||
if base == 10
|
||||
if type(base) == 5
|
||||
return num
|
||||
else
|
||||
return float2nr(num)
|
||||
endif
|
||||
else
|
||||
return tlib#number#ConvertBase(num, base)
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#bitwise#AND(num1, num2, ...) "{{{3
|
||||
let rtype = a:0 >= 1 ? a:1 : 'num'
|
||||
return s:BitwiseComparison(a:num1, a:num2, rtype,
|
||||
\ 'get(bits1, v:val) && get(bits2, v:val)')
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#bitwise#OR(num1, num2, ...) "{{{3
|
||||
let rtype = a:0 >= 1 ? a:1 : 'num'
|
||||
return s:BitwiseComparison(a:num1, a:num2, rtype,
|
||||
\ 'get(bits1, v:val) || get(bits2, v:val)')
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#bitwise#XOR(num1, num2, ...) "{{{3
|
||||
let rtype = a:0 >= 1 ? a:1 : 'num'
|
||||
return s:BitwiseComparison(a:num1, a:num2, rtype,
|
||||
\ 'get(bits1, v:val) ? !get(bits2, v:val) : get(bits2, v:val)')
|
||||
endf
|
||||
|
||||
|
||||
function! s:BitwiseComparison(num1, num2, rtype, expr) "{{{3
|
||||
let bits1 = tlib#bitwise#Num2Bits(a:num1)
|
||||
let bits2 = tlib#bitwise#Num2Bits(a:num2)
|
||||
let range = range(max([len(bits1), len(bits2)]))
|
||||
let bits = map(range, a:expr)
|
||||
if a:rtype == 'num' || (a:rtype == 'auto' && type(a:num1) <= 1)
|
||||
return tlib#bitwise#Bits2Num(bits)
|
||||
else
|
||||
return bits
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#bitwise#ShiftRight(bits, n) "{{{3
|
||||
let bits = a:bits[a:n : -1]
|
||||
if empty(bits)
|
||||
let bits = [0]
|
||||
endif
|
||||
return bits
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#bitwise#ShiftLeft(bits, n) "{{{3
|
||||
let bits = repeat([0], a:n) + a:bits
|
||||
return bits
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#bitwise#Add(num1, num2, ...) "{{{3
|
||||
let rtype = a:0 >= 1 ? a:1 : 'num'
|
||||
let bits1 = tlib#bitwise#Num2Bits(a:num1)
|
||||
let bits2 = tlib#bitwise#Num2Bits(a:num2)
|
||||
let range = range(max([len(bits1), len(bits2)]))
|
||||
" TLogVAR bits1, bits2, range
|
||||
let carry = 0
|
||||
let bits = []
|
||||
for i in range
|
||||
let sum = get(bits1, i) + get(bits2, i) + carry
|
||||
if sum == 3
|
||||
let bit = 1
|
||||
let carry = 1
|
||||
elseif sum == 2
|
||||
let bit = 0
|
||||
let carry = 1
|
||||
elseif sum == 1
|
||||
let bit = 1
|
||||
let carry = 0
|
||||
elseif sum == 0
|
||||
let bit = 0
|
||||
let carry = 0
|
||||
endif
|
||||
call add(bits, bit)
|
||||
" TLogVAR i, bits, bit
|
||||
endfor
|
||||
if carry == 1
|
||||
call add(bits, carry)
|
||||
endif
|
||||
if rtype == 'num' || (rtype == 'auto' && type(a:num1) <= 1)
|
||||
return tlib#bitwise#Bits2Num(bits)
|
||||
else
|
||||
return bits
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#bitwise#Sub(num1, num2, ...) "{{{3
|
||||
let rtype = a:0 >= 1 ? a:1 : 'num'
|
||||
let bits1 = tlib#bitwise#Num2Bits(a:num1)
|
||||
let bits2 = tlib#bitwise#Num2Bits(a:num2)
|
||||
let range = range(max([len(bits1), len(bits2)]))
|
||||
let bits2 = map(range, '!get(bits2, v:val)')
|
||||
let bits2 = tlib#bitwise#Add(bits2, [1], 'bits')
|
||||
let bits3 = tlib#bitwise#Add(bits1, bits2, 'bits')
|
||||
let bits = bits3[0 : -2]
|
||||
if rtype == 'num' || (rtype == 'auto' && type(a:num1) <= 1)
|
||||
return tlib#bitwise#Bits2Num(bits)
|
||||
else
|
||||
return bits
|
||||
endif
|
||||
endf
|
||||
|
@ -3,8 +3,13 @@
|
||||
" @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: 2012-02-09.
|
||||
" @Revision: 0.0.351
|
||||
" @Last Change: 2013-09-25.
|
||||
" @Revision: 0.0.352
|
||||
|
||||
|
||||
" Where to display the line when using |tlib#buffer#ViewLine|.
|
||||
" For possible values for position see |scroll-cursor|.
|
||||
TLet g:tlib_viewline_position = 'zz'
|
||||
|
||||
|
||||
let s:bmru = []
|
||||
|
@ -3,10 +3,16 @@
|
||||
" @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: 2012-05-11.
|
||||
" @Revision: 0.1.192
|
||||
" @Last Change: 2013-09-25.
|
||||
" @Revision: 0.1.220
|
||||
|
||||
|
||||
" The cache directory. If empty, use |tlib#dir#MyRuntime|.'/cache'.
|
||||
" You might want to delete old files from this directory from time to
|
||||
" time with a command like: >
|
||||
" find ~/vimfiles/cache/ -atime +31 -type f -print -delete
|
||||
TLet g:tlib_cache = ''
|
||||
|
||||
" |tlib#cache#Purge()|: Remove cache files older than N days.
|
||||
TLet g:tlib#cache#purge_days = 31
|
||||
|
||||
@ -24,15 +30,21 @@ 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
|
||||
" Verbosity level:
|
||||
" 0 ... Be quiet
|
||||
" 1 ... Display informative message
|
||||
" 2 ... Display detailed messages
|
||||
TLet g:tlib#cache#verbosity = 1
|
||||
|
||||
" 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()|.
|
||||
TLet g:tlib#cache#dont_purge = ['[\/]\.last_purge$']
|
||||
|
||||
" If the cache filename is longer than N characters, use
|
||||
" |pathshorten()|.
|
||||
TLet g:tlib#cache#max_filename = 200
|
||||
|
||||
|
||||
" :display: tlib#cache#Dir(?mode = 'bg')
|
||||
" The default cache directory.
|
||||
@ -49,7 +61,8 @@ endf
|
||||
" :def: function! tlib#cache#Filename(type, ?file=%, ?mkdir=0, ?dir='')
|
||||
function! tlib#cache#Filename(type, ...) "{{{3
|
||||
" TLogDBG 'bufname='. bufname('.')
|
||||
let dir = a:0 >= 3 && !empty(a:3) ? a:3 : tlib#cache#Dir()
|
||||
let dir0 = a:0 >= 3 && !empty(a:3) ? a:3 : tlib#cache#Dir()
|
||||
let dir = dir0
|
||||
if a:0 >= 1 && !empty(a:1)
|
||||
let file = a:1
|
||||
else
|
||||
@ -73,18 +86,23 @@ function! tlib#cache#Filename(type, ...) "{{{3
|
||||
" TLogVAR dir
|
||||
let file = fnamemodify(file, ':t')
|
||||
" TLogVAR file, dir, mkdir
|
||||
if mkdir && !isdirectory(dir)
|
||||
try
|
||||
call mkdir(dir, 'p')
|
||||
catch /^Vim\%((\a\+)\)\=:E739:/
|
||||
if filereadable(dir) && !isdirectory(dir)
|
||||
echoerr 'TLib: Cannot create directory for cache file because a file with the same name exists (please delete it):' dir
|
||||
" call delete(dir)
|
||||
" call mkdir(dir, 'p')
|
||||
endif
|
||||
endtry
|
||||
endif
|
||||
let cache_file = tlib#file#Join([dir, file])
|
||||
if len(cache_file) > g:tlib#cache#max_filename
|
||||
let shortfilename = pathshorten(file) .'_'. tlib#hash#Adler32(file)
|
||||
let cache_file = tlib#cache#Filename(a:type, shortfilename, mkdir, dir0)
|
||||
else
|
||||
if mkdir && !isdirectory(dir)
|
||||
try
|
||||
call mkdir(dir, 'p')
|
||||
catch /^Vim\%((\a\+)\)\=:E739:/
|
||||
if filereadable(dir) && !isdirectory(dir)
|
||||
echoerr 'TLib: Cannot create directory for cache file because a file with the same name exists (please delete it):' dir
|
||||
" call delete(dir)
|
||||
" call mkdir(dir, 'p')
|
||||
endif
|
||||
endtry
|
||||
endif
|
||||
endif
|
||||
" TLogVAR cache_file
|
||||
return cache_file
|
||||
endf
|
||||
@ -101,6 +119,22 @@ function! tlib#cache#Get(cfile) "{{{3
|
||||
endf
|
||||
|
||||
|
||||
" Get a cached value from cfile. If it is outdated (compared to ftime)
|
||||
" or does not exist, create it calling a generator function.
|
||||
function! tlib#cache#Value(cfile, generator, ftime, ...) "{{{3
|
||||
if !filereadable(a:cfile) || (a:ftime != 0 && getftime(a:cfile) < a:ftime)
|
||||
let args = a:0 >= 1 ? a:1 : []
|
||||
let val = call(a:generator, args)
|
||||
" TLogVAR a:generator, args, val
|
||||
call tlib#cache#Save(a:cfile, {'val': val})
|
||||
return val
|
||||
else
|
||||
let val = tlib#cache#Get(a:cfile)
|
||||
return val.val
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
" Call |tlib#cache#Purge()| if the last purge was done before
|
||||
" |g:tlib#cache#purge_every_days|.
|
||||
function! tlib#cache#MaybePurge() "{{{3
|
||||
@ -144,7 +178,7 @@ endf
|
||||
function! tlib#cache#Purge() "{{{3
|
||||
let threshold = localtime() - g:tlib#cache#purge_days * g:tlib#date#dayshift
|
||||
let dir = tlib#cache#Dir('g')
|
||||
if !g:tlib#cache#silent
|
||||
if g:tlib#cache#verbosity >= 1
|
||||
echohl WarningMsg
|
||||
echom "TLib: Delete files older than ". g:tlib#cache#purge_days ." days from ". dir
|
||||
echohl NONE
|
||||
@ -165,7 +199,7 @@ function! tlib#cache#Purge() "{{{3
|
||||
if getftime(file) < threshold
|
||||
if delete(file)
|
||||
call add(msg, "TLib: Could not delete cache file: ". file)
|
||||
else
|
||||
elseif g:tlib#cache#verbosity >= 2
|
||||
call add(msg, "TLib: Delete cache file: ". file)
|
||||
endif
|
||||
else
|
||||
@ -176,7 +210,7 @@ function! tlib#cache#Purge() "{{{3
|
||||
finally
|
||||
let &more = more
|
||||
endtry
|
||||
if !empty(msg) && !g:tlib#cache#silent
|
||||
if !empty(msg) && g:tlib#cache#verbosity >= 1
|
||||
echo join(msg, "\n")
|
||||
endif
|
||||
if !empty(deldir)
|
||||
@ -202,12 +236,14 @@ function! tlib#cache#Purge() "{{{3
|
||||
call writefile(script, scriptfile)
|
||||
call inputsave()
|
||||
if g:tlib#cache#run_script == 0
|
||||
echohl WarningMsg
|
||||
if g:tlib#cache#silent
|
||||
echom "TLib: Purged cache. Need to run script to delete directories"
|
||||
if g:tlib#cache#verbosity >= 1
|
||||
echohl WarningMsg
|
||||
if g:tlib#cache#verbosity >= 2
|
||||
echom "TLib: Purged cache. Need to run script to delete directories"
|
||||
endif
|
||||
echom "TLib: Please review and execute: ". scriptfile
|
||||
echohl NONE
|
||||
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: About to delete directories by means of a shell script.\nDirectory removal script: ". scriptfile ."\nRun script to delete directories now?", ['yes', 'no', 'edit'], 'no')
|
||||
|
@ -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: 2012-02-10.
|
||||
" @Revision: 0.0.35
|
||||
" @Last Change: 2013-05-14.
|
||||
" @Revision: 0.0.46
|
||||
|
||||
if &cp || exists("loaded_tlib_cmd_autoload")
|
||||
finish
|
||||
@ -17,12 +17,20 @@ let g:tlib#cmd#last_output = []
|
||||
|
||||
function! tlib#cmd#OutputAsList(command) "{{{3
|
||||
" TLogVAR a:command
|
||||
" let lines = ''
|
||||
redir => lines
|
||||
if exists('s:redir_lines')
|
||||
redir END
|
||||
let cache = s:redir_lines
|
||||
endif
|
||||
let s:redir_lines = ''
|
||||
redir =>> s:redir_lines
|
||||
silent! exec a:command
|
||||
redir END
|
||||
" TLogVAR lines
|
||||
let g:tlib#cmd#last_output = split(lines, '\n')
|
||||
let g:tlib#cmd#last_output = split(s:redir_lines, '\n')
|
||||
unlet s:redir_lines
|
||||
if exists('cache')
|
||||
let s:redir_lines = cache
|
||||
redir =>> s:redir_lines
|
||||
endif
|
||||
return g:tlib#cmd#last_output
|
||||
endf
|
||||
|
||||
|
@ -3,14 +3,18 @@
|
||||
" @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: 2009-08-04.
|
||||
" @Revision: 0.0.32
|
||||
" @Last Change: 2013-09-25.
|
||||
" @Revision: 0.0.37
|
||||
|
||||
if &cp || exists("loaded_tlib_dir_autoload")
|
||||
finish
|
||||
endif
|
||||
let loaded_tlib_dir_autoload = 1
|
||||
|
||||
" TLet g:tlib#dir#sep = '/'
|
||||
TLet g:tlib#dir#sep = exists('+shellslash') && !&shellslash ? '\' : '/'
|
||||
|
||||
|
||||
let s:dir_stack = []
|
||||
|
||||
" EXAMPLES: >
|
||||
@ -18,12 +22,25 @@ let s:dir_stack = []
|
||||
" => 'foo/bar/'
|
||||
function! tlib#dir#CanonicName(dirname) "{{{3
|
||||
if a:dirname !~ '[/\\]$'
|
||||
return a:dirname . g:tlib_filename_sep
|
||||
return a:dirname . g:tlib#dir#sep
|
||||
endif
|
||||
return a:dirname
|
||||
endf
|
||||
|
||||
|
||||
" EXAMPLES: >
|
||||
" tlib#dir#NativeName('foo/bar/')
|
||||
" On Windows:
|
||||
" => 'foo\bar\'
|
||||
" On Linux:
|
||||
" => 'foo/bar/'
|
||||
function! tlib#dir#NativeName(dirname) "{{{3
|
||||
let sep = tlib#rx#EscapeReplace(g:tlib#dir#sep)
|
||||
let dirname = substitute(a:dirname, '[\/]', sep, 'g')
|
||||
return dirname
|
||||
endf
|
||||
|
||||
|
||||
" EXAMPLES: >
|
||||
" tlib#dir#PlainName('foo/bar/')
|
||||
" => 'foo/bar'
|
||||
@ -33,7 +50,7 @@ function! tlib#dir#PlainName(dirname) "{{{3
|
||||
let dirname = dirname[0 : -2]
|
||||
endwh
|
||||
return dirname
|
||||
" return substitute(a:dirname, tlib#rx#Escape(g:tlib_filename_sep).'\+$', '', '')
|
||||
" return substitute(a:dirname, tlib#rx#Escape(g:tlib#dir#sep).'\+$', '', '')
|
||||
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: 2012-03-23.
|
||||
" @Revision: 0.0.106
|
||||
" @Last Change: 2013-09-25.
|
||||
" @Revision: 0.0.141
|
||||
|
||||
if &cp || exists("loaded_tlib_file_autoload")
|
||||
finish
|
||||
@ -42,13 +42,15 @@ endf
|
||||
" => 'foo/bar/filename.txt'
|
||||
function! tlib#file#Join(filename_parts, ...) "{{{3
|
||||
TVarArg 'strip_slashes'
|
||||
" TLogVAR a:filename_parts, strip_slashes
|
||||
if strip_slashes
|
||||
" let rx = tlib#rx#Escape(g:tlib_filename_sep) .'$'
|
||||
let rx = '[/\\]$'
|
||||
" let rx = tlib#rx#Escape(g:tlib#dir#sep) .'$'
|
||||
let rx = '[/\\]\+$'
|
||||
let parts = map(copy(a:filename_parts), 'substitute(v:val, rx, "", "")')
|
||||
return join(parts, g:tlib_filename_sep)
|
||||
" TLogVAR parts
|
||||
return join(parts, g:tlib#dir#sep)
|
||||
else
|
||||
return join(a:filename_parts, g:tlib_filename_sep)
|
||||
return join(a:filename_parts, g:tlib#dir#sep)
|
||||
endif
|
||||
endf
|
||||
|
||||
@ -60,14 +62,14 @@ function! tlib#file#Relative(filename, basedir) "{{{3
|
||||
" TLogVAR a:filename, a:basedir
|
||||
" TLogDBG getcwd()
|
||||
" TLogDBG expand('%:p')
|
||||
let f0 = fnamemodify(a:filename, ':p')
|
||||
let b0 = tlib#file#Absolute(a:basedir)
|
||||
let b = tlib#file#Split(b0)
|
||||
" TLogVAR b
|
||||
let f0 = tlib#file#Absolute(a:filename)
|
||||
let fn = fnamemodify(f0, ':t')
|
||||
let fd = fnamemodify(f0, ':h')
|
||||
let f = tlib#file#Split(fd)
|
||||
" TLogVAR f
|
||||
let b0 = fnamemodify(a:basedir, ':p')
|
||||
let b = tlib#file#Split(b0)
|
||||
" TLogVAR b
|
||||
" TLogVAR f0, fn, fd, f
|
||||
if f[0] != b[0]
|
||||
let rv = f0
|
||||
else
|
||||
@ -78,6 +80,7 @@ function! tlib#file#Relative(filename, basedir) "{{{3
|
||||
call remove(f, 0)
|
||||
call remove(b, 0)
|
||||
endwh
|
||||
" TLogVAR f, b
|
||||
let rv = tlib#file#Join(repeat(['..'], len(b)) + f + [fn])
|
||||
endif
|
||||
" TLogVAR rv
|
||||
@ -85,6 +88,21 @@ function! tlib#file#Relative(filename, basedir) "{{{3
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#file#Absolute(filename, ...) "{{{3
|
||||
if filereadable(a:filename)
|
||||
let filename = fnamemodify(a:filename, ':p')
|
||||
elseif a:filename =~ '^\(/\|[^\/]\+:\)'
|
||||
let filename = a:filename
|
||||
else
|
||||
let cwd = a:0 >= 1 ? a:1 : getcwd()
|
||||
let filename = tlib#file#Join([cwd, a:filename])
|
||||
endif
|
||||
let filename = substitute(filename, '\(^\|[\/]\)\zs\.[\/]', '', 'g')
|
||||
let filename = substitute(filename, '[\/]\zs[^\/]\+[\/]\.\.[\/]', '', 'g')
|
||||
return filename
|
||||
endf
|
||||
|
||||
|
||||
function! s:SetScrollBind(world) "{{{3
|
||||
let sb = get(a:world, 'scrollbind', &scrollbind)
|
||||
if sb != &scrollbind
|
||||
@ -118,7 +136,7 @@ function! tlib#file#With(fcmd, bcmd, files, ...) "{{{3
|
||||
if filereadable(f)
|
||||
if !empty(a:fcmd)
|
||||
" TLogDBG a:fcmd .' '. tlib#arg#Ex(f)
|
||||
exec 'autocmd TLibFileRead BufRead' escape(f, ' ') 'let s:bufread=expand("<afile>:p")'
|
||||
exec 'autocmd TLibFileRead BufRead' escape(f, '\ ') 'let s:bufread=expand("<afile>:p")'
|
||||
try
|
||||
exec a:fcmd .' '. tlib#arg#Ex(f)
|
||||
finally
|
||||
|
14
sources_non_forked/tlib/autoload/tlib/fixes.vim
Normal file
14
sources_non_forked/tlib/autoload/tlib/fixes.vim
Normal file
@ -0,0 +1,14 @@
|
||||
" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Last Change: 2013-02-22.
|
||||
" @Revision: 3
|
||||
|
||||
|
||||
function! tlib#fixes#Winpos() "{{{3
|
||||
if has('gui_win32')
|
||||
return 'winpos '. getwinposx() .' '. getwinposy()
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endf
|
||||
|
38
sources_non_forked/tlib/autoload/tlib/grep.vim
Normal file
38
sources_non_forked/tlib/autoload/tlib/grep.vim
Normal file
@ -0,0 +1,38 @@
|
||||
" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Last Change: 2013-10-16.
|
||||
" @Revision: 31
|
||||
|
||||
|
||||
function! tlib#grep#Do(cmd, rx, files) "{{{3
|
||||
" TLogVAR a:cmd, a:rx, a:files
|
||||
let files = join(map(copy(a:files), 'tlib#arg#Ex(v:val, "")'), ' ')
|
||||
let rx = '/'. escape(a:rx, '/') .'/j'
|
||||
" TLogVAR rx, files
|
||||
silent exec a:cmd rx files
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#grep#LocList(rx, files) "{{{3
|
||||
return tlib#grep#Do('noautocmd lvimgrep', a:rx, a:files)
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#grep#QuickFixList(rx, files) "{{{3
|
||||
return tlib#grep#Do('noautocmd vimgrep', a:rx, a:files)
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#grep#List(rx, files) "{{{3
|
||||
call setqflist([])
|
||||
call tlib#grep#Do('noautocmd vimgrepadd', a:rx, a:files)
|
||||
let qfl = getqflist()
|
||||
" TLogVAR qfl
|
||||
" try
|
||||
silent! colder
|
||||
" catch
|
||||
" call setqflist([], 'r')
|
||||
" endtry
|
||||
return qfl
|
||||
endf
|
||||
|
145
sources_non_forked/tlib/autoload/tlib/hash.vim
Normal file
145
sources_non_forked/tlib/autoload/tlib/hash.vim
Normal file
@ -0,0 +1,145 @@
|
||||
" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Revision: 276
|
||||
|
||||
|
||||
if !exists('g:tlib#hash#use_crc32')
|
||||
let g:tlib#hash#use_crc32 = '' "{{{2
|
||||
endif
|
||||
|
||||
|
||||
if !exists('g:tlib#hash#use_adler32')
|
||||
let g:tlib#hash#use_adler32 = '' "{{{2
|
||||
endif
|
||||
|
||||
|
||||
function! tlib#hash#CRC32B(chars) "{{{3
|
||||
if !empty(g:tlib#hash#use_crc32)
|
||||
let use = g:tlib#hash#use_crc32
|
||||
elseif has('ruby')
|
||||
let use = 'ruby'
|
||||
else
|
||||
let use = 'vim'
|
||||
endif
|
||||
if exists('*tlib#hash#CRC32B_'. use)
|
||||
return tlib#hash#CRC32B_{use}(a:chars)
|
||||
else
|
||||
throw "Unknown version of tlib#hash#CRC32B: ". use
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#hash#CRC32B_ruby(chars) "{{{3
|
||||
if has('ruby')
|
||||
let rv = ''
|
||||
if !exists('s:loaded_ruby_zlib')
|
||||
ruby require 'zlib'
|
||||
let s:loaded_ruby_zlib = 1
|
||||
endif
|
||||
ruby VIM::command('let rv = "%08X"' % Zlib.crc32(VIM::evaluate("a:chars")))
|
||||
return rv
|
||||
else
|
||||
throw "tlib#hash#CRC32B_ruby not supported in this version of vim"
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#hash#CRC32B_vim(chars) "{{{3
|
||||
if !exists('s:crc_table')
|
||||
let cfile = tlib#persistent#Filename('tlib', 'crc_table', 1)
|
||||
let s:crc_table = tlib#persistent#Value(cfile, 'tlib#hash#CreateCrcTable', 0)
|
||||
endif
|
||||
let xFFFF_FFFF = repeat([1], 32)
|
||||
let crc = tlib#bitwise#XOR([0], xFFFF_FFFF, 'bits')
|
||||
for char in split(a:chars, '\zs')
|
||||
let octet = char2nr(char)
|
||||
let r1 = tlib#bitwise#ShiftRight(crc, 8)
|
||||
let i0 = tlib#bitwise#AND(crc, xFFFF_FFFF, 'bits')
|
||||
let i1 = tlib#bitwise#XOR(i0, octet, 'bits')
|
||||
let i2 = tlib#bitwise#Bits2Num(tlib#bitwise#AND(i1, 0xff, 'bits'))
|
||||
let r2 = s:crc_table[i2]
|
||||
let crc = tlib#bitwise#XOR(r1, r2, 'bits')
|
||||
endfor
|
||||
let crc = tlib#bitwise#XOR(crc, xFFFF_FFFF, 'bits')
|
||||
let rv = tlib#bitwise#Bits2Num(crc, 16)
|
||||
if len(rv) < 8
|
||||
let rv = repeat('0', 8 - len(rv)) . rv
|
||||
endif
|
||||
return rv
|
||||
endf
|
||||
|
||||
|
||||
" :nodoc:
|
||||
function! tlib#hash#CreateCrcTable() "{{{3
|
||||
let sum = 0.0
|
||||
for exponent in [0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 16, 22, 23, 26, 32]
|
||||
let exp = tlib#bitwise#Bits2Num(repeat([0], 32 - exponent) + [1], 10.0)
|
||||
let sum += exp
|
||||
endfor
|
||||
let divisor = tlib#bitwise#Num2Bits(sum)
|
||||
let crc_table = []
|
||||
for octet in range(256)
|
||||
let remainder = tlib#bitwise#Num2Bits(octet)
|
||||
for i in range(8)
|
||||
if get(remainder, i) != 0
|
||||
let remainder = tlib#bitwise#XOR(remainder, tlib#bitwise#ShiftLeft(divisor, i), "bits")
|
||||
endif
|
||||
endfor
|
||||
let remainder = tlib#bitwise#ShiftRight(remainder, 8)
|
||||
call add(crc_table, remainder)
|
||||
endfor
|
||||
return crc_table
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#hash#Adler32(chars) "{{{3
|
||||
if !empty(g:tlib#hash#use_adler32)
|
||||
let use = g:tlib#hash#use_adler32
|
||||
elseif exists('*or')
|
||||
let use = 'vim'
|
||||
else
|
||||
let use = 'tlib'
|
||||
endif
|
||||
if exists('*tlib#hash#Adler32_'. use)
|
||||
return tlib#hash#Adler32_{use}(a:chars)
|
||||
else
|
||||
throw "Unknown version of tlib#hash#Adler32_: ". use
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#hash#Adler32_vim(chars) "{{{3
|
||||
if exists('*or')
|
||||
let mod_adler = 65521
|
||||
let a = 1
|
||||
let b = 0
|
||||
for index in range(len(a:chars))
|
||||
let c = char2nr(a:chars[index])
|
||||
let a = (a + c) % mod_adler
|
||||
let b = (b + a) % mod_adler
|
||||
endfor
|
||||
let bb = b * float2nr(pow(2, 16))
|
||||
let checksum = or(bb, a)
|
||||
" TLogVAR checksum, a, b, bb
|
||||
return printf("%08X", checksum)
|
||||
else
|
||||
throw "TLIB: Vim version doesn't support bitwise or()"
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
function! tlib#hash#Adler32_tlib(chars) "{{{3
|
||||
let mod_adler = 65521
|
||||
let a = 1
|
||||
let b = 0
|
||||
for index in range(len(a:chars))
|
||||
let c = char2nr(a:chars[index])
|
||||
let a = (a + c) % mod_adler
|
||||
let b = (b + a) % mod_adler
|
||||
endfor
|
||||
let bb = tlib#bitwise#ShiftLeft(tlib#bitwise#Num2Bits(b), 16)
|
||||
let checksum = tlib#bitwise#OR(bb, a, "bits")
|
||||
return printf('%08s', tlib#bitwise#Bits2Num(checksum, 16))
|
||||
endf
|
||||
|
||||
|
@ -3,13 +3,188 @@
|
||||
" @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: 2012-10-01.
|
||||
" @Revision: 0.0.966
|
||||
" @Last Change: 2013-09-30.
|
||||
" @Revision: 0.0.1262
|
||||
|
||||
|
||||
" :filedoc:
|
||||
" Input-related, select from a list etc.
|
||||
|
||||
" If a list is bigger than this value, don't try to be smart when
|
||||
" selecting an item. Be slightly faster instead.
|
||||
" See |tlib#input#List()|.
|
||||
TLet g:tlib#input#sortprefs_threshold = 200
|
||||
|
||||
|
||||
" If a list contains more items, |tlib#input#List()| does not perform an
|
||||
" incremental "live search" but uses |input()| to query the user for a
|
||||
" filter. This is useful on slower machines or with very long lists.
|
||||
TLet g:tlib#input#livesearch_threshold = 1000
|
||||
|
||||
|
||||
" Determine how |tlib#input#List()| and related functions work.
|
||||
" Can be "cnf", "cnfd", "cnfx", "seq", or "fuzzy". See:
|
||||
" cnfx ... Like cnfd but |g:tlib#Filter_cnfx#expander| is interpreted
|
||||
" as a wildcard (this is the default method)
|
||||
" - A plus character ("+") acts as a wildcard as if ".\{-}" (see
|
||||
" |/\{-|) were entered.
|
||||
" - Examples:
|
||||
" - "f+o" matches "fo", "fxo", and "fxxxoo", but doesn't match
|
||||
" "far".
|
||||
" - Otherwise it is a derivate of the cnf method (see below).
|
||||
" - See also |tlib#Filter_cnfx#New()|.
|
||||
" cnfd ... Like cnf but "." is interpreted as a wildcard, i.e. it is
|
||||
" expanded to "\.\{-}"
|
||||
" - A period character (".") acts as a wildcard as if ".\{-}" (see
|
||||
" |/\{-|) were entered.
|
||||
" - Examples:
|
||||
" - "f.o" matches "fo", "fxo", and "fxxxoo", but doesn't match
|
||||
" "far".
|
||||
" - Otherwise it is a derivate of the cnf method (see below).
|
||||
" - See also |tlib#Filter_cnfd#New()|.
|
||||
" cnf .... Match substrings
|
||||
" - A blank creates an AND conjunction, i.e. the next pattern has to
|
||||
" match too.
|
||||
" - A pipe character ("|") creates an OR conjunction, either this or
|
||||
" the next next pattern has to match.
|
||||
" - Patterns are very 'nomagic' |regexp| with a |\V| prefix.
|
||||
" - A pattern starting with "-" makes the filter exclude items
|
||||
" matching that pattern.
|
||||
" - Examples:
|
||||
" - "foo bar" matches items that contain the strings "foo" AND
|
||||
" "bar".
|
||||
" - "foo|bar boo|far" matches items that contain either ("foo" OR
|
||||
" "bar") AND ("boo" OR "far").
|
||||
" - See also |tlib#Filter_cnf#New()|.
|
||||
" seq .... Match sequences of characters
|
||||
" - |tlib#Filter_seq#New()|
|
||||
" fuzzy .. Match fuzzy character sequences
|
||||
" - |tlib#Filter_fuzzy#New()|
|
||||
TLet g:tlib#input#filter_mode = 'cnfx'
|
||||
|
||||
|
||||
" The highlight group to use for showing matches in the input list
|
||||
" window.
|
||||
" See |tlib#input#List()|.
|
||||
TLet g:tlib#input#higroup = 'IncSearch'
|
||||
|
||||
" When 1, automatically select the last remaining item only if the list
|
||||
" had only one item to begin with.
|
||||
" When 2, automatically select a last remaining item after applying
|
||||
" any filters.
|
||||
" See |tlib#input#List()|.
|
||||
TLet g:tlib_pick_last_item = 1
|
||||
|
||||
|
||||
" :doc:
|
||||
" Keys for |tlib#input#List|~
|
||||
|
||||
TLet g:tlib#input#and = ' '
|
||||
TLet g:tlib#input#or = '|'
|
||||
TLet g:tlib#input#not = '-'
|
||||
|
||||
" When editing a list with |tlib#input#List|, typing these numeric chars
|
||||
" (as returned by getchar()) will select an item based on its index, not
|
||||
" based on its name. I.e. in the default setting, typing a "4" will
|
||||
" select the fourth item, not the item called "4".
|
||||
" In order to make keys 0-9 filter the items in the list and make
|
||||
" <m-[0-9]> select an item by its index, remove the keys 48 to 57 from
|
||||
" this dictionary.
|
||||
" Format: [KEY] = BASE ... the number is calculated as KEY - BASE.
|
||||
" :nodefault:
|
||||
TLet g:tlib#input#numeric_chars = {
|
||||
\ 176: 176,
|
||||
\ 177: 176,
|
||||
\ 178: 176,
|
||||
\ 179: 176,
|
||||
\ 180: 176,
|
||||
\ 181: 176,
|
||||
\ 182: 176,
|
||||
\ 183: 176,
|
||||
\ 184: 176,
|
||||
\ 185: 176,
|
||||
\}
|
||||
" \ 48: 48,
|
||||
" \ 49: 48,
|
||||
" \ 50: 48,
|
||||
" \ 51: 48,
|
||||
" \ 52: 48,
|
||||
" \ 53: 48,
|
||||
" \ 54: 48,
|
||||
" \ 55: 48,
|
||||
" \ 56: 48,
|
||||
" \ 57: 48,
|
||||
|
||||
|
||||
" :nodefault:
|
||||
" The default key bindings for single-item-select list views. If you
|
||||
" want to use <c-j>, <c-k> to move the cursor up and down, add these two
|
||||
" lines to after/plugin/02tlib.vim: >
|
||||
"
|
||||
" let g:tlib#input#keyagents_InputList_s[10] = 'tlib#agent#Down' " <c-j>
|
||||
" let g:tlib#input#keyagents_InputList_s[11] = 'tlib#agent#Up' " <c-k>
|
||||
TLet g:tlib#input#keyagents_InputList_s = {
|
||||
\ "\<PageUp>": 'tlib#agent#PageUp',
|
||||
\ "\<PageDown>": 'tlib#agent#PageDown',
|
||||
\ "\<Up>": 'tlib#agent#Up',
|
||||
\ "\<Down>": 'tlib#agent#Down',
|
||||
\ "\<c-Up>": 'tlib#agent#UpN',
|
||||
\ "\<c-Down>": 'tlib#agent#DownN',
|
||||
\ "\<Left>": 'tlib#agent#ShiftLeft',
|
||||
\ "\<Right>": 'tlib#agent#ShiftRight',
|
||||
\ 18: 'tlib#agent#Reset',
|
||||
\ 242: 'tlib#agent#Reset',
|
||||
\ 17: 'tlib#agent#Input',
|
||||
\ 241: 'tlib#agent#Input',
|
||||
\ 27: 'tlib#agent#Exit',
|
||||
\ 26: 'tlib#agent#Suspend',
|
||||
\ 250: 'tlib#agent#Suspend',
|
||||
\ 15: 'tlib#agent#SuspendToParentWindow',
|
||||
\ 63: 'tlib#agent#Help',
|
||||
\ "\<F1>": 'tlib#agent#Help',
|
||||
\ "\<F10>": 'tlib#agent#ExecAgentByName',
|
||||
\ "\<S-Esc>": 'tlib#agent#ExecAgentByName',
|
||||
\ "\<bs>": 'tlib#agent#ReduceFilter',
|
||||
\ "\<del>": 'tlib#agent#ReduceFilter',
|
||||
\ "\<c-bs>": 'tlib#agent#PopFilter',
|
||||
\ "\<m-bs>": 'tlib#agent#PopFilter',
|
||||
\ "\<c-del>": 'tlib#agent#PopFilter',
|
||||
\ "\<m-del>": 'tlib#agent#PopFilter',
|
||||
\ "\<s-space>": 'tlib#agent#Wildcard',
|
||||
\ 191: 'tlib#agent#Debug',
|
||||
\ char2nr(g:tlib#input#or): 'tlib#agent#OR',
|
||||
\ char2nr(g:tlib#input#and): 'tlib#agent#AND',
|
||||
\ }
|
||||
|
||||
|
||||
" :nodefault:
|
||||
TLet g:tlib#input#keyagents_InputList_m = {
|
||||
\ 35: 'tlib#agent#Select',
|
||||
\ "\<s-up>": 'tlib#agent#SelectUp',
|
||||
\ "\<s-down>": 'tlib#agent#SelectDown',
|
||||
\ 1: 'tlib#agent#SelectAll',
|
||||
\ 225: 'tlib#agent#SelectAll',
|
||||
\ "\<F9>": 'tlib#agent#ToggleRestrictView',
|
||||
\ }
|
||||
" "\<c-space>": 'tlib#agent#Select'
|
||||
|
||||
|
||||
" :nodefault:
|
||||
TLet g:tlib#input#handlers_EditList = [
|
||||
\ {'key': 5, 'agent': 'tlib#agent#EditItem', 'key_name': '<c-e>', 'help': 'Edit item'},
|
||||
\ {'key': 4, 'agent': 'tlib#agent#DeleteItems', 'key_name': '<c-d>', 'help': 'Delete item(s)'},
|
||||
\ {'key': 14, 'agent': 'tlib#agent#NewItem', 'key_name': '<c-n>', 'help': 'New item'},
|
||||
\ {'key': 24, 'agent': 'tlib#agent#Cut', 'key_name': '<c-x>', 'help': 'Cut item(s)'},
|
||||
\ {'key': 3, 'agent': 'tlib#agent#Copy', 'key_name': '<c-c>', 'help': 'Copy item(s)'},
|
||||
\ {'key': 22, 'agent': 'tlib#agent#Paste', 'key_name': '<c-v>', 'help': 'Paste item(s)'},
|
||||
\ {'pick_last_item': 0},
|
||||
\ {'return_agent': 'tlib#agent#EditReturnValue'},
|
||||
\ {'help_extra': [
|
||||
\ 'Submit changes by pressing ENTER or <c-s> or <c-w><cr>',
|
||||
\ 'Cancel editing by pressing <c-w>c'
|
||||
\ ]},
|
||||
\ ]
|
||||
|
||||
|
||||
" If true, define a popup menu for |tlib#input#List()| and related
|
||||
" functions.
|
||||
@ -40,7 +215,7 @@ TLet g:tlib#input#filename_max_width = '&co / 2'
|
||||
" of selected elements or its indexes.
|
||||
"
|
||||
" By default, typing numbers will select an item by its index. See
|
||||
" |g:tlib_numeric_chars| to find out how to change this.
|
||||
" |g:tlib#input#numeric_chars| to find out how to change this.
|
||||
"
|
||||
" The item is automatically selected if the numbers typed equals the
|
||||
" number of digits of the list length. I.e. if a list contains 20 items,
|
||||
@ -58,7 +233,7 @@ TLet g:tlib#input#filename_max_width = '&co / 2'
|
||||
" mi ... Return a list of indexes
|
||||
"
|
||||
" Several pattern matching styles are supported. See
|
||||
" |g:tlib_inputlist_match|.
|
||||
" |g:tlib#input#filter_mode|.
|
||||
"
|
||||
" EXAMPLES: >
|
||||
" echo tlib#input#List('s', 'Select one item', [100,200,300])
|
||||
@ -110,7 +285,7 @@ function! tlib#input#List(type, ...) "{{{3
|
||||
let world.pick_last_item = tlib#list#Find(handlers, 'has_key(v:val, "pick_last_item")',
|
||||
\ tlib#var#Get('tlib_pick_last_item', 'bg'), 'v:val.pick_last_item')
|
||||
let world.numeric_chars = tlib#list#Find(handlers, 'has_key(v:val, "numeric_chars")',
|
||||
\ tlib#var#Get('tlib_numeric_chars', 'bg'), 'v:val.numeric_chars')
|
||||
\ g:tlib#input#numeric_chars, 'v:val.numeric_chars')
|
||||
let world.key_handlers = filter(copy(handlers), 'has_key(v:val, "key")')
|
||||
let filter = tlib#list#Find(handlers, 'has_key(v:val, "filter")', '', 'v:val.filter')
|
||||
if !empty(filter)
|
||||
@ -157,10 +332,12 @@ function! tlib#input#ListW(world, ...) "{{{3
|
||||
let &l:scrolloff = 0
|
||||
let @/ = ''
|
||||
let dlist = []
|
||||
let post_keys = ''
|
||||
" let &laststatus = 2
|
||||
|
||||
try
|
||||
while !empty(world.state) && world.state !~ '^exit' && (world.show_empty || !empty(world.base))
|
||||
let post_keys = ''
|
||||
" TLogDBG 'while'
|
||||
" TLogVAR world.state
|
||||
" let time01 = str2float(reltimestr(reltime())) " DBG
|
||||
@ -249,7 +426,7 @@ function! tlib#input#ListW(world, ...) "{{{3
|
||||
" TLogVAR world.idx, world.llen, world.state
|
||||
" TLogDBG world.FilterIsEmpty()
|
||||
if world.state == 'display'
|
||||
if world.idx == '' && world.llen < g:tlib_sortprefs_threshold && !world.FilterIsEmpty()
|
||||
if world.idx == '' && world.llen < g:tlib#input#sortprefs_threshold && !world.FilterIsEmpty()
|
||||
call world.SetPrefIdx()
|
||||
else
|
||||
let world.prefidx = world.idx == '' ? world.initial_index : world.idx
|
||||
@ -333,7 +510,7 @@ function! tlib#input#ListW(world, ...) "{{{3
|
||||
" let world.prefidx = world.offset
|
||||
" endif
|
||||
call world.DisplayList()
|
||||
if world.state == 'help'
|
||||
if world.state == 'help' || world.state == 'printlines'
|
||||
let world.state = 'display'
|
||||
else
|
||||
let world.state = ''
|
||||
@ -343,7 +520,7 @@ function! tlib#input#ListW(world, ...) "{{{3
|
||||
" TAssert IsNotEmpty(world.scratch)
|
||||
let world.list_wnr = winnr()
|
||||
|
||||
" TLogVAR world.next_state, world.state
|
||||
" TLogVAR world.state, world.next_state
|
||||
if !empty(world.next_state)
|
||||
let world.state = world.next_state
|
||||
let world.next_state = ''
|
||||
@ -354,11 +531,49 @@ function! tlib#input#ListW(world, ...) "{{{3
|
||||
continue
|
||||
endif
|
||||
|
||||
" TLogVAR world.timeout
|
||||
let c = tlib#char#Get(world.timeout, world.timeout_resolution)
|
||||
" TLogVAR c, has_key(world.key_map[world.key_mode],c)
|
||||
if world.state =~ '\<eval\>'
|
||||
let query = matchstr(world.state, '\<eval\[\zs.\{-}\ze\]')
|
||||
if empty(query)
|
||||
let query = 'Waiting for input ... Press ESC to continue'
|
||||
endif
|
||||
if has('gui_win32')
|
||||
let exec_cmd = input(query, '')
|
||||
" TLogVAR exec_cmd
|
||||
if exec_cmd == ''
|
||||
let world.state = 'redisplay'
|
||||
else
|
||||
exec exec_cmd
|
||||
endif
|
||||
elseif has('gui_gtk') || has('gui_gtk2')
|
||||
let c = getchar()
|
||||
let cmod = getcharmod()
|
||||
" TLogVAR c, cmod
|
||||
if c !~ '\D' && c > 0 && cmod != 0
|
||||
let c = printf("<%s-%s>", cmod, c)
|
||||
endif
|
||||
endif
|
||||
else
|
||||
" TLogVAR world.timeout
|
||||
let c = tlib#char#Get(world.timeout, world.timeout_resolution)
|
||||
" TLogVAR c, has_key(world.key_map[world.key_mode],c)
|
||||
let cmod = getcharmod()
|
||||
endif
|
||||
" TLogVAR c, cmod
|
||||
" TLogDBG string(sort(keys(world.key_map[world.key_mode])))
|
||||
if world.state != ''
|
||||
|
||||
" TLogVAR world.next_agent, world.next_eval
|
||||
if !empty(world.next_agent)
|
||||
let nagent = world.next_agent
|
||||
let world.next_agent = ''
|
||||
let world = call(nagent, [world, world.GetSelectedItems(world.CurrentItem())])
|
||||
call s:CheckAgentReturnValue(nagent, world)
|
||||
elseif !empty(world.next_eval)
|
||||
let selected = world.GetSelectedItems(world.CurrentItem())
|
||||
let neval = world.next_eval
|
||||
let world.next_eval = ''
|
||||
exec neval
|
||||
call s:CheckAgentReturnValue(neval, world)
|
||||
elseif world.state != ''
|
||||
" continue
|
||||
elseif has_key(world.key_map[world.key_mode], c)
|
||||
let sr = @/
|
||||
@ -382,35 +597,53 @@ function! tlib#input#ListW(world, ...) "{{{3
|
||||
let world.state = 'exit empty'
|
||||
endif
|
||||
elseif c == "\<LeftMouse>"
|
||||
let world.prefidx = world.GetLineIdx(v:mouse_lnum)
|
||||
" let world.offset = world.prefidx
|
||||
" TLogVAR v:mouse_lnum, world.prefidx
|
||||
if empty(world.prefidx)
|
||||
" call feedkeys(c, 't')
|
||||
let c = tlib#char#Get(world.timeout)
|
||||
let world.state = 'help'
|
||||
continue
|
||||
endif
|
||||
throw 'pick'
|
||||
elseif c == "\<RightMouse>"
|
||||
if g:tlib#input#use_popup && world.has_menu
|
||||
" if v:mouse_lnum != line('.')
|
||||
" endif
|
||||
if v:mouse_win == world.list_wnr
|
||||
let world.prefidx = world.GetLineIdx(v:mouse_lnum)
|
||||
let world.state = 'redisplay'
|
||||
call world.DisplayList()
|
||||
if line('w$') - v:mouse_lnum < 6
|
||||
popup ]TLibInputListPopupMenu
|
||||
" let world.offset = world.prefidx
|
||||
if empty(world.prefidx)
|
||||
" call feedkeys(c, 't')
|
||||
let c = tlib#char#Get(world.timeout)
|
||||
let world.state = 'help'
|
||||
continue
|
||||
endif
|
||||
throw 'pick'
|
||||
else
|
||||
let post_keys = v:mouse_lnum .'gg'. v:mouse_col .'|'. c
|
||||
if world.allow_suspend
|
||||
let world = tlib#agent#SuspendToParentWindow(world, world.rv)
|
||||
else
|
||||
popup! ]TLibInputListPopupMenu
|
||||
let world.state = 'exit empty'
|
||||
endif
|
||||
endif
|
||||
elseif c == "\<RightMouse>"
|
||||
if v:mouse_win == world.list_wnr
|
||||
call s:BuildMenu(world)
|
||||
let world.state = 'redisplay'
|
||||
if s:PopupmenuExists() == 1
|
||||
" if v:mouse_lnum != line('.')
|
||||
" endif
|
||||
let world.prefidx = world.GetLineIdx(v:mouse_lnum)
|
||||
let world.next_state = 'eval[Waiting for popup menu ... Press ESC to continue]'
|
||||
call world.DisplayList()
|
||||
if line('w$') - v:mouse_lnum < 6
|
||||
popup ]TLibInputListPopupMenu
|
||||
else
|
||||
popup! ]TLibInputListPopupMenu
|
||||
endif
|
||||
endif
|
||||
else
|
||||
let world.state = 'redisplay'
|
||||
let post_keys = v:mouse_lnum .'gg'. v:mouse_col .'|'. c
|
||||
if world.allow_suspend
|
||||
let world = tlib#agent#SuspendToParentWindow(world, world.rv)
|
||||
else
|
||||
let world.state = 'exit empty'
|
||||
endif
|
||||
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])
|
||||
call s:CheckAgentReturnValue(agent, world)
|
||||
elseif c >= 32
|
||||
let world.state = 'display'
|
||||
let numbase = get(world.numeric_chars, c, -99999)
|
||||
@ -425,7 +658,7 @@ function! tlib#input#ListW(world, ...) "{{{3
|
||||
else
|
||||
let world.idx = ''
|
||||
" TLogVAR world.filter
|
||||
if world.llen > g:tlib_inputlist_livesearch_threshold
|
||||
if world.llen > g:tlib#input#livesearch_threshold
|
||||
let pattern = input('Filter: ', world.CleanFilter(world.filter[0][0]) . nr2char(c))
|
||||
if empty(pattern)
|
||||
let world.state = 'exit empty'
|
||||
@ -552,9 +785,8 @@ function! tlib#input#ListW(world, ...) "{{{3
|
||||
" let &laststatus = laststatus
|
||||
silent! let @/ = lastsearch
|
||||
let &l:scrolloff = scrolloff
|
||||
if g:tlib#input#use_popup && world.has_menu
|
||||
if s:PopupmenuExists() == 1
|
||||
silent! aunmenu ]TLibInputListPopupMenu
|
||||
let world.has_menu = 0
|
||||
endif
|
||||
|
||||
" TLogDBG 'finally 2'
|
||||
@ -589,6 +821,10 @@ function! tlib#input#ListW(world, ...) "{{{3
|
||||
" endfor
|
||||
echo
|
||||
redraw!
|
||||
if !empty(post_keys)
|
||||
" TLogVAR post_keys
|
||||
call feedkeys(post_keys)
|
||||
endif
|
||||
endtry
|
||||
endf
|
||||
|
||||
@ -612,7 +848,7 @@ function! s:Init(world, cmd) "{{{3
|
||||
" 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.SetMatchMode(tlib#var#Get('tlib#input#filter_mode', 'wb'))
|
||||
call a:world.Initialize()
|
||||
if !has_key(a:world, 'key_mode')
|
||||
let a:world.key_mode = 'default'
|
||||
@ -623,18 +859,19 @@ function! s:Init(world, cmd) "{{{3
|
||||
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),
|
||||
\ copy(g:tlib#input#keyagents_InputList_s),
|
||||
\ 'keep')
|
||||
else
|
||||
let a:world.key_map[a:world.key_mode] = copy(g:tlib_keyagents_InputList_s)
|
||||
let a:world.key_map[a:world.key_mode] = copy(g:tlib#input#keyagents_InputList_s)
|
||||
endif
|
||||
else
|
||||
let a:world.key_map = {
|
||||
\ a:world.key_mode : copy(g:tlib_keyagents_InputList_s)
|
||||
\ a:world.key_mode : copy(g:tlib#input#keyagents_InputList_s)
|
||||
\ }
|
||||
endif
|
||||
" TLogVAR a:world.type
|
||||
if stridx(a:world.type, 'm') != -1
|
||||
call extend(a:world.key_map[a:world.key_mode], g:tlib_keyagents_InputList_m, 'force')
|
||||
call extend(a:world.key_map[a:world.key_mode], g:tlib#input#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}')
|
||||
@ -652,7 +889,6 @@ function! s:Init(world, cmd) "{{{3
|
||||
let a:world.state .= ' '. a:cmd
|
||||
endif
|
||||
endif
|
||||
call s:BuildMenu(a:world)
|
||||
" TLogVAR a:world.state, a:world.sticky
|
||||
endf
|
||||
|
||||
@ -667,40 +903,133 @@ function! s:ExtendKeyMap(world, key_mode, key_handlers) "{{{3
|
||||
endf
|
||||
|
||||
|
||||
function s:PopupmenuExists()
|
||||
if !g:tlib#input#use_popup
|
||||
\ || exists(':popup') != 2
|
||||
\ || !(has('gui_win32') || has('gui_gtk') || has('gui_gtk2'))
|
||||
" \ || !has('gui_win32')
|
||||
let rv = -1
|
||||
else
|
||||
try
|
||||
let rv = 1
|
||||
silent amenu ]TLibInputListPopupMenu
|
||||
catch
|
||||
let rv = 0
|
||||
endtry
|
||||
endif
|
||||
" TLogVAR rv
|
||||
return rv
|
||||
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
|
||||
if g:tlib#input#use_popup && s:PopupmenuExists() == 0
|
||||
call s:BuildItem('Pick\ selected\ item', {'key_name': '<cr>', 'eval': 'let world.state = "pick"'})
|
||||
call s:BuildItem('Cancel', {'key_name': '<esc>', 'agent': 'tlib#agent#Exit'})
|
||||
call s:BuildItem('Select', {'key_name': '#', 'agent': 'tlib#agent#Select'})
|
||||
call s:BuildItem('Select\ all', {'key_name': '<c-a>', 'agent': 'tlib#agent#SelectAll'})
|
||||
call s:BuildItem('Reset\ list', {'key_name': '<c-r>', 'agent': 'tlib#agent#Reset'})
|
||||
call s:BuildItem('-StandardEntries-', {'key': ":", 'eval': 'let world.state = "redisplay"'})
|
||||
for [key_mode, key_handlers] in items(a:world.key_map)
|
||||
let keys = sort(keys(key_handlers))
|
||||
let mitems = {}
|
||||
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
|
||||
let mname = ''
|
||||
else
|
||||
exec 'amenu ]TLibInputListPopupMenu'.
|
||||
\ '.'. escape(key_mode, ' .\')
|
||||
\ '.'. escape(handler.help, ' .\')
|
||||
\ .' '. handler.key_name
|
||||
let mname = escape(key_mode, ' .\') .'.'
|
||||
endif
|
||||
if has_key(handler, 'submenu')
|
||||
let submenu = escape(handler.submenu, ' .\')
|
||||
else
|
||||
let submenu = '~'
|
||||
endif
|
||||
for mfield in ['menu', 'help', 'key_name', 'agent']
|
||||
if has_key(handler, mfield)
|
||||
let mname .= escape(handler[mfield], ' .\')
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
if !has_key(mitems, submenu)
|
||||
let mitems[submenu] = {}
|
||||
endif
|
||||
let mitems[submenu][mname] = handler
|
||||
endif
|
||||
endfor
|
||||
for msubname in sort(keys(mitems))
|
||||
let msubitems = mitems[msubname]
|
||||
if msubname == '~'
|
||||
let msubmname = ''
|
||||
else
|
||||
let msubmname = msubname .'.'
|
||||
endif
|
||||
for mname in sort(keys(msubitems))
|
||||
let msname = msubmname . mname
|
||||
let handler = msubitems[mname]
|
||||
call s:BuildItem(msname, handler)
|
||||
" if has_key(handler, 'agent')
|
||||
" call s:BuildItem(msname, {'agent': handler.agent})
|
||||
" else
|
||||
" call s:BuildItem(msname, {'key': handler.key_name})
|
||||
" endif
|
||||
endfor
|
||||
endfor
|
||||
endfor
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
function! s:BuildItem(menu, def) "{{{3
|
||||
if has('gui_win32')
|
||||
let key_mode = 'c'
|
||||
elseif has('gui_gtk') || has('gui_gtk2')
|
||||
let key_mode = 'raw'
|
||||
endif
|
||||
for k in ['agent', 'eval', 'key_name', 'key']
|
||||
if has('gui_win32')
|
||||
elseif has('gui_gtk') || has('gui_gtk')
|
||||
if k == 'agent' || k == 'eval'
|
||||
continue
|
||||
endif
|
||||
endif
|
||||
try
|
||||
if has_key(a:def, k)
|
||||
let v = a:def[k]
|
||||
if k == 'key'
|
||||
if key_mode == 'c'
|
||||
" echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "'. v .'"<cr>'
|
||||
exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "'. v .'"<cr>'
|
||||
else
|
||||
" echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) v
|
||||
exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) v
|
||||
endif
|
||||
elseif k == 'key_name'
|
||||
if key_mode == 'c'
|
||||
" echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "\'. v .'"<cr>'
|
||||
exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "\'. v .'"<cr>'
|
||||
else
|
||||
let key = v
|
||||
" echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) key
|
||||
exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) key
|
||||
endif
|
||||
elseif k == 'agent'
|
||||
" echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_agent ='. string(v) .'<cr>'
|
||||
exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_agent ='. string(v) .'<cr>'
|
||||
elseif k == 'eval'
|
||||
" echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_eval ='. string(v) .'<cr>'
|
||||
exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_eval ='. string(v) .'<cr>'
|
||||
endif
|
||||
return
|
||||
endif
|
||||
catch
|
||||
endtry
|
||||
endfor
|
||||
endf
|
||||
|
||||
|
||||
function! s:RunStateHandlers(world) "{{{3
|
||||
" Provide the variable "world" in the environment of an "exec"
|
||||
" handler (ea).
|
||||
@ -748,7 +1077,7 @@ endf
|
||||
" EXAMPLES: >
|
||||
" echo tlib#input#EditList('Edit:', [100,200,300])
|
||||
function! tlib#input#EditList(query, list, ...) "{{{3
|
||||
let handlers = a:0 >= 1 && !empty(a:1) ? a:1 : g:tlib_handlers_EditList
|
||||
let handlers = a:0 >= 1 && !empty(a:1) ? a:1 : g:tlib#input#handlers_EditList
|
||||
let default = a:0 >= 2 ? a:2 : []
|
||||
let timeout = a:0 >= 3 ? a:3 : 0
|
||||
" TLogVAR handlers
|
||||
@ -767,7 +1096,7 @@ function! tlib#input#Resume(name, pick, bufnr) "{{{3
|
||||
" TLogVAR a:name, a:pick
|
||||
echo
|
||||
if bufnr('%') != a:bufnr
|
||||
if g:tlib_debug
|
||||
if g:tlib#debug
|
||||
echohl WarningMsg
|
||||
echom "tlib#input#Resume: Internal error: Not in scratch buffer:" bufname('%')
|
||||
echohl NONE
|
||||
@ -775,7 +1104,7 @@ function! tlib#input#Resume(name, pick, bufnr) "{{{3
|
||||
let br = tlib#buffer#Set(a:bufnr)
|
||||
endif
|
||||
if !exists('b:tlib_'. a:name)
|
||||
if g:tlib_debug
|
||||
if g:tlib#debug
|
||||
echohl WarningMsg
|
||||
echom "tlib#input#Resume: Internal error: b:tlib_". a:name ." does not exist:" bufname('%')
|
||||
echohl NONE
|
||||
|
30
sources_non_forked/tlib/autoload/tlib/number.vim
Normal file
30
sources_non_forked/tlib/autoload/tlib/number.vim
Normal file
@ -0,0 +1,30 @@
|
||||
" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Revision: 14
|
||||
|
||||
|
||||
function! tlib#number#ConvertBase(num, base, ...) "{{{3
|
||||
let rtype = a:0 >= 1 ? a:1 : 'string'
|
||||
" TLogVAR a:num, a:base, rtype
|
||||
let rv = []
|
||||
let num = 0.0 + a:num
|
||||
while floor(num) > 0.0
|
||||
let div = floor(num / a:base)
|
||||
let num1 = float2nr(num - a:base * div)
|
||||
if a:base <= 10
|
||||
call insert(rv, num1)
|
||||
elseif a:base == 16
|
||||
let char = "0123456789ABCDEF"[num1]
|
||||
call insert(rv, char)
|
||||
endif
|
||||
let num = num / a:base
|
||||
endwh
|
||||
" TLogVAR rv
|
||||
if rtype == 'list'
|
||||
return rv
|
||||
else
|
||||
return join(rv, '')
|
||||
endif
|
||||
endf
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2012-05-11.
|
||||
" @Last Change: 2012-05-11.
|
||||
" @Revision: 6
|
||||
" @Revision: 7
|
||||
|
||||
" The directory for persistent data files. If empty, use
|
||||
" |tlib#dir#MyRuntime|.'/share'.
|
||||
@ -38,6 +38,10 @@ function! tlib#persistent#Get(cfile) "{{{3
|
||||
endif
|
||||
endf
|
||||
|
||||
function! tlib#persistent#Value(...) "{{{3
|
||||
return call('tlib#cache#Value', a:000)
|
||||
endf
|
||||
|
||||
function! tlib#persistent#Save(cfile, dictionary) "{{{3
|
||||
if !empty(a:cfile)
|
||||
" TLogVAR a:dictionary
|
||||
|
@ -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: 2012-02-08.
|
||||
" @Revision: 0.0.167
|
||||
" @Last Change: 2013-10-16.
|
||||
" @Revision: 0.0.242
|
||||
|
||||
if &cp || exists("loaded_tlib_scratch_autoload")
|
||||
finish
|
||||
@ -12,6 +12,17 @@ endif
|
||||
let loaded_tlib_scratch_autoload = 1
|
||||
|
||||
|
||||
" Scratch window position. By default the list window is opened on the
|
||||
" bottom. Set this variable to 'topleft' or '' to change this behaviour.
|
||||
" See |tlib#input#List()|.
|
||||
TLet g:tlib_scratch_pos = 'botright'
|
||||
|
||||
" If you want the scratch buffer to be fully removed, you might want to
|
||||
" set this variable to 'wipe'.
|
||||
" See also https://github.com/tomtom/tlib_vim/pull/16
|
||||
TLet g:tlib#scratch#hidden = 'hide'
|
||||
|
||||
|
||||
" :def: function! tlib#scratch#UseScratch(?keyargs={})
|
||||
" Display a scratch buffer (a buffer with no file). See :TScratch for an
|
||||
" example.
|
||||
@ -22,23 +33,21 @@ function! tlib#scratch#UseScratch(...) "{{{3
|
||||
exec tlib#arg#Let([['keyargs', {}]])
|
||||
" TLogDBG string(keys(keyargs))
|
||||
let id = get(keyargs, 'scratch', '__Scratch__')
|
||||
" TLogVAR id
|
||||
" TLogDBG winnr()
|
||||
" TLogDBG bufnr(id)
|
||||
" TLogDBG bufwinnr(id)
|
||||
" TLogDBG bufnr('%')
|
||||
if id =~ '^\d\+$' && bufwinnr(id) != -1
|
||||
if bufnr('%') != id
|
||||
exec 'noautocmd buffer! '. id
|
||||
endif
|
||||
" let ft = &ft
|
||||
let ft = '*'
|
||||
" TLogVAR id, bufwinnr(id)
|
||||
" TLogVAR bufnr(id), bufname(id)
|
||||
" TLogVAR 1, winnr(), bufnr('%'), bufname("%")
|
||||
if bufwinnr(id) != -1
|
||||
" echom 'DBG noautocmd keepalt keepj' bufwinnr(id) 'wincmd w'
|
||||
exec 'noautocmd keepalt keepj' bufwinnr(id) 'wincmd w'
|
||||
" TLogVAR "reuse", bufnr("%"), bufname("%")
|
||||
else
|
||||
let winpos = ''
|
||||
let bn = bufnr(id)
|
||||
let wpos = get(keyargs, 'scratch_pos', g:tlib_scratch_pos)
|
||||
" TLogVAR keyargs.scratch_vertical
|
||||
if get(keyargs, 'scratch_vertical')
|
||||
let wpos .= ' vertical'
|
||||
let winpos = tlib#fixes#Winpos()
|
||||
endif
|
||||
" TLogVAR wpos
|
||||
let scratch_split = get(keyargs, 'scratch_split', 1)
|
||||
@ -47,7 +56,7 @@ function! tlib#scratch#UseScratch(...) "{{{3
|
||||
let wn = bufwinnr(bn)
|
||||
if wn != -1
|
||||
" TLogVAR wn
|
||||
exec 'noautocmd' (wn .'wincmd w')
|
||||
exec 'noautocmd keepalt keepj' (wn .'wincmd w')
|
||||
else
|
||||
if scratch_split == 1
|
||||
let cmd = wpos.' sbuffer!'
|
||||
@ -57,7 +66,7 @@ function! tlib#scratch#UseScratch(...) "{{{3
|
||||
let cmd = 'buffer!'
|
||||
endif
|
||||
" TLogVAR cmd
|
||||
silent exec 'noautocmd' cmd bn
|
||||
silent exec 'noautocmd keepalt keepj' cmd bn
|
||||
endif
|
||||
else
|
||||
" TLogVAR id
|
||||
@ -69,24 +78,29 @@ function! tlib#scratch#UseScratch(...) "{{{3
|
||||
let cmd = 'edit'
|
||||
endif
|
||||
" TLogVAR cmd
|
||||
silent exec 'noautocmd' cmd escape(id, '%#\ ')
|
||||
silent exec 'noautocmd keepalt keepj' cmd escape(id, '%#\ ')
|
||||
" silent exec 'split '. id
|
||||
endif
|
||||
let ft = get(keyargs, 'scratch_filetype', '')
|
||||
" TLogVAR ft
|
||||
endif
|
||||
setlocal buftype=nofile
|
||||
setlocal bufhidden=hide
|
||||
setlocal noswapfile
|
||||
setlocal nobuflisted
|
||||
setlocal foldmethod=manual
|
||||
setlocal foldcolumn=0
|
||||
setlocal modifiable
|
||||
setlocal nospell
|
||||
if &ft != '*'
|
||||
let &ft = ft
|
||||
" TLogVAR ft, winpos
|
||||
if !empty(winpos)
|
||||
exec winpos
|
||||
endif
|
||||
setlocal buftype=nofile
|
||||
let &l:bufhidden = get(keyargs, 'scratch_hidden', g:tlib#scratch#hidden)
|
||||
setlocal noswapfile
|
||||
setlocal nobuflisted
|
||||
setlocal foldmethod=manual
|
||||
setlocal foldcolumn=0
|
||||
setlocal modifiable
|
||||
setlocal nospell
|
||||
" TLogVAR &ft, ft
|
||||
if !empty(ft)
|
||||
let &l:ft = ft
|
||||
endif
|
||||
endif
|
||||
let keyargs.scratch = bufnr('%')
|
||||
" TLogVAR 2, winnr(), bufnr('%'), bufname("%")
|
||||
return keyargs.scratch
|
||||
endf
|
||||
|
||||
@ -106,7 +120,11 @@ function! tlib#scratch#CloseScratch(keyargs, ...) "{{{3
|
||||
if wn != -1
|
||||
" TLogDBG winnr()
|
||||
let wb = tlib#win#Set(wn)
|
||||
let winpos = tlib#fixes#Winpos()
|
||||
wincmd c
|
||||
if get(a:keyargs, 'scratch_vertical') && !empty(winpos)
|
||||
exec winpos
|
||||
endif
|
||||
" exec wb
|
||||
" redraw
|
||||
" TLogVAR winnr()
|
||||
|
@ -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-08-11.
|
||||
" @Revision: 0.0.56
|
||||
" @Last Change: 2013-09-25.
|
||||
" @Revision: 0.0.58
|
||||
|
||||
if &cp || exists("loaded_tlib_tag_autoload")
|
||||
finish
|
||||
@ -12,6 +12,23 @@ endif
|
||||
let loaded_tlib_tag_autoload = 1
|
||||
|
||||
|
||||
" Extra tags for |tlib#tag#Retrieve()| (see there). Can also be buffer-local.
|
||||
TLet g:tlib_tags_extra = ''
|
||||
|
||||
" Filter the tag description through |substitute()| for these filetypes.
|
||||
" This applies only if the tag cmd field (see |taglist()|) is used.
|
||||
" :nodefault:
|
||||
TLet g:tlib_tag_substitute = {
|
||||
\ 'java': [['\s*{\s*$', '', '']],
|
||||
\ 'ruby': [['\<\(def\|class\|module\)\>\s\+', '', '']],
|
||||
\ 'vim': [
|
||||
\ ['^\s*com\%[mand]!\?\(\s\+-\S\+\)*\s*\u\w*\zs.*$', '', ''],
|
||||
\ ['^\s*\(let\|aug\%[roup]\|fu\%[nction]!\?\|com\%[mand]!\?\(\s\+-\S\+\)*\)\s*', '', ''],
|
||||
\ ['"\?\s*{{{\d.*$', '', ''],
|
||||
\ ],
|
||||
\ }
|
||||
|
||||
|
||||
" :def: function! tlib#tag#Retrieve(rx, ?extra_tags=0)
|
||||
" Get all tags matching rx. Basically, this function simply calls
|
||||
" |taglist()|, but when extra_tags is true, the list of the tag files
|
||||
|
Reference in New Issue
Block a user