0% found this document useful (0 votes)
8 views

curses.beep()

The document outlines various functions defined in the curses module, which is used for terminal handling in Python. Key functions include curses.baudrate() for terminal speed, curses.cbreak() for entering cbreak mode, and curses.init_pair() for changing color pair definitions. It also describes functionalities for managing screen updates, input handling, and terminal modes.

Uploaded by

diegohazael2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

curses.beep()

The document outlines various functions defined in the curses module, which is used for terminal handling in Python. Key functions include curses.baudrate() for terminal speed, curses.cbreak() for entering cbreak mode, and curses.init_pair() for changing color pair definitions. It also describes functionalities for managing screen updates, input handling, and terminal modes.

Uploaded by

diegohazael2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

The module curses defines the following functions:

curses.baudrate()

Return the output speed of the terminal in bits per second. On software terminal
emulators it will have a fixed high value. Included for historical reasons; in
former times, it was used to write output loops for time delays and occasionally
to change interfaces depending on the line speed.

curses.beep()

Emit a short attention sound.

curses.can_change_color()

Return True or False, depending on whether the programmer can change the
colors displayed by the terminal.

curses.cbreak()

Enter cbreak mode. In cbreak mode (sometimes called “rare” mode) normal tty
line buffering is turned off and characters are available to be read one by one.
However, unlike raw mode, special characters (interrupt, quit, suspend, and flow
control) retain their effects on the tty driver and calling program. Calling first
raw() then cbreak() leaves the terminal in cbreak mode.

curses.color_content(color_number)

Return the intensity of the red, green, and blue (RGB) components in the color
color_number, which must be between 0 and COLORS - 1. Return a 3-tuple,
containing the R,G,B values for the given color, which will be between 0 (no
component) and 1000 (maximum amount of component).

curses.color_pair(pair_number)
Return the attribute value for displaying text in the specified color pair. Only the
first 256 color pairs are supported. This attribute value can be combined with
A_STANDOUT, A_REVERSE, and the other A_* attributes. pair_number() is the
counterpart to this function.

curses.curs_set(visibility)

Set the cursor state. visibility can be set to 0, 1, or 2, for invisible, normal, or
very visible. If the terminal supports the visibility requested, return the previous
cursor state; otherwise raise an exception. On many terminals, the “visible”
mode is an underline cursor and the “very visible” mode is a block cursor.

curses.def_prog_mode()

Save the current terminal mode as the “program” mode, the mode when the
running program is using curses. (Its counterpart is the “shell” mode, for when
the program is not in curses.) Subsequent calls to reset_prog_mode() will
restore this mode.

curses.def_shell_mode()

Save the current terminal mode as the “shell” mode, the mode when the running
program is not using curses. (Its counterpart is the “program” mode, when the
program is using curses capabilities.) Subsequent calls to
reset_shell_mode() will restore this mode.

curses.delay_output(ms)

Insert an ms millisecond pause in output.

curses.doupdate()

Update the physical screen. The curses library keeps two data structures, one
representing the current physical screen contents and a virtual screen
representing the desired next state. The doupdate() ground updates the
physical screen to match the virtual screen.

The virtual screen may be updated by a noutrefresh() call after write


operations such as addstr() have been performed on a window. The normal
refresh() call is simply noutrefresh() followed by doupdate(); if you have
to update multiple windows, you can speed performance and perhaps reduce
screen flicker by issuing noutrefresh() calls on all windows, followed by a
single doupdate().

curses.echo()

Enter echo mode. In echo mode, each character input is echoed to the screen
as it is entered.

curses.endwin()

De-initialize the library, and return terminal to normal status.

curses.erasechar()

Return the user’s current erase character as a one-byte bytes object. Under
Unix operating systems this is a property of the controlling tty of the curses
program, and is not set by the curses library itself.

curses.filter()

The filter() routine, if used, must be called before initscr() is called. The
effect is that, during those calls, LINES is set to 1; the capabilities clear, cup,
cud, cud1, cuu1, cuu, vpa are disabled; and the home string is set to the value
of cr. The effect is that the cursor is confined to the current line, and so are
screen updates. This may be used for enabling character-at-a-time line editing
without touching the rest of the screen.
curses.flash()

Flash the screen. That is, change it to reverse-video and then change it back in
a short interval. Some people prefer such as ‘visible bell’ to the audible attention
signal produced by beep().

curses.flushinp()

Flush all input buffers. This throws away any typeahead that has been typed by
the user and has not yet been processed by the program.

curses.getmouse()

After getch() returns KEY_MOUSE to signal a mouse event, this method should
be called to retrieve the queued mouse event, represented as a 5-tuple (id, x,
y, z, bstate). id is an ID value used to distinguish multiple devices, and x, y,
z are the event’s coordinates. (z is currently unused.) bstate is an integer value
whose bits will be set to indicate the type of event, and will be the bitwise OR of
one or more of the following constants, where n is the button number from 1 to
4: BUTTONn_PRESSED, BUTTONn_RELEASED, BUTTONn_CLICKED,
BUTTONn_DOUBLE_CLICKED, BUTTONn_TRIPLE_CLICKED, BUTTON_SHIFT,
BUTTON_CTRL, BUTTON_ALT.

curses.getsyx()

Return the current coordinates of the virtual screen cursor as a tuple (y, x). If
leaveok is currently True, then return (-1, -1).

curses.getwin(file)

Read window related data stored in the file by an earlier putwin() call. The
routine then creates and initializes a new window using that data, returning the
new window object.
curses.has_colors()

Return True if the terminal can display colors; otherwise, return False.

curses.has_ic()

Return True if the terminal has insert- and delete-character capabilities. This
function is included for historical reasons only, as all modern software terminal
emulators have such capabilities.

curses.has_il()

Return True if the terminal has insert- and delete-line capabilities, or can
simulate them using scrolling regions. This function is included for historical
reasons only, as all modern software terminal emulators have such capabilities.

curses.has_key(ch)

Take a key value ch, and return True if the current terminal type recognizes a
key with that value.

curses.halfdelay(tenths)

Used for half-delay mode, which is similar to cbreak mode in that characters
typed by the user are immediately available to the program. However, after
blocking for tenths tenths of seconds, raise an exception if nothing has been
typed. The value of tenths must be a number between 1 and 255. Use
nocbreak() to leave half-delay mode.

curses.init_color(color_number, r, g, b)

Change the definition of a color, taking the number of the color to be changed
followed by three RGB values (for the amounts of red, green, and blue
components). The value of color_number must be between 0 and COLORS - 1.
Each of r, g, b, must be a value between 0 and 1000. When init_color() is
used, all occurrences of that color on the screen immediately change to the new
definition. This function is a no-op on most terminals; it is active only if
can_change_color() returns True.

curses.init_pair(pair_number, fg, bg)

Change the definition of a color-pair. It takes three arguments: the number of the
color-pair to be changed, the foreground color number, and the background
color number. The value of pair_number must be between 1 and COLOR_PAIRS
- 1 (the 0 color pair is wired to white on black and cannot be changed). The
value of fg and bg arguments must be between 0 and COLORS - 1, or, after
calling use_default_colors(), -1. If the color-pair was previously initialized,
the screen is refreshed and all occurrences of that color-pair are changed to the
new definition.

curses.initscr()

Initialize the library. Return a window object which represents the whole screen.

Note If there is an error opening the terminal, the underlying curses library may
cause the interpreter to

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy