eye.helpers.buffers module¶
- eye.helpers.buffers.find_editor(path)[source]¶
Get an editor widget which has path opened
Searches in existing Editor widgets if one has path opened and return it, or None if path isn’t open in any editor. Searches with category “editor”.
- Returns:
an existing editor or None if no widget matches.
- Return type:
- eye.helpers.buffers.new_editor_open(path, loc=None, parent_tab_bar=None)[source]¶
Create a new editor with file path open
An Editor widget is created, with the contents of file at path. The new widget is attached to either the current tab widget or to parent_tab_bar if given. If loc is given, the widget will display this line-column index by default.
A new Editor will be created even if another Editor exists with the same file open already exists, and their documents won’t be shared together, so editing in a widget won’t propagate the changes into the other widget.
See also
- Parameters:
path (str) – path of the file to open
parent_tab_bar (
eye.widgets.tabs.TabWidget
) – the parent tab widget where to append the editor. If None, the currently focused tab widget will be used.loc (tuple[int, int]) – if not None, the editor shall be opened with this line/column shown (starting at 1)
- Returns:
the new editor
- Return type:
Create a new editor with same document as ed open
An editor widget is created, with the same document as existing editor ed. The new widget is attached to either the current tab widget or to parent_tab_bar if given. If loc is given, the widget will display this line-column index by default.
Since the documents of the new editor widget and ed are shared, making an modification in a widget (e.g. adding/removing characters, modifying markers/indicators, etc.) will propagate it to the other widget.
See also
new_editor_open
for the loc and parent_tab_bar parameters.- Parameters:
ed (eye.widgets.editor.Editor) – the editor with which the new editor should share the document
loc (tuple[int, int]) – if not None, the editor shall be opened with this line/column shown (starting at 1)
parent_tab_bar (
eye.widgets.tabs.TabWidget
) – the parent tab widget where to append the editor. If None, the currently focused tab widget will be used.
- Returns:
the new editor
- Return type:
Create a new editor with file path open, using an open document if possible
If another editor exists with path already open, a new editor is created with
new_editor_share
, else a new editor is created withnew_editor_open
.- Parameters:
path (str) – path of the file to open
loc (tuple[int, int]) – if not None, the editor shall be opened with this line/column shown (starting at 1)
parent_tab_bar (
eye.widgets.tabs.TabWidget
) – the parent tab widget where to append the editor. If None, the currently focused tab widget will be used.
- Return type:
- eye.helpers.buffers.open_editor(path, loc=None)[source]¶
Open a file in a new editor or focus an existing one.
If an editor widget already has path open, give it focus. Else, create a new editor (in a new tab of the currently focused tab widget).
- Parameters:
path (str) – path of the file to open in an editor widget
loc (tuple[int, int]) – optional line and column where to focus
- Returns:
an editor widget open to the file
- Return type: