bec_widgets.widgets.editors.monaco.monaco_dock#

Classes#

MonacoDock

MonacoDock is a dock widget that contains Monaco editor instances.

Module Contents#

class MonacoDock(parent=None, **kwargs)#

Bases: bec_widgets.widgets.containers.dock_area.basic_dock_area.DockAreaWidget

MonacoDock is a dock widget that contains Monaco editor instances. It is used to manage multiple Monaco editors in a dockable interface.

Base class for all BEC widgets. This class should be used as a mixin class for all BEC widgets, e.g.:

>>> class MyWidget(BECWidget, QWidget):
>>>     def __init__(self, parent=None, client=None, config=None, gui_id=None):
>>>         super().__init__(parent=parent, client=client, config=config, gui_id=gui_id)
Parameters:
  • client (BECClient, optional) – The BEC client.

  • config (ConnectionConfig, optional) – The connection configuration.

  • gui_id (str, optional) – The GUI ID.

  • theme_update (bool, optional) – Whether to subscribe to theme updates. Defaults to False. When set to True, the widget’s apply_theme method will be called when the theme changes.

_create_editor_widget() bec_widgets.widgets.editors.monaco.monaco_widget.MonacoWidget#

Create a configured Monaco editor widget.

_ensure_area_plus(area)#
_get_editor_dock(file_name: str) bec_widgets.widgets.containers.qt_ads.CDockWidget | None#
_get_open_files() list[str]#
_install_manager_scan_and_fix_guards() None#

Track ADS structural changes to trigger scan and fix of dock areas for plus button injection.

_on_editor_close_requested(dock: bec_widgets.widgets.containers.qt_ads.CDockWidget, widget: qtpy.QtWidgets.QWidget)#
_on_focus_event(old_widget, new_widget) None#
_on_last_focused_editor_changed(editor: bec_widgets.widgets.containers.qt_ads.CDockWidget | None)#
_on_signature_change(signature: dict)#
_scan_and_fix_areas(*_arg)#
_update_macros(widget: bec_widgets.widgets.editors.monaco.monaco_widget.MonacoWidget)#
static _update_tab_title_for_modification(dock: bec_widgets.widgets.containers.qt_ads.CDockWidget, modified: bool)#

Update the tab title to show modification status with a dot indicator.

_validate_macros(source: str) bool#
add_editor(area: Any | None = None, title: str | None = None, tooltip: str | None = None) bec_widgets.widgets.containers.qt_ads.CDockWidget#

Add a new Monaco editor dock to the specified area.

Parameters:
  • area (Any | None) – The area to add the editor to. If None, adds to the main area.

  • title (str | None) – The title of the editor tab. If None, a default title is used.

  • tooltip (str | None) – The tooltip for the editor tab. If None, no tooltip is set.

Returns:

The created dock widget containing the Monaco editor.

Return type:

CDockWidget

open_file(file_name: str, scope: str = '') None#

Open a file in the specified area. If the file is already open, activate it.

Parameters:
  • file_name (str) – The path to the file to open.

  • scope (str) – The scope to set for the editor metadata.

static reset_widget(widget: bec_widgets.widgets.editors.monaco.monaco_widget.MonacoWidget)#

Reset the given Monaco editor widget to its initial state.

Parameters:

widget (MonacoWidget) – The Monaco editor widget to reset.

save_file(widget: bec_widgets.widgets.editors.monaco.monaco_widget.MonacoWidget | None = None, force_save_as: bool = False, format_on_save=True) None#

Save the currently focused file.

Parameters:
  • widget (MonacoWidget | None) – The widget to save. If None, the last focused editor will be used.

  • force_save_as (bool) – If True, the “Save As” dialog will be shown even if the file is already saved.

  • format_on_save (bool) – If True, format the code before saving if it’s a Python file.

set_file_icon(file_name: str, icon) bool#

Set an icon for a specific file’s tab.

Parameters:
  • file_name (str) – The file path to set icon for

  • icon – The QIcon to set on the tab

Returns:

True if the file was found and icon was set, False otherwise

Return type:

bool

set_file_readonly(file_name: str, read_only: bool = True) bool#

Set a specific file’s editor to read-only mode.

Parameters:
  • file_name (str) – The file path to set read-only

  • read_only (bool) – Whether to set read-only mode (default: True)

Returns:

True if the file was found and read-only was set, False otherwise

Return type:

bool

set_vim_mode(enabled: bool)#

Set Vim mode for all editor widgets.

Parameters:

enabled (bool) – Whether to enable or disable Vim mode.

focused_editor#
property last_focused_editor: bec_widgets.widgets.containers.qt_ads.CDockWidget | None#

Get the last focused editor.

macro_file_updated#
save_enabled#
signature_help#