Merge branch 'improve/commandline' into master

This commit is contained in:
haya14busa 2014-02-08 01:47:44 +09:00
commit 9650037041
6 changed files with 52 additions and 19 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
@ -163,7 +164,7 @@ endfunction
function! s:base.connect(module, ...) function! s:base.connect(module, ...)
if type(a:module) == type("") if type(a:module) == type("")
return self.connect(s:get_module(a:module).make()) return call(self.connect, [s:get_module(a:module).make()] + a:000, self)
endif endif
let name = get(a:, 1, a:module.name) let name = get(a:, 1, a:module.name)
let self.variables.modules[name] = a:module let self.variables.modules[name] = a:module
@ -171,7 +172,7 @@ endfunction
function! s:base.disconnect(name) function! s:base.disconnect(name)
unlet self.variables.modules[a:name] = a:module unlet self.variables.modules[a:name]
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

@ -9,8 +9,6 @@ let s:module = {
function! s:module.on_char_pre(cmdline) function! s:module.on_char_pre(cmdline)
if a:cmdline.is_input("\<Esc>") if a:cmdline.is_input("\<Esc>")
\ || a:cmdline.is_input("\<C-c>") \ || a:cmdline.is_input("\<C-c>")
\ ||(a:cmdline.is_input("\<BS>") && a:cmdline.line.length() == 0)
\ ||(a:cmdline.is_input("\<C-h>") && a:cmdline.line.length() == 0)
" call a:cmdline.cancel() " call a:cmdline.cancel()
call a:cmdline.exit(1) call a:cmdline.exit(1)
call a:cmdline.setchar("") call a:cmdline.setchar("")

View File

@ -9,8 +9,12 @@ let s:module = {
function! s:module.on_char_pre(cmdline) function! s:module.on_char_pre(cmdline)
if a:cmdline.is_input("\<C-h>") if a:cmdline.is_input("\<C-h>")
\ || a:cmdline.is_input("\<BS>") \ || a:cmdline.is_input("\<BS>")
call a:cmdline.line.remove_prev() if a:cmdline.line.length() == 0
call a:cmdline.setchar('') return a:cmdline.exit(1)
else
call a:cmdline.line.remove_prev()
call a:cmdline.setchar('')
endif
elseif a:cmdline.is_input("\<Del>") elseif a:cmdline.is_input("\<Del>")
call a:cmdline.line.remove_pos() call a:cmdline.line.remove_pos()
call a:cmdline.setchar('') call a:cmdline.setchar('')

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

View File

@ -1,4 +1,4 @@
*easymotion.txt* Version 2.0 Last change:07 Feb 2014. *easymotion.txt* Version 2.0 Last change:08 Feb 2014.
______ __ ___ __ _ ______ __ ___ __ _
@ -528,6 +528,9 @@ Find Motion Command Line~
<Up> or <C-p> | Recall older (previous) search from history <Up> or <C-p> | Recall older (previous) search from history
<Down> or <C-n> | Recall more recent (next) search from history <Down> or <C-n> | Recall more recent (next) search from history
<C-r> {0-9a-z"%#:-=.} | Insert Register. See |c_Ctrl-R| <C-r> {0-9a-z"%#:-=.} | Insert Register. See |c_Ctrl-R|
<C-r><C-w> | Insert the Word under cursor
<C-r><C-a> | Insert the |WORD| under cursor
<C-r><C-f> | Insert the Filename under cursor
------------------------|--------------------------------------- ------------------------|---------------------------------------
<Over>(paste) | Paste yanked text to the command line <Over>(paste) | Paste yanked text to the command line
| Default: <C-v> | Default: <C-v>