Merge branch 'update-vital'

This commit is contained in:
haya14busa 2015-02-24 01:19:30 +09:00
commit 8acdfc60e5
13 changed files with 402 additions and 94 deletions

View File

@ -1,4 +1,5 @@
let s:self_version = expand('<sfile>:t:r') let s:self_version = expand('<sfile>:t:r')
let s:self_file = expand('<sfile>')
" Note: The extra argument to globpath() was added in Patch 7.2.051. " Note: The extra argument to globpath() was added in Patch 7.2.051.
let s:globpath_third_arg = v:version > 702 || v:version == 702 && has('patch51') let s:globpath_third_arg = v:version > 702 || v:version == 702 && has('patch51')
@ -300,5 +301,3 @@ endfunction
function! vital#{s:self_version}#new() abort function! vital#{s:self_version}#new() abort
return s:_import('') return s:_import('')
endfunction endfunction
let s:self_file = s:_unify_path(expand('<sfile>'))

View File

@ -8,11 +8,14 @@ function! s:_vital_loaded(V)
let s:String = s:V.import("Over.String") let s:String = s:V.import("Over.String")
let s:Signals = s:V.import("Over.Signals") let s:Signals = s:V.import("Over.Signals")
let s:Input = s:V.import("Over.Input") let s:Input = s:V.import("Over.Input")
let s:Keymapping = s:V.import("Over.Keymapping")
let s:Module = s:V.import("Over.Commandline.Modules") let s:Module = s:V.import("Over.Commandline.Modules")
let s:base.variables.modules = s:Signals.make() let s:base.variables.modules = s:Signals.make()
function! s:base.variables.modules.get_slot(val) function! s:base.variables.modules.get_slot(val)
return a:val.slot.module return a:val.slot.module
endfunction endfunction
let s:Highlight = s:V.import("Palette.Highlight")
endfunction endfunction
@ -21,7 +24,9 @@ function! s:_vital_depends()
\ "Over.String", \ "Over.String",
\ "Over.Signals", \ "Over.Signals",
\ "Over.Input", \ "Over.Input",
\ "Over.Keymapping",
\ "Over.Commandline.Modules", \ "Over.Commandline.Modules",
\ "Palette.Highlight",
\ ] \ ]
endfunction endfunction
@ -49,6 +54,7 @@ let s:base = {
\ "exit" : 0, \ "exit" : 0,
\ "keymapping" : {}, \ "keymapping" : {},
\ "suffix" : "", \ "suffix" : "",
\ "is_setted" : 0,
\ }, \ },
\ "highlights" : { \ "highlights" : {
\ "prompt" : "NONE", \ "prompt" : "NONE",
@ -85,8 +91,9 @@ function! s:base.setchar(char, ...)
" 1 の場合は既に設定されていても上書きする " 1 の場合は既に設定されていても上書きする
" 0 の場合は既に設定されていれば上書きしない " 0 の場合は既に設定されていれば上書きしない
let overwrite = get(a:, 1, 1) let overwrite = get(a:, 1, 1)
if overwrite || self.variables.input == self.char() if overwrite || self.variables.is_setted == 0
let self.variables.input = a:char let self.variables.input = a:char
let self.variables.is_setted = 1
endif endif
endfunction endfunction
@ -219,10 +226,9 @@ endfunction
function! s:base.cnoremap(lhs, rhs) function! s:base.cnoremap(lhs, rhs)
let self.variables.keymapping[a:lhs] = { let key = s:Keymapping.as_key_config(a:rhs)
\ "key" : a:rhs, let key.noremap = 1
\ "noremap" : 1, let self.variables.keymapping[a:lhs] = key
\ }
endfunction endfunction
@ -359,11 +365,34 @@ function! s:base._init_variables()
endfunction endfunction
function! s:_is_valid_highlight(name)
let highlight = s:Highlight.get(a:name)
if empty(highlight)
return 0
endif
if has("gui_running")
\ && (has_key(highlight, "guifg") || has_key(highlight, "guibg"))
return 1
elseif (has_key(highlight, "ctermfg") || has_key(highlight, "ctermbg"))
return 1
endif
return 0
endfunction
function! s:base._init() function! s:base._init()
call self._init_variables() call self._init_variables()
call self.hl_cursor_off() call self.hl_cursor_off()
if !hlexists(self.highlights.cursor) if !hlexists(self.highlights.cursor)
if s:_is_valid_highlight("Cursor")
execute "highlight link " . self.highlights.cursor . " Cursor" execute "highlight link " . self.highlights.cursor . " Cursor"
else
" Workaround by CUI Vim Cursor Highlight
" issues #92
" https://github.com/osyo-manga/vital-over/issues/92
execute "highlight " . self.highlights.cursor . " term=reverse cterm=reverse gui=reverse"
endif
endif endif
if !hlexists(self.highlights.cursor_on) if !hlexists(self.highlights.cursor_on)
execute "highlight link " . self.highlights.cursor_on . " " . self.highlights.cursor execute "highlight link " . self.highlights.cursor_on . " " . self.highlights.cursor
@ -394,6 +423,7 @@ function! s:base._input_char(char)
let self.variables.input_key = char let self.variables.input_key = char
let self.variables.char = char let self.variables.char = char
call self.setchar(self.variables.char) call self.setchar(self.variables.char)
let self.variables.is_setted = 0
call self.callevent("on_char_pre") call self.callevent("on_char_pre")
call self.insert(self.variables.input) call self.insert(self.variables.input)
call self.callevent("on_char") call self.callevent("on_char")
@ -401,9 +431,18 @@ endfunction
function! s:base._input(input, ...) function! s:base._input(input, ...)
if a:input == ""
return
endif
let self.variables.input_key = a:input let self.variables.input_key = a:input
if a:0 == 0
let keymapping = self._get_keymapping()
else
let keymapping = a:1
endif
if self.is_enable_keymapping() if self.is_enable_keymapping()
let key = s:_unmap(self._get_keymapping(), a:input) let key = s:Keymapping.unmapping(keymapping, a:input)
else else
let key = a:input let key = a:input
endif endif
@ -418,6 +457,40 @@ function! s:base._input(input, ...)
endfunction endfunction
function! s:is_input_waiting(keymapping, input)
let num = len(filter(copy(a:keymapping), 'stridx(v:key, a:input) == 0'))
return num > 1 || (num == 1 && !has_key(a:keymapping, a:input))
endfunction
function! s:base._inputting()
if !self.is_enable_keymapping()
return self._input(s:Input.getchar())
endif
let input = s:Input.getchar()
let old_line = self.getline()
let old_pos = self.getpos()
let old_forward = self.forward()
let old_backward = self.backward()
let keymapping = self._get_keymapping()
try
let t = reltime()
while s:is_input_waiting(keymapping, input)
\ && str2nr(reltimestr(reltime(t))) * 1000 < &timeoutlen
call self.setline(old_backward . input . old_forward)
call self.setpos(old_pos)
call self.draw()
let input .= s:Input.getchar(0)
endwhile
finally
call self.setline(old_line)
call self.setpos(old_pos)
endtry
call self._input(input, keymapping)
endfunction
function! s:base._update() function! s:base._update()
" call self.callevent("on_update") " call self.callevent("on_update")
" if !getchar(1) " if !getchar(1)
@ -428,7 +501,8 @@ function! s:base._update()
" call self.draw() " call self.draw()
call self.callevent("on_update") call self.callevent("on_update")
call self._input(s:Input.getchar()) call self._inputting()
" call self._input(s:Input.getchar())
if self._is_exit() if self._is_exit()
return -1 return -1
endif endif
@ -473,35 +547,6 @@ function! s:base._is_exit()
endfunction endfunction
function! s:_as_key_config(config)
let base = {
\ "noremap" : 0,
\ "lock" : 0,
\ }
return type(a:config) == type({}) ? extend(base, a:config)
\ : extend(base, {
\ "key" : a:config,
\ })
endfunction
function! s:_unmap(mapping, key)
let keys = s:String.split_by_keys(a:key)
if len(keys) > 1
return join(map(keys, 's:_unmap(a:mapping, v:val)'), '')
endif
if !has_key(a:mapping, a:key)
return a:key
endif
let rhs = s:_as_key_config(a:mapping[a:key])
let next = s:_as_key_config(get(a:mapping, rhs.key, {}))
if rhs.noremap && next.lock == 0
return rhs.key
endif
return s:_unmap(a:mapping, rhs.key)
endfunction
function! s:base._get_keymapping() function! s:base._get_keymapping()
let result = {} let result = {}
" for module in values(self.variables.modules) " for module in values(self.variables.modules)

View File

@ -101,11 +101,15 @@ endfunction
function! s:module.on_char_pre(cmdline) function! s:module.on_char_pre(cmdline)
if a:cmdline.is_input("<Over>(buffer-complete)") if a:cmdline.is_input("<Over>(buffer-complete)")
\ || a:cmdline.is_input("<Over>(buffer-complete-prev)")
if self.complete(a:cmdline) == -1 if self.complete(a:cmdline) == -1
call s:_finish() call s:_finish()
call a:cmdline.setchar('') call a:cmdline.setchar('')
return return
endif endif
if a:cmdline.is_input("<Over>(buffer-complete-prev)")
let s:count = len(s:complete_list) - 1
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("\<Tab>", "Completion")
@ -116,7 +120,8 @@ function! s:module.on_char_pre(cmdline)
if s:count >= len(s:complete_list) if s:count >= len(s:complete_list)
let s:count = 0 let s:count = 0
endif endif
elseif a:cmdline.is_input("\<Left>", "Completion") elseif a:cmdline.is_input("<Over>(buffer-complete-prev)", "Completion")
\ || a:cmdline.is_input("\<Left>", "Completion")
call a:cmdline.setchar('') call a:cmdline.setchar('')
let s:count -= 1 let s:count -= 1
if s:count < 0 if s:count < 0

View File

@ -21,11 +21,11 @@ function! s:module.on_char_pre(cmdline)
elseif a:cmdline.is_input("\<C-w>") elseif a:cmdline.is_input("\<C-w>")
let word = a:cmdline.backward_word() let word = a:cmdline.backward_word()
let backward = a:cmdline.backward()[ : -strlen(word)-1 ] let backward = a:cmdline.backward()[ : -strlen(word)-1 ]
call a:cmdline.setline(backward . a:cmdline.line.pos_word() . a:cmdline.forward()) call a:cmdline.setline(backward . a:cmdline.line.pos_char() . a:cmdline.forward())
call a:cmdline.setline(strchars(backward)) call a:cmdline.setline(strchars(backward))
call a:cmdline.setchar('') call a:cmdline.setchar('')
elseif a:cmdline.is_input("\<C-u>") elseif a:cmdline.is_input("\<C-u>")
call a:cmdline.setline(a:cmdline.line.pos_word() . a:cmdline.forward()) call a:cmdline.setline(a:cmdline.line.pos_char() . a:cmdline.forward())
call a:cmdline.setline(0) call a:cmdline.setline(0)
call a:cmdline.setchar('') call a:cmdline.setchar('')
endif endif

View File

@ -39,7 +39,7 @@ endfunction
let s:old_width = 0 let s:old_width = 0
function! s:_redraw(cmdline) function! s:_redraw(cmdline)
let left = a:cmdline.get_prompt() . a:cmdline.getline() . (empty(a:cmdline.line.pos_word()) ? " " : "") let left = a:cmdline.get_prompt() . a:cmdline.getline() . (empty(a:cmdline.line.pos_char()) ? " " : "")
let width = len(left) + 1 let width = len(left) + 1
if a:cmdline.get_suffix() != "" if a:cmdline.get_suffix() != ""
@ -71,14 +71,14 @@ endfunction
function! s:module.on_draw_pre(cmdline) function! s:module.on_draw_pre(cmdline)
if empty(a:cmdline.line.pos_word()) if empty(a:cmdline.line.pos_char())
let cursor = "echohl " . a:cmdline.highlights.cursor . " | echon ' '" let cursor = "echohl " . a:cmdline.highlights.cursor . " | echon ' '"
else else
let cursor = "echohl " . a:cmdline.highlights.cursor_on . " | " . s:_as_echon(a:cmdline.line.pos_word()) let cursor = "echohl " . a:cmdline.highlights.cursor_on . " | " . s:_as_echon(a:cmdline.line.pos_char())
endif endif
let suffix = "" let suffix = ""
if a:cmdline.get_suffix() != "" if a:cmdline.get_suffix() != ""
let suffix = s:_as_echon(s:suffix(a:cmdline.get_prompt() . a:cmdline.getline() . repeat(" ", empty(a:cmdline.line.pos_word())), a:cmdline.get_suffix())) let suffix = s:_as_echon(s:suffix(a:cmdline.get_prompt() . a:cmdline.getline() . repeat(" ", empty(a:cmdline.line.pos_char())), a:cmdline.get_suffix()))
endif endif
let self.draw_command = join([ let self.draw_command = join([
\ "echohl " . a:cmdline.highlights.prompt, \ "echohl " . a:cmdline.highlights.prompt,
@ -106,17 +106,17 @@ function! s:module.on_draw(cmdline)
" call s:echon(a:cmdline.get_prompt()) " call s:echon(a:cmdline.get_prompt())
" echohl NONE " echohl NONE
" call s:echon(a:cmdline.backward()) " call s:echon(a:cmdline.backward())
" if empty(a:cmdline.line.pos_word()) " if empty(a:cmdline.line.pos_char())
" execute "echohl" a:cmdline.highlights.cursor " execute "echohl" a:cmdline.highlights.cursor
" call s:echon(' ') " call s:echon(' ')
" else " else
" execute "echohl" a:cmdline.highlights.cursor_on " execute "echohl" a:cmdline.highlights.cursor_on
" call s:echon(a:cmdline.line.pos_word()) " call s:echon(a:cmdline.line.pos_char())
" endif " endif
" echohl NONE " echohl NONE
" call s:echon(a:cmdline.forward()) " call s:echon(a:cmdline.forward())
" if a:cmdline.get_suffix() != "" " if a:cmdline.get_suffix() != ""
" call s:echon(s:suffix(a:cmdline.get_prompt() . a:cmdline.getline() . repeat(" ", empty(a:cmdline.line.pos_word())), a:cmdline.get_suffix())) " call s:echon(s:suffix(a:cmdline.get_prompt() . a:cmdline.getline() . repeat(" ", empty(a:cmdline.line.pos_char())), a:cmdline.get_suffix()))
" endif " endif
endfunction endfunction

View File

@ -4,13 +4,13 @@ set cpo&vim
function! s:_vital_loaded(V) function! s:_vital_loaded(V)
let s:Keymapping = a:V.import("Over.Keymapping") let s:Keymapping = a:V.import("Palette.Keymapping")
endfunction endfunction
function! s:_vital_depends() function! s:_vital_depends()
return [ return [
\ "Over.Keymapping", \ "Palette.Keymapping",
\ ] \ ]
endfunction endfunction
@ -87,12 +87,13 @@ let s:vim_cmdline_mapping = {
function! s:_auto_cmap() function! s:_auto_cmap()
let cmaps = {} let cmaps = {}
let cmap_info = s:Keymapping.cmap_rhss(0, 1) let cmap_info = s:Keymapping.rhs_key_list("c", 0, 1)
" vital-over currently doesn't support <expr> nor <buffer> mappings " vital-over currently doesn't support <buffer> mappings
for c in filter(cmap_info, "v:val['expr'] ==# 0 && v:val['buffer'] ==# 0") for c in filter(cmap_info, "v:val['buffer'] ==# 0")
let cmaps[s:Keymapping.escape_key(c['lhs'])] = { let cmaps[s:Keymapping.escape_special_key(c['lhs'])] = {
\ 'noremap' : c['noremap'], \ 'noremap' : c['noremap'],
\ 'key' : s:Keymapping.escape_key(c['rhs']), \ 'key' : s:Keymapping.escape_special_key(c['rhs']),
\ 'expr' : s:Keymapping.escape_special_key(c['expr']),
\ } \ }
endfor endfor
return cmaps return cmaps
@ -108,6 +109,7 @@ function! s:vim_cmdline_mapping.keymapping(cmdline)
return self._cmaps return self._cmaps
endfunction endfunction
function! s:make_vim_cmdline_mapping() function! s:make_vim_cmdline_mapping()
return deepcopy(s:vim_cmdline_mapping) return deepcopy(s:vim_cmdline_mapping)
endfunction endfunction

View File

@ -15,7 +15,6 @@ endfunction
function! s:module.on_char_pre(cmdline) function! s:module.on_char_pre(cmdline)
if self.is_no_insert(a:cmdline.char()) if self.is_no_insert(a:cmdline.char())
\ && a:cmdline.char() == a:cmdline.variables.input
call a:cmdline.setchar("", 0) call a:cmdline.setchar("", 0)
endif endif
endfunction endfunction

View File

@ -3,53 +3,78 @@ let s:save_cpo = &cpo
set cpo&vim set cpo&vim
function! s:capture(cmd)
let verbose_save = &verbose function! s:_vital_loaded(V)
let &verbose = 0 let s:V = a:V
let s:String = s:V.import("Over.String")
endfunction
function! s:_vital_depends()
return [
\ "Over.String",
\ ]
endfunction
function! s:as_key_config(config)
let base = {
\ "noremap" : 0,
\ "lock" : 0,
\ "expr" : 0,
\ }
return type(a:config) == type({}) ? extend(base, a:config)
\ : extend(base, {
\ "key" : a:config,
\ })
endfunction
function! s:match_key(keymapping, key)
let keys = sort(keys(a:keymapping))
return get(filter(keys, 'stridx(a:key, v:val) == 0'), -1, '')
endfunction
function! s:_safe_eval(expr, ...)
call extend(l:, get(a:, 1, {}))
let result = get(a:, 2, "")
try try
redir => result let result = eval(a:expr)
execute "silent!" a:cmd catch
redir END echohl ErrorMsg | echom v:exception | echohl None
finally
let &verbose = verbose_save
endtry endtry
return result return result
endfunction endfunction
function! s:escape_key(key) function! s:_get_key(conf)
execute 'let result = "' . substitute(escape(a:key, '\"'), '\(<.\{-}>\)', '\\\1', 'g') . '"' " call extend(l:, a:conf)
return result let self = a:conf
return get(a:conf, "expr", 0) ? s:_safe_eval(a:conf.key, l:) : a:conf.key
endfunction endfunction
function! s:parse_mapping_lhs(map, mode) function! s:unmapping(keymapping, key, ...)
return matchstr(a:map, a:mode . '\s\+\zs\S\{-}\ze\s\+') let is_locking = get(a:, 1, 0)
let key = s:match_key(a:keymapping, a:key)
if key == ""
return s:String.length(a:key) <= 1 ? a:key : s:unmapping(a:keymapping, a:key[0], is_locking) . s:unmapping(a:keymapping, a:key[1:], is_locking)
endif
let map_conf = s:as_key_config(a:keymapping[key])
let next_input = s:unmapping(a:keymapping, a:key[len(key) : ], is_locking)
if map_conf.lock == 0 && is_locking
return key . next_input
elseif map_conf.lock
return s:unmapping(a:keymapping, s:_get_key(map_conf), is_locking) . next_input
else
return s:unmapping(a:keymapping, s:_get_key(map_conf), map_conf.noremap) . next_input
endif
endfunction endfunction
function! s:lhss(mode)
let maps = s:capture(a:mode . "map")
return filter(map(split(maps, "\n"), "s:parse_mapping_lhs(v:val, a:mode)"), 'v:val =~ ''\S\+''')
endfunction
function! s:rhss(mode, ...)
let abbr = get(a:, 1, 0)
let dict = get(a:, 2, 0)
return map(s:lhss(a:mode), "maparg(v:val, a:mode, abbr, dict)")
endfunction
function! s:cmap_lhss()
return s:lhss("c")
endfunction
function! s:cmap_rhss(...)
return call("s:rhss", ["c"] + a:000)
endfunction
let &cpo = s:save_cpo let &cpo = s:save_cpo
unlet s:save_cpo unlet s:save_cpo

View File

@ -46,7 +46,7 @@ function! s:base.forward()
return join(self.list[self.col+1 : ], '') return join(self.list[self.col+1 : ], '')
endfunction endfunction
function! s:base.pos_word() function! s:base.pos_char()
return get(self.list, self.col, "") return get(self.list, self.col, "")
endfunction endfunction
@ -273,5 +273,10 @@ function! s:index(haystack, needle, ...)
endfunction endfunction
function! s:length(str)
return len(s:split_by_keys(a:str))
endfunction
let &cpo = s:save_cpo let &cpo = s:save_cpo
unlet s:save_cpo unlet s:save_cpo

View File

@ -0,0 +1,99 @@
scriptencoding utf-8
let s:save_cpo = &cpo
set cpo&vim
function! s:_vital_loaded(V)
let s:V = a:V
let s:Message = s:V.import("Vim.Message")
endfunction
function! s:_vital_depends()
return [
\ "Vim.Message",
\ ]
endfunction
function! s:capture(name)
if hlexists(a:name) == 0
return ""
endif
return s:Message.capture("highlight " . a:name)
endfunction
function! s:links_to(highlight)
return matchstr(a:highlight, '^\S\+\s\+xxx links to \zs.*\ze$')
endfunction
function! s:parse_to_name(highlight)
return matchstr(a:highlight, '^\zs\w\+\ze')
endfunction
function! s:parse(highlight)
let highlight = a:highlight
if highlight !~# '^\w\+\s\+xxx\s'
return {}
endif
let name = s:parse_to_name(a:highlight)
let result = { "name " : name }
if highlight =~# '^\w\+\s\+xxx cleared'
let result.cleared = 1
return result
endif
let link = s:links_to(highlight)
if link != ""
let result.link = link
return result
endif
let attrs = [
\ "term",
\ "cterm",
\ "ctermfg",
\ "ctermbg",
\ "gui",
\ "font",
\ "guifg",
\ "guibg",
\ "guisp",
\ ]
for attr in attrs
let item = matchstr(highlight, '\s' . attr . '=\zs#\?\w\+\ze')
if item != ""
let result[attr] = item
endif
endfor
return result
endfunction
function! s:get(name, ...)
if !hlexists(a:name)
return {}
endif
let result = s:parse(substitute(s:capture(a:name), "\n", "", "g"))
if has_key(result, "link") && get(a:, 1, 0)
return s:get(result.link, get(a:, 1, 0))
else
return result
endif
endfunction
function! s:group_list()
let highlights = split(s:Message.capture("highlight"), "\n")
return filter(map(highlights, "s:parse_to_name(v:val)"), "v:val != ''")
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo

View File

@ -0,0 +1,73 @@
scriptencoding utf-8
let s:save_cpo = &cpo
set cpo&vim
function! s:_vital_loaded(V)
let s:V = a:V
let s:Message = s:V.import("Vim.Message")
endfunction
function! s:_vital_depends()
return [
\ "Vim.Message",
\ ]
endfunction
function! s:capture(...)
let mode = get(a:, 1, "")
if mode != "" && mode !~# "[nvoicsxl]"
return ""
endif
return s:Message.capture(mode . "map")
endfunction
function! s:_keymapping(str)
return a:str =~# '^[nvoicsxl]\s'
endfunction
function! s:capture_list(...)
let mode = get(a:, 1, "")
return filter(split(s:capture(mode), "\n"), "s:_keymapping(v:val)")
endfunction
function! s:escape_special_key(key)
execute 'let result = "' . substitute(escape(a:key, '\"'), '\(<.\{-}>\)', '\\\1', 'g') . '"'
return result
endfunction
function! s:parse_lhs(text, ...)
let mode = get(a:, 1, '[nvoicsxl]')
return matchstr(a:text, mode . '\s\+\zs\S\{-}\ze\s\+')
endfunction
function! s:parse_lhs_list(...)
let mode = get(a:, 1, "")
return map(s:capture_list(mode), "s:parse_lhs(v:val, mode)")
endfunction
function! s:lhs_key_list(...)
let mode = get(a:, 1, "")
return map(s:parse_lhs_list(mode), "s:escape_special_key(v:val)")
endfunction
function! s:rhs_key_list(...)
let mode = get(a:, 1, "")
let abbr = get(a:, 2, 0)
let dict = get(a:, 3, 0)
return map(s:parse_lhs_list(mode), "maparg(v:val, mode, abbr, dict)")
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo

View File

@ -0,0 +1,56 @@
let s:save_cpo = &cpo
set cpo&vim
function! s:echomsg(hl, msg) abort
execute 'echohl' a:hl
try
for m in split(a:msg, "\n")
echomsg m
endfor
finally
echohl None
endtry
endfunction
function! s:error(msg) abort
call s:echomsg('ErrorMsg', a:msg)
endfunction
function! s:warn(msg) abort
call s:echomsg('WarningMsg', a:msg)
endfunction
function! s:capture(command) abort
try
redir => out
silent execute a:command
finally
redir END
endtry
return out
endfunction
" * Get max length of |hit-enter|.
" If a string length of a message is greater than the max length,
" Vim waits for user input according to |hit-enter|.
" XXX: Those fixed values may be different between different OSes?
" Currently tested on only Windows.
function! s:get_hit_enter_max_length() abort
let maxlen = &columns * &cmdheight - 1
if &ruler
" TODO
endif
if &showcmd
let maxlen -= 11
endif
return maxlen
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo
" vim:set et ts=2 sts=2 sw=2 tw=0:

View File

@ -1,5 +1,5 @@
easymotion easymotion
651a023 9a8002c
Over.Commandline.Base Over.Commandline.Base
Over.Commandline.Modules.Cancel Over.Commandline.Modules.Cancel