Option for typing multi-byte and accented characters

Closes #276
This commit is contained in:
mattn 2012-09-12 21:32:18 +09:00 committed by Kien N
parent 6dae84fd23
commit 6089090b85
2 changed files with 49 additions and 8 deletions

View File

@ -64,6 +64,7 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] =
\ 'follow_symlinks': ['s:folsym', 0],
\ 'highlight_match': ['s:mathi', [1, 'CtrlPMatch']],
\ 'jump_to_buffer': ['s:jmptobuf', 'Et'],
\ 'key_loop': ['s:keyloop', 0],
\ 'lazy_update': ['s:lazy', 0],
\ 'match_func': ['s:matcher', {}],
\ 'match_window_bottom': ['s:mwbottom', 1],
@ -220,6 +221,9 @@ fu! s:opts(...)
let s:mxheight = max([s:mxheight, 1])
let s:glob = s:showhidden ? '.*\|*' : '*'
let s:igntype = empty(s:usrign) ? -1 : type(s:usrign)
if s:keyloop
let [s:lazy, s:glbs['imd']] = [0, 0]
en
if s:lazy
cal extend(s:glbs, { 'ut': ( s:lazy > 1 ? s:lazy : 250 ) })
en
@ -714,7 +718,7 @@ fu! s:PrtSelectJump(char)
let npos = match(lines, smartcs.'^'.chr, s:jmpchr[1] + 1)
let [jmpln, s:jmpchr] = [npos == -1 ? pos : npos, [chr, npos]]
en
keepj exe jmpln + 1
exe 'keepj norm!' ( jmpln + 1 ).'G'
if s:nolim != 1 | let s:cline = line('.') | en
if line('$') > winheight(0) | cal s:BuildPrompt(0) | en
en
@ -780,7 +784,6 @@ fu! s:MapNorms()
let cmd = substitute(pcmd, 'k%s', 'char-%d', '')
let pfunc = 'PrtFocusMap'
let ranges = [32, 33, 125, 126] + range(35, 91) + range(93, 123)
\ + range(128, 255)
for each in [34, 92, 124]
exe printf(cmd, each, pfunc, escape(nr2char(each), '"|\'))
endfo
@ -811,20 +814,34 @@ fu! s:MapSpecs()
endfo | endfo
let s:smapped = s:bufnr
endf
fu! s:KeyLoop()
wh exists('s:init') && s:keyloop
redr
let nr = getchar()
let chr = !type(nr) ? nr2char(nr) : nr
if nr >=# 0x20
cal s:PrtFocusMap(chr)
el
let cmd = matchstr(maparg(chr), ':<C-U>\zs.\+\ze<CR>$')
exe ( cmd != '' ? cmd : 'norm '.chr )
en
endw
endf
" * Toggling {{{1
fu! s:ToggleFocus()
let s:focus = s:focus ? 0 : 1
let s:focus = !s:focus
cal s:BuildPrompt(0)
endf
fu! s:ToggleRegex()
let s:regexp = s:regexp ? 0 : 1
let s:regexp = !s:regexp
cal s:PrtSwitcher()
endf
fu! s:ToggleByFname()
if s:ispath
let s:byfname = s:byfname ? 0 : 1
let s:byfname = !s:byfname
let s:mfunc = s:mfunc()
cal s:PrtSwitcher()
en
@ -838,6 +855,16 @@ fu! s:ToggleType(dir)
cal s:PrtSwitcher()
endf
fu! s:ToggleKeyLoop()
let s:keyloop = !s:keyloop
if s:keyloop
let [&ut, s:lazy] = [0, 0]
cal s:KeyLoop()
elsei has_key(s:glbs, 'ut')
let [&ut, s:lazy] = [s:glbs['ut'], 1]
en
endf
fu! s:PrtSwitcher()
let [s:force, s:matches] = [1, 1]
cal s:BuildPrompt(1)
@ -2010,6 +2037,7 @@ fu! ctrlp#init(type, ...)
cal ctrlp#setlines(s:settype(a:type))
cal s:SetDefTxt()
cal s:BuildPrompt(1)
if s:keyloop | cal s:KeyLoop() | en
endf
" - Autocmds {{{1
if has('autocmd')

View File

@ -63,8 +63,9 @@ Overview:~
|ctrlp_follow_symlinks|.......Follow symbolic links or not.
|ctrlp_lazy_update|...........Only update when typing has stopped.
|ctrlp_default_input|.........Seed the prompt with an initial string.
|ctrlp_key_loop|..............Use input looping for multi-byte input.
|ctrlp_use_migemo|............Use Migemo patterns for Japanese filenames.
|ctrlp_prompt_mappings|.......Change the mappings in the prompt.
|ctrlp_prompt_mappings|.......Change the mappings inside the prompt.
MRU mode:
|ctrlp_mruf_max|..............Max MRU entries to remember.
@ -417,6 +418,17 @@ as the default input: >
let g:ctrlp_default_input = 'anystring'
<
*'g:ctrlp_key_loop'*
An experimental feature. Set this to 1 to enable input looping for the typing
of multi-byte characters: >
let g:ctrlp_key_loop = 0
<
Note #1: when set, this option resets the |g:ctrlp_lazy_update| option.
Note #2: you can toggle this feature inside the prompt with a custom mapping: >
let g:ctrlp_prompt_mappings = { 'ToggleKeyLoop()': ['<F3>'] }
<
*'g:ctrlp_use_migemo'*
Set this to 1 to use Migemo Pattern for Japanese filenames. Migemo Search only
works in regexp mode. To split the pattern, separate words with space: >
@ -1180,13 +1192,14 @@ Special thanks:~
===============================================================================
CHANGELOG *ctrlp-changelog*
+ New options: |g:ctrlp_key_loop|,
|g:ctrlp_open_func|,
|g:ctrlp_tabpage_position|
+ Rename:
*g:ctrlp_dotfiles* -> |g:ctrlp_show_hidden|.
+ Change |g:ctrlp_switch_buffer|'s and |g:ctrlp_working_path_mode|'s type
(old values still work).
+ New key for |g:ctrlp_user_command| when it's a Dictionary: 'ignore'.
+ New options: |g:ctrlp_open_func|.
|g:ctrlp_tabpage_position|.
Before 2012/06/15~