GLXCurses.libs.TTY module

class GLXCurses.libs.TTY.Singleton(name, bases, dictionary)[source]

Bases: type

class GLXCurses.libs.TTY.Screen[source]

Bases: object

stdscr
cbreak

Normally, the tty driver buffers typed characters until a newline or carriage return is typed. If cbreak=True The cbreak property disables line buffering and erase/kill character-processing (interrupt and flow control characters are unaffected), making characters typed by the user immediately available to the program.

The (cbreak is False) returns the terminal to normal (cooked) mode.

Initially the terminal may or may not be in cbreak mode, as the mode is inherited; therefore, a program should call cbreak=True or cbreak=False explicitly.

Most interactive programs using curses set the cbreak=True mode.

Note that cbreak overrides raw.

The raw=False and cbreak=False calls follow historical practice in that they attempt to restore to normal (‘cooked’) mode from raw and cbreak modes respectively. M

Mixing (raw is True or False) and (cbreak is True or False) calls leads to tty driver control states that are hard to predict or understand; it is not recommended.

Note that return None if the property have never been set.

[See curs_getch(3X) for a discussion of how these routines interact with echo=True and echo=False.]

Returns:The cbreak property value
Return type:bool
echo

Control whether characters typed by the user are echoed by getch as they are typed.

Echoing by the tty driver is always disabled, but initially getch is in echo mode, so characters typed are echoed.

Authors of most interactive programs prefer to do their own echoing in a controlled area of the screen, or not to echo at all, so they disable echoing by calling noecho.

[See curs_getch(3X) for a discussion of how these routines interact with cbreak and nocbreak.]

:return the echo property value :rtype: bool

halfdelay

The halfdelay property is 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, ERR is returned if nothing has been typed.

Returns:
intrflush

If the intrflush property is enabled, (bf is TRUE), when an interrupt key is pressed on the keyboard (interrupt, break, quit) all output in the tty driver queue will be flushed, giving the effect of faster response to the interrupt, but causing curses to have the wrong idea of what is on the screen.

Disabling (bf is FALSE), the option prevents the flush.

The default for the option is inherited from the tty driver settings. The window argument is ignored.

Note: That return None only if property have never been set

Returns:The intrflush property value
Return type:bool or None
keypad

The keypad property enables the keypad of the user’s terminal.

If enabled (bf is TRUE), the user can press a function key (such as an arrow key) and wgetch returns a single value representing the function key, as in KEY_LEFT. If disabled (bf is FALSE), curses does not treat function keys specially and the program has to interpret the escape sequences itself.

If the keypad in the terminal can be turned on (made to transmit) and off (made to work locally), turning on this option causes the terminal keypad to be turned on when wgetch is called.

The default value for keypad is True.

Note: That return None if keypad have never been set.

Returns:The keypad property value
Return type:bool or None
instance = <GLXCurses.libs.TTY.Screen object>
meta

Initially, whether the terminal returns def_prog_mode7 or 8 significant bits on input depends on the control mode of the tty driver [see termio(7)].

To force 8 bits to be returned, invoke meta``=``True this is equivalent, under POSIX, to setting the CS8 flag on the terminal.

To force 7 bits to be returned, invoke meta``=``False this is equivalent, under POSIX, to setting the CS7 flag on the terminal.

If the terminfo capabilities smm (meta_on) and rmm (meta_off) are defined for the terminal, smm is sent to the terminal when meta``=``True is called and rmm is sent when meta``=``False is called.

Note: That return None when the property have never been set

Returns:The meta property value
Return type:bool or None
nodelay

The nodelay option causes getch to be a non-blocking call. If no input is ready, getch returns ERR. If disabled (bf is FALSE), getch waits until a key is pressed.

While interpreting an input escape sequence, wgetch sets a timer while waiting for the next character. If notimeout(win, TRUE) is called, then wgetch does not set a timer. The purpose of the timeout is to differentiate between sequences received from a function key and those typed by a user.

Returns:The nodelay property value
Return type:bool or None
raw

The raw property place the terminal into or out of raw mode.

Raw mode is similar to cbreak mode, in that characters typed are immediately passed through to the user program. The differences are that in raw mode, the interrupt, quit, suspend, and flow control characters are all passed through uninterpreted, instead of generating a signal.

The behavior of the BREAK key depends on other bits in the tty driver that are not set by curses.

Returns:The property value
Return type:bool or None
qiflush

When (qiflush is False) normal flush of input and output queues associated with the INTR, QUIT and SUSP characters will not be done [see termio(7)].

When (qiflush is True) is called, the queues will be flushed when these control characters are read.

You may want use (qiflush is False) in a signal handler if you want output to continue as though the interrupt had not occurred, after the handler exits.

Returns:The qiflush property value
Return type:bool or None
timeout

The timeout and wtimeout routines set blocking or non-blocking read for a given window.

If delay is negative, blocking read is used (i.e., waits indefinitely for input).

If delay is zero, then non-blocking read is used (i.e., read returns ERR if no input is waiting).

If delay is positive, then read blocks for delay milliseconds, and returns ERR if there is still no input.

Hence, these routines provide the same functionality as nodelay, plus the additional capability of being able to block for only delay milliseconds (where delay is positive).

Returns:
close()[source]

A Application must be close properly for permit to Curses to clean up everything and get back the tty in startup condition

Generally that is follow by a sys.exit(0) for generate a exit code.

lowlevel_getch()[source]

Use by the Mainloop for interact with teh keyboard and the mouse.

getch() returns an integer corresponding to the key pressed.

If it is a normal character, the integer value will be equivalent to the character. Otherwise it returns a number which can be matched with the constants defined in curses.h.

For example if the user presses F1, the integer returned is 265.

This can be checked using the macro KEY_F() defined in curses.h.

This makes reading keys portable and easy to manage.

ch = GLXCurses.Screen().lowlevel_getch()

lowlevel_getch() will wait for the user to press a key, (unless you specified a timeout) and when user presses a key, the corresponding integer is returned.

Then you can check the value returned with the constants defined in curses.h to match against the keys you want.

if ch == curses.KEY_LEFT
    print("Left arrow is pressed")
Returns:an integer corresponding to the key pressed.
Return type:int
reset_screen()[source]
refresh()[source]
touch_screen()[source]
static check_terminal(force_xterm=False)[source]
static get_mouse()[source]