euporie.core.graphics
Define controls for display of terminal graphics.
Functions
|
A decorator indicating abstract methods. |
|
Return the ceiling of x as an Integral. |
|
Find and cache conversion routes. |
|
Get the current active (running) Application. |
|
Return width of a string. |
|
Wrap an escape sequence for terminal passthrough. |
|
Determine which graphic control to use. |
|
Take a single list of (style_str, text) tuples and yield one such list for each line. |
|
Accept both booleans and Filters as input and turn it into a Filter. |
|
Convert the given value (which can be formatted text) into a list of text fragments. |
Classes
|
Metaclass for defining Abstract Base Classes (ABCs). |
|
A write position which also hold bounding box information. |
|
Represent a single character in a |
|
Turn any callable into a Filter. |
|
Class for storing and converting display data. |
|
A tuple of four integers with directions. |
|
Fast, lightweight cache which keeps at most size items. |
|
Float for use in a |
|
A base-class for display controls which render terminal graphics. |
|
Class which loads and positions graphics references in a |
|
A window responsible for displaying terminal graphics content. |
|
A graphic control which displays images using iTerm's graphics protocol. |
|
A graphic control which displays images using Kitty's graphics protocol. |
Two dimensional raster of callbacks for mouse events. |
|
|
|
|
Very simple cache that discards the oldest item when the cache size is exceeded. |
|
A graphic control which displays images as sixels. |
|
Content generated by a user control. |
Base class for all user interface controls. |
|
|
Container that holds a control. |
|
Exceptions
Exception to signal that a graphic is not currently visible. |
- class euporie.core.graphics.GraphicControl(datum: Datum, scale: float = 0, bbox: euporie.core.data_structures.DiInt | None = None)
Bases:
UIControl
A base-class for display controls which render terminal graphics.
- abstract convert_data(wp: WritePosition) str
Convert datum to required format.
- create_content(width: int, height: int) UIContent
Generate rendered output at a given size.
- Parameters:
width – The desired output width
height – The desired output height
- Returns:
UIContent for the given output size.
- get_invalidate_events() Iterable[Event[object]]
Return a list of Event objects. This can be a generator. (The application collects all these events, in order to bind redraw handlers to these events.)
- get_key_bindings() KeyBindingsBase | None
The key bindings that are specific for this user control.
Return a
KeyBindings
object if some key bindings are specified, or None otherwise.
- abstract get_rendered_lines(width: int, height: int, wrap_lines: bool = False) list[StyleAndTextTuples]
Render the output data.
- mouse_handler(mouse_event: MouseEvent) NotImplementedOrNone
Handle mouse events.
When NotImplemented is returned, it means that the given event is not handled by the UIControl itself. The Window or key bindings can decide to handle this event as scrolling or changing focus.
- Parameters:
mouse_event – MouseEvent instance.
- move_cursor_down() None
Request to move the cursor down. This happens when scrolling down and the cursor is completely at the top.
- class euporie.core.graphics.GraphicProcessor(control: UIControl)
Bases:
object
Class which loads and positions graphics references in a
UIContent
.- get_graphic_float(key: str) prompt_toolkit.layout.containers.Float | None
Create a graphical float for an image.
- class euporie.core.graphics.GraphicWindow(content: GraphicControl, get_position: Callable[[Screen], BoundedWritePosition], filter: FilterOrBool = True, *args: Any, **kwargs: Any)
Bases:
Window
A window responsible for displaying terminal graphics content.
The content is displayed floating on top of a target window.
The graphic will be displayed if: - a completion menu is not being shown - a dialog is not being shown - a menu is not being shown - the output it attached to is fully in view
- content: GraphicControl
- get_children() list[prompt_toolkit.layout.containers.Container]
Return the list of child
Container
objects.
- get_key_bindings() prompt_toolkit.key_binding.key_bindings.KeyBindingsBase | None
Returns a
KeyBindings
object. These bindings become active when any user control in this container has the focus, except if any containers between this container and the focused user control is modal.
- is_modal() bool
When this container is modal, key bindings from parent containers are not taken into account if a user control in this container is focused.
- preferred_height(width: int, max_available_height: int) Dimension
Calculate the preferred height for this window.
- preferred_width(max_available_width: int) Dimension
Calculate the preferred width for this window.
- reset() None
Reset the state of this container and all the children. (E.g. reset scroll offsets, etc…)
- write_to_screen(screen: Screen, mouse_handlers: MouseHandlers, write_position: WritePosition, parent_style: str, erase_bg: bool, z_index: int | None) None
Draw the graphic window’s contents to the screen if required.
- class euporie.core.graphics.ItermGraphicControl(datum: Datum, scale: float = 0, bbox: euporie.core.data_structures.DiInt | None = None)
Bases:
GraphicControl
A graphic control which displays images using iTerm’s graphics protocol.
- convert_data(wp: WritePosition) str
Convert the graphic’s data to base64 data.
- create_content(width: int, height: int) UIContent
Generate rendered output at a given size.
- Parameters:
width – The desired output width
height – The desired output height
- Returns:
UIContent for the given output size.
- get_invalidate_events() Iterable[Event[object]]
Return a list of Event objects. This can be a generator. (The application collects all these events, in order to bind redraw handlers to these events.)
- get_key_bindings() KeyBindingsBase | None
The key bindings that are specific for this user control.
Return a
KeyBindings
object if some key bindings are specified, or None otherwise.
- get_rendered_lines(width: int, height: int, wrap_lines: bool = False) list[StyleAndTextTuples]
Get rendered lines from the cache, or generate them.
- mouse_handler(mouse_event: MouseEvent) NotImplementedOrNone
Handle mouse events.
When NotImplemented is returned, it means that the given event is not handled by the UIControl itself. The Window or key bindings can decide to handle this event as scrolling or changing focus.
- Parameters:
mouse_event – MouseEvent instance.
- move_cursor_down() None
Request to move the cursor down. This happens when scrolling down and the cursor is completely at the top.
- class euporie.core.graphics.KittyGraphicControl(datum: Datum, scale: float = 0, bbox: euporie.core.data_structures.DiInt | None = None)
Bases:
GraphicControl
A graphic control which displays images using Kitty’s graphics protocol.
- convert_data(wp: WritePosition) str
Convert the graphic’s data to base64 data for kitty graphics protocol.
- create_content(width: int, height: int) UIContent
Generate rendered output at a given size.
- Parameters:
width – The desired output width
height – The desired output height
- Returns:
UIContent for the given output size.
- get_invalidate_events() Iterable[Event[object]]
Return a list of Event objects. This can be a generator. (The application collects all these events, in order to bind redraw handlers to these events.)
- get_key_bindings() KeyBindingsBase | None
The key bindings that are specific for this user control.
Return a
KeyBindings
object if some key bindings are specified, or None otherwise.
- get_rendered_lines(width: int, height: int, wrap_lines: bool = False) list[StyleAndTextTuples]
Get rendered lines from the cache, or generate them.
- mouse_handler(mouse_event: MouseEvent) NotImplementedOrNone
Handle mouse events.
When NotImplemented is returned, it means that the given event is not handled by the UIControl itself. The Window or key bindings can decide to handle this event as scrolling or changing focus.
- Parameters:
mouse_event – MouseEvent instance.
- move_cursor_down() None
Request to move the cursor down. This happens when scrolling down and the cursor is completely at the top.
- exception euporie.core.graphics.NotVisible
Bases:
Exception
Exception to signal that a graphic is not currently visible.
- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class euporie.core.graphics.SixelGraphicControl(datum: Datum, scale: float = 0, bbox: euporie.core.data_structures.DiInt | None = None)
Bases:
GraphicControl
A graphic control which displays images as sixels.
- convert_data(wp: WritePosition) str
Convert datum to required format.
- create_content(width: int, height: int) UIContent
Generate rendered output at a given size.
- Parameters:
width – The desired output width
height – The desired output height
- Returns:
UIContent for the given output size.
- get_invalidate_events() Iterable[Event[object]]
Return a list of Event objects. This can be a generator. (The application collects all these events, in order to bind redraw handlers to these events.)
- get_key_bindings() KeyBindingsBase | None
The key bindings that are specific for this user control.
Return a
KeyBindings
object if some key bindings are specified, or None otherwise.
- get_rendered_lines(width: int, height: int, wrap_lines: bool = False) list[StyleAndTextTuples]
Get rendered lines from the cache, or generate them.
- mouse_handler(mouse_event: MouseEvent) NotImplementedOrNone
Handle mouse events.
When NotImplemented is returned, it means that the given event is not handled by the UIControl itself. The Window or key bindings can decide to handle this event as scrolling or changing focus.
- Parameters:
mouse_event – MouseEvent instance.
- move_cursor_down() None
Request to move the cursor down. This happens when scrolling down and the cursor is completely at the top.
- euporie.core.graphics.select_graphic_control(format_: str) type[euporie.core.graphics.GraphicControl] | None
Determine which graphic control to use.