Skip to content
Browse files

Version 0.36

- Display a message when the filter is for whatever reason invalid
- Removed tlib#paragraph#Delete()
- New: tlib#paragraph#Define(), tlib#textobjects#StandardParagraph()
  • Loading branch information...
1 parent afbf493 commit eb07ace29aac031e1ba334966c5eb95121aba211 @tomtom tomtom committed with Feb 20, 2010
View
9 autoload/tlib.vim
@@ -3,13 +3,10 @@
" @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: 2009-02-15.
-" @Revision: 0.0.5
+" @Last Change: 2010-01-03.
+" @Revision: 0.0.7
-if &cp || exists("loaded_tlib_autoload")
- finish
-endif
-let loaded_tlib_autoload = 1
+" call tlog#Log('Load: '. expand('<sfile>')) " vimtlib-sfile
" Dummy file for backwards compatibility.
View
71 autoload/tlib/World.vim
@@ -3,27 +3,23 @@
" @Website: http://members.a1.net/t.link/
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-05-01.
-" @Last Change: 2009-10-25.
-" @Revision: 0.1.740
+" @Last Change: 2010-02-06.
+" @Revision: 0.1.812
" :filedoc:
" A prototype used by |tlib#input#List|.
" Inherits from |tlib#Object#New|.
-if &cp || exists("loaded_tlib_world_autoload")
- finish
-endif
-let loaded_tlib_world_autoload = 1
-
-
let s:prototype = tlib#Object#New({
\ '_class': 'World',
\ 'name': 'world',
\ 'allow_suspend': 1,
\ 'base': [],
\ 'bufnr': -1,
\ 'display_format': '',
+ \ 'fmt_display': {},
+ \ 'fmt_filter': {},
\ 'filetype': '',
\ 'filter': [['']],
\ 'filter_format': '',
@@ -155,17 +151,25 @@ endf
" :nodoc:
function! s:prototype.GetSelectedItems(current) dict "{{{3
+ " TLogVAR a:current
if stridx(self.type, 'i') != -1
let rv = copy(self.sel_idx)
else
let rv = map(copy(self.sel_idx), 'self.GetBaseItem(v:val)')
endif
- if a:current != ''
- let ci = index(rv, a:current)
- if ci != -1
- call remove(rv, ci)
+ if !empty(a:current)
+ " TLogVAR a:current, rv, type(a:current)
+ if tlib#type#IsNumber(a:current) || tlib#type#IsString(a:current)
+ call s:InsertSelectedItems(rv, a:current)
+ elseif tlib#type#IsList(a:current)
+ for item in a:current
+ call s:InsertSelectedItems(rv, item)
+ endfor
+ elseif tlib#type#IsDictionary(a:current)
+ for [inum, item] in items(a:current)
+ call s:InsertSelectedItems(rv, item)
+ endfor
endif
- call insert(rv, a:current)
endif
" TAssert empty(rv) || rv[0] == a:current
if stridx(self.type, 'i') != -1
@@ -179,6 +183,15 @@ function! s:prototype.GetSelectedItems(current) dict "{{{3
endf
+function! s:InsertSelectedItems(rv, current) "{{{3
+ let ci = index(a:rv, a:current)
+ if ci != -1
+ call remove(a:rv, ci)
+ endif
+ call insert(a:rv, a:current)
+endf
+
+
" :nodoc:
function! s:prototype.SelectItem(mode, index) dict "{{{3
let bi = self.GetBaseIdx(a:index)
@@ -235,9 +248,21 @@ endf
" :nodoc:
-function! s:prototype.FormatName(format, value) dict "{{{3
- let world = self
- return eval(call(function("printf"), self.FormatArgs(a:format, a:value)))
+function! s:prototype.FormatName(cache, format, value) dict "{{{3
+ " TLogVAR a:format, a:value
+ " TLogDBG has_key(self.fmt_display, a:value)
+ if has_key(a:cache, a:value)
+ " TLogDBG "cached"
+ return a:cache[a:value]
+ else
+ let world = self
+ let ftpl = self.FormatArgs(a:format, a:value)
+ let fn = call(function("printf"), ftpl)
+ let fmt = eval(fn)
+ " TLogVAR ftpl, fn, fmt
+ let a:cache[a:value] = fmt
+ return fmt
+ endif
endf
@@ -429,7 +454,7 @@ endf
function! s:prototype.MatchBaseIdx(idx) dict "{{{3
let text = self.GetBaseItem(a:idx)
if !empty(self.filter_format)
- let text = self.FormatName(self.filter_format, text)
+ let text = self.FormatName(self.fmt_filter, self.filter_format, text)
endif
" TLogVAR text
" return self.Match(text)
@@ -438,10 +463,16 @@ endf
" :nodoc:
-function! s:prototype.BuildTable() dict "{{{3
+function! s:prototype.BuildTableList() dict "{{{3
call self.SetFilter()
" TLogVAR self.filter_neg, self.filter_pos
- let self.table = filter(range(1, len(self.base)), 'self.MatchBaseIdx(v:val)')
+ if empty(self.filter_pos) && empty(self.filter_neg)
+ let self.table = range(1, len(self.base))
+ let self.list = copy(self.base)
+ else
+ let self.table = filter(range(1, len(self.base)), 'self.MatchBaseIdx(v:val)')
+ let self.list = map(copy(self.table), 'self.GetBaseItem(v:val)')
+ endif
endf
@@ -574,6 +605,8 @@ function! s:prototype.Reset(...) dict "{{{3
let self.idx = ''
let self.prefidx = 0
let self.initial_display = 1
+ let self.fmt_display = {}
+ let self.fmt_filter = {}
call self.UseInputListScratch()
call self.ResetSelected()
call self.Retrieve(!initial)
View
9 autoload/tlib/agent.vim
@@ -3,17 +3,14 @@
" @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: 2009-08-04.
-" @Revision: 0.1.172
+" @Last Change: 2010-01-05.
+" @Revision: 0.1.174
-if &cp || exists("loaded_tlib_agent_autoload") "{{{2
- finish
-endif
-let loaded_tlib_agent_autoload = 1
" :filedoc:
" Various agents for use as key handlers in tlib#input#List()
+
" General {{{1
function! tlib#agent#Exit(world, selected) "{{{3
View
8 autoload/tlib/autocmdgroup.vim
@@ -3,13 +3,9 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2008-08-19.
-" @Last Change: 2009-12-07.
-" @Revision: 0.0.5
+" @Last Change: 2010-01-05.
+" @Revision: 0.0.6
-if &cp || exists("loaded_tlib_autocmdgroup_autoload")
- finish
-endif
-let loaded_tlib_autocmdgroup_autoload = 1
let s:save_cpo = &cpo
set cpo&vim
View
8 autoload/tlib/buffer.vim
@@ -3,13 +3,9 @@
" @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: 2009-12-07.
-" @Revision: 0.0.287
+" @Last Change: 2010-01-05.
+" @Revision: 0.0.288
-if &cp || exists("loaded_tlib_buffer_autoload")
- finish
-endif
-let loaded_tlib_buffer_autoload = 1
let s:bmru = []
View
9 autoload/tlib/cache.vim
@@ -3,13 +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: 2009-02-15.
-" @Revision: 0.1.32
-
-if &cp || exists("loaded_tlib_cache_autoload")
- finish
-endif
-let loaded_tlib_cache_autoload = 1
+" @Last Change: 2010-01-05.
+" @Revision: 0.1.33
" :def: function! tlib#cache#Filename(type, ?file=%, ?mkdir=0)
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: 2009-03-13.
-" @Revision: 0.0.67
+" @Last Change: 2010-01-04.
+" @Revision: 0.0.69
if &cp || exists("loaded_tlib_file_autoload")
finish
View
146 autoload/tlib/input.vim
@@ -1,15 +1,12 @@
+
" input.vim
" @Author: Tom 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: 2009-12-16.
-" @Revision: 0.0.654
+" @Last Change: 2010-02-06.
+" @Revision: 0.0.686
-if &cp || exists("loaded_tlib_input_autoload")
- finish
-endif
-let loaded_tlib_input_autoload = 1
" :filedoc:
" Input-related, select from a list etc.
@@ -136,6 +133,7 @@ function! tlib#input#ListW(world, ...) "{{{3
" let laststatus = &laststatus
let lastsearch = @/
let @/ = ''
+ let dlist = []
" let &laststatus = 2
let world.initial_display = 1
@@ -189,75 +187,82 @@ function! tlib#input#ListW(world, ...) "{{{3
" TLogVAR world.rv
throw 'pick'
elseif world.state =~ 'display'
- if world.IsValidFilter() && world.state =~ '^display'
-
- call world.BuildTable()
- " TLogDBG 2
- " TLogDBG len(world.table)
- " TLogVAR world.table
- let world.list = map(copy(world.table), 'world.GetBaseItem(v:val)')
- " TLogDBG 3
- let world.llen = len(world.list)
- " TLogVAR world.index_table
- if empty(world.index_table)
- let dindex = range(1, world.llen)
- let world.index_width = len(world.llen)
- else
- let dindex = world.index_table
- let world.index_width = len(max(dindex))
- endif
- if world.llen == 0 && !world.show_empty
- call world.ReduceFilter()
- let world.offset = 1
- " TLogDBG 'ReduceFilter'
- continue
- else
- if world.llen == 1
- let world.last_item = world.list[0]
- if world.pick_last_item
- " echom 'Pick last item: '. world.list[0]
- let world.prefidx = '1'
- " TLogDBG 'pick last item'
- throw 'pick'
- endif
+ if world.state =~ '^display'
+ if world.IsValidFilter()
+
+ call world.BuildTableList()
+ " TLogDBG 2
+ " TLogDBG len(world.table)
+ " TLogVAR world.table
+ " let world.list = map(copy(world.table), 'world.GetBaseItem(v:val)')
+ " TLogDBG 3
+ let world.llen = len(world.list)
+ " TLogVAR world.index_table
+ if empty(world.index_table)
+ let dindex = range(1, world.llen)
+ let world.index_width = len(world.llen)
else
- let world.last_item = ''
+ let dindex = world.index_table
+ let world.index_width = len(max(dindex))
endif
- endif
- " TLogDBG 4
- " TLogVAR world.idx, world.llen, world.state
- " TLogDBG world.FilterIsEmpty()
- if world.state == 'display'
- if world.idx == '' && world.llen < g:tlib_sortprefs_threshold && !world.FilterIsEmpty()
- call world.SetPrefIdx()
+ if world.llen == 0 && !world.show_empty
+ call world.ReduceFilter()
+ let world.offset = 1
+ " TLogDBG 'ReduceFilter'
+ continue
else
- let world.prefidx = world.idx == '' ? world.initial_index : world.idx
+ if world.llen == 1
+ let world.last_item = world.list[0]
+ if world.pick_last_item
+ " echom 'Pick last item: '. world.list[0]
+ let world.prefidx = '1'
+ " TLogDBG 'pick last item'
+ throw 'pick'
+ endif
+ else
+ let world.last_item = ''
+ endif
endif
- if world.prefidx > world.llen
- let world.prefidx = world.llen
- elseif world.prefidx < 1
- let world.prefidx = 1
+ " TLogDBG 4
+ " TLogVAR world.idx, world.llen, world.state
+ " TLogDBG world.FilterIsEmpty()
+ if world.state == 'display'
+ if world.idx == '' && world.llen < g:tlib_sortprefs_threshold && !world.FilterIsEmpty()
+ call world.SetPrefIdx()
+ else
+ let world.prefidx = world.idx == '' ? world.initial_index : world.idx
+ endif
+ if world.prefidx > world.llen
+ let world.prefidx = world.llen
+ elseif world.prefidx < 1
+ let world.prefidx = 1
+ endif
endif
- endif
- " TLogVAR world.initial_index, world.prefidx
- " TLogDBG 5
- " TLogDBG len(world.list)
- " TLogVAR world.list
- let dlist = copy(world.list)
- if !empty(world.display_format)
- let display_format = world.display_format
- " TLogVAR display_format
- call map(dlist, 'world.FormatName(display_format, v:val)')
- endif
- " TLogVAR world.prefidx
- " TLogDBG 6
- if world.offset_horizontal > 0
- call map(dlist, 'v:val[world.offset_horizontal:-1]')
- 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
+ " TLogVAR world.initial_index, world.prefidx
+ " TLogDBG 5
+ " TLogDBG len(world.list)
+ " TLogVAR world.list
+ let dlist = copy(world.list)
+ if !empty(world.display_format)
+ let display_format = world.display_format
+ let cache = world.fmt_display
+ " TLogVAR display_format, fmt_entries
+ call map(dlist, 'world.FormatName(cache, display_format, v:val)')
+ endif
+ " TLogVAR world.prefidx
+ " TLogDBG 6
+ if world.offset_horizontal > 0
+ call map(dlist, 'v:val[world.offset_horizontal:-1]')
+ 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
+ else
+
+ let dlist = ['Malformed filter']
+
+ endif
endif
" TLogDBG 7
@@ -554,10 +559,11 @@ endf
" echo tlib#input#EditList('Edit:', [100,200,300])
function! tlib#input#EditList(query, list, ...) "{{{3
let handlers = a:0 >= 1 && !empty(a:1) ? a:1 : g:tlib_handlers_EditList
- let default = a:0 >= 2 ? a:2 : ''
+ let default = a:0 >= 2 ? a:2 : []
let timeout = a:0 >= 3 ? a:3 : 0
" TLogVAR handlers
let rv = tlib#input#List('m', a:query, copy(a:list), handlers, default, timeout)
+ " TLogVAR rv
if empty(rv)
return a:list
else
View
97 autoload/tlib/paragraph.vim
@@ -3,42 +3,83 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2009-10-26.
-" @Last Change: 2009-10-26.
-" @Revision: 0.0.12
+" @Last Change: 2010-01-09.
+" @Revision: 58
let s:save_cpo = &cpo
set cpo&vim
-" :def: function! tlib#paragraph#Delete(?register="")
-" Almost the same as dap but behaves differently when the cursor is on a
-" blank line or when the paragraph's last line is the last line in the
-" file.
-"
-" This function assumes that a paragraph is a block of text followed by
-" blank lines or the end of file.
-function! tlib#paragraph#Delete(...) "{{{3
- TVarArg 'register'
- if empty(register)
- let prefix = ''
- else
- let prefix = '"'. register
- endif
- let lineno = line('.')
- let lastno = line('$')
- let hastext = getline(lineno) =~ '\S'
- if line("'}") == lastno
- if lineno == lastno
- silent norm! {j0
+" Return an object describing an |paragraph|.
+function! tlib#paragraph#GetMetric() "{{{3
+ let sp = {'text_start': line("'{") + 1}
+ if line("'}") == line("$")
+ let sp.last = 1
+ let sp.text_end = line("'}")
+ if line("'{") == 1
+ let sp.ws_start = 0
+ let sp.ws_end = 0
+ let sp.top = sp.text_start
+ let sp.bottom = sp.text_end
else
- silent norm! }{j0
+ let sp.ws_start = prevnonblank(line("'{")) + 1
+ let sp.ws_end = line("'{")
+ let sp.top = sp.ws_start
+ let sp.bottom = sp.text_end
endif
- exec 'silent norm! '. prefix .'dG'
- elseif hastext
- silent norm! dap
- else
- silent norm! {j0dap
+ else
+ let sp.last = 0
+ let sp.text_end = line("'}") - 1
+ let sp.ws_start = line("'}")
+ for i in range(line("'}"), line('$'))
+ if getline(i) =~ '\w'
+ let sp.ws_end = i - 1
+ break
+ elseif i == line("$")
+ let sp.ws_end = i
+ endif
+ endfor
+ let sp.top = sp.text_start
+ let sp.bottom = sp.ws_end
endif
+ return sp
+endf
+
+
+function! tlib#paragraph#Move(direction, count)
+ " TLogVAR a:direction, a:count
+ let mycount = empty(a:count) ? 1 : a:count
+ for i in range(1, mycount)
+ let para = tlib#paragraph#GetMetric()
+ " TLogVAR para
+ let text = getline(para.text_start, para.text_end)
+ let ws = getline(para.ws_start, para.ws_end)
+ " TLogVAR text, ws
+ exec para.top .','. para.bottom .'delete'
+ if a:direction == "Down"
+ let other = tlib#paragraph#GetMetric()
+ let target = other.bottom + 1
+ if other.last
+ let lines = ws + text
+ let pos = target + len(ws)
+ else
+ let lines = text + ws
+ let pos = target
+ endif
+ elseif a:direction == "Up"
+ if !para.last
+ norm! {
+ endif
+ let other = tlib#paragraph#GetMetric()
+ let target = other.text_start
+ let lines = text + ws
+ let pos = target
+ endif
+ " TLogVAR other, target
+ " TLogVAR lines
+ call append(target - 1, lines)
+ exec pos
+ endfor
endf
View
14 autoload/tlib/progressbar.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-09-30.
-" @Last Change: 2009-02-15.
-" @Revision: 0.0.34
+" @Last Change: 2010-01-07.
+" @Revision: 0.0.66
if &cp || exists("loaded_tlib_progressbar_autoload")
finish
@@ -55,15 +55,21 @@ function! tlib#progressbar#Display(value, ...) "{{{3
let s:value[0] = val
let pbl = repeat('#', val)
let pbr = repeat('.', s:width[0] - val)
- let &statusline = printf(s:format[0], '['.pbl.pbr.']') . extra
+ let txt = printf(s:format[0], '['.pbl.pbr.']') . extra
+ let &l:statusline = txt
redrawstatus
+ " redraw
+ " call tlib#notify#Echo(txt)
endif
endf
function! tlib#progressbar#Restore() "{{{3
- let &statusline = remove(s:statusline, 0)
+ let &l:statusline = remove(s:statusline, 0)
let &laststatus = remove(s:laststatus, 0)
+ redrawstatus
+ " redraw
+ " echo
call remove(s:max, 0)
call remove(s:format, 0)
call remove(s:width, 0)
View
45 autoload/tlib/textobjects.vim
@@ -0,0 +1,45 @@
+" textobjects.vim
+" @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: 2010-01-09.
+" @Last Change: 2010-01-10.
+" @Revision: 0.0.29
+
+let s:save_cpo = &cpo
+set cpo&vim
+
+
+" :tag: standard-paragraph
+" Select a "Standard Paragraph", i.e. a text block followed by blank
+" lines. Other than |ap|, the last paragraph in a document is handled
+" just the same.
+"
+" The |text-object| can be accessed as "sp". Example: >
+"
+" vsp ... select the current standard paragraph
+"
+" Return 1, if the paragraph is the last one in the document.
+function! tlib#textobjects#StandardParagraph() "{{{3
+ if line("'}") == line('$')
+ norm! vip
+ return 1
+ else
+ norm! vap
+ return 0
+ endif
+endf
+
+
+function! tlib#textobjects#Init() "{{{3
+ if !exists('s:tlib_done_textobjects')
+ " sp ... Standard paragraph (for use as |text-objects|).
+ vnoremap <silent> sp <Esc>:call tlib#textobjects#StandardParagraph()<CR>
+ onoremap <silent> sp :<C-u>normal Vsp<CR>
+ let s:tlib_done_textobjects = 1
+ endif
+endf
+
+
+let &cpo = s:save_cpo
+unlet s:save_cpo
View
9 autoload/tlib/url.vim
@@ -3,13 +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: 2009-02-15.
-" @Revision: 0.0.26
-
-if &cp || exists("loaded_tlib_url_autoload")
- finish
-endif
-let loaded_tlib_url_autoload = 1
+" @Last Change: 2010-01-04.
+" @Revision: 0.0.27
" TODO: These functions could use printf() now.
View
330 doc/tlib.txt
@@ -57,21 +57,6 @@ Contents~
g:tlib_scroll_lines ..................... |g:tlib_scroll_lines|
g:tlib_keyagents_InputList_m ............ |g:tlib_keyagents_InputList_m|
g:tlib_handlers_EditList ................ |g:tlib_handlers_EditList|
- tlib#Filter_cnf#New ..................... |tlib#Filter_cnf#New()|
- tlib#Filter_cnfd#New .................... |tlib#Filter_cnfd#New()|
- tlib#Filter_fuzzy#New ................... |tlib#Filter_fuzzy#New()|
- tlib#Filter_seq#New ..................... |tlib#Filter_seq#New()|
- tlib#Object#New ......................... |tlib#Object#New()|
- prototype.New
- prototype.Inherit
- prototype.Extend
- prototype.IsA
- prototype.IsRelated
- prototype.RespondTo
- prototype.Super
- prototype.Methods
- tlib#World#New .......................... |tlib#World#New()|
- prototype.Reset
tlib#agent#Exit ......................... |tlib#agent#Exit()|
tlib#agent#CopyItems .................... |tlib#agent#CopyItems()|
tlib#agent#PageUp ....................... |tlib#agent#PageUp()|
@@ -159,6 +144,10 @@ Contents~
tlib#file#Join .......................... |tlib#file#Join()|
tlib#file#Relative ...................... |tlib#file#Relative()|
tlib#file#With .......................... |tlib#file#With()|
+ tlib#Filter_cnf#New ..................... |tlib#Filter_cnf#New()|
+ tlib#Filter_cnfd#New .................... |tlib#Filter_cnfd#New()|
+ tlib#Filter_fuzzy#New ................... |tlib#Filter_fuzzy#New()|
+ tlib#Filter_seq#New ..................... |tlib#Filter_seq#New()|
tlib#hook#Run ........................... |tlib#hook#Run()|
tlib#input#List ......................... |tlib#input#List()|
tlib#input#ListD ........................ |tlib#input#ListD()|
@@ -182,7 +171,17 @@ Contents~
tlib#normal#WithRegister ................ |tlib#normal#WithRegister()|
tlib#notify#Echo ........................ |tlib#notify#Echo()|
tlib#notify#TrimMessage ................. |tlib#notify#TrimMessage()|
- tlib#paragraph#Delete ................... |tlib#paragraph#Delete()|
+ tlib#Object#New ......................... |tlib#Object#New()|
+ prototype.New
+ prototype.Inherit
+ prototype.Extend
+ prototype.IsA
+ prototype.IsRelated
+ prototype.RespondTo
+ prototype.Super
+ prototype.Methods
+ tlib#paragraph#GetMetric ................ |tlib#paragraph#GetMetric()|
+ tlib#paragraph#Move ..................... |tlib#paragraph#Move()|
tlib#progressbar#Init ................... |tlib#progressbar#Init()|
tlib#progressbar#Display ................ |tlib#progressbar#Display()|
tlib#progressbar#Restore ................ |tlib#progressbar#Restore()|
@@ -210,6 +209,10 @@ Contents~
tlib#tag#Retrieve ....................... |tlib#tag#Retrieve()|
tlib#tag#Collect ........................ |tlib#tag#Collect()|
tlib#tag#Format ......................... |tlib#tag#Format()|
+ tlib#textobjects#StandardParagraph ...... |standard-paragraph|
+ tlib#textobjects#Init ................... |tlib#textobjects#Init()|
+ v_sp .................................... |v_sp|
+ o_sp .................................... |o_sp|
tlib#time#MSecs ......................... |tlib#time#MSecs()|
tlib#time#Now ........................... |tlib#time#Now()|
tlib#time#Diff .......................... |tlib#time#Diff()|
@@ -232,6 +235,8 @@ Contents~
tlib#win#SetLayout ...................... |tlib#win#SetLayout()|
tlib#win#List ........................... |tlib#win#List()|
tlib#win#Width .......................... |tlib#win#Width()|
+ tlib#World#New .......................... |tlib#World#New()|
+ prototype.Reset
========================================================================
@@ -415,132 +420,6 @@ g:tlib_handlers_EditList
========================================================================
-autoload/tlib/Filter_cnf.vim~
-
- *tlib#Filter_cnf#New()*
-tlib#Filter_cnf#New(...)
- The search pattern for |tlib#input#List()| is in conjunctive normal
- form: (P1 OR P2 ...) AND (P3 OR P4 ...) ...
- The pattern is a '/\V' very no-'/magic' regexp pattern.
-
- This is also the base class for other filters.
-
-
-========================================================================
-autoload/tlib/Filter_cnfd.vim~
-
- *tlib#Filter_cnfd#New()*
-tlib#Filter_cnfd#New(...)
- The same as |tlib#FilterCNF#New()| but a dot is expanded to '\.\{-}'.
- As a consequence, patterns cannot match dots.
- The pattern is a '/\V' very no-'/magic' regexp pattern.
-
-
-========================================================================
-autoload/tlib/Filter_fuzzy.vim~
-
- *tlib#Filter_fuzzy#New()*
-tlib#Filter_fuzzy#New(...)
- Support for "fuzzy" pattern matching in |tlib#input#List()|.
- Characters are interpreted as if connected with '.\{-}'.
-
-
-========================================================================
-autoload/tlib/Filter_seq.vim~
-
- *tlib#Filter_seq#New()*
-tlib#Filter_seq#New(...)
- The search pattern for |tlib#input#List()| is interpreted as a
- disjunction of 'magic' regular expressions with the exception of a dot
- ".", which is interpreted as ".\{-}".
- The pattern is a '/magic' regexp pattern.
-
-
-========================================================================
-autoload/tlib/Object.vim~
-Provides a prototype plus some OO-like methods.
-
- *tlib#Object#New()*
-tlib#Object#New(?fields={})
- This function creates a prototype that provides some kind of
- inheritance mechanism and a way to call parent/super's methods.
-
- The usage demonstrated in the following example works best, when every
- class/prototype is defined in a file of its own.
-
- The reason for why there is a dedicated constructor function is that
- this layout facilitates the use of templates and that methods are
- hidden from the user. Other solutions are possible.
-
- EXAMPLES: >
- let s:prototype = tlib#Object#New({
- \ '_class': ['FooBar'],
- \ 'foo': 1,
- \ 'bar': 2,
- \ })
- " Constructor
- function! FooBar(...)
- let object = s:prototype.New(a:0 >= 1 ? a:1 : {})
- return object
- endf
- function! s:prototype.babble() {
- echo "I think, therefore I am ". (self.foo * self.bar) ." months old."
- }
-
-< This could now be used like this: >
- let myfoo = FooBar({'foo': 3})
- call myfoo.babble()
- => I think, therefore I am 6 months old.
- echo myfoo.IsA('FooBar')
- => 1
- echo myfoo.IsA('object')
- => 1
- echo myfoo.IsA('Foo')
- => 0
- echo myfoo.RespondTo('babble')
- => 1
- echo myfoo.RespondTo('speak')
- => 0
-<
-
-
-prototype.New
-
-
-prototype.Inherit
-
-
-prototype.Extend
-
-
-prototype.IsA
-
-
-prototype.IsRelated
-
-
-prototype.RespondTo
-
-
-prototype.Super
-
-
-prototype.Methods
-
-
-========================================================================
-autoload/tlib/World.vim~
-A prototype used by |tlib#input#List|.
-Inherits from |tlib#Object#New|.
-
- *tlib#World#New()*
-tlib#World#New(...)
-
-
-prototype.Reset
-
-
-========================================================================
autoload/tlib/agent.vim~
Various agents for use as key handlers in tlib#input#List()
@@ -926,6 +805,48 @@ tlib#file#With(fcmd, bcmd, files, ?world={})
========================================================================
+autoload/tlib/Filter_cnf.vim~
+
+ *tlib#Filter_cnf#New()*
+tlib#Filter_cnf#New(...)
+ The search pattern for |tlib#input#List()| is in conjunctive normal
+ form: (P1 OR P2 ...) AND (P3 OR P4 ...) ...
+ The pattern is a '/\V' very no-'/magic' regexp pattern.
+
+ This is also the base class for other filters.
+
+
+========================================================================
+autoload/tlib/Filter_cnfd.vim~
+
+ *tlib#Filter_cnfd#New()*
+tlib#Filter_cnfd#New(...)
+ The same as |tlib#FilterCNF#New()| but a dot is expanded to '\.\{-}'.
+ As a consequence, patterns cannot match dots.
+ The pattern is a '/\V' very no-'/magic' regexp pattern.
+
+
+========================================================================
+autoload/tlib/Filter_fuzzy.vim~
+
+ *tlib#Filter_fuzzy#New()*
+tlib#Filter_fuzzy#New(...)
+ Support for "fuzzy" pattern matching in |tlib#input#List()|.
+ Characters are interpreted as if connected with '.\{-}'.
+
+
+========================================================================
+autoload/tlib/Filter_seq.vim~
+
+ *tlib#Filter_seq#New()*
+tlib#Filter_seq#New(...)
+ The search pattern for |tlib#input#List()| is interpreted as a
+ disjunction of 'magic' regular expressions with the exception of a dot
+ ".", which is interpreted as ".\{-}".
+ The pattern is a '/magic' regexp pattern.
+
+
+========================================================================
autoload/tlib/hook.vim~
*tlib#hook#Run()*
@@ -1141,16 +1062,86 @@ tlib#notify#TrimMessage(message)
========================================================================
-autoload/tlib/paragraph.vim~
+autoload/tlib/Object.vim~
+Provides a prototype plus some OO-like methods.
- *tlib#paragraph#Delete()*
-tlib#paragraph#Delete(?register="")
- Almost the same as dap but behaves differently when the cursor is on a
- blank line or when the paragraph's last line is the last line in the
- file.
+ *tlib#Object#New()*
+tlib#Object#New(?fields={})
+ This function creates a prototype that provides some kind of
+ inheritance mechanism and a way to call parent/super's methods.
- This function assumes that a paragraph is a block of text followed by
- blank lines or the end of file.
+ The usage demonstrated in the following example works best, when every
+ class/prototype is defined in a file of its own.
+
+ The reason for why there is a dedicated constructor function is that
+ this layout facilitates the use of templates and that methods are
+ hidden from the user. Other solutions are possible.
+
+ EXAMPLES: >
+ let s:prototype = tlib#Object#New({
+ \ '_class': ['FooBar'],
+ \ 'foo': 1,
+ \ 'bar': 2,
+ \ })
+ " Constructor
+ function! FooBar(...)
+ let object = s:prototype.New(a:0 >= 1 ? a:1 : {})
+ return object
+ endf
+ function! s:prototype.babble() {
+ echo "I think, therefore I am ". (self.foo * self.bar) ." months old."
+ }
+
+< This could now be used like this: >
+ let myfoo = FooBar({'foo': 3})
+ call myfoo.babble()
+ => I think, therefore I am 6 months old.
+ echo myfoo.IsA('FooBar')
+ => 1
+ echo myfoo.IsA('object')
+ => 1
+ echo myfoo.IsA('Foo')
+ => 0
+ echo myfoo.RespondTo('babble')
+ => 1
+ echo myfoo.RespondTo('speak')
+ => 0
+<
+
+
+prototype.New
+
+
+prototype.Inherit
+
+
+prototype.Extend
+
+
+prototype.IsA
+
+
+prototype.IsRelated
+
+
+prototype.RespondTo
+
+
+prototype.Super
+
+
+prototype.Methods
+
+
+========================================================================
+autoload/tlib/paragraph.vim~
+
+ *tlib#paragraph#GetMetric()*
+tlib#paragraph#GetMetric()
+ Return an object describing an |paragraph|.
+
+ *tlib#paragraph#Move()*
+tlib#paragraph#Move(direction, count)
========================================================================
@@ -1330,6 +1321,33 @@ tlib#tag#Format(tag)
========================================================================
+autoload/tlib/textobjects.vim~
+
+ *standard-paragraph*
+tlib#textobjects#StandardParagraph()
+ Select a "Standard Paragraph", i.e. a text block followed by blank
+ lines. Other than |ap|, the last paragraph in a document is handled
+ just the same.
+
+ The |text-object| can be accessed as "sp". Example: >
+
+ vsp ... select the current standard paragraph
+
+ Return 1, if the paragraph is the last one in the document.
+<
+
+ *tlib#textobjects#Init()*
+tlib#textobjects#Init()
+
+ *v_sp*
+v_sp ... <Esc>:call tlib#textobjects#StandardParagraph()<CR>
+ sp ... Standard paragraph (for use as |text-objects|).
+
+ *o_sp*
+o_sp ... :<C-u>normal Vsp<CR>
+
+
+========================================================================
autoload/tlib/time.vim~
*tlib#time#MSecs()*
@@ -1450,5 +1468,17 @@ tlib#win#List()
tlib#win#Width(wnr)
+========================================================================
+autoload/tlib/World.vim~
+A prototype used by |tlib#input#List|.
+Inherits from |tlib#Object#New|.
+
+ *tlib#World#New()*
+tlib#World#New(...)
+
+
+prototype.Reset
+
+
vim:tw=78:fo=tcq2:isk=!-~,^*,^|,^":ts=8:ft=help:norl:
View
14 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: 2009-12-21.
-" @Revision: 592
+" @Last Change: 2010-01-24.
+" @Revision: 603
" GetLatestVimScripts: 1863 1 tlib.vim
"
" Please see also ../test/tlib.vim for usage examples.
@@ -29,7 +29,8 @@ if v:version < 700 "{{{2
echoerr "tlib requires Vim >= 7"
finish
endif
-let loaded_tlib = 35
+let loaded_tlib = 36
+
let s:save_cpo = &cpo
set cpo&vim
@@ -563,3 +564,10 @@ pressing <esc> when browsing an index-list, returns 0 and not "")
0.35
- tlib#input#EditList(): return the list if the user presses esc
+0.36
+- Display a message when the filter is for whatever reason invalid
+- Removed tlib#paragraph#Delete()
+- New: tlib#paragraph#Define(), tlib#textobjects#StandardParagraph()
+- Try to speed up list display (a rewrite of World.DisplayList() etc. is
+required)
+

0 comments on commit eb07ace

Please sign in to comment.
Something went wrong with that request. Please try again.