Permalink
Browse files

Version 0.29

- tlib#string#Strip(): Strip also control characters (newlines etc.)
- tlib#rx#Suffixes(): 'suffixes' as Regexp
- World#RestoreOrigin(): Don't assume &splitbelow
  • Loading branch information...
1 parent 3c72e14 commit 9e63a0b60330195374acd47d80383b8a19c10bcf @tomtom tomtom committed with Feb 12, 2009
@@ -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: 2008-11-25.
-" @Last Change: 2008-11-30.
-" @Revision: 0.0.53
+" @Last Change: 2008-12-26.
+" @Revision: 0.0.56
let s:save_cpo = &cpo
set cpo&vim
@@ -61,6 +61,7 @@ endf
" :nodoc:
function! s:prototype.Match(world, text) dict "{{{3
+ " TLogVAR a:text
" let sc = &smartcase
" let ic = &ignorecase
" if &ignorecase
View
@@ -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: 2008-12-01.
-" @Revision: 0.1.669
+" @Last Change: 2009-02-07.
+" @Revision: 0.1.680
" :filedoc:
" A prototype used by |tlib#input#List|.
@@ -791,6 +791,7 @@ endf
" :nodoc:
function! s:prototype.SwitchWindow(where) dict "{{{3
+ " TLogDBG string(tlib#win#List())
let wnr = get(self, a:where.'_wnr')
" TLogVAR self, wnr
return tlib#win#Set(wnr)
@@ -834,13 +835,32 @@ endf
function! s:prototype.RestoreOrigin(...) dict "{{{3
TVarArg ['winview', 0]
if winview
+ " TLogVAR winview
call tlib#win#SetLayout(self.winview)
endif
- " TLogVAR self.win_wnr, self.bufnr, self.cursor
- if self.win_wnr != winnr()
- exec self.win_wnr .'wincmd w'
+ " TLogVAR self.win_wnr, self.bufnr, self.cursor, &splitbelow
+ " TLogDBG "RestoreOrigin0 ". string(tlib#win#List())
+ " If &splitbelow is false, we cannot rely on self.win_wnr to be our
+ " source buffer since, e.g, opening a buffer in a split window
+ " changes the whole layout.
+ " Possible solutions:
+ " - Restrict buffer switching to cases when the number of windows
+ " hasn't changed.
+ " - Guess the right window, which we try to do here.
+ if &splitbelow == 0
+ let wn = bufwinnr(self.bufnr)
+ " TLogVAR wn
+ if wn == -1
+ let wn = 1
+ end
+ else
+ let wn = self.win_wnr
+ endif
+ if wn != winnr()
+ exec wn .'wincmd w'
endif
exec 'buffer! '. self.bufnr
call setpos('.', self.cursor)
+ " TLogDBG "RestoreOrigin1 ". string(tlib#win#List())
endf
View
@@ -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: 2008-11-30.
-" @Revision: 0.1.165
+" @Last Change: 2008-12-19.
+" @Revision: 0.1.166
if &cp || exists("loaded_tlib_agent_autoload") "{{{2
finish
@@ -433,7 +433,7 @@ function! tlib#agent#PreviewLine(world, selected) "{{{3
let l = a:selected[0]
let ww = winnr()
exec a:world.win_wnr .'wincmd w'
- call tlib#buffer#ViewLine(l)
+ call tlib#buffer#ViewLine(l, 1)
exec ww .'wincmd w'
let a:world.state = 'redisplay'
return a:world
@@ -462,7 +462,7 @@ function! tlib#agent#GotoLine(world, selected) "{{{3
let world = tlib#agent#Suspend(a:world, a:selected)
exec a:world.win_wnr .'wincmd w'
endif
- call tlib#buffer#ViewLine(l)
+ call tlib#buffer#ViewLine(l, 1)
endif
return a:world
View
@@ -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: 2008-12-01.
-" @Revision: 0.0.260
+" @Last Change: 2008-12-19.
+" @Revision: 0.0.267
if &cp || exists("loaded_tlib_buffer_autoload")
finish
@@ -171,13 +171,16 @@ function! tlib#buffer#ViewLine(line, ...) "{{{3
if !empty(pos)
exec 'norm! '. pos
endif
- let @/ = '\%'. ln .'l.*'
+ call tlib#buffer#HighlightLine(ln)
+ " let @/ = '\%'. ln .'l.*'
endif
endf
function! tlib#buffer#HighlightLine(line) "{{{3
- exec 'match MatchParen /\V\%'. a:line .'l.*/'
+ " exec '3match MatchParen /^\%'. a:line .'l.*/'
+ exec '3match Search /^\%'. a:line .'l.*/'
+ autocmd TLib CursorHold,CursorHoldI,CursorMoved,CursorMovedI * 3match none
endf
View
@@ -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-11-01.
-" @Revision: 0.1.28
+" @Last Change: 2008-12-20.
+" @Revision: 0.1.29
if &cp || exists("loaded_tlib_cache_autoload")
finish
@@ -15,7 +15,7 @@ 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#var#Get('tlib_cache', 'wbg')
+ let dir = tlib#var#Get('tlib_cache', 'bg')
if empty(dir)
let dir = tlib#file#Join([tlib#dir#MyRuntime(), 'cache'])
endif
View
@@ -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: 2008-12-01.
-" @Revision: 0.0.58
+" @Last Change: 2008-12-24.
+" @Revision: 0.0.61
if &cp || exists("loaded_tlib_file_autoload")
finish
@@ -118,4 +118,3 @@ function! tlib#file#With(fcmd, bcmd, files, ...) "{{{3
endfor
endf
-
View
@@ -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: 2008-12-01.
-" @Revision: 0.0.620
+" @Last Change: 2009-02-07.
+" @Revision: 0.0.629
if &cp || exists("loaded_tlib_input_autoload")
finish
@@ -411,6 +411,7 @@ function! tlib#input#ListW(world, ...) "{{{3
endwh
" TLogVAR world.state
+ " TLogDBG string(tlib#win#List())
" TLogDBG 'exit while loop'
" TLogVAR world.list
" TLogVAR world.sel_idx
@@ -433,6 +434,7 @@ function! tlib#input#ListW(world, ...) "{{{3
" TLogDBG 'return agent'
" TLogVAR world.return_agent
call world.CloseScratch()
+ " TLogDBG "return_agent ". string(tlib#win#List())
" TAssert IsNotEmpty(world.scratch)
return call(world.return_agent, [world, world.GetSelectedItems(world.rv)])
elseif stridx(world.type, 'w') != -1
@@ -460,9 +462,11 @@ function! tlib#input#ListW(world, ...) "{{{3
" TLogDBG 'finally 2'
" TLogDBG string(world.Methods())
" TLogVAR world.state
+ " TLogDBG string(tlib#win#List())
if world.state !~ '\<suspend\>'
" TLogVAR world.sticky
if world.sticky
+ " TLogDBG "sticky"
" TLogVAR world.bufnr
" TLogDBG bufwinnr(world.bufnr)
if bufwinnr(world.bufnr) == -1
@@ -471,6 +475,7 @@ function! tlib#input#ListW(world, ...) "{{{3
endif
let world = tlib#agent#SuspendToParentWindow(world, world.GetSelectedItems(world.rv))
else
+ " TLogDBG "non sticky"
" TLogVAR world.state, world.win_wnr, world.bufnr
if world.CloseScratch()
" TLogVAR world.winview
View
@@ -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-20.
-" @Last Change: 2008-12-01.
-" @Revision: 0.0.17
+" @Last Change: 2008-12-26.
+" @Revision: 0.0.24
if &cp || exists("loaded_tlib_rx_autoload")
finish
@@ -47,3 +47,17 @@ function! tlib#rx#EscapeReplace(text, ...) "{{{3
endif
endf
+
+function! tlib#rx#Suffixes(...) "{{{3
+ TVarArg ['magic', 'm']
+ let sfx = split(&suffixes, ',')
+ call map(sfx, 'tlib#rx#Escape(v:val, magic)')
+ if magic ==# 'v'
+ return '('. join(sfx, '|') .')$'
+ elseif magic ==# 'V'
+ return '\('. join(sfx, '\|') .'\)\$'
+ else
+ return '\('. join(sfx, '\|') .'\)$'
+ endif
+endf
+
@@ -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: 2008-10-03.
-" @Revision: 0.0.122
+" @Last Change: 2009-02-07.
+" @Revision: 0.0.127
if &cp || exists("loaded_tlib_scratch_autoload")
finish
@@ -77,6 +77,7 @@ function! tlib#scratch#CloseScratch(keyargs, ...) "{{{3
TVarArg ['reset_scratch', 1]
let scratch = get(a:keyargs, 'scratch', '')
" TLogVAR scratch, reset_scratch
+ " TLogDBG string(tlib#win#List())
if !empty(scratch)
let wn = bufwinnr(scratch)
" TLogVAR wn
@@ -87,7 +88,7 @@ function! tlib#scratch#CloseScratch(keyargs, ...) "{{{3
wincmd c
" exec wb
" redraw
- " TLogDBG winnr()
+ " TLogVAR winnr()
return 1
endif
finally
View
@@ -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: 2008-11-23.
-" @Revision: 0.0.108
+" @Last Change: 2008-12-20.
+" @Revision: 0.0.109
if &cp || exists("loaded_tlib_string_autoload")
finish
@@ -130,12 +130,12 @@ endf
function! tlib#string#TrimLeft(string) "{{{3
- return substitute(a:string, '^\s\+', '', '')
+ return substitute(a:string, '^[[:space:][:cntrl:]]\+', '', '')
endf
function! tlib#string#TrimRight(string) "{{{3
- return substitute(a:string, '\s\+$', '', '')
+ return substitute(a:string, '[[:space:][:cntrl:]]\+$', '', '')
endf
View
@@ -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-08-24.
-" @Last Change: 2008-10-03.
-" @Revision: 0.0.40
+" @Last Change: 2009-02-07.
+" @Revision: 0.0.46
if &cp || exists("loaded_tlib_win_autoload")
finish
@@ -17,10 +17,12 @@ function! tlib#win#Set(winnr) "{{{3
if a:winnr > 0
" TLogVAR a:winnr
" TLogDBG winnr()
+ " TLogDBG string(tlib#win#List())
if winnr() != a:winnr && winbufnr(a:winnr) != -1
let rv = winnr().'wincmd w'
exec a:winnr .'wincmd w'
" TLogVAR rv
+ " TLogDBG string(tlib#win#List())
return rv
endif
endif
@@ -47,6 +49,7 @@ endf
function! tlib#win#SetLayout(layout) "{{{3
if a:layout.winnr == winnr('$')
" TLogVAR a:layout.winrestcmd
+ " TLogDBG string(tlib#win#List())
exec a:layout.winrestcmd
if !empty(a:layout.views)
let winnr = winnr()
@@ -60,12 +63,22 @@ function! tlib#win#SetLayout(layout) "{{{3
if a:layout.cmdheight != &cmdheight
let &cmdheight = a:layout.cmdheight
endif
+ " TLogDBG string(tlib#win#List())
return 1
endif
return 0
endf
+function! tlib#win#List() "{{{3
+ let wl = {}
+ for wn in range(1, winnr('$'))
+ let wl[wn] = bufname(winbufnr(wn))
+ endfor
+ return wl
+endf
+
+
" " :def: function! tlib#win#GetLayout1(?save_view=0)
" " Contrary to |tlib#win#GetLayout|, this version doesn't use
" " |winrestcmd()|. It can also save windows views.
Oops, something went wrong.

0 comments on commit 9e63a0b

Please sign in to comment.