Commits

ZyX_I  committed f00546d

@%autoload/Powerline/*: Added support for aurumlog and aurumcommit buffers
Ref #53, fixes #63

  • Participants
  • Parent commits 3e5eeac

Comments (0)

Files changed (5)

File autoload/Powerline/Functions/aurum.vim

     return get(get(s:_r.bufvars, bufnr('%'), {}), 'ploptions', '')
 endfunction
 let s:_functions+=['Powerline#Functions#aurum#GetOptions']
+function Powerline#Functions#aurum#GetProgress()
+    if !exists('b:aurum_log_progress')
+        return ''
+    endif
+    return printf('%-*s %3d%%', winwidth(0)-b:aurum_log_reservedwidth,
+                \               repeat('#', b:aurum_log_barwidth),
+                \               b:aurum_log_progress)
+endfunction
+let s:_functions+=['Powerline#Functions#aurum#GetProgress']

File autoload/Powerline/Matches.vim

 call extend(g:Powerline#Matches#matches, {
 	\'ft_aurumstatus':   Pl#Match#Add('getwinvar(a:window, "&ft")', '^aurumstatus$'  ),
 	\'ft_aurumannotate': Pl#Match#Add('getwinvar(a:window, "&ft")', '^aurumannotate$'),
+	\'ft_aurumlog':      Pl#Match#Add('getwinvar(a:window, "&ft")', '^aurumlog$'     ),
+	\'ft_aurumcommit':   Pl#Match#Add('getwinvar(a:window, "&ft")', '^aurumcommit$'  ),
+	\'aurumdiff':        Pl#Match#Add('bufname(winbufnr(a:window))','^aurum://diff:' ),
 \})
 unlet s:loading
 " vim: ft=vim ts=4 sts=4 sw=4 noet

File autoload/Powerline/Segments/aurum.vim

             \ Pl#Segment#Create('status',     '%{Powerline#Functions#aurum#GetStatus()}'),
             \ Pl#Segment#Create('repository', '%{Powerline#Functions#aurum#GetRepoPath()}'),
             \ Pl#Segment#Create('options',    '%{Powerline#Functions#aurum#GetOptions()}'),
+            \ Pl#Segment#Create('progress',   '%{Powerline#Functions#aurum#GetProgress()}'),
             \])

File autoload/Powerline/Themes/parts/aurum.vim

 source <sfile>:h:h:h/Matches.vim
 let Powerline#Themes#parts#aurum#part=[
-    \Pl#Theme#Buffer('ft_aurumstatus'
-            \ , ['static_str.name', 'Status']
-            \ , Pl#Segment#Truncate()
-            \ , 'aurum:repository'
-            \ , Pl#Segment#Split()
-            \ , 'aurum:options'
-    \),
-    \
-    \Pl#Theme#Buffer('ft_aurumannotate'
-            \ , ['static_str.name', 'Ann']
-            \ , Pl#Segment#Truncate()
-            \ , Pl#Segment#Split()
-            \ , 'aurum:options'
-    \),
+	\Pl#Theme#Buffer('ft_aurumstatus'
+			\ , ['static_str.name', 'Status']
+			\ , Pl#Segment#Truncate()
+			\ , 'aurum:repository'
+			\ , Pl#Segment#Split()
+			\ , 'aurum:options'
+	\),
+	\
+	\Pl#Theme#Buffer('ft_aurumannotate'
+			\ , ['static_str.name', 'Ann']
+			\ , Pl#Segment#Truncate()
+			\ , Pl#Segment#Split()
+			\ , 'aurum:options'
+	\),
+	\
+	\Pl#Theme#Buffer('ft_aurumlog'
+			\ , ['static_str.name', 'Log']
+			\ , 'aurum:progress'
+			\ , Pl#Segment#Truncate()
+			\ , 'aurum:repository'
+			\ , 'aurum:options'
+			\ , Pl#Segment#Split()
+			\ , 'scrollpercent'
+	\),
+	\
+	\Pl#Theme#Buffer('ft_aurumcommit'
+			\ , ['static_str.name', 'Commit']
+			\ , Pl#Segment#Truncate()
+			\ , 'aurum:repository'
+			\ , Pl#Segment#Split()
+			\ , 'aurum:options'
+	\),
 \]
+" vim: ft=vim ts=4 sts=4 sw=4 noet

File autoload/aurum/log.vim

         let r.csprocessed=0
         let r.csnum=get(r.csd, 'csnum', a:opts.limit)
         let r.oldstatusline=&l:statusline
+        let b:aurum_log_progress=0
+        let b:aurum_log_barwidth=0
+        let b:aurum_log_reservedwidth=35
     endif
     "▶3 Try to use cache
     let cid=hascheck.hasprogress.a:read.(join(reqprops, ';'))
                     \  '        call s:iterfuncs.csshow.next(self.sd)']
     endif
     if hasprogress
+        let plprogress=(!!g:Powerline_loaded)
+        let pgmul=(plprogress ? 100 : 1000)
+        let reservedwidth=(plprogress ? b:aurum_log_reservedwidth : 9)
         let function+=['        let self.csprocessed+=1',
-                    \  '        let progress=self.csprocessed*1000/self.csnum',
-                    \  '        let barwidth=self.csprocessed*(winwidth(0)-9)/'.
+                    \  '        let progress=self.csprocessed*'.pgmul.'/'.
+                    \                       'self.csnum',
+                    \  '        let barwidth=self.csprocessed*'.
+                    \                       '(winwidth(0)-'.reservedwidth.')/'.
                     \                       'self.csnum',
                     \  '        if progress!=self.prevprogress || '.
-                    \             'barwidth!=self.prevbarwidth',
+                    \             'barwidth!=self.prevbarwidth',]
+        if plprogress
+            let function+=[
+                    \  '            let b:aurum_log_progress=progress',
+                    \  '            let b:aurum_log_barwidth=barwidth',
+                    \]
+        else
+            let function+=[
                     \  '            let &l:stl=printf("[%-*s] %3d.%s%%%%", '.
-                    \                                'winwidth(0)-9, '.
+                    \                                'winwidth(0)-'.
+                    \                                        reservedwidth.', '.
                     \                                'substitute('.
                     \                                  'repeat("=", barwidth),'.
                     \                                  '".$", ">", ""),'.
                     \                                'progress/10, '.
                     \                                'progress[-1:])',
-                    \  '            let self.prevprogress=progress',
+                    \]
+        endif
+        let function+=['            let self.prevprogress=progress',
                     \  '            let self.prevbarwidth=barwidth',
                     \  '            redrawstatus',
                     \  '        endif']
         let &l:stl=gd.oldstatusline
         redrawstatus
     endif
+    unlet! b:aurum_log_progress b:aurum_log_barwidth b:aurum_log_width
+    unlet! b:aurum_log_reservedwidth
     let bvar=a:3
     if get(bvar, 'autoaddlog', 0) && r!=-1
         let bvar.gd=gd