id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
30,700
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
StackHistory._update_id_list
def _update_id_list(self): """Update list of corresponpding ids and tabs.""" self.id_list = [id(self.editor.tabs.widget(_i)) for _i in range(self.editor.tabs.count())]
python
def _update_id_list(self): """Update list of corresponpding ids and tabs.""" self.id_list = [id(self.editor.tabs.widget(_i)) for _i in range(self.editor.tabs.count())]
[ "def", "_update_id_list", "(", "self", ")", ":", "self", ".", "id_list", "=", "[", "id", "(", "self", ".", "editor", ".", "tabs", ".", "widget", "(", "_i", ")", ")", "for", "_i", "in", "range", "(", "self", ".", "editor", ".", "tabs", ".", "count...
Update list of corresponpding ids and tabs.
[ "Update", "list", "of", "corresponpding", "ids", "and", "tabs", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L249-L252
30,701
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
StackHistory.refresh
def refresh(self): """Remove editors that are not longer open.""" self._update_id_list() for _id in self.history[:]: if _id not in self.id_list: self.history.remove(_id)
python
def refresh(self): """Remove editors that are not longer open.""" self._update_id_list() for _id in self.history[:]: if _id not in self.id_list: self.history.remove(_id)
[ "def", "refresh", "(", "self", ")", ":", "self", ".", "_update_id_list", "(", ")", "for", "_id", "in", "self", ".", "history", "[", ":", "]", ":", "if", "_id", "not", "in", "self", ".", "id_list", ":", "self", ".", "history", ".", "remove", "(", ...
Remove editors that are not longer open.
[ "Remove", "editors", "that", "are", "not", "longer", "open", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L254-L259
30,702
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
StackHistory.remove
def remove(self, tab_index): """Remove the widget at the corresponding tab_index.""" _id = id(self.editor.tabs.widget(tab_index)) if _id in self.history: self.history.remove(_id)
python
def remove(self, tab_index): """Remove the widget at the corresponding tab_index.""" _id = id(self.editor.tabs.widget(tab_index)) if _id in self.history: self.history.remove(_id)
[ "def", "remove", "(", "self", ",", "tab_index", ")", ":", "_id", "=", "id", "(", "self", ".", "editor", ".", "tabs", ".", "widget", "(", "tab_index", ")", ")", "if", "_id", "in", "self", ".", "history", ":", "self", ".", "history", ".", "remove", ...
Remove the widget at the corresponding tab_index.
[ "Remove", "the", "widget", "at", "the", "corresponding", "tab_index", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L287-L291
30,703
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
StackHistory.remove_and_append
def remove_and_append(self, index): """Remove previous entrances of a tab, and add it as the latest.""" while index in self: self.remove(index) self.append(index)
python
def remove_and_append(self, index): """Remove previous entrances of a tab, and add it as the latest.""" while index in self: self.remove(index) self.append(index)
[ "def", "remove_and_append", "(", "self", ",", "index", ")", ":", "while", "index", "in", "self", ":", "self", ".", "remove", "(", "index", ")", "self", ".", "append", "(", "index", ")" ]
Remove previous entrances of a tab, and add it as the latest.
[ "Remove", "previous", "entrances", "of", "a", "tab", "and", "add", "it", "as", "the", "latest", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L293-L297
30,704
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
TabSwitcherWidget.load_data
def load_data(self): """Fill ListWidget with the tabs texts. Add elements in inverse order of stack_history. """ for index in reversed(self.stack_history): text = self.tabs.tabText(index) text = text.replace('&', '') item = QListWidgetItem(ima.icon('TextFileIcon'), text) self.addItem(item)
python
def load_data(self): """Fill ListWidget with the tabs texts. Add elements in inverse order of stack_history. """ for index in reversed(self.stack_history): text = self.tabs.tabText(index) text = text.replace('&', '') item = QListWidgetItem(ima.icon('TextFileIcon'), text) self.addItem(item)
[ "def", "load_data", "(", "self", ")", ":", "for", "index", "in", "reversed", "(", "self", ".", "stack_history", ")", ":", "text", "=", "self", ".", "tabs", ".", "tabText", "(", "index", ")", "text", "=", "text", ".", "replace", "(", "'&'", ",", "''...
Fill ListWidget with the tabs texts. Add elements in inverse order of stack_history.
[ "Fill", "ListWidget", "with", "the", "tabs", "texts", ".", "Add", "elements", "in", "inverse", "order", "of", "stack_history", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L326-L336
30,705
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
TabSwitcherWidget.item_selected
def item_selected(self, item=None): """Change to the selected document and hide this widget.""" if item is None: item = self.currentItem() # stack history is in inverse order try: index = self.stack_history[-(self.currentRow()+1)] except IndexError: pass else: self.editor.set_stack_index(index) self.editor.current_changed(index) self.hide()
python
def item_selected(self, item=None): """Change to the selected document and hide this widget.""" if item is None: item = self.currentItem() # stack history is in inverse order try: index = self.stack_history[-(self.currentRow()+1)] except IndexError: pass else: self.editor.set_stack_index(index) self.editor.current_changed(index) self.hide()
[ "def", "item_selected", "(", "self", ",", "item", "=", "None", ")", ":", "if", "item", "is", "None", ":", "item", "=", "self", ".", "currentItem", "(", ")", "# stack history is in inverse order\r", "try", ":", "index", "=", "self", ".", "stack_history", "[...
Change to the selected document and hide this widget.
[ "Change", "to", "the", "selected", "document", "and", "hide", "this", "widget", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L338-L351
30,706
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
TabSwitcherWidget.select_row
def select_row(self, steps): """Move selected row a number of steps. Iterates in a cyclic behaviour. """ row = (self.currentRow() + steps) % self.count() self.setCurrentRow(row)
python
def select_row(self, steps): """Move selected row a number of steps. Iterates in a cyclic behaviour. """ row = (self.currentRow() + steps) % self.count() self.setCurrentRow(row)
[ "def", "select_row", "(", "self", ",", "steps", ")", ":", "row", "=", "(", "self", ".", "currentRow", "(", ")", "+", "steps", ")", "%", "self", ".", "count", "(", ")", "self", ".", "setCurrentRow", "(", "row", ")" ]
Move selected row a number of steps. Iterates in a cyclic behaviour.
[ "Move", "selected", "row", "a", "number", "of", "steps", ".", "Iterates", "in", "a", "cyclic", "behaviour", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L353-L359
30,707
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
TabSwitcherWidget.set_dialog_position
def set_dialog_position(self): """Positions the tab switcher in the top-center of the editor.""" left = self.editor.geometry().width()/2 - self.width()/2 top = self.editor.tabs.tabBar().geometry().height() self.move(self.editor.mapToGlobal(QPoint(left, top)))
python
def set_dialog_position(self): """Positions the tab switcher in the top-center of the editor.""" left = self.editor.geometry().width()/2 - self.width()/2 top = self.editor.tabs.tabBar().geometry().height() self.move(self.editor.mapToGlobal(QPoint(left, top)))
[ "def", "set_dialog_position", "(", "self", ")", ":", "left", "=", "self", ".", "editor", ".", "geometry", "(", ")", ".", "width", "(", ")", "/", "2", "-", "self", ".", "width", "(", ")", "/", "2", "top", "=", "self", ".", "editor", ".", "tabs", ...
Positions the tab switcher in the top-center of the editor.
[ "Positions", "the", "tab", "switcher", "in", "the", "top", "-", "center", "of", "the", "editor", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L361-L366
30,708
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
TabSwitcherWidget.keyReleaseEvent
def keyReleaseEvent(self, event): """Reimplement Qt method. Handle "most recent used" tab behavior, When ctrl is released and tab_switcher is visible, tab will be changed. """ if self.isVisible(): qsc = get_shortcut(context='Editor', name='Go to next file') for key in qsc.split('+'): key = key.lower() if ((key == 'ctrl' and event.key() == Qt.Key_Control) or (key == 'alt' and event.key() == Qt.Key_Alt)): self.item_selected() event.accept()
python
def keyReleaseEvent(self, event): """Reimplement Qt method. Handle "most recent used" tab behavior, When ctrl is released and tab_switcher is visible, tab will be changed. """ if self.isVisible(): qsc = get_shortcut(context='Editor', name='Go to next file') for key in qsc.split('+'): key = key.lower() if ((key == 'ctrl' and event.key() == Qt.Key_Control) or (key == 'alt' and event.key() == Qt.Key_Alt)): self.item_selected() event.accept()
[ "def", "keyReleaseEvent", "(", "self", ",", "event", ")", ":", "if", "self", ".", "isVisible", "(", ")", ":", "qsc", "=", "get_shortcut", "(", "context", "=", "'Editor'", ",", "name", "=", "'Go to next file'", ")", "for", "key", "in", "qsc", ".", "spli...
Reimplement Qt method. Handle "most recent used" tab behavior, When ctrl is released and tab_switcher is visible, tab will be changed.
[ "Reimplement", "Qt", "method", ".", "Handle", "most", "recent", "used", "tab", "behavior", "When", "ctrl", "is", "released", "and", "tab_switcher", "is", "visible", "tab", "will", "be", "changed", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L368-L382
30,709
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
TabSwitcherWidget.keyPressEvent
def keyPressEvent(self, event): """Reimplement Qt method to allow cyclic behavior.""" if event.key() == Qt.Key_Down: self.select_row(1) elif event.key() == Qt.Key_Up: self.select_row(-1)
python
def keyPressEvent(self, event): """Reimplement Qt method to allow cyclic behavior.""" if event.key() == Qt.Key_Down: self.select_row(1) elif event.key() == Qt.Key_Up: self.select_row(-1)
[ "def", "keyPressEvent", "(", "self", ",", "event", ")", ":", "if", "event", ".", "key", "(", ")", "==", "Qt", ".", "Key_Down", ":", "self", ".", "select_row", "(", "1", ")", "elif", "event", ".", "key", "(", ")", "==", "Qt", ".", "Key_Up", ":", ...
Reimplement Qt method to allow cyclic behavior.
[ "Reimplement", "Qt", "method", "to", "allow", "cyclic", "behavior", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L384-L389
30,710
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
TabSwitcherWidget.focusOutEvent
def focusOutEvent(self, event): """Reimplement Qt method to close the widget when loosing focus.""" event.ignore() # Inspired from CompletionWidget.focusOutEvent() in file # widgets/sourcecode/base.py line 212 if sys.platform == "darwin": if event.reason() != Qt.ActiveWindowFocusReason: self.close() else: self.close()
python
def focusOutEvent(self, event): """Reimplement Qt method to close the widget when loosing focus.""" event.ignore() # Inspired from CompletionWidget.focusOutEvent() in file # widgets/sourcecode/base.py line 212 if sys.platform == "darwin": if event.reason() != Qt.ActiveWindowFocusReason: self.close() else: self.close()
[ "def", "focusOutEvent", "(", "self", ",", "event", ")", ":", "event", ".", "ignore", "(", ")", "# Inspired from CompletionWidget.focusOutEvent() in file\r", "# widgets/sourcecode/base.py line 212\r", "if", "sys", ".", "platform", "==", "\"darwin\"", ":", "if", "event", ...
Reimplement Qt method to close the widget when loosing focus.
[ "Reimplement", "Qt", "method", "to", "close", "the", "widget", "when", "loosing", "focus", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L391-L400
30,711
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.setup_editorstack
def setup_editorstack(self, parent, layout): """Setup editorstack's layout""" layout.setSpacing(1) self.fname_label = QLabel() self.fname_label.setStyleSheet( "QLabel {margin: 0px; padding: 3px;}") layout.addWidget(self.fname_label) menu_btn = create_toolbutton(self, icon=ima.icon('tooloptions'), tip=_('Options')) # Don't show menu arrow and remove padding if is_dark_interface(): menu_btn.setStyleSheet( ("QToolButton::menu-indicator{image: none;}\n" "QToolButton{margin: 1px; padding: 3px;}")) else: menu_btn.setStyleSheet( "QToolButton::menu-indicator{image: none;}") self.menu = QMenu(self) menu_btn.setMenu(self.menu) menu_btn.setPopupMode(menu_btn.InstantPopup) self.menu.aboutToShow.connect(self.__setup_menu) corner_widgets = {Qt.TopRightCorner: [menu_btn]} self.tabs = BaseTabs(self, menu=self.menu, menu_use_tooltips=True, corner_widgets=corner_widgets) self.tabs.tabBar().setObjectName('plugin-tab') self.tabs.set_close_function(self.close_file) self.tabs.tabBar().tabMoved.connect(self.move_editorstack_data) self.tabs.setMovable(True) self.stack_history.refresh() if hasattr(self.tabs, 'setDocumentMode') \ and not sys.platform == 'darwin': # Don't set document mode to true on OSX because it generates # a crash when the editor is detached from the main window # Fixes Issue 561 self.tabs.setDocumentMode(True) self.tabs.currentChanged.connect(self.current_changed) if sys.platform == 'darwin': tab_container = QWidget() tab_container.setObjectName('tab-container') tab_layout = QHBoxLayout(tab_container) tab_layout.setContentsMargins(0, 0, 0, 0) tab_layout.addWidget(self.tabs) layout.addWidget(tab_container) else: layout.addWidget(self.tabs)
python
def setup_editorstack(self, parent, layout): """Setup editorstack's layout""" layout.setSpacing(1) self.fname_label = QLabel() self.fname_label.setStyleSheet( "QLabel {margin: 0px; padding: 3px;}") layout.addWidget(self.fname_label) menu_btn = create_toolbutton(self, icon=ima.icon('tooloptions'), tip=_('Options')) # Don't show menu arrow and remove padding if is_dark_interface(): menu_btn.setStyleSheet( ("QToolButton::menu-indicator{image: none;}\n" "QToolButton{margin: 1px; padding: 3px;}")) else: menu_btn.setStyleSheet( "QToolButton::menu-indicator{image: none;}") self.menu = QMenu(self) menu_btn.setMenu(self.menu) menu_btn.setPopupMode(menu_btn.InstantPopup) self.menu.aboutToShow.connect(self.__setup_menu) corner_widgets = {Qt.TopRightCorner: [menu_btn]} self.tabs = BaseTabs(self, menu=self.menu, menu_use_tooltips=True, corner_widgets=corner_widgets) self.tabs.tabBar().setObjectName('plugin-tab') self.tabs.set_close_function(self.close_file) self.tabs.tabBar().tabMoved.connect(self.move_editorstack_data) self.tabs.setMovable(True) self.stack_history.refresh() if hasattr(self.tabs, 'setDocumentMode') \ and not sys.platform == 'darwin': # Don't set document mode to true on OSX because it generates # a crash when the editor is detached from the main window # Fixes Issue 561 self.tabs.setDocumentMode(True) self.tabs.currentChanged.connect(self.current_changed) if sys.platform == 'darwin': tab_container = QWidget() tab_container.setObjectName('tab-container') tab_layout = QHBoxLayout(tab_container) tab_layout.setContentsMargins(0, 0, 0, 0) tab_layout.addWidget(self.tabs) layout.addWidget(tab_container) else: layout.addWidget(self.tabs)
[ "def", "setup_editorstack", "(", "self", ",", "parent", ",", "layout", ")", ":", "layout", ".", "setSpacing", "(", "1", ")", "self", ".", "fname_label", "=", "QLabel", "(", ")", "self", ".", "fname_label", ".", "setStyleSheet", "(", "\"QLabel {margin: 0px; p...
Setup editorstack's layout
[ "Setup", "editorstack", "s", "layout" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L737-L787
30,712
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.update_fname_label
def update_fname_label(self): """Upadte file name label.""" filename = to_text_string(self.get_current_filename()) if len(filename) > 100: shorten_filename = u'...' + filename[-100:] else: shorten_filename = filename self.fname_label.setText(shorten_filename)
python
def update_fname_label(self): """Upadte file name label.""" filename = to_text_string(self.get_current_filename()) if len(filename) > 100: shorten_filename = u'...' + filename[-100:] else: shorten_filename = filename self.fname_label.setText(shorten_filename)
[ "def", "update_fname_label", "(", "self", ")", ":", "filename", "=", "to_text_string", "(", "self", ".", "get_current_filename", "(", ")", ")", "if", "len", "(", "filename", ")", ">", "100", ":", "shorten_filename", "=", "u'...'", "+", "filename", "[", "-"...
Upadte file name label.
[ "Upadte", "file", "name", "label", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L790-L797
30,713
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.clone_from
def clone_from(self, other): """Clone EditorStack from other instance""" for other_finfo in other.data: self.clone_editor_from(other_finfo, set_current=True) self.set_stack_index(other.get_stack_index())
python
def clone_from(self, other): """Clone EditorStack from other instance""" for other_finfo in other.data: self.clone_editor_from(other_finfo, set_current=True) self.set_stack_index(other.get_stack_index())
[ "def", "clone_from", "(", "self", ",", "other", ")", ":", "for", "other_finfo", "in", "other", ".", "data", ":", "self", ".", "clone_editor_from", "(", "other_finfo", ",", "set_current", "=", "True", ")", "self", ".", "set_stack_index", "(", "other", ".", ...
Clone EditorStack from other instance
[ "Clone", "EditorStack", "from", "other", "instance" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L830-L834
30,714
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.open_fileswitcher_dlg
def open_fileswitcher_dlg(self): """Open file list management dialog box""" if not self.tabs.count(): return if self.fileswitcher_dlg is not None and \ self.fileswitcher_dlg.is_visible: self.fileswitcher_dlg.hide() self.fileswitcher_dlg.is_visible = False return self.fileswitcher_dlg = FileSwitcher(self, self, self.tabs, self.data, ima.icon('TextFileIcon')) self.fileswitcher_dlg.sig_goto_file.connect(self.set_stack_index) self.fileswitcher_dlg.show() self.fileswitcher_dlg.is_visible = True
python
def open_fileswitcher_dlg(self): """Open file list management dialog box""" if not self.tabs.count(): return if self.fileswitcher_dlg is not None and \ self.fileswitcher_dlg.is_visible: self.fileswitcher_dlg.hide() self.fileswitcher_dlg.is_visible = False return self.fileswitcher_dlg = FileSwitcher(self, self, self.tabs, self.data, ima.icon('TextFileIcon')) self.fileswitcher_dlg.sig_goto_file.connect(self.set_stack_index) self.fileswitcher_dlg.show() self.fileswitcher_dlg.is_visible = True
[ "def", "open_fileswitcher_dlg", "(", "self", ")", ":", "if", "not", "self", ".", "tabs", ".", "count", "(", ")", ":", "return", "if", "self", ".", "fileswitcher_dlg", "is", "not", "None", "and", "self", ".", "fileswitcher_dlg", ".", "is_visible", ":", "s...
Open file list management dialog box
[ "Open", "file", "list", "management", "dialog", "box" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L837-L850
30,715
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.go_to_line
def go_to_line(self, line=None): """Go to line dialog""" if line is not None: # When this method is called from the flileswitcher, a line # number is specified, so there is no need for the dialog. self.get_current_editor().go_to_line(line) else: if self.data: self.get_current_editor().exec_gotolinedialog()
python
def go_to_line(self, line=None): """Go to line dialog""" if line is not None: # When this method is called from the flileswitcher, a line # number is specified, so there is no need for the dialog. self.get_current_editor().go_to_line(line) else: if self.data: self.get_current_editor().exec_gotolinedialog()
[ "def", "go_to_line", "(", "self", ",", "line", "=", "None", ")", ":", "if", "line", "is", "not", "None", ":", "# When this method is called from the flileswitcher, a line\r", "# number is specified, so there is no need for the dialog.\r", "self", ".", "get_current_editor", ...
Go to line dialog
[ "Go", "to", "line", "dialog" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L861-L869
30,716
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.set_or_edit_conditional_breakpoint
def set_or_edit_conditional_breakpoint(self): """Set conditional breakpoint""" if self.data: editor = self.get_current_editor() editor.debugger.toogle_breakpoint(edit_condition=True)
python
def set_or_edit_conditional_breakpoint(self): """Set conditional breakpoint""" if self.data: editor = self.get_current_editor() editor.debugger.toogle_breakpoint(edit_condition=True)
[ "def", "set_or_edit_conditional_breakpoint", "(", "self", ")", ":", "if", "self", ".", "data", ":", "editor", "=", "self", ".", "get_current_editor", "(", ")", "editor", ".", "debugger", ".", "toogle_breakpoint", "(", "edit_condition", "=", "True", ")" ]
Set conditional breakpoint
[ "Set", "conditional", "breakpoint" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L877-L881
30,717
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.set_bookmark
def set_bookmark(self, slot_num): """Bookmark current position to given slot.""" if self.data: editor = self.get_current_editor() editor.add_bookmark(slot_num)
python
def set_bookmark(self, slot_num): """Bookmark current position to given slot.""" if self.data: editor = self.get_current_editor() editor.add_bookmark(slot_num)
[ "def", "set_bookmark", "(", "self", ",", "slot_num", ")", ":", "if", "self", ".", "data", ":", "editor", "=", "self", ".", "get_current_editor", "(", ")", "editor", ".", "add_bookmark", "(", "slot_num", ")" ]
Bookmark current position to given slot.
[ "Bookmark", "current", "position", "to", "given", "slot", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L883-L887
30,718
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.inspect_current_object
def inspect_current_object(self): """Inspect current object in the Help plugin""" editor = self.get_current_editor() editor.sig_display_signature.connect(self.display_signature_help) line, col = editor.get_cursor_line_column() editor.request_hover(line, col)
python
def inspect_current_object(self): """Inspect current object in the Help plugin""" editor = self.get_current_editor() editor.sig_display_signature.connect(self.display_signature_help) line, col = editor.get_cursor_line_column() editor.request_hover(line, col)
[ "def", "inspect_current_object", "(", "self", ")", ":", "editor", "=", "self", ".", "get_current_editor", "(", ")", "editor", ".", "sig_display_signature", ".", "connect", "(", "self", ".", "display_signature_help", ")", "line", ",", "col", "=", "editor", ".",...
Inspect current object in the Help plugin
[ "Inspect", "current", "object", "in", "the", "Help", "plugin" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L889-L894
30,719
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.initialize_outlineexplorer
def initialize_outlineexplorer(self): """This method is called separately from 'set_oulineexplorer' to avoid doing unnecessary updates when there are multiple editor windows""" for index in range(self.get_stack_count()): if index != self.get_stack_index(): self._refresh_outlineexplorer(index=index)
python
def initialize_outlineexplorer(self): """This method is called separately from 'set_oulineexplorer' to avoid doing unnecessary updates when there are multiple editor windows""" for index in range(self.get_stack_count()): if index != self.get_stack_index(): self._refresh_outlineexplorer(index=index)
[ "def", "initialize_outlineexplorer", "(", "self", ")", ":", "for", "index", "in", "range", "(", "self", ".", "get_stack_count", "(", ")", ")", ":", "if", "index", "!=", "self", ".", "get_stack_index", "(", ")", ":", "self", ".", "_refresh_outlineexplorer", ...
This method is called separately from 'set_oulineexplorer' to avoid doing unnecessary updates when there are multiple editor windows
[ "This", "method", "is", "called", "separately", "from", "set_oulineexplorer", "to", "avoid", "doing", "unnecessary", "updates", "when", "there", "are", "multiple", "editor", "windows" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L923-L928
30,720
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.get_tab_text
def get_tab_text(self, index, is_modified=None, is_readonly=None): """Return tab title.""" files_path_list = [finfo.filename for finfo in self.data] fname = self.data[index].filename fname = sourcecode.disambiguate_fname(files_path_list, fname) return self.__modified_readonly_title(fname, is_modified, is_readonly)
python
def get_tab_text(self, index, is_modified=None, is_readonly=None): """Return tab title.""" files_path_list = [finfo.filename for finfo in self.data] fname = self.data[index].filename fname = sourcecode.disambiguate_fname(files_path_list, fname) return self.__modified_readonly_title(fname, is_modified, is_readonly)
[ "def", "get_tab_text", "(", "self", ",", "index", ",", "is_modified", "=", "None", ",", "is_readonly", "=", "None", ")", ":", "files_path_list", "=", "[", "finfo", ".", "filename", "for", "finfo", "in", "self", ".", "data", "]", "fname", "=", "self", "...
Return tab title.
[ "Return", "tab", "title", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1183-L1189
30,721
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.get_tab_tip
def get_tab_tip(self, filename, is_modified=None, is_readonly=None): """Return tab menu title""" text = u"%s — %s" text = self.__modified_readonly_title(text, is_modified, is_readonly) if self.tempfile_path is not None\ and filename == encoding.to_unicode_from_fs(self.tempfile_path): temp_file_str = to_text_string(_("Temporary file")) return text % (temp_file_str, self.tempfile_path) else: return text % (osp.basename(filename), osp.dirname(filename))
python
def get_tab_tip(self, filename, is_modified=None, is_readonly=None): """Return tab menu title""" text = u"%s — %s" text = self.__modified_readonly_title(text, is_modified, is_readonly) if self.tempfile_path is not None\ and filename == encoding.to_unicode_from_fs(self.tempfile_path): temp_file_str = to_text_string(_("Temporary file")) return text % (temp_file_str, self.tempfile_path) else: return text % (osp.basename(filename), osp.dirname(filename))
[ "def", "get_tab_tip", "(", "self", ",", "filename", ",", "is_modified", "=", "None", ",", "is_readonly", "=", "None", ")", ":", "text", "=", "u\"%s — %s\"\r", "text", "=", "self", ".", "__modified_readonly_title", "(", "text", ",", "is_modified", ",", "is_re...
Return tab menu title
[ "Return", "tab", "menu", "title" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1191-L1201
30,722
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.__setup_menu
def __setup_menu(self): """Setup tab context menu before showing it""" self.menu.clear() if self.data: actions = self.menu_actions else: actions = (self.new_action, self.open_action) self.setFocus() # --> Editor.__get_focus_editortabwidget add_actions(self.menu, list(actions) + self.__get_split_actions()) self.close_action.setEnabled(self.is_closable)
python
def __setup_menu(self): """Setup tab context menu before showing it""" self.menu.clear() if self.data: actions = self.menu_actions else: actions = (self.new_action, self.open_action) self.setFocus() # --> Editor.__get_focus_editortabwidget add_actions(self.menu, list(actions) + self.__get_split_actions()) self.close_action.setEnabled(self.is_closable)
[ "def", "__setup_menu", "(", "self", ")", ":", "self", ".", "menu", ".", "clear", "(", ")", "if", "self", ".", "data", ":", "actions", "=", "self", ".", "menu_actions", "else", ":", "actions", "=", "(", "self", ".", "new_action", ",", "self", ".", "...
Setup tab context menu before showing it
[ "Setup", "tab", "context", "menu", "before", "showing", "it" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1272-L1281
30,723
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.set_current_filename
def set_current_filename(self, filename, focus=True): """Set current filename and return the associated editor instance.""" index = self.has_filename(filename) if index is not None: if focus: self.set_stack_index(index) editor = self.data[index].editor if focus: editor.setFocus() else: self.stack_history.remove_and_append(index) return editor
python
def set_current_filename(self, filename, focus=True): """Set current filename and return the associated editor instance.""" index = self.has_filename(filename) if index is not None: if focus: self.set_stack_index(index) editor = self.data[index].editor if focus: editor.setFocus() else: self.stack_history.remove_and_append(index) return editor
[ "def", "set_current_filename", "(", "self", ",", "filename", ",", "focus", "=", "True", ")", ":", "index", "=", "self", ".", "has_filename", "(", "filename", ")", "if", "index", "is", "not", "None", ":", "if", "focus", ":", "self", ".", "set_stack_index"...
Set current filename and return the associated editor instance.
[ "Set", "current", "filename", "and", "return", "the", "associated", "editor", "instance", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1380-L1392
30,724
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.get_index_from_filename
def get_index_from_filename(self, filename): """ Return the position index of a file in the tab bar of the editorstack from its name. """ filenames = [d.filename for d in self.data] return filenames.index(filename)
python
def get_index_from_filename(self, filename): """ Return the position index of a file in the tab bar of the editorstack from its name. """ filenames = [d.filename for d in self.data] return filenames.index(filename)
[ "def", "get_index_from_filename", "(", "self", ",", "filename", ")", ":", "filenames", "=", "[", "d", ".", "filename", "for", "d", "in", "self", ".", "data", "]", "return", "filenames", ".", "index", "(", "filename", ")" ]
Return the position index of a file in the tab bar of the editorstack from its name.
[ "Return", "the", "position", "index", "of", "a", "file", "in", "the", "tab", "bar", "of", "the", "editorstack", "from", "its", "name", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1413-L1419
30,725
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.move_editorstack_data
def move_editorstack_data(self, start, end): """Reorder editorstack.data so it is synchronized with the tab bar when tabs are moved.""" if start < 0 or end < 0: return else: steps = abs(end - start) direction = (end-start) // steps # +1 for right, -1 for left data = self.data self.blockSignals(True) for i in range(start, end, direction): data[i], data[i+direction] = data[i+direction], data[i] self.blockSignals(False) self.refresh()
python
def move_editorstack_data(self, start, end): """Reorder editorstack.data so it is synchronized with the tab bar when tabs are moved.""" if start < 0 or end < 0: return else: steps = abs(end - start) direction = (end-start) // steps # +1 for right, -1 for left data = self.data self.blockSignals(True) for i in range(start, end, direction): data[i], data[i+direction] = data[i+direction], data[i] self.blockSignals(False) self.refresh()
[ "def", "move_editorstack_data", "(", "self", ",", "start", ",", "end", ")", ":", "if", "start", "<", "0", "or", "end", "<", "0", ":", "return", "else", ":", "steps", "=", "abs", "(", "end", "-", "start", ")", "direction", "=", "(", "end", "-", "s...
Reorder editorstack.data so it is synchronized with the tab bar when tabs are moved.
[ "Reorder", "editorstack", ".", "data", "so", "it", "is", "synchronized", "with", "the", "tab", "bar", "when", "tabs", "are", "moved", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1422-L1438
30,726
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.poll_open_file_languages
def poll_open_file_languages(self): """Get list of current opened files' languages""" languages = [] for index in range(self.get_stack_count()): languages.append( self.tabs.widget(index).language.lower()) return set(languages)
python
def poll_open_file_languages(self): """Get list of current opened files' languages""" languages = [] for index in range(self.get_stack_count()): languages.append( self.tabs.widget(index).language.lower()) return set(languages)
[ "def", "poll_open_file_languages", "(", "self", ")", ":", "languages", "=", "[", "]", "for", "index", "in", "range", "(", "self", ".", "get_stack_count", "(", ")", ")", ":", "languages", ".", "append", "(", "self", ".", "tabs", ".", "widget", "(", "ind...
Get list of current opened files' languages
[ "Get", "list", "of", "current", "opened", "files", "languages" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1504-L1510
30,727
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.notify_server_ready
def notify_server_ready(self, language, config): """Notify language server availability to code editors.""" for index in range(self.get_stack_count()): editor = self.tabs.widget(index) if editor.language.lower() == language: editor.start_lsp_services(config)
python
def notify_server_ready(self, language, config): """Notify language server availability to code editors.""" for index in range(self.get_stack_count()): editor = self.tabs.widget(index) if editor.language.lower() == language: editor.start_lsp_services(config)
[ "def", "notify_server_ready", "(", "self", ",", "language", ",", "config", ")", ":", "for", "index", "in", "range", "(", "self", ".", "get_stack_count", "(", ")", ")", ":", "editor", "=", "self", ".", "tabs", ".", "widget", "(", "index", ")", "if", "...
Notify language server availability to code editors.
[ "Notify", "language", "server", "availability", "to", "code", "editors", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1512-L1517
30,728
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.close_all_right
def close_all_right(self): """ Close all files opened to the right """ num = self.get_stack_index() n = self.get_stack_count() for i in range(num, n-1): self.close_file(num+1)
python
def close_all_right(self): """ Close all files opened to the right """ num = self.get_stack_index() n = self.get_stack_count() for i in range(num, n-1): self.close_file(num+1)
[ "def", "close_all_right", "(", "self", ")", ":", "num", "=", "self", ".", "get_stack_index", "(", ")", "n", "=", "self", ".", "get_stack_count", "(", ")", "for", "i", "in", "range", "(", "num", ",", "n", "-", "1", ")", ":", "self", ".", "close_file...
Close all files opened to the right
[ "Close", "all", "files", "opened", "to", "the", "right" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1524-L1529
30,729
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.close_all_but_this
def close_all_but_this(self): """Close all files but the current one""" self.close_all_right() for i in range(0, self.get_stack_count()-1 ): self.close_file(0)
python
def close_all_but_this(self): """Close all files but the current one""" self.close_all_right() for i in range(0, self.get_stack_count()-1 ): self.close_file(0)
[ "def", "close_all_but_this", "(", "self", ")", ":", "self", ".", "close_all_right", "(", ")", "for", "i", "in", "range", "(", "0", ",", "self", ".", "get_stack_count", "(", ")", "-", "1", ")", ":", "self", ".", "close_file", "(", "0", ")" ]
Close all files but the current one
[ "Close", "all", "files", "but", "the", "current", "one" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1531-L1535
30,730
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.sort_file_tabs_alphabetically
def sort_file_tabs_alphabetically(self): """Sort open tabs alphabetically.""" while self.sorted() is False: for i in range(0, self.tabs.tabBar().count()): if(self.tabs.tabBar().tabText(i) > self.tabs.tabBar().tabText(i + 1)): self.tabs.tabBar().moveTab(i, i + 1)
python
def sort_file_tabs_alphabetically(self): """Sort open tabs alphabetically.""" while self.sorted() is False: for i in range(0, self.tabs.tabBar().count()): if(self.tabs.tabBar().tabText(i) > self.tabs.tabBar().tabText(i + 1)): self.tabs.tabBar().moveTab(i, i + 1)
[ "def", "sort_file_tabs_alphabetically", "(", "self", ")", ":", "while", "self", ".", "sorted", "(", ")", "is", "False", ":", "for", "i", "in", "range", "(", "0", ",", "self", ".", "tabs", ".", "tabBar", "(", ")", ".", "count", "(", ")", ")", ":", ...
Sort open tabs alphabetically.
[ "Sort", "open", "tabs", "alphabetically", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1537-L1543
30,731
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.add_last_closed_file
def add_last_closed_file(self, fname): """Add to last closed file list.""" if fname in self.last_closed_files: self.last_closed_files.remove(fname) self.last_closed_files.insert(0, fname) if len(self.last_closed_files) > 10: self.last_closed_files.pop(-1)
python
def add_last_closed_file(self, fname): """Add to last closed file list.""" if fname in self.last_closed_files: self.last_closed_files.remove(fname) self.last_closed_files.insert(0, fname) if len(self.last_closed_files) > 10: self.last_closed_files.pop(-1)
[ "def", "add_last_closed_file", "(", "self", ",", "fname", ")", ":", "if", "fname", "in", "self", ".", "last_closed_files", ":", "self", ".", "last_closed_files", ".", "remove", "(", "fname", ")", "self", ".", "last_closed_files", ".", "insert", "(", "0", "...
Add to last closed file list.
[ "Add", "to", "last", "closed", "file", "list", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1553-L1559
30,732
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.file_saved_in_other_editorstack
def file_saved_in_other_editorstack(self, original_filename, filename): """ File was just saved in another editorstack, let's synchronize! This avoids file being automatically reloaded. The original filename is passed instead of an index in case the tabs on the editor stacks were moved and are now in a different order - see issue 5703. Filename is passed in case file was just saved as another name. """ index = self.has_filename(original_filename) if index is None: return finfo = self.data[index] finfo.newly_created = False finfo.filename = to_text_string(filename) finfo.lastmodified = QFileInfo(finfo.filename).lastModified()
python
def file_saved_in_other_editorstack(self, original_filename, filename): """ File was just saved in another editorstack, let's synchronize! This avoids file being automatically reloaded. The original filename is passed instead of an index in case the tabs on the editor stacks were moved and are now in a different order - see issue 5703. Filename is passed in case file was just saved as another name. """ index = self.has_filename(original_filename) if index is None: return finfo = self.data[index] finfo.newly_created = False finfo.filename = to_text_string(filename) finfo.lastmodified = QFileInfo(finfo.filename).lastModified()
[ "def", "file_saved_in_other_editorstack", "(", "self", ",", "original_filename", ",", "filename", ")", ":", "index", "=", "self", ".", "has_filename", "(", "original_filename", ")", "if", "index", "is", "None", ":", "return", "finfo", "=", "self", ".", "data",...
File was just saved in another editorstack, let's synchronize! This avoids file being automatically reloaded. The original filename is passed instead of an index in case the tabs on the editor stacks were moved and are now in a different order - see issue 5703. Filename is passed in case file was just saved as another name.
[ "File", "was", "just", "saved", "in", "another", "editorstack", "let", "s", "synchronize!", "This", "avoids", "file", "being", "automatically", "reloaded", ".", "The", "original", "filename", "is", "passed", "instead", "of", "an", "index", "in", "case", "the",...
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1734-L1750
30,733
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.analyze_script
def analyze_script(self, index=None): """Analyze current script with todos""" if self.is_analysis_done: return if index is None: index = self.get_stack_index() if self.data: finfo = self.data[index] if self.todolist_enabled: finfo.run_todo_finder() self.is_analysis_done = True
python
def analyze_script(self, index=None): """Analyze current script with todos""" if self.is_analysis_done: return if index is None: index = self.get_stack_index() if self.data: finfo = self.data[index] if self.todolist_enabled: finfo.run_todo_finder() self.is_analysis_done = True
[ "def", "analyze_script", "(", "self", ",", "index", "=", "None", ")", ":", "if", "self", ".", "is_analysis_done", ":", "return", "if", "index", "is", "None", ":", "index", "=", "self", ".", "get_stack_index", "(", ")", "if", "self", ".", "data", ":", ...
Analyze current script with todos
[ "Analyze", "current", "script", "with", "todos" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1910-L1920
30,734
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.set_todo_results
def set_todo_results(self, filename, todo_results): """Synchronize todo results between editorstacks""" index = self.has_filename(filename) if index is None: return self.data[index].set_todo_results(todo_results)
python
def set_todo_results(self, filename, todo_results): """Synchronize todo results between editorstacks""" index = self.has_filename(filename) if index is None: return self.data[index].set_todo_results(todo_results)
[ "def", "set_todo_results", "(", "self", ",", "filename", ",", "todo_results", ")", ":", "index", "=", "self", ".", "has_filename", "(", "filename", ")", "if", "index", "is", "None", ":", "return", "self", ".", "data", "[", "index", "]", ".", "set_todo_re...
Synchronize todo results between editorstacks
[ "Synchronize", "todo", "results", "between", "editorstacks" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1922-L1927
30,735
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.current_changed
def current_changed(self, index): """Stack index has changed""" # count = self.get_stack_count() # for btn in (self.filelist_btn, self.previous_btn, self.next_btn): # btn.setEnabled(count > 1) editor = self.get_current_editor() if editor.lsp_ready and not editor.document_opened: editor.document_did_open() if index != -1: editor.setFocus() logger.debug("Set focus to: %s" % editor.filename) else: self.reset_statusbar.emit() self.opened_files_list_changed.emit() self.stack_history.refresh() self.stack_history.remove_and_append(index) # Needed to avoid an error generated after moving/renaming # files outside Spyder while in debug mode. # See issue 8749. try: logger.debug("Current changed: %d - %s" % (index, self.data[index].editor.filename)) except IndexError: pass self.update_plugin_title.emit() if editor is not None: # Needed in order to handle the close of files open in a directory # that has been renamed. See issue 5157 try: self.current_file_changed.emit(self.data[index].filename, editor.get_position('cursor')) except IndexError: pass
python
def current_changed(self, index): """Stack index has changed""" # count = self.get_stack_count() # for btn in (self.filelist_btn, self.previous_btn, self.next_btn): # btn.setEnabled(count > 1) editor = self.get_current_editor() if editor.lsp_ready and not editor.document_opened: editor.document_did_open() if index != -1: editor.setFocus() logger.debug("Set focus to: %s" % editor.filename) else: self.reset_statusbar.emit() self.opened_files_list_changed.emit() self.stack_history.refresh() self.stack_history.remove_and_append(index) # Needed to avoid an error generated after moving/renaming # files outside Spyder while in debug mode. # See issue 8749. try: logger.debug("Current changed: %d - %s" % (index, self.data[index].editor.filename)) except IndexError: pass self.update_plugin_title.emit() if editor is not None: # Needed in order to handle the close of files open in a directory # that has been renamed. See issue 5157 try: self.current_file_changed.emit(self.data[index].filename, editor.get_position('cursor')) except IndexError: pass
[ "def", "current_changed", "(", "self", ",", "index", ")", ":", "# count = self.get_stack_count()\r", "# for btn in (self.filelist_btn, self.previous_btn, self.next_btn):\r", "# btn.setEnabled(count > 1)\r", "editor", "=", "self", ".", "get_current_editor", "(...
Stack index has changed
[ "Stack", "index", "has", "changed" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1933-L1969
30,736
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.focus_changed
def focus_changed(self): """Editor focus has changed""" fwidget = QApplication.focusWidget() for finfo in self.data: if fwidget is finfo.editor: self.refresh() self.editor_focus_changed.emit()
python
def focus_changed(self): """Editor focus has changed""" fwidget = QApplication.focusWidget() for finfo in self.data: if fwidget is finfo.editor: self.refresh() self.editor_focus_changed.emit()
[ "def", "focus_changed", "(", "self", ")", ":", "fwidget", "=", "QApplication", ".", "focusWidget", "(", ")", "for", "finfo", "in", "self", ".", "data", ":", "if", "fwidget", "is", "finfo", ".", "editor", ":", "self", ".", "refresh", "(", ")", "self", ...
Editor focus has changed
[ "Editor", "focus", "has", "changed" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1995-L2001
30,737
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack._refresh_outlineexplorer
def _refresh_outlineexplorer(self, index=None, update=True, clear=False): """Refresh outline explorer panel""" oe = self.outlineexplorer if oe is None: return if index is None: index = self.get_stack_index() if self.data: finfo = self.data[index] oe.setEnabled(True) if finfo.editor.oe_proxy is None: finfo.editor.oe_proxy = OutlineExplorerProxyEditor( finfo.editor, finfo.filename) oe.set_current_editor(finfo.editor.oe_proxy, update=update, clear=clear) if index != self.get_stack_index(): # The last file added to the outline explorer is not the # currently focused one in the editor stack. Therefore, # we need to force a refresh of the outline explorer to set # the current editor to the currently focused one in the # editor stack. See PR #8015. self._refresh_outlineexplorer(update=False) return self._sync_outlineexplorer_file_order()
python
def _refresh_outlineexplorer(self, index=None, update=True, clear=False): """Refresh outline explorer panel""" oe = self.outlineexplorer if oe is None: return if index is None: index = self.get_stack_index() if self.data: finfo = self.data[index] oe.setEnabled(True) if finfo.editor.oe_proxy is None: finfo.editor.oe_proxy = OutlineExplorerProxyEditor( finfo.editor, finfo.filename) oe.set_current_editor(finfo.editor.oe_proxy, update=update, clear=clear) if index != self.get_stack_index(): # The last file added to the outline explorer is not the # currently focused one in the editor stack. Therefore, # we need to force a refresh of the outline explorer to set # the current editor to the currently focused one in the # editor stack. See PR #8015. self._refresh_outlineexplorer(update=False) return self._sync_outlineexplorer_file_order()
[ "def", "_refresh_outlineexplorer", "(", "self", ",", "index", "=", "None", ",", "update", "=", "True", ",", "clear", "=", "False", ")", ":", "oe", "=", "self", ".", "outlineexplorer", "if", "oe", "is", "None", ":", "return", "if", "index", "is", "None"...
Refresh outline explorer panel
[ "Refresh", "outline", "explorer", "panel" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2003-L2026
30,738
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack._sync_outlineexplorer_file_order
def _sync_outlineexplorer_file_order(self): """ Order the root file items of the outline explorer as in the tabbar of the current EditorStack. """ if self.outlineexplorer is not None: self.outlineexplorer.treewidget.set_editor_ids_order( [finfo.editor.get_document_id() for finfo in self.data])
python
def _sync_outlineexplorer_file_order(self): """ Order the root file items of the outline explorer as in the tabbar of the current EditorStack. """ if self.outlineexplorer is not None: self.outlineexplorer.treewidget.set_editor_ids_order( [finfo.editor.get_document_id() for finfo in self.data])
[ "def", "_sync_outlineexplorer_file_order", "(", "self", ")", ":", "if", "self", ".", "outlineexplorer", "is", "not", "None", ":", "self", ".", "outlineexplorer", ".", "treewidget", ".", "set_editor_ids_order", "(", "[", "finfo", ".", "editor", ".", "get_document...
Order the root file items of the outline explorer as in the tabbar of the current EditorStack.
[ "Order", "the", "root", "file", "items", "of", "the", "outline", "explorer", "as", "in", "the", "tabbar", "of", "the", "current", "EditorStack", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2028-L2035
30,739
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.__refresh_statusbar
def __refresh_statusbar(self, index): """Refreshing statusbar widgets""" finfo = self.data[index] self.encoding_changed.emit(finfo.encoding) # Refresh cursor position status: line, index = finfo.editor.get_cursor_line_column() self.sig_editor_cursor_position_changed.emit(line, index)
python
def __refresh_statusbar(self, index): """Refreshing statusbar widgets""" finfo = self.data[index] self.encoding_changed.emit(finfo.encoding) # Refresh cursor position status: line, index = finfo.editor.get_cursor_line_column() self.sig_editor_cursor_position_changed.emit(line, index)
[ "def", "__refresh_statusbar", "(", "self", ",", "index", ")", ":", "finfo", "=", "self", ".", "data", "[", "index", "]", "self", ".", "encoding_changed", ".", "emit", "(", "finfo", ".", "encoding", ")", "# Refresh cursor position status:\r", "line", ",", "in...
Refreshing statusbar widgets
[ "Refreshing", "statusbar", "widgets" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2037-L2043
30,740
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.reload
def reload(self, index): """Reload file from disk""" finfo = self.data[index] txt, finfo.encoding = encoding.read(finfo.filename) finfo.lastmodified = QFileInfo(finfo.filename).lastModified() position = finfo.editor.get_position('cursor') finfo.editor.set_text(txt) finfo.editor.document().setModified(False) finfo.editor.document().changed_since_autosave = False finfo.editor.set_cursor_position(position) #XXX CodeEditor-only: re-scan the whole text to rebuild outline # explorer data from scratch (could be optimized because # rehighlighting text means searching for all syntax coloring # patterns instead of only searching for class/def patterns which # would be sufficient for outline explorer data. finfo.editor.rehighlight() self._refresh_outlineexplorer(index)
python
def reload(self, index): """Reload file from disk""" finfo = self.data[index] txt, finfo.encoding = encoding.read(finfo.filename) finfo.lastmodified = QFileInfo(finfo.filename).lastModified() position = finfo.editor.get_position('cursor') finfo.editor.set_text(txt) finfo.editor.document().setModified(False) finfo.editor.document().changed_since_autosave = False finfo.editor.set_cursor_position(position) #XXX CodeEditor-only: re-scan the whole text to rebuild outline # explorer data from scratch (could be optimized because # rehighlighting text means searching for all syntax coloring # patterns instead of only searching for class/def patterns which # would be sufficient for outline explorer data. finfo.editor.rehighlight() self._refresh_outlineexplorer(index)
[ "def", "reload", "(", "self", ",", "index", ")", ":", "finfo", "=", "self", ".", "data", "[", "index", "]", "txt", ",", "finfo", ".", "encoding", "=", "encoding", ".", "read", "(", "finfo", ".", "filename", ")", "finfo", ".", "lastmodified", "=", "...
Reload file from disk
[ "Reload", "file", "from", "disk" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2181-L2199
30,741
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.revert
def revert(self): """Revert file from disk""" index = self.get_stack_index() finfo = self.data[index] filename = finfo.filename if finfo.editor.document().isModified(): self.msgbox = QMessageBox( QMessageBox.Warning, self.title, _("All changes to <b>%s</b> will be lost." "<br>Do you want to revert file from disk?" ) % osp.basename(filename), QMessageBox.Yes | QMessageBox.No, self) answer = self.msgbox.exec_() if answer != QMessageBox.Yes: return self.reload(index)
python
def revert(self): """Revert file from disk""" index = self.get_stack_index() finfo = self.data[index] filename = finfo.filename if finfo.editor.document().isModified(): self.msgbox = QMessageBox( QMessageBox.Warning, self.title, _("All changes to <b>%s</b> will be lost." "<br>Do you want to revert file from disk?" ) % osp.basename(filename), QMessageBox.Yes | QMessageBox.No, self) answer = self.msgbox.exec_() if answer != QMessageBox.Yes: return self.reload(index)
[ "def", "revert", "(", "self", ")", ":", "index", "=", "self", ".", "get_stack_index", "(", ")", "finfo", "=", "self", ".", "data", "[", "index", "]", "filename", "=", "finfo", ".", "filename", "if", "finfo", ".", "editor", ".", "document", "(", ")", ...
Revert file from disk
[ "Revert", "file", "from", "disk" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2201-L2218
30,742
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.remove_trailing_spaces
def remove_trailing_spaces(self, index=None): """Remove trailing spaces""" if index is None: index = self.get_stack_index() finfo = self.data[index] finfo.editor.remove_trailing_spaces()
python
def remove_trailing_spaces(self, index=None): """Remove trailing spaces""" if index is None: index = self.get_stack_index() finfo = self.data[index] finfo.editor.remove_trailing_spaces()
[ "def", "remove_trailing_spaces", "(", "self", ",", "index", "=", "None", ")", ":", "if", "index", "is", "None", ":", "index", "=", "self", ".", "get_stack_index", "(", ")", "finfo", "=", "self", ".", "data", "[", "index", "]", "finfo", ".", "editor", ...
Remove trailing spaces
[ "Remove", "trailing", "spaces" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2403-L2408
30,743
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.fix_indentation
def fix_indentation(self, index=None): """Replace tab characters by spaces""" if index is None: index = self.get_stack_index() finfo = self.data[index] finfo.editor.fix_indentation()
python
def fix_indentation(self, index=None): """Replace tab characters by spaces""" if index is None: index = self.get_stack_index() finfo = self.data[index] finfo.editor.fix_indentation()
[ "def", "fix_indentation", "(", "self", ",", "index", "=", "None", ")", ":", "if", "index", "is", "None", ":", "index", "=", "self", ".", "get_stack_index", "(", ")", "finfo", "=", "self", ".", "data", "[", "index", "]", "finfo", ".", "editor", ".", ...
Replace tab characters by spaces
[ "Replace", "tab", "characters", "by", "spaces" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2410-L2415
30,744
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.run_selection
def run_selection(self): """ Run selected text or current line in console. If some text is selected, then execute that text in console. If no text is selected, then execute current line, unless current line is empty. Then, advance cursor to next line. If cursor is on last line and that line is not empty, then add a new blank line and move the cursor there. If cursor is on last line and that line is empty, then do not move cursor. """ text = self.get_current_editor().get_selection_as_executable_code() if text: self.exec_in_extconsole.emit(text.rstrip(), self.focus_to_editor) return editor = self.get_current_editor() line = editor.get_current_line() text = line.lstrip() if text: self.exec_in_extconsole.emit(text, self.focus_to_editor) if editor.is_cursor_on_last_line() and text: editor.append(editor.get_line_separator()) editor.move_cursor_to_next('line', 'down')
python
def run_selection(self): """ Run selected text or current line in console. If some text is selected, then execute that text in console. If no text is selected, then execute current line, unless current line is empty. Then, advance cursor to next line. If cursor is on last line and that line is not empty, then add a new blank line and move the cursor there. If cursor is on last line and that line is empty, then do not move cursor. """ text = self.get_current_editor().get_selection_as_executable_code() if text: self.exec_in_extconsole.emit(text.rstrip(), self.focus_to_editor) return editor = self.get_current_editor() line = editor.get_current_line() text = line.lstrip() if text: self.exec_in_extconsole.emit(text, self.focus_to_editor) if editor.is_cursor_on_last_line() and text: editor.append(editor.get_line_separator()) editor.move_cursor_to_next('line', 'down')
[ "def", "run_selection", "(", "self", ")", ":", "text", "=", "self", ".", "get_current_editor", "(", ")", ".", "get_selection_as_executable_code", "(", ")", "if", "text", ":", "self", ".", "exec_in_extconsole", ".", "emit", "(", "text", ".", "rstrip", "(", ...
Run selected text or current line in console. If some text is selected, then execute that text in console. If no text is selected, then execute current line, unless current line is empty. Then, advance cursor to next line. If cursor is on last line and that line is not empty, then add a new blank line and move the cursor there. If cursor is on last line and that line is empty, then do not move cursor.
[ "Run", "selected", "text", "or", "current", "line", "in", "console", ".", "If", "some", "text", "is", "selected", "then", "execute", "that", "text", "in", "console", ".", "If", "no", "text", "is", "selected", "then", "execute", "current", "line", "unless",...
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2418-L2441
30,745
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.run_cell
def run_cell(self): """Run current cell.""" text, line = self.get_current_editor().get_cell_as_executable_code() self._run_cell_text(text, line)
python
def run_cell(self): """Run current cell.""" text, line = self.get_current_editor().get_cell_as_executable_code() self._run_cell_text(text, line)
[ "def", "run_cell", "(", "self", ")", ":", "text", ",", "line", "=", "self", ".", "get_current_editor", "(", ")", ".", "get_cell_as_executable_code", "(", ")", "self", ".", "_run_cell_text", "(", "text", ",", "line", ")" ]
Run current cell.
[ "Run", "current", "cell", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2443-L2446
30,746
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorStack.re_run_last_cell
def re_run_last_cell(self): """Run the previous cell again.""" text, line = (self.get_current_editor() .get_last_cell_as_executable_code()) self._run_cell_text(text, line)
python
def re_run_last_cell(self): """Run the previous cell again.""" text, line = (self.get_current_editor() .get_last_cell_as_executable_code()) self._run_cell_text(text, line)
[ "def", "re_run_last_cell", "(", "self", ")", ":", "text", ",", "line", "=", "(", "self", ".", "get_current_editor", "(", ")", ".", "get_last_cell_as_executable_code", "(", ")", ")", "self", ".", "_run_cell_text", "(", "text", ",", "line", ")" ]
Run the previous cell again.
[ "Run", "the", "previous", "cell", "again", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2473-L2477
30,747
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorSplitter.split
def split(self, orientation=Qt.Vertical): """Create and attach a new EditorSplitter to the current EditorSplitter. The new EditorSplitter widget will contain an EditorStack that is a clone of the current EditorStack. A single EditorSplitter instance can be split multiple times, but the orientation will be the same for all the direct splits. If one of the child splits is split, then that split can have a different orientation. """ self.setOrientation(orientation) self.editorstack.set_orientation(orientation) editorsplitter = EditorSplitter(self.parent(), self.plugin, self.menu_actions, register_editorstack_cb=self.register_editorstack_cb, unregister_editorstack_cb=self.unregister_editorstack_cb) self.addWidget(editorsplitter) editorsplitter.destroyed.connect(lambda: self.editorsplitter_closed()) current_editor = editorsplitter.editorstack.get_current_editor() if current_editor is not None: current_editor.setFocus()
python
def split(self, orientation=Qt.Vertical): """Create and attach a new EditorSplitter to the current EditorSplitter. The new EditorSplitter widget will contain an EditorStack that is a clone of the current EditorStack. A single EditorSplitter instance can be split multiple times, but the orientation will be the same for all the direct splits. If one of the child splits is split, then that split can have a different orientation. """ self.setOrientation(orientation) self.editorstack.set_orientation(orientation) editorsplitter = EditorSplitter(self.parent(), self.plugin, self.menu_actions, register_editorstack_cb=self.register_editorstack_cb, unregister_editorstack_cb=self.unregister_editorstack_cb) self.addWidget(editorsplitter) editorsplitter.destroyed.connect(lambda: self.editorsplitter_closed()) current_editor = editorsplitter.editorstack.get_current_editor() if current_editor is not None: current_editor.setFocus()
[ "def", "split", "(", "self", ",", "orientation", "=", "Qt", ".", "Vertical", ")", ":", "self", ".", "setOrientation", "(", "orientation", ")", "self", ".", "editorstack", ".", "set_orientation", "(", "orientation", ")", "editorsplitter", "=", "EditorSplitter",...
Create and attach a new EditorSplitter to the current EditorSplitter. The new EditorSplitter widget will contain an EditorStack that is a clone of the current EditorStack. A single EditorSplitter instance can be split multiple times, but the orientation will be the same for all the direct splits. If one of the child splits is split, then that split can have a different orientation.
[ "Create", "and", "attach", "a", "new", "EditorSplitter", "to", "the", "current", "EditorSplitter", ".", "The", "new", "EditorSplitter", "widget", "will", "contain", "an", "EditorStack", "that", "is", "a", "clone", "of", "the", "current", "EditorStack", ".", "A...
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2655-L2676
30,748
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorMainWindow.add_toolbars_to_menu
def add_toolbars_to_menu(self, menu_title, actions): """Add toolbars to a menu.""" # Six is the position of the view menu in menus list # that you can find in plugins/editor.py setup_other_windows. view_menu = self.menus[6] if actions == self.toolbars and view_menu: toolbars = [] for toolbar in self.toolbars: action = toolbar.toggleViewAction() toolbars.append(action) add_actions(view_menu, toolbars)
python
def add_toolbars_to_menu(self, menu_title, actions): """Add toolbars to a menu.""" # Six is the position of the view menu in menus list # that you can find in plugins/editor.py setup_other_windows. view_menu = self.menus[6] if actions == self.toolbars and view_menu: toolbars = [] for toolbar in self.toolbars: action = toolbar.toggleViewAction() toolbars.append(action) add_actions(view_menu, toolbars)
[ "def", "add_toolbars_to_menu", "(", "self", ",", "menu_title", ",", "actions", ")", ":", "# Six is the position of the view menu in menus list\r", "# that you can find in plugins/editor.py setup_other_windows.\r", "view_menu", "=", "self", ".", "menus", "[", "6", "]", "if", ...
Add toolbars to a menu.
[ "Add", "toolbars", "to", "a", "menu", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2928-L2938
30,749
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorMainWindow.get_layout_settings
def get_layout_settings(self): """Return layout state""" splitsettings = self.editorwidget.editorsplitter.get_layout_settings() return dict(size=(self.window_size.width(), self.window_size.height()), pos=(self.pos().x(), self.pos().y()), is_maximized=self.isMaximized(), is_fullscreen=self.isFullScreen(), hexstate=qbytearray_to_str(self.saveState()), splitsettings=splitsettings)
python
def get_layout_settings(self): """Return layout state""" splitsettings = self.editorwidget.editorsplitter.get_layout_settings() return dict(size=(self.window_size.width(), self.window_size.height()), pos=(self.pos().x(), self.pos().y()), is_maximized=self.isMaximized(), is_fullscreen=self.isFullScreen(), hexstate=qbytearray_to_str(self.saveState()), splitsettings=splitsettings)
[ "def", "get_layout_settings", "(", "self", ")", ":", "splitsettings", "=", "self", ".", "editorwidget", ".", "editorsplitter", ".", "get_layout_settings", "(", ")", "return", "dict", "(", "size", "=", "(", "self", ".", "window_size", ".", "width", "(", ")", ...
Return layout state
[ "Return", "layout", "state" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2970-L2978
30,750
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorMainWindow.set_layout_settings
def set_layout_settings(self, settings): """Restore layout state""" size = settings.get('size') if size is not None: self.resize( QSize(*size) ) self.window_size = self.size() pos = settings.get('pos') if pos is not None: self.move( QPoint(*pos) ) hexstate = settings.get('hexstate') if hexstate is not None: self.restoreState( QByteArray().fromHex( str(hexstate).encode('utf-8')) ) if settings.get('is_maximized'): self.setWindowState(Qt.WindowMaximized) if settings.get('is_fullscreen'): self.setWindowState(Qt.WindowFullScreen) splitsettings = settings.get('splitsettings') if splitsettings is not None: self.editorwidget.editorsplitter.set_layout_settings(splitsettings)
python
def set_layout_settings(self, settings): """Restore layout state""" size = settings.get('size') if size is not None: self.resize( QSize(*size) ) self.window_size = self.size() pos = settings.get('pos') if pos is not None: self.move( QPoint(*pos) ) hexstate = settings.get('hexstate') if hexstate is not None: self.restoreState( QByteArray().fromHex( str(hexstate).encode('utf-8')) ) if settings.get('is_maximized'): self.setWindowState(Qt.WindowMaximized) if settings.get('is_fullscreen'): self.setWindowState(Qt.WindowFullScreen) splitsettings = settings.get('splitsettings') if splitsettings is not None: self.editorwidget.editorsplitter.set_layout_settings(splitsettings)
[ "def", "set_layout_settings", "(", "self", ",", "settings", ")", ":", "size", "=", "settings", ".", "get", "(", "'size'", ")", "if", "size", "is", "not", "None", ":", "self", ".", "resize", "(", "QSize", "(", "*", "size", ")", ")", "self", ".", "wi...
Restore layout state
[ "Restore", "layout", "state" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2980-L2999
30,751
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorPluginExample.file_saved_in_editorstack
def file_saved_in_editorstack(self, editorstack_id_str, original_filename, filename): """A file was saved in editorstack, this notifies others""" for editorstack in self.editorstacks: if str(id(editorstack)) != editorstack_id_str: editorstack.file_saved_in_other_editorstack(original_filename, filename)
python
def file_saved_in_editorstack(self, editorstack_id_str, original_filename, filename): """A file was saved in editorstack, this notifies others""" for editorstack in self.editorstacks: if str(id(editorstack)) != editorstack_id_str: editorstack.file_saved_in_other_editorstack(original_filename, filename)
[ "def", "file_saved_in_editorstack", "(", "self", ",", "editorstack_id_str", ",", "original_filename", ",", "filename", ")", ":", "for", "editorstack", "in", "self", ".", "editorstacks", ":", "if", "str", "(", "id", "(", "editorstack", ")", ")", "!=", "editorst...
A file was saved in editorstack, this notifies others
[ "A", "file", "was", "saved", "in", "editorstack", "this", "notifies", "others" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L3131-L3137
30,752
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
EditorPluginExample.file_renamed_in_data_in_editorstack
def file_renamed_in_data_in_editorstack(self, editorstack_id_str, original_filename, filename): """A file was renamed in data in editorstack, this notifies others""" for editorstack in self.editorstacks: if str(id(editorstack)) != editorstack_id_str: editorstack.rename_in_data(original_filename, filename)
python
def file_renamed_in_data_in_editorstack(self, editorstack_id_str, original_filename, filename): """A file was renamed in data in editorstack, this notifies others""" for editorstack in self.editorstacks: if str(id(editorstack)) != editorstack_id_str: editorstack.rename_in_data(original_filename, filename)
[ "def", "file_renamed_in_data_in_editorstack", "(", "self", ",", "editorstack_id_str", ",", "original_filename", ",", "filename", ")", ":", "for", "editorstack", "in", "self", ".", "editorstacks", ":", "if", "str", "(", "id", "(", "editorstack", ")", ")", "!=", ...
A file was renamed in data in editorstack, this notifies others
[ "A", "file", "was", "renamed", "in", "data", "in", "editorstack", "this", "notifies", "others" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L3142-L3147
30,753
spyder-ide/spyder
spyder/plugins/findinfiles/plugin.py
FindInFiles.findinfiles_callback
def findinfiles_callback(self): """Find in files callback""" widget = QApplication.focusWidget() if not self.ismaximized: self.dockwidget.setVisible(True) self.dockwidget.raise_() text = '' try: if widget.has_selected_text(): text = widget.get_selected_text() except AttributeError: # This is not a text widget deriving from TextEditBaseWidget pass self.findinfiles.set_search_text(text) if text: self.findinfiles.find()
python
def findinfiles_callback(self): """Find in files callback""" widget = QApplication.focusWidget() if not self.ismaximized: self.dockwidget.setVisible(True) self.dockwidget.raise_() text = '' try: if widget.has_selected_text(): text = widget.get_selected_text() except AttributeError: # This is not a text widget deriving from TextEditBaseWidget pass self.findinfiles.set_search_text(text) if text: self.findinfiles.find()
[ "def", "findinfiles_callback", "(", "self", ")", ":", "widget", "=", "QApplication", ".", "focusWidget", "(", ")", "if", "not", "self", ".", "ismaximized", ":", "self", ".", "dockwidget", ".", "setVisible", "(", "True", ")", "self", ".", "dockwidget", ".",...
Find in files callback
[ "Find", "in", "files", "callback" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/plugin.py#L98-L113
30,754
spyder-ide/spyder
spyder/plugins/editor/panels/codefolding.py
FoldingPanel._draw_fold_region_background
def _draw_fold_region_background(self, block, painter): """ Draw the fold region when the mouse is over and non collapsed indicator. :param top: Top position :param block: Current block. :param painter: QPainter """ r = FoldScope(block) th = TextHelper(self.editor) start, end = r.get_range(ignore_blank_lines=True) if start > 0: top = th.line_pos_from_number(start) else: top = 0 bottom = th.line_pos_from_number(end + 1) h = bottom - top if h == 0: h = self.sizeHint().height() w = self.sizeHint().width() self._draw_rect(QRectF(0, top, w, h), painter)
python
def _draw_fold_region_background(self, block, painter): """ Draw the fold region when the mouse is over and non collapsed indicator. :param top: Top position :param block: Current block. :param painter: QPainter """ r = FoldScope(block) th = TextHelper(self.editor) start, end = r.get_range(ignore_blank_lines=True) if start > 0: top = th.line_pos_from_number(start) else: top = 0 bottom = th.line_pos_from_number(end + 1) h = bottom - top if h == 0: h = self.sizeHint().height() w = self.sizeHint().width() self._draw_rect(QRectF(0, top, w, h), painter)
[ "def", "_draw_fold_region_background", "(", "self", ",", "block", ",", "painter", ")", ":", "r", "=", "FoldScope", "(", "block", ")", "th", "=", "TextHelper", "(", "self", ".", "editor", ")", "start", ",", "end", "=", "r", ".", "get_range", "(", "ignor...
Draw the fold region when the mouse is over and non collapsed indicator. :param top: Top position :param block: Current block. :param painter: QPainter
[ "Draw", "the", "fold", "region", "when", "the", "mouse", "is", "over", "and", "non", "collapsed", "indicator", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/codefolding.py#L226-L247
30,755
spyder-ide/spyder
spyder/plugins/editor/panels/codefolding.py
FoldingPanel._draw_rect
def _draw_rect(self, rect, painter): """ Draw the background rectangle using the current style primitive color. :param rect: The fold zone rect to draw :param painter: The widget's painter. """ c = self.editor.sideareas_color grad = QLinearGradient(rect.topLeft(), rect.topRight()) if sys.platform == 'darwin': grad.setColorAt(0, c.lighter(100)) grad.setColorAt(1, c.lighter(110)) outline = c.darker(110) else: grad.setColorAt(0, c.lighter(110)) grad.setColorAt(1, c.lighter(130)) outline = c.darker(100) painter.fillRect(rect, grad) painter.setPen(QPen(outline)) painter.drawLine(rect.topLeft() + QPointF(1, 0), rect.topRight() - QPointF(1, 0)) painter.drawLine(rect.bottomLeft() + QPointF(1, 0), rect.bottomRight() - QPointF(1, 0)) painter.drawLine(rect.topRight() + QPointF(0, 1), rect.bottomRight() - QPointF(0, 1)) painter.drawLine(rect.topLeft() + QPointF(0, 1), rect.bottomLeft() - QPointF(0, 1))
python
def _draw_rect(self, rect, painter): """ Draw the background rectangle using the current style primitive color. :param rect: The fold zone rect to draw :param painter: The widget's painter. """ c = self.editor.sideareas_color grad = QLinearGradient(rect.topLeft(), rect.topRight()) if sys.platform == 'darwin': grad.setColorAt(0, c.lighter(100)) grad.setColorAt(1, c.lighter(110)) outline = c.darker(110) else: grad.setColorAt(0, c.lighter(110)) grad.setColorAt(1, c.lighter(130)) outline = c.darker(100) painter.fillRect(rect, grad) painter.setPen(QPen(outline)) painter.drawLine(rect.topLeft() + QPointF(1, 0), rect.topRight() - QPointF(1, 0)) painter.drawLine(rect.bottomLeft() + QPointF(1, 0), rect.bottomRight() - QPointF(1, 0)) painter.drawLine(rect.topRight() + QPointF(0, 1), rect.bottomRight() - QPointF(0, 1)) painter.drawLine(rect.topLeft() + QPointF(0, 1), rect.bottomLeft() - QPointF(0, 1))
[ "def", "_draw_rect", "(", "self", ",", "rect", ",", "painter", ")", ":", "c", "=", "self", ".", "editor", ".", "sideareas_color", "grad", "=", "QLinearGradient", "(", "rect", ".", "topLeft", "(", ")", ",", "rect", ".", "topRight", "(", ")", ")", "if"...
Draw the background rectangle using the current style primitive color. :param rect: The fold zone rect to draw :param painter: The widget's painter.
[ "Draw", "the", "background", "rectangle", "using", "the", "current", "style", "primitive", "color", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/codefolding.py#L249-L285
30,756
spyder-ide/spyder
spyder/plugins/editor/panels/codefolding.py
FoldingPanel.find_parent_scope
def find_parent_scope(block): """Find parent scope, if the block is not a fold trigger.""" original = block if not TextBlockHelper.is_fold_trigger(block): # search level of next non blank line while block.text().strip() == '' and block.isValid(): block = block.next() ref_lvl = TextBlockHelper.get_fold_lvl(block) - 1 block = original while (block.blockNumber() and (not TextBlockHelper.is_fold_trigger(block) or TextBlockHelper.get_fold_lvl(block) > ref_lvl)): block = block.previous() return block
python
def find_parent_scope(block): """Find parent scope, if the block is not a fold trigger.""" original = block if not TextBlockHelper.is_fold_trigger(block): # search level of next non blank line while block.text().strip() == '' and block.isValid(): block = block.next() ref_lvl = TextBlockHelper.get_fold_lvl(block) - 1 block = original while (block.blockNumber() and (not TextBlockHelper.is_fold_trigger(block) or TextBlockHelper.get_fold_lvl(block) > ref_lvl)): block = block.previous() return block
[ "def", "find_parent_scope", "(", "block", ")", ":", "original", "=", "block", "if", "not", "TextBlockHelper", ".", "is_fold_trigger", "(", "block", ")", ":", "# search level of next non blank line", "while", "block", ".", "text", "(", ")", ".", "strip", "(", "...
Find parent scope, if the block is not a fold trigger.
[ "Find", "parent", "scope", "if", "the", "block", "is", "not", "a", "fold", "trigger", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/codefolding.py#L325-L338
30,757
spyder-ide/spyder
spyder/plugins/editor/panels/codefolding.py
FoldingPanel._decorate_block
def _decorate_block(self, start, end): """ Create a decoration and add it to the editor. Args: start (int) start line of the decoration end (int) end line of the decoration """ color = self._get_scope_highlight_color() draw_order = DRAW_ORDERS.get('codefolding') d = TextDecoration(self.editor.document(), start_line=start, end_line=end+1, draw_order=draw_order) d.set_background(color) d.set_full_width(True, clear=False) self.editor.decorations.add(d) self._scope_decos.append(d)
python
def _decorate_block(self, start, end): """ Create a decoration and add it to the editor. Args: start (int) start line of the decoration end (int) end line of the decoration """ color = self._get_scope_highlight_color() draw_order = DRAW_ORDERS.get('codefolding') d = TextDecoration(self.editor.document(), start_line=start, end_line=end+1, draw_order=draw_order) d.set_background(color) d.set_full_width(True, clear=False) self.editor.decorations.add(d) self._scope_decos.append(d)
[ "def", "_decorate_block", "(", "self", ",", "start", ",", "end", ")", ":", "color", "=", "self", ".", "_get_scope_highlight_color", "(", ")", "draw_order", "=", "DRAW_ORDERS", ".", "get", "(", "'codefolding'", ")", "d", "=", "TextDecoration", "(", "self", ...
Create a decoration and add it to the editor. Args: start (int) start line of the decoration end (int) end line of the decoration
[ "Create", "a", "decoration", "and", "add", "it", "to", "the", "editor", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/codefolding.py#L361-L376
30,758
spyder-ide/spyder
spyder/plugins/editor/panels/codefolding.py
FoldingPanel._highlight_block
def _highlight_block(self, block): """ Highlights the current fold scope. :param block: Block that starts the current fold scope. """ scope = FoldScope(block) if (self._current_scope is None or self._current_scope.get_range() != scope.get_range()): self._current_scope = scope self._clear_scope_decos() # highlight current scope with darker or lighter color start, end = scope.get_range() if not TextBlockHelper.is_collapsed(block): self._decorate_block(start, end)
python
def _highlight_block(self, block): """ Highlights the current fold scope. :param block: Block that starts the current fold scope. """ scope = FoldScope(block) if (self._current_scope is None or self._current_scope.get_range() != scope.get_range()): self._current_scope = scope self._clear_scope_decos() # highlight current scope with darker or lighter color start, end = scope.get_range() if not TextBlockHelper.is_collapsed(block): self._decorate_block(start, end)
[ "def", "_highlight_block", "(", "self", ",", "block", ")", ":", "scope", "=", "FoldScope", "(", "block", ")", "if", "(", "self", ".", "_current_scope", "is", "None", "or", "self", ".", "_current_scope", ".", "get_range", "(", ")", "!=", "scope", ".", "...
Highlights the current fold scope. :param block: Block that starts the current fold scope.
[ "Highlights", "the", "current", "fold", "scope", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/codefolding.py#L378-L392
30,759
spyder-ide/spyder
spyder/plugins/editor/panels/codefolding.py
FoldingPanel._show_previous_blank_lines
def _show_previous_blank_lines(block): """ Show the block previous blank lines """ # set previous blank lines visibles pblock = block.previous() while (pblock.text().strip() == '' and pblock.blockNumber() >= 0): pblock.setVisible(True) pblock = pblock.previous()
python
def _show_previous_blank_lines(block): """ Show the block previous blank lines """ # set previous blank lines visibles pblock = block.previous() while (pblock.text().strip() == '' and pblock.blockNumber() >= 0): pblock.setVisible(True) pblock = pblock.previous()
[ "def", "_show_previous_blank_lines", "(", "block", ")", ":", "# set previous blank lines visibles", "pblock", "=", "block", ".", "previous", "(", ")", "while", "(", "pblock", ".", "text", "(", ")", ".", "strip", "(", ")", "==", "''", "and", "pblock", ".", ...
Show the block previous blank lines
[ "Show", "the", "block", "previous", "blank", "lines" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/codefolding.py#L552-L561
30,760
spyder-ide/spyder
spyder/plugins/editor/panels/codefolding.py
FoldingPanel.refresh_decorations
def refresh_decorations(self, force=False): """ Refresh decorations colors. This function is called by the syntax highlighter when the style changed so that we may update our decorations colors according to the new style. """ cursor = self.editor.textCursor() if (self._prev_cursor is None or force or self._prev_cursor.blockNumber() != cursor.blockNumber()): for deco in self._block_decos: self.editor.decorations.remove(deco) for deco in self._block_decos: deco.set_outline(drift_color( self._get_scope_highlight_color(), 110)) deco.set_background(self._get_scope_highlight_color()) self.editor.decorations.add(deco) self._prev_cursor = cursor
python
def refresh_decorations(self, force=False): """ Refresh decorations colors. This function is called by the syntax highlighter when the style changed so that we may update our decorations colors according to the new style. """ cursor = self.editor.textCursor() if (self._prev_cursor is None or force or self._prev_cursor.blockNumber() != cursor.blockNumber()): for deco in self._block_decos: self.editor.decorations.remove(deco) for deco in self._block_decos: deco.set_outline(drift_color( self._get_scope_highlight_color(), 110)) deco.set_background(self._get_scope_highlight_color()) self.editor.decorations.add(deco) self._prev_cursor = cursor
[ "def", "refresh_decorations", "(", "self", ",", "force", "=", "False", ")", ":", "cursor", "=", "self", ".", "editor", ".", "textCursor", "(", ")", "if", "(", "self", ".", "_prev_cursor", "is", "None", "or", "force", "or", "self", ".", "_prev_cursor", ...
Refresh decorations colors. This function is called by the syntax highlighter when the style changed so that we may update our decorations colors according to the new style.
[ "Refresh", "decorations", "colors", ".", "This", "function", "is", "called", "by", "the", "syntax", "highlighter", "when", "the", "style", "changed", "so", "that", "we", "may", "update", "our", "decorations", "colors", "according", "to", "the", "new", "style",...
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/codefolding.py#L563-L579
30,761
spyder-ide/spyder
spyder/plugins/editor/panels/codefolding.py
FoldingPanel._refresh_editor_and_scrollbars
def _refresh_editor_and_scrollbars(self): """ Refrehes editor content and scollbars. We generate a fake resize event to refresh scroll bar. We have the same problem as described here: http://www.qtcentre.org/threads/44803 and we apply the same solution (don't worry, there is no visual effect, the editor does not grow up at all, even with a value = 500) """ TextHelper(self.editor).mark_whole_doc_dirty() self.editor.repaint() s = self.editor.size() s.setWidth(s.width() + 1) self.editor.resizeEvent(QResizeEvent(self.editor.size(), s))
python
def _refresh_editor_and_scrollbars(self): """ Refrehes editor content and scollbars. We generate a fake resize event to refresh scroll bar. We have the same problem as described here: http://www.qtcentre.org/threads/44803 and we apply the same solution (don't worry, there is no visual effect, the editor does not grow up at all, even with a value = 500) """ TextHelper(self.editor).mark_whole_doc_dirty() self.editor.repaint() s = self.editor.size() s.setWidth(s.width() + 1) self.editor.resizeEvent(QResizeEvent(self.editor.size(), s))
[ "def", "_refresh_editor_and_scrollbars", "(", "self", ")", ":", "TextHelper", "(", "self", ".", "editor", ")", ".", "mark_whole_doc_dirty", "(", ")", "self", ".", "editor", ".", "repaint", "(", ")", "s", "=", "self", ".", "editor", ".", "size", "(", ")",...
Refrehes editor content and scollbars. We generate a fake resize event to refresh scroll bar. We have the same problem as described here: http://www.qtcentre.org/threads/44803 and we apply the same solution (don't worry, there is no visual effect, the editor does not grow up at all, even with a value = 500)
[ "Refrehes", "editor", "content", "and", "scollbars", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/codefolding.py#L581-L596
30,762
spyder-ide/spyder
spyder/plugins/editor/panels/codefolding.py
FoldingPanel.collapse_all
def collapse_all(self): """ Collapses all triggers and makes all blocks with fold level > 0 invisible. """ self._clear_block_deco() block = self.editor.document().firstBlock() last = self.editor.document().lastBlock() while block.isValid(): lvl = TextBlockHelper.get_fold_lvl(block) trigger = TextBlockHelper.is_fold_trigger(block) if trigger: if lvl == 0: self._show_previous_blank_lines(block) TextBlockHelper.set_collapsed(block, True) block.setVisible(lvl == 0) if block == last and block.text().strip() == '': block.setVisible(True) self._show_previous_blank_lines(block) block = block.next() self._refresh_editor_and_scrollbars() tc = self.editor.textCursor() tc.movePosition(tc.Start) self.editor.setTextCursor(tc) self.collapse_all_triggered.emit()
python
def collapse_all(self): """ Collapses all triggers and makes all blocks with fold level > 0 invisible. """ self._clear_block_deco() block = self.editor.document().firstBlock() last = self.editor.document().lastBlock() while block.isValid(): lvl = TextBlockHelper.get_fold_lvl(block) trigger = TextBlockHelper.is_fold_trigger(block) if trigger: if lvl == 0: self._show_previous_blank_lines(block) TextBlockHelper.set_collapsed(block, True) block.setVisible(lvl == 0) if block == last and block.text().strip() == '': block.setVisible(True) self._show_previous_blank_lines(block) block = block.next() self._refresh_editor_and_scrollbars() tc = self.editor.textCursor() tc.movePosition(tc.Start) self.editor.setTextCursor(tc) self.collapse_all_triggered.emit()
[ "def", "collapse_all", "(", "self", ")", ":", "self", ".", "_clear_block_deco", "(", ")", "block", "=", "self", ".", "editor", ".", "document", "(", ")", ".", "firstBlock", "(", ")", "last", "=", "self", ".", "editor", ".", "document", "(", ")", ".",...
Collapses all triggers and makes all blocks with fold level > 0 invisible.
[ "Collapses", "all", "triggers", "and", "makes", "all", "blocks", "with", "fold", "level", ">", "0", "invisible", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/codefolding.py#L598-L622
30,763
spyder-ide/spyder
spyder/plugins/editor/panels/codefolding.py
FoldingPanel._clear_block_deco
def _clear_block_deco(self): """Clear the folded block decorations.""" for deco in self._block_decos: self.editor.decorations.remove(deco) self._block_decos[:] = []
python
def _clear_block_deco(self): """Clear the folded block decorations.""" for deco in self._block_decos: self.editor.decorations.remove(deco) self._block_decos[:] = []
[ "def", "_clear_block_deco", "(", "self", ")", ":", "for", "deco", "in", "self", ".", "_block_decos", ":", "self", ".", "editor", ".", "decorations", ".", "remove", "(", "deco", ")", "self", ".", "_block_decos", "[", ":", "]", "=", "[", "]" ]
Clear the folded block decorations.
[ "Clear", "the", "folded", "block", "decorations", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/codefolding.py#L624-L628
30,764
spyder-ide/spyder
spyder/plugins/editor/panels/codefolding.py
FoldingPanel.expand_all
def expand_all(self): """Expands all fold triggers.""" block = self.editor.document().firstBlock() while block.isValid(): TextBlockHelper.set_collapsed(block, False) block.setVisible(True) block = block.next() self._clear_block_deco() self._refresh_editor_and_scrollbars() self.expand_all_triggered.emit()
python
def expand_all(self): """Expands all fold triggers.""" block = self.editor.document().firstBlock() while block.isValid(): TextBlockHelper.set_collapsed(block, False) block.setVisible(True) block = block.next() self._clear_block_deco() self._refresh_editor_and_scrollbars() self.expand_all_triggered.emit()
[ "def", "expand_all", "(", "self", ")", ":", "block", "=", "self", ".", "editor", ".", "document", "(", ")", ".", "firstBlock", "(", ")", "while", "block", ".", "isValid", "(", ")", ":", "TextBlockHelper", ".", "set_collapsed", "(", "block", ",", "False...
Expands all fold triggers.
[ "Expands", "all", "fold", "triggers", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/codefolding.py#L630-L639
30,765
spyder-ide/spyder
spyder/plugins/editor/panels/codefolding.py
FoldingPanel._on_action_toggle
def _on_action_toggle(self): """Toggle the current fold trigger.""" block = FoldScope.find_parent_scope(self.editor.textCursor().block()) self.toggle_fold_trigger(block)
python
def _on_action_toggle(self): """Toggle the current fold trigger.""" block = FoldScope.find_parent_scope(self.editor.textCursor().block()) self.toggle_fold_trigger(block)
[ "def", "_on_action_toggle", "(", "self", ")", ":", "block", "=", "FoldScope", ".", "find_parent_scope", "(", "self", ".", "editor", ".", "textCursor", "(", ")", ".", "block", "(", ")", ")", "self", ".", "toggle_fold_trigger", "(", "block", ")" ]
Toggle the current fold trigger.
[ "Toggle", "the", "current", "fold", "trigger", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/codefolding.py#L641-L644
30,766
spyder-ide/spyder
spyder/plugins/editor/panels/codefolding.py
FoldingPanel._highlight_caret_scope
def _highlight_caret_scope(self): """ Highlight the scope of the current caret position. This get called only if :attr:` spyder.widgets.panels.FoldingPanel.highlight_care_scope` is True. """ cursor = self.editor.textCursor() block_nbr = cursor.blockNumber() if self._block_nbr != block_nbr: block = FoldScope.find_parent_scope( self.editor.textCursor().block()) try: s = FoldScope(block) except ValueError: self._clear_scope_decos() else: self._mouse_over_line = block.blockNumber() if TextBlockHelper.is_fold_trigger(block): self._highlight_block(block) self._block_nbr = block_nbr
python
def _highlight_caret_scope(self): """ Highlight the scope of the current caret position. This get called only if :attr:` spyder.widgets.panels.FoldingPanel.highlight_care_scope` is True. """ cursor = self.editor.textCursor() block_nbr = cursor.blockNumber() if self._block_nbr != block_nbr: block = FoldScope.find_parent_scope( self.editor.textCursor().block()) try: s = FoldScope(block) except ValueError: self._clear_scope_decos() else: self._mouse_over_line = block.blockNumber() if TextBlockHelper.is_fold_trigger(block): self._highlight_block(block) self._block_nbr = block_nbr
[ "def", "_highlight_caret_scope", "(", "self", ")", ":", "cursor", "=", "self", ".", "editor", ".", "textCursor", "(", ")", "block_nbr", "=", "cursor", ".", "blockNumber", "(", ")", "if", "self", ".", "_block_nbr", "!=", "block_nbr", ":", "block", "=", "F...
Highlight the scope of the current caret position. This get called only if :attr:` spyder.widgets.panels.FoldingPanel.highlight_care_scope` is True.
[ "Highlight", "the", "scope", "of", "the", "current", "caret", "position", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/codefolding.py#L657-L677
30,767
spyder-ide/spyder
spyder/plugins/history/widgets.py
History.set_menu_actions
def set_menu_actions(self, menu_actions): """Add options to corner menu.""" if self.menu_actions is not None: add_actions(self.menu, self.menu_actions)
python
def set_menu_actions(self, menu_actions): """Add options to corner menu.""" if self.menu_actions is not None: add_actions(self.menu, self.menu_actions)
[ "def", "set_menu_actions", "(", "self", ",", "menu_actions", ")", ":", "if", "self", ".", "menu_actions", "is", "not", "None", ":", "add_actions", "(", "self", ".", "menu", ",", "self", ".", "menu_actions", ")" ]
Add options to corner menu.
[ "Add", "options", "to", "corner", "menu", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/history/widgets.py#L76-L79
30,768
spyder-ide/spyder
spyder/plugins/history/widgets.py
History.add_history
def add_history(self, filename, color_scheme, font, wrap): """ Add new history tab. Args: filename (str): file to be loaded in a new tab. """ filename = encoding.to_unicode_from_fs(filename) if filename in self.filenames: return editor = codeeditor.CodeEditor(self) if osp.splitext(filename)[1] == '.py': language = 'py' else: language = 'bat' editor.setup_editor(linenumbers=False, language=language, scrollflagarea=False, show_class_func_dropdown=False) editor.focus_changed.connect(lambda: self.focus_changed.emit()) editor.setReadOnly(True) editor.set_font(font, color_scheme) editor.toggle_wrap_mode(wrap) text, _ = encoding.read(filename) editor.set_text(text) editor.set_cursor_position('eof') self.editors.append(editor) self.filenames.append(filename) index = self.tabwidget.addTab(editor, osp.basename(filename)) self.find_widget.set_editor(editor) self.tabwidget.setTabToolTip(index, filename) self.tabwidget.setCurrentIndex(index)
python
def add_history(self, filename, color_scheme, font, wrap): """ Add new history tab. Args: filename (str): file to be loaded in a new tab. """ filename = encoding.to_unicode_from_fs(filename) if filename in self.filenames: return editor = codeeditor.CodeEditor(self) if osp.splitext(filename)[1] == '.py': language = 'py' else: language = 'bat' editor.setup_editor(linenumbers=False, language=language, scrollflagarea=False, show_class_func_dropdown=False) editor.focus_changed.connect(lambda: self.focus_changed.emit()) editor.setReadOnly(True) editor.set_font(font, color_scheme) editor.toggle_wrap_mode(wrap) text, _ = encoding.read(filename) editor.set_text(text) editor.set_cursor_position('eof') self.editors.append(editor) self.filenames.append(filename) index = self.tabwidget.addTab(editor, osp.basename(filename)) self.find_widget.set_editor(editor) self.tabwidget.setTabToolTip(index, filename) self.tabwidget.setCurrentIndex(index)
[ "def", "add_history", "(", "self", ",", "filename", ",", "color_scheme", ",", "font", ",", "wrap", ")", ":", "filename", "=", "encoding", ".", "to_unicode_from_fs", "(", "filename", ")", "if", "filename", "in", "self", ".", "filenames", ":", "return", "edi...
Add new history tab. Args: filename (str): file to be loaded in a new tab.
[ "Add", "new", "history", "tab", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/history/widgets.py#L101-L135
30,769
spyder-ide/spyder
spyder/plugins/history/widgets.py
History.append_to_history
def append_to_history(self, filename, command, go_to_eof): """ Append an entry to history filename. Args: filename (str): file to be updated in a new tab. command (str): line to be added. go_to_eof (bool): scroll to the end of file. """ if not is_text_string(filename): # filename is a QString filename = to_text_string(filename.toUtf8(), 'utf-8') command = to_text_string(command) index = self.filenames.index(filename) self.editors[index].append(command) if go_to_eof: self.editors[index].set_cursor_position('eof') self.tabwidget.setCurrentIndex(index)
python
def append_to_history(self, filename, command, go_to_eof): """ Append an entry to history filename. Args: filename (str): file to be updated in a new tab. command (str): line to be added. go_to_eof (bool): scroll to the end of file. """ if not is_text_string(filename): # filename is a QString filename = to_text_string(filename.toUtf8(), 'utf-8') command = to_text_string(command) index = self.filenames.index(filename) self.editors[index].append(command) if go_to_eof: self.editors[index].set_cursor_position('eof') self.tabwidget.setCurrentIndex(index)
[ "def", "append_to_history", "(", "self", ",", "filename", ",", "command", ",", "go_to_eof", ")", ":", "if", "not", "is_text_string", "(", "filename", ")", ":", "# filename is a QString", "filename", "=", "to_text_string", "(", "filename", ".", "toUtf8", "(", "...
Append an entry to history filename. Args: filename (str): file to be updated in a new tab. command (str): line to be added. go_to_eof (bool): scroll to the end of file.
[ "Append", "an", "entry", "to", "history", "filename", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/history/widgets.py#L137-L153
30,770
spyder-ide/spyder
spyder/plugins/editor/utils/lsp.py
request
def request(req=None, method=None, requires_response=True): """Call function req and then emit its results to the LSP server.""" if req is None: return functools.partial(request, method=method, requires_response=requires_response) @functools.wraps(req) def wrapper(self, *args, **kwargs): if self.lsp_ready: params = req(self, *args, **kwargs) if params is not None: self.emit_request(method, params, requires_response) return wrapper
python
def request(req=None, method=None, requires_response=True): """Call function req and then emit its results to the LSP server.""" if req is None: return functools.partial(request, method=method, requires_response=requires_response) @functools.wraps(req) def wrapper(self, *args, **kwargs): if self.lsp_ready: params = req(self, *args, **kwargs) if params is not None: self.emit_request(method, params, requires_response) return wrapper
[ "def", "request", "(", "req", "=", "None", ",", "method", "=", "None", ",", "requires_response", "=", "True", ")", ":", "if", "req", "is", "None", ":", "return", "functools", ".", "partial", "(", "request", ",", "method", "=", "method", ",", "requires_...
Call function req and then emit its results to the LSP server.
[ "Call", "function", "req", "and", "then", "emit", "its", "results", "to", "the", "LSP", "server", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/lsp.py#L12-L24
30,771
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.get_focus_client
def get_focus_client(self): """Return current client with focus, if any""" widget = QApplication.focusWidget() for client in self.get_clients(): if widget is client or widget is client.get_control(): return client
python
def get_focus_client(self): """Return current client with focus, if any""" widget = QApplication.focusWidget() for client in self.get_clients(): if widget is client or widget is client.get_control(): return client
[ "def", "get_focus_client", "(", "self", ")", ":", "widget", "=", "QApplication", ".", "focusWidget", "(", ")", "for", "client", "in", "self", ".", "get_clients", "(", ")", ":", "if", "widget", "is", "client", "or", "widget", "is", "client", ".", "get_con...
Return current client with focus, if any
[ "Return", "current", "client", "with", "focus", "if", "any" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L417-L422
30,772
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.run_script
def run_script(self, filename, wdir, args, debug, post_mortem, current_client, clear_variables): """Run script in current or dedicated client""" norm = lambda text: remove_backslashes(to_text_string(text)) # Run Cython files in a dedicated console is_cython = osp.splitext(filename)[1] == '.pyx' if is_cython: current_client = False # Select client to execute code on it is_new_client = False if current_client: client = self.get_current_client() else: client = self.get_client_for_file(filename) if client is None: self.create_client_for_file(filename, is_cython=is_cython) client = self.get_current_client() is_new_client = True if client is not None: # Internal kernels, use runfile if client.get_kernel() is not None: line = "%s('%s'" % ('debugfile' if debug else 'runfile', norm(filename)) if args: line += ", args='%s'" % norm(args) if wdir: line += ", wdir='%s'" % norm(wdir) if post_mortem: line += ", post_mortem=True" line += ")" else: # External kernels, use %run line = "%run " if debug: line += "-d " line += "\"%s\"" % to_text_string(filename) if args: line += " %s" % norm(args) try: if client.shellwidget._executing: # Don't allow multiple executions when there's # still an execution taking place # Fixes issue 7293 pass elif client.shellwidget._reading: client.shellwidget._append_html( _("<br><b>Please exit from debugging before trying to " "run a file in this console.</b>\n<hr><br>"), before_prompt=True) return elif current_client: self.execute_code(line, current_client, clear_variables) else: if is_new_client: client.shellwidget.silent_execute('%clear') else: client.shellwidget.execute('%clear') client.shellwidget.sig_prompt_ready.connect( lambda: self.execute_code(line, current_client, clear_variables)) except AttributeError: pass self.switch_to_plugin() else: #XXX: not sure it can really happen QMessageBox.warning(self, _('Warning'), _("No IPython console is currently available to run <b>%s</b>." "<br><br>Please open a new one and try again." ) % osp.basename(filename), QMessageBox.Ok)
python
def run_script(self, filename, wdir, args, debug, post_mortem, current_client, clear_variables): """Run script in current or dedicated client""" norm = lambda text: remove_backslashes(to_text_string(text)) # Run Cython files in a dedicated console is_cython = osp.splitext(filename)[1] == '.pyx' if is_cython: current_client = False # Select client to execute code on it is_new_client = False if current_client: client = self.get_current_client() else: client = self.get_client_for_file(filename) if client is None: self.create_client_for_file(filename, is_cython=is_cython) client = self.get_current_client() is_new_client = True if client is not None: # Internal kernels, use runfile if client.get_kernel() is not None: line = "%s('%s'" % ('debugfile' if debug else 'runfile', norm(filename)) if args: line += ", args='%s'" % norm(args) if wdir: line += ", wdir='%s'" % norm(wdir) if post_mortem: line += ", post_mortem=True" line += ")" else: # External kernels, use %run line = "%run " if debug: line += "-d " line += "\"%s\"" % to_text_string(filename) if args: line += " %s" % norm(args) try: if client.shellwidget._executing: # Don't allow multiple executions when there's # still an execution taking place # Fixes issue 7293 pass elif client.shellwidget._reading: client.shellwidget._append_html( _("<br><b>Please exit from debugging before trying to " "run a file in this console.</b>\n<hr><br>"), before_prompt=True) return elif current_client: self.execute_code(line, current_client, clear_variables) else: if is_new_client: client.shellwidget.silent_execute('%clear') else: client.shellwidget.execute('%clear') client.shellwidget.sig_prompt_ready.connect( lambda: self.execute_code(line, current_client, clear_variables)) except AttributeError: pass self.switch_to_plugin() else: #XXX: not sure it can really happen QMessageBox.warning(self, _('Warning'), _("No IPython console is currently available to run <b>%s</b>." "<br><br>Please open a new one and try again." ) % osp.basename(filename), QMessageBox.Ok)
[ "def", "run_script", "(", "self", ",", "filename", ",", "wdir", ",", "args", ",", "debug", ",", "post_mortem", ",", "current_client", ",", "clear_variables", ")", ":", "norm", "=", "lambda", "text", ":", "remove_backslashes", "(", "to_text_string", "(", "tex...
Run script in current or dedicated client
[ "Run", "script", "in", "current", "or", "dedicated", "client" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L436-L507
30,773
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.set_current_client_working_directory
def set_current_client_working_directory(self, directory): """Set current client working directory.""" shellwidget = self.get_current_shellwidget() if shellwidget is not None: shellwidget.set_cwd(directory)
python
def set_current_client_working_directory(self, directory): """Set current client working directory.""" shellwidget = self.get_current_shellwidget() if shellwidget is not None: shellwidget.set_cwd(directory)
[ "def", "set_current_client_working_directory", "(", "self", ",", "directory", ")", ":", "shellwidget", "=", "self", ".", "get_current_shellwidget", "(", ")", "if", "shellwidget", "is", "not", "None", ":", "shellwidget", ".", "set_cwd", "(", "directory", ")" ]
Set current client working directory.
[ "Set", "current", "client", "working", "directory", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L571-L575
30,774
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.set_working_directory
def set_working_directory(self, dirname): """Set current working directory. In the workingdirectory and explorer plugins. """ if dirname: self.main.workingdirectory.chdir(dirname, refresh_explorer=True, refresh_console=False)
python
def set_working_directory(self, dirname): """Set current working directory. In the workingdirectory and explorer plugins. """ if dirname: self.main.workingdirectory.chdir(dirname, refresh_explorer=True, refresh_console=False)
[ "def", "set_working_directory", "(", "self", ",", "dirname", ")", ":", "if", "dirname", ":", "self", ".", "main", ".", "workingdirectory", ".", "chdir", "(", "dirname", ",", "refresh_explorer", "=", "True", ",", "refresh_console", "=", "False", ")" ]
Set current working directory. In the workingdirectory and explorer plugins.
[ "Set", "current", "working", "directory", ".", "In", "the", "workingdirectory", "and", "explorer", "plugins", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L577-L583
30,775
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.execute_code
def execute_code(self, lines, current_client=True, clear_variables=False): """Execute code instructions.""" sw = self.get_current_shellwidget() if sw is not None: if sw._reading: pass else: if not current_client: # Clear console and reset namespace for # dedicated clients # See issue 5748 try: sw.sig_prompt_ready.disconnect() except TypeError: pass sw.reset_namespace(warning=False) elif current_client and clear_variables: sw.reset_namespace(warning=False) # Needed to handle an error when kernel_client is none # See issue 6308 try: sw.execute(to_text_string(lines)) except AttributeError: pass self.activateWindow() self.get_current_client().get_control().setFocus()
python
def execute_code(self, lines, current_client=True, clear_variables=False): """Execute code instructions.""" sw = self.get_current_shellwidget() if sw is not None: if sw._reading: pass else: if not current_client: # Clear console and reset namespace for # dedicated clients # See issue 5748 try: sw.sig_prompt_ready.disconnect() except TypeError: pass sw.reset_namespace(warning=False) elif current_client and clear_variables: sw.reset_namespace(warning=False) # Needed to handle an error when kernel_client is none # See issue 6308 try: sw.execute(to_text_string(lines)) except AttributeError: pass self.activateWindow() self.get_current_client().get_control().setFocus()
[ "def", "execute_code", "(", "self", ",", "lines", ",", "current_client", "=", "True", ",", "clear_variables", "=", "False", ")", ":", "sw", "=", "self", ".", "get_current_shellwidget", "(", ")", "if", "sw", "is", "not", "None", ":", "if", "sw", ".", "_...
Execute code instructions.
[ "Execute", "code", "instructions", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L591-L616
30,776
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.create_new_client
def create_new_client(self, give_focus=True, filename='', is_cython=False, is_pylab=False, is_sympy=False, given_name=None): """Create a new client""" self.master_clients += 1 client_id = dict(int_id=to_text_string(self.master_clients), str_id='A') cf = self._new_connection_file() show_elapsed_time = self.get_option('show_elapsed_time') reset_warning = self.get_option('show_reset_namespace_warning') ask_before_restart = self.get_option('ask_before_restart') client = ClientWidget(self, id_=client_id, history_filename=get_conf_path('history.py'), config_options=self.config_options(), additional_options=self.additional_options( is_pylab=is_pylab, is_sympy=is_sympy), interpreter_versions=self.interpreter_versions(), connection_file=cf, menu_actions=self.menu_actions, options_button=self.options_button, show_elapsed_time=show_elapsed_time, reset_warning=reset_warning, given_name=given_name, ask_before_restart=ask_before_restart, css_path=self.css_path) # Change stderr_dir if requested if self.test_dir is not None: client.stderr_dir = self.test_dir self.add_tab(client, name=client.get_name(), filename=filename) if cf is None: error_msg = self.permission_error_msg.format(jupyter_runtime_dir()) client.show_kernel_error(error_msg) return # Check if ipykernel is present in the external interpreter. # Else we won't be able to create a client if not CONF.get('main_interpreter', 'default'): pyexec = CONF.get('main_interpreter', 'executable') has_spyder_kernels = programs.is_module_installed( 'spyder_kernels', interpreter=pyexec, version='>=1.0.0') if not has_spyder_kernels: client.show_kernel_error( _("Your Python environment or installation doesn't " "have the <tt>spyder-kernels</tt> module or the " "right version of it installed. " "Without this module is not possible for " "Spyder to create a console for you.<br><br>" "You can install it by running in a system terminal:" "<br><br>" "<tt>conda install spyder-kernels</tt>" "<br><br>or<br><br>" "<tt>pip install spyder-kernels</tt>")) return self.connect_client_to_kernel(client, is_cython=is_cython, is_pylab=is_pylab, is_sympy=is_sympy) if client.shellwidget.kernel_manager is None: return self.register_client(client)
python
def create_new_client(self, give_focus=True, filename='', is_cython=False, is_pylab=False, is_sympy=False, given_name=None): """Create a new client""" self.master_clients += 1 client_id = dict(int_id=to_text_string(self.master_clients), str_id='A') cf = self._new_connection_file() show_elapsed_time = self.get_option('show_elapsed_time') reset_warning = self.get_option('show_reset_namespace_warning') ask_before_restart = self.get_option('ask_before_restart') client = ClientWidget(self, id_=client_id, history_filename=get_conf_path('history.py'), config_options=self.config_options(), additional_options=self.additional_options( is_pylab=is_pylab, is_sympy=is_sympy), interpreter_versions=self.interpreter_versions(), connection_file=cf, menu_actions=self.menu_actions, options_button=self.options_button, show_elapsed_time=show_elapsed_time, reset_warning=reset_warning, given_name=given_name, ask_before_restart=ask_before_restart, css_path=self.css_path) # Change stderr_dir if requested if self.test_dir is not None: client.stderr_dir = self.test_dir self.add_tab(client, name=client.get_name(), filename=filename) if cf is None: error_msg = self.permission_error_msg.format(jupyter_runtime_dir()) client.show_kernel_error(error_msg) return # Check if ipykernel is present in the external interpreter. # Else we won't be able to create a client if not CONF.get('main_interpreter', 'default'): pyexec = CONF.get('main_interpreter', 'executable') has_spyder_kernels = programs.is_module_installed( 'spyder_kernels', interpreter=pyexec, version='>=1.0.0') if not has_spyder_kernels: client.show_kernel_error( _("Your Python environment or installation doesn't " "have the <tt>spyder-kernels</tt> module or the " "right version of it installed. " "Without this module is not possible for " "Spyder to create a console for you.<br><br>" "You can install it by running in a system terminal:" "<br><br>" "<tt>conda install spyder-kernels</tt>" "<br><br>or<br><br>" "<tt>pip install spyder-kernels</tt>")) return self.connect_client_to_kernel(client, is_cython=is_cython, is_pylab=is_pylab, is_sympy=is_sympy) if client.shellwidget.kernel_manager is None: return self.register_client(client)
[ "def", "create_new_client", "(", "self", ",", "give_focus", "=", "True", ",", "filename", "=", "''", ",", "is_cython", "=", "False", ",", "is_pylab", "=", "False", ",", "is_sympy", "=", "False", ",", "given_name", "=", "None", ")", ":", "self", ".", "m...
Create a new client
[ "Create", "a", "new", "client" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L634-L697
30,777
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.create_client_for_kernel
def create_client_for_kernel(self): """Create a client connected to an existing kernel""" connect_output = KernelConnectionDialog.get_connection_parameters(self) (connection_file, hostname, sshkey, password, ok) = connect_output if not ok: return else: self._create_client_for_kernel(connection_file, hostname, sshkey, password)
python
def create_client_for_kernel(self): """Create a client connected to an existing kernel""" connect_output = KernelConnectionDialog.get_connection_parameters(self) (connection_file, hostname, sshkey, password, ok) = connect_output if not ok: return else: self._create_client_for_kernel(connection_file, hostname, sshkey, password)
[ "def", "create_client_for_kernel", "(", "self", ")", ":", "connect_output", "=", "KernelConnectionDialog", ".", "get_connection_parameters", "(", "self", ")", "(", "connection_file", ",", "hostname", ",", "sshkey", ",", "password", ",", "ok", ")", "=", "connect_ou...
Create a client connected to an existing kernel
[ "Create", "a", "client", "connected", "to", "an", "existing", "kernel" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L712-L720
30,778
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.connect_client_to_kernel
def connect_client_to_kernel(self, client, is_cython=False, is_pylab=False, is_sympy=False): """Connect a client to its kernel""" connection_file = client.connection_file stderr_handle = None if self.test_no_stderr else client.stderr_handle km, kc = self.create_kernel_manager_and_kernel_client( connection_file, stderr_handle, is_cython=is_cython, is_pylab=is_pylab, is_sympy=is_sympy) # An error occurred if this is True if is_string(km) and kc is None: client.shellwidget.kernel_manager = None client.show_kernel_error(km) return # This avoids a recurrent, spurious NameError when running our # tests in our CIs if not self.testing: kc.started_channels.connect( lambda c=client: self.process_started(c)) kc.stopped_channels.connect( lambda c=client: self.process_finished(c)) kc.start_channels(shell=True, iopub=True) shellwidget = client.shellwidget shellwidget.kernel_manager = km shellwidget.kernel_client = kc
python
def connect_client_to_kernel(self, client, is_cython=False, is_pylab=False, is_sympy=False): """Connect a client to its kernel""" connection_file = client.connection_file stderr_handle = None if self.test_no_stderr else client.stderr_handle km, kc = self.create_kernel_manager_and_kernel_client( connection_file, stderr_handle, is_cython=is_cython, is_pylab=is_pylab, is_sympy=is_sympy) # An error occurred if this is True if is_string(km) and kc is None: client.shellwidget.kernel_manager = None client.show_kernel_error(km) return # This avoids a recurrent, spurious NameError when running our # tests in our CIs if not self.testing: kc.started_channels.connect( lambda c=client: self.process_started(c)) kc.stopped_channels.connect( lambda c=client: self.process_finished(c)) kc.start_channels(shell=True, iopub=True) shellwidget = client.shellwidget shellwidget.kernel_manager = km shellwidget.kernel_client = kc
[ "def", "connect_client_to_kernel", "(", "self", ",", "client", ",", "is_cython", "=", "False", ",", "is_pylab", "=", "False", ",", "is_sympy", "=", "False", ")", ":", "connection_file", "=", "client", ".", "connection_file", "stderr_handle", "=", "None", "if",...
Connect a client to its kernel
[ "Connect", "a", "client", "to", "its", "kernel" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L722-L751
30,779
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.edit_file
def edit_file(self, filename, line): """Handle %edit magic petitions.""" if encoding.is_text_file(filename): # The default line number sent by ipykernel is always the last # one, but we prefer to use the first. self.edit_goto.emit(filename, 1, '')
python
def edit_file(self, filename, line): """Handle %edit magic petitions.""" if encoding.is_text_file(filename): # The default line number sent by ipykernel is always the last # one, but we prefer to use the first. self.edit_goto.emit(filename, 1, '')
[ "def", "edit_file", "(", "self", ",", "filename", ",", "line", ")", ":", "if", "encoding", ".", "is_text_file", "(", "filename", ")", ":", "# The default line number sent by ipykernel is always the last\r", "# one, but we prefer to use the first.\r", "self", ".", "edit_go...
Handle %edit magic petitions.
[ "Handle", "%edit", "magic", "petitions", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L754-L759
30,780
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.config_options
def config_options(self): """ Generate a Trailets Config instance for shell widgets using our config system This lets us create each widget with its own config """ # ---- Jupyter config ---- try: full_cfg = load_pyconfig_files(['jupyter_qtconsole_config.py'], jupyter_config_dir()) # From the full config we only select the JupyterWidget section # because the others have no effect here. cfg = Config({'JupyterWidget': full_cfg.JupyterWidget}) except: cfg = Config() # ---- Spyder config ---- spy_cfg = Config() # Make the pager widget a rich one (i.e a QTextEdit) spy_cfg.JupyterWidget.kind = 'rich' # Gui completion widget completion_type_o = self.get_option('completion_type') completions = {0: "droplist", 1: "ncurses", 2: "plain"} spy_cfg.JupyterWidget.gui_completion = completions[completion_type_o] # Pager pager_o = self.get_option('use_pager') if pager_o: spy_cfg.JupyterWidget.paging = 'inside' else: spy_cfg.JupyterWidget.paging = 'none' # Calltips calltips_o = self.get_option('show_calltips') spy_cfg.JupyterWidget.enable_calltips = calltips_o # Buffer size buffer_size_o = self.get_option('buffer_size') spy_cfg.JupyterWidget.buffer_size = buffer_size_o # Prompts in_prompt_o = self.get_option('in_prompt') out_prompt_o = self.get_option('out_prompt') if in_prompt_o: spy_cfg.JupyterWidget.in_prompt = in_prompt_o if out_prompt_o: spy_cfg.JupyterWidget.out_prompt = out_prompt_o # Style color_scheme = CONF.get('appearance', 'selected') style_sheet = create_qss_style(color_scheme)[0] spy_cfg.JupyterWidget.style_sheet = style_sheet spy_cfg.JupyterWidget.syntax_style = color_scheme # Merge QtConsole and Spyder configs. Spyder prefs will have # prevalence over QtConsole ones cfg._merge(spy_cfg) return cfg
python
def config_options(self): """ Generate a Trailets Config instance for shell widgets using our config system This lets us create each widget with its own config """ # ---- Jupyter config ---- try: full_cfg = load_pyconfig_files(['jupyter_qtconsole_config.py'], jupyter_config_dir()) # From the full config we only select the JupyterWidget section # because the others have no effect here. cfg = Config({'JupyterWidget': full_cfg.JupyterWidget}) except: cfg = Config() # ---- Spyder config ---- spy_cfg = Config() # Make the pager widget a rich one (i.e a QTextEdit) spy_cfg.JupyterWidget.kind = 'rich' # Gui completion widget completion_type_o = self.get_option('completion_type') completions = {0: "droplist", 1: "ncurses", 2: "plain"} spy_cfg.JupyterWidget.gui_completion = completions[completion_type_o] # Pager pager_o = self.get_option('use_pager') if pager_o: spy_cfg.JupyterWidget.paging = 'inside' else: spy_cfg.JupyterWidget.paging = 'none' # Calltips calltips_o = self.get_option('show_calltips') spy_cfg.JupyterWidget.enable_calltips = calltips_o # Buffer size buffer_size_o = self.get_option('buffer_size') spy_cfg.JupyterWidget.buffer_size = buffer_size_o # Prompts in_prompt_o = self.get_option('in_prompt') out_prompt_o = self.get_option('out_prompt') if in_prompt_o: spy_cfg.JupyterWidget.in_prompt = in_prompt_o if out_prompt_o: spy_cfg.JupyterWidget.out_prompt = out_prompt_o # Style color_scheme = CONF.get('appearance', 'selected') style_sheet = create_qss_style(color_scheme)[0] spy_cfg.JupyterWidget.style_sheet = style_sheet spy_cfg.JupyterWidget.syntax_style = color_scheme # Merge QtConsole and Spyder configs. Spyder prefs will have # prevalence over QtConsole ones cfg._merge(spy_cfg) return cfg
[ "def", "config_options", "(", "self", ")", ":", "# ---- Jupyter config ----\r", "try", ":", "full_cfg", "=", "load_pyconfig_files", "(", "[", "'jupyter_qtconsole_config.py'", "]", ",", "jupyter_config_dir", "(", ")", ")", "# From the full config we only select the JupyterWi...
Generate a Trailets Config instance for shell widgets using our config system This lets us create each widget with its own config
[ "Generate", "a", "Trailets", "Config", "instance", "for", "shell", "widgets", "using", "our", "config", "system", "This", "lets", "us", "create", "each", "widget", "with", "its", "own", "config" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L761-L822
30,781
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.additional_options
def additional_options(self, is_pylab=False, is_sympy=False): """ Additional options for shell widgets that are not defined in JupyterWidget config options """ options = dict( pylab=self.get_option('pylab'), autoload_pylab=self.get_option('pylab/autoload'), sympy=self.get_option('symbolic_math'), show_banner=self.get_option('show_banner') ) if is_pylab is True: options['autoload_pylab'] = True options['sympy'] = False if is_sympy is True: options['autoload_pylab'] = False options['sympy'] = True return options
python
def additional_options(self, is_pylab=False, is_sympy=False): """ Additional options for shell widgets that are not defined in JupyterWidget config options """ options = dict( pylab=self.get_option('pylab'), autoload_pylab=self.get_option('pylab/autoload'), sympy=self.get_option('symbolic_math'), show_banner=self.get_option('show_banner') ) if is_pylab is True: options['autoload_pylab'] = True options['sympy'] = False if is_sympy is True: options['autoload_pylab'] = False options['sympy'] = True return options
[ "def", "additional_options", "(", "self", ",", "is_pylab", "=", "False", ",", "is_sympy", "=", "False", ")", ":", "options", "=", "dict", "(", "pylab", "=", "self", ".", "get_option", "(", "'pylab'", ")", ",", "autoload_pylab", "=", "self", ".", "get_opt...
Additional options for shell widgets that are not defined in JupyterWidget config options
[ "Additional", "options", "for", "shell", "widgets", "that", "are", "not", "defined", "in", "JupyterWidget", "config", "options" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L854-L873
30,782
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.register_client
def register_client(self, client, give_focus=True): """Register new client""" client.configure_shellwidget(give_focus=give_focus) # Local vars shellwidget = client.shellwidget control = shellwidget._control page_control = shellwidget._page_control # Create new clients with Ctrl+T shortcut shellwidget.new_client.connect(self.create_new_client) # For tracebacks control.go_to_error.connect(self.go_to_error) shellwidget.sig_pdb_step.connect( lambda fname, lineno, shellwidget=shellwidget: self.pdb_has_stopped(fname, lineno, shellwidget)) # To handle %edit magic petitions shellwidget.custom_edit_requested.connect(self.edit_file) # Set shell cwd according to preferences cwd_path = '' if CONF.get('workingdir', 'console/use_project_or_home_directory'): cwd_path = get_home_dir() if (self.main.projects is not None and self.main.projects.get_active_project() is not None): cwd_path = self.main.projects.get_active_project_path() elif CONF.get('workingdir', 'console/use_fixed_directory'): cwd_path = CONF.get('workingdir', 'console/fixed_directory') if osp.isdir(cwd_path) and self.main is not None: shellwidget.set_cwd(cwd_path) if give_focus: # Syncronice cwd with explorer and cwd widget shellwidget.get_cwd() # Connect text widget to Help if self.main.help is not None: control.set_help(self.main.help) control.set_help_enabled(CONF.get('help', 'connect/ipython_console')) # Connect client to our history log if self.main.historylog is not None: self.main.historylog.add_history(client.history_filename) client.append_to_history.connect( self.main.historylog.append_to_history) # Set font for client client.set_font( self.get_plugin_font() ) # Connect focus signal to client's control widget control.focus_changed.connect(lambda: self.focus_changed.emit()) shellwidget.sig_change_cwd.connect(self.set_working_directory) # Update the find widget if focus changes between control and # page_control self.find_widget.set_editor(control) if page_control: page_control.focus_changed.connect(lambda: self.focus_changed.emit()) control.visibility_changed.connect(self.refresh_plugin) page_control.visibility_changed.connect(self.refresh_plugin) page_control.show_find_widget.connect(self.find_widget.show)
python
def register_client(self, client, give_focus=True): """Register new client""" client.configure_shellwidget(give_focus=give_focus) # Local vars shellwidget = client.shellwidget control = shellwidget._control page_control = shellwidget._page_control # Create new clients with Ctrl+T shortcut shellwidget.new_client.connect(self.create_new_client) # For tracebacks control.go_to_error.connect(self.go_to_error) shellwidget.sig_pdb_step.connect( lambda fname, lineno, shellwidget=shellwidget: self.pdb_has_stopped(fname, lineno, shellwidget)) # To handle %edit magic petitions shellwidget.custom_edit_requested.connect(self.edit_file) # Set shell cwd according to preferences cwd_path = '' if CONF.get('workingdir', 'console/use_project_or_home_directory'): cwd_path = get_home_dir() if (self.main.projects is not None and self.main.projects.get_active_project() is not None): cwd_path = self.main.projects.get_active_project_path() elif CONF.get('workingdir', 'console/use_fixed_directory'): cwd_path = CONF.get('workingdir', 'console/fixed_directory') if osp.isdir(cwd_path) and self.main is not None: shellwidget.set_cwd(cwd_path) if give_focus: # Syncronice cwd with explorer and cwd widget shellwidget.get_cwd() # Connect text widget to Help if self.main.help is not None: control.set_help(self.main.help) control.set_help_enabled(CONF.get('help', 'connect/ipython_console')) # Connect client to our history log if self.main.historylog is not None: self.main.historylog.add_history(client.history_filename) client.append_to_history.connect( self.main.historylog.append_to_history) # Set font for client client.set_font( self.get_plugin_font() ) # Connect focus signal to client's control widget control.focus_changed.connect(lambda: self.focus_changed.emit()) shellwidget.sig_change_cwd.connect(self.set_working_directory) # Update the find widget if focus changes between control and # page_control self.find_widget.set_editor(control) if page_control: page_control.focus_changed.connect(lambda: self.focus_changed.emit()) control.visibility_changed.connect(self.refresh_plugin) page_control.visibility_changed.connect(self.refresh_plugin) page_control.show_find_widget.connect(self.find_widget.show)
[ "def", "register_client", "(", "self", ",", "client", ",", "give_focus", "=", "True", ")", ":", "client", ".", "configure_shellwidget", "(", "give_focus", "=", "give_focus", ")", "# Local vars\r", "shellwidget", "=", "client", ".", "shellwidget", "control", "=",...
Register new client
[ "Register", "new", "client" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L875-L939
30,783
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.get_client_index_from_id
def get_client_index_from_id(self, client_id): """Return client index from id""" for index, client in enumerate(self.clients): if id(client) == client_id: return index
python
def get_client_index_from_id(self, client_id): """Return client index from id""" for index, client in enumerate(self.clients): if id(client) == client_id: return index
[ "def", "get_client_index_from_id", "(", "self", ",", "client_id", ")", ":", "for", "index", ",", "client", "in", "enumerate", "(", "self", ".", "clients", ")", ":", "if", "id", "(", "client", ")", "==", "client_id", ":", "return", "index" ]
Return client index from id
[ "Return", "client", "index", "from", "id" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L1016-L1020
30,784
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.get_related_clients
def get_related_clients(self, client): """ Get all other clients that are connected to the same kernel as `client` """ related_clients = [] for cl in self.get_clients(): if cl.connection_file == client.connection_file and \ cl is not client: related_clients.append(cl) return related_clients
python
def get_related_clients(self, client): """ Get all other clients that are connected to the same kernel as `client` """ related_clients = [] for cl in self.get_clients(): if cl.connection_file == client.connection_file and \ cl is not client: related_clients.append(cl) return related_clients
[ "def", "get_related_clients", "(", "self", ",", "client", ")", ":", "related_clients", "=", "[", "]", "for", "cl", "in", "self", ".", "get_clients", "(", ")", ":", "if", "cl", ".", "connection_file", "==", "client", ".", "connection_file", "and", "cl", "...
Get all other clients that are connected to the same kernel as `client`
[ "Get", "all", "other", "clients", "that", "are", "connected", "to", "the", "same", "kernel", "as", "client" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L1022-L1031
30,785
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.restart
def restart(self): """ Restart the console This is needed when we switch projects to update PYTHONPATH and the selected interpreter """ self.master_clients = 0 self.create_new_client_if_empty = False for i in range(len(self.clients)): client = self.clients[-1] try: client.shutdown() except Exception as e: QMessageBox.warning(self, _('Warning'), _("It was not possible to restart the IPython console " "when switching to this project. The error was<br><br>" "<tt>{0}</tt>").format(e), QMessageBox.Ok) self.close_client(client=client, force=True) self.create_new_client(give_focus=False) self.create_new_client_if_empty = True
python
def restart(self): """ Restart the console This is needed when we switch projects to update PYTHONPATH and the selected interpreter """ self.master_clients = 0 self.create_new_client_if_empty = False for i in range(len(self.clients)): client = self.clients[-1] try: client.shutdown() except Exception as e: QMessageBox.warning(self, _('Warning'), _("It was not possible to restart the IPython console " "when switching to this project. The error was<br><br>" "<tt>{0}</tt>").format(e), QMessageBox.Ok) self.close_client(client=client, force=True) self.create_new_client(give_focus=False) self.create_new_client_if_empty = True
[ "def", "restart", "(", "self", ")", ":", "self", ".", "master_clients", "=", "0", "self", ".", "create_new_client_if_empty", "=", "False", "for", "i", "in", "range", "(", "len", "(", "self", ".", "clients", ")", ")", ":", "client", "=", "self", ".", ...
Restart the console This is needed when we switch projects to update PYTHONPATH and the selected interpreter
[ "Restart", "the", "console", "This", "is", "needed", "when", "we", "switch", "projects", "to", "update", "PYTHONPATH", "and", "the", "selected", "interpreter" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L1039-L1059
30,786
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.create_client_from_path
def create_client_from_path(self, path): """Create a client with its cwd pointing to path.""" self.create_new_client() sw = self.get_current_shellwidget() sw.set_cwd(path)
python
def create_client_from_path(self, path): """Create a client with its cwd pointing to path.""" self.create_new_client() sw = self.get_current_shellwidget() sw.set_cwd(path)
[ "def", "create_client_from_path", "(", "self", ",", "path", ")", ":", "self", ".", "create_new_client", "(", ")", "sw", "=", "self", ".", "get_current_shellwidget", "(", ")", "sw", ".", "set_cwd", "(", "path", ")" ]
Create a client with its cwd pointing to path.
[ "Create", "a", "client", "with", "its", "cwd", "pointing", "to", "path", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L1076-L1080
30,787
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.create_client_for_file
def create_client_for_file(self, filename, is_cython=False): """Create a client to execute code related to a file.""" # Create client self.create_new_client(filename=filename, is_cython=is_cython) # Don't increase the count of master clients self.master_clients -= 1 # Rename client tab with filename client = self.get_current_client() client.allow_rename = False tab_text = self.disambiguate_fname(filename) self.rename_client_tab(client, tab_text)
python
def create_client_for_file(self, filename, is_cython=False): """Create a client to execute code related to a file.""" # Create client self.create_new_client(filename=filename, is_cython=is_cython) # Don't increase the count of master clients self.master_clients -= 1 # Rename client tab with filename client = self.get_current_client() client.allow_rename = False tab_text = self.disambiguate_fname(filename) self.rename_client_tab(client, tab_text)
[ "def", "create_client_for_file", "(", "self", ",", "filename", ",", "is_cython", "=", "False", ")", ":", "# Create client\r", "self", ".", "create_new_client", "(", "filename", "=", "filename", ",", "is_cython", "=", "is_cython", ")", "# Don't increase the count of ...
Create a client to execute code related to a file.
[ "Create", "a", "client", "to", "execute", "code", "related", "to", "a", "file", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L1082-L1094
30,788
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.get_client_for_file
def get_client_for_file(self, filename): """Get client associated with a given file.""" client = None for idx, cl in enumerate(self.get_clients()): if self.filenames[idx] == filename: self.tabwidget.setCurrentIndex(idx) client = cl break return client
python
def get_client_for_file(self, filename): """Get client associated with a given file.""" client = None for idx, cl in enumerate(self.get_clients()): if self.filenames[idx] == filename: self.tabwidget.setCurrentIndex(idx) client = cl break return client
[ "def", "get_client_for_file", "(", "self", ",", "filename", ")", ":", "client", "=", "None", "for", "idx", ",", "cl", "in", "enumerate", "(", "self", ".", "get_clients", "(", ")", ")", ":", "if", "self", ".", "filenames", "[", "idx", "]", "==", "file...
Get client associated with a given file.
[ "Get", "client", "associated", "with", "a", "given", "file", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L1096-L1104
30,789
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.set_elapsed_time
def set_elapsed_time(self, client): """Set elapsed time for slave clients.""" related_clients = self.get_related_clients(client) for cl in related_clients: if cl.timer is not None: client.create_time_label() client.t0 = cl.t0 client.timer.timeout.connect(client.show_time) client.timer.start(1000) break
python
def set_elapsed_time(self, client): """Set elapsed time for slave clients.""" related_clients = self.get_related_clients(client) for cl in related_clients: if cl.timer is not None: client.create_time_label() client.t0 = cl.t0 client.timer.timeout.connect(client.show_time) client.timer.start(1000) break
[ "def", "set_elapsed_time", "(", "self", ",", "client", ")", ":", "related_clients", "=", "self", ".", "get_related_clients", "(", "client", ")", "for", "cl", "in", "related_clients", ":", "if", "cl", ".", "timer", "is", "not", "None", ":", "client", ".", ...
Set elapsed time for slave clients.
[ "Set", "elapsed", "time", "for", "slave", "clients", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L1106-L1115
30,790
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.tunnel_to_kernel
def tunnel_to_kernel(self, connection_info, hostname, sshkey=None, password=None, timeout=10): """ Tunnel connections to a kernel via ssh. Remote ports are specified in the connection info ci. """ lports = zmqtunnel.select_random_ports(4) rports = (connection_info['shell_port'], connection_info['iopub_port'], connection_info['stdin_port'], connection_info['hb_port']) remote_ip = connection_info['ip'] for lp, rp in zip(lports, rports): self.ssh_tunnel(lp, rp, hostname, remote_ip, sshkey, password, timeout) return tuple(lports)
python
def tunnel_to_kernel(self, connection_info, hostname, sshkey=None, password=None, timeout=10): """ Tunnel connections to a kernel via ssh. Remote ports are specified in the connection info ci. """ lports = zmqtunnel.select_random_ports(4) rports = (connection_info['shell_port'], connection_info['iopub_port'], connection_info['stdin_port'], connection_info['hb_port']) remote_ip = connection_info['ip'] for lp, rp in zip(lports, rports): self.ssh_tunnel(lp, rp, hostname, remote_ip, sshkey, password, timeout) return tuple(lports)
[ "def", "tunnel_to_kernel", "(", "self", ",", "connection_info", ",", "hostname", ",", "sshkey", "=", "None", ",", "password", "=", "None", ",", "timeout", "=", "10", ")", ":", "lports", "=", "zmqtunnel", ".", "select_random_ports", "(", "4", ")", "rports",...
Tunnel connections to a kernel via ssh. Remote ports are specified in the connection info ci.
[ "Tunnel", "connections", "to", "a", "kernel", "via", "ssh", ".", "Remote", "ports", "are", "specified", "in", "the", "connection", "info", "ci", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L1129-L1143
30,791
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.create_kernel_spec
def create_kernel_spec(self, is_cython=False, is_pylab=False, is_sympy=False): """Create a kernel spec for our own kernels""" # Before creating our kernel spec, we always need to # set this value in spyder.ini CONF.set('main', 'spyder_pythonpath', self.main.get_spyder_pythonpath()) return SpyderKernelSpec(is_cython=is_cython, is_pylab=is_pylab, is_sympy=is_sympy)
python
def create_kernel_spec(self, is_cython=False, is_pylab=False, is_sympy=False): """Create a kernel spec for our own kernels""" # Before creating our kernel spec, we always need to # set this value in spyder.ini CONF.set('main', 'spyder_pythonpath', self.main.get_spyder_pythonpath()) return SpyderKernelSpec(is_cython=is_cython, is_pylab=is_pylab, is_sympy=is_sympy)
[ "def", "create_kernel_spec", "(", "self", ",", "is_cython", "=", "False", ",", "is_pylab", "=", "False", ",", "is_sympy", "=", "False", ")", ":", "# Before creating our kernel spec, we always need to\r", "# set this value in spyder.ini\r", "CONF", ".", "set", "(", "'m...
Create a kernel spec for our own kernels
[ "Create", "a", "kernel", "spec", "for", "our", "own", "kernels" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L1145-L1154
30,792
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.create_kernel_manager_and_kernel_client
def create_kernel_manager_and_kernel_client(self, connection_file, stderr_handle, is_cython=False, is_pylab=False, is_sympy=False): """Create kernel manager and client.""" # Kernel spec kernel_spec = self.create_kernel_spec(is_cython=is_cython, is_pylab=is_pylab, is_sympy=is_sympy) # Kernel manager try: kernel_manager = QtKernelManager(connection_file=connection_file, config=None, autorestart=True) except Exception: error_msg = _("The error is:<br><br>" "<tt>{}</tt>").format(traceback.format_exc()) return (error_msg, None) kernel_manager._kernel_spec = kernel_spec kwargs = {} if os.name == 'nt': # avoid closing fds on win+Python 3.7 # which prevents interrupts # jupyter_client > 5.2.3 will do this by default kwargs['close_fds'] = False # Catch any error generated when trying to start the kernel # See issue 7302 try: kernel_manager.start_kernel(stderr=stderr_handle, **kwargs) except Exception: error_msg = _("The error is:<br><br>" "<tt>{}</tt>").format(traceback.format_exc()) return (error_msg, None) # Kernel client kernel_client = kernel_manager.client() # Increase time to detect if a kernel is alive # See Issue 3444 kernel_client.hb_channel.time_to_dead = 18.0 return kernel_manager, kernel_client
python
def create_kernel_manager_and_kernel_client(self, connection_file, stderr_handle, is_cython=False, is_pylab=False, is_sympy=False): """Create kernel manager and client.""" # Kernel spec kernel_spec = self.create_kernel_spec(is_cython=is_cython, is_pylab=is_pylab, is_sympy=is_sympy) # Kernel manager try: kernel_manager = QtKernelManager(connection_file=connection_file, config=None, autorestart=True) except Exception: error_msg = _("The error is:<br><br>" "<tt>{}</tt>").format(traceback.format_exc()) return (error_msg, None) kernel_manager._kernel_spec = kernel_spec kwargs = {} if os.name == 'nt': # avoid closing fds on win+Python 3.7 # which prevents interrupts # jupyter_client > 5.2.3 will do this by default kwargs['close_fds'] = False # Catch any error generated when trying to start the kernel # See issue 7302 try: kernel_manager.start_kernel(stderr=stderr_handle, **kwargs) except Exception: error_msg = _("The error is:<br><br>" "<tt>{}</tt>").format(traceback.format_exc()) return (error_msg, None) # Kernel client kernel_client = kernel_manager.client() # Increase time to detect if a kernel is alive # See Issue 3444 kernel_client.hb_channel.time_to_dead = 18.0 return kernel_manager, kernel_client
[ "def", "create_kernel_manager_and_kernel_client", "(", "self", ",", "connection_file", ",", "stderr_handle", ",", "is_cython", "=", "False", ",", "is_pylab", "=", "False", ",", "is_sympy", "=", "False", ")", ":", "# Kernel spec\r", "kernel_spec", "=", "self", ".",...
Create kernel manager and client.
[ "Create", "kernel", "manager", "and", "client", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L1156-L1199
30,793
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.restart_kernel
def restart_kernel(self): """Restart kernel of current client.""" client = self.get_current_client() if client is not None: self.switch_to_plugin() client.restart_kernel()
python
def restart_kernel(self): """Restart kernel of current client.""" client = self.get_current_client() if client is not None: self.switch_to_plugin() client.restart_kernel()
[ "def", "restart_kernel", "(", "self", ")", ":", "client", "=", "self", ".", "get_current_client", "(", ")", "if", "client", "is", "not", "None", ":", "self", ".", "switch_to_plugin", "(", ")", "client", ".", "restart_kernel", "(", ")" ]
Restart kernel of current client.
[ "Restart", "kernel", "of", "current", "client", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L1201-L1206
30,794
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.reset_kernel
def reset_kernel(self): """Reset kernel of current client.""" client = self.get_current_client() if client is not None: self.switch_to_plugin() client.reset_namespace()
python
def reset_kernel(self): """Reset kernel of current client.""" client = self.get_current_client() if client is not None: self.switch_to_plugin() client.reset_namespace()
[ "def", "reset_kernel", "(", "self", ")", ":", "client", "=", "self", ".", "get_current_client", "(", ")", "if", "client", "is", "not", "None", ":", "self", ".", "switch_to_plugin", "(", ")", "client", ".", "reset_namespace", "(", ")" ]
Reset kernel of current client.
[ "Reset", "kernel", "of", "current", "client", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L1208-L1213
30,795
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.interrupt_kernel
def interrupt_kernel(self): """Interrupt kernel of current client.""" client = self.get_current_client() if client is not None: self.switch_to_plugin() client.stop_button_click_handler()
python
def interrupt_kernel(self): """Interrupt kernel of current client.""" client = self.get_current_client() if client is not None: self.switch_to_plugin() client.stop_button_click_handler()
[ "def", "interrupt_kernel", "(", "self", ")", ":", "client", "=", "self", ".", "get_current_client", "(", ")", "if", "client", "is", "not", "None", ":", "self", ".", "switch_to_plugin", "(", ")", "client", ".", "stop_button_click_handler", "(", ")" ]
Interrupt kernel of current client.
[ "Interrupt", "kernel", "of", "current", "client", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L1215-L1220
30,796
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.update_execution_state_kernel
def update_execution_state_kernel(self): """Update actions following the execution state of the kernel.""" client = self.get_current_client() if client is not None: executing = client.stop_button.isEnabled() self.interrupt_action.setEnabled(executing)
python
def update_execution_state_kernel(self): """Update actions following the execution state of the kernel.""" client = self.get_current_client() if client is not None: executing = client.stop_button.isEnabled() self.interrupt_action.setEnabled(executing)
[ "def", "update_execution_state_kernel", "(", "self", ")", ":", "client", "=", "self", ".", "get_current_client", "(", ")", "if", "client", "is", "not", "None", ":", "executing", "=", "client", ".", "stop_button", ".", "isEnabled", "(", ")", "self", ".", "i...
Update actions following the execution state of the kernel.
[ "Update", "actions", "following", "the", "execution", "state", "of", "the", "kernel", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L1222-L1227
30,797
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.connect_external_kernel
def connect_external_kernel(self, shellwidget): """ Connect an external kernel to the Variable Explorer and Help, if it is a Spyder kernel. """ sw = shellwidget kc = shellwidget.kernel_client if self.main.help is not None: self.main.help.set_shell(sw) if self.main.variableexplorer is not None: self.main.variableexplorer.add_shellwidget(sw) sw.set_namespace_view_settings() sw.refresh_namespacebrowser() kc.stopped_channels.connect(lambda : self.main.variableexplorer.remove_shellwidget(id(sw)))
python
def connect_external_kernel(self, shellwidget): """ Connect an external kernel to the Variable Explorer and Help, if it is a Spyder kernel. """ sw = shellwidget kc = shellwidget.kernel_client if self.main.help is not None: self.main.help.set_shell(sw) if self.main.variableexplorer is not None: self.main.variableexplorer.add_shellwidget(sw) sw.set_namespace_view_settings() sw.refresh_namespacebrowser() kc.stopped_channels.connect(lambda : self.main.variableexplorer.remove_shellwidget(id(sw)))
[ "def", "connect_external_kernel", "(", "self", ",", "shellwidget", ")", ":", "sw", "=", "shellwidget", "kc", "=", "shellwidget", ".", "kernel_client", "if", "self", ".", "main", ".", "help", "is", "not", "None", ":", "self", ".", "main", ".", "help", "."...
Connect an external kernel to the Variable Explorer and Help, if it is a Spyder kernel.
[ "Connect", "an", "external", "kernel", "to", "the", "Variable", "Explorer", "and", "Help", "if", "it", "is", "a", "Spyder", "kernel", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L1229-L1243
30,798
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.disambiguate_fname
def disambiguate_fname(self, fname): """Generate a file name without ambiguation.""" files_path_list = [filename for filename in self.filenames if filename] return sourcecode.disambiguate_fname(files_path_list, fname)
python
def disambiguate_fname(self, fname): """Generate a file name without ambiguation.""" files_path_list = [filename for filename in self.filenames if filename] return sourcecode.disambiguate_fname(files_path_list, fname)
[ "def", "disambiguate_fname", "(", "self", ",", "fname", ")", ":", "files_path_list", "=", "[", "filename", "for", "filename", "in", "self", ".", "filenames", "if", "filename", "]", "return", "sourcecode", ".", "disambiguate_fname", "(", "files_path_list", ",", ...
Generate a file name without ambiguation.
[ "Generate", "a", "file", "name", "without", "ambiguation", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L1269-L1273
30,799
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.update_tabs_text
def update_tabs_text(self): """Update the text from the tabs.""" # This is needed to prevent that hanged consoles make reference # to an index that doesn't exist. See issue 4881 try: for index, fname in enumerate(self.filenames): client = self.clients[index] if fname: self.rename_client_tab(client, self.disambiguate_fname(fname)) else: self.rename_client_tab(client, None) except IndexError: pass
python
def update_tabs_text(self): """Update the text from the tabs.""" # This is needed to prevent that hanged consoles make reference # to an index that doesn't exist. See issue 4881 try: for index, fname in enumerate(self.filenames): client = self.clients[index] if fname: self.rename_client_tab(client, self.disambiguate_fname(fname)) else: self.rename_client_tab(client, None) except IndexError: pass
[ "def", "update_tabs_text", "(", "self", ")", ":", "# This is needed to prevent that hanged consoles make reference\r", "# to an index that doesn't exist. See issue 4881\r", "try", ":", "for", "index", ",", "fname", "in", "enumerate", "(", "self", ".", "filenames", ")", ":",...
Update the text from the tabs.
[ "Update", "the", "text", "from", "the", "tabs", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L1275-L1288