class euporie.core.widgets.cell.FormattedTextControl(text: AnyFormattedText = '', style: str = '', focusable: FilterOrBool = False, key_bindings: KeyBindingsBase | None = None, show_cursor: bool = True, modal: bool = False, get_cursor_position: Callable[[], Point | None] | None = None)

Control that displays formatted text. This can be either plain text, an HTML object an ANSI object, a list of (style_str, text) tuples or a callable that takes no argument and returns one of those, depending on how you prefer to do the formatting. See prompt_toolkit.layout.formatted_text for more information.

(It’s mostly optimized for rather small widgets, like toolbars, menus, etc…)

When this UI control has the focus, the cursor will be shown in the upper left corner of this control by default. There are two ways for specifying the cursor position:

  • Pass a get_cursor_position function which returns a Point instance with the current cursor position.

  • If the (formatted) text is passed as a list of (style, text) tuples and there is one that looks like ('[SetCursorPosition]', ''), then this will specify the cursor position.

Mouse support:

The list of fragments can also contain tuples of three items, looking like: (style_str, text, handler). When mouse support is enabled and the user clicks on this fragment, then the given handler is called. That handler should accept two inputs: (Application, MouseEvent) and it should either handle the event or return NotImplemented in case we want the containing Window to handle this event.

  • focusablebool or Filter: Tell whether this control is focusable.

  • text – Text or formatted text to be displayed.

  • style – Style string applied to the content. (If you want to style the whole Window, pass the style to the Window instead.)

  • key_bindings – a KeyBindings object.

  • get_cursor_position – A callable that returns the cursor position as a Point instance.