Skip to content

Commit

Permalink
Version 0.20
Browse files Browse the repository at this point in the history
CHANGES:
- The arguments of tlib#tag#Collect() have changed.
- tlib#input#List(): The view can be "suspended" on initial display.
- tlib#input#List(): Follow/trace cursor functionality
  • Loading branch information
tomtom authored and vim-scripts committed Oct 18, 2010
1 parent 3579334 commit 13de43e
Show file tree
Hide file tree
Showing 6 changed files with 358 additions and 226 deletions.
54 changes: 41 additions & 13 deletions autoload/tlib/World.vim
Expand Up @@ -3,8 +3,8 @@
" @Website: http://members.a1.net/t.link/ " @Website: http://members.a1.net/t.link/
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-05-01. " @Created: 2007-05-01.
" @Last Change: 2007-11-03. " @Last Change: 2007-11-11.
" @Revision: 0.1.383 " @Revision: 0.1.408


" :filedoc: " :filedoc:
" A prototype used by |tlib#input#List|. " A prototype used by |tlib#input#List|.
Expand All @@ -26,12 +26,14 @@ let s:prototype = tlib#Object#New({
\ 'display_format': '', \ 'display_format': '',
\ 'filter': [['']], \ 'filter': [['']],
\ 'filter_format': '', \ 'filter_format': '',
\ 'follow_cursor': '',
\ 'index_table': [], \ 'index_table': [],
\ 'initial_filter': [['']], \ 'initial_filter': [['']],
\ 'initial_index': 1, \ 'initial_index': 1,
\ 'initialized': 0, \ 'initialized': 0,
\ 'key_handlers': [], \ 'key_handlers': [],
\ 'list': [], \ 'list': [],
\ 'next_state': '',
\ 'numeric_chars': tlib#var#Get('tlib_numeric_chars', 'bg'), \ 'numeric_chars': tlib#var#Get('tlib_numeric_chars', 'bg'),
\ 'offset': 1, \ 'offset': 1,
\ 'offset_horizontal': 0, \ 'offset_horizontal': 0,
Expand Down Expand Up @@ -83,7 +85,7 @@ endf
function! s:prototype.Highlight_filename() dict "{{{3 function! s:prototype.Highlight_filename() dict "{{{3
" exec 'syn match TLibDir /\%>'. (3 + eval(g:tlib_inputlist_width_filename)) .'c \(\S:\)\?[\/].*$/ contained containedin=TLibMarker' " exec 'syn match TLibDir /\%>'. (3 + eval(g:tlib_inputlist_width_filename)) .'c \(\S:\)\?[\/].*$/ contained containedin=TLibMarker'
exec 'syn match TLibDir /\(\a:\|\.\.\.\S\{-}\)\?[\/][^&<>*|]*$/ contained containedin=TLibMarker' exec 'syn match TLibDir /\(\a:\|\.\.\.\S\{-}\)\?[\/][^&<>*|]*$/ contained containedin=TLibMarker'
exec 'syn match TLibMarker /\%>'. (1 + eval(g:tlib_inputlist_width_filename)) .'c |\( \|[[:alnum:]%+-]*\)| \S.*$/ contains=TLibDir' exec 'syn match TLibMarker /\%>'. (1 + eval(g:tlib_inputlist_width_filename)) .'c |\( \|[[:alnum:]%*+-]*\)| \S.*$/ contains=TLibDir'
hi def link TLibMarker Special hi def link TLibMarker Special
hi def link TLibDir Directory hi def link TLibDir Directory
endf endf
Expand All @@ -101,7 +103,7 @@ function! s:prototype.FormatFilename(file) dict "{{{3
let dname = '...'. strpart(fnamemodify(a:file, ":h"), len(dname) - dnmax) let dname = '...'. strpart(fnamemodify(a:file, ":h"), len(dname) - dnmax)
endif endif
let marker = [] let marker = []
let bnr = bufnr(a:file) let bnr = bufnr(a:file)
" TLogVAR a:file, bnr, self.bufnr " TLogVAR a:file, bnr, self.bufnr
if bnr != -1 if bnr != -1
if bnr == self.bufnr if bnr == self.bufnr
Expand All @@ -113,18 +115,15 @@ function! s:prototype.FormatFilename(file) dict "{{{3
call add(marker, 'B') call add(marker, 'B')
endif endif
elseif bufloaded(a:file) elseif bufloaded(a:file)
call add(marker, 'b') call add(marker, 'h')
else else
call add(marker, '-') call add(marker, 'u')
endif endif
else else
call add(marker, ' ') call add(marker, ' ')
endif endif
if !empty(marker) call insert(marker, '|')
call insert(marker, '|') call add(marker, '|')
call add(marker, '|')
" let fname .= ' '. join(marker, '')
endif
return printf("%-". eval(g:tlib_inputlist_width_filename) ."s %s %s", fname, join(marker, ''), dname) return printf("%-". eval(g:tlib_inputlist_width_filename) ."s %s %s", fname, join(marker, ''), dname)
endf endf


Expand Down Expand Up @@ -256,6 +255,21 @@ function! s:prototype.GetCurrentItem() dict "{{{3
endf endf




function! s:prototype.CurrentItem() dict "{{{3
if stridx(self.type, 'i') != -1
return self.GetBaseIdx(self.llen == 1 ? 1 : self.prefidx)
else
if self.llen == 1
" TLogVAR self.llen
return self.list[0]
elseif self.prefidx > 0
" TLogVAR self.prefidx
return self.GetCurrentItem()
endif
endif
endf


function! s:prototype.SetFilter() dict "{{{3 function! s:prototype.SetFilter() dict "{{{3
" let mrx = '\V'. (a:0 >= 1 && a:1 ? '\C' : '') " let mrx = '\V'. (a:0 >= 1 && a:1 ? '\C' : '')
let mrx = '\V'. self.filter_format let mrx = '\V'. self.filter_format
Expand Down Expand Up @@ -334,7 +348,8 @@ endf




function! s:prototype.SetInitialFilter(filter) dict "{{{3 function! s:prototype.SetInitialFilter(filter) dict "{{{3
let self.initial_filter = [[''], [a:filter]] " let self.initial_filter = [[''], [a:filter]]
let self.initial_filter = [[a:filter]]
endf endf




Expand Down Expand Up @@ -624,3 +639,16 @@ function! s:prototype.SwitchWindow(where) dict "{{{3
endf endf




function! s:prototype.FollowCursor() dict "{{{3
if !empty(self.follow_cursor)
let back = self.SwitchWindow('win')
" TLogVAR back
" TLogDBG winnr()
try
call call(self.follow_cursor, [self, [self.CurrentItem()]])
finally
exec back
endtry
endif
endf

8 changes: 5 additions & 3 deletions autoload/tlib/buffer.vim
Expand Up @@ -3,8 +3,8 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037 " @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-06-30. " @Created: 2007-06-30.
" @Last Change: 2007-10-26. " @Last Change: 2007-11-11.
" @Revision: 0.0.157 " @Revision: 0.0.173


if &cp || exists("loaded_tlib_buffer_autoload") if &cp || exists("loaded_tlib_buffer_autoload")
finish finish
Expand Down Expand Up @@ -115,14 +115,16 @@ function! tlib#buffer#ViewLine(line, ...) "{{{3
TVarArg 'pos' TVarArg 'pos'
let ln = matchstr(a:line, '^\d\+') let ln = matchstr(a:line, '^\d\+')
let lt = matchstr(a:line, '^\d\+: \zs.*') let lt = matchstr(a:line, '^\d\+: \zs.*')
TLogVAR pos, ln, lt
exec ln exec ln
if empty(pos) if empty(pos)
let pos = tlib#var#Get('tlib_viewline_position', 'wbg') let pos = tlib#var#Get('tlib_viewline_position', 'wbg')
endif endif
" TLogVAR pos
if !empty(pos) if !empty(pos)
exec 'norm! '. pos exec 'norm! '. pos
endif endif
let @/ = '\V\%'. ln .'l'. escape(lt, '\') let @/ = '\%'. ln .'l.*'
endif endif
endf endf


Expand Down
33 changes: 18 additions & 15 deletions autoload/tlib/input.vim
Expand Up @@ -3,8 +3,8 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037 " @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-06-30. " @Created: 2007-06-30.
" @Last Change: 2007-11-03. " @Last Change: 2007-11-11.
" @Revision: 0.0.407 " @Revision: 0.0.436


if &cp || exists("loaded_tlib_input_autoload") if &cp || exists("loaded_tlib_input_autoload")
finish finish
Expand Down Expand Up @@ -76,8 +76,8 @@ function! tlib#input#List(type, ...) "{{{3
call world.Set_display_format(tlib#list#Find(handlers, 'has_key(v:val, "display_format")', '', 'v:val.display_format')) call world.Set_display_format(tlib#list#Find(handlers, 'has_key(v:val, "display_format")', '', 'v:val.display_format'))
let world.initial_index = tlib#list#Find(handlers, 'has_key(v:val, "initial_index")', 1, 'v:val.initial_index') let world.initial_index = tlib#list#Find(handlers, 'has_key(v:val, "initial_index")', 1, 'v:val.initial_index')
let world.index_table = tlib#list#Find(handlers, 'has_key(v:val, "index_table")', [], 'v:val.index_table') let world.index_table = tlib#list#Find(handlers, 'has_key(v:val, "index_table")', [], 'v:val.index_table')
let world.state_handlers = filter(copy(handlers), 'has_key(v:val, "state")') let world.state_handlers = filter(copy(handlers), 'has_key(v:val, "state")')
let world.post_handlers = filter(copy(handlers), 'has_key(v:val, "postprocess")') let world.post_handlers = filter(copy(handlers), 'has_key(v:val, "postprocess")')
let world.filter_format = tlib#list#Find(handlers, 'has_key(v:val, "filter_format")', '', 'v:val.filter_format') let world.filter_format = tlib#list#Find(handlers, 'has_key(v:val, "filter_format")', '', 'v:val.filter_format')
let world.return_agent = tlib#list#Find(handlers, 'has_key(v:val, "return_agent")', '', 'v:val.return_agent') let world.return_agent = tlib#list#Find(handlers, 'has_key(v:val, "return_agent")', '', 'v:val.return_agent')
let world.resize = tlib#list#Find(handlers, 'has_key(v:val, "resize")', '', 'v:val.resize') let world.resize = tlib#list#Find(handlers, 'has_key(v:val, "resize")', '', 'v:val.resize')
Expand Down Expand Up @@ -267,6 +267,7 @@ function! tlib#input#ListW(world, ...) "{{{3
" TLogDBG 8 " TLogDBG 8
if initial_display || !tlib#char#IsAvailable() if initial_display || !tlib#char#IsAvailable()
call world.DisplayList(world.query .' (filter: '. world.DisplayFilter() .'; press "?" for help)', dlist) call world.DisplayList(world.query .' (filter: '. world.DisplayFilter() .'; press "?" for help)', dlist)
call world.FollowCursor()
let initial_display = 0 let initial_display = 0
" TLogDBG 9 " TLogDBG 9
endif endif
Expand All @@ -280,11 +281,23 @@ function! tlib#input#ListW(world, ...) "{{{3
let world.state = 'display' let world.state = 'display'
else else
let world.state = '' let world.state = ''
call world.FollowCursor()
endif endif
endif endif
" TAssert IsNotEmpty(world.scratch) " TAssert IsNotEmpty(world.scratch)
let world.list_wnr = winnr() let world.list_wnr = winnr()


" TLogVAR world.next_state, world.state
if !empty(world.next_state)
let world.state = world.next_state
let world.next_state = ''
endif

if world.state =~ '\<suspend\>'
let world = tlib#agent#SuspendToParentWindow(world, world.rv)
continue
endif

" TLogVAR world.timeout " TLogVAR world.timeout
let c = tlib#char#Get(world.timeout, world.timeout_resolution) let c = tlib#char#Get(world.timeout, world.timeout_resolution)
if world.state != '' if world.state != ''
Expand Down Expand Up @@ -351,17 +364,7 @@ function! tlib#input#ListW(world, ...) "{{{3
" TLogVAR world.list " TLogVAR world.list
if empty(world.state) if empty(world.state)
" TLogVAR world.state " TLogVAR world.state
if stridx(world.type, 'i') != -1 let world.rv = world.CurrentItem()
let world.rv = world.GetBaseIdx(world.llen == 1 ? 1 : world.prefidx)
else
if world.llen == 1
" TLogVAR world.llen
let world.rv = world.list[0]
elseif world.prefidx > 0
" TLogVAR world.prefidx
let world.rv = world.GetCurrentItem()
endif
endif
endif endif
for handler in world.post_handlers for handler in world.post_handlers
let state = get(handler, 'postprocess', '') let state = get(handler, 'postprocess', '')
Expand Down
46 changes: 39 additions & 7 deletions autoload/tlib/tag.vim
Expand Up @@ -3,8 +3,8 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037 " @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-11-01. " @Created: 2007-11-01.
" @Last Change: 2007-11-04. " @Last Change: 2007-11-11.
" @Revision: 0.0.28 " @Revision: 0.0.44


if &cp || exists("loaded_tlib_tag_autoload") if &cp || exists("loaded_tlib_tag_autoload")
finish finish
Expand All @@ -16,6 +16,26 @@ let loaded_tlib_tag_autoload = 1
" Get all tags matching rx. Basically, this function simply calls " Get all tags matching rx. Basically, this function simply calls
" |taglist()|, but when extra_tags is true, the list of the tag files " |taglist()|, but when extra_tags is true, the list of the tag files
" (see 'tags') is temporarily expanded with |g:tlib_tags_extra|. " (see 'tags') is temporarily expanded with |g:tlib_tags_extra|.
"
" Example use:
" If want to include tags for, eg, JDK, normal tags use can become slow.
" You could proceed as follows:
" 1. Create a tags file for the JDK sources. When creating the tags
" file, make sure to include inheritance information and the like
" (command-line options like --fields=+iaSm --extra=+q should be ok).
" In this example, we want tags only for public methods (there are
" most likely better ways to do this): >
" ctags -R --fields=+iaSm --extra=+q ${JAVA_HOME}/src
" head -n 6 tags > tags0
" grep access:public tags >> tags0
" < 2. Say 'tags' included project specific tags files. In
" ~/vimfiles/after/ftplugin/java.vim insert: >
" let b:tlib_tags_extra = $JAVA_HOME .'/tags0'
" < 3. When this function is invoked as >
" echo tlib#tag#Retrieve('print')
" < It will return only project-local tags. If it is invoked as >
" echo tlib#tag#Retrieve('print', 1)
" < tags from the JDK will be included.
function! tlib#tag#Retrieve(rx, ...) "{{{3 function! tlib#tag#Retrieve(rx, ...) "{{{3
TVarArg ['extra_tags', 0] TVarArg ['extra_tags', 0]
if extra_tags if extra_tags
Expand Down Expand Up @@ -43,18 +63,24 @@ endf
" regexp, with the exception of the kind field that is a list of chars). " regexp, with the exception of the kind field that is a list of chars).
" For the use of the optional use_extra argument see " For the use of the optional use_extra argument see
" |tlib#tag#Retrieve()|. " |tlib#tag#Retrieve()|.
" :def: function! tlib#tag#Collect(constraints, ?use_extra=0, ?match_front=0) " :def: function! tlib#tag#Collect(constraints, ?use_extra=1, ?match_front=1)
function! tlib#tag#Collect(constraints, ...) "{{{3 function! tlib#tag#Collect(constraints, ...) "{{{3
TVarArg ['use_extra', 0], ['match_front', 0] TVarArg ['use_extra', 0], ['match_end', 1], ['match_front', 1]
" TLogVAR a:constraints, use_extra " TLogVAR a:constraints, use_extra
let rx = get(a:constraints, 'name', '') let rx = get(a:constraints, 'name', '')
if empty(rx) || rx == '*' if empty(rx) || rx == '*'
let rx = '.' let rx = '.'
else else
let rx = '\C^'. tlib#rx#Escape(rx) let rxl = ['\C']
if !match_front if match_front
let rx .= '$' call add(rxl, '^')
endif endif
" call add(rxl, tlib#rx#Escape(rx))
call add(rxl, rx)
if match_end
call add(rxl, '$')
endif
let rx = join(rxl, '')
endif endif
" TLogVAR rx, use_extra " TLogVAR rx, use_extra
let tags = tlib#tag#Retrieve(rx, use_extra) let tags = tlib#tag#Retrieve(rx, use_extra)
Expand All @@ -81,6 +107,12 @@ function! tlib#tag#Format(tag) "{{{3
let name = substitute(name, '^/\^\?\s*', '', '') let name = substitute(name, '^/\^\?\s*', '', '')
let name = substitute(name, '\s*\$\?/$', '', '') let name = substitute(name, '\s*\$\?/$', '', '')
let name = substitute(name, '\s\{2,}', ' ', 'g') let name = substitute(name, '\s\{2,}', ' ', 'g')
let tsub = tlib#var#Get('tlib_tag_substitute', 'bg')
if has_key(tsub, &filetype)
for [rx, rplc, sub] in tsub[&filetype]
let name = substitute(name, rx, rplc, sub)
endfor
endif
else else
let name = a:tag.name let name = a:tag.name
endif endif
Expand Down

0 comments on commit 13de43e

Please sign in to comment.