The managers package contains a series of managers classes for CodeEdit.
A manager is class that takes care of a specific aspect of CodeEdit:
- FileManager: open, save, encoding detection
- BackendManager: manage the backend process (start the process and handle communication through sockets).
- ModesManager: manage the list of modes of an editor
- PanelsManager: manage the list of panels and draw them into the editor margins.
- DecorationManager: manage text decorations
Bases: pyqode.core.api.manager.Manager
The backend controller takes care of controlling the client-server architecture.
It is responsible of starting the backend process and the client socket and exposes an API to easily control the backend:
- start
- stop
- send_request
Picks a free port
Requests some work to be done by the backend. You can get notified of the work results by passing a callback (on_receive).
Parameters: |
|
---|---|
Raise: | backend.NotRunning if the backend process is not running. |
Starts the backend process.
The backend is a python script that starts a pyqode.core.backend.JsonServer. You must write the backend script so that you can apply your own backend configuration.
The script can be run with a custom interpreter. The default is to use sys.executable.
Note
This restart the backend process if it was previously running.
Parameters: |
|
---|
Stops the backend process.
Checks if the client socket is connected to the backend.
Returns the backend process exit status or None if the process is till running.
Tells whether the backend process is running.
Returns: | True if the process is running, otherwise False |
---|
Bases: pyqode.core.api.manager.Manager
Example of usage:
editor = CodeEdit()
assert editor.file.path == ''
# open a file with default locale encoding or using the cached one.
editor.open(__file__)
assert editor.file.path == __file__
print(editor.file.encoding)
# reload with another encoding
editor.open(__file__, encoding='cp1252', use_cached_encoding=False)
assert editor.file.path == __file__
editor.file.encoding == 'cp1252'
Parameters: | clear – True to clear the editor content. Default is True. |
---|
Guesses the mime type of a file. If mime type cannot be detected, plain text is assumed.
Parameters: | path – path of the file |
---|---|
Returns: | the corresponding mime type. |
Open a file and set its content on the editor widget.
pyqode does not try to guess encoding. It’s up to the client code to handle encodings. You can either use a charset detector to detect encoding or rely on a settings in your application. It is also up to you to handle UnicodeDecodeError, unless you’ve added class:pyqode.core.panels.EncodingPanel on the editor.
pyqode automatically caches file encoding that you can later reuse it automatically.
Parameters: |
|
---|---|
Raises: | UnicodeDecodeError in case of error if no EncodingPanel were set on the editor. |
Reload the file with another encoding.
Parameters: | encoding – the new encoding to use to reload the file. |
---|
Save the editor content to a file.
Parameters: |
|
---|
True to clean trailing whitespaces of changed lines. Default is True
Gets the file directory name
Gets the file encoding
Gets the file path
Gets the file icon, provided by _get_icon
File mimetype
Gets the file base name
Opening flag. Set to true during the opening of a file.
Gets the file path
True to replace tabs by spaces
True to restore cursor position (if the document has already been
If True, the file is saved to a temporary file first. If the save went fine, the temporary file is renamed to the final filename.
Saving flag. Set to while saving the editor content to a file.
Bases: pyqode.core.api.manager.Manager
Manages the list of modes of the code edit widget.
Adds a mode to the editor.
Parameters: | mode – The mode instance to append. |
---|
Removes all modes from the editor. All modes are removed from list and deleted.
Gets a mode by name (or class)
Parameters: | name_or_klass (str or type) – The name or the class of the mode to get |
---|---|
Return type: | pyqode.core.api.Mode |
Removes a mode from the editor.
Parameters: | name_or_klass – The name (or class) of the mode to remove. |
---|---|
Returns: | The removed mode. |
Bases: pyqode.core.api.manager.Manager
Manages the list of panels and draws them inised the margin of the code edit widget.
Installs a panel on the editor.
Parameters: |
|
---|---|
Returns: | The installed panel |
Removes all panel from the editor.
Gets a specific panel instance.
Parameters: | name_or_klass – Name or class of the panel to retrieve. |
---|---|
Returns: | The specified panel instance. |
Gets the size of a specific margin.
Parameters: | position – Margin position. See pyqode.core.api.Panel.Position |
---|---|
Returns: | The size of the specified margin |
Return type: | float |
Gets the list of panels attached to the specified zone.
Parameters: | zone – Panel position. |
---|---|
Returns: | List of panels instances. |
Refreshes the editor panels (resize and update margins)
Removes the specified panel.
Parameters: | name_or_klass – Name or class of the panel to remove. |
---|---|
Returns: | The removed panel |
Resizes panels
Bases: pyqode.core.api.manager.Manager
Manages the collection of TextDecoration that have been set on the editor widget.
Adds a text decoration on a CodeEdit instance
Parameters: | decoration (pyqode.core.api.TextDecoration) – Text decoration to add |
---|
Removes all text decoration from the editor.
Removes a text decoration from the editor.
Parameters: | decoration (pyqode.core.api.TextDecoration) – Text decoration to remove |
---|