Commits

ZyX_I committed 3f6f12d

@aurum/log: Added progress bar support. Fixes #37.

Comments (0)

Files changed (2)

                 Flag. Overrides |g:aurum_procinput|: determines whether user 
                 input will be processed while generating log.
                 Note If enabled, acts like g:aurum_procinput=2.
+    [no]progress
+                Flag. Determines whether progress bar should be shown in the 
+                statusline while generating log.
 
                                                                      *:AuMove*
 AuMove [copy] [rightrepl] [leftpattern] [pretend] [repo {repo}] [args ...]
     returns a dictionary containing at least the “next” key. The “next” value 
     is a function reference that has previously returned dictionary in |self| 
     variable and must return either a |aurum-changeset| or zero indicating 
-    that there are no changesets left. Returned changeset objects must be 
-    sorted in topological order like described under |aurum-rf-getchangesets|.
+    that there are no changesets left. If there is “csnum” key its value will 
+    be used for progress bar to determine how many revisions should be 
+    processed. Returned changeset objects must be sorted in topological order 
+    like described under |aurum-rf-getchangesets|.
     Note: try to omit processsing options dictionary more then it is required 
           to do the job (see below). It will be done in any case by log 
           generator function.
          aurum-repo.cslist being empty, changed format of 
          |aurum-repo.iterfuncs|, removed repo.cslist, added 
          |aurum-repo.mutable|.
+    4.1: Added csnum key to value returned by |aurum-repo.iterfuncs|.func().
 @aurum:
     0.1: Added |:AuBranch| and |:AuName|.
     0.2: Added |:AuOther|.

plugin/aurum/log.vim

         unlet r.checkd
     endif
     let r.opts=a:opts
+    "▶3 Initialize variables used for progress bar
+    let hasprogress=(get(a:opts, 'progress', 0) &&
+                \    (has_key(r.csd, 'csnum') || a:opts.limit))
+    if hasprogress
+        let r.tick=0
+        let r.prevprogress=0
+        let r.prevbarwidth=-1
+        let r.csprocessed=0
+        let r.csnum=get(r.csd, 'csnum', a:opts.limit)
+        let r.oldstatusline=&l:statusline
+    endif
     "▶3 Try to use cache
-    let cid=hascheck.a:read.(join(reqprops, ';'))
+    let cid=hascheck.hasprogress.a:read.(join(reqprops, ';'))
     if has_key(s:glogcache, cid)
         let [r.next, r.ffnext]=s:glogcache[cid]
         return r
                     \  '        endif',
                     \  '        call s:iterfuncs.csshow.next(self.sd)']
     endif
+    if hasprogress
+        let function+=['        let self.csprocessed+=1',
+                    \  '        let progress=self.csprocessed*100/self.csnum',
+                    \  '        let barwidth=self.csprocessed*(winwidth(0)-7)/'.
+                    \                       'self.csnum',
+                    \  '        if progress!=self.prevprogress || '.
+                    \             'barwidth!=self.prevbarwidth',
+                    \  '            let &l:stl=printf("[%-*s] %3d%%%%", '.
+                    \                                'winwidth(0)-7, '.
+                    \                                'substitute('.
+                    \                                  'repeat("=", barwidth),'.
+                    \                                  '".$", ">", ""),'.
+                    \                                'progress)',
+                    \  '            let self.prevprogress=progress',
+                    \  '            let self.prevbarwidth=barwidth',
+                    \  '            redrawstatus',
+                    \  '        endif']
+    endif
     if hascheck
         let function+=['        unlet lines rectangle special',
                     \  '    endfor',
     if has_key(gd, 'sd')
         call s:iterfuncs.csshow.finish(gd.sd)
     endif
+    if has_key(gd, 'oldstatusline')
+        let &l:stl=gd.oldstatusline
+        redrawstatus
+    endif
     let bvar=a:3
     if get(bvar, 'autoaddlog', 0) && r!=-1
         let bvar.gd=gd
             \          ' !   ?showcopies'.
             \          ' !   ?procinput'.
             \          ' !   ?autoaddlog'.
+            \          ' !   ?progress'.
             \          s:_r.repo.diffoptsstr.
             \          '    ?cmd      type ""'.
             \          '}', 'filter']
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.