Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 1 | \section{\module{curses} --- |
Thomas Wouters | f831663 | 2000-07-16 19:01:10 +0000 | [diff] [blame] | 2 | Terminal independent console handling} |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 3 | |
| 4 | \declaremodule{extension}{curses} |
| 5 | \sectionauthor{Moshe Zadka}{mzadka@geocities.com} |
| 6 | \modulesynopsis{An interface to the curses library.} |
| 7 | |
| 8 | The \module{curses} module provides an interface to the curses \UNIX{} |
| 9 | library, the de-facto standard for portable advanced terminal |
| 10 | handling. |
| 11 | |
| 12 | While curses is most widely used in the \UNIX{} environment, versions |
| 13 | are available for DOS, OS/2, and possibly other systems as well. The |
| 14 | extension module has not been tested with all available versions of |
| 15 | curses. |
| 16 | |
| 17 | \begin{seealso} |
Fred Drake | 5c529d3 | 2000-06-28 22:11:40 +0000 | [diff] [blame] | 18 | \seemodule{curses.ascii}{Utilities for working with \ASCII{} |
| 19 | characters, regardless of your locale |
| 20 | settings.} |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 21 | \seetext{Tutorial material on using curses with Python is available |
Fred Drake | 37f1574 | 1999-11-10 16:21:37 +0000 | [diff] [blame] | 22 | on the Python Web site as Andrew Kuchling's |
| 23 | \citetitle[http://www.python.org/doc/howto/curses/curses.html]{Curses |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 24 | Programming with Python}, at |
| 25 | \url{http://www.python.org/doc/howto/curses/curses.html}.} |
| 26 | \end{seealso} |
| 27 | |
| 28 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 29 | \subsection{Functions \label{curses-functions}} |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 30 | |
| 31 | The module \module{curses} defines the following exception: |
| 32 | \begin{excdesc}{error} |
| 33 | Curses function returned an error status. |
| 34 | \end{excdesc} |
| 35 | |
Fred Drake | 0bccd73 | 1999-06-23 17:28:01 +0000 | [diff] [blame] | 36 | \strong{Note:} Whenever \var{x} or \var{y} arguments to a function |
| 37 | or a method are optional, they default to the current cursor location. |
| 38 | Whenever \var{attr} is optional, it defaults to \constant{A_NORMAL}. |
| 39 | |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 40 | The module \module{curses} defines the following functions: |
| 41 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 42 | \begin{funcdesc}{baudrate}{} |
| 43 | Returns the output speed of the terminal in bits per second. |
| 44 | \end{funcdesc} |
| 45 | |
| 46 | \begin{funcdesc}{beep}{} |
| 47 | Emit a short sound. |
| 48 | \end{funcdesc} |
| 49 | |
| 50 | \begin{funcdesc}{can_change_color}{} |
| 51 | Returns true or false, depending on whether the programmer can change |
| 52 | the colors displayed by the terminal. |
| 53 | \end{funcdesc} |
| 54 | |
| 55 | \begin{funcdesc}{cbreak}{} |
| 56 | Enter cbreak mode. |
| 57 | \end{funcdesc} |
| 58 | |
| 59 | \begin{funcdesc}{color_content}{color_number} |
| 60 | Returns the intensity of the red, green, and blue (RGB) components in |
| 61 | the color \var{color_number}, which must be between 0 and COLORS. A |
| 62 | 3-tuple is returned, containing the R,G,B values for the given color, |
| 63 | which will be between 0 (no component) and 1000 (maximum amount of |
| 64 | component). |
| 65 | \end{funcdesc} |
| 66 | |
| 67 | \begin{funcdesc}{color_pair}{color_number} |
| 68 | Returns the attribute value for displaying text in the specified |
| 69 | color. This attribute value can be combined with |
| 70 | \constant{A_STANDOUT}, \constant{A_REVERSE}, and the other |
| 71 | \constant{A_*} attributes. \function{pair_number()} is the counterpart to this function. |
| 72 | \end{funcdesc} |
| 73 | |
| 74 | \begin{funcdesc}{curs_set}{visibility} |
| 75 | Sets the cursor state. \var{visibility} can be set to 0, 1, or 2, for |
| 76 | invisible, normal, or very visible. If the terminal supports the |
| 77 | visibility requested, the previous cursor state is returned; |
| 78 | otherwise, an exception is raised. |
| 79 | \end{funcdesc} |
| 80 | |
| 81 | \begin{funcdesc}{def_prog_mode}{} |
| 82 | Saves the current terminal mode as the ``program'' mode, the mode when |
| 83 | the running program is using curses. (Its counterpart is the |
| 84 | ``shell'' mode, for when the program is not in curses.) Subsequent calls |
| 85 | to \function{reset_prog_mode()} will restore this mode. |
| 86 | \end{funcdesc} |
| 87 | |
| 88 | \begin{funcdesc}{def_shell_mode}{} |
| 89 | Saves the current terminal mode as the ``shell'' mode, the mode when |
| 90 | the running program is not using curses. (Its counterpart is the |
| 91 | ``program'' mode, when the program is using curses capabilities.) |
| 92 | Subsequent calls |
| 93 | to \function{reset_shell_mode()} will restore this mode. |
| 94 | \end{funcdesc} |
| 95 | |
| 96 | \begin{funcdesc}{delay_output}{ms} |
| 97 | Inserts an \var{ms} millisecond pause in output. |
| 98 | \end{funcdesc} |
| 99 | |
| 100 | \begin{funcdesc}{doupdate}{} |
| 101 | Update the screen. |
| 102 | \end{funcdesc} |
| 103 | |
| 104 | \begin{funcdesc}{echo}{} |
| 105 | Enter echo mode. |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 106 | \end{funcdesc} |
| 107 | |
| 108 | \begin{funcdesc}{endwin}{} |
| 109 | De-initialize the library, and return terminal to normal status. |
| 110 | \end{funcdesc} |
| 111 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 112 | \begin{funcdesc}{erasechar}{} |
| 113 | Returns the user's current erase character. |
| 114 | \end{funcdesc} |
| 115 | |
| 116 | \begin{funcdesc}{filter}{} |
| 117 | The \function{filter()} routine, if used, must be called before |
| 118 | \function{initscr()} is called. |
| 119 | |
| 120 | The effect is that, during those calls, LINES is set to 1; the |
| 121 | capabilities clear, cup, cud, cud1, cuu1, cuu, vpa are disabled; and |
| 122 | the home string is set to the value of cr. |
| 123 | \end{funcdesc} |
| 124 | |
| 125 | \begin{funcdesc}{flash}{} |
| 126 | Flash the screen. |
| 127 | \end{funcdesc} |
| 128 | |
| 129 | \begin{funcdesc}{flushinp}{} |
| 130 | Flush all input buffers. |
| 131 | \end{funcdesc} |
| 132 | |
Andrew M. Kuchling | efc43d4 | 2000-06-30 01:05:39 +0000 | [diff] [blame] | 133 | \begin{funcdesc}{getmouse}{} |
| 134 | After \method{getch()} returns \constant{KEY_MOUSE} to signal a mouse |
| 135 | event, this method should be call to retrieve the queued mouse event, |
| 136 | represented as a 5-tuple |
| 137 | \code{(\var{id}, \var{x}, \var{y}, \var{z}, \var{bstate})}. |
| 138 | \var{id} is an ID value used to distinguish multiple devices, |
| 139 | and \var{x}, \var{y}, \var{z} are the event's coordinates. (\var{z} |
| 140 | is currently unused.). \var{bstate} is an integer value whose bits |
| 141 | will be set to indicate the type of event, and will be the bitwise OR |
| 142 | of one or more of the following constants, where \var{n} is the button |
| 143 | number from 1 to 4: |
| 144 | \constant{BUTTON\var{n}_PRESSED}, |
| 145 | \constant{BUTTON\var{n}_RELEASED}, |
| 146 | \constant{BUTTON\var{n}_CLICKED}, |
| 147 | \constant{BUTTON\var{n}_DOUBLE_CLICKED}, |
| 148 | \constant{BUTTON\var{n}_TRIPLE_CLICKED}, |
| 149 | \constant{BUTTON_SHIFT}, |
| 150 | \constant{BUTTON_CTRL}, |
| 151 | \constant{BUTTON_ALT}. |
| 152 | \end{funcdesc} |
| 153 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 154 | \begin{funcdesc}{getsyx}{} |
| 155 | Returns the current coordinates of the virtual screen cursor in y and |
| 156 | x. If leaveok is currently true, then -1,-1 is returned. |
| 157 | \end{funcdesc} |
| 158 | |
| 159 | \begin{funcdesc}{getwin}{file} |
| 160 | Reads window related data stored in the file by an earlier |
| 161 | \function{putwin()} call. The routine then creates and initializes a |
| 162 | new window using that data, returning the new window object. |
| 163 | \end{funcdesc} |
| 164 | |
| 165 | \begin{funcdesc}{has_colors}{} |
| 166 | Returns true if the terminal can manipulate colors; otherwise, it |
| 167 | returns false. |
| 168 | \end{funcdesc} |
| 169 | |
| 170 | \begin{funcdesc}{has_ic}{} |
| 171 | Returns true if the terminal has insert- and delete- character |
| 172 | capabilities. |
| 173 | \end{funcdesc} |
| 174 | |
| 175 | \begin{funcdesc}{has_il}{} |
| 176 | Returns true if the terminal has insert- and |
| 177 | delete-line capabilities, or can simulate them using |
| 178 | scrolling regions. |
| 179 | \end{funcdesc} |
| 180 | |
| 181 | \begin{funcdesc}{has_key}{ch} |
| 182 | Takes a key value \var{ch}, and returns true if the current terminal |
| 183 | type recognizes a key with that value. |
| 184 | \end{funcdesc} |
| 185 | |
| 186 | \begin{funcdesc}{halfdelay}{tenths} |
| 187 | Used for half-delay mode, which is similar to cbreak mode in that |
| 188 | characters typed by the user are immediately available to the program. |
| 189 | However, after blocking for \var{tenths} tenths of seconds, an |
| 190 | exception is raised if nothing has been typed. The value of |
| 191 | \var{tenths} must be a number between 1 and 255. Use nocbreak to |
| 192 | leave half-delay mode. |
| 193 | \end{funcdesc} |
| 194 | |
| 195 | \begin{funcdesc}{init_color}{color_number, r, g, b} |
| 196 | Changes the definition of a color, taking the number of the color to |
| 197 | be changed followed by three RGB values (for the amounts of red, |
| 198 | green, and blue components). The value of \var{color_number} must be |
| 199 | between 0 and COLORS. Each of \var{r}, \var{g}, \var{b}, must be a |
| 200 | value between 0 and 1000. When \function{init_color()} is used, all |
| 201 | occurrences of that color on the screen immediately change to the new |
| 202 | definition. |
| 203 | \end{funcdesc} |
| 204 | |
| 205 | \begin{funcdesc}{init_pair}{pair_number, fg, bg} |
| 206 | Changes the definition of a color-pair. It takes three arguments: the |
| 207 | number of the color-pair to be changed, the foreground color number, |
| 208 | and the background color number. The value of \var{pair_number} must |
| 209 | be between 1 and COLOR_PAIRS-1 (the 0 color pair is wired to white on |
| 210 | black and cannot be changed). The value of \var{fg} and \var{bg} |
| 211 | arguments must be between 0 and COLORS. If the color-pair was |
| 212 | previously initialized, the screen is refreshed and all occurrences of |
| 213 | that color-pair are changed to the new definition. |
| 214 | \end{funcdesc} |
| 215 | |
| 216 | \begin{funcdesc}{initscr}{} |
| 217 | Initialize the library. Returns a \class{WindowObject} which represents |
| 218 | the whole screen. |
| 219 | \end{funcdesc} |
| 220 | |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 221 | \begin{funcdesc}{isendwin}{} |
| 222 | Returns true if \function{endwin()} has been called. |
| 223 | \end{funcdesc} |
| 224 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 225 | \begin{funcdesc}{keyname}{k} |
| 226 | Return the name of the key numbered \var{k}. |
| 227 | \end{funcdesc} |
| 228 | |
| 229 | \begin{funcdesc}{killchar}{} |
| 230 | Returns the user's current line kill character. |
| 231 | \end{funcdesc} |
| 232 | |
| 233 | \begin{funcdesc}{longname}{} |
| 234 | Returns a string containing a verbose description of the current |
| 235 | terminal. The maximum length of a verbose description is 128 |
| 236 | characters. It is defined only after the call to |
| 237 | \function{initscr()}. |
| 238 | \end{funcdesc} |
| 239 | |
| 240 | \begin{funcdesc}{meta}{yes} |
| 241 | If \var{yes} is 1, allow 8-bit characters. If \var{yes} is 0, |
| 242 | allow only 7-bit chars. |
| 243 | \end{funcdesc} |
| 244 | |
Andrew M. Kuchling | efc43d4 | 2000-06-30 01:05:39 +0000 | [diff] [blame] | 245 | \begin{funcdesc}{mouseinterval}{interval} |
Thomas Wouters | f831663 | 2000-07-16 19:01:10 +0000 | [diff] [blame] | 246 | Sets the maximum time in milliseconds that can elapse between press and |
Andrew M. Kuchling | efc43d4 | 2000-06-30 01:05:39 +0000 | [diff] [blame] | 247 | release events in order for them to be recognized as a click, and |
| 248 | returns the previous interval value. The default value is 200 msec, |
| 249 | or one fifth of a second. |
| 250 | \end{funcdesc} |
| 251 | |
| 252 | \begin{funcdesc}{mousemask}{mousemask} |
| 253 | Sets the mouse events to be reported, and returns a tuple |
| 254 | \code{(\var{availmask}, \var{oldmask})}. |
| 255 | \var{availmask} indicates which of the |
| 256 | specified mouse events can be reported; on complete failure it returns |
| 257 | 0. \var{oldmask} is the previous value of the given window's mouse |
| 258 | event mask. If this function is never called, no mouse events are |
| 259 | ever reported. |
| 260 | \end{funcdesc} |
| 261 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 262 | \begin{funcdesc}{newpad}{nlines, ncols} |
| 263 | Creates and returns a pointer to a new pad data structure with the |
| 264 | given number of lines and columns. A pad is returned as a |
| 265 | window object. |
| 266 | |
| 267 | A pad is like a window, |
| 268 | except that it is not restricted by the screen size, and is not |
| 269 | necessarily associated with a particular part of the screen. |
| 270 | Pads can be used when a large window is needed, and only a part |
| 271 | of the window will be on the screen at one time. Automatic |
| 272 | refreshes of pads (e.g., from scrolling or echoing of |
| 273 | input) do not occur. It is not legal to call wrefresh |
| 274 | with a pad as an argument; the routines prefresh or |
| 275 | pnoutrefresh should be called instead. Note that these |
| 276 | routines require additional parameters to specify the part of |
| 277 | the pad to be displayed and the location on the screen to be |
| 278 | used for the display. |
| 279 | |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 280 | \end{funcdesc} |
| 281 | |
| 282 | \begin{funcdesc}{newwin}{\optional{nlines, ncols,} begin_y, begin_x} |
| 283 | Return a new window, whose left-upper corner is at |
| 284 | \code{(\var{begin_y}, \var{begin_x})}, and whose height/width is |
Fred Drake | 0bccd73 | 1999-06-23 17:28:01 +0000 | [diff] [blame] | 285 | \var{nlines}/\var{ncols}. |
| 286 | |
| 287 | By default, the window will extend from the |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 288 | specified position to the lower right corner of the screen. |
| 289 | \end{funcdesc} |
| 290 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 291 | \begin{funcdesc}{nl}{} |
| 292 | Enter nl mode. |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 293 | \end{funcdesc} |
| 294 | |
| 295 | \begin{funcdesc}{nocbreak}{} |
| 296 | Leave cbreak mode. |
| 297 | \end{funcdesc} |
| 298 | |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 299 | \begin{funcdesc}{noecho}{} |
| 300 | Leave echo mode. |
| 301 | \end{funcdesc} |
| 302 | |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 303 | \begin{funcdesc}{nonl}{} |
| 304 | Leave nl mode. |
| 305 | \end{funcdesc} |
| 306 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 307 | \begin{funcdesc}{noqiflush}{} |
| 308 | When the noqiflush routine is used, normal flush of input and |
| 309 | output queues associated with the INTR, QUIT and SUSP |
| 310 | characters will not be done. You may want to call |
| 311 | \function{noqiflush()} in a signal handler if you want output |
| 312 | to continue as though the interrupt had not occurred, after the |
| 313 | handler exits. |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 314 | \end{funcdesc} |
| 315 | |
| 316 | \begin{funcdesc}{noraw}{} |
| 317 | Leave raw mode. |
| 318 | \end{funcdesc} |
| 319 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 320 | \begin{funcdesc}{pair_content}{pair_number} |
| 321 | Returns a tuple \var{(fg,bg)} containing the colors for the requested |
| 322 | color pair. The value of \var{pair_number} must be between 0 and |
| 323 | COLOR_PAIRS-1. |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 324 | \end{funcdesc} |
| 325 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 326 | \begin{funcdesc}{pair_number}{attr} |
| 327 | Returns the number of the color-pair set by the attribute value \var{attr}. |
| 328 | \function{color_pair()} is the counterpart to this function. |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 329 | \end{funcdesc} |
| 330 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 331 | \begin{funcdesc}{putp}{string} |
| 332 | Equivalent to \code{tputs(str, 1, putchar)}. Note that the output of putp always |
| 333 | goes to standard output. |
| 334 | \end{funcdesc} |
| 335 | |
| 336 | \begin{funcdesc}{qiflush}{ \optional{flag} } |
| 337 | If \var{flag} is false, the effect is the same as calling |
| 338 | \function{noqiflush()}. If \var{flag} is true, or no argument is |
| 339 | provided, the queues will be flushed when these control characters are |
| 340 | read. |
| 341 | \end{funcdesc} |
| 342 | |
| 343 | \begin{funcdesc}{raw}{} |
| 344 | Enter raw mode. |
| 345 | \end{funcdesc} |
| 346 | |
| 347 | \begin{funcdesc}{reset_prog_mode}{} |
| 348 | Restores the terminal to ``program'' mode, as previously saved |
| 349 | by \function{def_prog_mode()}. |
| 350 | \end{funcdesc} |
| 351 | |
| 352 | \begin{funcdesc}{reset_shell_mode}{} |
| 353 | Restores the terminal to ``shell'' mode, as previously saved |
| 354 | by \function{def_shell_mode()}. |
| 355 | \end{funcdesc} |
| 356 | |
| 357 | \begin{funcdesc}{setsyx}{y, x} |
| 358 | Sets the virtual screen cursor to \var{y}, \var{x}. |
| 359 | If \var{y} and \var{x} are both -1, then leaveok is set. |
| 360 | \end{funcdesc} |
| 361 | |
| 362 | \begin{funcdesc}{start_color}{} |
| 363 | Must be called if the programmer wants to use colors, and before any |
| 364 | other color manipulation routine is called. It is good |
| 365 | practice to call this routine right after \function{initscr()}. |
| 366 | |
| 367 | \function{start_color()} initializes eight basic colors (black, red, |
| 368 | green, yellow, blue, magenta, cyan, and white), and two global |
| 369 | variables in the \module{curses} module, COLORS and COLOR_PAIRS, |
| 370 | containing the maximum number of colors and color-pairs the terminal |
| 371 | can support. It also restores the colors on the terminal to the |
| 372 | values they had when the terminal was just turned on. |
| 373 | \end{funcdesc} |
| 374 | |
| 375 | \begin{funcdesc}{termattrs}{} |
| 376 | Returns a logical OR of all video attributes supported by the |
| 377 | terminal. This information is useful when a curses program needs |
| 378 | complete control over the appearance of the screen. |
| 379 | \end{funcdesc} |
| 380 | |
| 381 | \begin{funcdesc}{termname}{} |
| 382 | Returns the value of the environment variable TERM, truncated to 14 |
| 383 | characters. |
| 384 | \end{funcdesc} |
| 385 | |
Andrew M. Kuchling | d24ff44 | 2000-06-21 01:42:51 +0000 | [diff] [blame] | 386 | \begin{funcdesc}{typeahead}{fd} |
| 387 | Specifies that the file descriptor \var{fd} be used for typeahead |
| 388 | checking. If \var{fd} is -1, then no typeahead checking is done. |
| 389 | |
| 390 | The curses library does ``line-breakout optimization'' by looking for |
| 391 | typeahead periodically while updating the screen. If input is found, |
| 392 | and it is coming from a tty, the current update is postponed until |
| 393 | refresh or doupdate is called again, allowing faster response to |
| 394 | commands typed in advance. This function allows specifying a different |
| 395 | file descriptor for typeahead checking. |
| 396 | \end{funcdesc} |
| 397 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 398 | \begin{funcdesc}{unctrl}{ch} |
| 399 | Returns a string which is a printable representation of the character |
| 400 | \var{ch}. Control characters are displayed as a caret followed by the |
| 401 | character, for example as \verb|^C|. Printing characters are left as they |
| 402 | are. |
| 403 | \end{funcdesc} |
| 404 | |
| 405 | \begin{funcdesc}{ungetch}{ch} |
| 406 | Push \var{ch} so the next \method{getch()} will return it. |
| 407 | \strong{Note:} only one \var{ch} can be pushed before \method{getch()} |
| 408 | is called. |
| 409 | \end{funcdesc} |
| 410 | |
Andrew M. Kuchling | efc43d4 | 2000-06-30 01:05:39 +0000 | [diff] [blame] | 411 | \begin{funcdesc}{ungetmouse}{id, x, y, z, bstate} |
| 412 | Push a \constant{KEY_MOUSE} event onto the input queue, associating |
| 413 | the given state data with it. |
| 414 | \end{funcdesc} |
| 415 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 416 | \begin{funcdesc}{use_env}{flag} |
| 417 | If used, this function should be called before \function{initscr} or |
| 418 | newterm are called. When \var{flag} is false, the values of |
| 419 | lines and columns specified in the terminfo database will be |
| 420 | used, even if environment variables LINES and COLUMNS (used by |
| 421 | default) are set, or if curses is running in a window (in which |
| 422 | case default behavior would be to use the window size if LINES |
| 423 | and COLUMNS are not set). |
| 424 | \end{funcdesc} |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 425 | |
| 426 | \subsection{Window Objects \label{curses-window-objects}} |
| 427 | |
| 428 | Window objects, as returned by \function{initscr()} and |
| 429 | \function{newwin()} above, have the |
| 430 | following methods: |
| 431 | |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 432 | \begin{methoddesc}{addch}{\optional{y, x,} ch\optional{, attr}} |
| 433 | \strong{Note:} A \emph{character} means a C character (i.e., an |
| 434 | \ASCII{} code), rather then a Python character (a string of length 1). |
| 435 | (This note is true whenever the documentation mentions a character.) |
| 436 | |
| 437 | Paint character \var{ch} at \code{(\var{y}, \var{x})} with attributes |
| 438 | \var{attr}, overwriting any character previously painter at that |
| 439 | location. By default, the character position and attributes are the |
| 440 | current settings for the window object. |
| 441 | \end{methoddesc} |
| 442 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 443 | \begin{methoddesc}{addnstr}{\optional{y, x,} str, n\optional{, attr}} |
| 444 | Paint at most \var{n} characters of the |
| 445 | string \var{str} at \code{(\var{y}, \var{x})} with attributes |
Fred Drake | 0bccd73 | 1999-06-23 17:28:01 +0000 | [diff] [blame] | 446 | \var{attr}, overwriting anything previously on the display. |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 447 | \end{methoddesc} |
| 448 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 449 | \begin{methoddesc}{addstr}{\optional{y, x,} str\optional{, attr}} |
| 450 | Paint the string \var{str} at \code{(\var{y}, \var{x})} with attributes |
| 451 | \var{attr}, overwriting anything previously on the display. |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 452 | \end{methoddesc} |
| 453 | |
| 454 | \begin{methoddesc}{attroff}{attr} |
Fred Drake | 0bccd73 | 1999-06-23 17:28:01 +0000 | [diff] [blame] | 455 | Turn off attribute \var{attr}. |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 456 | \end{methoddesc} |
| 457 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 458 | \begin{methoddesc}{attron}{attr} |
| 459 | Turn on attribute \var{attr}. |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 460 | \end{methoddesc} |
| 461 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 462 | \begin{methoddesc}{attrset}{attr} |
| 463 | Set the attributes to \var{attr}. |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 464 | \end{methoddesc} |
| 465 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 466 | \begin{methoddesc}{bkgd}{ch\optional{, attr}} |
| 467 | Sets the background property of the window to the character \var{ch}, |
| 468 | with attributes \var{attr}. The change is then applied to every |
| 469 | character position in that window: |
| 470 | \begin{itemize} |
| 471 | \item The attribute of every character in the window is |
| 472 | changed to the new background attribute. |
| 473 | |
| 474 | \item Wherever the former background character appears, |
| 475 | it is changed to the new background character. |
| 476 | \end{itemize} |
| 477 | |
| 478 | \end{methoddesc} |
| 479 | |
| 480 | \begin{methoddesc}{bkgdset}{ch\optional{, attr}} |
| 481 | Sets the window's background. A window's background consists of a |
| 482 | character and any combination of attributes. The attribute part of |
| 483 | the background is combined (OR'ed) with all non-blank characters that |
| 484 | are written into the window. Both the character and attribute parts |
| 485 | of the background are combined with the blank characters. The |
| 486 | background becomes a property of the character and moves with the |
| 487 | character through any scrolling and insert/delete line/character |
| 488 | operations. |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 489 | \end{methoddesc} |
| 490 | |
Fred Drake | 0bccd73 | 1999-06-23 17:28:01 +0000 | [diff] [blame] | 491 | \begin{methoddesc}{border}{\optional{ls\optional{, rs\optional{, ts\optional{, |
| 492 | bs\optional{, tl\optional{, tr\optional{, |
| 493 | bl\optional{, br}}}}}}}}} |
| 494 | Draw a border around the edges of the window. Each parameter specifies |
| 495 | the character to use for a specific part of the border; see the table |
| 496 | below for more details. The characters must be specified as integers; |
| 497 | using one-character strings will cause \exception{TypeError} to be |
| 498 | raised. |
| 499 | |
| 500 | \strong{Note:} A \code{0} value for any parameter will cause the |
| 501 | default character to be used for that parameter. Keyword parameters |
| 502 | can \emph{not} be used. The defaults are listed in this table: |
| 503 | |
| 504 | \begin{tableiii}{l|l|l}{var}{Parameter}{Description}{Default value} |
| 505 | \lineiii{ls}{Left side}{\constant{ACS_VLINE}} |
| 506 | \lineiii{rs}{Right side}{\constant{ACS_VLINE}} |
| 507 | \lineiii{ts}{Top}{\constant{ACS_HLINE}} |
| 508 | \lineiii{bs}{Bottom}{\constant{ACS_HLINE}} |
| 509 | \lineiii{tl}{Upper-left corner}{\constant{ACS_ULCORNER}} |
| 510 | \lineiii{tr}{Upper-right corner}{\constant{ACS_URCORNER}} |
| 511 | \lineiii{bl}{Bottom-left corner}{\constant{ACS_BLCORNER}} |
| 512 | \lineiii{br}{Bottom-right corner}{\constant{ACS_BRCORNER}} |
| 513 | \end{tableiii} |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 514 | \end{methoddesc} |
| 515 | |
Fred Drake | 0bccd73 | 1999-06-23 17:28:01 +0000 | [diff] [blame] | 516 | \begin{methoddesc}{box}{\optional{vertch, horch}} |
| 517 | Similar to \method{border()}, but both \var{ls} and \var{rs} are |
| 518 | \var{vertch} and both \var{ts} and {bs} are \var{horch}. The default |
| 519 | corner characters are always used by this function. |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 520 | \end{methoddesc} |
| 521 | |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 522 | \begin{methoddesc}{clear}{} |
| 523 | Like \method{erase()}, but also causes the whole screen to be repainted |
| 524 | upon next call to \method{refresh()}. |
| 525 | \end{methoddesc} |
| 526 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 527 | \begin{methoddesc}{clearok}{yes} |
| 528 | If \var{yes} is 1, the next call to \method{refresh()} |
| 529 | will clear the screen completely. |
| 530 | \end{methoddesc} |
| 531 | |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 532 | \begin{methoddesc}{clrtobot}{} |
| 533 | Erase from cursor to the end of the screen: all lines below the cursor |
| 534 | are deleted, and then the equivalent of \method{clrtoeol()} is performed. |
| 535 | \end{methoddesc} |
| 536 | |
| 537 | \begin{methoddesc}{clrtoeol}{} |
| 538 | Erase from cursor to the end of the line. |
| 539 | \end{methoddesc} |
| 540 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 541 | \begin{methoddesc}{cursyncup}{} |
| 542 | Updates the current cursor position of all the ancestors of the window |
| 543 | to reflect the current cursor position of the window. |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 544 | \end{methoddesc} |
| 545 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 546 | \begin{methoddesc}{delch}{\optional{x, y}} |
| 547 | Delete any character at \code{(\var{y}, \var{x})}. |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 548 | \end{methoddesc} |
| 549 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 550 | \begin{methoddesc}{deleteln}{} |
| 551 | Delete the line under the cursor. All following lines are moved up |
| 552 | by 1 line. |
| 553 | \end{methoddesc} |
| 554 | |
| 555 | \begin{methoddesc}{derwin}{\optional{nlines, ncols,} begin_y, begin_y} |
| 556 | An abbreviation for ``derive window'', \method{derwin()} is the same |
| 557 | as calling \method{subwin()}, except that \var{begin_y} and |
| 558 | \var{begin_x} are relative to the origin of the window, rather than |
| 559 | relative to the entire screen. Returns a window object for the |
| 560 | derived window. |
| 561 | \end{methoddesc} |
| 562 | |
| 563 | \begin{methoddesc}{echochar}{ch\optional{, attr}} |
| 564 | Add character \var{ch} with attribute \var{attr}, and immediately |
| 565 | call \method{refresh}. |
| 566 | \end{methoddesc} |
| 567 | |
Andrew M. Kuchling | efc43d4 | 2000-06-30 01:05:39 +0000 | [diff] [blame] | 568 | \begin{methoddesc}{enclose}{y, x} |
| 569 | Tests whether the given pair of screen-relative character-cell |
| 570 | coordinates are enclosed by the given window, returning true or |
| 571 | false. It is useful for determining what subset of the screen |
| 572 | windows enclose the location of a mouse event. |
| 573 | \end{methoddesc} |
| 574 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 575 | \begin{methoddesc}{erase}{} |
| 576 | Clear the window. |
| 577 | \end{methoddesc} |
| 578 | |
| 579 | \begin{methoddesc}{getbegyx}{} |
| 580 | Return a tuple \code{(\var{y}, \var{x})} of co-ordinates of upper-left |
| 581 | corner. |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 582 | \end{methoddesc} |
| 583 | |
| 584 | \begin{methoddesc}{getch}{\optional{x, y}} |
| 585 | Get a character. Note that the integer returned does \emph{not} have to |
| 586 | be in \ASCII{} range: function keys, keypad keys and so on return numbers |
| 587 | higher then 256. In no-delay mode, an exception is raised if there is |
| 588 | no input. |
| 589 | \end{methoddesc} |
| 590 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 591 | \begin{methoddesc}{getkey}{\optional{x, y}} |
| 592 | Get a character, returning a string instead of an integer, as |
| 593 | \method{getch()} does. Function keys, keypad keys and so on return a |
| 594 | multibyte string containing the key name. In no-delay mode, an |
| 595 | exception is raised if there is no input. |
| 596 | \end{methoddesc} |
| 597 | |
| 598 | \begin{methoddesc}{getmaxyx}{} |
| 599 | Return a tuple \code{(\var{y}, \var{x})} of the height and width of |
| 600 | the window. |
| 601 | \end{methoddesc} |
| 602 | |
| 603 | \begin{methoddesc}{getparyx}{} |
| 604 | Returns the beginning coordinates of this window relative to its |
| 605 | parent window into two integer variables y and x. Returns |
| 606 | \code{-1,-1} if this window has no parent. |
| 607 | \end{methoddesc} |
| 608 | |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 609 | \begin{methoddesc}{getstr}{\optional{x, y}} |
| 610 | Read a string from the user, with primitive line editing capacity. |
| 611 | \end{methoddesc} |
| 612 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 613 | \begin{methoddesc}{getyx}{} |
| 614 | Return a tuple \code{(\var{y}, \var{x})} of current cursor position. |
| 615 | \end{methoddesc} |
| 616 | |
| 617 | \begin{methoddesc}{hline}{\optional{y, x,} ch, n} |
| 618 | Display a horizontal line starting at \code{(\var{y}, \var{x})} with |
| 619 | length \var{n} consisting of the character \var{ch}. |
| 620 | \end{methoddesc} |
| 621 | |
| 622 | \begin{methoddesc}{idcok}{flag} |
| 623 | If \var{flag} is false, curses no longer considers using the hardware |
| 624 | insert/delete character feature of the terminal; if \var{flag} is |
| 625 | true, use of character insertion and deletion is enabled. When curses |
| 626 | is first initialized, use of character insert/delete is enabled by |
| 627 | default. |
| 628 | \end{methoddesc} |
| 629 | |
| 630 | \begin{methoddesc}{idlok}{yes} |
| 631 | If called with \var{yes} equal to 1, \module{curses} will try and use |
| 632 | hardware line editing facilities. Otherwise, line insertion/deletion |
| 633 | are disabled. |
| 634 | \end{methoddesc} |
| 635 | |
| 636 | \begin{methoddesc}{immedok}{flag} |
| 637 | If \var{flag} is true, any change in the window image |
| 638 | automatically causes the window to be refreshed; you no longer |
| 639 | have to call \method{refresh()} yourself. However, it may |
| 640 | degrade performance considerably, due to repeated calls to |
| 641 | wrefresh. This option is disabled by default. |
| 642 | \end{methoddesc} |
| 643 | |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 644 | \begin{methoddesc}{inch}{\optional{x, y}} |
| 645 | Return the character at the given position in the window. The bottom |
| 646 | 8 bits are the character proper, and upper bits are the attributes. |
| 647 | \end{methoddesc} |
| 648 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 649 | \begin{methoddesc}{insch}{\optional{y, x,} ch\optional{, attr}} |
| 650 | Paint character \var{ch} at \code{(\var{y}, \var{x})} with attributes |
| 651 | \var{attr}, moving the line from position \var{x} right by one |
| 652 | character. |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 653 | \end{methoddesc} |
| 654 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 655 | \begin{methoddesc}{insdelln}{nlines} |
| 656 | Inserts \var{nlines} lines into the specified window above the current |
| 657 | line. The \var{nlines} bottom lines are lost. For negative |
| 658 | \var{nlines}, delete \var{nlines} lines starting with the one under |
| 659 | the cursor, and move the remaining lines up. The bottom \var{nlines} |
| 660 | lines are cleared. The current cursor position remains the same. |
| 661 | \end{methoddesc} |
| 662 | |
| 663 | \begin{methoddesc}{insertln}{} |
| 664 | Insert a blank line under the cursor. All following lines are moved |
| 665 | down by 1 line. |
| 666 | \end{methoddesc} |
| 667 | |
| 668 | \begin{methoddesc}{insnstr}{\optional{y, x, } str, n \optional{, attr}} |
| 669 | Insert a character string (as many characters as will fit on the line) |
| 670 | before the character under the cursor, up to \var{n} characters. |
| 671 | If \var{n} is zero or negative, |
| 672 | the entire string is inserted. |
| 673 | All characters to the right of |
| 674 | the cursor are shifted right, with the the rightmost characters on the |
| 675 | line being lost. The cursor position does not change (after moving to |
| 676 | \var{y}, \var{x}, if specified). |
| 677 | \end{methoddesc} |
| 678 | |
| 679 | \begin{methoddesc}{insstr}{\optional{y, x, } str \optional{, attr}} |
| 680 | Insert a character string (as many characters as will fit on the line) |
| 681 | before the character under the cursor. All characters to the right of |
| 682 | the cursor are shifted right, with the the rightmost characters on the |
| 683 | line being lost. The cursor position does not change (after moving to |
| 684 | \var{y}, \var{x}, if specified). |
| 685 | \end{methoddesc} |
| 686 | |
| 687 | \begin{methoddesc}{instr}{\optional{y, x} \optional{, n}} |
| 688 | Returns a string of characters, extracted from the window starting at |
| 689 | the current cursor position, or at \var{y}, \var{x} if specified. |
| 690 | Attributes are stripped from the characters. If \var{n} is specified, |
| 691 | \method{instr()} returns return a string at most \var{n} characters |
| 692 | long (exclusive of the trailing NUL). |
| 693 | \end{methoddesc} |
| 694 | |
| 695 | \begin{methoddesc}{is_linetouched}{\var{line}} |
| 696 | Returns true if the specified line was modified since the last call to |
| 697 | \method{refresh()}; otherwise returns false. Raises a |
| 698 | \exception{curses.error} exception if \var{line} is not valid |
| 699 | for the given window. |
| 700 | \end{methoddesc} |
| 701 | |
| 702 | \begin{methoddesc}{is_wintouched}{} |
| 703 | Returns true if the specified window was modified since the last call to |
| 704 | \method{refresh()}; otherwise returns false. |
| 705 | \end{methoddesc} |
| 706 | |
| 707 | \begin{methoddesc}{keypad}{yes} |
| 708 | If \var{yes} is 1, escape sequences generated by some keys (keypad, |
| 709 | function keys) will be interpreted by \module{curses}. |
| 710 | If \var{yes} is 0, escape sequences will be left as is in the input |
| 711 | stream. |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 712 | \end{methoddesc} |
| 713 | |
| 714 | \begin{methoddesc}{leaveok}{yes} |
| 715 | If \var{yes} is 1, |
| 716 | cursor is left where it is, instead of being at ``cursor position.'' |
| 717 | This reduces cursor movement where possible. If possible it will be made |
| 718 | invisible. |
| 719 | |
| 720 | If \var{yes} is 0, cursor will always be at |
| 721 | ``cursor position'' after an update. |
| 722 | \end{methoddesc} |
| 723 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 724 | \begin{methoddesc}{move}{new_y, new_x} |
| 725 | Move cursor to \code{(\var{new_y}, \var{new_x})}. |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 726 | \end{methoddesc} |
| 727 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 728 | \begin{methoddesc}{mvderwin}{y, x} |
| 729 | Moves the window inside its parent window. The screen-relative |
| 730 | parameters of the window are not changed. This routine is used to |
| 731 | display different parts of the parent window at the same physical |
| 732 | position on the screen. |
| 733 | \end{methoddesc} |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 734 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 735 | \begin{methoddesc}{mvwin}{new_y, new_x} |
| 736 | Move the window so its upper-left corner is at \code{(\var{new_y}, \var{new_x})}. |
Fred Drake | a4070ce | 1999-06-21 21:13:09 +0000 | [diff] [blame] | 737 | \end{methoddesc} |
| 738 | |
| 739 | \begin{methoddesc}{nodelay}{yes} |
| 740 | If \var{yes} is 1, \method{getch()} will be non-blocking. |
| 741 | \end{methoddesc} |
| 742 | |
| 743 | \begin{methoddesc}{notimeout}{yes} |
| 744 | If \var{yes} is 1, escape sequences will not be timed out. |
| 745 | |
| 746 | If \var{yes} is 0, after a few milliseconds, an escape sequence will |
| 747 | not be interpreted, and will be left in the input stream as is. |
| 748 | \end{methoddesc} |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 749 | |
| 750 | \begin{methoddesc}{noutrefresh}{} |
| 751 | Mark for refresh but wait. |
| 752 | \end{methoddesc} |
| 753 | |
| 754 | \begin{methoddesc}{putwin}{file} |
| 755 | Writes all data associated with the window into the provided file |
| 756 | object. This information can be later retrieved using the |
| 757 | \function{getwin()} function. |
| 758 | |
| 759 | \end{methoddesc} |
| 760 | |
| 761 | \begin{methoddesc}{redrawln}{beg, num} |
| 762 | Indicates that the \var{num} screen lines, starting at line \var{beg}, |
| 763 | are corrupted and should be completely redrawn on the next |
| 764 | \method{refresh()} call. |
| 765 | \end{methoddesc} |
| 766 | |
| 767 | \begin{methoddesc}{redrawwin}{} |
| 768 | Touches the entire window, causing it to be completely redrawn on the |
| 769 | next \method{refresh()} call. |
| 770 | \end{methoddesc} |
| 771 | |
| 772 | \begin{methoddesc}{refresh}{ \optional{pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol} } |
| 773 | Update the display immediately (sync actual screen with previous |
| 774 | drawing/deleting methods). |
| 775 | |
| 776 | The 6 optional arguments can only be specified when the window is a |
| 777 | pad created with \function{newpad()}. The additional parameters are |
| 778 | needed to indicate what part of the pad and screen are involved. |
| 779 | \var{pminrow} and \var{pmincol} specify the upper left-hand corner of the |
| 780 | rectangle to be displayed in the pad. \var{sminrow}, \var{smincol}, |
| 781 | \var{smaxrow}, and \var{smaxcol} specify the edges of the rectangle to be displayed on the screen. The lower right-hand corner of the |
| 782 | rectangle to be displayed in the pad is calculated from the screen |
| 783 | coordinates, since the rectangles must be the same size. Both |
| 784 | rectangles must be entirely contained within their respective |
| 785 | structures. Negative values of \var{pminrow}, \var{pmincol}, |
| 786 | \var{sminrow}, or \var{smincol} are treated as if they were zero. |
| 787 | \end{methoddesc} |
| 788 | |
| 789 | \begin{methoddesc}{scroll}{\optional{lines\code{ = 1}}} |
| 790 | Scroll the screen upward by \var{lines} lines. |
| 791 | \end{methoddesc} |
| 792 | |
| 793 | \begin{methoddesc}{scrollok}{flag} |
| 794 | Controls what happens when the cursor of a window is moved off the |
| 795 | edge of the window or scrolling region, either as a result of a |
| 796 | newline action on the bottom line, or typing the last character |
| 797 | of the last line. If \var{flag} is false, the cursor is left |
| 798 | on the bottom line. If \var{flag} is true, the window is |
| 799 | scrolled up one line. Note that in order to get the physical |
| 800 | scrolling effect on the terminal, it is also necessary to call |
| 801 | \method{idlok()}. |
| 802 | \end{methoddesc} |
| 803 | |
| 804 | \begin{methoddesc}{setscrreg}{top, bottom} |
| 805 | Set the scrolling region from line \var{top} to line \var{bottom}. All |
| 806 | scrolling actions will take place in this region. |
| 807 | \end{methoddesc} |
| 808 | |
| 809 | \begin{methoddesc}{standend}{} |
| 810 | Turn off all attributes. |
| 811 | \end{methoddesc} |
| 812 | |
| 813 | \begin{methoddesc}{standout}{} |
| 814 | Turn on attribute \var{A_STANDOUT}. |
| 815 | \end{methoddesc} |
| 816 | |
| 817 | \begin{methoddesc}{subpad}{\optional{nlines, ncols,} begin_y, begin_y} |
| 818 | Return a sub-window, whose upper-left corner is at |
| 819 | \code{(\var{begin_y}, \var{begin_x})}, and whose width/height is |
| 820 | \var{ncols}/\var{nlines}. |
| 821 | \end{methoddesc} |
| 822 | |
| 823 | \begin{methoddesc}{subwin}{\optional{nlines, ncols,} begin_y, begin_y} |
| 824 | Return a sub-window, whose upper-left corner is at |
| 825 | \code{(\var{begin_y}, \var{begin_x})}, and whose width/height is |
| 826 | \var{ncols}/\var{nlines}. |
| 827 | |
| 828 | By default, the sub-window will extend from the |
| 829 | specified position to the lower right corner of the window. |
| 830 | \end{methoddesc} |
| 831 | |
| 832 | \begin{methoddesc}{syncdown}{} |
| 833 | Touches each location in the window that has been touched in any of |
| 834 | its ancestor windows. This routine is called by \method{refresh()}, |
| 835 | so it should almost never be necessary to call it manually. |
| 836 | \end{methoddesc} |
| 837 | |
| 838 | \begin{methoddesc}{syncok}{flag} |
| 839 | If called with \var{flag} set to true, then \method{syncup()} is |
| 840 | called automatically whenever there is a change in the window. |
| 841 | \end{methoddesc} |
| 842 | |
| 843 | \begin{methoddesc}{syncup}{} |
| 844 | Touches all locations in ancestors of the window that have been changed in |
| 845 | the window. |
| 846 | \end{methoddesc} |
| 847 | |
Andrew M. Kuchling | d24ff44 | 2000-06-21 01:42:51 +0000 | [diff] [blame] | 848 | \begin{methoddesc}{timeout}{delay} |
Thomas Wouters | f831663 | 2000-07-16 19:01:10 +0000 | [diff] [blame] | 849 | Sets blocking or non-blocking read behavior for the window. If |
Andrew M. Kuchling | d24ff44 | 2000-06-21 01:42:51 +0000 | [diff] [blame] | 850 | \var{delay} is negative, blocking read is used, which will wait |
| 851 | indefinitely for input). If \var{delay} is zero, then non-blocking |
| 852 | read is used, and -1 will be returned by \method{getch()} if no input |
| 853 | is waiting. If \var{delay} is positive, then \method{getch()} will |
| 854 | block for \var{delay} milliseconds, and return -1 if there is still no |
| 855 | input at the end of that time. |
| 856 | \end{methoddesc} |
| 857 | |
Andrew M. Kuchling | f1dc5fa | 2000-05-23 16:46:04 +0000 | [diff] [blame] | 858 | \begin{methoddesc}{touchline}{start, count} |
| 859 | Pretend \var{count} lines have been changed, starting with line |
| 860 | \var{start}. |
| 861 | \end{methoddesc} |
| 862 | |
| 863 | \begin{methoddesc}{touchwin}{} |
| 864 | Pretend the whole window has been changed, for purposes of drawing |
| 865 | optimizations. |
| 866 | \end{methoddesc} |
| 867 | |
| 868 | \begin{methoddesc}{untouchwin}{} |
| 869 | Marks all lines in the window as unchanged since the last call to |
| 870 | \method{refresh()}. |
| 871 | \end{methoddesc} |
| 872 | |
| 873 | \begin{methoddesc}{vline}{\optional{y, x,} ch, n} |
| 874 | Display a vertical line starting at \code{(\var{y}, \var{x})} with |
| 875 | length \var{n} consisting of the character \var{ch}. |
| 876 | \end{methoddesc} |
| 877 | |
| 878 | \subsection{Constants} |
| 879 | |
| 880 | The \module{curses} module defines the following data members: |
| 881 | |
| 882 | \begin{datadesc}{version} |
| 883 | A string representing the current version of the module. |
| 884 | Also available as \constant{__version__}. |
| 885 | \end{datadesc} |
| 886 | |
| 887 | |
| 888 | \begin{tableii}{c|l}{code}{Attribute}{Meaning} |
| 889 | \lineii{A_ALTCHARSET}{Alternate character set mode.} |
| 890 | \lineii{A_BLINK}{Blink mode.} |
| 891 | \lineii{A_BOLD}{Bold mode.} |
| 892 | \lineii{A_DIM}{Dim mode.} |
| 893 | \lineii{A_NORMAL}{Normal attribute.} |
| 894 | \lineii{A_STANDOUT}{Standout mode.} |
| 895 | \lineii{A_UNDERLINE}{Underline mode.} |
| 896 | \end{tableii} |
| 897 | |
| 898 | Keys are referred to by integer constants with names starting with |
| 899 | \code{KEY_}. The exact names available are system dependent. |
| 900 | |
| 901 | % XXX this table is far too large! |
| 902 | % XXX should this table be alphabetized? |
| 903 | |
| 904 | \begin{tableii}{c|l}{code}{Key constant}{Key} |
| 905 | \lineii{KEY_MIN}{Minimum key value} |
| 906 | \lineii{KEY_BREAK}{ Break key (unreliable) } |
| 907 | \lineii{KEY_DOWN}{ Down-arrow } |
| 908 | \lineii{KEY_UP}{ Up-arrow } |
| 909 | \lineii{KEY_LEFT}{ Left-arrow } |
| 910 | \lineii{KEY_RIGHT}{ Right-arrow } |
| 911 | \lineii{KEY_HOME}{ Home key (upward+left arrow) } |
| 912 | \lineii{KEY_BACKSPACE}{ Backspace (unreliable) } |
| 913 | \lineii{KEY_F0}{ Function keys. Up to 64 function keys are supported. } |
| 914 | \lineii{KEY_F\var{n}}{ Value of function key \var{n} } |
| 915 | \lineii{KEY_DL}{ Delete line } |
| 916 | \lineii{KEY_IL}{ Insert line } |
| 917 | \lineii{KEY_DC}{ Delete character } |
| 918 | \lineii{KEY_IC}{ Insert char or enter insert mode } |
| 919 | \lineii{KEY_EIC}{ Exit insert char mode } |
| 920 | \lineii{KEY_CLEAR}{ Clear screen } |
| 921 | \lineii{KEY_EOS}{ Clear to end of screen } |
| 922 | \lineii{KEY_EOL}{ Clear to end of line } |
| 923 | \lineii{KEY_SF}{ Scroll 1 line forward } |
| 924 | \lineii{KEY_SR}{ Scroll 1 line backward (reverse) } |
| 925 | \lineii{KEY_NPAGE}{ Next page } |
| 926 | \lineii{KEY_PPAGE}{ Previous page } |
| 927 | \lineii{KEY_STAB}{ Set tab } |
| 928 | \lineii{KEY_CTAB}{ Clear tab } |
| 929 | \lineii{KEY_CATAB}{ Clear all tabs } |
| 930 | \lineii{KEY_ENTER}{ Enter or send (unreliable) } |
| 931 | \lineii{KEY_SRESET}{ Soft (partial) reset (unreliable) } |
| 932 | \lineii{KEY_RESET}{ Reset or hard reset (unreliable) } |
| 933 | \lineii{KEY_PRINT}{ Print } |
| 934 | \lineii{KEY_LL}{ Home down or bottom (lower left) } |
| 935 | \lineii{KEY_A1}{ Upper left of keypad } |
| 936 | \lineii{KEY_A3}{ Upper right of keypad } |
| 937 | \lineii{KEY_B2}{ Center of keypad } |
| 938 | \lineii{KEY_C1}{ Lower left of keypad } |
| 939 | \lineii{KEY_C3}{ Lower right of keypad } |
| 940 | \lineii{KEY_BTAB}{ Back tab } |
| 941 | \lineii{KEY_BEG}{ Beg (beginning) } |
| 942 | \lineii{KEY_CANCEL}{ Cancel } |
| 943 | \lineii{KEY_CLOSE}{ Close } |
| 944 | \lineii{KEY_COMMAND}{ Cmd (command) } |
| 945 | \lineii{KEY_COPY}{ Copy } |
| 946 | \lineii{KEY_CREATE}{ Create } |
| 947 | \lineii{KEY_END}{ End } |
| 948 | \lineii{KEY_EXIT}{ Exit } |
| 949 | \lineii{KEY_FIND}{ Find } |
| 950 | \lineii{KEY_HELP}{ Help } |
| 951 | \lineii{KEY_MARK}{ Mark } |
| 952 | \lineii{KEY_MESSAGE}{ Message } |
| 953 | \lineii{KEY_MOVE}{ Move } |
| 954 | \lineii{KEY_NEXT}{ Next } |
| 955 | \lineii{KEY_OPEN}{ Open } |
| 956 | \lineii{KEY_OPTIONS}{ Options } |
| 957 | \lineii{KEY_PREVIOUS}{ Prev (previous) } |
| 958 | \lineii{KEY_REDO}{ Redo } |
| 959 | \lineii{KEY_REFERENCE}{ Ref (reference) } |
| 960 | \lineii{KEY_REFRESH}{ Refresh } |
| 961 | \lineii{KEY_REPLACE}{ Replace } |
| 962 | \lineii{KEY_RESTART}{ Restart } |
| 963 | \lineii{KEY_RESUME}{ Resume } |
| 964 | \lineii{KEY_SAVE}{ Save } |
| 965 | \lineii{KEY_SBEG}{ Shifted Beg (beginning) } |
| 966 | \lineii{KEY_SCANCEL}{ Shifted Cancel } |
| 967 | \lineii{KEY_SCOMMAND}{ Shifted Command } |
| 968 | \lineii{KEY_SCOPY}{ Shifted Copy } |
| 969 | \lineii{KEY_SCREATE}{ Shifted Create } |
| 970 | \lineii{KEY_SDC}{ Shifted Delete char } |
| 971 | \lineii{KEY_SDL}{ Shifted Delete line } |
| 972 | \lineii{KEY_SELECT}{ Select } |
| 973 | \lineii{KEY_SEND}{ Shifted End } |
| 974 | \lineii{KEY_SEOL}{ Shifted Clear line } |
| 975 | \lineii{KEY_SEXIT}{ Shifted Dxit } |
| 976 | \lineii{KEY_SFIND}{ Shifted Find } |
| 977 | \lineii{KEY_SHELP}{ Shifted Help } |
| 978 | \lineii{KEY_SHOME}{ Shifted Home } |
| 979 | \lineii{KEY_SIC}{ Shifted Input } |
| 980 | \lineii{KEY_SLEFT}{ Shifted Left arrow } |
| 981 | \lineii{KEY_SMESSAGE}{ Shifted Message } |
| 982 | \lineii{KEY_SMOVE}{ Shifted Move } |
| 983 | \lineii{KEY_SNEXT}{ Shifted Next } |
| 984 | \lineii{KEY_SOPTIONS}{ Shifted Options } |
| 985 | \lineii{KEY_SPREVIOUS}{ Shifted Prev } |
| 986 | \lineii{KEY_SPRINT}{ Shifted Print } |
| 987 | \lineii{KEY_SREDO}{ Shifted Redo } |
| 988 | \lineii{KEY_SREPLACE}{ Shifted Replace } |
| 989 | \lineii{KEY_SRIGHT}{ Shifted Right arrow } |
| 990 | \lineii{KEY_SRSUME}{ Shifted Resume } |
| 991 | \lineii{KEY_SSAVE}{ Shifted Save } |
| 992 | \lineii{KEY_SSUSPEND}{ Shifted Suspend } |
| 993 | \lineii{KEY_SUNDO}{ Shifted Undo } |
| 994 | \lineii{KEY_SUSPEND}{ Suspend } |
| 995 | \lineii{KEY_UNDO}{ Undo } |
| 996 | \lineii{KEY_MOUSE}{ Mouse event has occurred } |
| 997 | \lineii{KEY_RESIZE}{ Terminal resize event } |
| 998 | \lineii{KEY_MAX}{Maximum key value} |
| 999 | \end{tableii} |
| 1000 | |
| 1001 | The following table lists characters from the alternate character set. |
| 1002 | \strong{Note:} These are available only after \function{initscr()} has |
| 1003 | been called. |
| 1004 | |
| 1005 | \begin{tableii}{c|l}{code}{ACS code}{Meaning} |
| 1006 | \lineii{ACS_BBSS}{} |
| 1007 | \lineii{ACS_BLOCK}{} |
| 1008 | \lineii{ACS_BOARD}{} |
| 1009 | \lineii{ACS_BSBS}{} |
| 1010 | \lineii{ACS_BSSB}{} |
| 1011 | \lineii{ACS_BSSS}{} |
| 1012 | \lineii{ACS_BTEE}{} |
| 1013 | \lineii{ACS_BULLET}{} |
| 1014 | \lineii{ACS_CKBOARD}{} |
| 1015 | \lineii{ACS_DARROW}{} |
| 1016 | \lineii{ACS_DEGREE}{} |
| 1017 | \lineii{ACS_DIAMOND}{} |
| 1018 | \lineii{ACS_GEQUAL}{ (Not available with SGI curses)} |
| 1019 | \lineii{ACS_HLINE}{} |
| 1020 | \lineii{ACS_LANTERN}{} |
| 1021 | \lineii{ACS_LARROW}{} |
| 1022 | \lineii{ACS_LEQUAL}{ (Not available with SGI curses)} |
| 1023 | \lineii{ACS_LLCORNER}{} |
| 1024 | \lineii{ACS_LRCORNER}{} |
| 1025 | \lineii{ACS_LTEE}{} |
| 1026 | \lineii{ACS_NEQUAL}{ (Not available with SGI curses)} |
| 1027 | \lineii{ACS_PI}{ (Not available with SGI curses)} |
| 1028 | \lineii{ACS_PLMINUS}{} |
| 1029 | \lineii{ACS_PLUS}{} |
| 1030 | \lineii{ACS_RARROW}{} |
| 1031 | \lineii{ACS_RTEE}{} |
| 1032 | \lineii{ACS_S1}{} |
| 1033 | \lineii{ACS_S3}{ (Not available with SGI curses)} |
| 1034 | \lineii{ACS_S9}{} |
| 1035 | \lineii{ACS_SBBS}{} |
| 1036 | \lineii{ACS_SBSB}{} |
| 1037 | \lineii{ACS_SBSS}{} |
| 1038 | \lineii{ACS_SSBB}{} |
| 1039 | \lineii{ACS_SSBS}{} |
| 1040 | \lineii{ACS_SSSB}{} |
| 1041 | \lineii{ACS_SSSS}{} |
| 1042 | \lineii{ACS_STERLING}{ (Not available with SGI curses)} |
| 1043 | \lineii{ACS_TTEE}{} |
| 1044 | \lineii{ACS_UARROW}{} |
| 1045 | \lineii{ACS_ULCORNER}{} |
| 1046 | \lineii{ACS_URCORNER}{} |
| 1047 | \lineii{ACS_VLINE}{} |
| 1048 | \end{tableii} |
| 1049 | |
| 1050 | The following table lists the predefined colors: |
| 1051 | |
| 1052 | \begin{tableii}{c|l}{code}{Constant}{Color} |
| 1053 | \lineii{COLOR_BLACK}{Black} |
| 1054 | \lineii{COLOR_BLUE}{Blue} |
| 1055 | \lineii{COLOR_CYAN}{Cyan (light greenish blue)} |
| 1056 | \lineii{COLOR_GREEN}{Green} |
| 1057 | \lineii{COLOR_MAGENTA}{Magenta (purplish red)} |
| 1058 | \lineii{COLOR_RED}{Red} |
| 1059 | \lineii{COLOR_WHITE}{White} |
| 1060 | \lineii{COLOR_YELLOW}{Yellow} |
| 1061 | \end{tableii} |
| 1062 | |