euporie.core.widgets.display
Define custom controls which re-render on resize.
Functions
|
Add a command to the centralized command system. |
|
Return the ceiling of x as an Integral. |
|
Convert between formats. |
|
Get the dimensions of an image. |
|
Find the shortest conversion path between two formats. |
|
Return the character width of this text fragment list. |
|
Get the current active (running) Application. |
|
Generate function to positioning floats over existing windows. |
|
Assign key-bindings to commands based on a dictionary. |
|
Get the cell width and aspect ration of a pixel dimension. |
|
Update the key-binding registry. |
|
Return a filter which indicates if a window is scrollable. |
|
Determine which graphic control to use. |
|
Take a single list of (style_str, text) tuples and yield one such list for each line. |
|
Wrap an escape sequence for tmux passthrough. |
|
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. |
|
Turn callable or string into string. |
|
Wrap formatted text at a given width. |
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. |
|
Wrapper around any other container that can change the visibility. |
|
A tuple of four integers with directions. |
|
Rich output displays. |
|
A data formatter, which displays cell output data. |
|
A window sub-class which can scroll left and right. |
|
Simple event to which event handlers can be attached. For instance::. |
|
Float for use in a |
|
A data formatter, which displays cell output data. |
|
A base-class for display controls which render terminal graphics. |
|
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. |
|
A container which renders a stand-alone margin. |
|
Mouse event, sent to UIControl.mouse_handler. |
|
|
Two dimensional raster of callbacks for mouse events. |
|
|
|
|
Margin displaying a scrollbar. |
|
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. |
|
|
Several layouts, one stacked left/right of the other. ::. |
|
Container that holds a control. |
|
|
partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords. |
Exceptions
Exception to signal that a graphic is not currently visible. |
- class euporie.core.widgets.display.Display(data: Any, format_: str, path: Path | None = None, fg_color: str | None = None, bg_color: str | None = None, height: AnyDimension = None, width: AnyDimension = None, px: int | None = None, py: int | None = None, focusable: FilterOrBool = False, focus_on_click: FilterOrBool = False, wrap_lines: FilterOrBool = False, always_hide_cursor: FilterOrBool = True, scrollbar: FilterOrBool = True, scrollbar_autohide: FilterOrBool = True, dont_extend_height: FilterOrBool = True, style: str | Callable[[], str] = '')
Bases:
object
Rich output displays.
A container for displaying rich output data.
- property data: Any
Return the display’s current data.
- class euporie.core.widgets.display.DisplayControl(data: Any, format_: str, path: Path | None = None, fg_color: str | None = None, bg_color: str | None = None, sizing_func: Callable[[], tuple[int, float]] | None = None, focusable: FilterOrBool = False, focus_on_click: FilterOrBool = False, wrap_lines: FilterOrBool = False)
Bases:
prompt_toolkit.layout.controls.UIControl
A data formatter, which displays cell output data.
It will attempt to display the data in the best way possible, and reacts to resize events - i.e. images are downscaled to fit, markdown is re-flowed, etc.
- create_content(width: int, height: int) prompt_toolkit.layout.controls.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.
- property cursor_position: prompt_toolkit.data_structures.Point
Get the cursor position.
- property data: Any
Return the control’s display data.
- get_key_bindings() KeyBindingsBase | None
Return the control’s key bindings.
- get_rendered_lines(width: int, height: int, wrap_lines: bool = False) list[StyleAndTextTuples]
Render the output data.
- mouse_handler(mouse_event: MouseEvent) NotImplementedOrNone
Mouse handler for this control.
- class euporie.core.widgets.display.DisplayWindow(content: UIControl | None = None, width: AnyDimension = None, height: AnyDimension = None, z_index: int | None = None, dont_extend_width: FilterOrBool = False, dont_extend_height: FilterOrBool = False, ignore_content_width: FilterOrBool = False, ignore_content_height: FilterOrBool = False, left_margins: Sequence[Margin] | None = None, right_margins: Sequence[Margin] | None = None, scroll_offsets: ScrollOffsets | None = None, allow_scroll_beyond_bottom: FilterOrBool = False, wrap_lines: FilterOrBool = False, get_vertical_scroll: Callable[[Window], int] | None = None, get_horizontal_scroll: Callable[[Window], int] | None = None, always_hide_cursor: FilterOrBool = False, cursorline: FilterOrBool = False, cursorcolumn: FilterOrBool = False, colorcolumns: None | list[ColorColumn] | Callable[[], list[ColorColumn]] = None, align: WindowAlign | Callable[[], WindowAlign] = WindowAlign.LEFT, style: str | Callable[[], str] = '', char: None | str | Callable[[], str] = None, get_line_prefix: GetLinePrefixCallable | None = None)
Bases:
prompt_toolkit.layout.containers.Window
A window sub-class which can scroll left and right.
- content: DisplayControl
- 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) prompt_toolkit.layout.dimension.Dimension
Calculate the preferred height for this window.
- preferred_width(max_available_width: int) prompt_toolkit.layout.dimension.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: prompt_toolkit.layout.screen.Screen, mouse_handlers: prompt_toolkit.layout.mouse_handlers.MouseHandlers, write_position: prompt_toolkit.layout.screen.WritePosition, parent_style: str, erase_bg: bool, z_index: int | None) None
Write window to screen. This renders the user control, the margins and copies everything over to the absolute position at the given screen.
- class euporie.core.widgets.display.FormattedTextDisplayControl(data: Any, format_: str, path: Path | None = None, fg_color: str | None = None, bg_color: str | None = None, sizing_func: Callable[[], tuple[int, float]] | None = None, focusable: FilterOrBool = False, focus_on_click: FilterOrBool = False, wrap_lines: FilterOrBool = False)
Bases:
euporie.core.widgets.display.DisplayControl
A data formatter, which displays cell output data.
It will attempt to display the data in the best way possible, and reacts to resize events - i.e. images are downscaled to fit, markdown is re-flowed, etc.
- create_content(width: int, height: int) prompt_toolkit.layout.controls.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.
- property cursor_position: prompt_toolkit.data_structures.Point
Get the cursor position.
- property data: Any
Return the control’s display data.
- get_key_bindings() KeyBindingsBase | None
Return the control’s key bindings.
- 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
Mouse handler for this control.
- class euporie.core.widgets.display.GraphicControl(data: Any, format_: str, path: Path | None = None, fg_color: str | None = None, bg_color: str | None = None, sizing_func: Callable[[], tuple[int, float]] | None = None, focusable: FilterOrBool = False, focus_on_click: FilterOrBool = False, scale: float = 0, bbox: DiInt | None = None)
Bases:
euporie.core.widgets.display.DisplayControl
A base-class for display controls which render terminal graphics.
- create_content(width: int, height: int) prompt_toolkit.layout.controls.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.
- property cursor_position: prompt_toolkit.data_structures.Point
Get the cursor position.
- property data: Any
Return the control’s display data.
- get_key_bindings() KeyBindingsBase | None
Return the control’s key bindings.
- get_rendered_lines(width: int, height: int, wrap_lines: bool = False) list[StyleAndTextTuples]
Render the output data.
- mouse_handler(mouse_event: MouseEvent) NotImplementedOrNone
Mouse handler for this control.
- class euporie.core.widgets.display.GraphicWindow(content: GraphicControl, position: Callable[[Screen], tuple[WritePosition, DiInt]], filter: FilterOrBool = True, *args: Any, **kwargs: Any)
Bases:
prompt_toolkit.layout.containers.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) prompt_toolkit.layout.dimension.Dimension
Calculate the preferred height for this window.
- preferred_width(max_available_width: int) prompt_toolkit.layout.dimension.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.widgets.display.ItermGraphicControl(data: Any, format_: str, path: Path | None = None, fg_color: str | None = None, bg_color: str | None = None, sizing_func: Callable[[], tuple[int, float]] | None = None, focusable: FilterOrBool = False, focus_on_click: FilterOrBool = False, scale: float = 0, bbox: DiInt | None = None)
Bases:
euporie.core.widgets.display.GraphicControl
A graphic control which displays images using iTerm’s graphics protocol.
- create_content(width: int, height: int) prompt_toolkit.layout.controls.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.
- property cursor_position: prompt_toolkit.data_structures.Point
Get the cursor position.
- property data: Any
Return the control’s display data.
- get_key_bindings() KeyBindingsBase | None
Return the control’s key bindings.
- 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
Mouse handler for this control.
- class euporie.core.widgets.display.KittyGraphicControl(data: Any, format_: str, path: Path | None = None, fg_color: str | None = None, bg_color: str | None = None, sizing_func: Callable[[], tuple[int, float]] | None = None, focusable: FilterOrBool = False, focus_on_click: FilterOrBool = False, scale: float = 0, bbox: DiInt | None = None)
Bases:
euporie.core.widgets.display.GraphicControl
A graphic control which displays images using Kitty’s graphics protocol.
- convert_data(rows: int, cols: int) str
Convert the graphic’s data to base64 data for kitty graphics protocol.
- create_content(width: int, height: int) prompt_toolkit.layout.controls.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.
- property cursor_position: prompt_toolkit.data_structures.Point
Get the cursor position.
- property data: Any
Return the control’s display data.
- get_key_bindings() KeyBindingsBase | None
Return the control’s key bindings.
- 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
Mouse handler for this control.
- exception euporie.core.widgets.display.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.widgets.display.SixelGraphicControl(data: Any, format_: str, path: Path | None = None, fg_color: str | None = None, bg_color: str | None = None, sizing_func: Callable[[], tuple[int, float]] | None = None, focusable: FilterOrBool = False, focus_on_click: FilterOrBool = False, scale: float = 0, bbox: DiInt | None = None)
Bases:
euporie.core.widgets.display.GraphicControl
A graphic control which displays images as sixels.
- create_content(width: int, height: int) prompt_toolkit.layout.controls.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.
- property cursor_position: prompt_toolkit.data_structures.Point
Get the cursor position.
- property data: Any
Return the control’s display data.
- get_key_bindings() KeyBindingsBase | None
Return the control’s key bindings.
- 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
Mouse handler for this control.
- euporie.core.widgets.display.get_position_func_overlay(target_window: Window) Callable[[Screen], tuple[WritePosition, DiInt]]
Generate function to positioning floats over existing windows.
- euporie.core.widgets.display.select_graphic_control(format_: str) type[euporie.core.widgets.display.GraphicControl] | None
Determine which graphic control to use.