Permalink
Browse files

Version 0.19

NEW:
    - tag.vim
FIX:
    - dir.vim: Use plain dir name in tlib#dir#Ensure()
    - tlib#input#List(): An initial filter argument creates [[filter]]
    and not as before [[''], [filter]].
    - tlib#input#List(): When type was "si" and the item was picked by
    filter, the wrong index was returned.
    - tlib#input#List(): Don't check if chars are typed when displaying
    the list for the first time.
  • Loading branch information...
1 parent b7e236e commit 35793344517b8ab717fd1fcf2798050937f35892 @tomtom tomtom committed with Nov 5, 2007
@@ -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-10-21.
-" @Revision: 0.1.374
+" @Last Change: 2007-11-03.
+" @Revision: 0.1.383
" :filedoc:
" A prototype used by |tlib#input#List|.
@@ -83,7 +83,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
@@ -488,13 +488,14 @@ endf
function! s:prototype.Resize(hsize, vsize) dict "{{{3
+ " TLogVAR self.scratch_vertical, a:hsize, a:vsize
if self.scratch_vertical
if a:vsize
- exec 'vert resize '. a:vsize
+ exec 'vert resize '. eval(a:vsize)
endif
else
if a:hsize
- exec 'resize '. a:hsize
+ exec 'resize '. eval(a:hsize)
endif
endif
endf
@@ -530,6 +531,7 @@ function! s:prototype.DisplayList(query, ...) dict "{{{3
" let w = winwidth(0) - &fdc - 1
let lines = copy(list)
let lines = map(lines, 'printf("%-'. w .'.'. w .'s", substitute(v:val, ''[[:cntrl:][:space:]]'', " ", "g"))')
+ " TLogVAR lines
call append(0, lines)
norm! Gddgg
endif
@@ -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-09-19.
-" @Revision: 0.0.155
+" @Last Change: 2007-10-26.
+" @Revision: 0.0.157
if &cp || exists("loaded_tlib_buffer_autoload")
finish
@@ -239,3 +239,8 @@ function! tlib#buffer#InsertText0(text, ...) "{{{3
return tlib#buffer#InsertText(a:text, keyargs)
endf
+
+function! tlib#buffer#CurrentByte() "{{{3
+ return line2byte(line('.')) + col('.')
+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: 2007-09-19.
-" @Revision: 0.1.23
+" @Last Change: 2007-11-01.
+" @Revision: 0.1.28
if &cp || exists("loaded_tlib_cache_autoload")
finish
@@ -28,12 +28,20 @@ function! tlib#cache#Filename(type, ...) "{{{3
let file = expand('%:p')
let file = tlib#file#Relative(file, tlib#file#Join([dir, '..']))
endif
+ " TLogVAR file, dir
let mkdir = a:0 >= 2 ? a:2 : 0
let file = substitute(file, '\.\.\|[:&<>]\|//\+\|\\\\\+', '_', 'g')
- let dir = tlib#dir#PlainName(tlib#file#Join([dir, a:type, fnamemodify(file, ':h')]))
- let file = fnamemodify(file, ':t')
+ let dirs = [dir, a:type]
+ let dirf = fnamemodify(file, ':h')
+ if dirf != '.'
+ call add(dirs, dirf)
+ endif
+ let dir = tlib#file#Join(dirs)
" TLogVAR dir
- " TLogVAR file
+ let dir = tlib#dir#PlainName(dir)
+ " TLogVAR dir
+ let file = fnamemodify(file, ':t')
+ " TLogVAR file, dir
if mkdir && !isdirectory(dir)
call mkdir(dir, 'p')
endif
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-09-11.
-" @Revision: 0.0.22
+" @Last Change: 2007-11-01.
+" @Revision: 0.0.28
if &cp || exists("loaded_tlib_dir_autoload")
finish
@@ -28,14 +28,20 @@ endf
" tlib#dir#PlainName('foo/bar/')
" => 'foo/bar'
function! tlib#dir#PlainName(dirname) "{{{3
- return substitute(a:dirname, tlib#rx#Escape(g:tlib_filename_sep).'\+$', '', '')
+ let dirname = a:dirname
+ while dirname[-1 : -1] == g:tlib_filename_sep
+ let dirname = dirname[0 : -2]
+ endwh
+ return dirname
+ " return substitute(a:dirname, tlib#rx#Escape(g:tlib_filename_sep).'\+$', '', '')
endf
" Create a directory if it doesn't already exist.
function! tlib#dir#Ensure(dir) "{{{3
if !isdirectory(a:dir)
- return mkdir(a:dir, 'p')
+ let dir = tlib#dir#PlainName(a:dir)
+ return mkdir(dir, 'p')
endif
return 1
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: 2007-10-09.
-" @Revision: 0.0.45
+" @Last Change: 2007-11-01.
+" @Revision: 0.0.51
if &cp || exists("loaded_tlib_file_autoload")
finish
@@ -89,22 +89,30 @@ endf
" :def: function! tlib#file#With(fcmd, bcmd, files, ?world={})
function! tlib#file#With(fcmd, bcmd, files, ...) "{{{3
+ " TLogVAR a:fcmd, a:bcmd, a:files
exec tlib#arg#Let([['world', {}]])
for f in a:files
let bn = bufnr('^'.f.'$')
+ " TLogVAR f, bn
if bn != -1 && buflisted(bn)
if !empty(a:bcmd)
" TLogDBG a:bcmd .' '. bn
exec a:bcmd .' '. bn
call s:SetScrollBind(world)
endif
- elseif filereadable(f)
- if !empty(a:fcmd)
- " TLogDBG a:fcmd .' '. escape(f, '%#\ ')
- " exec a:fcmd .' '. escape(f, '%#\ ')
- " exec a:fcmd .' '. escape(f, '%# ')
- exec a:fcmd .' '. tlib#arg#Ex(f)
- call s:SetScrollBind(world)
+ else
+ if filereadable(f)
+ if !empty(a:fcmd)
+ " TLogDBG a:fcmd .' '. escape(f, '%#\ ')
+ " exec a:fcmd .' '. escape(f, '%#\ ')
+ " exec a:fcmd .' '. escape(f, '%# ')
+ exec a:fcmd .' '. tlib#arg#Ex(f)
+ call s:SetScrollBind(world)
+ endif
+ else
+ echohl error
+ echom 'File not readable: '. f
+ echohl NONE
endif
endif
endfor
@@ -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-21.
-" @Revision: 0.0.381
+" @Last Change: 2007-11-03.
+" @Revision: 0.0.407
if &cp || exists("loaded_tlib_input_autoload")
finish
@@ -89,7 +89,8 @@ function! tlib#input#List(type, ...) "{{{3
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)
- let world.initial_filter = [[''], [filter]]
+ " let world.initial_filter = [[''], [filter]]
+ let world.initial_filter = [[filter]]
" TLogVAR world.initial_filter
endif
endif
@@ -139,6 +140,7 @@ function! tlib#input#ListW(world, ...) "{{{3
let lastsearch = @/
let @/ = ''
let &laststatus = 2
+ let initial_display = 1
try
while !empty(world.state) && world.state !~ '^exit' && (world.show_empty || !empty(world.base))
@@ -232,6 +234,7 @@ function! tlib#input#ListW(world, ...) "{{{3
endif
" TLogVAR world.initial_index, world.prefidx
" TLogDBG 5
+ " TLogVAR world.list
let dlist = copy(world.list)
if !empty(world.display_format)
let display_format = world.display_format
@@ -245,6 +248,7 @@ function! tlib#input#ListW(world, ...) "{{{3
endif
" TLogVAR dindex
let dlist = map(range(0, world.llen - 1), 'printf("%0'. world.index_width .'d", dindex[v:val]) .": ". dlist[v:val]')
+ " TLogVAR dlist
endif
" TLogDBG 7
" TLogVAR world.prefidx, world.offset
@@ -261,8 +265,9 @@ function! tlib#input#ListW(world, ...) "{{{3
" let world.offset = world.prefidx
" endif
" TLogDBG 8
- if !tlib#char#IsAvailable()
+ if initial_display || !tlib#char#IsAvailable()
call world.DisplayList(world.query .' (filter: '. world.DisplayFilter() .'; press "?" for help)', dlist)
+ let initial_display = 0
" TLogDBG 9
endif
let world.state = ''
@@ -307,10 +312,12 @@ function! tlib#input#ListW(world, ...) "{{{3
elseif c >= 32
let world.state = 'display'
let numbase = get(world.numeric_chars, c, -99999)
+ " TLogVAR numbase, world.numeric_chars, c
if numbase != -99999
let world.idx .= (c - numbase)
if len(world.idx) == world.index_width
let world.prefidx = world.idx
+ " TLogVAR world.prefidx
throw 'pick'
endif
else
@@ -326,6 +333,7 @@ function! tlib#input#ListW(world, ...) "{{{3
endif
else
let world.state = 'redisplay'
+ " let world.state = 'continue'
endif
catch /^pick$/
@@ -344,7 +352,7 @@ function! tlib#input#ListW(world, ...) "{{{3
if empty(world.state)
" TLogVAR world.state
if stridx(world.type, 'i') != -1
- let world.rv = world.llen == 1 ? 1 : world.prefidx
+ let world.rv = world.GetBaseIdx(world.llen == 1 ? 1 : world.prefidx)
else
if world.llen == 1
" TLogVAR world.llen
@@ -378,24 +386,36 @@ function! tlib#input#ListW(world, ...) "{{{3
" TLogVAR world.idx
" TLogVAR world.prefidx
" TLogVAR world.rv
+ " TLogVAR world.type, world.state, world.return_agent, world.index_table, world.rv
if world.state =~ '\<suspend\>'
+ " TLogDBG 'return suspended'
" TLogVAR world.prefidx
" exec world.prefidx
return
elseif world.state =~ '\<empty\>'
+ " TLogDBG 'return empty'
return stridx(world.type, 'm') != -1 ? [] : stridx(world.type, 'i') != -1 ? 0 : ''
elseif !empty(world.return_agent)
+ " TLogDBG 'return agent'
" TLogVAR world.return_agent
call world.CloseScratch()
" TAssert IsNotEmpty(world.scratch)
return call(world.return_agent, [world, world.GetSelectedItems(world.rv)])
elseif stridx(world.type, 'w') != -1
+ " TLogDBG 'return world'
return world
elseif stridx(world.type, 'm') != -1
+ " TLogDBG 'return multi'
return world.GetSelectedItems(world.rv)
- elseif stridx(world.type, 'i') != -1 && !empty(world.index_table)
- return world.index_table[world.rv - 1]
+ elseif stridx(world.type, 'i') != -1
+ " TLogDBG 'return index'
+ if empty(world.index_table)
+ return world.rv
+ else
+ return world.index_table[world.rv - 1]
+ endif
else
+ " TLogDBG 'return normal'
return world.rv
endif
@@ -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-09-11.
-" @Revision: 0.0.25
+" @Last Change: 2007-11-02.
+" @Revision: 0.0.30
if &cp || exists("loaded_tlib_list_autoload")
finish
@@ -144,3 +144,25 @@ function! s:GetNthElement(n, lists, default) "{{{3
endf
+function! tlib#list#Uniq(list, ...) "{{{3
+ TVarArg ['get_value', '']
+ let s:uniq_values = []
+ if empty(get_value)
+ call filter(a:list, 's:UniqValue(v:val)')
+ else
+ call filter(a:list, 's:UniqValue(eval(printf(get_value, string(v:val))))')
+ endif
+ return a:list
+endf
+
+
+function! s:UniqValue(value) "{{{3
+ if index(s:uniq_values, a:value) == -1
+ call add(s:uniq_values, a:value)
+ return true
+ else
+ return false
+ endif
+endf
+
+
@@ -3,8 +3,8 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-07-18.
-" @Last Change: 2007-10-07.
-" @Revision: 0.0.117
+" @Last Change: 2007-11-01.
+" @Revision: 0.0.119
if &cp || exists("loaded_tlib_scratch_autoload")
finish
@@ -35,6 +35,7 @@ function! tlib#scratch#UseScratch(...) "{{{3
if get(keyargs, 'scratch_vertical')
let wpos .= ' vertical'
endif
+ " TLogVAR wpos
if bn != -1
" TLogVAR bn
let wn = bufwinnr(bn)
Oops, something went wrong. Retry.

0 comments on commit 3579334

Please sign in to comment.