zsh-workers
 help / color / mirror / code / Atom feed
* zcurses input timeout and window resizing
@ 2015-09-30  9:41 Andrew Janke
  2015-09-30 10:49 ` Andrew Janke
  2015-09-30 13:34 ` Jun T.
  0 siblings, 2 replies; 4+ messages in thread
From: Andrew Janke @ 2015-09-30  9:41 UTC (permalink / raw)
  To: Zsh hackers list

Hi, Zsh folks,

I'm running in to an issue with the interaction between "zcurses 
timeout"/"zcurses input" and terminal window resizing. On OS X, it seems 
that if you resize a window while waiting on a "zcurses input", the 
timeout will effectively be ignored, and "zcurses input" will block 
until actual input is received.

Sounds like this was a known possible issue. The Src/Modules/curses.c 
file has a comment due to it interacting poorly with unspecified 
behavior of getch wrt handled signals.

https://github.com/zsh-users/zsh/blob/6ff0628182ac74bbf22dc02edcc9a148f12767db/Src/Modules/curses.c#L1072-L1104

      * There remains a potential bug here in that, if the caller has set
      * a timeout for the read [see zccmd_timeout()] the countdown is very
      * likely restarted on every call to wgetch(), so an interrupted call
      * might wait much longer than desired.

I think I'm actually running in to that potential bug here on Mac OS X 
10.9.5.

Test code:

#!/bin/zsh

# test_zcurses_resize.zsh
#
# Test how window resizing interacts with zcurses

zmodload zsh/curses

zcurses init
zcurses timeout stdscr 1000

logfile=test_zcurses_resize.log
rm -f $logfile
while (( 1 )); do
   printf "%4s: %s %s stty: %s\n" $SECONDS $LINES $COLUMNS "$(stty 
size)" >>$logfile
   zcurses input stdscr key keypad mouse
   printf "%4s: input received: \$?=%s k='%s' kp='%s' m='%s'\n" \
     $SECONDS $? "$key" "$keypad" "$mouse" >>$logfile
done

# end test_zcurses_resize.zsh

"watch -n 0.5 tail -15 test_zcurses_resize.log" to see results.

When I run it on OS X (in iTerm2 or Terminal.app) and resize the window, 
it stops producing new output indefinitely, until I actually hit a key 
or do mouse input. On Debian Linux 8, it still works after the resize, 
with the "zcurses input" timing out as expected. Tested on both zsh 
5.0.2 and 5.1.1.

Any known workarounds to this? Maybe it's dependent on the version of 
curses? My OS X zsh is linked against libncurses.5.4.dylib; the Debian 
one against libncursesw.so.5.

The "tetriscurses" example program seems to stay live through window 
sizes on the same OS X system, and I can't figure out what it's doing 
differently to keep the timeout working through window resizes.

Cheers,
Andrew


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: zcurses input timeout and window resizing
  2015-09-30  9:41 zcurses input timeout and window resizing Andrew Janke
@ 2015-09-30 10:49 ` Andrew Janke
  2015-09-30 13:34 ` Jun T.
  1 sibling, 0 replies; 4+ messages in thread
From: Andrew Janke @ 2015-09-30 10:49 UTC (permalink / raw)
  To: Zsh hackers list

On 9/30/15 5:41 AM, Andrew Janke wrote:
> I'm running in to an issue with the interaction between "zcurses 
> timeout"/"zcurses input" and terminal window resizing. On OS X, it 
> seems that if you resize a window while waiting on a "zcurses input", 
> the timeout will effectively be ignored, and "zcurses input" will 
> block until actual input is received.

> Any known workarounds to this? Maybe it's dependent on the version of 
> curses? My OS X zsh is linked against libncurses.5.4.dylib; the Debian 
> one against libncursesw.so.5.
>
> The "tetriscurses" example program seems to stay live through window 
> sizes on the same OS X system, and I can't figure out what it's doing 
> differently to keep the timeout working through window resizes.
Think I partially answered my own question here: I rebuilt a zsh 5.1.1 
against ncurses 6.0 on OS X, and on that one, the timeouts work through 
window resizes. Still curious how tetriscurses seems to work even with 
ncurses 5.4.

Andrew


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: zcurses input timeout and window resizing
  2015-09-30  9:41 zcurses input timeout and window resizing Andrew Janke
  2015-09-30 10:49 ` Andrew Janke
@ 2015-09-30 13:34 ` Jun T.
  2015-09-30 16:41   ` Andrew Janke
  1 sibling, 1 reply; 4+ messages in thread
From: Jun T. @ 2015-09-30 13:34 UTC (permalink / raw)
  To: zsh-workers


2015/09/30 18:41, Andrew Janke <floss@apjanke.net> wrote:
> 
>  Tested on both zsh 5.0.2 and 5.1.1.

Are you sure about this?
Testing on OS X 10.9.5 indicates that /bin/zsh (5.0.2, installed
by Apple) has the problem, but 5.1.1 (my own build, but linked to
/usr/bin/libncurses.5.4.dylib, which is installed by Apple) works OK.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: zcurses input timeout and window resizing
  2015-09-30 13:34 ` Jun T.
@ 2015-09-30 16:41   ` Andrew Janke
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Janke @ 2015-09-30 16:41 UTC (permalink / raw)
  To: Jun T., zsh-workers



On 9/30/15 9:34 AM, Jun T. wrote:
> 2015/09/30 18:41, Andrew Janke <floss@apjanke.net> wrote:
>>   Tested on both zsh 5.0.2 and 5.1.1.
> Are you sure about this?
> Testing on OS X 10.9.5 indicates that /bin/zsh (5.0.2, installed
> by Apple) has the problem, but 5.1.1 (my own build, but linked to
> /usr/bin/libncurses.5.4.dylib, which is installed by Apple) works OK.
Yes, though I don't know if there are other relevant differences between 
the builds. I tested it against the system /bin/zsh (5.0.2) and a 
Homebrew-managed /usr/local/bin/zsh (5.1.1), and both had the problem.

I'll see if I can narrow it down further by adjusting the build options 
and seeing if I can isolate one that makes the difference.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-09-30 16:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-30  9:41 zcurses input timeout and window resizing Andrew Janke
2015-09-30 10:49 ` Andrew Janke
2015-09-30 13:34 ` Jun T.
2015-09-30 16:41   ` Andrew Janke

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).