Commits

ZyX_I  committed d578b44

Fixed graphlog

  • Participants
  • Parent commits 56d23b6

Comments (0)

Files changed (1)

File ftplugin/aurumgraphlog.vim

 "▶1
 scriptencoding utf-8
-setlocal nolist tw=0 nowrap
+setlocal textwidth=0
+setlocal nolist nowrap
+setlocal concealcursor+=n conceallevel=2
+setlocal nonumber norelativenumber
+setlocal noswapfile
+setlocal nomodeline
 execute frawor#Setup('0.0', {'@aurum': '0.0',
             \            '@/mappings': '0.0',
             \        '@/autocommands': '0.0',})
     if a:fix_tail && a:n_columns_diff==a:p_diff && a:n_columns_diff!=0
         if a:n_columns_diff==-1
             let start=max([a:node_index+1, a:p_node_index])
-            let tail=repeat(['|', ' '], (start-a:node_index-1))+
+            return repeat(['|', ' '], (start-a:node_index-1))+
                         \repeat(['/', ' '], (a:n_columns-start))
-            return tail
         else
             return repeat(['\', ' '], (a:n_columns-a:node_index-1))
         endif
             if start>end
                 let [start, end]=[end, start]
             endif
-            for i in range(2*start + 1, 2*end)
+            for i in range(2*start+1, 2*end-1)
                 if a:nodeline[i] isnot# '+'
                     let a:nodeline[i]='-'
                 endif
     if index(a:edges, [a:ni, a:ni-1])!=-1 || index(a:edges, [a:ni, a:ni])!=-1
         let c='|'
     endif
-    let line=repeat(['|', ' '], a:ni)+
+    return repeat(['|', ' '], a:ni)+
                 \[c, ' ']+
                 \repeat(['|', " "], (a:n_columns-a:ni-1))
-    return line
 endfunction
 "▶2 glog.addlines
 function s:F.glog.addlines(text, lnum)
 endfunction
 "▶1 setup
 function s:F.setup()
-    let bvar=s:_r.aurum.bufvars[bufnr('%')]
+    let buf=bufnr('%')
+    let bvar=s:_r.aurum.bufvars[buf]
     let text=s:F.glog.graphlog(bvar.repo)
     let bvar.specials=text.specials
     let bvar.rectangles=text.rectangles
     call setline(1, text.text)
+    setlocal readonly
+    call s:_f.augroup.add('AuGlog', [['InsertEnter', '<buffer='.buf.'>', 0,
+                \                     'call feedkeys("\e", "n")']])
 endfunction
 let s:filetype=expand('<sfile>:t:r')
 call s:_f.augroup.add('AuGlog', [['FileType', s:filetype, 0, s:F.setup]])
                 \((curline>a:block[1][0])?( 1):
                 \                         ( 0)))
 endfunction
+"▶1 gethex :: _ + cursor, bvar → rev
+function s:F.gethex()
+    return s:F.bisect(s:_r.aurum.bufvars[bufnr('%')].rectangles,
+                \     s:F.checkinblock)[2]
+endfunction
 "▶1 cr
 function s:F.cr()
     let bvar=s:_r.aurum.bufvars[bufnr('%')]
-    let hex=s:F.bisect(bvar.rectangles, s:F.checkinblock)[2]
+    let hex=s:F.gethex()
     echom string(hex)
 endfunction
-call s:_f.mapgroup.add('AuGlog', {'enter': {'lhs': '<CR>',
+call s:_f.mapgroup.add('AuGlog', {'Enter': {'lhs': '<CR>',
             \                               'rhs': s:F.cr,}},)
 "▶1
 execute frawor#Lockvar(s:, '_r')