[Tutor] How to use "curses.resizeterm(nlines, ncols)"

Cameron Simpson cs at cskk.id.au
Sun Feb 24 18:03:23 EST 2019


On 24Feb2019 22:51, Mark Lawrence <breamoreboy at gmail.com> wrote:
>As I know squat about the curses module is this a time when a bug 
>report could be put into the docs to clarify things, or do you have to 
>know something about curses before you try using the Python wrapper?

Well, both.

The Python curses module is mostly a thin shim around the curses(3) C 
library. So the real semantics come from that; the Python module doco 
test closely resembles the text from the curses(3) manual entry (what 
you get from the "man 3 curses" command).

The curses(3) manual entry (well, ncurses on my Mac here) says:

  The ncurses library includes facilities for responding to window resizing
  events, e.g., when running in an xterm.  See the resizeterm(3X) and
  wresize(3X) manual pages for details.  In addition, the library may  be
  configured with a SIGWINCH handler.

and resizeterm(3) says in part:

  resizeterm
    The function resizeterm resizes the standard and current windows to
    the specified  dimensions,  and  adjusts other bookkeeping data used by
    the ncurses library that record the window dimensions such as the 
    LINES and COLS variables.

However, since people using the Python module might reasonably be 
expected to know less than those using the C library directly it would 
be useful to make it more clear that resizeterm() is essentailly "tell 
curses the terminal size" function, not a "make the terminal a specific 
size" function, and that because curses normally notices changes 
automatically then it is uncommon to need to call resizeterm().

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Tutor mailing list