The situation is different in ncurses -- at least, if using the X-Window system -- because the size of the text console is entirely under the control of the user. The user can resize the text console at will, and the program has little effective control over the resizing.
This presents a difficulty, because Turbo C programs have naturally been written under the suppositions that the text console size has been set by the program itself, and that the text console is not going to be unexpectedly resized during program execution. Yet, these suppositions are both rather dodgy with code that has been ported using the TurboC library.
There are several possible approaches to the problem:
- For TurboC versions 04/18/02 and later, the screen size is now correct if the ported program is run under xterm. TurboC physically resizes the xterm console correctly upon starting the program. While it cannot prevent the user from manually resizing the window later, it will correct any manual resizing by automatically restoring the window to its correct size. (Sadly, it is possible for a persistent user to corrupt the window by trying hard enough to resize it, but the behavior is usually pretty acceptable.) Or,
- If for some reason it's impractical to use xterm, or if the window manager being used resists TurboC's attempts to resize xterm , then you may need to use some method outside of TurboC (such as instructions to the user) to prevent resizing of the window; or
- Set the BypassResizeXterm variable to 1, and recode those portions of your program that depend on knowledge of the screen size (such as those using gotoxy and windowgotoxy(1,25) , but use gotoxy(1,LINES) instead. functions) so that they are more flexible. For example, don't use things like
In the latter case, by the way, if the user manually resizes the text console, then your current window (as determined by the windowor textmode function) will automatically be reduced in size (if necessary) to fit the new console size. However, it will not be correspondingly increased in size of the user later enlarges the text console. To override this behavior, you'll need to provide an alternative to the ResizeTurboC function. You'll need to examine the source code for any further explanation.
No comments:
Post a Comment