Permalink
Browse files

Version 0.20

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 Nov 12, 2007
1 parent 3579334 commit 13de43e63d408862dda99b6133cc5aa1a6862446
Showing with 358 additions and 226 deletions.
  1. +41 −13 autoload/tlib/World.vim
  2. +5 −3 autoload/tlib/buffer.vim
  3. +18 −15 autoload/tlib/input.vim
  4. +39 −7 autoload/tlib/tag.vim
  5. +226 −184 doc/tlib.txt
  6. +29 −4 plugin/02tlib.vim
View
@@ -3,8 +3,8 @@
" @Website: http://members.a1.net/t.link/
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-05-01.
-" @Last Change: 2007-11-03.
-" @Revision: 0.1.383
+" @Last Change: 2007-11-11.
+" @Revision: 0.1.408
" :filedoc:
" A prototype used by |tlib#input#List|.
@@ -26,12 +26,14 @@ let s:prototype = tlib#Object#New({
\ 'display_format': '',
\ 'filter': [['']],
\ 'filter_format': '',
+ \ 'follow_cursor': '',
\ 'index_table': [],
\ 'initial_filter': [['']],
\ 'initial_index': 1,
\ 'initialized': 0,
\ 'key_handlers': [],
- \ 'list': [],
+ \ 'list': [],
+ \ 'next_state': '',
\ 'numeric_chars': tlib#var#Get('tlib_numeric_chars', 'bg'),
\ 'offset': 1,
\ 'offset_horizontal': 0,
@@ -83,7 +85,7 @@ endf
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 /\(\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 TLibDir Directory
endf
@@ -101,7 +103,7 @@ function! s:prototype.FormatFilename(file) dict "{{{3
let dname = '...'. strpart(fnamemodify(a:file, ":h"), len(dname) - dnmax)
endif
let marker = []
- let bnr = bufnr(a:file)
+ let bnr = bufnr(a:file)
" TLogVAR a:file, bnr, self.bufnr
if bnr != -1
if bnr == self.bufnr
@@ -113,18 +115,15 @@ function! s:prototype.FormatFilename(file) dict "{{{3
call add(marker, 'B')
endif
elseif bufloaded(a:file)
- call add(marker, 'b')
+ call add(marker, 'h')
else
- call add(marker, '-')
+ call add(marker, 'u')
endif
else
call add(marker, ' ')
endif
- if !empty(marker)
- call insert(marker, '|')
- call add(marker, '|')
- " let fname .= ' '. join(marker, '')
- endif
+ call insert(marker, '|')
+ call add(marker, '|')
return printf("%-". eval(g:tlib_inputlist_width_filename) ."s %s %s", fname, join(marker, ''), dname)
endf
@@ -256,6 +255,21 @@ function! s:prototype.GetCurrentItem() dict "{{{3
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
" let mrx = '\V'. (a:0 >= 1 && a:1 ? '\C' : '')
let mrx = '\V'. self.filter_format
@@ -334,7 +348,8 @@ endf
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
@@ -624,3 +639,16 @@ function! s:prototype.SwitchWindow(where) dict "{{{3
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
+
View
@@ -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: 2007-10-26.
-" @Revision: 0.0.157
+" @Last Change: 2007-11-11.
+" @Revision: 0.0.173
if &cp || exists("loaded_tlib_buffer_autoload")
finish
@@ -115,14 +115,16 @@ function! tlib#buffer#ViewLine(line, ...) "{{{3
TVarArg 'pos'
let ln = matchstr(a:line, '^\d\+')
let lt = matchstr(a:line, '^\d\+: \zs.*')
+ TLogVAR pos, ln, lt
exec ln
if empty(pos)
let pos = tlib#var#Get('tlib_viewline_position', 'wbg')
endif
+ " TLogVAR pos
if !empty(pos)
exec 'norm! '. pos
endif
- let @/ = '\V\%'. ln .'l'. escape(lt, '\')
+ let @/ = '\%'. ln .'l.*'
endif
endf
View
@@ -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: 2007-11-03.
-" @Revision: 0.0.407
+" @Last Change: 2007-11-11.
+" @Revision: 0.0.436
if &cp || exists("loaded_tlib_input_autoload")
finish
@@ -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'))
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.state_handlers = filter(copy(handlers), 'has_key(v:val, "state")')
- let world.post_handlers = filter(copy(handlers), 'has_key(v:val, "postprocess")')
+ 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.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.resize = tlib#list#Find(handlers, 'has_key(v:val, "resize")', '', 'v:val.resize')
@@ -267,6 +267,7 @@ function! tlib#input#ListW(world, ...) "{{{3
" TLogDBG 8
if initial_display || !tlib#char#IsAvailable()
call world.DisplayList(world.query .' (filter: '. world.DisplayFilter() .'; press "?" for help)', dlist)
+ call world.FollowCursor()
let initial_display = 0
" TLogDBG 9
endif
@@ -280,11 +281,23 @@ function! tlib#input#ListW(world, ...) "{{{3
let world.state = 'display'
else
let world.state = ''
+ call world.FollowCursor()
endif
endif
" TAssert IsNotEmpty(world.scratch)
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
let c = tlib#char#Get(world.timeout, world.timeout_resolution)
if world.state != ''
@@ -351,17 +364,7 @@ function! tlib#input#ListW(world, ...) "{{{3
" TLogVAR world.list
if empty(world.state)
" TLogVAR world.state
- if stridx(world.type, 'i') != -1
- 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
+ let world.rv = world.CurrentItem()
endif
for handler in world.post_handlers
let state = get(handler, 'postprocess', '')
View
@@ -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: 2007-11-04.
-" @Revision: 0.0.28
+" @Last Change: 2007-11-11.
+" @Revision: 0.0.44
if &cp || exists("loaded_tlib_tag_autoload")
finish
@@ -16,6 +16,26 @@ let loaded_tlib_tag_autoload = 1
" Get all tags matching rx. Basically, this function simply calls
" |taglist()|, but when extra_tags is true, the list of the tag files
" (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
TVarArg ['extra_tags', 0]
if extra_tags
@@ -43,18 +63,24 @@ endf
" regexp, with the exception of the kind field that is a list of chars).
" For the use of the optional use_extra argument see
" |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
- TVarArg ['use_extra', 0], ['match_front', 0]
+ TVarArg ['use_extra', 0], ['match_end', 1], ['match_front', 1]
" TLogVAR a:constraints, use_extra
let rx = get(a:constraints, 'name', '')
if empty(rx) || rx == '*'
let rx = '.'
else
- let rx = '\C^'. tlib#rx#Escape(rx)
- if !match_front
- let rx .= '$'
+ let rxl = ['\C']
+ if match_front
+ call add(rxl, '^')
endif
+ " call add(rxl, tlib#rx#Escape(rx))
+ call add(rxl, rx)
+ if match_end
+ call add(rxl, '$')
+ endif
+ let rx = join(rxl, '')
endif
" TLogVAR rx, use_extra
let tags = tlib#tag#Retrieve(rx, use_extra)
@@ -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\{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
let name = a:tag.name
endif
Oops, something went wrong.

0 comments on commit 13de43e

Please sign in to comment.