auto commit

This commit is contained in:
Supasorn Suwajanakorn 2013-05-13 22:53:51 -07:00
parent 229a190ceb
commit 27a8f3ddb4
2 changed files with 38 additions and 3 deletions

View File

@ -358,8 +358,10 @@
" }}} " }}}
" Prepare marker lines {{{ " Prepare marker lines {{{
let lines = {} let lines = {}
let lines_marks = {}
let hl_coords = [] let hl_coords = []
let hl_coords2 = [] " Highlight for two characters let hl_coords2 = [] " Highlight for two characters
let overlap_coords = [] " Highlight for two characters
let coord_key_dict = s:CreateCoordKeyDict(a:groups) let coord_key_dict = s:CreateCoordKeyDict(a:groups)
@ -375,6 +377,8 @@
let current_line = getline(line_num) let current_line = getline(line_num)
let lines[line_num] = { 'orig': current_line, 'marker': current_line, 'mb_compensation': 0 } let lines[line_num] = { 'orig': current_line, 'marker': current_line, 'mb_compensation': 0 }
let lines_marks[line_num] = {}
endif endif
" Compensate for byte difference between marker " Compensate for byte difference between marker
@ -405,12 +409,24 @@
" Add highlighting coordinates " Add highlighting coordinates
if target_key_len == 1 if target_key_len == 1
if has_key(lines_marks[line_num], col_num)
call add(overlap_coords, '\%' . line_num . 'l\%' . col_num . 'c')
else
call add(hl_coords, '\%' . line_num . 'l\%' . col_num . 'c') call add(hl_coords, '\%' . line_num . 'l\%' . col_num . 'c')
endif
let lines_marks[line_num][col_num] = 1
else else
let c = 0 let c = 0
while c < target_key_len while c < target_key_len
if has_key(lines_marks[line_num], col_num + c)
call add(overlap_coords, '\%' . line_num . 'l\%' . (col_num + c) . 'c')
else
call add(hl_coords2, '\%' . line_num . 'l\%' . (col_num + c) . 'c') call add(hl_coords2, '\%' . line_num . 'l\%' . (col_num + c) . 'c')
endif
let lines_marks[line_num][col_num + c] = 1
let c += 1 let c += 1
endwhile endwhile
endif endif
@ -425,7 +441,13 @@
" }}} " }}}
" Highlight targets {{{ " Highlight targets {{{
let target_hl_id = matchadd(g:EasyMotion_hl_group_target, join(hl_coords, '\|'), 1) let target_hl_id = matchadd(g:EasyMotion_hl_group_target, join(hl_coords, '\|'), 1)
if len(hl_coords2) > 0
let target_hl2_id = matchadd(g:EasyMotion_hl2_group_target, join(hl_coords2, '\|'), 1) let target_hl2_id = matchadd(g:EasyMotion_hl2_group_target, join(hl_coords2, '\|'), 1)
endif
if len(overlap_coords) > 0
let target_overlap_id = matchadd(g:EasyMotion_hl_group_overlap, join(overlap_coords, '\|'), 1)
endif
" }}} " }}}
try try
@ -450,6 +472,9 @@
if exists('target_hl2_id') if exists('target_hl2_id')
call matchdelete(target_hl2_id) call matchdelete(target_hl2_id)
endif endif
if exists('target_overlap_id')
call matchdelete(target_overlap_id)
endif
" }}} " }}}
redraw redraw

View File

@ -21,6 +21,7 @@
\ \
\ , 'hl_group_target' : 'EasyMotionTarget' \ , 'hl_group_target' : 'EasyMotionTarget'
\ , 'hl2_group_target' : 'EasyMotionTarget2' \ , 'hl2_group_target' : 'EasyMotionTarget2'
\ , 'hl_group_overlap' : 'EasyMotionOverlap'
\ , 'hl_group_shade' : 'EasyMotionShade' \ , 'hl_group_shade' : 'EasyMotionShade'
\ }) \ })
" }}} " }}}
@ -37,6 +38,13 @@
\ , 'cterm' : ['NONE', 'red' , 'bold'] \ , 'cterm' : ['NONE', 'red' , 'bold']
\ } \ }
let s:target_hl_overlap_defaults = {
\ 'gui' : ['NONE', '#ff0000' , 'bold']
\ , 'cterm256': ['NONE', '196' , 'bold']
\ , 'cterm' : ['NONE', 'red' , 'bold']
\ }
let s:shade_hl_defaults = { let s:shade_hl_defaults = {
\ 'gui' : ['NONE', '#777777' , 'NONE'] \ 'gui' : ['NONE', '#777777' , 'NONE']
\ , 'cterm256': ['NONE', '242' , 'NONE'] \ , 'cterm256': ['NONE', '242' , 'NONE']
@ -45,6 +53,7 @@
call EasyMotion#InitHL(g:EasyMotion_hl_group_target, s:target_hl_defaults) call EasyMotion#InitHL(g:EasyMotion_hl_group_target, s:target_hl_defaults)
call EasyMotion#InitHL(g:EasyMotion_hl2_group_target, s:target_hl2_defaults) call EasyMotion#InitHL(g:EasyMotion_hl2_group_target, s:target_hl2_defaults)
call EasyMotion#InitHL(g:EasyMotion_hl_group_overlap, s:target_hl_overlap_defaults)
call EasyMotion#InitHL(g:EasyMotion_hl_group_shade, s:shade_hl_defaults) call EasyMotion#InitHL(g:EasyMotion_hl_group_shade, s:shade_hl_defaults)
" Reset highlighting after loading a new color scheme {{{ " Reset highlighting after loading a new color scheme {{{
@ -53,6 +62,7 @@
autocmd ColorScheme * call EasyMotion#InitHL(g:EasyMotion_hl_group_target, s:target_hl_defaults) autocmd ColorScheme * call EasyMotion#InitHL(g:EasyMotion_hl_group_target, s:target_hl_defaults)
autocmd ColorScheme * call EasyMotion#InitHL(g:EasyMotion_hl2_group_target, s:target_hl2_defaults) autocmd ColorScheme * call EasyMotion#InitHL(g:EasyMotion_hl2_group_target, s:target_hl2_defaults)
autocmd ColorScheme * call EasyMotion#InitHL(g:EasyMotion_hl_group_overlap, s:target_hl_overlap_defaults)
autocmd ColorScheme * call EasyMotion#InitHL(g:EasyMotion_hl_group_shade, s:shade_hl_defaults) autocmd ColorScheme * call EasyMotion#InitHL(g:EasyMotion_hl_group_shade, s:shade_hl_defaults)
augroup end augroup end
" }}} " }}}