screen - manage a virtual ‘screen’¶
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.
- This license is approved by the OSI and FSF as GPL-compatible.
Copyright (c) 2012, Noah Spurrier <email@example.com> PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES. THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- class pexpect.screen.screen(r=24, c=80)[source]¶
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).
This returns a printable representation of the screen. The end of each screen line is terminated by a newline.
This advances the cursor with CRLF properties. The cursor will line wrap and the screen may scroll.
This returns a copy of the screen as a string. This is similar to __str__ except that lines are not terminated with line feeds.
Erases from the current cursor position to the end of the current line.
Erases from the current cursor position to the start of the current line.
- insert_abs(r, c, ch)[source]¶
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.
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.