Skip to content

Commit

Permalink
Version 0.14
Browse files Browse the repository at this point in the history
NEW:
    - tlib#buffer#InsertText()
CHANGES:
    - tlib#win#[SG]etLayout(): Use a dictionnary, set &cmdheight.
FIXES:
    - tlib#input#List(): Wrong order with pre-defined filters.
  • Loading branch information
tomtom authored and vim-scripts committed Oct 18, 2010
1 parent 61ee933 commit 7b21ba9
Show file tree
Hide file tree
Showing 26 changed files with 511 additions and 295 deletions.
6 changes: 3 additions & 3 deletions autoload/tlib.vim
@@ -1,10 +1,10 @@
" tlib.vim
" @Author: Thomas Link (mailto:micathom AT gmail com?subject=[vim])
" @Author: Thomas Link (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-08-27.
" @Revision: 0.0.3
" @Last Change: 2007-09-11.
" @Revision: 0.0.4

if &cp || exists("loaded_tlib_autoload")
finish
Expand Down
6 changes: 3 additions & 3 deletions autoload/tlib/Object.vim
@@ -1,10 +1,10 @@
" Object.vim -- Prototype objects?
" @Author: Thomas Link (mailto:micathom AT gmail com?subject=[vim])
" @Author: Thomas Link (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-09-02.
" @Revision: 0.1.115
" @Last Change: 2007-09-11.
" @Revision: 0.1.116

" :filedoc:
" Provides a prototype plus some OO-like methods.
Expand Down
6 changes: 3 additions & 3 deletions autoload/tlib/Test.vim
@@ -1,10 +1,10 @@
" Test.vim -- A test class
" @Author: Thomas Link (mailto:micathom AT gmail com?subject=[vim])
" @Author: Thomas Link (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-27.
" @Revision: 0.1.7
" @Last Change: 2007-09-11.
" @Revision: 0.1.8

" :enddoc:

Expand Down
6 changes: 3 additions & 3 deletions autoload/tlib/TestChild.vim
@@ -1,10 +1,10 @@
" TestChild.vim
" @Author: Thomas Link (mailto:micathom AT gmail com?subject=[vim])
" @Author: Thomas Link (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-08-27.
" @Revision: 0.1.11
" @Last Change: 2007-09-11.
" @Revision: 0.1.12

" :enddoc:

Expand Down
6 changes: 3 additions & 3 deletions autoload/tlib/World.vim
@@ -1,10 +1,10 @@
" World.vim -- The World prototype for tlib#input#List()
" @Author: Thomas Link (mailto:micathom AT gmail com?subject=[vim])
" @Author: Thomas Link (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-09-10.
" @Revision: 0.1.314
" @Last Change: 2007-09-11.
" @Revision: 0.1.315

" :filedoc:
" A prototype used by |tlib#input#List|.
Expand Down
25 changes: 22 additions & 3 deletions autoload/tlib/agent.vim
@@ -1,10 +1,10 @@
" agent.vim
" @Author: Thomas Link (mailto:micathom AT gmail com?subject=[vim])
" @Author: Thomas Link (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-09-10.
" @Revision: 0.1.124
" @Last Change: 2007-09-15.
" @Revision: 0.1.136

if &cp || exists("loaded_tlib_agent_autoload") "{{{2
finish
Expand Down Expand Up @@ -434,3 +434,22 @@ function! tlib#agent#GotoLine(world, selected) "{{{3
return a:world
endf


function! tlib#agent#DoAtLine(world, selected) "{{{3
if !empty(a:selected)
let cmd = input('Command: ')
if !empty(cmd)
call a:world.SwitchWindow('win')
let pos = getpos('.')
for l in a:selected
call tlib#buffer#ViewLine(l, '')
exec cmd
endfor
call setpos('.', pos)
endif
endif
call a:world.ResetSelected()
let a:world.state = 'exit'
return a:world
endf

18 changes: 15 additions & 3 deletions autoload/tlib/arg.vim
@@ -1,10 +1,10 @@
" arg.vim
" @Author: Thomas Link (mailto:micathom AT gmail com?subject=[vim])
" @Author: Thomas Link (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-27.
" @Revision: 0.0.19
" @Last Change: 2007-09-14.
" @Revision: 0.0.32

if &cp || exists("loaded_tlib_arg_autoload")
finish
Expand Down Expand Up @@ -38,6 +38,18 @@ function! tlib#arg#Let(list, ...) "{{{3
endf


" :def: function! tlib#arg#Key(dict, list, ?default='')
" See |:TKeyArg|.
function! tlib#arg#Key(list, ...) "{{{3
let default = a:0 >= 1 ? a:1 : ''
let dict = a:list[0]
let list = map(copy(a:list[1:-1]), 'type(v:val) == 3 ? v:val : [v:val, default]')
let args = map(list, '"let ". v:val[0] ." = ". string(get(dict, v:val[0], v:val[1]))')
" TLogVAR dict, list, args
return join(args, ' | ')
endf



""" Command line {{{1

Expand Down
78 changes: 74 additions & 4 deletions autoload/tlib/buffer.vim
@@ -1,10 +1,10 @@
" buffer.vim
" @Author: Thomas Link (mailto:micathom AT gmail com?subject=[vim])
" @Author: Thomas Link (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-09-10.
" @Revision: 0.0.66
" @Last Change: 2007-09-19.
" @Revision: 0.0.155

if &cp || exists("loaded_tlib_buffer_autoload")
finish
Expand Down Expand Up @@ -107,11 +107,12 @@ endf


" :def: function! tlib#buffer#ViewLine(line, ?position='z')
" line is either a number or a string that begins with a number.
" For possible values for position see |scroll-cursor|.
" See also |g:tlib_viewline_position|.
function! tlib#buffer#ViewLine(line, ...) "{{{3
if a:line
exec tlib#arg#Let(['pos'])
TVarArg 'pos'
let ln = matchstr(a:line, '^\d\+')
let lt = matchstr(a:line, '^\d\+: \zs.*')
exec ln
Expand Down Expand Up @@ -169,3 +170,72 @@ function! tlib#buffer#BufDo(exec) "{{{3
exec 'buffer! '. bn
endf


" :def: function! tlib#buffer#InsertText(text, keyargs)
" Keyargs:
" 'shift': 0|N
" 'col': col('.')|N
" 'lineno': line('.')|N
" 'indent': 0|1
" 'pos': 'e'|'s' ... Where to locate the cursor (somewhat like s and e in {offset})
" Insert text (a string) in the buffer.
function! tlib#buffer#InsertText(text, ...) "{{{3
TVarArg ['keyargs', {}]
TKeyArg keyargs, ['shift', 0], ['col', col('.')], ['lineno', line('.')], ['pos', 'e'],
\ ['indent', 0]
" TLogVAR shift, col, lineno, pos, indent
let line = getline(lineno)
if col + shift > 0
let pre = line[0 : (col - 1 + shift)]
let post = line[(col + shift): -1]
else
let pre = ''
let post = line
endif
" TLogVAR lineno, line, pre, post
let text = split(pre . a:text . post, '\n', 1)
" TLogVAR text
let icol = len(pre)
if indent && col > 1
let idt = repeat(' ', icol)
for i in range(1, len(text) - 1)
let text[i] = idt . text[i]
endfor
" TLogVAR text
endif
exec 'norm! '. lineno .'Gdd'
call append(lineno - 1, text)
let tlen = len(text)
let posshift = matchstr(pos, '\d\+')
if pos =~ '^e'
exec lineno + tlen - 1
exec 'norm! 0'. (len(text[-1]) - len(post) + posshift - 1) .'l'
elseif pos =~ '^s'
exec lineno
exec 'norm! '. len(pre) .'|'
if !empty(posshift)
exec 'norm! '. posshift .'h'
endif
endif
" TLogDBG string(getline(1, '$'))
endf


function! tlib#buffer#InsertText0(text, ...) "{{{3
TVarArg ['keyargs', {}]
let mode = get(keyargs, 'mode', 'i')
" TLogVAR mode
if !has_key(keyargs, 'shift')
let col = col('.')
" if mode =~ 'i'
" let col += 1
" endif
let keyargs.shift = col >= col('$') ? 0 : -1
" let keyargs.shift = col('.') >= col('$') ? 0 : -1
" TLogVAR col
" TLogDBG col('.') .'-'. col('$') .': '. string(getline('.'))
endif
" TLogVAR keyargs.shift
return tlib#buffer#InsertText(a:text, keyargs)
endf

6 changes: 3 additions & 3 deletions autoload/tlib/cache.vim
@@ -1,10 +1,10 @@
" cache.vim
" @Author: Thomas Link (mailto:micathom AT gmail com?subject=[vim])
" @Author: Thomas Link (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-09-09.
" @Revision: 0.1.20
" @Last Change: 2007-09-19.
" @Revision: 0.1.23

if &cp || exists("loaded_tlib_cache_autoload")
finish
Expand Down
6 changes: 3 additions & 3 deletions autoload/tlib/char.vim
@@ -1,10 +1,10 @@
" char.vim
" @Author: Thomas Link (mailto:micathom AT gmail com?subject=[vim])
" @Author: Thomas Link (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-27.
" @Revision: 0.0.11
" @Last Change: 2007-09-11.
" @Revision: 0.0.12

if &cp || exists("loaded_tlib_char_autoload")
finish
Expand Down
6 changes: 3 additions & 3 deletions autoload/tlib/cmd.vim
@@ -1,10 +1,10 @@
" cmd.vim
" @Author: Thomas Link (mailto:micathom AT gmail com?subject=[vim])
" @Author: Thomas Link (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-08-23.
" @Last Change: 2007-08-29.
" @Revision: 0.0.10
" @Last Change: 2007-09-11.
" @Revision: 0.0.11

if &cp || exists("loaded_tlib_cmd_autoload")
finish
Expand Down
6 changes: 3 additions & 3 deletions autoload/tlib/dir.vim
@@ -1,10 +1,10 @@
" dir.vim
" @Author: Thomas Link (mailto:micathom AT gmail com?subject=[vim])
" @Author: Thomas Link (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-09-02.
" @Revision: 0.0.21
" @Last Change: 2007-09-11.
" @Revision: 0.0.22

if &cp || exists("loaded_tlib_dir_autoload")
finish
Expand Down
55 changes: 55 additions & 0 deletions autoload/tlib/eval.vim
@@ -0,0 +1,55 @@
" eval.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-09-16.
" @Last Change: 2007-09-16.
" @Revision: 0.0.33

if &cp || exists("loaded_tlib_eval_autoload")
finish
endif
let loaded_tlib_eval_autoload = 1


function! tlib#eval#FormatValue(value, ...) "{{{3
TVarArg ['indent', 0]
" TLogVAR a:value, indent
let indent1 = indent + 1
let indenti = repeat(' ', &sw)
let type = type(a:value)
let acc = []
if type == 0 || type == 1 || type == 2
" TLogDBG 'Use string() for type='. type
call add(acc, string(a:value))
elseif type == 3 "List
" TLogDBG 'List'
call add(acc, '[')
for e in a:value
call add(acc, printf('%s%s,', indenti, tlib#eval#FormatValue(e, indent1)))
unlet e
endfor
call add(acc, ']')
elseif type == 4 "Dictionary
" TLogDBG 'Dictionary'
call add(acc, '{')
let indent1 = indent + 1
for [k, v] in items(a:value)
call add(acc, printf("%s%s: %s,", indenti, string(k), tlib#eval#FormatValue(v, indent1)))
unlet k v
endfor
call add(acc, '}')
else
" TLogDBG 'Unknown type: '. string(a:value)
call add(acc, string(a:value))
endif
if indent > 0
let is = repeat(' ', indent * &sw)
for i in range(1,len(acc) - 1)
let acc[i] = is . acc[i]
endfor
endif
return join(acc, "\n")
endf


8 changes: 4 additions & 4 deletions autoload/tlib/file.vim
@@ -1,10 +1,10 @@
" file.vim
" @Author: Thomas Link (mailto:micathom AT gmail com?subject=[vim])
" @Author: Thomas Link (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-09-11.
" @Revision: 0.0.41
" @Last Change: 2007-09-14.
" @Revision: 0.0.43

if &cp || exists("loaded_tlib_file_autoload")
finish
Expand Down Expand Up @@ -91,7 +91,7 @@ endf
function! tlib#file#With(fcmd, bcmd, files, ...) "{{{3
exec tlib#arg#Let([['world', {}]])
for f in a:files
let bn = bufnr(f)
let bn = bufnr('^'.f.'$')
if bn != -1 && buflisted(bn)
if !empty(a:bcmd)
" TLogDBG a:bcmd .' '. bn
Expand Down
6 changes: 3 additions & 3 deletions autoload/tlib/hook.vim
@@ -1,10 +1,10 @@
" hook.vim
" @Author: Thomas Link (mailto:micathom AT gmail com?subject=[vim])
" @Author: Thomas Link (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-08-21.
" @Last Change: 2007-08-27.
" @Revision: 0.0.7
" @Last Change: 2007-09-11.
" @Revision: 0.0.8

if &cp || exists("loaded_tlib_hook_autoload")
finish
Expand Down

0 comments on commit 7b21ba9

Please sign in to comment.