screen — Implements a virtual screen, used to support ANSI terminal emulation.

This implements a virtual screen. This is used to support ANSI terminal emulation. The screen representation and state is implemented in this class. Most of the methods are inspired by ANSI screen control codes. The ANSI class extends this class to add parsing of ANSI escape codes.

$Id: screen.py 486 2007-07-13 01:04:16Z noah $

screen.constrain(n, min, max)

This returns a number, n constrained to the min and max bounds.

class screen.screen(r=24, c=80)

This object maintains the state of a virtual text screen as a rectangluar array. This maintains a virtual cursor position and handles scrolling as characters are added. This supports most of the methods needed by an ANSI text screen. Row and column indexes are 1-based (not zero-based, like arrays).

clear_all_tabs()

Clears all tabs.

clear_tab()

Clears tab at the current position.

cr()

This moves the cursor to the beginning (col 1) of the current row.

crlf()

This advances the cursor with CRLF properties. The cursor will line wrap and the screen may scroll.

cursor_constrain()

This keeps the cursor within the screen area.

cursor_force_position(r, c)

Identical to Cursor Home.

cursor_restore_attrs()

Restores cursor position after a Save Cursor.

cursor_save()

Save current cursor position.

cursor_save_attrs()

Save current cursor position.

cursor_unsave()

Restores cursor position after a Save Cursor.

dump()

This returns a copy of the screen as a string. This is similar to __str__ except that lines are not terminated with line feeds.

erase_down()

Erases the screen from the current line down to the bottom of the screen.

erase_end_of_line()

Erases from the current cursor position to the end of the current line.

erase_line()

Erases the entire current line.

erase_screen()

Erases the screen with the background color.

erase_start_of_line()

Erases from the current cursor position to the start of the current line.

erase_up()

Erases the screen from the current line up to the top of the screen.

get_region(rs, cs, re, ce)

This returns a list of lines representing the region.

insert_abs(r, c, ch)

This inserts a character at (r,c). Everything under and to the right is shifted right one character. The last character of the line is lost.

lf()

This moves the cursor down with scrolling.

newline()

This is an alias for crlf().

pretty()

This returns a copy of the screen as a string with an ASCII text box around the screen border. This is similar to __str__ except that it adds a box.

put(ch)

This puts a characters at the current cursor position.

put_abs(r, c, ch)

Screen array starts at 1 index.

scroll_constrain()

This keeps the scroll region within the screen region.

scroll_down()

Scroll display down one line.

scroll_screen()

Enable scrolling for entire display.

scroll_screen_rows(rs, re)

Enable scrolling from row {start} to row {end}.

scroll_up()

Scroll display up one line.

set_tab()

Sets a tab at the current position.

Previous topic

pxssh — Extends pexpect.spawn to specialize setting up SSH connections.

Next topic

ANSI — This implements an ANSI terminal emulator as a subclass of screen.

This Page