Repository navigation
Expand file tree
/
Copy patheditor.py
More file actions
83 lines (61 loc) · 1.8 KB
/
Copy patheditor.py
File metadata and controls
83 lines (61 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
"""
This module contains an API for interacting with the main window's editors.
"""
from ._shared import _window
def open_file(path, line=None, column=0):
"""
Opens a file in a new editor.
If the file was already open, the existing editor instance is returned.
:param path: file path to open in a new editor.
:param line: line to go to (optional).
:param line: column to go to (optional).
:return: The editor widget instance that has been created.
:rtype: pyqode.core.api.CodeEdit
"""
return _window().open_file(path, line, column)
def get_current_editor():
"""
Returns the current editor widget.
:rtype: pyqode.core.api.CodeEdit
"""
return _window().current_tab
def get_current_path():
"""
Returns the path of the current editor.
"""
tab = _window().current_tab
if tab is not None:
return tab.file.path
return None
def get_all_editors(include_clones=False):
"""
Returns the list of all the open editors.
:param include_clones: True to include cloned editors (split)
:returns: a list of CodeEdit
:rtype: list
"""
return _window().tab_widget.widgets(include_clones=include_clones)
def get_all_paths():
"""
Returns the list of all the open editor paths.
:returns: a list of paths
:rtype: list of str
"""
return [w.file.path for w in _window().tab_widget.widgets()
if hasattr(w, 'file') and hasattr(w.file, 'path')]
def save_current_editor_as():
"""
Saves the current editor as (the save as dialog will be shown
automatically).
"""
_window().save_current_as()
def save_current_editor():
"""
Saves the current editor.
"""
_window().save_current()
def save_all_editors():
"""
Saves all editors.
"""
_window().save_all()