Editor
elva.apps.editor
ELVA editor app.
Classes:
-
LogStatus
–Widget reflecting the state of logging.
-
StoreStatus
–Widget reflecting the state of storage.
-
RendererStatus
–Widget reflecting the state of rendering.
-
ProviderStatus
–Widget reflecting the state of a provider.
-
UI
–User interface.
Functions:
-
get_provider
–Get the provider from the message parameter in the merged configuration.
-
encode_content
–Encode data for inclusion in the displayed QR code for sharing.
-
cli
–Edit text documents collaboratively in real-time.
Attributes:
-
LOG_LEVEL_MAP
–Mapping of logging levels to their corresponding names.
-
LANGUAGES
–Supported languages.
LOG_LEVEL_MAP = dict(FATAL=logging.FATAL, ERROR=logging.ERROR, WARNING=logging.WARNING, INFO=logging.INFO, DEBUG=logging.DEBUG)
module-attribute
Mapping of logging levels to their corresponding names.
LANGUAGES = {'py': 'python', 'md': 'markdown', 'sh': 'bash', 'js': 'javascript', 'rs': 'rust', 'yml': 'yaml'}
module-attribute
Supported languages.
LogStatus(params, *args, config=None, rename=None, **kwargs)
Bases: FeatureStatus
Widget reflecting the state of logging.
Methods:
-
apply
–Apply the new state.
-
on_button_pressed
–Hook called on a button pressed event.
Attributes:
Source code in src/elva/widgets/status.py
is_ready
property
Flag whether all conditions for successful logging are fulfilled.
Returns:
-
bool
–True
if all conditions are fulfilled, elseFalse
.
apply()
Apply the new state.
If is_ready
returns True
, logging gets reinitialized with updated parameters.
Else, logging is stopped.
Source code in src/elva/apps/editor.py
on_button_pressed(message)
Hook called on a button pressed event.
Basically, this method toggles the state of the logging feature.
Parameters:
-
message
(Message
) –an object holding information about the button pressed event.
Source code in src/elva/apps/editor.py
StoreStatus(yobject, params, *args, **kwargs)
Bases: ComponentStatus
Widget reflecting the state of storage.
Methods:
-
on_worker_state_changed
–Hook called on a worker state change event.
Attributes:
-
component
–Instance of the controlled
SQLiteStore
component. -
is_ready
(bool
) –Flag whether all conditions for successful storing are fulfilled.
Source code in src/elva/widgets/status.py
component = SQLiteStore
class-attribute
instance-attribute
Instance of the controlled SQLiteStore
component.
is_ready
property
Flag whether all conditions for successful storing are fulfilled.
Returns:
-
bool
–True
if all conditions are fulfilled, elseFalse
.
on_worker_state_changed(message)
Hook called on a worker state change event.
This method changes the status depending on the state of the worker the SQLiteStore
component is running in.
Parameters:
-
message
(Message
) –an object holding information about the worker state change event.
Source code in src/elva/apps/editor.py
RendererStatus(yobject, params, *args, **kwargs)
Bases: ComponentStatus
Widget reflecting the state of rendering.
Methods:
-
on_worker_state_changed
–Hook called on a worker state change event.
Attributes:
-
component
–Instance of the controlled
TextRenderer
component. -
is_ready
(bool
) –Flag whether all conditions for successful rendering are fulfilled.
Source code in src/elva/widgets/status.py
component = TextRenderer
class-attribute
instance-attribute
Instance of the controlled TextRenderer
component.
is_ready
property
Flag whether all conditions for successful rendering are fulfilled.
Returns:
-
bool
–True
if all conditions are fulfilled, elseFalse
.
on_worker_state_changed(message)
Hook called on a worker state change event.
This method changes the status depending on the state of the worker the TextRenderer
component is running in.
Parameters:
-
message
(Message
) –an object holding information about the worker state change event.
Source code in src/elva/apps/editor.py
ProviderStatus(yobject, params, *args, **kwargs)
Bases: ComponentStatus
Widget reflecting the state of a provider.
Methods:
-
on_worker_state_changed
–Hook called on a worker state change event.
-
watch_connection_status
–Watch the connection status of the controlled provider component.
Attributes:
-
component
–Instance of the controlled provider component.
-
is_ready
(bool
) –Flag whether all conditions for successful connection are fulfilled.
Source code in src/elva/widgets/status.py
component = get_provider
class-attribute
instance-attribute
Instance of the controlled provider component.
is_ready
property
Flag whether all conditions for successful connection are fulfilled.
Returns:
-
bool
–True
if all conditions are fulfilled, elseFalse
.
on_worker_state_changed(message)
Hook called on a worker state change event.
This method changes the status depending on the state of the worker the provider component is running in.
Parameters:
-
message
(Message
) –an object holding information about the worker state change event.
Source code in src/elva/apps/editor.py
watch_connection_status()
async
Watch the connection status of the controlled provider component.
This method listens for connection or disconnection events and update the status accordingly.
Source code in src/elva/apps/editor.py
UI(config)
Bases: App
User interface.
Parameters:
-
config
(dict
) –mapping of configuration parameters to their values.
Methods:
-
on_config_panel_applied
–Hook called on an applied event from the config panel.
-
on_exception
–Hook called on an exception raised in the provider component.
-
on_mount
–Hook called on mounting the app.
-
compose
–Hook arranging child widgets.
-
on_button_pressed
–Hook called on a pressed button event.
-
on_config_view_saved
–Hook called on a Saved event from a config view.
-
on_config_view_changed
–Hook called on a
Changed
event from a config view. -
update_qrcode
–Update the QR code for sharing.
-
action_render
–Hook called on an invoked render action.
-
action_save
–Hook called on an invoked save action.
Attributes:
-
CSS_PATH
–Path to the used textual CSS file.
-
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.py
CSS_PATH = 'editor.tcss'
class-attribute
instance-attribute
Path to the used textual CSS file.
BINDINGS = [Binding('ctrl+s', 'save'), Binding('ctrl+r', 'render')]
class-attribute
instance-attribute
Key bindings for actions of the app.
language
property
The language the text document is written in.
on_config_panel_applied(message)
async
Hook called on an applied event from the config panel.
This method transfers the new configuration to the status widgets.
Parameters:
-
message
(Message
) –an object holding information about the applied event.
Source code in src/elva/apps/editor.py
on_exception(exc)
async
Hook called on an exception raised in the provider component.
This method opens the config panel and updates the provider status widget to signal the issue to the user.
Parameters:
-
exc
(Exception
) –the exception that the provide component raised.
Raises:
-
exc
–the exception that was raised by the provider component.
Source code in src/elva/apps/editor.py
on_mount()
async
Hook called on mounting the app.
compose()
Hook arranging child widgets.
Source code in src/elva/apps/editor.py
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
|
on_button_pressed(message)
Hook called on a pressed button event.
This methods toggles the visibility of the config panel.
Parameters:
-
message
(Message
) –an object holding information about the button pressed event.
Source code in src/elva/apps/editor.py
on_config_view_saved(message)
Hook called on a Saved event from a config view.
This methods saves the config view's key-value-pair as metadata entry to the ELVA SQLite database file.
Parameters:
-
message
(Message
) –an object holding information about the button pressed event.
Source code in src/elva/apps/editor.py
on_config_view_changed(message)
Hook called on a Changed
event from a config view.
This methods keeps the QR Code updated.
Parameters:
-
message
(Message
) –an object holding information about the button pressed event.
Source code in src/elva/apps/editor.py
update_qrcode()
Update the QR code for sharing.
This method queries the current values from the identifier, server and message views, encodes them and updates the QR Code with that.
Source code in src/elva/apps/editor.py
action_render()
Hook called on an invoked render action.
If a renderer component is running, its write
method is called.
Otherwise, the config panel opens to let the user fill in missing information.
Source code in src/elva/apps/editor.py
action_save()
Hook called on an invoked save action.
If a store component is running, nothing happens - everything gets written automatically. Otherwise, the config panel opens to let the user fill in missing information.
Source code in src/elva/apps/editor.py
get_provider(self, ydoc, **config)
Get the provider from the message parameter in the merged configuration.
Parameters:
-
ydoc
(Doc
) –instance of a Y Document passed to the provider class.
-
config
(dict
, default:{}
) –merged configuration parameters.
Returns:
-
WebsocketProvider | ElvaWebsocketProvider
–instance of a provider.
Source code in src/elva/apps/editor.py
encode_content(data)
cli(ctx, auto_render, apply, ansi_color, file)
Edit text documents collaboratively in real-time.
Parameters:
-
ctx
(Context
) –the click context holding the configuration parameter mapping.
-
auto_render
(bool
) –flag whether to render on closing.
-
apply
(bool
) –flag whether to mark the configuration as applied.
-
ansi_color
(bool
) –flag whether to use the terminal's ANSI color codes.
-
file
(None | Path
) –path to the ELVA SQLite database file.