euporie.web.widgets.webview

Defines a web-view control.

Functions

add_cmd(**kwargs)

Add a command to the centralized command system.

cast(typ, val)

Cast a value to a type.

fragment_list_width(fragments)

Return the character width of this text fragment list.

get_app()

Get the current active (running) Application.

get_format(path[, default])

Attempt to guess the format of a path.

get_loop()

Create or return the conversion IO loop.

load_registered_bindings(*names[, config])

Assign key-bindings to commands based on a dictionary.

parse_path(path[, resolve])

Parse and resolve a path.

paste(ft_top, ft_bottom[, row, col, transparent])

Pate formatted text on top of other formatted text.

register_bindings(bindings)

Update the key-binding registry.

split_lines(fragments)

Take a single list of (style_str, text) tuples and yield one such list for each line.

Classes

Condition(func)

Turn any callable into a Filter.

Datum(data, *args, **kwargs)

Class for storing and converting display data.

Event(sender[, handler])

Simple event to which event handlers can be attached. For instance::.

FastDictCache(get_value[, size])

Fast, lightweight cache which keeps at most size items.

GraphicProcessor(control)

Class which loads and positions graphics references in a UIContent.

HTML(markup[, base, width, height, ...])

A HTML formatted text renderer.

MouseButton(*values)

MouseEvent(position, event_type, button, ...)

Mouse event, sent to UIControl.mouse_handler.

MouseEventType(*values)

Node(dom, name, parent[, text, attrs, contents])

Represent an node in the DOM.

Point(x, y)

Thread([group, target, name, args, kwargs, ...])

A class that represents a thread of control.

UIContent(get_line, StyleAndTextTuples] = >, ...)

Content generated by a user control.

UIControl()

Base class for all user interface controls.

UPath(*args[, protocol])

WebViewControl([url, link_handler])

Web view displays.

Window(*args, **kwargs)

Container that holds a control.

class euporie.web.widgets.webview.WebViewControl(url: str | Path = 'about:blank', link_handler: Callable | None = None)

Bases: UIControl

Web view displays.

A control which displays rendered HTML content.

property content_width: int

Return the width of the content.

create_content(width: int, height: int) UIContent

Generate the content for this user control.

Returns:

A UIContent instance.

property cursor_position: Point

Get the cursor position.

property dom: HTML

Return the dom for the current URL.

get_content(url: Path, loading: bool, resizing: bool, width: int, height: int, cursor_position: Point, assets_loaded: bool) UIContent

Create a cacheable UIContent.

get_dom(url: Path) HTML

Load a HTML page as renderable formatted text.

get_invalidate_events() Iterable[Event[object]]

Return a list of Event objects, which can be a generator.

the application collects all these events, in order to bind redraw handlers to these events.

get_key_bindings() KeyBindingsBase | None

Return key bindings that are specific for this user control.

Returns:

A KeyBindings object if some key bindings are specified, or

None otherwise.

invalidate() None

Trigger a redraw of the webview.

is_focusable() bool

Tell whether this user control is focusable.

load_url(url: str | Path, **kwargs: Any) None

Load a new URL.

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_eventMouseEvent instance.

Returns:

NotImplemented if the UI does not need to be updates, None if it does

move_cursor_down() None

Move the cursor down one line.

move_cursor_left() None

Move the cursor down one line.

move_cursor_right() None

Move the cursor up one line.

move_cursor_up() None

Move the cursor up one line.

nav_next() None

Navigate backwards through the browser history.

nav_prev() None

Navigate forwards through the browser history.

preferred_height(width: int, max_available_height: int, wrap_lines: bool, get_line_prefix: GetLinePrefixCallable | None) int | None

Calculate and return the preferred height of the control.

preferred_width(max_available_width: int) int | None

Calculate and return the preferred width of the control.

render(force: bool = False) None

Render the HTML DOM in a thread.

reset() None

Reset the state of the control.

property title: str

Return the title of the current HTML page.

property window: Window

Get the control’s window.