Permalink
Browse files

Version 0.12

NEW:
    - tlib/tab.vim
CHANGES:
    - Renamed tlib#win#SetWin() to tlib#win#Set()
IMPROVEMENTS:
    - tlib#input#List(): <left>, <right> keys work in some lists
    - tlib#input#List(): If an index_table is provided this will be used
    instead of the item's list index.
FIXES:
    - tlib#input#List(): Problem with scrolling, when the list was
    shorter than the window (eg when using a vertical window).
    - tlib#cache#Filename(): Don't rewrite name as relative filename if
    explicitly given as argument. Avoid double (back)slashes.
    - TLet: simplified
  • Loading branch information...
tomtom authored and vim-scripts committed Sep 8, 2007
1 parent 0df04c8 commit 0dd2b686864e705ce89d0d5c8a2c57a833882501
View
@@ -1,10 +1,10 @@
" tlib.vim
-" @Author: Thomas Link (mailto:samul AT web de?subject=[vim])
+" @Author: Thomas 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: 2007-07-17.
-" @Last Change: 2007-07-17.
-" @Revision: 0.0.2
+" @Last Change: 2007-08-27.
+" @Revision: 0.0.3
if &cp || exists("loaded_tlib_autoload")
finish
View
@@ -1,10 +1,10 @@
" Object.vim -- Prototype objects?
-" @Author: Thomas Link (mailto:samul AT web de?subject=[vim])
+" @Author: Thomas Link (mailto:micathom AT gmail com?subject=[vim])
" @Website: http://members.a1.net/t.link/
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-05-01.
-" @Last Change: 2007-08-18.
-" @Revision: 0.1.110
+" @Last Change: 2007-09-02.
+" @Revision: 0.1.115
" :filedoc:
" Provides a prototype plus some OO-like methods.
@@ -145,3 +145,15 @@ function! s:prototype.Super(method, arglist) dict "{{{3
echoerr 'tlib#Object: Does not respond to '. a:method .': '. string(self)
endf
+
+function! s:prototype.Methods() dict "{{{3
+ let o = items(self)
+ call filter(o, 'type(v:val[1]) == 2 && string(v:val[1]) =~ "^function(''\\d\\+'')"')
+ let acc = {}
+ for e in o
+ let id = matchstr(string(e[1]), '\d\+')
+ let acc[id] = e[0]
+ endfor
+ return acc
+endf
+
View
@@ -1,10 +1,10 @@
" Test.vim -- A test class
-" @Author: Thomas Link (mailto:samul AT web de?subject=[vim])
+" @Author: Thomas Link (mailto:micathom AT gmail com?subject=[vim])
" @Website: http://members.a1.net/t.link/
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-05-01.
-" @Last Change: 2007-07-28.
-" @Revision: 0.1.6
+" @Last Change: 2007-08-27.
+" @Revision: 0.1.7
" :enddoc:
@@ -1,10 +1,10 @@
" TestChild.vim
-" @Author: Thomas Link (mailto:samul AT web de?subject=[vim])
+" @Author: Thomas Link (mailto:micathom AT gmail com?subject=[vim])
" @Website: http://members.a1.net/t.link/
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-05-18.
-" @Last Change: 2007-07-28.
-" @Revision: 0.1.10
+" @Last Change: 2007-08-27.
+" @Revision: 0.1.11
" :enddoc:
View
@@ -1,10 +1,10 @@
" World.vim -- The World prototype for tlib#input#List()
-" @Author: Thomas Link (mailto:samul AT web de?subject=[vim])
+" @Author: Thomas Link (mailto:micathom AT gmail com?subject=[vim])
" @Website: http://members.a1.net/t.link/
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-05-01.
-" @Last Change: 2007-08-26.
-" @Revision: 0.1.259
+" @Last Change: 2007-09-02.
+" @Revision: 0.1.305
" :filedoc:
" A prototype used by |tlib#input#List|.
@@ -25,11 +25,14 @@ let s:prototype = tlib#Object#New({
\ 'bufnr': -1,
\ 'display_format': '',
\ 'filter_format': '',
+ \ 'index_table': [],
\ 'initial_index': 1,
\ 'initialized': 0,
\ 'key_handlers': [],
\ 'list': [],
\ 'numeric_chars': tlib#var#Get('tlib_numeric_chars', 'bg'),
+ \ 'offset': 1,
+ \ 'offset_horizontal': 0,
\ 'pick_last_item': tlib#var#Get('tlib_pick_last_item', 'bg'),
\ 'post_handlers': [],
\ 'query': '',
@@ -61,8 +64,8 @@ function! s:prototype.Set_display_format(value) dict "{{{3
if a:value == 'filename'
let self.display_format = 's:FormatFilename(world, %s)'
let self.tlib_UseInputListScratch =
- \ 'syn match TLibMarker /\%>'. (2 + g:tlib_inputlist_width_filename) .'c |.\{-}| / | hi def link TLibMarker Special'
- let self.tlib_UseInputListScratch .= '| syn match TLibDir /\%>'. (4 + g:tlib_inputlist_width_filename) .'c\S\{-}[\/].*$/ | hi def link TLibDir Directory'
+ \ 'syn match TLibMarker /\%>'. (2 + eval(g:tlib_inputlist_width_filename)) .'c |.\{-}| / | hi def link TLibMarker Special'
+ let self.tlib_UseInputListScratch .= '| syn match TLibDir /\%>'. (4 + eval(g:tlib_inputlist_width_filename)) .'c\S\{-}[\/].*$/ | hi def link TLibDir Directory'
else
let self.display_format = a:value
endif
@@ -82,6 +85,13 @@ function! s:prototype.GetSelectedItems(current) dict "{{{3
endif
call insert(rv, a:current)
endif
+ if stridx(self.type, 'i') != -1
+ if !empty(self.index_table)
+ " TLogVAR rv, self.index_table
+ call map(rv, 'self.index_table[v:val - 1]')
+ " TLogVAR rv
+ endif
+ endif
return rv
endf
@@ -143,12 +153,21 @@ endf
function! s:prototype.GetListIdx(baseidx) dict "{{{3
- return index(self.table, a:baseidx)
+ " if empty(self.index_table)
+ let baseidx = a:baseidx
+ " else
+ " let baseidx = 0 + self.index_table[a:baseidx - 1]
+ " " TLogVAR a:baseidx, baseidx, self.index_table
+ " endif
+ let rv = index(self.table, baseidx)
+ " TLogVAR rv, self.table
+ return rv
endf
function! s:prototype.GetBaseIdx(idx) dict "{{{3
- if !empty(self.table) && a:idx > 0
+ " TLogVAR a:idx, self.table, self.index_table
+ if !empty(self.table) && a:idx > 0 && a:idx <= len(self.table)
return self.table[a:idx - 1]
else
return ''
@@ -398,8 +417,10 @@ function! s:prototype.DisplayList(world, query, ...) dict "{{{3
elseif self.state == 'help'
call self.DisplayHelp(a:world)
else
- let ll = len(list)
- let x = len(ll) + 1
+ " let ll = len(list)
+ let ll = a:world.llen
+ " let x = len(ll) + 1
+ let x = a:world.index_width + 1
" TLogVAR ll
if self.state =~ '\<display\>'
let resize = get(self, 'resize', 0)
@@ -411,7 +432,8 @@ function! s:prototype.DisplayList(world, query, ...) dict "{{{3
norm! ggdG
let w = winwidth(0) - &fdc
" let w = winwidth(0) - &fdc - 1
- let lines = map(copy(list), 'printf("%-'. w .'.'. w .'s", substitute(v:val, ''[[:cntrl:][:space:]]'', " ", "g"))')
+ let lines = copy(list)
+ let lines = map(lines, 'printf("%-'. w .'.'. w .'s", substitute(v:val, ''[[:cntrl:][:space:]]'', " ", "g"))')
call append(0, lines)
norm! Gddgg
endif
@@ -462,6 +484,9 @@ function! s:prototype.SetOffset() dict "{{{3
" TLogDBG winheight(0)
" TLogDBG self.prefidx > self.offset + winheight(0) - 1
let listtop = len(self.list) - winheight(0) + 1
+ if listtop < 1
+ let listtop = 1
+ endif
if self.prefidx > listtop
let self.offset = listtop
elseif self.prefidx > self.offset + winheight(0) - 1
@@ -474,6 +499,7 @@ function! s:prototype.SetOffset() dict "{{{3
elseif self.prefidx < self.offset
let self.offset = self.prefidx
endif
+ " TLogVAR self.offset
endf
@@ -496,7 +522,7 @@ endf
function! s:prototype.SwitchWindow(where) dict "{{{3
let wnr = get(self, a:where.'_wnr')
" TLogVAR wnr
- return tlib#win#SetWin(wnr)
+ return tlib#win#Set(wnr)
endf
View
@@ -1,10 +1,10 @@
" agent.vim
-" @Author: Thomas Link (mailto:samul AT web de?subject=[vim])
+" @Author: Thomas 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: 2007-06-24.
-" @Last Change: 2007-08-26.
-" @Revision: 0.1.114
+" @Last Change: 2007-09-02.
+" @Revision: 0.1.122
if &cp || exists("loaded_tlib_agent_autoload") "{{{2
finish
@@ -86,6 +86,23 @@ function! tlib#agent#DownN(world, selected) "{{{3
endf
+function! tlib#agent#ShiftLeft(world, selected) "{{{3
+ let a:world.offset_horizontal -= (winwidth(0) / 2)
+ if a:world.offset_horizontal < 0
+ let a:world.offset_horizontal = 0
+ endif
+ let a:world.state = 'display shift'
+ return a:world
+endf
+
+
+function! tlib#agent#ShiftRight(world, selected) "{{{3
+ let a:world.offset_horizontal += (winwidth(0) / 2)
+ let a:world.state = 'display shift'
+ return a:world
+endf
+
+
function! tlib#agent#Reset(world, selected) "{{{3
let a:world.state = 'reset'
return a:world
@@ -328,12 +345,9 @@ endf
" Files related {{{1
function! tlib#agent#ViewFile(world, selected) "{{{3
- if a:world.SwitchWindow('win')
- call tlib#file#With('edit', 'buffer', a:selected, a:world)
- if !a:world.SwitchWindow('list')
- throw 'tlib: Cannot switch back to list window: '. string(a:world)
- end
- endif
+ let back = a:world.SwitchWindow('win')
+ call tlib#file#With('edit', 'buffer', a:selected, a:world)
+ exec back
let a:world.state = 'display'
return a:world
endf
View
@@ -1,10 +1,10 @@
" arg.vim
-" @Author: Thomas Link (mailto:samul AT web de?subject=[vim])
+" @Author: Thomas 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: 2007-06-30.
-" @Last Change: 2007-08-21.
-" @Revision: 0.0.18
+" @Last Change: 2007-08-27.
+" @Revision: 0.0.19
if &cp || exists("loaded_tlib_arg_autoload")
finish
View
@@ -1,10 +1,10 @@
" buffer.vim
-" @Author: Thomas Link (mailto:samul AT web de?subject=[vim])
+" @Author: Thomas 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: 2007-06-30.
-" @Last Change: 2007-08-24.
-" @Revision: 0.0.47
+" @Last Change: 2007-09-02.
+" @Revision: 0.0.58
if &cp || exists("loaded_tlib_buffer_autoload")
finish
@@ -91,8 +91,14 @@ function! tlib#buffer#GetList(...)
redir END
let buffer_list = split(bfs, '\n')
let buffer_nr = map(copy(buffer_list), 'matchstr(v:val, ''\s*\zs\d\+\ze'')')
+ " TLogVAR buffer_list
call map(buffer_list, 'matchstr(v:val, ''\s*\d\+\zs.\{-}\ze\s\+line \d\+\s*$'')')
+ " call map(buffer_list, 'matchstr(v:val, ''\s*\d\+.\{-}\ze\s\+line \d\+\s*$'')')
+ " TLogVAR buffer_list
+ " call map(buffer_list, 'matchstr(v:val, ''^.\{-}\ze\s\+line \d\+\s*$'')')
+ " TLogVAR buffer_list
call map(buffer_list, 'matchstr(v:val, ''^[^"]\+''). printf("%-20s %s", fnamemodify(matchstr(v:val, ''"\zs.\{-}\ze"$''), ":t"), fnamemodify(matchstr(v:val, ''"\zs.\{-}\ze"$''), ":h"))')
+ " TLogVAR buffer_list
return [buffer_nr, buffer_list]
endf
View
@@ -1,10 +1,10 @@
" cache.vim
-" @Author: Thomas Link (mailto:samul AT web de?subject=[vim])
+" @Author: Thomas 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: 2007-06-30.
-" @Last Change: 2007-07-27.
-" @Revision: 0.1.9
+" @Last Change: 2007-09-02.
+" @Revision: 0.1.17
if &cp || exists("loaded_tlib_cache_autoload")
finish
@@ -15,22 +15,28 @@ let loaded_tlib_cache_autoload = 1
" :def: function! tlib#cache#Filename(type, ?file=%, ?mkdir=0)
function! tlib#cache#Filename(type, ...) "{{{3
" TLogDBG 'bufname='. bufname('.')
- if empty(expand('%:t'))
- return ''
+ let dir = tlib#dir#MyRuntime()
+ if a:0 >= 1 && !empty(a:1)
+ let file = a:1
+ else
+ if empty(expand('%:t'))
+ return ''
+ endif
+ let file = expand('%:p')
+ let file = tlib#file#Relative(file, dir)
endif
- let file = a:0 >= 1 && !empty(a:1) ? a:1 : expand('%:p')
let mkdir = a:0 >= 2 ? a:2 : 0
- let dir = tlib#dir#MyRuntime()
- let file = tlib#file#Relative(file, dir)
let file = substitute(file, '\.\.\|[:&<>]\|//\+\|\\\\\+', '_', 'g')
- let dir = tlib#file#Join([dir, 'cache', a:type, fnamemodify(file, ':h')])
+ let dir = tlib#dir#PlainName(tlib#file#Join([dir, 'cache', a:type, fnamemodify(file, ':h')]))
let file = fnamemodify(file, ':t')
" TLogVAR dir
" TLogVAR file
if mkdir && !isdirectory(dir)
call mkdir(dir, 'p')
endif
- retur tlib#file#Join([dir, file])
+ let cache_file = tlib#file#Join([dir, file])
+ " TLogVAR cache_file
+ return cache_file
endf
View
@@ -1,10 +1,10 @@
" char.vim
-" @Author: Thomas Link (mailto:samul AT web de?subject=[vim])
+" @Author: Thomas 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: 2007-06-30.
-" @Last Change: 2007-07-29.
-" @Revision: 0.0.10
+" @Last Change: 2007-08-27.
+" @Revision: 0.0.11
if &cp || exists("loaded_tlib_char_autoload")
finish
Oops, something went wrong.

0 comments on commit 0dd2b68

Please sign in to comment.