Herold Heiko wrote:
From: Hrvoje Niksic [mailto:[EMAIL PROTECTED]
..
Yes. Specifically, Unix's SIGWINCH simply sets a flag that means
window size might have changed, please check it out. That is
because checking window size on each refresh would perform an
unnecessary ioctl.
One thing we could do for Windows is check for window size every
second or so.
I agree, but I have no idea how taxing those GetStdHandle() and
GetConsoleScreenBufferInfo() are.
Maybe David can shed more light on this, or even profile a bit.
Possibly the handle could be cached, saving at least the GetStdHandle() bit.
Heiko
Yes, GetStdHandle() would only need to be called once unless the handle
were to change during execution (fork_to_background()?).
I haven't done any exhaustive profiling but the attached patch doesn't
seem to affect performance. It calls determine_screen_width() every time
the progress bar is updated (~5 times per second?).
Note: I'm not suggesting we use the patch as-is, it's just a test.
It might be possible to implement something similar to SIGWINCH using
WinEvents, but that's not really what they were designed for. They were
designed to be used by accessibility software (screen readers, etc.),
and it may not be available on older versions of Windows.
How often do people change the size of the screen buffer while a command
is running?
Index: progress.c
===
RCS file: /pack/anoncvs/wget/src/progress.c,v
retrieving revision 1.43
diff -u -r1.43 progress.c
--- progress.c 2004/01/28 01:02:26 1.43
+++ progress.c 2004/01/28 19:37:50
@@ -579,6 +579,22 @@
/* Don't update more often than five times per second. */
return;
+#ifdef WINDOWS
+{
+ int old_width = screen_width;
+ screen_width = determine_screen_width ();
+ if (!screen_width)
+ screen_width = DEFAULT_SCREEN_WIDTH;
+ else if (screen_width MINIMUM_SCREEN_WIDTH)
+ screen_width = MINIMUM_SCREEN_WIDTH;
+ if (screen_width != old_width)
+ {
+ bp-width = screen_width - 1;
+ bp-buffer = xrealloc (bp-buffer, bp-width + 1);
+ }
+}
+#endif
+
create_image (bp, dltime);
display_image (bp-buffer);
bp-last_screen_update = dltime;