Add a save dialog

Close #25
This commit is contained in:
Kien N 2011-11-07 01:44:02 +07:00
parent ae6f1592b4
commit 8c8e24e151

View File

@ -52,9 +52,9 @@ cal s:opts()
let s:lash = ctrlp#utils#lash()
" Global options
let s:glbs = { 'magic': '1', 'to': '1', 'tm': '0', 'sb': '1', 'hls': '0',
\ 'im': '0', 'report': '9999', 'sc': '0', 'ss': '0', 'siso': '0',
\ 'mfd': '200', 'gcr': 'a:block-PmenuSel-blinkon0', 'mouse': 'n' }
let s:glbs = { 'magic': 1, 'to': 1, 'tm': 0, 'sb': 1, 'hls': 0,
\ 'im': 0, 'report': 9999, 'sc': 0, 'ss': 0, 'siso': 0,
\ 'mfd': 200, 'gcr': 'a:block-PmenuSel-blinkon0', 'mouse': 'n' }
" Limiters
let [s:compare_lim, s:nocache_lim, s:mltipats_lim] = [3000, 4000, 2000]
@ -1108,6 +1108,8 @@ endf
fu! s:openfile(cmd)
try
exe a:cmd
cat /^Vim\%((\a\+)\)\=:E37/
cal s:savedialog(a:cmd)
cat
echoh Identifier
echon "CtrlP: Operation can't be completed. Make sure filename is valid."
@ -1115,6 +1117,20 @@ fu! s:openfile(cmd)
endt
endf
fu! s:savedialog(cmd)
echoh MoreMsg
cal inputsave()
let prtmsg = "Save changes to \"".bufname('%')."\"?\n[Y]es, (N)o, (C)ancel: "
let usrinput = input(prtmsg)
cal inputrestore()
echoh None
if empty(usrinput) || usrinput ==? 'y'
exe substitute(a:cmd, '^e ', 'w | e ', '')
elsei usrinput ==? 'n'
exe substitute(a:cmd, '^e ', 'new ', '')
en
endf
fu! s:walker(max, pos, dir)
retu a:dir > 0 ? a:pos < a:max ? a:pos + 1 : 0 : a:pos > 0 ? a:pos - 1 : a:max
endf