ZyX_I avatar ZyX_I committed 1fab447

@aurum/log: A bit of refactoring: moved non-mercurial-logger-related stuff from
“glog” fold

Comments (0)

Files changed (1)

plugin/aurum/log.vim

 " iterfuncs :: {fname: { "start": startfunc, "next": nextfunc }}
 " startfunc (always) :: repo, opts, * → d
 let s:iterfuncs={}
+"▶1 addcols
+function s:F.addcols(special, cnum)
+    let mapexpr='[v:val[0], v:val[1]+'.a:cnum.']+v:val[2:]'
+    call map(a:special, 'v:key[-2:] is? "_r"?'.
+                \             'map(v:val, '.string(mapexpr).'):'.
+                \             mapexpr)
+    return a:special
+endfunction
+"▶1 gettext :: skip, cs, opts, repo, width → Text
+let s:skiptext={'skip': 1, 'text': [], 'special': {}}
+function s:F.gettext(skip, ...)
+    if a:skip
+        return deepcopy(s:skiptext)
+    else
+        return call(a:2.templatefunc, a:000, {})
+    endif
+endfunction
 "▶1 graph
 "▶2 graph.update_state :: graph, gstate → + graph
 function s:F.graph.update_state(s)
     endwhile
     return r
 endfunction
+"▶2 graph.graph_init :: repo, [cs] → graph
+let s:defgraph={
+            \'cs':                0,
+            \'num_parents':       0,
+            \'expansion_row':     0,
+            \'state':             'padding',
+            \'prev_state':        'padding',
+            \'commit_index':      0,
+            \'prev_commit_index': 0,
+            \'columns':           [],
+            \'new_columns':       [],
+            \'mapping':           [],
+            \'new_mapping':       [],
+            \'mapping_size':      0,
+            \'skipchangesets':    {},
+        \}
+function s:F.graph.graph_init(showparents, opts, repo)
+    let graph=deepcopy(s:defgraph)
+    let graph.opts=a:opts
+    let graph.repo=a:repo
+    let graph.workcss=a:showparents
+    let graph.skipchangesets=a:opts.skipchangesets
+    call extend(graph, s:F.graph)
+    return graph
+endfunction
+"▶2 graph.show_log :: cs, skip::Bool → Text
+function s:F.graph.show_log(cs, skip)
+    let lines=((self.cs is 0)?([]):(self.show_remainder()))
+    call self.update(a:cs)
+    let lines+=self.show_commit()
+    if a:skip && len(lines)==1 && lines[0]!~#'[^|* ]'
+        return deepcopy(s:skiptext)
+    endif
+    let collen=len(lines[-1])
+    let text=s:F.gettext(a:skip, a:cs, self.opts, self.repo, collen)
+    let text.block_r=[[0, collen],
+                \     [len(text.text)-1,
+                \      collen+max(map(copy(text.text), 'len(v:val)'))]]
+    call s:F.addcols(text.special, collen)
+    let lines[-1]=lines[-1][:-2].' '.get(text.text, 0, '')
+    let cchar=self.output_commit_char()
+    let bidx=stridx(lines[-1], cchar)
+    if bidx!=-1
+        let text.special.bullet=[0, bidx, cchar]
+    endif
+    for line in text.text[1:]
+        let lines+=[self.next_line()[:-2].' '.line]
+    endfor
+    let text.text=lines
+    return text
+endfunction
 "▶1 glog
 "▶2 glog.utfedges
 function s:F.glog.utfedges(seen, hex, parents)
     endif
     return repeat('| ', a:ni).c.' '.repeat('| ', (a:n_columns-a:ni-1))
 endfunction
-"▶2 glog.addcols
-function s:F.glog.addcols(special, cnum)
-    let mapexpr='[v:val[0], v:val[1]+'.a:cnum.']+v:val[2:]'
-    call map(a:special, 'v:key[-2:] is? "_r"?'.
-                \             'map(v:val, '.string(mapexpr).'):'.
-                \             mapexpr)
-    return a:special
-endfunction
-"▶2 glog.gettext :: skip, cs, opts, repo, width → Text
-let s:skiptext={'skip': 1, 'text': [], 'special': {}}
-function s:F.glog.gettext(skip, ...)
-    if a:skip
-        return deepcopy(s:skiptext)
-    else
-        return call(a:2.templatefunc, a:000, {})
-    endif
-endfunction
 "▶2 glog.utf
 function s:F.glog.utf(state, type, coldata, char, skip, cs, opts, repo)
     let [idx, edges, ncols, coldiff]=a:coldata
-    let text=s:F.glog.gettext(a:skip, a:cs, a:opts, a:repo, ncols)
+    let text=s:F.gettext(a:skip, a:cs, a:opts, a:repo, ncols)
     let add_padding_line=0
     let lnum = (has_key(text, 'text') ? len(text.text) : 0)
     if coldiff==-1
     call map(lines, 'printf("%-*s ", indentation_level, v:val)')
     let curspecial=text.special
     let shiftlen=len(lines[0])
-    call s:F.glog.addcols(text.special, shiftlen)
+    call s:F.addcols(text.special, shiftlen)
     let text.block_r=[[0, shiftlen],
                 \     [len(text.text)-1,
                 \      max(map(copy(lines), 'len(v:val)'))]]
     call map(text.text, 'lines[v:key].v:val')
     return text
 endfunction
-"▶2 glog.graph_init :: repo, [cs] → graph
-let s:defgraph={
-            \'cs':                0,
-            \'num_parents':       0,
-            \'expansion_row':     0,
-            \'state':             'padding',
-            \'prev_state':        'padding',
-            \'commit_index':      0,
-            \'prev_commit_index': 0,
-            \'columns':           [],
-            \'new_columns':       [],
-            \'mapping':           [],
-            \'new_mapping':       [],
-            \'mapping_size':      0,
-            \'skipchangesets':    {},
-        \}
-function s:F.glog.graph_init(showparents, opts, repo)
-    let graph=deepcopy(s:defgraph)
-    let graph.opts=a:opts
-    let graph.repo=a:repo
-    let graph.workcss=a:showparents
-    let graph.skipchangesets=a:opts.skipchangesets
-    call extend(graph, s:F.graph)
-    return graph
-endfunction
-"▶2 glog.show_log :: graph, cs, skip::Bool → Text
-function s:F.glog.show_log(graph, cs, skip)
-    let lines=((a:graph.cs is 0)?([]):(a:graph.show_remainder()))
-    call a:graph.update(a:cs)
-    let lines+=a:graph.show_commit()
-    if a:skip && len(lines)==1 && lines[0]!~#'[^|* ]'
-        return deepcopy(s:skiptext)
-    endif
-    let collen=len(lines[-1])
-    let text=s:F.glog.gettext(a:skip, a:cs, a:graph.opts, a:graph.repo, collen)
-    let text.block_r=[[0, collen],
-                \     [len(text.text)-1,
-                \      collen+max(map(copy(text.text), 'len(v:val)'))]]
-    call s:F.glog.addcols(text.special, collen)
-    let lines[-1]=lines[-1][:-2].' '.get(text.text, 0, '')
-    let cchar=a:graph.output_commit_char()
-    let bidx=stridx(lines[-1], cchar)
-    if bidx!=-1
-        let text.special.bullet=[0, bidx, cchar]
-    endif
-    for line in text.text[1:]
-        let lines+=[a:graph.next_line()[:-2].' '.line]
-    endfor
-    let text.text=lines
-    return text
-endfunction
-"▶2 s:DateCmp :: cs, cs → -1|0|1
-function s:DateCmp(a, b)
-    let a=a:a.time
-    let b=a:b.time
-    return ((a==b)?(0):((a>b)?(-1):(1)))
-endfunction
-let s:_functions+=['s:DateCmp']
-"▶2 iterfuncs.csshow
+"▶1 iterfuncs.csshow
 let s:iterfuncs.csshow={}
-"▶3 iterfuncs.csshow.setup :: procinput → d
+"▶2 iterfuncs.csshow.setup :: procinput → d
 function s:iterfuncs.csshow.setup(procinput)
     return {     'input': '',
            \ 'skipuntil': 0,
            \ 'procinput': a:procinput,
            \ 'allowskip': 0,}
 endfunction
-"▶3 iterfuncs.csshow.next
+"▶2 iterfuncs.csshow.next
 function s:iterfuncs.csshow.next(d)
     if !a:d.didredraw
         let haschar=getchar(1)
         endif
     endif
 endfunction
-"▶3 iterfuncs.csshow.finish
+"▶2 iterfuncs.csshow.finish
 function s:iterfuncs.csshow.finish(d)
     if !empty(a:d.input)
         return feedkeys(a:d.input)
 "▶2 iterfuncs.git
 let s:iterfuncs.git={}
 function s:iterfuncs.git.start(repo, opts, ...)
-    let graph=s:F.glog.graph_init(get(a:000, 0, []), a:opts, a:repo)
+    let graph=s:F.graph.graph_init(get(a:000, 0, []), a:opts, a:repo)
     return {'graph': graph, 'opts': a:opts, 'repo': a:repo}
 endfunction
 function s:iterfuncs.git.proccs(d, cs)
     let skip=has_key(a:d.opts.skipchangesets, a:cs.hex)
-    let text=s:F.glog.show_log(a:d.graph, a:cs, skip)
+    let text=a:d.graph.show_log(a:cs, skip)
     if skip
         return [text.text, 0, 0]
     else
                 \      max(map(copy(text.text), 'len(v:val)'))]]
     let char='@o'[(index(a:d.showparents, a:cs.hex)==-1)]
     call map(text.text, '(v:key ? "|" : char)." ".v:val')
-    call s:F.glog.addcols(text.special, 2)
+    call s:F.addcols(text.special, 2)
     let text.special.bullet=[0, 0, char]
     return [text.text, text.block_r, text.special]
 endfunction
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.