App
elva.apps.editor.app
App definition.
Classes:
-
UI
–User interface.
Attributes:
-
LANGUAGES
–Supported languages.
LANGUAGES = {'py': 'python', 'md': 'markdown', 'sh': 'bash', 'js': 'javascript', 'rs': 'rust', 'yml': 'yaml'}
module-attribute
Supported languages.
UI(config)
Bases: App
User interface.
Parameters:
-
config
(dict
) –mapping of configuration parameters to their values.
Methods:
-
on_provider_exception
–Wrapper method around the provider exception handler
-
on_awareness_update
–Wrapper method around the
-
wait_for_component_state
–Wait for a component to set a specific state.
-
on_mount
–Hook called on mounting the app.
-
on_unmount
–Hook called on unmounting the app.
-
compose
–Hook arranging child widgets.
-
action_save
–Action performed on triggering the
save
key binding. -
get_and_set_file_paths
–Get and set the data or render file paths after the input prompt.
-
action_render
–Action performed on triggering the
render
key binding. -
action_toggle_dashboard
–Action performed on triggering the
toggle_dashboard
key binding. -
push_client_states
–Method pushing the client states to the active dashboard.
-
push_config
–Method pushing the configuration mapping to the active dashboard.
Attributes:
-
CSS_PATH
–The path to the default CSS.
-
SCREENS
–The installed screens.
-
BINDINGS
–Key bindings for actions of the app.
-
language
(str
) –The language the text document is written in.
Source code in src/elva/apps/editor/app.py
CSS_PATH = 'style.tcss'
class-attribute
instance-attribute
The path to the default CSS.
SCREENS = {'dashboard': Dashboard, 'input': InputScreen}
class-attribute
instance-attribute
The installed screens.
BINDINGS = [Binding('ctrl+b', 'toggle_dashboard', 'Toggle the dashboard'), Binding('ctrl+s', 'save', 'Save to data file'), Binding('ctrl+r', 'render', 'Render to file')]
class-attribute
instance-attribute
Key bindings for actions of the app.
language
property
The language the text document is written in.
on_provider_exception(exc, config)
Wrapper method around the provider exception handler
_on_provider_exception
.
Parameters:
-
exc
(WebSocketException
) –the exception raised by the provider.
-
config
(dict
) –the configuration stored in the provider.
Source code in src/elva/apps/editor/app.py
_on_provider_exception(exc, config)
async
Handler for exceptions raised by the provider.
It exits the app after displaying the error message to the user.
Parameters:
-
exc
(WebSocketException
) –the exception raised by the provider.
-
config
(dict
) –the configuration stored in the provider.
Source code in src/elva/apps/editor/app.py
on_awareness_update(topic, data)
Wrapper method around the
_on_awareness_update
callback.
Parameters:
-
topic
(Literal['update', 'change']
) –the topic under which the changes are published.
-
data
(tuple[dict, Any]
) –manipulation actions taken as well as the origin of the changes.
Source code in src/elva/apps/editor/app.py
_on_awareness_update(topic, data)
async
Hook called on a change in the awareness states.
It pushes client states to the dashboard and removes offline client IDs from the future.
Parameters:
-
topic
(Literal['update', 'change']
) –the topic under which the changes are published.
-
data
(tuple[dict, Any]
) –manipulation actions taken as well as the origin of the changes.
Source code in src/elva/apps/editor/app.py
wait_for_component_state(component, state)
async
Wait for a component to set a specific state.
Parameters:
-
component
(Component
) –the component of interest.
-
state
(ComponentState
) –the awaited state.
Source code in src/elva/apps/editor/app.py
on_mount()
async
Hook called on mounting the app.
Source code in src/elva/apps/editor/app.py
on_unmount()
async
Hook called on unmounting the app.
Source code in src/elva/apps/editor/app.py
compose()
action_save()
async
get_and_set_file_paths(data_file=True)
async
Get and set the data or render file paths after the input prompt.
Parameters:
-
data_file
(bool
, default:True
) –flag whether to add a data file path to the config.
Source code in src/elva/apps/editor/app.py
action_render()
async
Action performed on triggering the render
key binding.
Source code in src/elva/apps/editor/app.py
action_toggle_dashboard()
async
Action performed on triggering the toggle_dashboard
key binding.
Source code in src/elva/apps/editor/app.py
push_client_states()
Method pushing the client states to the active dashboard.
Source code in src/elva/apps/editor/app.py
push_config()
Method pushing the configuration mapping to the active dashboard.