Update vital-over

This commit is contained in:
haya14busa 2014-02-06 23:04:12 +09:00
parent 1b842507ba
commit 508978ea58
3 changed files with 40 additions and 12 deletions

View File

@ -137,6 +137,7 @@ function! s:base.is_input(key, ...)
let prekey = get(a:, 1, "")
return self.get_tap_key() == prekey
\ && self.char() == a:key
" \ && self.char() == (prekey . a:key)
endfunction
@ -334,6 +335,7 @@ function! s:base._main(...)
let self.variables.input_key = s:_getchar()
let self.variables.char = s:_unmap(self._get_keymapping(), self.variables.input_key)
" let self.variables.char = s:_unmap(self._get_keymapping(), self.get_tap_key() . self.variables.input_key)
call self.setchar(self.variables.char)

View File

@ -63,6 +63,7 @@ endfunction
function! s:module.complete(cmdline)
call s:_finish()
let s:old_statusline = &statusline
let backward = a:cmdline.backward()
@ -98,6 +99,10 @@ endfunction
function! s:module.on_char_pre(cmdline)
" echom "-----"
" echom a:cmdline.char()
" echom "Completion\<Tab>"
" echom "Completion\<Tab>" == a:cmdline.char()
if a:cmdline.is_input("<Over>(buffer-complete)")
if self.complete(a:cmdline) == -1
call s:_finish()
@ -106,6 +111,7 @@ function! s:module.on_char_pre(cmdline)
endif
call a:cmdline.setchar('')
call a:cmdline.tap_keyinput("Completion")
" elseif a:cmdline.is_input("\<Tab>", "Completion")
elseif a:cmdline.is_input("<Over>(buffer-complete)", "Completion")
\ || a:cmdline.is_input("\<Right>", "Completion")
call a:cmdline.setchar('')
@ -121,7 +127,7 @@ function! s:module.on_char_pre(cmdline)
endif
else
if a:cmdline.untap_keyinput("Completion")
call a:cmdline._on_char_pre()
" call a:cmdline._on_char_pre()
endif
call s:_finish()
return
@ -138,6 +144,7 @@ endfunction
function! s:module.on_leave(cmdline)
call s:_finish()
unlet! s:complete
endfunction

View File

@ -33,47 +33,66 @@ let s:module = {
function! s:module.on_enter(...)
let self.cword = expand("<cword>")
let self.cWORD = expand("cWORD")
let self.cWORD = expand("<cWORD>")
let self.cfile = expand("<cfile>")
" let self.prefix_key = ""
endfunction
function! s:module.on_char_pre(cmdline)
if a:cmdline.is_input("\<C-r>")
call a:cmdline.setchar('"')
call a:cmdline.tap_keyinput("InsertRegister")
let self.prefix_key = a:cmdline.input_key()
let self.old_line = a:cmdline.getline()
let self.old_pos = a:cmdline.getpos()
return
elseif a:cmdline.get_tap_key() == "InsertRegister"
elseif exists("self.prefix_key")
\ && a:cmdline.get_tap_key() == self.prefix_key
call a:cmdline.setline(self.old_line)
call a:cmdline.setpos(self.old_pos)
let char = a:cmdline.char()
let char = a:cmdline.input_key()
if char =~ '^[0-9a-zA-z.%#:/"\-*]$'
execute "let regist = @" . char
call a:cmdline.setchar(regist)
elseif a:cmdline.is_input('=', "InsertRegister")
elseif char == "="
call a:cmdline.setchar(s:input(a:cmdline))
elseif a:cmdline.is_input("\<C-w>", "InsertRegister")
elseif char == "\<C-w>"
call a:cmdline.setchar(self.cword)
elseif a:cmdline.is_input("\<C-a>", "InsertRegister")
elseif char == "\<C-a>"
call a:cmdline.setchar(self.cWORD)
elseif a:cmdline.is_input("\<C-f>", "InsertRegister")
elseif char == "\<C-f>"
call a:cmdline.setchar(self.cfile)
elseif a:cmdline.is_input("\<C-r>", "InsertRegister")
elseif char == "\<C-r>"
call a:cmdline.setchar('"')
else
call a:cmdline.setchar("")
endif
" elseif a:cmdline.is_input('=', self.prefix_key)
" call a:cmdline.setchar(s:input(a:cmdline))
" elseif a:cmdline.is_input("\<C-w>", self.prefix_key)
" call a:cmdline.setchar(self.cword)
" elseif a:cmdline.is_input("\<C-a>", self.prefix_key)
" call a:cmdline.setchar(self.cWORD)
" elseif a:cmdline.is_input("\<C-f>", self.prefix_key)
" call a:cmdline.setchar(self.cfile)
" elseif a:cmdline.is_input("\<C-r>", self.prefix_key)
" call a:cmdline.setchar('"')
" else
" call a:cmdline.setchar("")
" endif
endif
endfunction
function! s:module.on_char(cmdline)
if a:cmdline.is_input("\<C-r>", "InsertRegister")
if a:cmdline.is_input("\<C-r>")
call a:cmdline.tap_keyinput(self.prefix_key)
call a:cmdline.setpos(a:cmdline.getpos()-1)
else
call a:cmdline.untap_keyinput("InsertRegister")
if exists("self.prefix_key")
call a:cmdline.untap_keyinput(self.prefix_key)
unlet! self.prefix_key
endif
endif
endfunction