Patch 7.4.1594

53 views
Skip to first unread message

Bram Moolenaar

unread,
Mar 19, 2016, 9:11:43 AM3/19/16
to vim...@googlegroups.com

Patch 7.4.1594
Problem: Timers don't work on Unix.
Solution: Add missing code.
Files: src/os_unix.c


*** ../vim-7.4.1593/src/os_unix.c 2016-03-11 22:52:00.738438072 +0100
--- src/os_unix.c 2016-03-19 14:05:21.646727700 +0100
***************
*** 176,181 ****
--- 176,182 ----
static pid_t wait4pid(pid_t, waitstatus *);

static int WaitForChar(long);
+ static int WaitForCharOrMouse(long);
#if defined(__BEOS__) || defined(VMS)
int RealWaitForChar(int, long, int *);
#else
***************
*** 5347,5359 ****
}

/*
! * Wait "msec" msec until a character is available from the keyboard or from
! * inbuf[]. msec == -1 will block forever.
* When a GUI is being used, this will never get called -- webb
*/
static int
WaitForChar(long msec)
{
#ifdef FEAT_MOUSE_GPM
int gpm_process_wanted;
#endif
--- 5348,5397 ----
}

/*
! * Wait "msec" msec until a character is available from the mouse, keyboard,
! * from inbuf[].
! * "msec" == -1 will block forever.
! * Invokes timer callbacks when needed.
* When a GUI is being used, this will never get called -- webb
*/
static int
WaitForChar(long msec)
{
+ #ifdef FEAT_TIMERS
+ long due_time;
+ long remaining = msec;
+
+ /* When waiting very briefly don't trigger timers. */
+ if (msec >= 0 && msec < 10L)
+ return WaitForCharOrMouse(msec);
+
+ while (msec < 0 || remaining > 0)
+ {
+ /* Trigger timers and then get the time in msec until the next one is
+ * due. Wait up to that time. */
+ due_time = check_due_timer();
+ if (due_time <= 0 || (msec > 0 && due_time > remaining))
+ due_time = remaining;
+ if (WaitForCharOrMouse(due_time))
+ return TRUE;
+ if (msec > 0)
+ remaining -= due_time;
+ }
+ return FALSE;
+ #else
+ return WaitForCharOrMouse(msec);
+ #endif
+ }
+
+ /*
+ * Wait "msec" msec until a character is available from the mouse or keyboard
+ * or from inbuf[].
+ * "msec" == -1 will block forever.
+ * When a GUI is being used, this will never get called -- webb
+ */
+ static int
+ WaitForCharOrMouse(long msec)
+ {
#ifdef FEAT_MOUSE_GPM
int gpm_process_wanted;
#endif
*** ../vim-7.4.1593/src/version.c 2016-03-19 13:49:39.460590857 +0100
--- src/version.c 2016-03-19 14:06:12.342197470 +0100
***************
*** 750,751 ****
--- 750,753 ----
{ /* Add new patch number below this line */
+ /**/
+ 1594,
/**/

--
ASCII stupid question, get a stupid ANSI.

/// Bram Moolenaar -- Br...@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 ///

h_east

unread,
Mar 19, 2016, 10:31:16 AM3/19/16
to vim_dev
Hi Bram,

2016-3-19(Sat) 22:11:43 UTC+9 Bram Moolenaar:

Yeah, I had been waiting for this patch :-)

I checked this patch.
I found many wrong redraw behavior.

sample.vim
----
let g:tt_cnt = 0
func MyHandler(timer)
let g:tt_cnt += 1
echo g:tt_cnt
endfunc
let timer = timer_start(500, 'MyHandler', {'repeat': 200})
----

$ vim -Nu NONE -S ttt.vim -c "set wildmenu"

1. type :
--> over write by timer callback's echo message.

2. type <Esc>:set <TAB>
--> wild menu is over write unexpected statusline redraw.

3. type <ESC>:ver<CR>
--> `-- More --` duplicate.
and type <Space>
--> timer callback's echo message displayed more line.

We need a screen drawing in other than the normal mode and the insert mode?

I don't know well, but wrote a patch.
How about this?

--
Best regards,
Hirohito Higashi (a.k.a. h_east)

timer_redraw.patch

h_east

unread,
Mar 19, 2016, 10:33:33 AM3/19/16
to vim_dev

> $ vim -Nu NONE -S ttt.vim -c "set wildmenu"

Sorry for typo.
$ vim -Nu NONE -S sample.vim -c "set wildmenu"

Bram Moolenaar

unread,
Mar 19, 2016, 12:05:42 PM3/19/16
to h_east, vim_dev

Hirohito Higashi wrote:

> Hi Bram,
>
> 2016-3-19(Sat) 22:11:43 UTC+9 Bram Moolenaar:
> > Patch 7.4.1594
> > Problem: Timers don't work on Unix.
> > Solution: Add missing code.
> > Files: src/os_unix.c

[...]

> Yeah, I had been waiting for this patch :-)

Sorry, somehow I just forgot to include it with the patch that went out
earlier.

> I checked this patch.
> I found many wrong redraw behavior.
>
> sample.vim
> ----
> let g:tt_cnt = 0
> func MyHandler(timer)
> let g:tt_cnt += 1
> echo g:tt_cnt
> endfunc
> let timer = timer_start(500, 'MyHandler', {'repeat': 200})
> ----
>
> $ vim -Nu NONE -S ttt.vim -c "set wildmenu"
>
> 1. type :
> --> over write by timer callback's echo message.
>
> 2. type <Esc>:set <TAB>
> --> wild menu is over write unexpected statusline redraw.
>
> 3. type <ESC>:ver<CR>
> --> `-- More --` duplicate.
> and type <Space>
> --> timer callback's echo message displayed more line.
>
> We need a screen drawing in other than the normal mode and the insert mode?
>
> I don't know well, but wrote a patch.
> How about this?

Thanks. A timer outputting text is bound to cause some redraw problems,
but we can try to minimize the damage. Besides what you did I think we
should also avoid that the more prompt is used recursively. And there
is a problem at the hit-Enter prompt. I'll fix that, but there may be
more problems.

--
hundred-and-one symptoms of being an internet addict:
90. Instead of calling you to dinner, your spouse sends e-mail.
Reply all
Reply to author
Forward
0 new messages