From 7679b622e478687b8f0896c2d57a0d91933c98e8 Mon Sep 17 00:00:00 2001 From: Kien N Date: Fri, 9 Sep 2011 10:30:18 +0700 Subject: [PATCH] add a loading progress indicator --- autoload/ctrlp.vim | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 36a7adc..080c699 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -130,11 +130,12 @@ func! s:List(dirs, allfiles) let entries_copy = deepcopy(entries) let alldirs = filter(entries, 'isdirectory(v:val)') let allfiles = filter(entries_copy, '!isdirectory(v:val)') - cal extend(allfiles, a:allfiles) + cal extend(allfiles, a:allfiles, 0) if empty(alldirs) let s:allfiles = allfiles else let dirs = join(alldirs, ',') + cal s:progress(allfiles) cal s:List(dirs, allfiles) endif endfunc @@ -254,7 +255,6 @@ func! s:GetMatchedItems(items, pats, limit) "{{{ endfunc "}}} func! s:SetupBlank() "{{{ - cal s:statusline() setf ctrlp setl bt=nofile setl bh=delete @@ -276,6 +276,7 @@ func! s:SetupBlank() "{{{ setl noudf setl cc=0 endif + redr endfunc "}}} func! s:BufOpen(...) "{{{ @@ -744,11 +745,14 @@ func! s:statusline(...) let max = len(itemtypes) - 1 let next = itemtypes[s:walker(max, s:itemtype, 1, 1)][1] let prev = itemtypes[s:walker(max, s:itemtype, -1, 1)][1] - let regex = s:regexp ? '[regex]' : '' - let byfname = s:byfname ? '[file]' : '[path]' - let focus = s:Focus() ? '[prt]' : '[win]' let item = itemtypes[s:itemtype][0] - exe 'setl stl='.focus.byfname.regex.'+-('.prev.')-[['.item.']]-('.next.')-+' + let focus = s:Focus() ? 'prt' : 'win' + let byfname = s:byfname ? 'file' : 'path' + let regex = s:regexp ? '%#Conditional#\ regex\ %*' : '' + let focus = '%#MatchParen#\ '.focus.'\ %*' + let byfname = '%#Character#\ '.byfname.'\ %*' + let item = '%#Constant#\ '.item.'\ %*' + exe 'setl stl='.focus.byfname.regex.'\ +-<'.prev.'>-{'.item.'}-<'.next.'>-+' endfunc func! s:matchsubstr(item, pat) @@ -762,6 +766,11 @@ func! s:matchlists(item, lst) retu 1 endfunc +func! s:progress(entries) + exe 'setl stl=%#WarningMsg#\ '.len(a:entries).'\ %*\ ' + redr +endfunc + func! s:syntax() syn match CtrlPNoEntries '^ == NO MATCHES ==$' syn match CtrlPNoEntries '^ == DISABLED ==$' @@ -795,11 +804,12 @@ func! ctrlp#init(type, ...) "{{{ else sil! cal ctrlp#SetWorkingPath() endif - sil! cal s:SetLines(a:type) sil! cal s:BufOpen('ControlP') sil! cal s:SetupBlank() sil! cal s:MapKeys() + sil! cal s:SetLines(a:type) sil! cal s:Renderer(s:lines) + cal s:statusline() cal s:BuildPrompt() sil! cal s:syntax() endfunc "}}}