Friday, August 26, 2011

Re: getchar() blocks the output

On 06:50 Fri 26 Aug , sinbad wrote:
> hi,
>
> i've the following function.
>
> 1 fun! Dosome()
> 2 vertical botright new
> 3 setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
> 4 setlocal nowrap
> 5 setlocal nonu
> 6
> 7 for m in g:list
> 8 let txt = printf("%s %-50s %-4d %-50s", m[0], m[1]. "()",
> m[2], m[3])
> 9 put =txt
> 10 endfor
> 11
> 12 let char = getchar()
> 13 setlocal nomodifiable
> 14 silent! "'".char
> 15 endfun
>
> basically i want to display a list of choices for the user and based
> on the users input i will take some action. so the lines 7-8 will
> actually list the users with some choices in a new window. but the
> window is not getting opened because of getchar(), according to
> the code that's what suppose to happen. why getchar() is blocking
> output, is there any way around this.
>
> thanks
Hi,

There are vim functions to ask user for input see the various functions at
':help interactive-functions'. Note that if you want an approach using ':echo'
(or ':echomsg') you also might need to use ':redraw'

Best,
Marcin
>
> --
> 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 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: