lookatme.render.context module

class lookatme.render.context.ContainerInfo(container: 'urwid.Widget', meta: 'Dict[str, Any]', source_token: 'Optional[Dict]')[source]

Bases: object

class lookatme.render.context.Context(loop: Optional[urwid.main_loop.MainLoop])[source]

Bases: object

clean_state_snapshot()[source]
clean_state_validate()[source]

Validate that all stacks are empty, that everything unwound correctly

clone() → lookatme.render.context.Context[source]

Create a new limited clone of the current context.

The only data that is actually cloned is the source and spec stacks.

container

Return the current container

container_pop() → lookatme.render.context.ContainerInfo[source]

Pop the last element off the stack. Returns the popped widget

container_push(new_item: urwid.widget.Widget, is_new_block: bool, custom_add: Optional[urwid.widget.Widget] = None)[source]

Push to the stack and propagate metadata

ensure_new_block()[source]

Ensure that we are in a new block

fake_token(type: str, **kwargs) → Dict[KT, VT][source]
get_inline_markup()[source]

Return the current inline markup, ignoring any widgets that may have made it in

get_inline_widgets()[source]

Return the results of any inline rendering that has occurred in Widget form. The conversion here is necessary since inline rendering functions often produce urwid Text Markup instead of widgets, which need to be converted to ClickableText.

inline_clear()[source]

Clear the inline rendered results

inline_convert_all_to_widgets()[source]
inline_flush()[source]

Add all inline widgets to the current container

inline_markup_consumed

Return and clear the inline markup

inline_push(inline_result: Union[urwid.widget.Widget, str, Tuple[Optional[urwid.display_common.AttrSpec], str]])[source]

Push a new inline render result onto the stack. Either a widget, or text markup

inline_widgets_consumed

Return and clear the inline widgets

is_literal
level_inc()[source]
log_debug(msg)[source]
meta

Return metadata associated with the current container, or None if the current container is None.

source

Return the current markdown source

source_get_token_lines(token: Dict[KT, VT], extra: int = 5, with_lines: bool = True, with_marker: bool = True) → List[str][source]
source_pop() → str[source]

Pop the latest source off of the source stack

source_push(new_source: str)[source]

Push new markdown source onto the source stack

spec_general

Return the current fully resolved current AttrSpec

spec_peek() → urwid.display_common.AttrSpec[source]

Return the most recent spec, or None

spec_pop()[source]

Push a new AttrSpec onto the spec_stack

spec_push(new_spec, text_only=False)[source]

Push a new AttrSpec onto the spec_stack

spec_text
spec_text_with(other_spec: Union[None, urwid.display_common.AttrSpec]) → urwid.display_common.AttrSpec[source]
tag
tag_is_ancestor(ancestor_tag_name: str) → bool[source]
tag_pop()[source]

Pop the most recent tag off of the tag stack

tag_push(new_tag: str, token: Dict[KT, VT], spec=None, text_only_spec=False)[source]

Push a new tag name onto the stack

tag_token
tokens

Return the current token iterator

tokens_pop()[source]
tokens_push(tokens: List[Dict[KT, VT]], inline: bool = False)[source]
unwind_bookmark
unwind_tokens

Generate a list of unwind (close) tokens from the token iterators in the stack

unwind_tokens_consumed

Generate a list of unwind (close) tokens from the token iterators in the stack

unwind_tokens_from(bookmark: int) → List[Dict[KT, VT]][source]
use_container(new_container: urwid.widget.Widget, is_new_block: bool, custom_add: Optional[urwid.widget.Widget] = None)[source]

Ensure that the container is pushed/popped correctly

use_container_tmp(new_container: urwid.widget.Widget)[source]

Swap out the entire container stack for a new one with the new container as the only item, while keeping spec and tag stacks

use_spec(new_spec, text_only=False)[source]

Ensure that specs are pushed/popped correctly

use_tokens(tokens, inline: bool = False)[source]

Create a context manager for pushing/popping tokens via a with block

widget_add(w: Union[List[urwid.widget.Widget], urwid.widget.Widget], wrap: Optional[bool] = False)[source]

Add the provided widget to the current container.

wrap_widget(w: urwid.widget.Widget, spec: Optional[urwid.display_common.AttrSpec] = None) → urwid.widget.Widget[source]

Wrap the provided widget with an AttrMap that will apply the current styling to the entire widget (using spec_general)