Browse files

Version 1.01

- Set g:tlib_inputlist_and to  ' ' again- g:tlib#input#filename_max_width: maximum display width of filenames- tlib#input#List: <s-esc>, <f10>: run command by nameMD5 checksum: a42f90275cdbe9f7d92cac61b884a2d1
  • Loading branch information...
1 parent b0470c1 commit b5c3723735c2e0cb852db4f841f883de5bc63e98 @tomtom tomtom committed with Oct 3, 2012
Showing with 128 additions and 17 deletions.
  1. +2 −2 autoload/tlib/Filter_cnf.vim
  2. +42 −0 autoload/tlib/Filter_cnfx.vim
  3. +14 −6 autoload/tlib/World.vim
  4. +42 −2 autoload/tlib/agent.vim
  5. +7 −2 autoload/tlib/input.vim
  6. +15 −1 doc/tlib.txt
  7. +6 −4 plugin/02tlib.vim
View
4 autoload/tlib/Filter_cnf.vim
@@ -4,7 +4,7 @@
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2008-11-25.
" @Last Change: 2012-09-26.
-" @Revision: 0.0.88
+" @Revision: 0.0.90
let s:prototype = tlib#Object#New({'_class': ['Filter_cnf'], 'name': 'cnf'}) "{{{2
let s:prototype.highlight = g:tlib_inputlist_higroup
@@ -33,7 +33,7 @@ endf
" :nodoc:
function! s:prototype.Help(world) dict "{{{3
call a:world.PushHelp(
- \ printf('%s, %s, %sWORD', g:tlib_inputlist_and, g:tlib_inputlist_or, g:tlib_inputlist_not),
+ \ printf('"%s", "%s", "%sWORD"', g:tlib_inputlist_and, g:tlib_inputlist_or, g:tlib_inputlist_not),
\ 'AND, OR, NOT')
endf
View
42 autoload/tlib/Filter_cnfx.vim
@@ -0,0 +1,42 @@
+" @Author: Tom 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: 2008-11-25.
+" @Last Change: 2012-09-20.
+" @Revision: 0.0.61
+
+let s:prototype = tlib#Filter_cnfd#New({'_class': ['Filter_cnfx'], 'name': 'cnfx'}) "{{{2
+let s:prototype.highlight = g:tlib_inputlist_higroup
+
+
+" A character that should be expanded to '\.\{-}'.
+TLet g:tlib#Filter_cnfx#expander = '+'
+
+
+" The same as |tlib#Filter_cnfd#New()| but a a customizable character
+" |see tlib#Filter_cnfx#expander| is expanded to '\.\{-}'.
+" The pattern is a '/\V' very no-'/magic' regexp pattern.
+function! tlib#Filter_cnfx#New(...) "{{{3
+ let object = s:prototype.New(a:0 >= 1 ? a:1 : {})
+ return object
+endf
+
+
+" :nodoc:
+function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3
+ let pattern = substitute(a:pattern, tlib#rx#Escape(g:tlib#Filter_cnfx#expander, 'V'), '\\.\\{-}', 'g')
+ let a:world.filter[0] = reverse(split(pattern, '\s*|\s*')) + a:world.filter[0][1 : -1]
+endf
+
+
+" :nodoc:
+function! s:prototype.PushFrontFilter(world, char) dict "{{{3
+ let a:world.filter[0][0] .= a:char == char2nr(g:tlib#Filter_cnfx#expander) ? '\.\{-}' : nr2char(a:char)
+endf
+
+
+" :nodoc:
+function! s:prototype.CleanFilter(filter) dict "{{{3
+ return substitute(a:filter, '\\.\\{-}', g:tlib#Filter_cnfx#expander, 'g')
+endf
+
View
20 autoload/tlib/World.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-05-01.
-" @Last Change: 2012-09-25.
-" @Revision: 0.1.1192
+" @Last Change: 2012-10-03.
+" @Revision: 0.1.1202
" :filedoc:
" A prototype used by |tlib#input#List|.
@@ -132,11 +132,15 @@ else
function! s:prototype.Highlight_filename() dict "{{{3
" let self.width_filename = 1 + eval(g:tlib_inputlist_width_filename)
" TLogVAR self.base
- let self.width_filename = max(map(copy(self.base), 'len(fnamemodify(v:val, ":t"))'))
+ let self.width_filename = min([
+ \ get(self, 'width_filename', &co),
+ \ empty(g:tlib#input#filename_max_width) ? &co : eval(g:tlib#input#filename_max_width),
+ \ max(map(copy(self.base), 'len(fnamemodify(v:val, ":t"))'))
+ \ ])
" TLogVAR self.width_filename
- syntax match TLibDir /\(\a:\|\.\.\..\{-}\)\?[\/][^&<>*|]\{-}\ze[^\/]\+$/ contained containedin=TLibMarker
- syntax match TLibFilename /[^\/]\+$/ contained containedin=TLibMarker
- exec 'syntax match TLibMarker /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \S.*$/ contains=TLibDir,TLibFilename'
+ exec 'syntax match TLibFilename /[^\/]\+$/ contained containedin=TLibDir'
+ exec 'syntax match TLibDir /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \zs\(\(\a:\|\.\.\..\{-}\)\?[\/][^&<>*|]\{-}\)\?[^\/]\+$/ contained containedin=TLibMarker contains=TLibFilename'
+ exec 'syntax match TLibMarker /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \S.*$/ contains=TLibDir'
hi def link TLibMarker Special
hi def link TLibDir Directory
hi def link TLibFilename NonText
@@ -160,6 +164,9 @@ else
" let dname = strpart(a:file, 0, split - 1)
let dname = a:file
endif
+ if strwidth(fname) > width
+ let fname = strpart(fname, 0, width - 3) .'...'
+ endif
let dnmax = &co - max([width, len(fname)]) - 10 - self.index_width - &fdc
if g:tlib_inputlist_filename_indicators
let dnmax -= 2
@@ -841,6 +848,7 @@ function! s:prototype.DisplayHelp() dict "{{{3
call self.PushHelp('<M-Number>', 'Pick an item')
call self.PushHelp('Mouse', 'L: Pick item, R: Show menu')
call self.PushHelp('<BS>, <C-BS>', 'Reduce filter')
+ call self.PushHelp('<S-Esc>, <F10>', 'Enter command')
if self.key_mode == 'default'
call self.PushHelp('<C|M-r>', 'Reset the display')
View
44 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: 2012-09-19.
-" @Revision: 0.1.194
+" @Last Change: 2012-10-03.
+" @Revision: 0.1.208
" :filedoc:
@@ -521,3 +521,43 @@ function! tlib#agent#Null(world, selected) "{{{3
return a:world
endf
+
+function! tlib#agent#ExecAgentByName(world, selected) "{{{3
+ let s:agent_names_world = a:world
+ let agent_names = {}
+ for def in values(a:world.key_map[a:world.key_mode])
+ if has_key(def, 'help') && !empty(def.help) && has_key(def, 'agent') && !empty(def.agent)
+ let agent_names[def.help] = def.agent
+ endif
+ endfor
+ let s:agent_names = join(sort(keys(agent_names)), "\n")
+ let command = input('Command: ', '', 'custom,tlib#agent#CompleteAgentNames')
+ " TLogVAR command
+ if !has_key(agent_names, command)
+ " TLogVAR command
+ silent! let matches = filter(keys(agent_names), 'v:val =~ command')
+ " TLogVAR matches
+ if len(matches) == 1
+ let command = matches[0]
+ endif
+ endif
+ if has_key(agent_names, command)
+ let agent = agent_names[command]
+ return call(agent, [a:world, a:selected])
+ else
+ if !empty(command)
+ echohl WarningMsg
+ echom "Unknown command:" command
+ echohl NONE
+ sleep 1
+ endif
+ let a:world.state = 'display'
+ return a:world
+ endif
+endf
+
+
+function! tlib#agent#CompleteAgentNames(ArgLead, CmdLine, CursorPos)
+ return s:agent_names
+endf
+
View
9 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: 2012-09-23.
-" @Revision: 0.0.960
+" @Last Change: 2012-10-01.
+" @Revision: 0.0.966
" :filedoc:
@@ -28,6 +28,11 @@ TLet g:tlib#input#format_filename = 'l'
TLet g:tlib#input#filename_padding_r = '&co / 10'
+" If g:tlib#input#format_filename == 'l', an expression that
+" |eval()|uates to the maximum display width of filenames.
+TLet g:tlib#input#filename_max_width = '&co / 2'
+
+
" Functions related to tlib#input#List(type, ...) "{{{2
" :def: function! tlib#input#List(type. ?query='', ?list=[], ?handlers=[], ?default="", ?timeout=0)
View
16 doc/tlib.txt
@@ -180,6 +180,8 @@ Contents~
tlib#agent#DoAtLine ..................... |tlib#agent#DoAtLine()|
tlib#agent#Wildcard ..................... |tlib#agent#Wildcard()|
tlib#agent#Null ......................... |tlib#agent#Null()|
+ tlib#agent#ExecAgentByName .............. |tlib#agent#ExecAgentByName()|
+ tlib#agent#CompleteAgentNames ........... |tlib#agent#CompleteAgentNames()|
g:tlib#Filter_cnfx#expander ............. |g:tlib#Filter_cnfx#expander|
tlib#Filter_cnfx#New .................... |tlib#Filter_cnfx#New()|
tlib#url#Decode ......................... |tlib#url#Decode()|
@@ -200,6 +202,7 @@ Contents~
g:tlib#input#use_popup .................. |g:tlib#input#use_popup|
g:tlib#input#format_filename ............ |g:tlib#input#format_filename|
g:tlib#input#filename_padding_r ......... |g:tlib#input#filename_padding_r|
+ g:tlib#input#filename_max_width ......... |g:tlib#input#filename_max_width|
tlib#input#List ......................... |tlib#input#List()|
tlib#input#ListD ........................ |tlib#input#ListD()|
tlib#input#ListW ........................ |tlib#input#ListW()|
@@ -462,7 +465,7 @@ g:tlib_viewline_position (default: 'zz')
Keys for |tlib#input#List|~
*g:tlib_inputlist_and*
-g:tlib_inputlist_and (default: '" "')
+g:tlib_inputlist_and (default: ' ')
*g:tlib_inputlist_or*
g:tlib_inputlist_or (default: '|')
@@ -1119,6 +1122,12 @@ tlib#agent#Wildcard(world, selected)
*tlib#agent#Null()*
tlib#agent#Null(world, selected)
+ *tlib#agent#ExecAgentByName()*
+tlib#agent#ExecAgentByName(world, selected)
+
+ *tlib#agent#CompleteAgentNames()*
+tlib#agent#CompleteAgentNames(ArgLead, CmdLine, CursorPos)
+
========================================================================
autoload/tlib/Filter_cnfx.vim~
@@ -1273,6 +1282,11 @@ g:tlib#input#filename_padding_r (default: '&co / 10')
If g:tlib#input#format_filename == 'r', how much space should be kept
free on the right side.
+ *g:tlib#input#filename_max_width*
+g:tlib#input#filename_max_width (default: '&co / 2')
+ If g:tlib#input#format_filename == 'l', an expression that
+ |eval()|uates to the maximum display width of filenames.
+
*tlib#input#List()*
tlib#input#List(type. ?query='', ?list=[], ?handlers=[], ?default="", ?timeout=0)
Select a single or multiple items from a list. Return either the list
View
10 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: 2012-09-26.
-" @Revision: 686
+" @Last Change: 2012-10-03.
+" @Revision: 691
" GetLatestVimScripts: 1863 1 tlib.vim
if &cp || exists("loaded_tlib")
@@ -14,7 +14,7 @@ if v:version < 700 "{{{2
echoerr "tlib requires Vim >= 7"
finish
endif
-let loaded_tlib = 100
+let loaded_tlib = 101
let s:save_cpo = &cpo
set cpo&vim
@@ -207,7 +207,7 @@ TLet g:tlib_viewline_position = 'zz'
" :doc:
" Keys for |tlib#input#List|~
-TLet g:tlib_inputlist_and = '" "'
+TLet g:tlib_inputlist_and = ' '
TLet g:tlib_inputlist_or = '|'
TLet g:tlib_inputlist_not = '-'
@@ -269,6 +269,8 @@ TLet g:tlib_keyagents_InputList_s = {
\ 15: 'tlib#agent#SuspendToParentWindow',
\ 63: 'tlib#agent#Help',
\ "\<F1>": 'tlib#agent#Help',
+ \ "\<F10>": 'tlib#agent#ExecAgentByName',
+ \ "\<S-Esc>": 'tlib#agent#ExecAgentByName',
\ "\<bs>": 'tlib#agent#ReduceFilter',
\ "\<del>": 'tlib#agent#ReduceFilter',
\ "\<c-bs>": 'tlib#agent#PopFilter',

0 comments on commit b5c3723

Please sign in to comment.