Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyloop #276

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions autoload/ctrlp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ let [s:pref, s:opts, s:new_opts] = ['g:ctrlp_', {
\ 'highlight_match': ['s:mathi', [1, 'CtrlPMatch']],
\ 'jump_to_buffer': ['s:jmptobuf', 'Et'],
\ 'lazy_update': ['s:lazy', 0],
\ 'key_loop': ['s:keyloop', 0],
\ 'match_func': ['s:matcher', {}],
\ 'match_window_bottom': ['s:mwbottom', 1],
\ 'match_window_reversed': ['s:mwreverse', 1],
Expand Down Expand Up @@ -196,6 +197,11 @@ fu! s:opts() "{{{2
let s:mxheight = max([s:mxheight, 1])
let s:glob = s:dotfiles ? '.*\|*' : '*'
let s:igntype = empty(s:usrign) ? -1 : type(s:usrign)
if s:keyloop
let s:lazy = 0
let s:glbs['imd'] = 0
en
if s:keyloop | let s:lazy = 0 | en
if s:lazy
cal extend(s:glbs, { 'ut': ( s:lazy > 1 ? s:lazy : 250 ) })
en
Expand Down Expand Up @@ -529,6 +535,25 @@ fu! s:BuildPrompt(upd)
exe 'echoh' hibase '| echon "_" | echoh None'
en
endf

fu! s:KeyLoop()
wh exists('s:focus') && s:focus
redr
let n = getchar()
let c = type(n) == 0 ? nr2char(n) : n
if n >=# 0x20
cal s:PrtFocusMap(c)
else
let ma = matchstr(maparg(c), ':<C-U>\zs.*\ze<CR>$')
if len(ma) > 0
exe ma
else
exe "keepj norm" c
en
endif
endw
endf

" - SetDefTxt() {{{1
fu! s:SetDefTxt()
if s:deftxt == '0' || ( s:deftxt == 1 && !s:ispath ) | retu | en
Expand Down Expand Up @@ -1980,6 +2005,7 @@ fu! ctrlp#init(type, ...)
cal ctrlp#setlines(s:settype(a:type))
cal s:SetDefTxt()
cal s:BuildPrompt(1)
if s:keyloop | call s:KeyLoop() | en
endf
" - Autocmds {{{1
if has('autocmd')
Expand Down
7 changes: 7 additions & 0 deletions doc/ctrlp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Overview:~
|ctrlp_arg_map| Intercept <c-y> and <c-o> or not.
|ctrlp_follow_symlinks| Follow symbolic links or not.
|ctrlp_lazy_update| Only update when typing has stopped.
|ctrlp_key_loop| Use event loop. Useful for multi-bytes input.
|ctrlp_default_input| Seed the prompt with an initial string.
|ctrlp_use_migemo| Use Migemo patterns for Japanese filenames.
|ctrlp_prompt_mappings| Change the mappings in the prompt.
Expand Down Expand Up @@ -391,6 +392,12 @@ after typing's been stopped for a certain amount of time: >
If is 1, update after 250ms. If bigger than 1, the number will be used as the
delay time in milliseconds.

*'g:ctrlp_key_loop'*
Set this to 1 to enable the key event loop. Useful for multi-byte input: >
let g:ctrlp_key_loop = 0
<
Note that This is experimental feature.

*'g:ctrlp_default_input'*
Set this to 1 to enable seeding the prompt with the current file's relative
path: >
Expand Down