This commit is contained in:
haya14busa 2016-01-22 09:12:33 +09:00
parent d00540912c
commit 799491e007

View File

@ -471,16 +471,28 @@ function! s:SetLines(lines, key) " {{{
endfunction " }}} endfunction " }}}
" -- Get characters from user input ------ " -- Get characters from user input ------
function! s:GetChar() " {{{ function! s:GetChar(...) abort "{{{
let char = getchar() let mode = get(a:, 1, 0)
if char == 27 || char == 3 while 1
" Escape or <C-c> key pressed " Workaround for https://github.com/osyo-manga/vital-over/issues/53
redraw try
call s:Message('Cancelled') let char = call('getchar', a:000)
return '' catch /^Vim:Interrupt$/
endif let char = 3 " <C-c>
return nr2char(char) endtry
endfunction " }}} if char == 27 || char == 3
" Escape or <C-c> key pressed
redraw
call s:Message('Cancelled')
return ''
endif
" Workaround for the <expr> mappings
if string(char) !=# "\x80\xfd`"
return mode == 1 ? !!char
\ : type(char) == type(0) ? nr2char(char) : char
endif
endwhile
endfunction "}}}
" -- Find Motion Helper ------------------ " -- Find Motion Helper ------------------
function! s:findMotion(num_strokes, direction) "{{{ function! s:findMotion(num_strokes, direction) "{{{