Package tdl :: Class Typewriter |
[frames] | no frames]

# Class Typewriter

source code

    object --+
             |
            Typewriter

Converts a console into a scrolling text log that respects special characters.

This class works best on a Window or off-screen Console instance. In a Window for example the scrolling text is limited to the Window's isolated area.

Instance Methods
__init__(self, console) Add a virtual cursor to a Console or Window instance. | source code
addChar(self, char) Draw a single character at the cursor. | source code
addStr(self, string) Write a string at the cursor. | source code
(int, int) |
getCursor(self) Return the virtual cursor position. | source code
move(self, x, y) Move the virtual cursor. | source code
setBG(self, color) Change the background color | source code
setFG(self, color) Change the foreground color | source code
write(self, string) This method mimics basic file-like behaviour. | source code
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties
Inherited from `object`: `__class__`

Method Details

### __init__(self, console) (Constructor) | source code
Add a virtual cursor to a Console or Window instance. Parameters: `console` (Console or Window) Overrides: object.__init__

### addStr(self, string) | source code
Write a string at the cursor. Handles special characters such as newlines. Parameters: `string` (string)

### getCursor(self) | source code
Return the virtual cursor position. Returns: (int, int) Returns (x, y) a 2-integer tuple containing where the next addChar or addStr will start at. This can be changed with the move method.

### move(self, x, y) | source code
Move the virtual cursor. Parameters: `x` (int) - X position to place the cursor. `y` (int) - Y position to place the cursor.

### write(self, string) | source code
This method mimics basic file-like behaviour. Because of this method you can replace sys.stdout or sys.stderr with a Typewriter instance. Parameters: `string` (string)