plainbox.vendor.textland – TextLand

This package contains a bundled copy of the upstream TextLand project. Over time it will be updated with subsequent releases. Eventually it will be replaced by a dependency on API-stable TextLand release.

See also

TextLand upstream project: https://github.com/zyga/textland/

Text Land

class plainbox.vendor.textland.Cell(char, attributes)

Bases: tuple

attributes

Alias for field number 1

char

Alias for field number 0

count(value) → integer -- return number of occurrences of value
index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

class plainbox.vendor.textland.DrawingContext(image: plainbox.vendor.textland.image.TextImage)[source]

Bases: object

Context for simple text drawing

border(lm=0, rm=0, tm=0, bm=0) → None[source]

Draw a border around the edges of the current cli. Each parameter specifies the margin to use for a specific side of the border.

clip_by(dx1: int, dy1: int, dx2: int, dy2: int) → None[source]
clip_to(x1: int, y1: int, x2: int, y2: int) → None[source]
fill(c: str) → None[source]
move_by(dx: int, dy: int) → None[source]

Move paint offset by the specified delta

move_to(x: int, y: int) → None[source]

Move paint offset to the specified spot

print(text: str) → None[source]

Print the specified text

Multi-line strings are supported. The offset and clipping area is respected. Painting beyond the clipping area is ignored

The offset is automatically adjusted to point to the end of the string.

class plainbox.vendor.textland.Event(kind, data)

Bases: tuple

count(value) → integer -- return number of occurrences of value
data

Alias for field number 1

index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

kind

Alias for field number 0

class plainbox.vendor.textland.IApplication[source]

Bases: object

Interface for all applications.

Applications are simple objects that react to events by repainting their buffer. Each application has exactly one full-screen buffer.

consume_event(event: plainbox.vendor.textland.events.Event) → plainbox.vendor.textland.image.TextImage[source]

Send an event to the controller.

Parameters:event – Event that the controller should handle

This method is called whenever the application should react to an event. The application may raise StopIteration to ask the display to exit.

class plainbox.vendor.textland.IDisplay[source]

Bases: object

Abstract display system.

run(app: plainbox.vendor.textland.abc.IApplication) → None[source]

Run forever, feeding events to the controller the controller can raise StopIteration to “quit”

class plainbox.vendor.textland.KeyboardData(key)

Bases: tuple

count(value) → integer -- return number of occurrences of value
index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

key

Alias for field number 0

class plainbox.vendor.textland.MouseData(x, y, buttons)

Bases: tuple

buttons

Alias for field number 2

count(value) → integer -- return number of occurrences of value
index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

x

Alias for field number 0

y

Alias for field number 1

class plainbox.vendor.textland.Rect(x1, y1, x2, y2)

Bases: tuple

count(value) → integer -- return number of occurrences of value
index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

x1

Alias for field number 0

x2

Alias for field number 2

y1

Alias for field number 1

y2

Alias for field number 3

class plainbox.vendor.textland.Size(width, height)

Bases: tuple

count(value) → integer -- return number of occurrences of value
height

Alias for field number 1

index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

width

Alias for field number 0

class plainbox.vendor.textland.TestDisplay(size=Size(width=80, height=25))[source]

Bases: plainbox.vendor.textland.display.AbstractDisplay

A display that records all images and replays pre-recorded events

display_image(image: plainbox.vendor.textland.image.TextImage) → None[source]
get_display_size() → plainbox.vendor.textland.bits.Size[source]
inject_event(event: plainbox.vendor.textland.events.Event) → None[source]

Inject an event.

Events are served in FIFO mode.

run(app: plainbox.vendor.textland.abc.IApplication) → None

Run forever, feeding events to the controller the controller can raise StopIteration to “quit”

wait_for_event() → plainbox.vendor.textland.events.Event[source]
class plainbox.vendor.textland.TextAttributes[source]

Bases: object

packed
reset()[source]
static unpack(pa: int) -> (<class 'int'>, <class 'int'>, <class 'int'>)[source]

Unpack packed attributes into (fg, bg, style)

class plainbox.vendor.textland.TextImage(size: plainbox.vendor.textland.bits.Size)[source]

Bases: object

A rectangular, mutable text image.

The image supports NORMAL, REVERSE and UNDERLINE as per-cell attributes, the 8 colors described in the ANSI standard and the BOLD video attribute to render the foreground colors as bright (aka light or intensified).

get(x: int, y: int) → plainbox.vendor.textland.bits.Cell[source]

Get a cell from (x, y)

Parameters:
  • x – X coordinate
  • y – Y coordinate
Returns:

Cell(c, pa)

print_frame() → None[source]
put(x: int, y: int, c: str, pa: int) → None[source]

Put character c with attributes pa into cell at (x, y)

Parameters:
  • x – X coordinate
  • y – Y coordinate
  • c – One character string
  • pa – Packed attribute (up to uint16_t)
plainbox.vendor.textland.get_display(display=None) → plainbox.vendor.textland.abc.IDisplay[source]

Get a ITextDisplay according to TEXTLAND_DISPLAY environment variable

comments powered by Disqus