From: edgar <edg...@we...> - 2010-09-23 20:40:15
|
Hi CLISP devels, Sorry for the rather lengthy post, this is _NOT_ a really urgent topic and doesn't need a quick reply. This post is based on a discussion on c.l.l. about CLISP's SCREEN package. edgar [me] wrote on comp.lang.lisp: > ... under Debian, the SCREEN package only works correctly if the terminal > window has an exact size of 80x25 characters, with smaller terminal window > sizes the SCREEN output gets garbled and produces unreadable nonsense > (also with the examples from "screen.tst"), with bigger terminal window > sizes the CLISP output in the terminal window gets garbled after the > SCREEN functions have finished ... After some fiddling with the Lisp functions and reading the "Window Stream" section of "src/stream.d" several times, I came to the following conclusion: The only real problem seems to be that the terminal geometry gets initialized at CLISP's start-up time and doesn't get updated if the user resizes the terminal window. For example, I start CLISP in a 80x24 terminal window and type: [1]> (screen:with-window (screen:window-size screen:*window*)) 24 ; 80 Now I resize the terminal window to any other size, but CLISP still returns: [2]> (screen:with-window (screen:window-size screen:*window*)) 24 ; 80 If I now give any output to the *window* stream, CLISP assumes a wrong terminal size and produces garbled nonsense. If I resize the terminal window back to 80x24, everything works OK again. I assume the SCREEN package had been written for a real terminal environment (e.g. using CLISP from the Unix/Linux login prompt), where the size of the terminal window doesn't change after CLISP has started. Unfortunately in a window-based environment the terminal window can be changed by the user at will and at any random time. Two possible solutions: 1) Leaving the SCREEN package as-is and updating the "Random Screen Access" section in the CLISP impnotes, e.g. by a preamble where is explained that the window-size does not get updated after CLISP has been started. Also the "size" and "coordinate" explanations of several functions are incorrect for window-based systems. Updating the docs is a task I can easily do myself. I then would add a tutorial, e.g. to the cliki how to use CLISP's SCREEN package together with EXT:*KEYBOARD-INPUT*. 2) Adding geometry checks before every output function, where I'm not sure if this is a really good idea, because lots of run-time tests do not necessarily speed-up program execution (carefully said) and there is not only one terminal emulator in "src/stream.d", but several for Unix and Windows, littered with a myriad of #ifdefs, so I'm not sure if the result would not be worse than before, at least if I do this myself. Question: Is there anybody, who uses the SCREEN package frequently, and who can tell me if adding geometry checks is a really good or a bad idea? Thanks, - edgar -- The author of this email does not necessarily endorse the following advertisements, which are the sole responsibility of the advertiser: |
From: Vladimir T. <vtz...@gm...> - 2010-09-23 21:27:13
|
On 9/23/10, edgar <edg...@we...> wrote: > For example, I start CLISP in a 80x24 terminal window and type: > > [1]> (screen:with-window (screen:window-size screen:*window*)) > 24 ; > 80 > > Now I resize the terminal window to any other size, but CLISP still returns: > > [2]> (screen:with-window (screen:window-size screen:*window*)) > 24 ; > 80 I do not have experience with SCREEN but SIGWINCH signal is handled and SYS::*PRIN-LINELENGTH* is updated. Isn't this the place where terminal dimensions can be set as well? Vladimir |
From: edgar <edg...@we...> - 2010-09-23 21:55:23
|
> I do not have experience with SCREEN but SIGWINCH signal is handled > and SYS::*PRIN-LINELENGTH* is updated. Isn't this the place where > terminal dimensions can be set as well? Thanks for the quick reply. The window stream functions of the SCREEN package get their terminal width and height values from two C variables named "cols" and "rows", which are set in the init_term function in "src/stream.d" and then are never updated. My own favourite trick from the Lisp level is using READLINE:GET-SCREEN-SIZE, what always gives the right results, even after resizing the terminal window. But READLINE is a compile-time option, so I cannot rely that READLINE is available on all systems. - edgar -- The author of this email does not necessarily endorse the following advertisements, which are the sole responsibility of the advertiser: |
From: Sam S. <sd...@gn...> - 2010-09-27 16:30:28
|
edgar wrote: > > The only real problem seems to be that the terminal geometry gets initialized > at CLISP's start-up time and doesn't get updated if the user resizes the > terminal window. oops. should be fixed in the cvs head. thanks for the bug report. note that the use of static vars here means that if MT clisp has several windows on different terminals with different geometries, we are screwed no matter what. I think this facility needs to be reworked... |