Le jeudi 5 avril 2018 22:47:38 UTC+2, Bram Moolenaar a écrit :
> Niva wrote:
>
> > What event can be used to know inactivity of vim for a long time?
>
> Use CursorHold? 'updatetime' can be used to set the time.
> Unfortunately, this option is used for other things as well (flushing
> the swap file).
>
> --
> hundred-and-one symptoms of being an internet addict:
> 105. When someone asks you for your address, you tell them your URL.
>
> /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
> /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
> \\\ an exciting new programming language -- http://www.Zimbu.org ///
> \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
plugin/foo.vim
scriptencoding utf-8
au FocusLost * call monitoring#unpause()
au FocusGained * call monitoring#pause()
au VimEnter * call monitoring#main()
autoload/foo.vim
scriptencoding utf-8
" client code
fu Foo()
echomsg "Save your data"
echomsg "Save your data"
echomsg "Save your data"
endfunc
let g:monitorfunc = 'Foo'
let s:startmonitoring = "Start Timer to monitoring"
let s:starttime = 0.0
let s:timeoutkill = 10
let s:timer = {}
fun! monitoring#main() "{{{
echomsg s:startmonitoring
let s:starttime = reltime()
let s:timer = timer_start(500, 'monitoring#handler', {'repeat': -1})
call timer_pause(s:timer,1)
endfunc "}}}
fun! monitoring#pause() "{{{
echomsg "Pause monitoring"
call timer_pause(s:timer,1)
endfunc
"}}}
fun! monitoring#unpause() "{{{
let s:starttime = reltime()
echomsg "Unpause monitoring"
call timer_pause(s:timer,0)
endfunc
"}}}
fun! monitoring#handler(timer) "{{{
let elapsedtime = reltimestr(reltime(s:starttime))
if str2float(elapsedtime) > s:timeoutkill
echomsg "Monitoring, timeout ! time to save your data !! "
call funcref(g:monitorfunc)
else
echomsg "Monitoring, alive...".elapsedtime
endif
endfunc "}}}
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment