Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Version 0.13

CHANGES:
    - Scratch: Set &fdc=0.
    - The cache directory can be configured via g:tlib_cache
    - Renamed tlib#buffer#SetBuffer() to tlib#buffer#Set().
FIXES:
    - tlib#input#List(): Select the active item per mouse.
    - TLet: simplified
  • Loading branch information...
commit 61ee93333942ed7297053e64b3204bcae4d5e02c 1 parent 0dd2b68
@tomtom tomtom authored committed
View
10 autoload/tlib/World.vim
@@ -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-09-02.
-" @Revision: 0.1.305
+" @Last Change: 2007-09-10.
+" @Revision: 0.1.314
" :filedoc:
" A prototype used by |tlib#input#List|.
@@ -24,8 +24,10 @@ let s:prototype = tlib#Object#New({
\ 'base': [],
\ 'bufnr': -1,
\ 'display_format': '',
+ \ 'filter': [['']],
\ 'filter_format': '',
\ 'index_table': [],
+ \ 'initial_filter': [['']],
\ 'initial_index': 1,
\ 'initialized': 0,
\ 'key_handlers': [],
@@ -256,7 +258,7 @@ endf
function! s:prototype.FilterIsEmpty() dict "{{{3
" TLogVAR self.filter
- return self.filter == [['']]
+ return self.filter == copy(self.initial_filter)
endf
@@ -306,7 +308,7 @@ function! s:prototype.Reset(...) dict "{{{3
" TLogVAR initial
let self.state = 'display'
let self.offset = 1
- let self.filter = [['']]
+ let self.filter = deepcopy(self.initial_filter)
let self.idx = ''
let self.prefidx = 0
call self.UseInputListScratch()
View
8 autoload/tlib/agent.vim
@@ -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-24.
-" @Last Change: 2007-09-02.
-" @Revision: 0.1.122
+" @Last Change: 2007-09-10.
+" @Revision: 0.1.124
if &cp || exists("loaded_tlib_agent_autoload") "{{{2
finish
@@ -151,7 +151,7 @@ function! tlib#agent#Suspend(world, selected) "{{{3
if a:world.allow_suspend
" TAssert IsNotEmpty(a:world.scratch)
" TLogDBG bufnr('%')
- let br = tlib#buffer#SetBuffer(a:world.scratch)
+ let br = tlib#buffer#Set(a:world.scratch)
" TLogVAR br, a:world.bufnr, a:world.scratch
" TLogDBG bufnr('%')
let b:tlib_suspend = ['<m-z>', '<c-z>', '<cr>', '<space>', '<LeftMouse>']
@@ -378,7 +378,7 @@ endf
function! tlib#agent#EditFileInTab(world, selected) "{{{3
call a:world.CloseScratch()
- call tlib#file#With('tabedit', 'tab buffer', a:selected, a:world)
+ call tlib#file#With('tabedit', 'tab sbuffer', a:selected, a:world)
return tlib#agent#Exit(a:world, a:selected)
endf
View
31 autoload/tlib/buffer.vim
@@ -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-02.
-" @Revision: 0.0.58
+" @Last Change: 2007-09-10.
+" @Revision: 0.0.66
if &cp || exists("loaded_tlib_buffer_autoload")
finish
@@ -14,7 +14,7 @@ let loaded_tlib_buffer_autoload = 1
" Set the buffer to buffer and return a command as string that can be
" evaluated by |:execute| in order to restore the original view.
-function! tlib#buffer#SetBuffer(buffer) "{{{3
+function! tlib#buffer#Set(buffer) "{{{3
let lazyredraw = &lazyredraw
set lazyredraw
try
@@ -52,7 +52,7 @@ function! tlib#buffer#Eval(buffer, code) "{{{3
" let sb = sn != cb
let lazyredraw = &lazyredraw
set lazyredraw
- let restore = tlib#buffer#SetBuffer(a:buffer)
+ let restore = tlib#buffer#Set(a:buffer)
try
exec a:code
" if sb
@@ -82,9 +82,9 @@ function! tlib#buffer#Eval(buffer, code) "{{{3
endf
-" :def: function! tlib#buffer#GetList(?show_hidden=0)
+" :def: function! tlib#buffer#GetList(?show_hidden=0, ?show_number=0)
function! tlib#buffer#GetList(...)
- exec tlib#arg#Let(['show_hidden'])
+ TVarArg ['show_hidden', 0], ['show_number', 0]
let ls_bang = show_hidden ? '!' : ''
redir => bfs
exec 'silent ls'. ls_bang
@@ -92,8 +92,11 @@ function! tlib#buffer#GetList(...)
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*$'')')
+ if show_number
+ call map(buffer_list, 'matchstr(v:val, ''\s*\d\+.\{-}\ze\s\+line \d\+\s*$'')')
+ else
+ call map(buffer_list, 'matchstr(v:val, ''\s*\d\+\zs.\{-}\ze\s\+line \d\+\s*$'')')
+ endif
" TLogVAR buffer_list
" call map(buffer_list, 'matchstr(v:val, ''^.\{-}\ze\s\+line \d\+\s*$'')')
" TLogVAR buffer_list
@@ -123,6 +126,11 @@ function! tlib#buffer#ViewLine(line, ...) "{{{3
endf
+function! tlib#buffer#HighlightLine(line) "{{{3
+ exec 'match MatchParen /\V\%'. a:line .'l.*/'
+endf
+
+
" Delete the lines in the current buffer. Wrapper for |:delete|.
function! tlib#buffer#DeleteRange(line1, line2) "{{{3
exec a:line1.','.a:line2.'delete'
@@ -154,3 +162,10 @@ function! tlib#buffer#ScratchEnd() "{{{3
endf
+" Run exec on all buffers via bufdo and return to the original buffer.
+function! tlib#buffer#BufDo(exec) "{{{3
+ let bn = bufnr('%')
+ exec 'bufdo '. a:exec
+ exec 'buffer! '. bn
+endf
+
View
13 autoload/tlib/cache.vim
@@ -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-02.
-" @Revision: 0.1.17
+" @Last Change: 2007-09-09.
+" @Revision: 0.1.20
if &cp || exists("loaded_tlib_cache_autoload")
finish
@@ -15,7 +15,10 @@ let loaded_tlib_cache_autoload = 1
" :def: function! tlib#cache#Filename(type, ?file=%, ?mkdir=0)
function! tlib#cache#Filename(type, ...) "{{{3
" TLogDBG 'bufname='. bufname('.')
- let dir = tlib#dir#MyRuntime()
+ let dir = tlib#var#Get('tlib_cache', 'wbg')
+ if empty(dir)
+ let dir = tlib#file#Join([tlib#dir#MyRuntime(), 'cache'])
+ endif
if a:0 >= 1 && !empty(a:1)
let file = a:1
else
@@ -23,11 +26,11 @@ function! tlib#cache#Filename(type, ...) "{{{3
return ''
endif
let file = expand('%:p')
- let file = tlib#file#Relative(file, dir)
+ let file = tlib#file#Relative(file, tlib#file#Join([dir, '..']))
endif
let mkdir = a:0 >= 2 ? a:2 : 0
let file = substitute(file, '\.\.\|[:&<>]\|//\+\|\\\\\+', '_', 'g')
- let dir = tlib#dir#PlainName(tlib#file#Join([dir, 'cache', a:type, fnamemodify(file, ':h')]))
+ let dir = tlib#dir#PlainName(tlib#file#Join([dir, a:type, fnamemodify(file, ':h')]))
let file = fnamemodify(file, ':t')
" TLogVAR dir
" TLogVAR file
View
4 autoload/tlib/file.vim
@@ -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-02.
-" @Revision: 0.0.39
+" @Last Change: 2007-09-11.
+" @Revision: 0.0.41
if &cp || exists("loaded_tlib_file_autoload")
finish
View
38 autoload/tlib/input.vim
@@ -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-02.
-" @Revision: 0.0.323
+" @Last Change: 2007-09-11.
+" @Revision: 0.0.343
if &cp || exists("loaded_tlib_input_autoload")
finish
@@ -87,6 +87,11 @@ function! tlib#input#List(type, ...) "{{{3
let world.numeric_chars = tlib#list#Find(handlers, 'has_key(v:val, "numeric_chars")',
\ tlib#var#Get('tlib_numeric_chars', 'bg'), 'v:val.numeric_chars')
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], ['']]
+ " TLogVAR world.initial_filter
+ endif
endif
return tlib#input#ListW(world)
endf
@@ -167,6 +172,7 @@ function! tlib#input#ListW(world, ...) "{{{3
let world.prefidx = world.offset
let world.state = 'redisplay'
endif
+ " TLogVAR world.filter
if world.state =~ 'display'
if world.state =~ '^display'
let world.table = filter(range(1, len(world.base)), 'world.MatchBaseIdx(world.filter_format, v:val)')
@@ -267,15 +273,17 @@ function! tlib#input#ListW(world, ...) "{{{3
" continue
elseif has_key(key_agents, c)
let sr = @/
- let @/ = lastsearch
+ silent! let @/ = lastsearch
let world = call(key_agents[c], [world, world.GetSelectedItems(world.GetCurrentItem())])
call s:CheckAgentReturnValue(c, world)
- let @/ = sr
+ silent! let @/ = sr
" continue
elseif c == 13
throw 'pick'
elseif c == "\<LeftMouse>"
- let world.prefidx = matchstr(getline(v:mouse_lnum), '^\d\+\ze:')
+ let line = getline(v:mouse_lnum)
+ " TLogVAR line
+ let world.prefidx = matchstr(line, '^\d\+\ze[*:]')
if empty(world.prefidx)
" call feedkeys(c, 't')
let c = tlib#char#Get(world.timeout)
@@ -374,7 +382,7 @@ function! tlib#input#ListW(world, ...) "{{{3
finally
let &statusline = statusline
let &laststatus = laststatus
- let @/ = lastsearch
+ silent! let @/ = lastsearch
" TLogDBG 'finally 2'
if world.state !~ '\<suspend\>'
" TLogVAR world.state, world.win_wnr, world.bufnr
@@ -467,11 +475,11 @@ function! s:FormatFilename(world, file) "{{{3
let bnr = bufnr(a:file)
" TLogVAR a:file, bnr, a:world.bufnr
if bnr != -1
- if buflisted(a:file)
+ if bnr == a:world.bufnr
+ call add(marker, '%')
+ elseif buflisted(a:file)
if getbufvar(a:file, "&mod")
call add(marker, '+')
- elseif bnr == a:world.bufnr
- call add(marker, '%')
else
call add(marker, 'B')
endif
@@ -555,10 +563,11 @@ endf
" :def: function! tlib#input#Edit(name, value, callback, ?cb_args=[])
"
-" Edit value in a scratch buffer. Use name for identification. Call
-" callback when done (or on cancel).
+" Edit a value (asynchronously) in a scratch buffer. Use name for
+" identification. Call callback when done (or on cancel).
" In the scratch buffer:
-" Press <c-s> to enter, <c-w>c to cancel editing.
+" Press <c-s> or <c-w><cr> to enter the new value, <c-w>c to cancel
+" editing.
" EXAMPLES: >
" fun! FooContinue(success, text)
" if a:success
@@ -575,15 +584,18 @@ function! tlib#input#Edit(name, value, callback, ...) "{{{3
imap <buffer> <c-w>c <c-o>call <SID>EditCallback(0)<cr>
map <buffer> <c-s> :call <SID>EditCallback(1)<cr>
imap <buffer> <c-s> <c-o>call <SID>EditCallback(1)<cr>
+ map <buffer> <c-w><cr> :call <SID>EditCallback(1)<cr>
+ imap <buffer> <c-w><cr> <c-o>call <SID>EditCallback(1)<cr>
norm! ggdG
call append(1, split(a:value, "\<c-j>", 1))
" let hrm = 'DON''T DELETE THIS HEADER'
" let hr3 = repeat('"', (tlib#win#Width(0) - len(hrm)) / 2)
let s:horizontal_line = repeat('`', tlib#win#Width(0))
" hr3.hrm.hr3
- let hd = ['``` Keys: <c-s> ... save/accept; <c-w>c ... cancel', s:horizontal_line]
+ let hd = ['Keys: <c-s>, <c-w><cr> ... save/accept; <c-w>c ... cancel', s:horizontal_line]
call append(1, hd)
norm! ggdd
+ syntax match TlibEditComment /^\%1l.*/
syntax match TlibEditComment /^```.*/
hi link TlibEditComment Comment
exec len(hd) + 1
View
5 autoload/tlib/scratch.vim
@@ -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-08-27.
-" @Revision: 0.0.109
+" @Last Change: 2007-09-08.
+" @Revision: 0.0.110
if &cp || exists("loaded_tlib_scratch_autoload")
finish
@@ -57,6 +57,7 @@ function! tlib#scratch#UseScratch(...) "{{{3
setlocal nobuflisted
setlocal modifiable
setlocal foldmethod=manual
+ setlocal foldcolumn=0
let ft = get(keyargs, 'scratch_filetype', '')
" TLogVAR ft
" if !empty(ft)
View
19 autoload/tlib/var.vim
@@ -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-08-27.
-" @Revision: 0.0.18
+" @Last Change: 2007-09-09.
+" @Revision: 0.0.20
if &cp || exists("loaded_tlib_var_autoload")
finish
@@ -68,3 +68,18 @@ function! tlib#var#Get(var, namespace, ...) "{{{3
endf
+" :def: function! tlib#var#List(rx, ?prefix='')
+" Get a list of variables matching rx.
+" EXAMPLE:
+" echo tlib#var#List('tlib_', 'g:')
+function! tlib#var#List(rx, ...) "{{{3
+ TVarArg ['prefix', '']
+ redir => vars
+ silent! exec 'let '. prefix
+ redir END
+ let varlist = split(vars, '\n')
+ call map(varlist, 'matchstr(v:val, ''^\S\+'')')
+ call filter(varlist, 'v:val =~ a:rx')
+ return varlist
+endf
+
View
26 plugin/02tlib.vim
@@ -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-04-10.
-" @Last Change: 2007-09-05.
-" @Revision: 0.12.338
+" @Last Change: 2007-09-10.
+" @Revision: 0.13.355
" GetLatestVimScripts: 1863 1 tlib.vim
"
" Please see also ../test/tlib.vim for usage examples.
@@ -24,20 +24,20 @@ if v:version < 700 "{{{2
echoerr "tlib requires Vim >= 7"
finish
endif
-let loaded_tlib = 12
+let loaded_tlib = 13
let s:save_cpo = &cpo
set cpo&vim
" Commands {{{1
-" See |tlib#var#Let| for an example.
-" command! -nargs=+ TLLet exec tlib#var#Let(<args>)
-
" :display: :TLet VAR = VALUE
" Set a variable only if it doesn't already exist.
" EXAMPLES: >
" TLet foo = 1
-command! -nargs=+ TLet exec printf('if !exists("%s") | let %s | endif', matchstr(<q-args>, '^[^=[:space:]]\+'), <q-args>)
+" TLet foo = 2
+" echo foo
+" => 1
+command! -nargs=+ TLet if !exists(matchstr(<q-args>, '^[^=[:space:]]\+')) | exec 'let '. <q-args> | endif
" Open a scratch buffer (a buffer without a file). >
@@ -88,6 +88,8 @@ TLet g:tlib_inputlist_higroup = 'IncSearch'
TLet g:tlib_filename_sep = '/'
" TLet g:tlib_filename_sep = exists('+shellslash') && !&shellslash ? '\' : '/' " {{{2
+" The cache directory. If empty, use |tlib#dir#MyRuntime|.'/cache'
+TLet g:tlib_cache = ''
" Where to display the line when using |tlib#buffer#ViewLine|.
" For possible values for position see |scroll-cursor|.
@@ -319,3 +321,13 @@ FIXES:
explicitly given as argument. Avoid double (back)slashes.
- TLet: simplified
+0.13
+CHANGES:
+ - Scratch: Set &fdc=0.
+ - The cache directory can be configured via g:tlib_cache
+ - Renamed tlib#buffer#SetBuffer() to tlib#buffer#Set().
+FIXES:
+ - tlib#input#List(): Select the active item per mouse.
+ - TLet: simplified
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.