Thursday, September 15, 2011

Re: Interrupt a while as CTRL_C

On 15/09/11 20:19, niva wrote:
> Hi,
>
> I am running this script and would like to interrupt it from a call
> feedkeys("\C-c") but it does not work.
>
>
> while 1
>
> calll system("myexe")
> sleep 1000m
> redraw
>
> endwhile
>
> When I type CTRL + C on my keyboard, it works and stop the while loop.
>
> When I click on amenu icon that execute :call feedkeys(("\C-c")<CR> it
> fails and does not stop the current while loop script.
>
> Thanks for help
>

(untested)

func s:Sleep(prog)
while 1
call system(a:prog)
sleep 1
redraw
if getchar(0) == 3
return
endif
endwhile
endfunc

command -nargs=1 -complete=shellcmd SleepCall call s:Sleep(<q-args>)

Invoke it at the console or in a script by
:call SleepCall('myexe')

Get out of it (I think) by hitting Ctrl-C or by feedkeys("\<C-C>").
Anything else you type before Crtl-C is discarded.


Best regards,
Tony.
--
Klein bottle for sale ... inquire within.

--
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

No comments: