Révision | 023b91234643d148acc0b0aac3fff7ed6df0c427 (tree) |
---|---|
l'heure | 2022-06-22 16:32:02 |
Auteur | badcoff33 <none@none> |
Commiter | badcoff33 |
work of TextYankPost feature
@@ -64,22 +64,26 @@ function visuals#blend_down() | ||
64 | 64 | endif |
65 | 65 | endfunction |
66 | 66 | |
67 | -function! visuals#blink_on_yank_now() | |
68 | - call prop_type_delete('TP_Visual') | |
69 | - call prop_type_add('TP_Visual', #{ highlight: 'Visual' }) | |
70 | - let al = getpos("'[")[1] | |
71 | - let ac = getpos("'[")[2] | |
72 | - let bl = getpos("']")[1] | |
73 | - let bc = getpos("']")[2] | |
74 | - let ac = (ac > 1000) ? 1 : ac | |
75 | - let bc = (bc > 1000) ? len(getline(bl)) : bc | |
76 | - call prop_add_list( | |
77 | - \ #{bufnr: bufnr("%"), id: 1, type: 'TP_Visual'}, | |
78 | - \ [[al, ac, bl, bc + 1]]) | |
79 | - call timer_start(200, "BlinkOffYank", {'repeat': 1}) | |
67 | +" avoid error 2nd from prop_type_add by delete it first | |
68 | +call prop_type_delete('text_prop_yank') | |
69 | +call prop_type_add('text_prop_yank', #{ highlight: 'CursorLine' }) | |
70 | + | |
71 | +function! visuals#blink_on_yank_now(lead_pos, trail_pos) | |
72 | + if v:event['visual'] == v:true | |
73 | + return | |
74 | + endif | |
75 | + if v:event['operator'] == 'd' | |
76 | + return | |
77 | + endif | |
78 | + if a:trail_pos[2] == 0x7fffffff | |
79 | + let sp = len(getline(a:trail_pos[1])) | |
80 | + else | |
81 | + let sp = a:trail_pos[2] | |
82 | + endif | |
83 | + call prop_add_list(#{bufnr: bufnr("%"), id: 1, type: 'text_prop_yank'}, [[a:lead_pos[1], a:lead_pos[2], a:trail_pos[1], sp + 1]]) | |
84 | + call timer_start(200, "visuals#blink_on_yank_off", {'repeat': 1}) | |
80 | 85 | endfunction |
81 | 86 | |
82 | 87 | function! visuals#blink_on_yank_off(tid) |
83 | 88 | call prop_clear(1, line("$")) |
84 | - call prop_type_delete('TP_Visual') | |
85 | 89 | endfunction |
@@ -13,6 +13,6 @@ augroup END | ||
13 | 13 | noremap <Leader><Leader> <cmd>HlWord<CR> |
14 | 14 | |
15 | 15 | autocmd! TextYankPost |
16 | -autocmd TextYankPost * call visuals#blink_on_yank_now() | |
16 | +autocmd TextYankPost * call visuals#blink_on_yank_now(getpos("'["), getpos("']")) | |
17 | 17 | |
18 | 18 | BlinkyOn " default to ON |
@@ -248,31 +248,6 @@ let g:term = &term | ||
248 | 248 | syntax on |
249 | 249 | |
250 | 250 | runtime plugins.vim |
251 | -function! BlinkOnYank() | |
252 | - let ml = getmarklist("%") | |
253 | - for e in ml | |
254 | - if e["mark"] == "'[" | |
255 | - let lead_pos = e["pos"] | |
256 | - endif | |
257 | - if e["mark"] == "']" | |
258 | - let trail_pos = e["pos"] | |
259 | - endif | |
260 | - endfor | |
261 | - call prop_type_delete('TP_Visual') | |
262 | - call prop_type_add('TP_Visual', #{ highlight: 'Visual' }) | |
263 | - if trail_pos[2] == -2147483648 | |
264 | - let sp = len(getline(trail_pos[1])) | |
265 | - else | |
266 | - let sp = trail_pos[2] | |
267 | - endif | |
268 | - call prop_add_list(#{bufnr: bufnr("%"), id: 1, type: 'TP_Visual'}, [[lead_pos[1], lead_pos[2], trail_pos[1], sp + 1]]) | |
269 | - call timer_start(200, "BlinkOffYank", {'repeat': 1}) | |
270 | -endfunction | |
271 | -function! BlinkOffYank(tid) | |
272 | - call prop_clear(1, line("$")) | |
273 | - call prop_type_delete('TP_Visual') | |
274 | -endfunction | |
275 | -autocmd! TextYankPost | |
276 | -autocmd TextYankPost * call BlinkOnYank() | |
251 | + | |
277 | 252 | " vim:sw=2:tw=78:nocindent:foldmethod=marker:nofen: |
278 | 253 |