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, "") let prekey = get(a:, 1, "")
return self.get_tap_key() == prekey return self.get_tap_key() == prekey
\ && self.char() == a:key \ && self.char() == a:key
" \ && self.char() == (prekey . a:key)
endfunction endfunction
@ -334,6 +335,7 @@ function! s:base._main(...)
let self.variables.input_key = s:_getchar() 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.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) call self.setchar(self.variables.char)

View File

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

View File

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