batgrl.terminal.events#

Terminal Events.

Module Attributes

SpecialKey

A special keyboard key.

CharKey

A printable character keyboard key.

Key

A keyboard key.

MouseButton

A mouse button.

MouseEventType

A mouse event type.

Classes

ColorReportEvent(kind, color)

A background or foreground color report event.

CursorPositionResponseEvent(pos)

A cursor position response event.

DeviceAttributesReportEvent(device_attributes)

A primary device attributes report event.

Event()

Base event.

FocusEvent(focus)

A focus event.

KeyEvent(key[, alt, ctrl, shift])

A key event.

MouseEvent(pos, button, event_type, alt, ...)

A mouse event.

PasteEvent(paste)

A paste event.

ResizeEvent(size)

A terminal resize event.

UnknownEscapeSequence(escape)

Event generated from an unknown ansi escape sequence.

batgrl.terminal.events.CharKey#

A printable character keyboard key.

alias of Literal[’ ‘, ‘!’, ‘”’, ‘#’, ‘$’, ‘%’, ‘&’, “’”, ‘(’, ‘)’, ‘*’, ‘+’, ‘,’, ‘-’, ‘.’, ‘/’, ‘0’, ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’, ‘:’, ‘;’, ‘<’, ‘=’, ‘>’, ‘?’, ‘@’, ‘A’, ‘B’, ‘C’, ‘D’, ‘E’, ‘F’, ‘G’, ‘H’, ‘I’, ‘J’, ‘K’, ‘L’, ‘M’, ‘N’, ‘O’, ‘P’, ‘Q’, ‘R’, ‘S’, ‘T’, ‘U’, ‘V’, ‘W’, ‘X’, ‘Y’, ‘Z’, ‘[’, ‘\’, ‘]’, ‘^’, ‘_’, ‘`’, ‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘h’, ‘i’, ‘j’, ‘k’, ‘l’, ‘m’, ‘n’, ‘o’, ‘p’, ‘q’, ‘r’, ‘s’, ‘t’, ‘u’, ‘v’, ‘w’, ‘x’, ‘y’, ‘z’, ‘{’, ‘|’, ‘}’, ‘~’]

class batgrl.terminal.events.ColorReportEvent(kind: Literal['fg', 'bg'], color: Color)#

Bases: Event

A background or foreground color report event.

Parameters:
kindLiteral[“fg”, “bg”]

Whether report is for a foreground (“fg”) or background (“bg”) color.

colorColor

The reported color.

Attributes:
kindLiteral[“fg”, “bg”]

Whether report is for a foreground (“fg”) or background (“bg”) color.

colorColor

The reported color.

color: Color#

The reported color.

kind: Literal['fg', 'bg']#

Whether report is for a foreground (“fg”) or background (“bg”) color.

class batgrl.terminal.events.CursorPositionResponseEvent(pos: Point)#

Bases: Event

A cursor position response event.

Parameters:
posPoint

The reported cursor position.

Attributes:
posPoint

The reported cursor position.

pos: Point#

The reported cursor position.

class batgrl.terminal.events.DeviceAttributesReportEvent(device_attributes: frozenset[int])#

Bases: Event

A primary device attributes report event.

A description of the primary device attributes can be found at https://vt100.net/docs/vt510-rm/chapter4.html. (Search text for “Primary Device Attributes”).

Parameters:
device_attributesfrozenset[int]

Reported terminal attributes.

Attributes:
device_attributesfrozenset[int]

Reported terminal attributes.

device_attributes: frozenset[int]#

Reported terminal attributes.

class batgrl.terminal.events.Event#

Bases: object

Base event.

class batgrl.terminal.events.FocusEvent(focus: Literal['in', 'out'])#

Bases: Event

A focus event.

Parameters:
focusLiteral[“in”, “out”]

The type of focus; either "in" or "out".

Attributes:
focusLiteral[“in”, “out”]

The type of focus; either "in" or "out".

focus: Literal['in', 'out']#

The type of focus; either "in" or "out".

batgrl.terminal.events.Key#

A keyboard key.

alias of Literal[‘backspace’, ‘delete’, ‘down’, ‘end’, ‘enter’, ‘escape’, ‘f1’, ‘f2’, ‘f3’, ‘f4’, ‘f5’, ‘f6’, ‘f7’, ‘f8’, ‘f9’, ‘f10’, ‘f11’, ‘f12’, ‘f13’, ‘f14’, ‘f15’, ‘f16’, ‘f17’, ‘f18’, ‘f19’, ‘f20’, ‘f21’, ‘f22’, ‘f23’, ‘f24’, ‘home’, ‘insert’, ‘left’, ‘page_down’, ‘page_up’, ‘right’, ‘scroll_down’, ‘scroll_up’, ‘tab’, ‘up’] | Literal[’ ‘, ‘!’, ‘”’, ‘#’, ‘$’, ‘%’, ‘&’, “’”, ‘(’, ‘)’, ‘*’, ‘+’, ‘,’, ‘-’, ‘.’, ‘/’, ‘0’, ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’, ‘:’, ‘;’, ‘<’, ‘=’, ‘>’, ‘?’, ‘@’, ‘A’, ‘B’, ‘C’, ‘D’, ‘E’, ‘F’, ‘G’, ‘H’, ‘I’, ‘J’, ‘K’, ‘L’, ‘M’, ‘N’, ‘O’, ‘P’, ‘Q’, ‘R’, ‘S’, ‘T’, ‘U’, ‘V’, ‘W’, ‘X’, ‘Y’, ‘Z’, ‘[’, ‘\’, ‘]’, ‘^’, ‘_’, ‘`’, ‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘h’, ‘i’, ‘j’, ‘k’, ‘l’, ‘m’, ‘n’, ‘o’, ‘p’, ‘q’, ‘r’, ‘s’, ‘t’, ‘u’, ‘v’, ‘w’, ‘x’, ‘y’, ‘z’, ‘{’, ‘|’, ‘}’, ‘~’]

class batgrl.terminal.events.KeyEvent(key: Literal['backspace', 'delete', 'down', 'end', 'enter', 'escape', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f11', 'f12', 'f13', 'f14', 'f15', 'f16', 'f17', 'f18', 'f19', 'f20', 'f21', 'f22', 'f23', 'f24', 'home', 'insert', 'left', 'page_down', 'page_up', 'right', 'scroll_down', 'scroll_up', 'tab', 'up', ' ', '!', '"', '#', '$', '%', '&', "'", '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~'], alt: bool = False, ctrl: bool = False, shift: bool = False)#

Bases: Event

A key event.

Parameters:
keyKey

The pressed key.

altbool, default: False

Whether alt was pressed.

ctrlbool, default: False

Whether ctrl was pressed.

shiftbool, default: False

Whether shift was pressed.

Attributes:
keyKey

The pressed key.

altbool

Whether alt was pressed.

ctrlbool

Whether ctrl was pressed.

shiftbool

Whether shift was pressed.

metabool

Alias for alt.

controlbool

Alias for ctrl.

alt: bool = False#

Whether alt was pressed.

property control: bool#

Alias for ctrl.

ctrl: bool = False#

Whether ctrl was pressed.

key: Literal['backspace', 'delete', 'down', 'end', 'enter', 'escape', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f11', 'f12', 'f13', 'f14', 'f15', 'f16', 'f17', 'f18', 'f19', 'f20', 'f21', 'f22', 'f23', 'f24', 'home', 'insert', 'left', 'page_down', 'page_up', 'right', 'scroll_down', 'scroll_up', 'tab', 'up', ' ', '!', '"', '#', '$', '%', '&', "'", '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~']#

The pressed key.

property meta: bool#

Alias for alt.

shift: bool = False#

Whether shift was pressed.

batgrl.terminal.events.MouseButton#

A mouse button.

alias of Literal[‘left’, ‘middle’, ‘no_button’, ‘right’]

class batgrl.terminal.events.MouseEvent(pos: Point, button: Literal['left', 'middle', 'no_button', 'right'], event_type: Literal['mouse_down', 'mouse_move', 'mouse_up', 'scroll_down', 'scroll_up'], alt: bool, ctrl: bool, shift: bool, dy: int, dx: int, nclicks: int = 0)#

Bases: Event

A mouse event.

Parameters:
posPoint

The mouse position.

buttonMouseButton

The mouse button.

event_typeMouseEventType

The mouse event type.

altbool

Whether alt was pressed.

ctrlbool

Whether ctrl was pressed.

shiftbool

Whether shift was pressed.

dyint

The change in y-coordinate of the mouse position.

dxint

The change in x-coordinate of the mouse position.

nclicksint, default: 0

The number of consecutive "mouse_down" events with same button.

Attributes:
posPoint

The mouse position.

buttonMouseButton

The mouse button.

event_typeMouseEventType

The mouse event type.

altbool

Whether alt was pressed.

ctrlbool

Whether ctrl was pressed.

shiftbool

Whether shift was pressed.

dyint

The change in y-coordinate of the mouse position.

dxint

The change in x-coordinate of the mouse position.

nclicksint

The number of consecutive "mouse_down" events with same button.

metabool

Alias for alt.

controlbool

Alias for ctrl.

alt: bool#

Whether alt was pressed.

button: Literal['left', 'middle', 'no_button', 'right']#

The mouse button.

property control: bool#

Alias for ctrl.

ctrl: bool#

Whether ctrl was pressed.

dx: int#

The change in x-coordinate of the mouse position.

dy: int#

The change in y-coordinate of the mouse position.

event_type: Literal['mouse_down', 'mouse_move', 'mouse_up', 'scroll_down', 'scroll_up']#

The mouse event type.

property meta: bool#

Alias for alt.

nclicks: int = 0#

The number of consecutive "mouse_down" events with same button.

pos: Point#

The mouse position.

shift: bool#

Whether shift was pressed.

batgrl.terminal.events.MouseEventType#

A mouse event type.

alias of Literal[‘mouse_down’, ‘mouse_move’, ‘mouse_up’, ‘scroll_down’, ‘scroll_up’]

class batgrl.terminal.events.PasteEvent(paste: str)#

Bases: Event

A paste event.

Parameters:
pastestr

The paste content.

Attributes:
pastestr

The paste content.

paste: str#

The paste content.

class batgrl.terminal.events.ResizeEvent(size: Size)#

Bases: Event

A terminal resize event.

Parameters:
sizeSize

The new terminal size.

Attributes:
sizeSize

The new terminal size.

size: Size#

The new terminal size.

batgrl.terminal.events.SpecialKey#

A special keyboard key.

alias of Literal[‘backspace’, ‘delete’, ‘down’, ‘end’, ‘enter’, ‘escape’, ‘f1’, ‘f2’, ‘f3’, ‘f4’, ‘f5’, ‘f6’, ‘f7’, ‘f8’, ‘f9’, ‘f10’, ‘f11’, ‘f12’, ‘f13’, ‘f14’, ‘f15’, ‘f16’, ‘f17’, ‘f18’, ‘f19’, ‘f20’, ‘f21’, ‘f22’, ‘f23’, ‘f24’, ‘home’, ‘insert’, ‘left’, ‘page_down’, ‘page_up’, ‘right’, ‘scroll_down’, ‘scroll_up’, ‘tab’, ‘up’]

class batgrl.terminal.events.UnknownEscapeSequence(escape: str)#

Bases: Event

Event generated from an unknown ansi escape sequence.

Parameters:
escapestr

The unknown ansi escape sequence.

Attributes:
escapestr

The unknown ansi escape sequence.

escape: str#

The unknown ansi escape sequence.