repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1 value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
spyder-ide/spyder | spyder/plugins/help/plugin.py | Help.render_sphinx_doc | def render_sphinx_doc(self, doc, context=None, css_path=CSS_PATH):
"""Transform doc string dictionary to HTML and show it"""
# Math rendering option could have changed
if self.main.editor is not None:
fname = self.main.editor.get_current_filename()
dname = osp.dirname(fname)
else:
dname = ''
self._sphinx_thread.render(doc, context, self.get_option('math'),
dname, css_path=self.css_path) | python | def render_sphinx_doc(self, doc, context=None, css_path=CSS_PATH):
"""Transform doc string dictionary to HTML and show it"""
# Math rendering option could have changed
if self.main.editor is not None:
fname = self.main.editor.get_current_filename()
dname = osp.dirname(fname)
else:
dname = ''
self._sphinx_thread.render(doc, context, self.get_option('math'),
dname, css_path=self.css_path) | [
"def",
"render_sphinx_doc",
"(",
"self",
",",
"doc",
",",
"context",
"=",
"None",
",",
"css_path",
"=",
"CSS_PATH",
")",
":",
"# Math rendering option could have changed\r",
"if",
"self",
".",
"main",
".",
"editor",
"is",
"not",
"None",
":",
"fname",
"=",
"self",
".",
"main",
".",
"editor",
".",
"get_current_filename",
"(",
")",
"dname",
"=",
"osp",
".",
"dirname",
"(",
"fname",
")",
"else",
":",
"dname",
"=",
"''",
"self",
".",
"_sphinx_thread",
".",
"render",
"(",
"doc",
",",
"context",
",",
"self",
".",
"get_option",
"(",
"'math'",
")",
",",
"dname",
",",
"css_path",
"=",
"self",
".",
"css_path",
")"
] | Transform doc string dictionary to HTML and show it | [
"Transform",
"doc",
"string",
"dictionary",
"to",
"HTML",
"and",
"show",
"it"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L636-L645 | train |
spyder-ide/spyder | spyder/plugins/help/plugin.py | Help._on_sphinx_thread_html_ready | def _on_sphinx_thread_html_ready(self, html_text):
"""Set our sphinx documentation based on thread result"""
self._sphinx_thread.wait()
self.set_rich_text_html(html_text, QUrl.fromLocalFile(self.css_path)) | python | def _on_sphinx_thread_html_ready(self, html_text):
"""Set our sphinx documentation based on thread result"""
self._sphinx_thread.wait()
self.set_rich_text_html(html_text, QUrl.fromLocalFile(self.css_path)) | [
"def",
"_on_sphinx_thread_html_ready",
"(",
"self",
",",
"html_text",
")",
":",
"self",
".",
"_sphinx_thread",
".",
"wait",
"(",
")",
"self",
".",
"set_rich_text_html",
"(",
"html_text",
",",
"QUrl",
".",
"fromLocalFile",
"(",
"self",
".",
"css_path",
")",
")"
] | Set our sphinx documentation based on thread result | [
"Set",
"our",
"sphinx",
"documentation",
"based",
"on",
"thread",
"result"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L647-L650 | train |
spyder-ide/spyder | spyder/plugins/help/plugin.py | Help._on_sphinx_thread_error_msg | def _on_sphinx_thread_error_msg(self, error_msg):
""" Display error message on Sphinx rich text failure"""
self._sphinx_thread.wait()
self.plain_text_action.setChecked(True)
sphinx_ver = programs.get_module_version('sphinx')
QMessageBox.critical(self,
_('Help'),
_("The following error occured when calling "
"<b>Sphinx %s</b>. <br>Incompatible Sphinx "
"version or doc string decoding failed."
"<br><br>Error message:<br>%s"
) % (sphinx_ver, error_msg)) | python | def _on_sphinx_thread_error_msg(self, error_msg):
""" Display error message on Sphinx rich text failure"""
self._sphinx_thread.wait()
self.plain_text_action.setChecked(True)
sphinx_ver = programs.get_module_version('sphinx')
QMessageBox.critical(self,
_('Help'),
_("The following error occured when calling "
"<b>Sphinx %s</b>. <br>Incompatible Sphinx "
"version or doc string decoding failed."
"<br><br>Error message:<br>%s"
) % (sphinx_ver, error_msg)) | [
"def",
"_on_sphinx_thread_error_msg",
"(",
"self",
",",
"error_msg",
")",
":",
"self",
".",
"_sphinx_thread",
".",
"wait",
"(",
")",
"self",
".",
"plain_text_action",
".",
"setChecked",
"(",
"True",
")",
"sphinx_ver",
"=",
"programs",
".",
"get_module_version",
"(",
"'sphinx'",
")",
"QMessageBox",
".",
"critical",
"(",
"self",
",",
"_",
"(",
"'Help'",
")",
",",
"_",
"(",
"\"The following error occured when calling \"",
"\"<b>Sphinx %s</b>. <br>Incompatible Sphinx \"",
"\"version or doc string decoding failed.\"",
"\"<br><br>Error message:<br>%s\"",
")",
"%",
"(",
"sphinx_ver",
",",
"error_msg",
")",
")"
] | Display error message on Sphinx rich text failure | [
"Display",
"error",
"message",
"on",
"Sphinx",
"rich",
"text",
"failure"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L652-L663 | train |
spyder-ide/spyder | spyder/plugins/help/plugin.py | Help.show_help | def show_help(self, obj_text, ignore_unknown=False):
"""Show help"""
shell = self.get_shell()
if shell is None:
return
obj_text = to_text_string(obj_text)
if not shell.is_defined(obj_text):
if self.get_option('automatic_import') and \
self.internal_shell.is_defined(obj_text, force_import=True):
shell = self.internal_shell
else:
shell = None
doc = None
source_text = None
if shell is not None:
doc = shell.get_doc(obj_text)
source_text = shell.get_source(obj_text)
is_code = False
if self.rich_help:
self.render_sphinx_doc(doc, css_path=self.css_path)
return doc is not None
elif self.docstring:
hlp_text = doc
if hlp_text is None:
hlp_text = source_text
if hlp_text is None:
hlp_text = self.no_doc_string
if ignore_unknown:
return False
else:
hlp_text = source_text
if hlp_text is None:
hlp_text = doc
if hlp_text is None:
hlp_text = _("No source code available.")
if ignore_unknown:
return False
else:
is_code = True
self.set_plain_text(hlp_text, is_code=is_code)
return True | python | def show_help(self, obj_text, ignore_unknown=False):
"""Show help"""
shell = self.get_shell()
if shell is None:
return
obj_text = to_text_string(obj_text)
if not shell.is_defined(obj_text):
if self.get_option('automatic_import') and \
self.internal_shell.is_defined(obj_text, force_import=True):
shell = self.internal_shell
else:
shell = None
doc = None
source_text = None
if shell is not None:
doc = shell.get_doc(obj_text)
source_text = shell.get_source(obj_text)
is_code = False
if self.rich_help:
self.render_sphinx_doc(doc, css_path=self.css_path)
return doc is not None
elif self.docstring:
hlp_text = doc
if hlp_text is None:
hlp_text = source_text
if hlp_text is None:
hlp_text = self.no_doc_string
if ignore_unknown:
return False
else:
hlp_text = source_text
if hlp_text is None:
hlp_text = doc
if hlp_text is None:
hlp_text = _("No source code available.")
if ignore_unknown:
return False
else:
is_code = True
self.set_plain_text(hlp_text, is_code=is_code)
return True | [
"def",
"show_help",
"(",
"self",
",",
"obj_text",
",",
"ignore_unknown",
"=",
"False",
")",
":",
"shell",
"=",
"self",
".",
"get_shell",
"(",
")",
"if",
"shell",
"is",
"None",
":",
"return",
"obj_text",
"=",
"to_text_string",
"(",
"obj_text",
")",
"if",
"not",
"shell",
".",
"is_defined",
"(",
"obj_text",
")",
":",
"if",
"self",
".",
"get_option",
"(",
"'automatic_import'",
")",
"and",
"self",
".",
"internal_shell",
".",
"is_defined",
"(",
"obj_text",
",",
"force_import",
"=",
"True",
")",
":",
"shell",
"=",
"self",
".",
"internal_shell",
"else",
":",
"shell",
"=",
"None",
"doc",
"=",
"None",
"source_text",
"=",
"None",
"if",
"shell",
"is",
"not",
"None",
":",
"doc",
"=",
"shell",
".",
"get_doc",
"(",
"obj_text",
")",
"source_text",
"=",
"shell",
".",
"get_source",
"(",
"obj_text",
")",
"is_code",
"=",
"False",
"if",
"self",
".",
"rich_help",
":",
"self",
".",
"render_sphinx_doc",
"(",
"doc",
",",
"css_path",
"=",
"self",
".",
"css_path",
")",
"return",
"doc",
"is",
"not",
"None",
"elif",
"self",
".",
"docstring",
":",
"hlp_text",
"=",
"doc",
"if",
"hlp_text",
"is",
"None",
":",
"hlp_text",
"=",
"source_text",
"if",
"hlp_text",
"is",
"None",
":",
"hlp_text",
"=",
"self",
".",
"no_doc_string",
"if",
"ignore_unknown",
":",
"return",
"False",
"else",
":",
"hlp_text",
"=",
"source_text",
"if",
"hlp_text",
"is",
"None",
":",
"hlp_text",
"=",
"doc",
"if",
"hlp_text",
"is",
"None",
":",
"hlp_text",
"=",
"_",
"(",
"\"No source code available.\"",
")",
"if",
"ignore_unknown",
":",
"return",
"False",
"else",
":",
"is_code",
"=",
"True",
"self",
".",
"set_plain_text",
"(",
"hlp_text",
",",
"is_code",
"=",
"is_code",
")",
"return",
"True"
] | Show help | [
"Show",
"help"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L665-L709 | train |
spyder-ide/spyder | spyder/plugins/editor/api/decoration.py | TextDecoration.contains_cursor | def contains_cursor(self, cursor):
"""
Checks if the textCursor is in the decoration.
:param cursor: The text cursor to test
:type cursor: QtGui.QTextCursor
:returns: True if the cursor is over the selection
"""
start = self.cursor.selectionStart()
end = self.cursor.selectionEnd()
if cursor.atBlockEnd():
end -= 1
return start <= cursor.position() <= end | python | def contains_cursor(self, cursor):
"""
Checks if the textCursor is in the decoration.
:param cursor: The text cursor to test
:type cursor: QtGui.QTextCursor
:returns: True if the cursor is over the selection
"""
start = self.cursor.selectionStart()
end = self.cursor.selectionEnd()
if cursor.atBlockEnd():
end -= 1
return start <= cursor.position() <= end | [
"def",
"contains_cursor",
"(",
"self",
",",
"cursor",
")",
":",
"start",
"=",
"self",
".",
"cursor",
".",
"selectionStart",
"(",
")",
"end",
"=",
"self",
".",
"cursor",
".",
"selectionEnd",
"(",
")",
"if",
"cursor",
".",
"atBlockEnd",
"(",
")",
":",
"end",
"-=",
"1",
"return",
"start",
"<=",
"cursor",
".",
"position",
"(",
")",
"<=",
"end"
] | Checks if the textCursor is in the decoration.
:param cursor: The text cursor to test
:type cursor: QtGui.QTextCursor
:returns: True if the cursor is over the selection | [
"Checks",
"if",
"the",
"textCursor",
"is",
"in",
"the",
"decoration",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/api/decoration.py#L117-L130 | train |
spyder-ide/spyder | spyder/plugins/editor/api/decoration.py | TextDecoration.select_line | def select_line(self):
"""
Select the entire line but starts at the first non whitespace character
and stops at the non-whitespace character.
:return:
"""
self.cursor.movePosition(self.cursor.StartOfBlock)
text = self.cursor.block().text()
lindent = len(text) - len(text.lstrip())
self.cursor.setPosition(self.cursor.block().position() + lindent)
self.cursor.movePosition(self.cursor.EndOfBlock,
self.cursor.KeepAnchor) | python | def select_line(self):
"""
Select the entire line but starts at the first non whitespace character
and stops at the non-whitespace character.
:return:
"""
self.cursor.movePosition(self.cursor.StartOfBlock)
text = self.cursor.block().text()
lindent = len(text) - len(text.lstrip())
self.cursor.setPosition(self.cursor.block().position() + lindent)
self.cursor.movePosition(self.cursor.EndOfBlock,
self.cursor.KeepAnchor) | [
"def",
"select_line",
"(",
"self",
")",
":",
"self",
".",
"cursor",
".",
"movePosition",
"(",
"self",
".",
"cursor",
".",
"StartOfBlock",
")",
"text",
"=",
"self",
".",
"cursor",
".",
"block",
"(",
")",
".",
"text",
"(",
")",
"lindent",
"=",
"len",
"(",
"text",
")",
"-",
"len",
"(",
"text",
".",
"lstrip",
"(",
")",
")",
"self",
".",
"cursor",
".",
"setPosition",
"(",
"self",
".",
"cursor",
".",
"block",
"(",
")",
".",
"position",
"(",
")",
"+",
"lindent",
")",
"self",
".",
"cursor",
".",
"movePosition",
"(",
"self",
".",
"cursor",
".",
"EndOfBlock",
",",
"self",
".",
"cursor",
".",
"KeepAnchor",
")"
] | Select the entire line but starts at the first non whitespace character
and stops at the non-whitespace character.
:return: | [
"Select",
"the",
"entire",
"line",
"but",
"starts",
"at",
"the",
"first",
"non",
"whitespace",
"character",
"and",
"stops",
"at",
"the",
"non",
"-",
"whitespace",
"character",
".",
":",
"return",
":"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/api/decoration.py#L162-L173 | train |
spyder-ide/spyder | spyder/plugins/editor/api/decoration.py | TextDecoration.set_as_underlined | def set_as_underlined(self, color=Qt.blue):
"""
Underlines the text.
:param color: underline color.
"""
self.format.setUnderlineStyle(
QTextCharFormat.SingleUnderline)
self.format.setUnderlineColor(color) | python | def set_as_underlined(self, color=Qt.blue):
"""
Underlines the text.
:param color: underline color.
"""
self.format.setUnderlineStyle(
QTextCharFormat.SingleUnderline)
self.format.setUnderlineColor(color) | [
"def",
"set_as_underlined",
"(",
"self",
",",
"color",
"=",
"Qt",
".",
"blue",
")",
":",
"self",
".",
"format",
".",
"setUnderlineStyle",
"(",
"QTextCharFormat",
".",
"SingleUnderline",
")",
"self",
".",
"format",
".",
"setUnderlineColor",
"(",
"color",
")"
] | Underlines the text.
:param color: underline color. | [
"Underlines",
"the",
"text",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/api/decoration.py#L190-L198 | train |
spyder-ide/spyder | spyder/plugins/editor/api/decoration.py | TextDecoration.set_as_spell_check | def set_as_spell_check(self, color=Qt.blue):
"""
Underlines text as a spellcheck error.
:param color: Underline color
:type color: QtGui.QColor
"""
self.format.setUnderlineStyle(
QTextCharFormat.SpellCheckUnderline)
self.format.setUnderlineColor(color) | python | def set_as_spell_check(self, color=Qt.blue):
"""
Underlines text as a spellcheck error.
:param color: Underline color
:type color: QtGui.QColor
"""
self.format.setUnderlineStyle(
QTextCharFormat.SpellCheckUnderline)
self.format.setUnderlineColor(color) | [
"def",
"set_as_spell_check",
"(",
"self",
",",
"color",
"=",
"Qt",
".",
"blue",
")",
":",
"self",
".",
"format",
".",
"setUnderlineStyle",
"(",
"QTextCharFormat",
".",
"SpellCheckUnderline",
")",
"self",
".",
"format",
".",
"setUnderlineColor",
"(",
"color",
")"
] | Underlines text as a spellcheck error.
:param color: Underline color
:type color: QtGui.QColor | [
"Underlines",
"text",
"as",
"a",
"spellcheck",
"error",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/api/decoration.py#L200-L209 | train |
spyder-ide/spyder | spyder/plugins/editor/api/decoration.py | TextDecoration.set_as_error | def set_as_error(self, color=Qt.red):
"""
Highlights text as a syntax error.
:param color: Underline color
:type color: QtGui.QColor
"""
self.format.setUnderlineStyle(
QTextCharFormat.WaveUnderline)
self.format.setUnderlineColor(color) | python | def set_as_error(self, color=Qt.red):
"""
Highlights text as a syntax error.
:param color: Underline color
:type color: QtGui.QColor
"""
self.format.setUnderlineStyle(
QTextCharFormat.WaveUnderline)
self.format.setUnderlineColor(color) | [
"def",
"set_as_error",
"(",
"self",
",",
"color",
"=",
"Qt",
".",
"red",
")",
":",
"self",
".",
"format",
".",
"setUnderlineStyle",
"(",
"QTextCharFormat",
".",
"WaveUnderline",
")",
"self",
".",
"format",
".",
"setUnderlineColor",
"(",
"color",
")"
] | Highlights text as a syntax error.
:param color: Underline color
:type color: QtGui.QColor | [
"Highlights",
"text",
"as",
"a",
"syntax",
"error",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/api/decoration.py#L211-L220 | train |
spyder-ide/spyder | spyder/plugins/editor/api/decoration.py | TextDecoration.set_as_warning | def set_as_warning(self, color=QColor("orange")):
"""
Highlights text as a syntax warning.
:param color: Underline color
:type color: QtGui.QColor
"""
self.format.setUnderlineStyle(
QTextCharFormat.WaveUnderline)
self.format.setUnderlineColor(color) | python | def set_as_warning(self, color=QColor("orange")):
"""
Highlights text as a syntax warning.
:param color: Underline color
:type color: QtGui.QColor
"""
self.format.setUnderlineStyle(
QTextCharFormat.WaveUnderline)
self.format.setUnderlineColor(color) | [
"def",
"set_as_warning",
"(",
"self",
",",
"color",
"=",
"QColor",
"(",
"\"orange\"",
")",
")",
":",
"self",
".",
"format",
".",
"setUnderlineStyle",
"(",
"QTextCharFormat",
".",
"WaveUnderline",
")",
"self",
".",
"format",
".",
"setUnderlineColor",
"(",
"color",
")"
] | Highlights text as a syntax warning.
:param color: Underline color
:type color: QtGui.QColor | [
"Highlights",
"text",
"as",
"a",
"syntax",
"warning",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/api/decoration.py#L222-L231 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | AnalysisThread.run | def run(self):
"""Run analysis"""
try:
self.results = self.checker(self.source_code)
except Exception as e:
logger.error(e, exc_info=True) | python | def run(self):
"""Run analysis"""
try:
self.results = self.checker(self.source_code)
except Exception as e:
logger.error(e, exc_info=True) | [
"def",
"run",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"results",
"=",
"self",
".",
"checker",
"(",
"self",
".",
"source_code",
")",
"except",
"Exception",
"as",
"e",
":",
"logger",
".",
"error",
"(",
"e",
",",
"exc_info",
"=",
"True",
")"
] | Run analysis | [
"Run",
"analysis"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L76-L81 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | ThreadManager.close_threads | def close_threads(self, parent):
"""Close threads associated to parent_id"""
logger.debug("Call ThreadManager's 'close_threads'")
if parent is None:
# Closing all threads
self.pending_threads = []
threadlist = []
for threads in list(self.started_threads.values()):
threadlist += threads
else:
parent_id = id(parent)
self.pending_threads = [(_th, _id) for (_th, _id)
in self.pending_threads
if _id != parent_id]
threadlist = self.started_threads.get(parent_id, [])
for thread in threadlist:
logger.debug("Waiting for thread %r to finish" % thread)
while thread.isRunning():
# We can't terminate thread safely, so we simply wait...
QApplication.processEvents() | python | def close_threads(self, parent):
"""Close threads associated to parent_id"""
logger.debug("Call ThreadManager's 'close_threads'")
if parent is None:
# Closing all threads
self.pending_threads = []
threadlist = []
for threads in list(self.started_threads.values()):
threadlist += threads
else:
parent_id = id(parent)
self.pending_threads = [(_th, _id) for (_th, _id)
in self.pending_threads
if _id != parent_id]
threadlist = self.started_threads.get(parent_id, [])
for thread in threadlist:
logger.debug("Waiting for thread %r to finish" % thread)
while thread.isRunning():
# We can't terminate thread safely, so we simply wait...
QApplication.processEvents() | [
"def",
"close_threads",
"(",
"self",
",",
"parent",
")",
":",
"logger",
".",
"debug",
"(",
"\"Call ThreadManager's 'close_threads'\"",
")",
"if",
"parent",
"is",
"None",
":",
"# Closing all threads\r",
"self",
".",
"pending_threads",
"=",
"[",
"]",
"threadlist",
"=",
"[",
"]",
"for",
"threads",
"in",
"list",
"(",
"self",
".",
"started_threads",
".",
"values",
"(",
")",
")",
":",
"threadlist",
"+=",
"threads",
"else",
":",
"parent_id",
"=",
"id",
"(",
"parent",
")",
"self",
".",
"pending_threads",
"=",
"[",
"(",
"_th",
",",
"_id",
")",
"for",
"(",
"_th",
",",
"_id",
")",
"in",
"self",
".",
"pending_threads",
"if",
"_id",
"!=",
"parent_id",
"]",
"threadlist",
"=",
"self",
".",
"started_threads",
".",
"get",
"(",
"parent_id",
",",
"[",
"]",
")",
"for",
"thread",
"in",
"threadlist",
":",
"logger",
".",
"debug",
"(",
"\"Waiting for thread %r to finish\"",
"%",
"thread",
")",
"while",
"thread",
".",
"isRunning",
"(",
")",
":",
"# We can't terminate thread safely, so we simply wait...\r",
"QApplication",
".",
"processEvents",
"(",
")"
] | Close threads associated to parent_id | [
"Close",
"threads",
"associated",
"to",
"parent_id"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L93-L112 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | ThreadManager.add_thread | def add_thread(self, checker, end_callback, source_code, parent):
"""Add thread to queue"""
parent_id = id(parent)
thread = AnalysisThread(self, checker, source_code)
self.end_callbacks[id(thread)] = end_callback
self.pending_threads.append((thread, parent_id))
logger.debug("Added thread %r to queue" % thread)
QTimer.singleShot(50, self.update_queue) | python | def add_thread(self, checker, end_callback, source_code, parent):
"""Add thread to queue"""
parent_id = id(parent)
thread = AnalysisThread(self, checker, source_code)
self.end_callbacks[id(thread)] = end_callback
self.pending_threads.append((thread, parent_id))
logger.debug("Added thread %r to queue" % thread)
QTimer.singleShot(50, self.update_queue) | [
"def",
"add_thread",
"(",
"self",
",",
"checker",
",",
"end_callback",
",",
"source_code",
",",
"parent",
")",
":",
"parent_id",
"=",
"id",
"(",
"parent",
")",
"thread",
"=",
"AnalysisThread",
"(",
"self",
",",
"checker",
",",
"source_code",
")",
"self",
".",
"end_callbacks",
"[",
"id",
"(",
"thread",
")",
"]",
"=",
"end_callback",
"self",
".",
"pending_threads",
".",
"append",
"(",
"(",
"thread",
",",
"parent_id",
")",
")",
"logger",
".",
"debug",
"(",
"\"Added thread %r to queue\"",
"%",
"thread",
")",
"QTimer",
".",
"singleShot",
"(",
"50",
",",
"self",
".",
"update_queue",
")"
] | Add thread to queue | [
"Add",
"thread",
"to",
"queue"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L119-L126 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | ThreadManager.update_queue | def update_queue(self):
"""Update queue"""
started = 0
for parent_id, threadlist in list(self.started_threads.items()):
still_running = []
for thread in threadlist:
if thread.isFinished():
end_callback = self.end_callbacks.pop(id(thread))
if thread.results is not None:
# The thread was executed successfully
end_callback(thread.results)
thread.setParent(None)
thread = None
else:
still_running.append(thread)
started += 1
threadlist = None
if still_running:
self.started_threads[parent_id] = still_running
else:
self.started_threads.pop(parent_id)
logger.debug("Updating queue:")
logger.debug(" started: %d" % started)
logger.debug(" pending: %d" % len(self.pending_threads))
if self.pending_threads and started < self.max_simultaneous_threads:
thread, parent_id = self.pending_threads.pop(0)
thread.finished.connect(self.update_queue)
threadlist = self.started_threads.get(parent_id, [])
self.started_threads[parent_id] = threadlist+[thread]
logger.debug("===>starting: %r" % thread)
thread.start() | python | def update_queue(self):
"""Update queue"""
started = 0
for parent_id, threadlist in list(self.started_threads.items()):
still_running = []
for thread in threadlist:
if thread.isFinished():
end_callback = self.end_callbacks.pop(id(thread))
if thread.results is not None:
# The thread was executed successfully
end_callback(thread.results)
thread.setParent(None)
thread = None
else:
still_running.append(thread)
started += 1
threadlist = None
if still_running:
self.started_threads[parent_id] = still_running
else:
self.started_threads.pop(parent_id)
logger.debug("Updating queue:")
logger.debug(" started: %d" % started)
logger.debug(" pending: %d" % len(self.pending_threads))
if self.pending_threads and started < self.max_simultaneous_threads:
thread, parent_id = self.pending_threads.pop(0)
thread.finished.connect(self.update_queue)
threadlist = self.started_threads.get(parent_id, [])
self.started_threads[parent_id] = threadlist+[thread]
logger.debug("===>starting: %r" % thread)
thread.start() | [
"def",
"update_queue",
"(",
"self",
")",
":",
"started",
"=",
"0",
"for",
"parent_id",
",",
"threadlist",
"in",
"list",
"(",
"self",
".",
"started_threads",
".",
"items",
"(",
")",
")",
":",
"still_running",
"=",
"[",
"]",
"for",
"thread",
"in",
"threadlist",
":",
"if",
"thread",
".",
"isFinished",
"(",
")",
":",
"end_callback",
"=",
"self",
".",
"end_callbacks",
".",
"pop",
"(",
"id",
"(",
"thread",
")",
")",
"if",
"thread",
".",
"results",
"is",
"not",
"None",
":",
"# The thread was executed successfully\r",
"end_callback",
"(",
"thread",
".",
"results",
")",
"thread",
".",
"setParent",
"(",
"None",
")",
"thread",
"=",
"None",
"else",
":",
"still_running",
".",
"append",
"(",
"thread",
")",
"started",
"+=",
"1",
"threadlist",
"=",
"None",
"if",
"still_running",
":",
"self",
".",
"started_threads",
"[",
"parent_id",
"]",
"=",
"still_running",
"else",
":",
"self",
".",
"started_threads",
".",
"pop",
"(",
"parent_id",
")",
"logger",
".",
"debug",
"(",
"\"Updating queue:\"",
")",
"logger",
".",
"debug",
"(",
"\" started: %d\"",
"%",
"started",
")",
"logger",
".",
"debug",
"(",
"\" pending: %d\"",
"%",
"len",
"(",
"self",
".",
"pending_threads",
")",
")",
"if",
"self",
".",
"pending_threads",
"and",
"started",
"<",
"self",
".",
"max_simultaneous_threads",
":",
"thread",
",",
"parent_id",
"=",
"self",
".",
"pending_threads",
".",
"pop",
"(",
"0",
")",
"thread",
".",
"finished",
".",
"connect",
"(",
"self",
".",
"update_queue",
")",
"threadlist",
"=",
"self",
".",
"started_threads",
".",
"get",
"(",
"parent_id",
",",
"[",
"]",
")",
"self",
".",
"started_threads",
"[",
"parent_id",
"]",
"=",
"threadlist",
"+",
"[",
"thread",
"]",
"logger",
".",
"debug",
"(",
"\"===>starting: %r\"",
"%",
"thread",
")",
"thread",
".",
"start",
"(",
")"
] | Update queue | [
"Update",
"queue"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L128-L158 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | FileInfo.text_changed | def text_changed(self):
"""Editor's text has changed"""
self.default = False
self.editor.document().changed_since_autosave = True
self.text_changed_at.emit(self.filename,
self.editor.get_position('cursor')) | python | def text_changed(self):
"""Editor's text has changed"""
self.default = False
self.editor.document().changed_since_autosave = True
self.text_changed_at.emit(self.filename,
self.editor.get_position('cursor')) | [
"def",
"text_changed",
"(",
"self",
")",
":",
"self",
".",
"default",
"=",
"False",
"self",
".",
"editor",
".",
"document",
"(",
")",
".",
"changed_since_autosave",
"=",
"True",
"self",
".",
"text_changed_at",
".",
"emit",
"(",
"self",
".",
"filename",
",",
"self",
".",
"editor",
".",
"get_position",
"(",
"'cursor'",
")",
")"
] | Editor's text has changed | [
"Editor",
"s",
"text",
"has",
"changed"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L197-L202 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | FileInfo.run_todo_finder | def run_todo_finder(self):
"""Run TODO finder"""
if self.editor.is_python():
self.threadmanager.add_thread(codeanalysis.find_tasks,
self.todo_finished,
self.get_source_code(), self) | python | def run_todo_finder(self):
"""Run TODO finder"""
if self.editor.is_python():
self.threadmanager.add_thread(codeanalysis.find_tasks,
self.todo_finished,
self.get_source_code(), self) | [
"def",
"run_todo_finder",
"(",
"self",
")",
":",
"if",
"self",
".",
"editor",
".",
"is_python",
"(",
")",
":",
"self",
".",
"threadmanager",
".",
"add_thread",
"(",
"codeanalysis",
".",
"find_tasks",
",",
"self",
".",
"todo_finished",
",",
"self",
".",
"get_source_code",
"(",
")",
",",
"self",
")"
] | Run TODO finder | [
"Run",
"TODO",
"finder"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L208-L213 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | FileInfo.set_todo_results | def set_todo_results(self, results):
"""Set TODO results and update markers in editor"""
self.todo_results = results
self.editor.process_todo(results) | python | def set_todo_results(self, results):
"""Set TODO results and update markers in editor"""
self.todo_results = results
self.editor.process_todo(results) | [
"def",
"set_todo_results",
"(",
"self",
",",
"results",
")",
":",
"self",
".",
"todo_results",
"=",
"results",
"self",
".",
"editor",
".",
"process_todo",
"(",
"results",
")"
] | Set TODO results and update markers in editor | [
"Set",
"TODO",
"results",
"and",
"update",
"markers",
"in",
"editor"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L220-L223 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | FileInfo.bookmarks_changed | def bookmarks_changed(self):
"""Bookmarks list has changed."""
bookmarks = self.editor.get_bookmarks()
if self.editor.bookmarks != bookmarks:
self.editor.bookmarks = bookmarks
self.sig_save_bookmarks.emit(self.filename, repr(bookmarks)) | python | def bookmarks_changed(self):
"""Bookmarks list has changed."""
bookmarks = self.editor.get_bookmarks()
if self.editor.bookmarks != bookmarks:
self.editor.bookmarks = bookmarks
self.sig_save_bookmarks.emit(self.filename, repr(bookmarks)) | [
"def",
"bookmarks_changed",
"(",
"self",
")",
":",
"bookmarks",
"=",
"self",
".",
"editor",
".",
"get_bookmarks",
"(",
")",
"if",
"self",
".",
"editor",
".",
"bookmarks",
"!=",
"bookmarks",
":",
"self",
".",
"editor",
".",
"bookmarks",
"=",
"bookmarks",
"self",
".",
"sig_save_bookmarks",
".",
"emit",
"(",
"self",
".",
"filename",
",",
"repr",
"(",
"bookmarks",
")",
")"
] | Bookmarks list has changed. | [
"Bookmarks",
"list",
"has",
"changed",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L229-L234 | train |
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 | train |
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",
"(",
"_id",
")"
] | 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 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | StackHistory.insert | def insert(self, i, tab_index):
"""Insert the widget (at tab index) in the position i (index)."""
_id = id(self.editor.tabs.widget(tab_index))
self.history.insert(i, _id) | python | def insert(self, i, tab_index):
"""Insert the widget (at tab index) in the position i (index)."""
_id = id(self.editor.tabs.widget(tab_index))
self.history.insert(i, _id) | [
"def",
"insert",
"(",
"self",
",",
"i",
",",
"tab_index",
")",
":",
"_id",
"=",
"id",
"(",
"self",
".",
"editor",
".",
"tabs",
".",
"widget",
"(",
"tab_index",
")",
")",
"self",
".",
"history",
".",
"insert",
"(",
"i",
",",
"_id",
")"
] | Insert the widget (at tab index) in the position i (index). | [
"Insert",
"the",
"widget",
"(",
"at",
"tab",
"index",
")",
"in",
"the",
"position",
"i",
"(",
"index",
")",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L282-L285 | train |
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",
"(",
"_id",
")"
] | 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 | train |
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 | train |
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",
"(",
"'&'",
",",
"''",
")",
"item",
"=",
"QListWidgetItem",
"(",
"ima",
".",
"icon",
"(",
"'TextFileIcon'",
")",
",",
"text",
")",
"self",
".",
"addItem",
"(",
"item",
")"
] | 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 | train |
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",
"[",
"-",
"(",
"self",
".",
"currentRow",
"(",
")",
"+",
"1",
")",
"]",
"except",
"IndexError",
":",
"pass",
"else",
":",
"self",
".",
"editor",
".",
"set_stack_index",
"(",
"index",
")",
"self",
".",
"editor",
".",
"current_changed",
"(",
"index",
")",
"self",
".",
"hide",
"(",
")"
] | 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 | train |
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 | train |
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",
".",
"tabBar",
"(",
")",
".",
"geometry",
"(",
")",
".",
"height",
"(",
")",
"self",
".",
"move",
"(",
"self",
".",
"editor",
".",
"mapToGlobal",
"(",
"QPoint",
"(",
"left",
",",
"top",
")",
")",
")"
] | 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 | train |
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",
".",
"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",
"(",
")"
] | 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 | train |
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",
":",
"self",
".",
"select_row",
"(",
"-",
"1",
")"
] | 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 | train |
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",
".",
"reason",
"(",
")",
"!=",
"Qt",
".",
"ActiveWindowFocusReason",
":",
"self",
".",
"close",
"(",
")",
"else",
":",
"self",
".",
"close",
"(",
")"
] | 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 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.create_shortcuts | def create_shortcuts(self):
"""Create local shortcuts"""
# --- Configurable shortcuts
inspect = config_shortcut(self.inspect_current_object, context='Editor',
name='Inspect current object', parent=self)
set_breakpoint = config_shortcut(self.set_or_clear_breakpoint,
context='Editor', name='Breakpoint',
parent=self)
set_cond_breakpoint = config_shortcut(
self.set_or_edit_conditional_breakpoint,
context='Editor',
name='Conditional breakpoint',
parent=self)
gotoline = config_shortcut(self.go_to_line, context='Editor',
name='Go to line', parent=self)
tab = config_shortcut(lambda: self.tab_navigation_mru(forward=False),
context='Editor',
name='Go to previous file', parent=self)
tabshift = config_shortcut(self.tab_navigation_mru, context='Editor',
name='Go to next file', parent=self)
prevtab = config_shortcut(lambda: self.tabs.tab_navigate(-1),
context='Editor',
name='Cycle to previous file', parent=self)
nexttab = config_shortcut(lambda: self.tabs.tab_navigate(1),
context='Editor',
name='Cycle to next file', parent=self)
run_selection = config_shortcut(self.run_selection, context='Editor',
name='Run selection', parent=self)
new_file = config_shortcut(lambda : self.sig_new_file[()].emit(),
context='Editor', name='New file',
parent=self)
open_file = config_shortcut(lambda : self.plugin_load[()].emit(),
context='Editor', name='Open file',
parent=self)
save_file = config_shortcut(self.save, context='Editor',
name='Save file', parent=self)
save_all = config_shortcut(self.save_all, context='Editor',
name='Save all', parent=self)
save_as = config_shortcut(lambda : self.sig_save_as.emit(),
context='Editor', name='Save As',
parent=self)
close_all = config_shortcut(self.close_all_files, context='Editor',
name='Close all', parent=self)
prev_edit_pos = config_shortcut(lambda : self.sig_prev_edit_pos.emit(),
context="Editor",
name="Last edit location",
parent=self)
prev_cursor = config_shortcut(lambda : self.sig_prev_cursor.emit(),
context="Editor",
name="Previous cursor position",
parent=self)
next_cursor = config_shortcut(lambda : self.sig_next_cursor.emit(),
context="Editor",
name="Next cursor position",
parent=self)
zoom_in_1 = config_shortcut(lambda : self.zoom_in.emit(),
context="Editor",
name="zoom in 1",
parent=self)
zoom_in_2 = config_shortcut(lambda : self.zoom_in.emit(),
context="Editor",
name="zoom in 2",
parent=self)
zoom_out = config_shortcut(lambda : self.zoom_out.emit(),
context="Editor",
name="zoom out",
parent=self)
zoom_reset = config_shortcut(lambda: self.zoom_reset.emit(),
context="Editor",
name="zoom reset",
parent=self)
close_file_1 = config_shortcut(self.close_file,
context="Editor",
name="close file 1",
parent=self)
close_file_2 = config_shortcut(self.close_file,
context="Editor",
name="close file 2",
parent=self)
run_cell = config_shortcut(self.run_cell,
context="Editor",
name="run cell",
parent=self)
run_cell_and_advance = config_shortcut(self.run_cell_and_advance,
context="Editor",
name="run cell and advance",
parent=self)
go_to_next_cell = config_shortcut(self.advance_cell,
context="Editor",
name="go to next cell",
parent=self)
go_to_previous_cell = config_shortcut(lambda: self.advance_cell(reverse=True),
context="Editor",
name="go to previous cell",
parent=self)
re_run_last_cell = config_shortcut(self.re_run_last_cell,
context="Editor",
name="re-run last cell",
parent=self)
prev_warning = config_shortcut(lambda: self.sig_prev_warning.emit(),
context="Editor",
name="Previous warning",
parent=self)
next_warning = config_shortcut(lambda: self.sig_next_warning.emit(),
context="Editor",
name="Next warning",
parent=self)
split_vertically = config_shortcut(lambda: self.sig_split_vertically.emit(),
context="Editor",
name="split vertically",
parent=self)
split_horizontally = config_shortcut(lambda: self.sig_split_horizontally.emit(),
context="Editor",
name="split horizontally",
parent=self)
close_split = config_shortcut(self.close_split,
context="Editor",
name="close split panel",
parent=self)
# Return configurable ones
return [inspect, set_breakpoint, set_cond_breakpoint, gotoline, tab,
tabshift, run_selection, new_file, open_file, save_file,
save_all, save_as, close_all, prev_edit_pos, prev_cursor,
next_cursor, zoom_in_1, zoom_in_2, zoom_out, zoom_reset,
close_file_1, close_file_2, run_cell, run_cell_and_advance,
go_to_next_cell, go_to_previous_cell, re_run_last_cell,
prev_warning, next_warning, split_vertically,
split_horizontally, close_split,
prevtab, nexttab] | python | def create_shortcuts(self):
"""Create local shortcuts"""
# --- Configurable shortcuts
inspect = config_shortcut(self.inspect_current_object, context='Editor',
name='Inspect current object', parent=self)
set_breakpoint = config_shortcut(self.set_or_clear_breakpoint,
context='Editor', name='Breakpoint',
parent=self)
set_cond_breakpoint = config_shortcut(
self.set_or_edit_conditional_breakpoint,
context='Editor',
name='Conditional breakpoint',
parent=self)
gotoline = config_shortcut(self.go_to_line, context='Editor',
name='Go to line', parent=self)
tab = config_shortcut(lambda: self.tab_navigation_mru(forward=False),
context='Editor',
name='Go to previous file', parent=self)
tabshift = config_shortcut(self.tab_navigation_mru, context='Editor',
name='Go to next file', parent=self)
prevtab = config_shortcut(lambda: self.tabs.tab_navigate(-1),
context='Editor',
name='Cycle to previous file', parent=self)
nexttab = config_shortcut(lambda: self.tabs.tab_navigate(1),
context='Editor',
name='Cycle to next file', parent=self)
run_selection = config_shortcut(self.run_selection, context='Editor',
name='Run selection', parent=self)
new_file = config_shortcut(lambda : self.sig_new_file[()].emit(),
context='Editor', name='New file',
parent=self)
open_file = config_shortcut(lambda : self.plugin_load[()].emit(),
context='Editor', name='Open file',
parent=self)
save_file = config_shortcut(self.save, context='Editor',
name='Save file', parent=self)
save_all = config_shortcut(self.save_all, context='Editor',
name='Save all', parent=self)
save_as = config_shortcut(lambda : self.sig_save_as.emit(),
context='Editor', name='Save As',
parent=self)
close_all = config_shortcut(self.close_all_files, context='Editor',
name='Close all', parent=self)
prev_edit_pos = config_shortcut(lambda : self.sig_prev_edit_pos.emit(),
context="Editor",
name="Last edit location",
parent=self)
prev_cursor = config_shortcut(lambda : self.sig_prev_cursor.emit(),
context="Editor",
name="Previous cursor position",
parent=self)
next_cursor = config_shortcut(lambda : self.sig_next_cursor.emit(),
context="Editor",
name="Next cursor position",
parent=self)
zoom_in_1 = config_shortcut(lambda : self.zoom_in.emit(),
context="Editor",
name="zoom in 1",
parent=self)
zoom_in_2 = config_shortcut(lambda : self.zoom_in.emit(),
context="Editor",
name="zoom in 2",
parent=self)
zoom_out = config_shortcut(lambda : self.zoom_out.emit(),
context="Editor",
name="zoom out",
parent=self)
zoom_reset = config_shortcut(lambda: self.zoom_reset.emit(),
context="Editor",
name="zoom reset",
parent=self)
close_file_1 = config_shortcut(self.close_file,
context="Editor",
name="close file 1",
parent=self)
close_file_2 = config_shortcut(self.close_file,
context="Editor",
name="close file 2",
parent=self)
run_cell = config_shortcut(self.run_cell,
context="Editor",
name="run cell",
parent=self)
run_cell_and_advance = config_shortcut(self.run_cell_and_advance,
context="Editor",
name="run cell and advance",
parent=self)
go_to_next_cell = config_shortcut(self.advance_cell,
context="Editor",
name="go to next cell",
parent=self)
go_to_previous_cell = config_shortcut(lambda: self.advance_cell(reverse=True),
context="Editor",
name="go to previous cell",
parent=self)
re_run_last_cell = config_shortcut(self.re_run_last_cell,
context="Editor",
name="re-run last cell",
parent=self)
prev_warning = config_shortcut(lambda: self.sig_prev_warning.emit(),
context="Editor",
name="Previous warning",
parent=self)
next_warning = config_shortcut(lambda: self.sig_next_warning.emit(),
context="Editor",
name="Next warning",
parent=self)
split_vertically = config_shortcut(lambda: self.sig_split_vertically.emit(),
context="Editor",
name="split vertically",
parent=self)
split_horizontally = config_shortcut(lambda: self.sig_split_horizontally.emit(),
context="Editor",
name="split horizontally",
parent=self)
close_split = config_shortcut(self.close_split,
context="Editor",
name="close split panel",
parent=self)
# Return configurable ones
return [inspect, set_breakpoint, set_cond_breakpoint, gotoline, tab,
tabshift, run_selection, new_file, open_file, save_file,
save_all, save_as, close_all, prev_edit_pos, prev_cursor,
next_cursor, zoom_in_1, zoom_in_2, zoom_out, zoom_reset,
close_file_1, close_file_2, run_cell, run_cell_and_advance,
go_to_next_cell, go_to_previous_cell, re_run_last_cell,
prev_warning, next_warning, split_vertically,
split_horizontally, close_split,
prevtab, nexttab] | [
"def",
"create_shortcuts",
"(",
"self",
")",
":",
"# --- Configurable shortcuts\r",
"inspect",
"=",
"config_shortcut",
"(",
"self",
".",
"inspect_current_object",
",",
"context",
"=",
"'Editor'",
",",
"name",
"=",
"'Inspect current object'",
",",
"parent",
"=",
"self",
")",
"set_breakpoint",
"=",
"config_shortcut",
"(",
"self",
".",
"set_or_clear_breakpoint",
",",
"context",
"=",
"'Editor'",
",",
"name",
"=",
"'Breakpoint'",
",",
"parent",
"=",
"self",
")",
"set_cond_breakpoint",
"=",
"config_shortcut",
"(",
"self",
".",
"set_or_edit_conditional_breakpoint",
",",
"context",
"=",
"'Editor'",
",",
"name",
"=",
"'Conditional breakpoint'",
",",
"parent",
"=",
"self",
")",
"gotoline",
"=",
"config_shortcut",
"(",
"self",
".",
"go_to_line",
",",
"context",
"=",
"'Editor'",
",",
"name",
"=",
"'Go to line'",
",",
"parent",
"=",
"self",
")",
"tab",
"=",
"config_shortcut",
"(",
"lambda",
":",
"self",
".",
"tab_navigation_mru",
"(",
"forward",
"=",
"False",
")",
",",
"context",
"=",
"'Editor'",
",",
"name",
"=",
"'Go to previous file'",
",",
"parent",
"=",
"self",
")",
"tabshift",
"=",
"config_shortcut",
"(",
"self",
".",
"tab_navigation_mru",
",",
"context",
"=",
"'Editor'",
",",
"name",
"=",
"'Go to next file'",
",",
"parent",
"=",
"self",
")",
"prevtab",
"=",
"config_shortcut",
"(",
"lambda",
":",
"self",
".",
"tabs",
".",
"tab_navigate",
"(",
"-",
"1",
")",
",",
"context",
"=",
"'Editor'",
",",
"name",
"=",
"'Cycle to previous file'",
",",
"parent",
"=",
"self",
")",
"nexttab",
"=",
"config_shortcut",
"(",
"lambda",
":",
"self",
".",
"tabs",
".",
"tab_navigate",
"(",
"1",
")",
",",
"context",
"=",
"'Editor'",
",",
"name",
"=",
"'Cycle to next file'",
",",
"parent",
"=",
"self",
")",
"run_selection",
"=",
"config_shortcut",
"(",
"self",
".",
"run_selection",
",",
"context",
"=",
"'Editor'",
",",
"name",
"=",
"'Run selection'",
",",
"parent",
"=",
"self",
")",
"new_file",
"=",
"config_shortcut",
"(",
"lambda",
":",
"self",
".",
"sig_new_file",
"[",
"(",
")",
"]",
".",
"emit",
"(",
")",
",",
"context",
"=",
"'Editor'",
",",
"name",
"=",
"'New file'",
",",
"parent",
"=",
"self",
")",
"open_file",
"=",
"config_shortcut",
"(",
"lambda",
":",
"self",
".",
"plugin_load",
"[",
"(",
")",
"]",
".",
"emit",
"(",
")",
",",
"context",
"=",
"'Editor'",
",",
"name",
"=",
"'Open file'",
",",
"parent",
"=",
"self",
")",
"save_file",
"=",
"config_shortcut",
"(",
"self",
".",
"save",
",",
"context",
"=",
"'Editor'",
",",
"name",
"=",
"'Save file'",
",",
"parent",
"=",
"self",
")",
"save_all",
"=",
"config_shortcut",
"(",
"self",
".",
"save_all",
",",
"context",
"=",
"'Editor'",
",",
"name",
"=",
"'Save all'",
",",
"parent",
"=",
"self",
")",
"save_as",
"=",
"config_shortcut",
"(",
"lambda",
":",
"self",
".",
"sig_save_as",
".",
"emit",
"(",
")",
",",
"context",
"=",
"'Editor'",
",",
"name",
"=",
"'Save As'",
",",
"parent",
"=",
"self",
")",
"close_all",
"=",
"config_shortcut",
"(",
"self",
".",
"close_all_files",
",",
"context",
"=",
"'Editor'",
",",
"name",
"=",
"'Close all'",
",",
"parent",
"=",
"self",
")",
"prev_edit_pos",
"=",
"config_shortcut",
"(",
"lambda",
":",
"self",
".",
"sig_prev_edit_pos",
".",
"emit",
"(",
")",
",",
"context",
"=",
"\"Editor\"",
",",
"name",
"=",
"\"Last edit location\"",
",",
"parent",
"=",
"self",
")",
"prev_cursor",
"=",
"config_shortcut",
"(",
"lambda",
":",
"self",
".",
"sig_prev_cursor",
".",
"emit",
"(",
")",
",",
"context",
"=",
"\"Editor\"",
",",
"name",
"=",
"\"Previous cursor position\"",
",",
"parent",
"=",
"self",
")",
"next_cursor",
"=",
"config_shortcut",
"(",
"lambda",
":",
"self",
".",
"sig_next_cursor",
".",
"emit",
"(",
")",
",",
"context",
"=",
"\"Editor\"",
",",
"name",
"=",
"\"Next cursor position\"",
",",
"parent",
"=",
"self",
")",
"zoom_in_1",
"=",
"config_shortcut",
"(",
"lambda",
":",
"self",
".",
"zoom_in",
".",
"emit",
"(",
")",
",",
"context",
"=",
"\"Editor\"",
",",
"name",
"=",
"\"zoom in 1\"",
",",
"parent",
"=",
"self",
")",
"zoom_in_2",
"=",
"config_shortcut",
"(",
"lambda",
":",
"self",
".",
"zoom_in",
".",
"emit",
"(",
")",
",",
"context",
"=",
"\"Editor\"",
",",
"name",
"=",
"\"zoom in 2\"",
",",
"parent",
"=",
"self",
")",
"zoom_out",
"=",
"config_shortcut",
"(",
"lambda",
":",
"self",
".",
"zoom_out",
".",
"emit",
"(",
")",
",",
"context",
"=",
"\"Editor\"",
",",
"name",
"=",
"\"zoom out\"",
",",
"parent",
"=",
"self",
")",
"zoom_reset",
"=",
"config_shortcut",
"(",
"lambda",
":",
"self",
".",
"zoom_reset",
".",
"emit",
"(",
")",
",",
"context",
"=",
"\"Editor\"",
",",
"name",
"=",
"\"zoom reset\"",
",",
"parent",
"=",
"self",
")",
"close_file_1",
"=",
"config_shortcut",
"(",
"self",
".",
"close_file",
",",
"context",
"=",
"\"Editor\"",
",",
"name",
"=",
"\"close file 1\"",
",",
"parent",
"=",
"self",
")",
"close_file_2",
"=",
"config_shortcut",
"(",
"self",
".",
"close_file",
",",
"context",
"=",
"\"Editor\"",
",",
"name",
"=",
"\"close file 2\"",
",",
"parent",
"=",
"self",
")",
"run_cell",
"=",
"config_shortcut",
"(",
"self",
".",
"run_cell",
",",
"context",
"=",
"\"Editor\"",
",",
"name",
"=",
"\"run cell\"",
",",
"parent",
"=",
"self",
")",
"run_cell_and_advance",
"=",
"config_shortcut",
"(",
"self",
".",
"run_cell_and_advance",
",",
"context",
"=",
"\"Editor\"",
",",
"name",
"=",
"\"run cell and advance\"",
",",
"parent",
"=",
"self",
")",
"go_to_next_cell",
"=",
"config_shortcut",
"(",
"self",
".",
"advance_cell",
",",
"context",
"=",
"\"Editor\"",
",",
"name",
"=",
"\"go to next cell\"",
",",
"parent",
"=",
"self",
")",
"go_to_previous_cell",
"=",
"config_shortcut",
"(",
"lambda",
":",
"self",
".",
"advance_cell",
"(",
"reverse",
"=",
"True",
")",
",",
"context",
"=",
"\"Editor\"",
",",
"name",
"=",
"\"go to previous cell\"",
",",
"parent",
"=",
"self",
")",
"re_run_last_cell",
"=",
"config_shortcut",
"(",
"self",
".",
"re_run_last_cell",
",",
"context",
"=",
"\"Editor\"",
",",
"name",
"=",
"\"re-run last cell\"",
",",
"parent",
"=",
"self",
")",
"prev_warning",
"=",
"config_shortcut",
"(",
"lambda",
":",
"self",
".",
"sig_prev_warning",
".",
"emit",
"(",
")",
",",
"context",
"=",
"\"Editor\"",
",",
"name",
"=",
"\"Previous warning\"",
",",
"parent",
"=",
"self",
")",
"next_warning",
"=",
"config_shortcut",
"(",
"lambda",
":",
"self",
".",
"sig_next_warning",
".",
"emit",
"(",
")",
",",
"context",
"=",
"\"Editor\"",
",",
"name",
"=",
"\"Next warning\"",
",",
"parent",
"=",
"self",
")",
"split_vertically",
"=",
"config_shortcut",
"(",
"lambda",
":",
"self",
".",
"sig_split_vertically",
".",
"emit",
"(",
")",
",",
"context",
"=",
"\"Editor\"",
",",
"name",
"=",
"\"split vertically\"",
",",
"parent",
"=",
"self",
")",
"split_horizontally",
"=",
"config_shortcut",
"(",
"lambda",
":",
"self",
".",
"sig_split_horizontally",
".",
"emit",
"(",
")",
",",
"context",
"=",
"\"Editor\"",
",",
"name",
"=",
"\"split horizontally\"",
",",
"parent",
"=",
"self",
")",
"close_split",
"=",
"config_shortcut",
"(",
"self",
".",
"close_split",
",",
"context",
"=",
"\"Editor\"",
",",
"name",
"=",
"\"close split panel\"",
",",
"parent",
"=",
"self",
")",
"# Return configurable ones\r",
"return",
"[",
"inspect",
",",
"set_breakpoint",
",",
"set_cond_breakpoint",
",",
"gotoline",
",",
"tab",
",",
"tabshift",
",",
"run_selection",
",",
"new_file",
",",
"open_file",
",",
"save_file",
",",
"save_all",
",",
"save_as",
",",
"close_all",
",",
"prev_edit_pos",
",",
"prev_cursor",
",",
"next_cursor",
",",
"zoom_in_1",
",",
"zoom_in_2",
",",
"zoom_out",
",",
"zoom_reset",
",",
"close_file_1",
",",
"close_file_2",
",",
"run_cell",
",",
"run_cell_and_advance",
",",
"go_to_next_cell",
",",
"go_to_previous_cell",
",",
"re_run_last_cell",
",",
"prev_warning",
",",
"next_warning",
",",
"split_vertically",
",",
"split_horizontally",
",",
"close_split",
",",
"prevtab",
",",
"nexttab",
"]"
] | Create local shortcuts | [
"Create",
"local",
"shortcuts"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L597-L726 | train |
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; 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\r",
"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\r",
"# a crash when the editor is detached from the main window\r",
"# Fixes Issue 561\r",
"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",
")"
] | 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 | train |
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",
"[",
"-",
"100",
":",
"]",
"else",
":",
"shorten_filename",
"=",
"filename",
"self",
".",
"fname_label",
".",
"setText",
"(",
"shorten_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 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.closeEvent | def closeEvent(self, event):
"""Overrides QWidget closeEvent()."""
self.threadmanager.close_all_threads()
self.analysis_timer.timeout.disconnect(self.analyze_script)
# Remove editor references from the outline explorer settings
if self.outlineexplorer is not None:
for finfo in self.data:
self.outlineexplorer.remove_editor(finfo.editor.oe_proxy)
QWidget.closeEvent(self, event) | python | def closeEvent(self, event):
"""Overrides QWidget closeEvent()."""
self.threadmanager.close_all_threads()
self.analysis_timer.timeout.disconnect(self.analyze_script)
# Remove editor references from the outline explorer settings
if self.outlineexplorer is not None:
for finfo in self.data:
self.outlineexplorer.remove_editor(finfo.editor.oe_proxy)
QWidget.closeEvent(self, event) | [
"def",
"closeEvent",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"threadmanager",
".",
"close_all_threads",
"(",
")",
"self",
".",
"analysis_timer",
".",
"timeout",
".",
"disconnect",
"(",
"self",
".",
"analyze_script",
")",
"# Remove editor references from the outline explorer settings\r",
"if",
"self",
".",
"outlineexplorer",
"is",
"not",
"None",
":",
"for",
"finfo",
"in",
"self",
".",
"data",
":",
"self",
".",
"outlineexplorer",
".",
"remove_editor",
"(",
"finfo",
".",
"editor",
".",
"oe_proxy",
")",
"QWidget",
".",
"closeEvent",
"(",
"self",
",",
"event",
")"
] | Overrides QWidget closeEvent(). | [
"Overrides",
"QWidget",
"closeEvent",
"()",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L808-L818 | train |
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",
".",
"get_stack_index",
"(",
")",
")"
] | 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 | train |
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",
":",
"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"
] | 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 | train |
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",
"(",
"line",
")",
"else",
":",
"if",
"self",
".",
"data",
":",
"self",
".",
"get_current_editor",
"(",
")",
".",
"exec_gotolinedialog",
"(",
")"
] | 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 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.set_or_clear_breakpoint | def set_or_clear_breakpoint(self):
"""Set/clear breakpoint"""
if self.data:
editor = self.get_current_editor()
editor.debugger.toogle_breakpoint() | python | def set_or_clear_breakpoint(self):
"""Set/clear breakpoint"""
if self.data:
editor = self.get_current_editor()
editor.debugger.toogle_breakpoint() | [
"def",
"set_or_clear_breakpoint",
"(",
"self",
")",
":",
"if",
"self",
".",
"data",
":",
"editor",
"=",
"self",
".",
"get_current_editor",
"(",
")",
"editor",
".",
"debugger",
".",
"toogle_breakpoint",
"(",
")"
] | Set/clear breakpoint | [
"Set",
"/",
"clear",
"breakpoint"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L871-L875 | train |
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 | train |
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 | train |
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",
".",
"get_cursor_line_column",
"(",
")",
"editor",
".",
"request_hover",
"(",
"line",
",",
"col",
")"
] | 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 | train |
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",
"(",
"index",
"=",
"index",
")"
] | 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 | train |
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",
".",
"data",
"[",
"index",
"]",
".",
"filename",
"fname",
"=",
"sourcecode",
".",
"disambiguate_fname",
"(",
"files_path_list",
",",
"fname",
")",
"return",
"self",
".",
"__modified_readonly_title",
"(",
"fname",
",",
"is_modified",
",",
"is_readonly",
")"
] | Return tab title. | [
"Return",
"tab",
"title",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1183-L1189 | train |
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_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",
")",
")"
] | 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 | train |
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",
".",
"open_action",
")",
"self",
".",
"setFocus",
"(",
")",
"# --> Editor.__get_focus_editortabwidget\r",
"add_actions",
"(",
"self",
".",
"menu",
",",
"list",
"(",
"actions",
")",
"+",
"self",
".",
"__get_split_actions",
"(",
")",
")",
"self",
".",
"close_action",
".",
"setEnabled",
"(",
"self",
".",
"is_closable",
")"
] | 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 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.has_filename | def has_filename(self, filename):
"""Return the self.data index position for the filename.
Args:
filename: Name of the file to search for in self.data.
Returns:
The self.data index for the filename. Returns None
if the filename is not found in self.data.
"""
fixpath = lambda path: osp.normcase(osp.realpath(path))
for index, finfo in enumerate(self.data):
if fixpath(filename) == fixpath(finfo.filename):
return index
return None | python | def has_filename(self, filename):
"""Return the self.data index position for the filename.
Args:
filename: Name of the file to search for in self.data.
Returns:
The self.data index for the filename. Returns None
if the filename is not found in self.data.
"""
fixpath = lambda path: osp.normcase(osp.realpath(path))
for index, finfo in enumerate(self.data):
if fixpath(filename) == fixpath(finfo.filename):
return index
return None | [
"def",
"has_filename",
"(",
"self",
",",
"filename",
")",
":",
"fixpath",
"=",
"lambda",
"path",
":",
"osp",
".",
"normcase",
"(",
"osp",
".",
"realpath",
"(",
"path",
")",
")",
"for",
"index",
",",
"finfo",
"in",
"enumerate",
"(",
"self",
".",
"data",
")",
":",
"if",
"fixpath",
"(",
"filename",
")",
"==",
"fixpath",
"(",
"finfo",
".",
"filename",
")",
":",
"return",
"index",
"return",
"None"
] | Return the self.data index position for the filename.
Args:
filename: Name of the file to search for in self.data.
Returns:
The self.data index for the filename. Returns None
if the filename is not found in self.data. | [
"Return",
"the",
"self",
".",
"data",
"index",
"position",
"for",
"the",
"filename",
".",
"Args",
":",
"filename",
":",
"Name",
"of",
"the",
"file",
"to",
"search",
"for",
"in",
"self",
".",
"data",
".",
"Returns",
":",
"The",
"self",
".",
"data",
"index",
"for",
"the",
"filename",
".",
"Returns",
"None",
"if",
"the",
"filename",
"is",
"not",
"found",
"in",
"self",
".",
"data",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1364-L1378 | train |
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",
"(",
"index",
")",
"editor",
"=",
"self",
".",
"data",
"[",
"index",
"]",
".",
"editor",
"if",
"focus",
":",
"editor",
".",
"setFocus",
"(",
")",
"else",
":",
"self",
".",
"stack_history",
".",
"remove_and_append",
"(",
"index",
")",
"return",
"editor"
] | 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 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.is_file_opened | def is_file_opened(self, filename=None):
"""Return if filename is in the editor stack.
Args:
filename: Name of the file to search for. If filename is None,
then checks if any file is open.
Returns:
True: If filename is None and a file is open.
False: If filename is None and no files are open.
None: If filename is not None and the file isn't found.
integer: Index of file name in editor stack.
"""
if filename is None:
# Is there any file opened?
return len(self.data) > 0
else:
return self.has_filename(filename) | python | def is_file_opened(self, filename=None):
"""Return if filename is in the editor stack.
Args:
filename: Name of the file to search for. If filename is None,
then checks if any file is open.
Returns:
True: If filename is None and a file is open.
False: If filename is None and no files are open.
None: If filename is not None and the file isn't found.
integer: Index of file name in editor stack.
"""
if filename is None:
# Is there any file opened?
return len(self.data) > 0
else:
return self.has_filename(filename) | [
"def",
"is_file_opened",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"if",
"filename",
"is",
"None",
":",
"# Is there any file opened?\r",
"return",
"len",
"(",
"self",
".",
"data",
")",
">",
"0",
"else",
":",
"return",
"self",
".",
"has_filename",
"(",
"filename",
")"
] | Return if filename is in the editor stack.
Args:
filename: Name of the file to search for. If filename is None,
then checks if any file is open.
Returns:
True: If filename is None and a file is open.
False: If filename is None and no files are open.
None: If filename is not None and the file isn't found.
integer: Index of file name in editor stack. | [
"Return",
"if",
"filename",
"is",
"in",
"the",
"editor",
"stack",
".",
"Args",
":",
"filename",
":",
"Name",
"of",
"the",
"file",
"to",
"search",
"for",
".",
"If",
"filename",
"is",
"None",
"then",
"checks",
"if",
"any",
"file",
"is",
"open",
".",
"Returns",
":",
"True",
":",
"If",
"filename",
"is",
"None",
"and",
"a",
"file",
"is",
"open",
".",
"False",
":",
"If",
"filename",
"is",
"None",
"and",
"no",
"files",
"are",
"open",
".",
"None",
":",
"If",
"filename",
"is",
"not",
"None",
"and",
"the",
"file",
"isn",
"t",
"found",
".",
"integer",
":",
"Index",
"of",
"file",
"name",
"in",
"editor",
"stack",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1394-L1411 | train |
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 | train |
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",
"-",
"start",
")",
"//",
"steps",
"# +1 for right, -1 for left\r",
"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",
"(",
")"
] | 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 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.close_file | def close_file(self, index=None, force=False):
"""Close file (index=None -> close current file)
Keep current file index unchanged (if current file
that is being closed)"""
current_index = self.get_stack_index()
count = self.get_stack_count()
if index is None:
if count > 0:
index = current_index
else:
self.find_widget.set_editor(None)
return
new_index = None
if count > 1:
if current_index == index:
new_index = self._get_previous_file_index()
else:
new_index = current_index
is_ok = force or self.save_if_changed(cancelable=True, index=index)
if is_ok:
finfo = self.data[index]
self.threadmanager.close_threads(finfo)
# Removing editor reference from outline explorer settings:
if self.outlineexplorer is not None:
self.outlineexplorer.remove_editor(finfo.editor.oe_proxy)
filename = self.data[index].filename
self.remove_from_data(index)
finfo.editor.notify_close()
# We pass self object ID as a QString, because otherwise it would
# depend on the platform: long for 64bit, int for 32bit. Replacing
# by long all the time is not working on some 32bit platforms
# (see Issue 1094, Issue 1098)
self.sig_close_file.emit(str(id(self)), filename)
self.opened_files_list_changed.emit()
self.update_code_analysis_actions.emit()
self._refresh_outlineexplorer()
self.refresh_file_dependent_actions.emit()
self.update_plugin_title.emit()
editor = self.get_current_editor()
if editor:
editor.setFocus()
if new_index is not None:
if index < new_index:
new_index -= 1
self.set_stack_index(new_index)
self.add_last_closed_file(finfo.filename)
if self.get_stack_count() == 0 and self.create_new_file_if_empty:
self.sig_new_file[()].emit()
return False
self.__modify_stack_title()
return is_ok | python | def close_file(self, index=None, force=False):
"""Close file (index=None -> close current file)
Keep current file index unchanged (if current file
that is being closed)"""
current_index = self.get_stack_index()
count = self.get_stack_count()
if index is None:
if count > 0:
index = current_index
else:
self.find_widget.set_editor(None)
return
new_index = None
if count > 1:
if current_index == index:
new_index = self._get_previous_file_index()
else:
new_index = current_index
is_ok = force or self.save_if_changed(cancelable=True, index=index)
if is_ok:
finfo = self.data[index]
self.threadmanager.close_threads(finfo)
# Removing editor reference from outline explorer settings:
if self.outlineexplorer is not None:
self.outlineexplorer.remove_editor(finfo.editor.oe_proxy)
filename = self.data[index].filename
self.remove_from_data(index)
finfo.editor.notify_close()
# We pass self object ID as a QString, because otherwise it would
# depend on the platform: long for 64bit, int for 32bit. Replacing
# by long all the time is not working on some 32bit platforms
# (see Issue 1094, Issue 1098)
self.sig_close_file.emit(str(id(self)), filename)
self.opened_files_list_changed.emit()
self.update_code_analysis_actions.emit()
self._refresh_outlineexplorer()
self.refresh_file_dependent_actions.emit()
self.update_plugin_title.emit()
editor = self.get_current_editor()
if editor:
editor.setFocus()
if new_index is not None:
if index < new_index:
new_index -= 1
self.set_stack_index(new_index)
self.add_last_closed_file(finfo.filename)
if self.get_stack_count() == 0 and self.create_new_file_if_empty:
self.sig_new_file[()].emit()
return False
self.__modify_stack_title()
return is_ok | [
"def",
"close_file",
"(",
"self",
",",
"index",
"=",
"None",
",",
"force",
"=",
"False",
")",
":",
"current_index",
"=",
"self",
".",
"get_stack_index",
"(",
")",
"count",
"=",
"self",
".",
"get_stack_count",
"(",
")",
"if",
"index",
"is",
"None",
":",
"if",
"count",
">",
"0",
":",
"index",
"=",
"current_index",
"else",
":",
"self",
".",
"find_widget",
".",
"set_editor",
"(",
"None",
")",
"return",
"new_index",
"=",
"None",
"if",
"count",
">",
"1",
":",
"if",
"current_index",
"==",
"index",
":",
"new_index",
"=",
"self",
".",
"_get_previous_file_index",
"(",
")",
"else",
":",
"new_index",
"=",
"current_index",
"is_ok",
"=",
"force",
"or",
"self",
".",
"save_if_changed",
"(",
"cancelable",
"=",
"True",
",",
"index",
"=",
"index",
")",
"if",
"is_ok",
":",
"finfo",
"=",
"self",
".",
"data",
"[",
"index",
"]",
"self",
".",
"threadmanager",
".",
"close_threads",
"(",
"finfo",
")",
"# Removing editor reference from outline explorer settings:\r",
"if",
"self",
".",
"outlineexplorer",
"is",
"not",
"None",
":",
"self",
".",
"outlineexplorer",
".",
"remove_editor",
"(",
"finfo",
".",
"editor",
".",
"oe_proxy",
")",
"filename",
"=",
"self",
".",
"data",
"[",
"index",
"]",
".",
"filename",
"self",
".",
"remove_from_data",
"(",
"index",
")",
"finfo",
".",
"editor",
".",
"notify_close",
"(",
")",
"# We pass self object ID as a QString, because otherwise it would\r",
"# depend on the platform: long for 64bit, int for 32bit. Replacing\r",
"# by long all the time is not working on some 32bit platforms\r",
"# (see Issue 1094, Issue 1098)\r",
"self",
".",
"sig_close_file",
".",
"emit",
"(",
"str",
"(",
"id",
"(",
"self",
")",
")",
",",
"filename",
")",
"self",
".",
"opened_files_list_changed",
".",
"emit",
"(",
")",
"self",
".",
"update_code_analysis_actions",
".",
"emit",
"(",
")",
"self",
".",
"_refresh_outlineexplorer",
"(",
")",
"self",
".",
"refresh_file_dependent_actions",
".",
"emit",
"(",
")",
"self",
".",
"update_plugin_title",
".",
"emit",
"(",
")",
"editor",
"=",
"self",
".",
"get_current_editor",
"(",
")",
"if",
"editor",
":",
"editor",
".",
"setFocus",
"(",
")",
"if",
"new_index",
"is",
"not",
"None",
":",
"if",
"index",
"<",
"new_index",
":",
"new_index",
"-=",
"1",
"self",
".",
"set_stack_index",
"(",
"new_index",
")",
"self",
".",
"add_last_closed_file",
"(",
"finfo",
".",
"filename",
")",
"if",
"self",
".",
"get_stack_count",
"(",
")",
"==",
"0",
"and",
"self",
".",
"create_new_file_if_empty",
":",
"self",
".",
"sig_new_file",
"[",
"(",
")",
"]",
".",
"emit",
"(",
")",
"return",
"False",
"self",
".",
"__modify_stack_title",
"(",
")",
"return",
"is_ok"
] | Close file (index=None -> close current file)
Keep current file index unchanged (if current file
that is being closed) | [
"Close",
"file",
"(",
"index",
"=",
"None",
"-",
">",
"close",
"current",
"file",
")",
"Keep",
"current",
"file",
"index",
"unchanged",
"(",
"if",
"current",
"file",
"that",
"is",
"being",
"closed",
")"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1442-L1502 | train |
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",
"(",
"index",
")",
".",
"language",
".",
"lower",
"(",
")",
")",
"return",
"set",
"(",
"languages",
")"
] | 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 | train |
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",
"editor",
".",
"language",
".",
"lower",
"(",
")",
"==",
"language",
":",
"editor",
".",
"start_lsp_services",
"(",
"config",
")"
] | 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 | train |
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",
"(",
"num",
"+",
"1",
")"
] | 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 | train |
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 | train |
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",
"(",
")",
")",
":",
"if",
"(",
"self",
".",
"tabs",
".",
"tabBar",
"(",
")",
".",
"tabText",
"(",
"i",
")",
">",
"self",
".",
"tabs",
".",
"tabBar",
"(",
")",
".",
"tabText",
"(",
"i",
"+",
"1",
")",
")",
":",
"self",
".",
"tabs",
".",
"tabBar",
"(",
")",
".",
"moveTab",
"(",
"i",
",",
"i",
"+",
"1",
")"
] | 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 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.sorted | def sorted(self):
"""Utility function for sort_file_tabs_alphabetically()."""
for i in range(0, self.tabs.tabBar().count() - 1):
if (self.tabs.tabBar().tabText(i) >
self.tabs.tabBar().tabText(i + 1)):
return False
return True | python | def sorted(self):
"""Utility function for sort_file_tabs_alphabetically()."""
for i in range(0, self.tabs.tabBar().count() - 1):
if (self.tabs.tabBar().tabText(i) >
self.tabs.tabBar().tabText(i + 1)):
return False
return True | [
"def",
"sorted",
"(",
"self",
")",
":",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"self",
".",
"tabs",
".",
"tabBar",
"(",
")",
".",
"count",
"(",
")",
"-",
"1",
")",
":",
"if",
"(",
"self",
".",
"tabs",
".",
"tabBar",
"(",
")",
".",
"tabText",
"(",
"i",
")",
">",
"self",
".",
"tabs",
".",
"tabBar",
"(",
")",
".",
"tabText",
"(",
"i",
"+",
"1",
")",
")",
":",
"return",
"False",
"return",
"True"
] | Utility function for sort_file_tabs_alphabetically(). | [
"Utility",
"function",
"for",
"sort_file_tabs_alphabetically",
"()",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1545-L1551 | train |
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",
",",
"fname",
")",
"if",
"len",
"(",
"self",
".",
"last_closed_files",
")",
">",
"10",
":",
"self",
".",
"last_closed_files",
".",
"pop",
"(",
"-",
"1",
")"
] | 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 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.save_if_changed | def save_if_changed(self, cancelable=False, index=None):
"""Ask user to save file if modified.
Args:
cancelable: Show Cancel button.
index: File to check for modification.
Returns:
False when save() fails or is cancelled.
True when save() is successful, there are no modifications,
or user selects No or NoToAll.
This function controls the message box prompt for saving
changed files. The actual save is performed in save() for
each index processed. This function also removes autosave files
corresponding to files the user chooses not to save.
"""
if index is None:
indexes = list(range(self.get_stack_count()))
else:
indexes = [index]
buttons = QMessageBox.Yes | QMessageBox.No
if cancelable:
buttons |= QMessageBox.Cancel
unsaved_nb = 0
for index in indexes:
if self.data[index].editor.document().isModified():
unsaved_nb += 1
if not unsaved_nb:
# No file to save
return True
if unsaved_nb > 1:
buttons |= QMessageBox.YesToAll | QMessageBox.NoToAll
yes_all = no_all = False
for index in indexes:
self.set_stack_index(index)
finfo = self.data[index]
if finfo.filename == self.tempfile_path or yes_all:
if not self.save(index):
return False
elif no_all:
self.autosave.remove_autosave_file(finfo)
elif (finfo.editor.document().isModified() and
self.save_dialog_on_tests):
self.msgbox = QMessageBox(
QMessageBox.Question,
self.title,
_("<b>%s</b> has been modified."
"<br>Do you want to save changes?"
) % osp.basename(finfo.filename),
buttons,
parent=self)
answer = self.msgbox.exec_()
if answer == QMessageBox.Yes:
if not self.save(index):
return False
elif answer == QMessageBox.No:
self.autosave.remove_autosave_file(finfo)
elif answer == QMessageBox.YesToAll:
if not self.save(index):
return False
yes_all = True
elif answer == QMessageBox.NoToAll:
self.autosave.remove_autosave_file(finfo)
no_all = True
elif answer == QMessageBox.Cancel:
return False
return True | python | def save_if_changed(self, cancelable=False, index=None):
"""Ask user to save file if modified.
Args:
cancelable: Show Cancel button.
index: File to check for modification.
Returns:
False when save() fails or is cancelled.
True when save() is successful, there are no modifications,
or user selects No or NoToAll.
This function controls the message box prompt for saving
changed files. The actual save is performed in save() for
each index processed. This function also removes autosave files
corresponding to files the user chooses not to save.
"""
if index is None:
indexes = list(range(self.get_stack_count()))
else:
indexes = [index]
buttons = QMessageBox.Yes | QMessageBox.No
if cancelable:
buttons |= QMessageBox.Cancel
unsaved_nb = 0
for index in indexes:
if self.data[index].editor.document().isModified():
unsaved_nb += 1
if not unsaved_nb:
# No file to save
return True
if unsaved_nb > 1:
buttons |= QMessageBox.YesToAll | QMessageBox.NoToAll
yes_all = no_all = False
for index in indexes:
self.set_stack_index(index)
finfo = self.data[index]
if finfo.filename == self.tempfile_path or yes_all:
if not self.save(index):
return False
elif no_all:
self.autosave.remove_autosave_file(finfo)
elif (finfo.editor.document().isModified() and
self.save_dialog_on_tests):
self.msgbox = QMessageBox(
QMessageBox.Question,
self.title,
_("<b>%s</b> has been modified."
"<br>Do you want to save changes?"
) % osp.basename(finfo.filename),
buttons,
parent=self)
answer = self.msgbox.exec_()
if answer == QMessageBox.Yes:
if not self.save(index):
return False
elif answer == QMessageBox.No:
self.autosave.remove_autosave_file(finfo)
elif answer == QMessageBox.YesToAll:
if not self.save(index):
return False
yes_all = True
elif answer == QMessageBox.NoToAll:
self.autosave.remove_autosave_file(finfo)
no_all = True
elif answer == QMessageBox.Cancel:
return False
return True | [
"def",
"save_if_changed",
"(",
"self",
",",
"cancelable",
"=",
"False",
",",
"index",
"=",
"None",
")",
":",
"if",
"index",
"is",
"None",
":",
"indexes",
"=",
"list",
"(",
"range",
"(",
"self",
".",
"get_stack_count",
"(",
")",
")",
")",
"else",
":",
"indexes",
"=",
"[",
"index",
"]",
"buttons",
"=",
"QMessageBox",
".",
"Yes",
"|",
"QMessageBox",
".",
"No",
"if",
"cancelable",
":",
"buttons",
"|=",
"QMessageBox",
".",
"Cancel",
"unsaved_nb",
"=",
"0",
"for",
"index",
"in",
"indexes",
":",
"if",
"self",
".",
"data",
"[",
"index",
"]",
".",
"editor",
".",
"document",
"(",
")",
".",
"isModified",
"(",
")",
":",
"unsaved_nb",
"+=",
"1",
"if",
"not",
"unsaved_nb",
":",
"# No file to save\r",
"return",
"True",
"if",
"unsaved_nb",
">",
"1",
":",
"buttons",
"|=",
"QMessageBox",
".",
"YesToAll",
"|",
"QMessageBox",
".",
"NoToAll",
"yes_all",
"=",
"no_all",
"=",
"False",
"for",
"index",
"in",
"indexes",
":",
"self",
".",
"set_stack_index",
"(",
"index",
")",
"finfo",
"=",
"self",
".",
"data",
"[",
"index",
"]",
"if",
"finfo",
".",
"filename",
"==",
"self",
".",
"tempfile_path",
"or",
"yes_all",
":",
"if",
"not",
"self",
".",
"save",
"(",
"index",
")",
":",
"return",
"False",
"elif",
"no_all",
":",
"self",
".",
"autosave",
".",
"remove_autosave_file",
"(",
"finfo",
")",
"elif",
"(",
"finfo",
".",
"editor",
".",
"document",
"(",
")",
".",
"isModified",
"(",
")",
"and",
"self",
".",
"save_dialog_on_tests",
")",
":",
"self",
".",
"msgbox",
"=",
"QMessageBox",
"(",
"QMessageBox",
".",
"Question",
",",
"self",
".",
"title",
",",
"_",
"(",
"\"<b>%s</b> has been modified.\"",
"\"<br>Do you want to save changes?\"",
")",
"%",
"osp",
".",
"basename",
"(",
"finfo",
".",
"filename",
")",
",",
"buttons",
",",
"parent",
"=",
"self",
")",
"answer",
"=",
"self",
".",
"msgbox",
".",
"exec_",
"(",
")",
"if",
"answer",
"==",
"QMessageBox",
".",
"Yes",
":",
"if",
"not",
"self",
".",
"save",
"(",
"index",
")",
":",
"return",
"False",
"elif",
"answer",
"==",
"QMessageBox",
".",
"No",
":",
"self",
".",
"autosave",
".",
"remove_autosave_file",
"(",
"finfo",
")",
"elif",
"answer",
"==",
"QMessageBox",
".",
"YesToAll",
":",
"if",
"not",
"self",
".",
"save",
"(",
"index",
")",
":",
"return",
"False",
"yes_all",
"=",
"True",
"elif",
"answer",
"==",
"QMessageBox",
".",
"NoToAll",
":",
"self",
".",
"autosave",
".",
"remove_autosave_file",
"(",
"finfo",
")",
"no_all",
"=",
"True",
"elif",
"answer",
"==",
"QMessageBox",
".",
"Cancel",
":",
"return",
"False",
"return",
"True"
] | Ask user to save file if modified.
Args:
cancelable: Show Cancel button.
index: File to check for modification.
Returns:
False when save() fails or is cancelled.
True when save() is successful, there are no modifications,
or user selects No or NoToAll.
This function controls the message box prompt for saving
changed files. The actual save is performed in save() for
each index processed. This function also removes autosave files
corresponding to files the user chooses not to save. | [
"Ask",
"user",
"to",
"save",
"file",
"if",
"modified",
".",
"Args",
":",
"cancelable",
":",
"Show",
"Cancel",
"button",
".",
"index",
":",
"File",
"to",
"check",
"for",
"modification",
".",
"Returns",
":",
"False",
"when",
"save",
"()",
"fails",
"or",
"is",
"cancelled",
".",
"True",
"when",
"save",
"()",
"is",
"successful",
"there",
"are",
"no",
"modifications",
"or",
"user",
"selects",
"No",
"or",
"NoToAll",
".",
"This",
"function",
"controls",
"the",
"message",
"box",
"prompt",
"for",
"saving",
"changed",
"files",
".",
"The",
"actual",
"save",
"is",
"performed",
"in",
"save",
"()",
"for",
"each",
"index",
"processed",
".",
"This",
"function",
"also",
"removes",
"autosave",
"files",
"corresponding",
"to",
"files",
"the",
"user",
"chooses",
"not",
"to",
"save",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1568-L1637 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack._write_to_file | def _write_to_file(self, fileinfo, filename):
"""Low-level function for writing text of editor to file.
Args:
fileinfo: FileInfo object associated to editor to be saved
filename: str with filename to save to
This is a low-level function that only saves the text to file in the
correct encoding without doing any error handling.
"""
txt = to_text_string(fileinfo.editor.get_text_with_eol())
fileinfo.encoding = encoding.write(txt, filename, fileinfo.encoding) | python | def _write_to_file(self, fileinfo, filename):
"""Low-level function for writing text of editor to file.
Args:
fileinfo: FileInfo object associated to editor to be saved
filename: str with filename to save to
This is a low-level function that only saves the text to file in the
correct encoding without doing any error handling.
"""
txt = to_text_string(fileinfo.editor.get_text_with_eol())
fileinfo.encoding = encoding.write(txt, filename, fileinfo.encoding) | [
"def",
"_write_to_file",
"(",
"self",
",",
"fileinfo",
",",
"filename",
")",
":",
"txt",
"=",
"to_text_string",
"(",
"fileinfo",
".",
"editor",
".",
"get_text_with_eol",
"(",
")",
")",
"fileinfo",
".",
"encoding",
"=",
"encoding",
".",
"write",
"(",
"txt",
",",
"filename",
",",
"fileinfo",
".",
"encoding",
")"
] | Low-level function for writing text of editor to file.
Args:
fileinfo: FileInfo object associated to editor to be saved
filename: str with filename to save to
This is a low-level function that only saves the text to file in the
correct encoding without doing any error handling. | [
"Low",
"-",
"level",
"function",
"for",
"writing",
"text",
"of",
"editor",
"to",
"file",
".",
"Args",
":",
"fileinfo",
":",
"FileInfo",
"object",
"associated",
"to",
"editor",
"to",
"be",
"saved",
"filename",
":",
"str",
"with",
"filename",
"to",
"save",
"to",
"This",
"is",
"a",
"low",
"-",
"level",
"function",
"that",
"only",
"saves",
"the",
"text",
"to",
"file",
"in",
"the",
"correct",
"encoding",
"without",
"doing",
"any",
"error",
"handling",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1639-L1650 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.save | def save(self, index=None, force=False):
"""Write text of editor to a file.
Args:
index: self.data index to save. If None, defaults to
currentIndex().
force: Force save regardless of file state.
Returns:
True upon successful save or when file doesn't need to be saved.
False if save failed.
If the text isn't modified and it's not newly created, then the save
is aborted. If the file hasn't been saved before, then save_as()
is invoked. Otherwise, the file is written using the file name
currently in self.data. This function doesn't change the file name.
"""
if index is None:
# Save the currently edited file
if not self.get_stack_count():
return
index = self.get_stack_index()
finfo = self.data[index]
if not (finfo.editor.document().isModified() or
finfo.newly_created) and not force:
return True
if not osp.isfile(finfo.filename) and not force:
# File has not been saved yet
return self.save_as(index=index)
if self.always_remove_trailing_spaces:
self.remove_trailing_spaces(index)
if self.convert_eol_on_save:
# hack to account for the fact that the config file saves
# CR/LF/CRLF while set_os_eol_chars wants the os.name value.
osname_lookup = {'LF': 'posix', 'CRLF': 'nt', 'CR': 'mac'}
osname = osname_lookup[self.convert_eol_on_save_to]
self.set_os_eol_chars(osname=osname)
try:
self._write_to_file(finfo, finfo.filename)
self.autosave.remove_autosave_file(finfo)
finfo.newly_created = False
self.encoding_changed.emit(finfo.encoding)
finfo.lastmodified = QFileInfo(finfo.filename).lastModified()
# We pass self object ID as a QString, because otherwise it would
# depend on the platform: long for 64bit, int for 32bit. Replacing
# by long all the time is not working on some 32bit platforms
# (see Issue 1094, Issue 1098)
# The filename is passed instead of an index in case the tabs
# have been rearranged (see issue 5703).
self.file_saved.emit(str(id(self)),
finfo.filename, finfo.filename)
finfo.editor.document().setModified(False)
finfo.editor.document().changed_since_autosave = False
self.modification_changed(index=index)
self.analyze_script(index)
#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)
finfo.editor.notify_save()
return True
except EnvironmentError as error:
self.msgbox = QMessageBox(
QMessageBox.Critical,
_("Save Error"),
_("<b>Unable to save file '%s'</b>"
"<br><br>Error message:<br>%s"
) % (osp.basename(finfo.filename),
str(error)),
parent=self)
self.msgbox.exec_()
return False | python | def save(self, index=None, force=False):
"""Write text of editor to a file.
Args:
index: self.data index to save. If None, defaults to
currentIndex().
force: Force save regardless of file state.
Returns:
True upon successful save or when file doesn't need to be saved.
False if save failed.
If the text isn't modified and it's not newly created, then the save
is aborted. If the file hasn't been saved before, then save_as()
is invoked. Otherwise, the file is written using the file name
currently in self.data. This function doesn't change the file name.
"""
if index is None:
# Save the currently edited file
if not self.get_stack_count():
return
index = self.get_stack_index()
finfo = self.data[index]
if not (finfo.editor.document().isModified() or
finfo.newly_created) and not force:
return True
if not osp.isfile(finfo.filename) and not force:
# File has not been saved yet
return self.save_as(index=index)
if self.always_remove_trailing_spaces:
self.remove_trailing_spaces(index)
if self.convert_eol_on_save:
# hack to account for the fact that the config file saves
# CR/LF/CRLF while set_os_eol_chars wants the os.name value.
osname_lookup = {'LF': 'posix', 'CRLF': 'nt', 'CR': 'mac'}
osname = osname_lookup[self.convert_eol_on_save_to]
self.set_os_eol_chars(osname=osname)
try:
self._write_to_file(finfo, finfo.filename)
self.autosave.remove_autosave_file(finfo)
finfo.newly_created = False
self.encoding_changed.emit(finfo.encoding)
finfo.lastmodified = QFileInfo(finfo.filename).lastModified()
# We pass self object ID as a QString, because otherwise it would
# depend on the platform: long for 64bit, int for 32bit. Replacing
# by long all the time is not working on some 32bit platforms
# (see Issue 1094, Issue 1098)
# The filename is passed instead of an index in case the tabs
# have been rearranged (see issue 5703).
self.file_saved.emit(str(id(self)),
finfo.filename, finfo.filename)
finfo.editor.document().setModified(False)
finfo.editor.document().changed_since_autosave = False
self.modification_changed(index=index)
self.analyze_script(index)
#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)
finfo.editor.notify_save()
return True
except EnvironmentError as error:
self.msgbox = QMessageBox(
QMessageBox.Critical,
_("Save Error"),
_("<b>Unable to save file '%s'</b>"
"<br><br>Error message:<br>%s"
) % (osp.basename(finfo.filename),
str(error)),
parent=self)
self.msgbox.exec_()
return False | [
"def",
"save",
"(",
"self",
",",
"index",
"=",
"None",
",",
"force",
"=",
"False",
")",
":",
"if",
"index",
"is",
"None",
":",
"# Save the currently edited file\r",
"if",
"not",
"self",
".",
"get_stack_count",
"(",
")",
":",
"return",
"index",
"=",
"self",
".",
"get_stack_index",
"(",
")",
"finfo",
"=",
"self",
".",
"data",
"[",
"index",
"]",
"if",
"not",
"(",
"finfo",
".",
"editor",
".",
"document",
"(",
")",
".",
"isModified",
"(",
")",
"or",
"finfo",
".",
"newly_created",
")",
"and",
"not",
"force",
":",
"return",
"True",
"if",
"not",
"osp",
".",
"isfile",
"(",
"finfo",
".",
"filename",
")",
"and",
"not",
"force",
":",
"# File has not been saved yet\r",
"return",
"self",
".",
"save_as",
"(",
"index",
"=",
"index",
")",
"if",
"self",
".",
"always_remove_trailing_spaces",
":",
"self",
".",
"remove_trailing_spaces",
"(",
"index",
")",
"if",
"self",
".",
"convert_eol_on_save",
":",
"# hack to account for the fact that the config file saves\r",
"# CR/LF/CRLF while set_os_eol_chars wants the os.name value.\r",
"osname_lookup",
"=",
"{",
"'LF'",
":",
"'posix'",
",",
"'CRLF'",
":",
"'nt'",
",",
"'CR'",
":",
"'mac'",
"}",
"osname",
"=",
"osname_lookup",
"[",
"self",
".",
"convert_eol_on_save_to",
"]",
"self",
".",
"set_os_eol_chars",
"(",
"osname",
"=",
"osname",
")",
"try",
":",
"self",
".",
"_write_to_file",
"(",
"finfo",
",",
"finfo",
".",
"filename",
")",
"self",
".",
"autosave",
".",
"remove_autosave_file",
"(",
"finfo",
")",
"finfo",
".",
"newly_created",
"=",
"False",
"self",
".",
"encoding_changed",
".",
"emit",
"(",
"finfo",
".",
"encoding",
")",
"finfo",
".",
"lastmodified",
"=",
"QFileInfo",
"(",
"finfo",
".",
"filename",
")",
".",
"lastModified",
"(",
")",
"# We pass self object ID as a QString, because otherwise it would\r",
"# depend on the platform: long for 64bit, int for 32bit. Replacing\r",
"# by long all the time is not working on some 32bit platforms\r",
"# (see Issue 1094, Issue 1098)\r",
"# The filename is passed instead of an index in case the tabs\r",
"# have been rearranged (see issue 5703).\r",
"self",
".",
"file_saved",
".",
"emit",
"(",
"str",
"(",
"id",
"(",
"self",
")",
")",
",",
"finfo",
".",
"filename",
",",
"finfo",
".",
"filename",
")",
"finfo",
".",
"editor",
".",
"document",
"(",
")",
".",
"setModified",
"(",
"False",
")",
"finfo",
".",
"editor",
".",
"document",
"(",
")",
".",
"changed_since_autosave",
"=",
"False",
"self",
".",
"modification_changed",
"(",
"index",
"=",
"index",
")",
"self",
".",
"analyze_script",
"(",
"index",
")",
"#XXX CodeEditor-only: re-scan the whole text to rebuild outline\r",
"# explorer data from scratch (could be optimized because\r",
"# rehighlighting text means searching for all syntax coloring\r",
"# patterns instead of only searching for class/def patterns which\r",
"# would be sufficient for outline explorer data.\r",
"finfo",
".",
"editor",
".",
"rehighlight",
"(",
")",
"self",
".",
"_refresh_outlineexplorer",
"(",
"index",
")",
"finfo",
".",
"editor",
".",
"notify_save",
"(",
")",
"return",
"True",
"except",
"EnvironmentError",
"as",
"error",
":",
"self",
".",
"msgbox",
"=",
"QMessageBox",
"(",
"QMessageBox",
".",
"Critical",
",",
"_",
"(",
"\"Save Error\"",
")",
",",
"_",
"(",
"\"<b>Unable to save file '%s'</b>\"",
"\"<br><br>Error message:<br>%s\"",
")",
"%",
"(",
"osp",
".",
"basename",
"(",
"finfo",
".",
"filename",
")",
",",
"str",
"(",
"error",
")",
")",
",",
"parent",
"=",
"self",
")",
"self",
".",
"msgbox",
".",
"exec_",
"(",
")",
"return",
"False"
] | Write text of editor to a file.
Args:
index: self.data index to save. If None, defaults to
currentIndex().
force: Force save regardless of file state.
Returns:
True upon successful save or when file doesn't need to be saved.
False if save failed.
If the text isn't modified and it's not newly created, then the save
is aborted. If the file hasn't been saved before, then save_as()
is invoked. Otherwise, the file is written using the file name
currently in self.data. This function doesn't change the file name. | [
"Write",
"text",
"of",
"editor",
"to",
"a",
"file",
".",
"Args",
":",
"index",
":",
"self",
".",
"data",
"index",
"to",
"save",
".",
"If",
"None",
"defaults",
"to",
"currentIndex",
"()",
".",
"force",
":",
"Force",
"save",
"regardless",
"of",
"file",
"state",
".",
"Returns",
":",
"True",
"upon",
"successful",
"save",
"or",
"when",
"file",
"doesn",
"t",
"need",
"to",
"be",
"saved",
".",
"False",
"if",
"save",
"failed",
".",
"If",
"the",
"text",
"isn",
"t",
"modified",
"and",
"it",
"s",
"not",
"newly",
"created",
"then",
"the",
"save",
"is",
"aborted",
".",
"If",
"the",
"file",
"hasn",
"t",
"been",
"saved",
"before",
"then",
"save_as",
"()",
"is",
"invoked",
".",
"Otherwise",
"the",
"file",
"is",
"written",
"using",
"the",
"file",
"name",
"currently",
"in",
"self",
".",
"data",
".",
"This",
"function",
"doesn",
"t",
"change",
"the",
"file",
"name",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1652-L1732 | train |
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",
"[",
"index",
"]",
"finfo",
".",
"newly_created",
"=",
"False",
"finfo",
".",
"filename",
"=",
"to_text_string",
"(",
"filename",
")",
"finfo",
".",
"lastmodified",
"=",
"QFileInfo",
"(",
"finfo",
".",
"filename",
")",
".",
"lastModified",
"(",
")"
] | 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",
"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",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1734-L1750 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.select_savename | def select_savename(self, original_filename):
"""Select a name to save a file.
Args:
original_filename: Used in the dialog to display the current file
path and name.
Returns:
Normalized path for the selected file name or None if no name was
selected.
"""
if self.edit_filetypes is None:
self.edit_filetypes = get_edit_filetypes()
if self.edit_filters is None:
self.edit_filters = get_edit_filters()
# Don't use filters on KDE to not make the dialog incredible
# slow
# Fixes issue 4156
if is_kde_desktop() and not is_anaconda():
filters = ''
selectedfilter = ''
else:
filters = self.edit_filters
selectedfilter = get_filter(self.edit_filetypes,
osp.splitext(original_filename)[1])
self.redirect_stdio.emit(False)
filename, _selfilter = getsavefilename(self, _("Save file"),
original_filename,
filters=filters,
selectedfilter=selectedfilter,
options=QFileDialog.HideNameFilterDetails)
self.redirect_stdio.emit(True)
if filename:
return osp.normpath(filename)
return None | python | def select_savename(self, original_filename):
"""Select a name to save a file.
Args:
original_filename: Used in the dialog to display the current file
path and name.
Returns:
Normalized path for the selected file name or None if no name was
selected.
"""
if self.edit_filetypes is None:
self.edit_filetypes = get_edit_filetypes()
if self.edit_filters is None:
self.edit_filters = get_edit_filters()
# Don't use filters on KDE to not make the dialog incredible
# slow
# Fixes issue 4156
if is_kde_desktop() and not is_anaconda():
filters = ''
selectedfilter = ''
else:
filters = self.edit_filters
selectedfilter = get_filter(self.edit_filetypes,
osp.splitext(original_filename)[1])
self.redirect_stdio.emit(False)
filename, _selfilter = getsavefilename(self, _("Save file"),
original_filename,
filters=filters,
selectedfilter=selectedfilter,
options=QFileDialog.HideNameFilterDetails)
self.redirect_stdio.emit(True)
if filename:
return osp.normpath(filename)
return None | [
"def",
"select_savename",
"(",
"self",
",",
"original_filename",
")",
":",
"if",
"self",
".",
"edit_filetypes",
"is",
"None",
":",
"self",
".",
"edit_filetypes",
"=",
"get_edit_filetypes",
"(",
")",
"if",
"self",
".",
"edit_filters",
"is",
"None",
":",
"self",
".",
"edit_filters",
"=",
"get_edit_filters",
"(",
")",
"# Don't use filters on KDE to not make the dialog incredible\r",
"# slow\r",
"# Fixes issue 4156\r",
"if",
"is_kde_desktop",
"(",
")",
"and",
"not",
"is_anaconda",
"(",
")",
":",
"filters",
"=",
"''",
"selectedfilter",
"=",
"''",
"else",
":",
"filters",
"=",
"self",
".",
"edit_filters",
"selectedfilter",
"=",
"get_filter",
"(",
"self",
".",
"edit_filetypes",
",",
"osp",
".",
"splitext",
"(",
"original_filename",
")",
"[",
"1",
"]",
")",
"self",
".",
"redirect_stdio",
".",
"emit",
"(",
"False",
")",
"filename",
",",
"_selfilter",
"=",
"getsavefilename",
"(",
"self",
",",
"_",
"(",
"\"Save file\"",
")",
",",
"original_filename",
",",
"filters",
"=",
"filters",
",",
"selectedfilter",
"=",
"selectedfilter",
",",
"options",
"=",
"QFileDialog",
".",
"HideNameFilterDetails",
")",
"self",
".",
"redirect_stdio",
".",
"emit",
"(",
"True",
")",
"if",
"filename",
":",
"return",
"osp",
".",
"normpath",
"(",
"filename",
")",
"return",
"None"
] | Select a name to save a file.
Args:
original_filename: Used in the dialog to display the current file
path and name.
Returns:
Normalized path for the selected file name or None if no name was
selected. | [
"Select",
"a",
"name",
"to",
"save",
"a",
"file",
".",
"Args",
":",
"original_filename",
":",
"Used",
"in",
"the",
"dialog",
"to",
"display",
"the",
"current",
"file",
"path",
"and",
"name",
".",
"Returns",
":",
"Normalized",
"path",
"for",
"the",
"selected",
"file",
"name",
"or",
"None",
"if",
"no",
"name",
"was",
"selected",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1752-L1788 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.save_as | def save_as(self, index=None):
"""Save file as...
Args:
index: self.data index for the file to save.
Returns:
False if no file name was selected or if save() was unsuccessful.
True is save() was successful.
Gets the new file name from select_savename(). If no name is chosen,
then the save_as() aborts. Otherwise, the current stack is checked
to see if the selected name already exists and, if so, then the tab
with that name is closed.
The current stack (self.data) and current tabs are updated with the
new name and other file info. The text is written with the new
name using save() and the name change is propagated to the other stacks
via the file_renamed_in_data signal.
"""
if index is None:
# Save the currently edited file
index = self.get_stack_index()
finfo = self.data[index]
# The next line is necessary to avoid checking if the file exists
# While running __check_file_status
# See issues 3678 and 3026
finfo.newly_created = True
original_filename = finfo.filename
filename = self.select_savename(original_filename)
if filename:
ao_index = self.has_filename(filename)
# Note: ao_index == index --> saving an untitled file
if ao_index is not None and ao_index != index:
if not self.close_file(ao_index):
return
if ao_index < index:
index -= 1
new_index = self.rename_in_data(original_filename,
new_filename=filename)
# We pass self object ID as a QString, because otherwise it would
# depend on the platform: long for 64bit, int for 32bit. Replacing
# by long all the time is not working on some 32bit platforms
# (see Issue 1094, Issue 1098)
self.file_renamed_in_data.emit(str(id(self)),
original_filename, filename)
ok = self.save(index=new_index, force=True)
self.refresh(new_index)
self.set_stack_index(new_index)
return ok
else:
return False | python | def save_as(self, index=None):
"""Save file as...
Args:
index: self.data index for the file to save.
Returns:
False if no file name was selected or if save() was unsuccessful.
True is save() was successful.
Gets the new file name from select_savename(). If no name is chosen,
then the save_as() aborts. Otherwise, the current stack is checked
to see if the selected name already exists and, if so, then the tab
with that name is closed.
The current stack (self.data) and current tabs are updated with the
new name and other file info. The text is written with the new
name using save() and the name change is propagated to the other stacks
via the file_renamed_in_data signal.
"""
if index is None:
# Save the currently edited file
index = self.get_stack_index()
finfo = self.data[index]
# The next line is necessary to avoid checking if the file exists
# While running __check_file_status
# See issues 3678 and 3026
finfo.newly_created = True
original_filename = finfo.filename
filename = self.select_savename(original_filename)
if filename:
ao_index = self.has_filename(filename)
# Note: ao_index == index --> saving an untitled file
if ao_index is not None and ao_index != index:
if not self.close_file(ao_index):
return
if ao_index < index:
index -= 1
new_index = self.rename_in_data(original_filename,
new_filename=filename)
# We pass self object ID as a QString, because otherwise it would
# depend on the platform: long for 64bit, int for 32bit. Replacing
# by long all the time is not working on some 32bit platforms
# (see Issue 1094, Issue 1098)
self.file_renamed_in_data.emit(str(id(self)),
original_filename, filename)
ok = self.save(index=new_index, force=True)
self.refresh(new_index)
self.set_stack_index(new_index)
return ok
else:
return False | [
"def",
"save_as",
"(",
"self",
",",
"index",
"=",
"None",
")",
":",
"if",
"index",
"is",
"None",
":",
"# Save the currently edited file\r",
"index",
"=",
"self",
".",
"get_stack_index",
"(",
")",
"finfo",
"=",
"self",
".",
"data",
"[",
"index",
"]",
"# The next line is necessary to avoid checking if the file exists\r",
"# While running __check_file_status\r",
"# See issues 3678 and 3026\r",
"finfo",
".",
"newly_created",
"=",
"True",
"original_filename",
"=",
"finfo",
".",
"filename",
"filename",
"=",
"self",
".",
"select_savename",
"(",
"original_filename",
")",
"if",
"filename",
":",
"ao_index",
"=",
"self",
".",
"has_filename",
"(",
"filename",
")",
"# Note: ao_index == index --> saving an untitled file\r",
"if",
"ao_index",
"is",
"not",
"None",
"and",
"ao_index",
"!=",
"index",
":",
"if",
"not",
"self",
".",
"close_file",
"(",
"ao_index",
")",
":",
"return",
"if",
"ao_index",
"<",
"index",
":",
"index",
"-=",
"1",
"new_index",
"=",
"self",
".",
"rename_in_data",
"(",
"original_filename",
",",
"new_filename",
"=",
"filename",
")",
"# We pass self object ID as a QString, because otherwise it would\r",
"# depend on the platform: long for 64bit, int for 32bit. Replacing\r",
"# by long all the time is not working on some 32bit platforms\r",
"# (see Issue 1094, Issue 1098)\r",
"self",
".",
"file_renamed_in_data",
".",
"emit",
"(",
"str",
"(",
"id",
"(",
"self",
")",
")",
",",
"original_filename",
",",
"filename",
")",
"ok",
"=",
"self",
".",
"save",
"(",
"index",
"=",
"new_index",
",",
"force",
"=",
"True",
")",
"self",
".",
"refresh",
"(",
"new_index",
")",
"self",
".",
"set_stack_index",
"(",
"new_index",
")",
"return",
"ok",
"else",
":",
"return",
"False"
] | Save file as...
Args:
index: self.data index for the file to save.
Returns:
False if no file name was selected or if save() was unsuccessful.
True is save() was successful.
Gets the new file name from select_savename(). If no name is chosen,
then the save_as() aborts. Otherwise, the current stack is checked
to see if the selected name already exists and, if so, then the tab
with that name is closed.
The current stack (self.data) and current tabs are updated with the
new name and other file info. The text is written with the new
name using save() and the name change is propagated to the other stacks
via the file_renamed_in_data signal. | [
"Save",
"file",
"as",
"...",
"Args",
":",
"index",
":",
"self",
".",
"data",
"index",
"for",
"the",
"file",
"to",
"save",
".",
"Returns",
":",
"False",
"if",
"no",
"file",
"name",
"was",
"selected",
"or",
"if",
"save",
"()",
"was",
"unsuccessful",
".",
"True",
"is",
"save",
"()",
"was",
"successful",
".",
"Gets",
"the",
"new",
"file",
"name",
"from",
"select_savename",
"()",
".",
"If",
"no",
"name",
"is",
"chosen",
"then",
"the",
"save_as",
"()",
"aborts",
".",
"Otherwise",
"the",
"current",
"stack",
"is",
"checked",
"to",
"see",
"if",
"the",
"selected",
"name",
"already",
"exists",
"and",
"if",
"so",
"then",
"the",
"tab",
"with",
"that",
"name",
"is",
"closed",
".",
"The",
"current",
"stack",
"(",
"self",
".",
"data",
")",
"and",
"current",
"tabs",
"are",
"updated",
"with",
"the",
"new",
"name",
"and",
"other",
"file",
"info",
".",
"The",
"text",
"is",
"written",
"with",
"the",
"new",
"name",
"using",
"save",
"()",
"and",
"the",
"name",
"change",
"is",
"propagated",
"to",
"the",
"other",
"stacks",
"via",
"the",
"file_renamed_in_data",
"signal",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1790-L1844 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.save_copy_as | def save_copy_as(self, index=None):
"""Save copy of file as...
Args:
index: self.data index for the file to save.
Returns:
False if no file name was selected or if save() was unsuccessful.
True is save() was successful.
Gets the new file name from select_savename(). If no name is chosen,
then the save_copy_as() aborts. Otherwise, the current stack is
checked to see if the selected name already exists and, if so, then the
tab with that name is closed.
Unlike save_as(), this calls write() directly instead of using save().
The current file and tab aren't changed at all. The copied file is
opened in a new tab.
"""
if index is None:
# Save the currently edited file
index = self.get_stack_index()
finfo = self.data[index]
original_filename = finfo.filename
filename = self.select_savename(original_filename)
if filename:
ao_index = self.has_filename(filename)
# Note: ao_index == index --> saving an untitled file
if ao_index is not None and ao_index != index:
if not self.close_file(ao_index):
return
if ao_index < index:
index -= 1
try:
self._write_to_file(finfo, filename)
# open created copy file
self.plugin_load.emit(filename)
return True
except EnvironmentError as error:
self.msgbox = QMessageBox(
QMessageBox.Critical,
_("Save Error"),
_("<b>Unable to save file '%s'</b>"
"<br><br>Error message:<br>%s"
) % (osp.basename(finfo.filename),
str(error)),
parent=self)
self.msgbox.exec_()
else:
return False | python | def save_copy_as(self, index=None):
"""Save copy of file as...
Args:
index: self.data index for the file to save.
Returns:
False if no file name was selected or if save() was unsuccessful.
True is save() was successful.
Gets the new file name from select_savename(). If no name is chosen,
then the save_copy_as() aborts. Otherwise, the current stack is
checked to see if the selected name already exists and, if so, then the
tab with that name is closed.
Unlike save_as(), this calls write() directly instead of using save().
The current file and tab aren't changed at all. The copied file is
opened in a new tab.
"""
if index is None:
# Save the currently edited file
index = self.get_stack_index()
finfo = self.data[index]
original_filename = finfo.filename
filename = self.select_savename(original_filename)
if filename:
ao_index = self.has_filename(filename)
# Note: ao_index == index --> saving an untitled file
if ao_index is not None and ao_index != index:
if not self.close_file(ao_index):
return
if ao_index < index:
index -= 1
try:
self._write_to_file(finfo, filename)
# open created copy file
self.plugin_load.emit(filename)
return True
except EnvironmentError as error:
self.msgbox = QMessageBox(
QMessageBox.Critical,
_("Save Error"),
_("<b>Unable to save file '%s'</b>"
"<br><br>Error message:<br>%s"
) % (osp.basename(finfo.filename),
str(error)),
parent=self)
self.msgbox.exec_()
else:
return False | [
"def",
"save_copy_as",
"(",
"self",
",",
"index",
"=",
"None",
")",
":",
"if",
"index",
"is",
"None",
":",
"# Save the currently edited file\r",
"index",
"=",
"self",
".",
"get_stack_index",
"(",
")",
"finfo",
"=",
"self",
".",
"data",
"[",
"index",
"]",
"original_filename",
"=",
"finfo",
".",
"filename",
"filename",
"=",
"self",
".",
"select_savename",
"(",
"original_filename",
")",
"if",
"filename",
":",
"ao_index",
"=",
"self",
".",
"has_filename",
"(",
"filename",
")",
"# Note: ao_index == index --> saving an untitled file\r",
"if",
"ao_index",
"is",
"not",
"None",
"and",
"ao_index",
"!=",
"index",
":",
"if",
"not",
"self",
".",
"close_file",
"(",
"ao_index",
")",
":",
"return",
"if",
"ao_index",
"<",
"index",
":",
"index",
"-=",
"1",
"try",
":",
"self",
".",
"_write_to_file",
"(",
"finfo",
",",
"filename",
")",
"# open created copy file\r",
"self",
".",
"plugin_load",
".",
"emit",
"(",
"filename",
")",
"return",
"True",
"except",
"EnvironmentError",
"as",
"error",
":",
"self",
".",
"msgbox",
"=",
"QMessageBox",
"(",
"QMessageBox",
".",
"Critical",
",",
"_",
"(",
"\"Save Error\"",
")",
",",
"_",
"(",
"\"<b>Unable to save file '%s'</b>\"",
"\"<br><br>Error message:<br>%s\"",
")",
"%",
"(",
"osp",
".",
"basename",
"(",
"finfo",
".",
"filename",
")",
",",
"str",
"(",
"error",
")",
")",
",",
"parent",
"=",
"self",
")",
"self",
".",
"msgbox",
".",
"exec_",
"(",
")",
"else",
":",
"return",
"False"
] | Save copy of file as...
Args:
index: self.data index for the file to save.
Returns:
False if no file name was selected or if save() was unsuccessful.
True is save() was successful.
Gets the new file name from select_savename(). If no name is chosen,
then the save_copy_as() aborts. Otherwise, the current stack is
checked to see if the selected name already exists and, if so, then the
tab with that name is closed.
Unlike save_as(), this calls write() directly instead of using save().
The current file and tab aren't changed at all. The copied file is
opened in a new tab. | [
"Save",
"copy",
"of",
"file",
"as",
"...",
"Args",
":",
"index",
":",
"self",
".",
"data",
"index",
"for",
"the",
"file",
"to",
"save",
".",
"Returns",
":",
"False",
"if",
"no",
"file",
"name",
"was",
"selected",
"or",
"if",
"save",
"()",
"was",
"unsuccessful",
".",
"True",
"is",
"save",
"()",
"was",
"successful",
".",
"Gets",
"the",
"new",
"file",
"name",
"from",
"select_savename",
"()",
".",
"If",
"no",
"name",
"is",
"chosen",
"then",
"the",
"save_copy_as",
"()",
"aborts",
".",
"Otherwise",
"the",
"current",
"stack",
"is",
"checked",
"to",
"see",
"if",
"the",
"selected",
"name",
"already",
"exists",
"and",
"if",
"so",
"then",
"the",
"tab",
"with",
"that",
"name",
"is",
"closed",
".",
"Unlike",
"save_as",
"()",
"this",
"calls",
"write",
"()",
"directly",
"instead",
"of",
"using",
"save",
"()",
".",
"The",
"current",
"file",
"and",
"tab",
"aren",
"t",
"changed",
"at",
"all",
".",
"The",
"copied",
"file",
"is",
"opened",
"in",
"a",
"new",
"tab",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1846-L1895 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.save_all | def save_all(self):
"""Save all opened files.
Iterate through self.data and call save() on any modified files.
"""
for index in range(self.get_stack_count()):
if self.data[index].editor.document().isModified():
self.save(index) | python | def save_all(self):
"""Save all opened files.
Iterate through self.data and call save() on any modified files.
"""
for index in range(self.get_stack_count()):
if self.data[index].editor.document().isModified():
self.save(index) | [
"def",
"save_all",
"(",
"self",
")",
":",
"for",
"index",
"in",
"range",
"(",
"self",
".",
"get_stack_count",
"(",
")",
")",
":",
"if",
"self",
".",
"data",
"[",
"index",
"]",
".",
"editor",
".",
"document",
"(",
")",
".",
"isModified",
"(",
")",
":",
"self",
".",
"save",
"(",
"index",
")"
] | Save all opened files.
Iterate through self.data and call save() on any modified files. | [
"Save",
"all",
"opened",
"files",
".",
"Iterate",
"through",
"self",
".",
"data",
"and",
"call",
"save",
"()",
"on",
"any",
"modified",
"files",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1897-L1904 | train |
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",
":",
"finfo",
"=",
"self",
".",
"data",
"[",
"index",
"]",
"if",
"self",
".",
"todolist_enabled",
":",
"finfo",
".",
"run_todo_finder",
"(",
")",
"self",
".",
"is_analysis_done",
"=",
"True"
] | 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 | train |
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_results",
"(",
"todo_results",
")"
] | 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 | train |
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",
"(",
")",
"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\r",
"# files outside Spyder while in debug mode.\r",
"# See issue 8749.\r",
"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\r",
"# that has been renamed. See issue 5157\r",
"try",
":",
"self",
".",
"current_file_changed",
".",
"emit",
"(",
"self",
".",
"data",
"[",
"index",
"]",
".",
"filename",
",",
"editor",
".",
"get_position",
"(",
"'cursor'",
")",
")",
"except",
"IndexError",
":",
"pass"
] | 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 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.tab_navigation_mru | def tab_navigation_mru(self, forward=True):
"""
Tab navigation with "most recently used" behaviour.
It's fired when pressing 'go to previous file' or 'go to next file'
shortcuts.
forward:
True: move to next file
False: move to previous file
"""
self.tabs_switcher = TabSwitcherWidget(self, self.stack_history,
self.tabs)
self.tabs_switcher.show()
self.tabs_switcher.select_row(1 if forward else -1)
self.tabs_switcher.setFocus() | python | def tab_navigation_mru(self, forward=True):
"""
Tab navigation with "most recently used" behaviour.
It's fired when pressing 'go to previous file' or 'go to next file'
shortcuts.
forward:
True: move to next file
False: move to previous file
"""
self.tabs_switcher = TabSwitcherWidget(self, self.stack_history,
self.tabs)
self.tabs_switcher.show()
self.tabs_switcher.select_row(1 if forward else -1)
self.tabs_switcher.setFocus() | [
"def",
"tab_navigation_mru",
"(",
"self",
",",
"forward",
"=",
"True",
")",
":",
"self",
".",
"tabs_switcher",
"=",
"TabSwitcherWidget",
"(",
"self",
",",
"self",
".",
"stack_history",
",",
"self",
".",
"tabs",
")",
"self",
".",
"tabs_switcher",
".",
"show",
"(",
")",
"self",
".",
"tabs_switcher",
".",
"select_row",
"(",
"1",
"if",
"forward",
"else",
"-",
"1",
")",
"self",
".",
"tabs_switcher",
".",
"setFocus",
"(",
")"
] | Tab navigation with "most recently used" behaviour.
It's fired when pressing 'go to previous file' or 'go to next file'
shortcuts.
forward:
True: move to next file
False: move to previous file | [
"Tab",
"navigation",
"with",
"most",
"recently",
"used",
"behaviour",
".",
"It",
"s",
"fired",
"when",
"pressing",
"go",
"to",
"previous",
"file",
"or",
"go",
"to",
"next",
"file",
"shortcuts",
".",
"forward",
":",
"True",
":",
"move",
"to",
"next",
"file",
"False",
":",
"move",
"to",
"previous",
"file"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1978-L1993 | train |
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_changed",
".",
"emit",
"(",
")"
] | 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 | train |
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",
":",
"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\r",
"# currently focused one in the editor stack. Therefore,\r",
"# we need to force a refresh of the outline explorer to set\r",
"# the current editor to the currently focused one in the\r",
"# editor stack. See PR #8015.\r",
"self",
".",
"_refresh_outlineexplorer",
"(",
"update",
"=",
"False",
")",
"return",
"self",
".",
"_sync_outlineexplorer_file_order",
"(",
")"
] | 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 | train |
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_id",
"(",
")",
"for",
"finfo",
"in",
"self",
".",
"data",
"]",
")"
] | 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 | train |
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",
",",
"index",
"=",
"finfo",
".",
"editor",
".",
"get_cursor_line_column",
"(",
")",
"self",
".",
"sig_editor_cursor_position_changed",
".",
"emit",
"(",
"line",
",",
"index",
")"
] | Refreshing statusbar widgets | [
"Refreshing",
"statusbar",
"widgets"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2037-L2043 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.__check_file_status | def __check_file_status(self, index):
"""Check if file has been changed in any way outside Spyder:
1. removed, moved or renamed outside Spyder
2. modified outside Spyder"""
if self.__file_status_flag:
# Avoid infinite loop: when the QMessageBox.question pops, it
# gets focus and then give it back to the CodeEditor instance,
# triggering a refresh cycle which calls this method
return
self.__file_status_flag = True
finfo = self.data[index]
name = osp.basename(finfo.filename)
if finfo.newly_created:
# File was just created (not yet saved): do nothing
# (do not return because of the clean-up at the end of the method)
pass
elif not osp.isfile(finfo.filename):
# File doesn't exist (removed, moved or offline):
self.msgbox = QMessageBox(
QMessageBox.Warning,
self.title,
_("<b>%s</b> is unavailable "
"(this file may have been removed, moved "
"or renamed outside Spyder)."
"<br>Do you want to close it?") % name,
QMessageBox.Yes | QMessageBox.No,
self)
answer = self.msgbox.exec_()
if answer == QMessageBox.Yes:
self.close_file(index)
else:
finfo.newly_created = True
finfo.editor.document().setModified(True)
self.modification_changed(index=index)
else:
# Else, testing if it has been modified elsewhere:
lastm = QFileInfo(finfo.filename).lastModified()
if to_text_string(lastm.toString()) \
!= to_text_string(finfo.lastmodified.toString()):
if finfo.editor.document().isModified():
self.msgbox = QMessageBox(
QMessageBox.Question,
self.title,
_("<b>%s</b> has been modified outside Spyder."
"<br>Do you want to reload it and lose all "
"your changes?") % name,
QMessageBox.Yes | QMessageBox.No,
self)
answer = self.msgbox.exec_()
if answer == QMessageBox.Yes:
self.reload(index)
else:
finfo.lastmodified = lastm
else:
self.reload(index)
# Finally, resetting temporary flag:
self.__file_status_flag = False | python | def __check_file_status(self, index):
"""Check if file has been changed in any way outside Spyder:
1. removed, moved or renamed outside Spyder
2. modified outside Spyder"""
if self.__file_status_flag:
# Avoid infinite loop: when the QMessageBox.question pops, it
# gets focus and then give it back to the CodeEditor instance,
# triggering a refresh cycle which calls this method
return
self.__file_status_flag = True
finfo = self.data[index]
name = osp.basename(finfo.filename)
if finfo.newly_created:
# File was just created (not yet saved): do nothing
# (do not return because of the clean-up at the end of the method)
pass
elif not osp.isfile(finfo.filename):
# File doesn't exist (removed, moved or offline):
self.msgbox = QMessageBox(
QMessageBox.Warning,
self.title,
_("<b>%s</b> is unavailable "
"(this file may have been removed, moved "
"or renamed outside Spyder)."
"<br>Do you want to close it?") % name,
QMessageBox.Yes | QMessageBox.No,
self)
answer = self.msgbox.exec_()
if answer == QMessageBox.Yes:
self.close_file(index)
else:
finfo.newly_created = True
finfo.editor.document().setModified(True)
self.modification_changed(index=index)
else:
# Else, testing if it has been modified elsewhere:
lastm = QFileInfo(finfo.filename).lastModified()
if to_text_string(lastm.toString()) \
!= to_text_string(finfo.lastmodified.toString()):
if finfo.editor.document().isModified():
self.msgbox = QMessageBox(
QMessageBox.Question,
self.title,
_("<b>%s</b> has been modified outside Spyder."
"<br>Do you want to reload it and lose all "
"your changes?") % name,
QMessageBox.Yes | QMessageBox.No,
self)
answer = self.msgbox.exec_()
if answer == QMessageBox.Yes:
self.reload(index)
else:
finfo.lastmodified = lastm
else:
self.reload(index)
# Finally, resetting temporary flag:
self.__file_status_flag = False | [
"def",
"__check_file_status",
"(",
"self",
",",
"index",
")",
":",
"if",
"self",
".",
"__file_status_flag",
":",
"# Avoid infinite loop: when the QMessageBox.question pops, it\r",
"# gets focus and then give it back to the CodeEditor instance,\r",
"# triggering a refresh cycle which calls this method\r",
"return",
"self",
".",
"__file_status_flag",
"=",
"True",
"finfo",
"=",
"self",
".",
"data",
"[",
"index",
"]",
"name",
"=",
"osp",
".",
"basename",
"(",
"finfo",
".",
"filename",
")",
"if",
"finfo",
".",
"newly_created",
":",
"# File was just created (not yet saved): do nothing\r",
"# (do not return because of the clean-up at the end of the method)\r",
"pass",
"elif",
"not",
"osp",
".",
"isfile",
"(",
"finfo",
".",
"filename",
")",
":",
"# File doesn't exist (removed, moved or offline):\r",
"self",
".",
"msgbox",
"=",
"QMessageBox",
"(",
"QMessageBox",
".",
"Warning",
",",
"self",
".",
"title",
",",
"_",
"(",
"\"<b>%s</b> is unavailable \"",
"\"(this file may have been removed, moved \"",
"\"or renamed outside Spyder).\"",
"\"<br>Do you want to close it?\"",
")",
"%",
"name",
",",
"QMessageBox",
".",
"Yes",
"|",
"QMessageBox",
".",
"No",
",",
"self",
")",
"answer",
"=",
"self",
".",
"msgbox",
".",
"exec_",
"(",
")",
"if",
"answer",
"==",
"QMessageBox",
".",
"Yes",
":",
"self",
".",
"close_file",
"(",
"index",
")",
"else",
":",
"finfo",
".",
"newly_created",
"=",
"True",
"finfo",
".",
"editor",
".",
"document",
"(",
")",
".",
"setModified",
"(",
"True",
")",
"self",
".",
"modification_changed",
"(",
"index",
"=",
"index",
")",
"else",
":",
"# Else, testing if it has been modified elsewhere:\r",
"lastm",
"=",
"QFileInfo",
"(",
"finfo",
".",
"filename",
")",
".",
"lastModified",
"(",
")",
"if",
"to_text_string",
"(",
"lastm",
".",
"toString",
"(",
")",
")",
"!=",
"to_text_string",
"(",
"finfo",
".",
"lastmodified",
".",
"toString",
"(",
")",
")",
":",
"if",
"finfo",
".",
"editor",
".",
"document",
"(",
")",
".",
"isModified",
"(",
")",
":",
"self",
".",
"msgbox",
"=",
"QMessageBox",
"(",
"QMessageBox",
".",
"Question",
",",
"self",
".",
"title",
",",
"_",
"(",
"\"<b>%s</b> has been modified outside Spyder.\"",
"\"<br>Do you want to reload it and lose all \"",
"\"your changes?\"",
")",
"%",
"name",
",",
"QMessageBox",
".",
"Yes",
"|",
"QMessageBox",
".",
"No",
",",
"self",
")",
"answer",
"=",
"self",
".",
"msgbox",
".",
"exec_",
"(",
")",
"if",
"answer",
"==",
"QMessageBox",
".",
"Yes",
":",
"self",
".",
"reload",
"(",
"index",
")",
"else",
":",
"finfo",
".",
"lastmodified",
"=",
"lastm",
"else",
":",
"self",
".",
"reload",
"(",
"index",
")",
"# Finally, resetting temporary flag:\r",
"self",
".",
"__file_status_flag",
"=",
"False"
] | Check if file has been changed in any way outside Spyder:
1. removed, moved or renamed outside Spyder
2. modified outside Spyder | [
"Check",
"if",
"file",
"has",
"been",
"changed",
"in",
"any",
"way",
"outside",
"Spyder",
":",
"1",
".",
"removed",
"moved",
"or",
"renamed",
"outside",
"Spyder",
"2",
".",
"modified",
"outside",
"Spyder"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2054-L2115 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.refresh | def refresh(self, index=None):
"""Refresh tabwidget"""
if index is None:
index = self.get_stack_index()
# Set current editor
if self.get_stack_count():
index = self.get_stack_index()
finfo = self.data[index]
editor = finfo.editor
editor.setFocus()
self._refresh_outlineexplorer(index, update=False)
self.__refresh_statusbar(index)
self.__refresh_readonly(index)
self.__check_file_status(index)
self.__modify_stack_title()
self.update_plugin_title.emit()
else:
editor = None
# Update the modification-state-dependent parameters
self.modification_changed()
# Update FindReplace binding
self.find_widget.set_editor(editor, refresh=False) | python | def refresh(self, index=None):
"""Refresh tabwidget"""
if index is None:
index = self.get_stack_index()
# Set current editor
if self.get_stack_count():
index = self.get_stack_index()
finfo = self.data[index]
editor = finfo.editor
editor.setFocus()
self._refresh_outlineexplorer(index, update=False)
self.__refresh_statusbar(index)
self.__refresh_readonly(index)
self.__check_file_status(index)
self.__modify_stack_title()
self.update_plugin_title.emit()
else:
editor = None
# Update the modification-state-dependent parameters
self.modification_changed()
# Update FindReplace binding
self.find_widget.set_editor(editor, refresh=False) | [
"def",
"refresh",
"(",
"self",
",",
"index",
"=",
"None",
")",
":",
"if",
"index",
"is",
"None",
":",
"index",
"=",
"self",
".",
"get_stack_index",
"(",
")",
"# Set current editor\r",
"if",
"self",
".",
"get_stack_count",
"(",
")",
":",
"index",
"=",
"self",
".",
"get_stack_index",
"(",
")",
"finfo",
"=",
"self",
".",
"data",
"[",
"index",
"]",
"editor",
"=",
"finfo",
".",
"editor",
"editor",
".",
"setFocus",
"(",
")",
"self",
".",
"_refresh_outlineexplorer",
"(",
"index",
",",
"update",
"=",
"False",
")",
"self",
".",
"__refresh_statusbar",
"(",
"index",
")",
"self",
".",
"__refresh_readonly",
"(",
"index",
")",
"self",
".",
"__check_file_status",
"(",
"index",
")",
"self",
".",
"__modify_stack_title",
"(",
")",
"self",
".",
"update_plugin_title",
".",
"emit",
"(",
")",
"else",
":",
"editor",
"=",
"None",
"# Update the modification-state-dependent parameters\r",
"self",
".",
"modification_changed",
"(",
")",
"# Update FindReplace binding\r",
"self",
".",
"find_widget",
".",
"set_editor",
"(",
"editor",
",",
"refresh",
"=",
"False",
")"
] | Refresh tabwidget | [
"Refresh",
"tabwidget"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2122-L2143 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.modification_changed | def modification_changed(self, state=None, index=None, editor_id=None):
"""
Current editor's modification state has changed
--> change tab title depending on new modification state
--> enable/disable save/save all actions
"""
if editor_id is not None:
for index, _finfo in enumerate(self.data):
if id(_finfo.editor) == editor_id:
break
# This must be done before refreshing save/save all actions:
# (otherwise Save/Save all actions will always be enabled)
self.opened_files_list_changed.emit()
# --
if index is None:
index = self.get_stack_index()
if index == -1:
return
finfo = self.data[index]
if state is None:
state = finfo.editor.document().isModified() or finfo.newly_created
self.set_stack_title(index, state)
# Toggle save/save all actions state
self.save_action.setEnabled(state)
self.refresh_save_all_action.emit()
# Refreshing eol mode
eol_chars = finfo.editor.get_line_separator()
self.refresh_eol_chars(eol_chars)
self.stack_history.refresh() | python | def modification_changed(self, state=None, index=None, editor_id=None):
"""
Current editor's modification state has changed
--> change tab title depending on new modification state
--> enable/disable save/save all actions
"""
if editor_id is not None:
for index, _finfo in enumerate(self.data):
if id(_finfo.editor) == editor_id:
break
# This must be done before refreshing save/save all actions:
# (otherwise Save/Save all actions will always be enabled)
self.opened_files_list_changed.emit()
# --
if index is None:
index = self.get_stack_index()
if index == -1:
return
finfo = self.data[index]
if state is None:
state = finfo.editor.document().isModified() or finfo.newly_created
self.set_stack_title(index, state)
# Toggle save/save all actions state
self.save_action.setEnabled(state)
self.refresh_save_all_action.emit()
# Refreshing eol mode
eol_chars = finfo.editor.get_line_separator()
self.refresh_eol_chars(eol_chars)
self.stack_history.refresh() | [
"def",
"modification_changed",
"(",
"self",
",",
"state",
"=",
"None",
",",
"index",
"=",
"None",
",",
"editor_id",
"=",
"None",
")",
":",
"if",
"editor_id",
"is",
"not",
"None",
":",
"for",
"index",
",",
"_finfo",
"in",
"enumerate",
"(",
"self",
".",
"data",
")",
":",
"if",
"id",
"(",
"_finfo",
".",
"editor",
")",
"==",
"editor_id",
":",
"break",
"# This must be done before refreshing save/save all actions:\r",
"# (otherwise Save/Save all actions will always be enabled)\r",
"self",
".",
"opened_files_list_changed",
".",
"emit",
"(",
")",
"# --\r",
"if",
"index",
"is",
"None",
":",
"index",
"=",
"self",
".",
"get_stack_index",
"(",
")",
"if",
"index",
"==",
"-",
"1",
":",
"return",
"finfo",
"=",
"self",
".",
"data",
"[",
"index",
"]",
"if",
"state",
"is",
"None",
":",
"state",
"=",
"finfo",
".",
"editor",
".",
"document",
"(",
")",
".",
"isModified",
"(",
")",
"or",
"finfo",
".",
"newly_created",
"self",
".",
"set_stack_title",
"(",
"index",
",",
"state",
")",
"# Toggle save/save all actions state\r",
"self",
".",
"save_action",
".",
"setEnabled",
"(",
"state",
")",
"self",
".",
"refresh_save_all_action",
".",
"emit",
"(",
")",
"# Refreshing eol mode\r",
"eol_chars",
"=",
"finfo",
".",
"editor",
".",
"get_line_separator",
"(",
")",
"self",
".",
"refresh_eol_chars",
"(",
"eol_chars",
")",
"self",
".",
"stack_history",
".",
"refresh",
"(",
")"
] | Current editor's modification state has changed
--> change tab title depending on new modification state
--> enable/disable save/save all actions | [
"Current",
"editor",
"s",
"modification",
"state",
"has",
"changed",
"--",
">",
"change",
"tab",
"title",
"depending",
"on",
"new",
"modification",
"state",
"--",
">",
"enable",
"/",
"disable",
"save",
"/",
"save",
"all",
"actions"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2145-L2173 | train |
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",
"=",
"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\r",
"# explorer data from scratch (could be optimized because\r",
"# rehighlighting text means searching for all syntax coloring\r",
"# patterns instead of only searching for class/def patterns which\r",
"# would be sufficient for outline explorer data.\r",
"finfo",
".",
"editor",
".",
"rehighlight",
"(",
")",
"self",
".",
"_refresh_outlineexplorer",
"(",
"index",
")"
] | 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 | train |
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",
"(",
")",
".",
"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",
")"
] | 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 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.create_new_editor | def create_new_editor(self, fname, enc, txt, set_current, new=False,
cloned_from=None, add_where='end'):
"""
Create a new editor instance
Returns finfo object (instead of editor as in previous releases)
"""
editor = codeeditor.CodeEditor(self)
editor.go_to_definition.connect(
lambda fname, line, column: self.sig_go_to_definition.emit(
fname, line, column))
finfo = FileInfo(fname, enc, editor, new, self.threadmanager)
self.add_to_data(finfo, set_current, add_where)
finfo.send_to_help.connect(self.send_to_help)
finfo.todo_results_changed.connect(
lambda: self.todo_results_changed.emit())
finfo.edit_goto.connect(lambda fname, lineno, name:
self.edit_goto.emit(fname, lineno, name))
finfo.sig_save_bookmarks.connect(lambda s1, s2:
self.sig_save_bookmarks.emit(s1, s2))
editor.sig_run_selection.connect(self.run_selection)
editor.sig_run_cell.connect(self.run_cell)
editor.sig_run_cell_and_advance.connect(self.run_cell_and_advance)
editor.sig_re_run_last_cell.connect(self.re_run_last_cell)
editor.sig_new_file.connect(self.sig_new_file.emit)
editor.sig_breakpoints_saved.connect(self.sig_breakpoints_saved)
language = get_file_language(fname, txt)
editor.setup_editor(
linenumbers=self.linenumbers_enabled,
show_blanks=self.blanks_enabled,
scroll_past_end=self.scrollpastend_enabled,
edge_line=self.edgeline_enabled,
edge_line_columns=self.edgeline_columns, language=language,
markers=self.has_markers(), font=self.default_font,
color_scheme=self.color_scheme,
wrap=self.wrap_enabled, tab_mode=self.tabmode_enabled,
intelligent_backspace=self.intelligent_backspace_enabled,
highlight_current_line=self.highlight_current_line_enabled,
highlight_current_cell=self.highlight_current_cell_enabled,
occurrence_highlighting=self.occurrence_highlighting_enabled,
occurrence_timeout=self.occurrence_highlighting_timeout,
close_parentheses=self.close_parentheses_enabled,
close_quotes=self.close_quotes_enabled,
add_colons=self.add_colons_enabled,
auto_unindent=self.auto_unindent_enabled,
indent_chars=self.indent_chars,
tab_stop_width_spaces=self.tab_stop_width_spaces,
cloned_from=cloned_from,
filename=fname,
show_class_func_dropdown=self.show_class_func_dropdown,
indent_guides=self.indent_guides)
if cloned_from is None:
editor.set_text(txt)
editor.document().setModified(False)
editor.document().changed_since_autosave = False
finfo.text_changed_at.connect(
lambda fname, position:
self.text_changed_at.emit(fname, position))
editor.sig_cursor_position_changed.connect(
self.editor_cursor_position_changed)
editor.textChanged.connect(self.start_stop_analysis_timer)
editor.sig_perform_lsp_request.connect(
lambda lang, method, params: self.perform_lsp_request.emit(
lang, method, params))
editor.modificationChanged.connect(
lambda state: self.modification_changed(state,
editor_id=id(editor)))
editor.focus_in.connect(self.focus_changed)
editor.zoom_in.connect(lambda: self.zoom_in.emit())
editor.zoom_out.connect(lambda: self.zoom_out.emit())
editor.zoom_reset.connect(lambda: self.zoom_reset.emit())
editor.sig_eol_chars_changed.connect(lambda eol_chars: self.refresh_eol_chars(eol_chars))
self.find_widget.set_editor(editor)
self.refresh_file_dependent_actions.emit()
self.modification_changed(index=self.data.index(finfo))
# Needs to reset the highlighting on startup in case the PygmentsSH
# is in use
editor.run_pygments_highlighter()
options = {
'language': editor.language,
'filename': editor.filename,
'codeeditor': editor
}
self.sig_open_file.emit(options)
if self.get_stack_index() == 0:
self.current_changed(0)
return finfo | python | def create_new_editor(self, fname, enc, txt, set_current, new=False,
cloned_from=None, add_where='end'):
"""
Create a new editor instance
Returns finfo object (instead of editor as in previous releases)
"""
editor = codeeditor.CodeEditor(self)
editor.go_to_definition.connect(
lambda fname, line, column: self.sig_go_to_definition.emit(
fname, line, column))
finfo = FileInfo(fname, enc, editor, new, self.threadmanager)
self.add_to_data(finfo, set_current, add_where)
finfo.send_to_help.connect(self.send_to_help)
finfo.todo_results_changed.connect(
lambda: self.todo_results_changed.emit())
finfo.edit_goto.connect(lambda fname, lineno, name:
self.edit_goto.emit(fname, lineno, name))
finfo.sig_save_bookmarks.connect(lambda s1, s2:
self.sig_save_bookmarks.emit(s1, s2))
editor.sig_run_selection.connect(self.run_selection)
editor.sig_run_cell.connect(self.run_cell)
editor.sig_run_cell_and_advance.connect(self.run_cell_and_advance)
editor.sig_re_run_last_cell.connect(self.re_run_last_cell)
editor.sig_new_file.connect(self.sig_new_file.emit)
editor.sig_breakpoints_saved.connect(self.sig_breakpoints_saved)
language = get_file_language(fname, txt)
editor.setup_editor(
linenumbers=self.linenumbers_enabled,
show_blanks=self.blanks_enabled,
scroll_past_end=self.scrollpastend_enabled,
edge_line=self.edgeline_enabled,
edge_line_columns=self.edgeline_columns, language=language,
markers=self.has_markers(), font=self.default_font,
color_scheme=self.color_scheme,
wrap=self.wrap_enabled, tab_mode=self.tabmode_enabled,
intelligent_backspace=self.intelligent_backspace_enabled,
highlight_current_line=self.highlight_current_line_enabled,
highlight_current_cell=self.highlight_current_cell_enabled,
occurrence_highlighting=self.occurrence_highlighting_enabled,
occurrence_timeout=self.occurrence_highlighting_timeout,
close_parentheses=self.close_parentheses_enabled,
close_quotes=self.close_quotes_enabled,
add_colons=self.add_colons_enabled,
auto_unindent=self.auto_unindent_enabled,
indent_chars=self.indent_chars,
tab_stop_width_spaces=self.tab_stop_width_spaces,
cloned_from=cloned_from,
filename=fname,
show_class_func_dropdown=self.show_class_func_dropdown,
indent_guides=self.indent_guides)
if cloned_from is None:
editor.set_text(txt)
editor.document().setModified(False)
editor.document().changed_since_autosave = False
finfo.text_changed_at.connect(
lambda fname, position:
self.text_changed_at.emit(fname, position))
editor.sig_cursor_position_changed.connect(
self.editor_cursor_position_changed)
editor.textChanged.connect(self.start_stop_analysis_timer)
editor.sig_perform_lsp_request.connect(
lambda lang, method, params: self.perform_lsp_request.emit(
lang, method, params))
editor.modificationChanged.connect(
lambda state: self.modification_changed(state,
editor_id=id(editor)))
editor.focus_in.connect(self.focus_changed)
editor.zoom_in.connect(lambda: self.zoom_in.emit())
editor.zoom_out.connect(lambda: self.zoom_out.emit())
editor.zoom_reset.connect(lambda: self.zoom_reset.emit())
editor.sig_eol_chars_changed.connect(lambda eol_chars: self.refresh_eol_chars(eol_chars))
self.find_widget.set_editor(editor)
self.refresh_file_dependent_actions.emit()
self.modification_changed(index=self.data.index(finfo))
# Needs to reset the highlighting on startup in case the PygmentsSH
# is in use
editor.run_pygments_highlighter()
options = {
'language': editor.language,
'filename': editor.filename,
'codeeditor': editor
}
self.sig_open_file.emit(options)
if self.get_stack_index() == 0:
self.current_changed(0)
return finfo | [
"def",
"create_new_editor",
"(",
"self",
",",
"fname",
",",
"enc",
",",
"txt",
",",
"set_current",
",",
"new",
"=",
"False",
",",
"cloned_from",
"=",
"None",
",",
"add_where",
"=",
"'end'",
")",
":",
"editor",
"=",
"codeeditor",
".",
"CodeEditor",
"(",
"self",
")",
"editor",
".",
"go_to_definition",
".",
"connect",
"(",
"lambda",
"fname",
",",
"line",
",",
"column",
":",
"self",
".",
"sig_go_to_definition",
".",
"emit",
"(",
"fname",
",",
"line",
",",
"column",
")",
")",
"finfo",
"=",
"FileInfo",
"(",
"fname",
",",
"enc",
",",
"editor",
",",
"new",
",",
"self",
".",
"threadmanager",
")",
"self",
".",
"add_to_data",
"(",
"finfo",
",",
"set_current",
",",
"add_where",
")",
"finfo",
".",
"send_to_help",
".",
"connect",
"(",
"self",
".",
"send_to_help",
")",
"finfo",
".",
"todo_results_changed",
".",
"connect",
"(",
"lambda",
":",
"self",
".",
"todo_results_changed",
".",
"emit",
"(",
")",
")",
"finfo",
".",
"edit_goto",
".",
"connect",
"(",
"lambda",
"fname",
",",
"lineno",
",",
"name",
":",
"self",
".",
"edit_goto",
".",
"emit",
"(",
"fname",
",",
"lineno",
",",
"name",
")",
")",
"finfo",
".",
"sig_save_bookmarks",
".",
"connect",
"(",
"lambda",
"s1",
",",
"s2",
":",
"self",
".",
"sig_save_bookmarks",
".",
"emit",
"(",
"s1",
",",
"s2",
")",
")",
"editor",
".",
"sig_run_selection",
".",
"connect",
"(",
"self",
".",
"run_selection",
")",
"editor",
".",
"sig_run_cell",
".",
"connect",
"(",
"self",
".",
"run_cell",
")",
"editor",
".",
"sig_run_cell_and_advance",
".",
"connect",
"(",
"self",
".",
"run_cell_and_advance",
")",
"editor",
".",
"sig_re_run_last_cell",
".",
"connect",
"(",
"self",
".",
"re_run_last_cell",
")",
"editor",
".",
"sig_new_file",
".",
"connect",
"(",
"self",
".",
"sig_new_file",
".",
"emit",
")",
"editor",
".",
"sig_breakpoints_saved",
".",
"connect",
"(",
"self",
".",
"sig_breakpoints_saved",
")",
"language",
"=",
"get_file_language",
"(",
"fname",
",",
"txt",
")",
"editor",
".",
"setup_editor",
"(",
"linenumbers",
"=",
"self",
".",
"linenumbers_enabled",
",",
"show_blanks",
"=",
"self",
".",
"blanks_enabled",
",",
"scroll_past_end",
"=",
"self",
".",
"scrollpastend_enabled",
",",
"edge_line",
"=",
"self",
".",
"edgeline_enabled",
",",
"edge_line_columns",
"=",
"self",
".",
"edgeline_columns",
",",
"language",
"=",
"language",
",",
"markers",
"=",
"self",
".",
"has_markers",
"(",
")",
",",
"font",
"=",
"self",
".",
"default_font",
",",
"color_scheme",
"=",
"self",
".",
"color_scheme",
",",
"wrap",
"=",
"self",
".",
"wrap_enabled",
",",
"tab_mode",
"=",
"self",
".",
"tabmode_enabled",
",",
"intelligent_backspace",
"=",
"self",
".",
"intelligent_backspace_enabled",
",",
"highlight_current_line",
"=",
"self",
".",
"highlight_current_line_enabled",
",",
"highlight_current_cell",
"=",
"self",
".",
"highlight_current_cell_enabled",
",",
"occurrence_highlighting",
"=",
"self",
".",
"occurrence_highlighting_enabled",
",",
"occurrence_timeout",
"=",
"self",
".",
"occurrence_highlighting_timeout",
",",
"close_parentheses",
"=",
"self",
".",
"close_parentheses_enabled",
",",
"close_quotes",
"=",
"self",
".",
"close_quotes_enabled",
",",
"add_colons",
"=",
"self",
".",
"add_colons_enabled",
",",
"auto_unindent",
"=",
"self",
".",
"auto_unindent_enabled",
",",
"indent_chars",
"=",
"self",
".",
"indent_chars",
",",
"tab_stop_width_spaces",
"=",
"self",
".",
"tab_stop_width_spaces",
",",
"cloned_from",
"=",
"cloned_from",
",",
"filename",
"=",
"fname",
",",
"show_class_func_dropdown",
"=",
"self",
".",
"show_class_func_dropdown",
",",
"indent_guides",
"=",
"self",
".",
"indent_guides",
")",
"if",
"cloned_from",
"is",
"None",
":",
"editor",
".",
"set_text",
"(",
"txt",
")",
"editor",
".",
"document",
"(",
")",
".",
"setModified",
"(",
"False",
")",
"editor",
".",
"document",
"(",
")",
".",
"changed_since_autosave",
"=",
"False",
"finfo",
".",
"text_changed_at",
".",
"connect",
"(",
"lambda",
"fname",
",",
"position",
":",
"self",
".",
"text_changed_at",
".",
"emit",
"(",
"fname",
",",
"position",
")",
")",
"editor",
".",
"sig_cursor_position_changed",
".",
"connect",
"(",
"self",
".",
"editor_cursor_position_changed",
")",
"editor",
".",
"textChanged",
".",
"connect",
"(",
"self",
".",
"start_stop_analysis_timer",
")",
"editor",
".",
"sig_perform_lsp_request",
".",
"connect",
"(",
"lambda",
"lang",
",",
"method",
",",
"params",
":",
"self",
".",
"perform_lsp_request",
".",
"emit",
"(",
"lang",
",",
"method",
",",
"params",
")",
")",
"editor",
".",
"modificationChanged",
".",
"connect",
"(",
"lambda",
"state",
":",
"self",
".",
"modification_changed",
"(",
"state",
",",
"editor_id",
"=",
"id",
"(",
"editor",
")",
")",
")",
"editor",
".",
"focus_in",
".",
"connect",
"(",
"self",
".",
"focus_changed",
")",
"editor",
".",
"zoom_in",
".",
"connect",
"(",
"lambda",
":",
"self",
".",
"zoom_in",
".",
"emit",
"(",
")",
")",
"editor",
".",
"zoom_out",
".",
"connect",
"(",
"lambda",
":",
"self",
".",
"zoom_out",
".",
"emit",
"(",
")",
")",
"editor",
".",
"zoom_reset",
".",
"connect",
"(",
"lambda",
":",
"self",
".",
"zoom_reset",
".",
"emit",
"(",
")",
")",
"editor",
".",
"sig_eol_chars_changed",
".",
"connect",
"(",
"lambda",
"eol_chars",
":",
"self",
".",
"refresh_eol_chars",
"(",
"eol_chars",
")",
")",
"self",
".",
"find_widget",
".",
"set_editor",
"(",
"editor",
")",
"self",
".",
"refresh_file_dependent_actions",
".",
"emit",
"(",
")",
"self",
".",
"modification_changed",
"(",
"index",
"=",
"self",
".",
"data",
".",
"index",
"(",
"finfo",
")",
")",
"# Needs to reset the highlighting on startup in case the PygmentsSH\r",
"# is in use\r",
"editor",
".",
"run_pygments_highlighter",
"(",
")",
"options",
"=",
"{",
"'language'",
":",
"editor",
".",
"language",
",",
"'filename'",
":",
"editor",
".",
"filename",
",",
"'codeeditor'",
":",
"editor",
"}",
"self",
".",
"sig_open_file",
".",
"emit",
"(",
"options",
")",
"if",
"self",
".",
"get_stack_index",
"(",
")",
"==",
"0",
":",
"self",
".",
"current_changed",
"(",
"0",
")",
"return",
"finfo"
] | Create a new editor instance
Returns finfo object (instead of editor as in previous releases) | [
"Create",
"a",
"new",
"editor",
"instance",
"Returns",
"finfo",
"object",
"(",
"instead",
"of",
"editor",
"as",
"in",
"previous",
"releases",
")"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2220-L2311 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.send_to_help | def send_to_help(self, name, signature, force=False):
"""qstr1: obj_text, qstr2: argpspec, qstr3: note, qstr4: doc_text"""
if not force and not self.help_enabled:
return
if self.help is not None \
and (force or self.help.dockwidget.isVisible()):
signature = to_text_string(signature)
signature = unicodedata.normalize("NFKD", signature)
parts = signature.split('\n\n')
definition = parts[0]
documentation = '\n\n'.join(parts[1:])
args = ''
if '(' in definition:
args = definition[definition.find('('):]
doc = {'obj_text': '', 'name': name,
'argspec': args, 'note': '',
'docstring': documentation}
self.help.set_editor_doc(doc, force_refresh=force)
editor = self.get_current_editor()
editor.setFocus() | python | def send_to_help(self, name, signature, force=False):
"""qstr1: obj_text, qstr2: argpspec, qstr3: note, qstr4: doc_text"""
if not force and not self.help_enabled:
return
if self.help is not None \
and (force or self.help.dockwidget.isVisible()):
signature = to_text_string(signature)
signature = unicodedata.normalize("NFKD", signature)
parts = signature.split('\n\n')
definition = parts[0]
documentation = '\n\n'.join(parts[1:])
args = ''
if '(' in definition:
args = definition[definition.find('('):]
doc = {'obj_text': '', 'name': name,
'argspec': args, 'note': '',
'docstring': documentation}
self.help.set_editor_doc(doc, force_refresh=force)
editor = self.get_current_editor()
editor.setFocus() | [
"def",
"send_to_help",
"(",
"self",
",",
"name",
",",
"signature",
",",
"force",
"=",
"False",
")",
":",
"if",
"not",
"force",
"and",
"not",
"self",
".",
"help_enabled",
":",
"return",
"if",
"self",
".",
"help",
"is",
"not",
"None",
"and",
"(",
"force",
"or",
"self",
".",
"help",
".",
"dockwidget",
".",
"isVisible",
"(",
")",
")",
":",
"signature",
"=",
"to_text_string",
"(",
"signature",
")",
"signature",
"=",
"unicodedata",
".",
"normalize",
"(",
"\"NFKD\"",
",",
"signature",
")",
"parts",
"=",
"signature",
".",
"split",
"(",
"'\\n\\n'",
")",
"definition",
"=",
"parts",
"[",
"0",
"]",
"documentation",
"=",
"'\\n\\n'",
".",
"join",
"(",
"parts",
"[",
"1",
":",
"]",
")",
"args",
"=",
"''",
"if",
"'('",
"in",
"definition",
":",
"args",
"=",
"definition",
"[",
"definition",
".",
"find",
"(",
"'('",
")",
":",
"]",
"doc",
"=",
"{",
"'obj_text'",
":",
"''",
",",
"'name'",
":",
"name",
",",
"'argspec'",
":",
"args",
",",
"'note'",
":",
"''",
",",
"'docstring'",
":",
"documentation",
"}",
"self",
".",
"help",
".",
"set_editor_doc",
"(",
"doc",
",",
"force_refresh",
"=",
"force",
")",
"editor",
"=",
"self",
".",
"get_current_editor",
"(",
")",
"editor",
".",
"setFocus",
"(",
")"
] | qstr1: obj_text, qstr2: argpspec, qstr3: note, qstr4: doc_text | [
"qstr1",
":",
"obj_text",
"qstr2",
":",
"argpspec",
"qstr3",
":",
"note",
"qstr4",
":",
"doc_text"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2317-L2337 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.new | def new(self, filename, encoding, text, default_content=False,
empty=False):
"""
Create new filename with *encoding* and *text*
"""
finfo = self.create_new_editor(filename, encoding, text,
set_current=False, new=True)
finfo.editor.set_cursor_position('eof')
if not empty:
finfo.editor.insert_text(os.linesep)
if default_content:
finfo.default = True
finfo.editor.document().setModified(False)
return finfo | python | def new(self, filename, encoding, text, default_content=False,
empty=False):
"""
Create new filename with *encoding* and *text*
"""
finfo = self.create_new_editor(filename, encoding, text,
set_current=False, new=True)
finfo.editor.set_cursor_position('eof')
if not empty:
finfo.editor.insert_text(os.linesep)
if default_content:
finfo.default = True
finfo.editor.document().setModified(False)
return finfo | [
"def",
"new",
"(",
"self",
",",
"filename",
",",
"encoding",
",",
"text",
",",
"default_content",
"=",
"False",
",",
"empty",
"=",
"False",
")",
":",
"finfo",
"=",
"self",
".",
"create_new_editor",
"(",
"filename",
",",
"encoding",
",",
"text",
",",
"set_current",
"=",
"False",
",",
"new",
"=",
"True",
")",
"finfo",
".",
"editor",
".",
"set_cursor_position",
"(",
"'eof'",
")",
"if",
"not",
"empty",
":",
"finfo",
".",
"editor",
".",
"insert_text",
"(",
"os",
".",
"linesep",
")",
"if",
"default_content",
":",
"finfo",
".",
"default",
"=",
"True",
"finfo",
".",
"editor",
".",
"document",
"(",
")",
".",
"setModified",
"(",
"False",
")",
"return",
"finfo"
] | Create new filename with *encoding* and *text* | [
"Create",
"new",
"filename",
"with",
"*",
"encoding",
"*",
"and",
"*",
"text",
"*"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2339-L2352 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.load | def load(self, filename, set_current=True, add_where='end'):
"""
Load filename, create an editor instance and return it
*Warning* This is loading file, creating editor but not executing
the source code analysis -- the analysis must be done by the editor
plugin (in case multiple editorstack instances are handled)
"""
filename = osp.abspath(to_text_string(filename))
self.starting_long_process.emit(_("Loading %s...") % filename)
text, enc = encoding.read(filename)
finfo = self.create_new_editor(filename, enc, text, set_current,
add_where=add_where)
index = self.data.index(finfo)
self._refresh_outlineexplorer(index, update=True)
self.ending_long_process.emit("")
if self.isVisible() and self.checkeolchars_enabled \
and sourcecode.has_mixed_eol_chars(text):
name = osp.basename(filename)
self.msgbox = QMessageBox(
QMessageBox.Warning,
self.title,
_("<b>%s</b> contains mixed end-of-line "
"characters.<br>Spyder will fix this "
"automatically.") % name,
QMessageBox.Ok,
self)
self.msgbox.exec_()
self.set_os_eol_chars(index)
self.is_analysis_done = False
return finfo | python | def load(self, filename, set_current=True, add_where='end'):
"""
Load filename, create an editor instance and return it
*Warning* This is loading file, creating editor but not executing
the source code analysis -- the analysis must be done by the editor
plugin (in case multiple editorstack instances are handled)
"""
filename = osp.abspath(to_text_string(filename))
self.starting_long_process.emit(_("Loading %s...") % filename)
text, enc = encoding.read(filename)
finfo = self.create_new_editor(filename, enc, text, set_current,
add_where=add_where)
index = self.data.index(finfo)
self._refresh_outlineexplorer(index, update=True)
self.ending_long_process.emit("")
if self.isVisible() and self.checkeolchars_enabled \
and sourcecode.has_mixed_eol_chars(text):
name = osp.basename(filename)
self.msgbox = QMessageBox(
QMessageBox.Warning,
self.title,
_("<b>%s</b> contains mixed end-of-line "
"characters.<br>Spyder will fix this "
"automatically.") % name,
QMessageBox.Ok,
self)
self.msgbox.exec_()
self.set_os_eol_chars(index)
self.is_analysis_done = False
return finfo | [
"def",
"load",
"(",
"self",
",",
"filename",
",",
"set_current",
"=",
"True",
",",
"add_where",
"=",
"'end'",
")",
":",
"filename",
"=",
"osp",
".",
"abspath",
"(",
"to_text_string",
"(",
"filename",
")",
")",
"self",
".",
"starting_long_process",
".",
"emit",
"(",
"_",
"(",
"\"Loading %s...\"",
")",
"%",
"filename",
")",
"text",
",",
"enc",
"=",
"encoding",
".",
"read",
"(",
"filename",
")",
"finfo",
"=",
"self",
".",
"create_new_editor",
"(",
"filename",
",",
"enc",
",",
"text",
",",
"set_current",
",",
"add_where",
"=",
"add_where",
")",
"index",
"=",
"self",
".",
"data",
".",
"index",
"(",
"finfo",
")",
"self",
".",
"_refresh_outlineexplorer",
"(",
"index",
",",
"update",
"=",
"True",
")",
"self",
".",
"ending_long_process",
".",
"emit",
"(",
"\"\"",
")",
"if",
"self",
".",
"isVisible",
"(",
")",
"and",
"self",
".",
"checkeolchars_enabled",
"and",
"sourcecode",
".",
"has_mixed_eol_chars",
"(",
"text",
")",
":",
"name",
"=",
"osp",
".",
"basename",
"(",
"filename",
")",
"self",
".",
"msgbox",
"=",
"QMessageBox",
"(",
"QMessageBox",
".",
"Warning",
",",
"self",
".",
"title",
",",
"_",
"(",
"\"<b>%s</b> contains mixed end-of-line \"",
"\"characters.<br>Spyder will fix this \"",
"\"automatically.\"",
")",
"%",
"name",
",",
"QMessageBox",
".",
"Ok",
",",
"self",
")",
"self",
".",
"msgbox",
".",
"exec_",
"(",
")",
"self",
".",
"set_os_eol_chars",
"(",
"index",
")",
"self",
".",
"is_analysis_done",
"=",
"False",
"return",
"finfo"
] | Load filename, create an editor instance and return it
*Warning* This is loading file, creating editor but not executing
the source code analysis -- the analysis must be done by the editor
plugin (in case multiple editorstack instances are handled) | [
"Load",
"filename",
"create",
"an",
"editor",
"instance",
"and",
"return",
"it",
"*",
"Warning",
"*",
"This",
"is",
"loading",
"file",
"creating",
"editor",
"but",
"not",
"executing",
"the",
"source",
"code",
"analysis",
"--",
"the",
"analysis",
"must",
"be",
"done",
"by",
"the",
"editor",
"plugin",
"(",
"in",
"case",
"multiple",
"editorstack",
"instances",
"are",
"handled",
")"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2354-L2383 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.set_os_eol_chars | def set_os_eol_chars(self, index=None, osname=None):
"""Sets the EOL character(s) based on the operating system.
If `osname` is None, then the default line endings for the current
operating system (`os.name` value) will be used.
`osname` can be one of:
('posix', 'nt', 'java')
"""
if osname is None:
osname = os.name
if index is None:
index = self.get_stack_index()
finfo = self.data[index]
eol_chars = sourcecode.get_eol_chars_from_os_name(osname)
finfo.editor.set_eol_chars(eol_chars)
finfo.editor.document().setModified(True) | python | def set_os_eol_chars(self, index=None, osname=None):
"""Sets the EOL character(s) based on the operating system.
If `osname` is None, then the default line endings for the current
operating system (`os.name` value) will be used.
`osname` can be one of:
('posix', 'nt', 'java')
"""
if osname is None:
osname = os.name
if index is None:
index = self.get_stack_index()
finfo = self.data[index]
eol_chars = sourcecode.get_eol_chars_from_os_name(osname)
finfo.editor.set_eol_chars(eol_chars)
finfo.editor.document().setModified(True) | [
"def",
"set_os_eol_chars",
"(",
"self",
",",
"index",
"=",
"None",
",",
"osname",
"=",
"None",
")",
":",
"if",
"osname",
"is",
"None",
":",
"osname",
"=",
"os",
".",
"name",
"if",
"index",
"is",
"None",
":",
"index",
"=",
"self",
".",
"get_stack_index",
"(",
")",
"finfo",
"=",
"self",
".",
"data",
"[",
"index",
"]",
"eol_chars",
"=",
"sourcecode",
".",
"get_eol_chars_from_os_name",
"(",
"osname",
")",
"finfo",
".",
"editor",
".",
"set_eol_chars",
"(",
"eol_chars",
")",
"finfo",
".",
"editor",
".",
"document",
"(",
")",
".",
"setModified",
"(",
"True",
")"
] | Sets the EOL character(s) based on the operating system.
If `osname` is None, then the default line endings for the current
operating system (`os.name` value) will be used.
`osname` can be one of:
('posix', 'nt', 'java') | [
"Sets",
"the",
"EOL",
"character",
"(",
"s",
")",
"based",
"on",
"the",
"operating",
"system",
".",
"If",
"osname",
"is",
"None",
"then",
"the",
"default",
"line",
"endings",
"for",
"the",
"current",
"operating",
"system",
"(",
"os",
".",
"name",
"value",
")",
"will",
"be",
"used",
".",
"osname",
"can",
"be",
"one",
"of",
":",
"(",
"posix",
"nt",
"java",
")"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2385-L2401 | train |
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 | [
"Remove",
"trailing",
"spaces"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2403-L2408 | train |
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",
".",
"fix_indentation",
"(",
")"
] | 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 | train |
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",
"(",
")",
",",
"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'",
")"
] | 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",
"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",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2418-L2441 | train |
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 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.advance_cell | def advance_cell(self, reverse=False):
"""Advance to the next cell.
reverse = True --> go to previous cell.
"""
if not reverse:
move_func = self.get_current_editor().go_to_next_cell
else:
move_func = self.get_current_editor().go_to_previous_cell
if self.focus_to_editor:
move_func()
else:
term = QApplication.focusWidget()
move_func()
term.setFocus()
term = QApplication.focusWidget()
move_func()
term.setFocus() | python | def advance_cell(self, reverse=False):
"""Advance to the next cell.
reverse = True --> go to previous cell.
"""
if not reverse:
move_func = self.get_current_editor().go_to_next_cell
else:
move_func = self.get_current_editor().go_to_previous_cell
if self.focus_to_editor:
move_func()
else:
term = QApplication.focusWidget()
move_func()
term.setFocus()
term = QApplication.focusWidget()
move_func()
term.setFocus() | [
"def",
"advance_cell",
"(",
"self",
",",
"reverse",
"=",
"False",
")",
":",
"if",
"not",
"reverse",
":",
"move_func",
"=",
"self",
".",
"get_current_editor",
"(",
")",
".",
"go_to_next_cell",
"else",
":",
"move_func",
"=",
"self",
".",
"get_current_editor",
"(",
")",
".",
"go_to_previous_cell",
"if",
"self",
".",
"focus_to_editor",
":",
"move_func",
"(",
")",
"else",
":",
"term",
"=",
"QApplication",
".",
"focusWidget",
"(",
")",
"move_func",
"(",
")",
"term",
".",
"setFocus",
"(",
")",
"term",
"=",
"QApplication",
".",
"focusWidget",
"(",
")",
"move_func",
"(",
")",
"term",
".",
"setFocus",
"(",
")"
] | Advance to the next cell.
reverse = True --> go to previous cell. | [
"Advance",
"to",
"the",
"next",
"cell",
".",
"reverse",
"=",
"True",
"--",
">",
"go",
"to",
"previous",
"cell",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2453-L2471 | train |
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 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack._run_cell_text | def _run_cell_text(self, text, line):
"""Run cell code in the console.
Cell code is run in the console by copying it to the console if
`self.run_cell_copy` is ``True`` otherwise by using the `run_cell`
function.
Parameters
----------
text : str
The code in the cell as a string.
line : int
The starting line number of the cell in the file.
"""
finfo = self.get_current_finfo()
editor = self.get_current_editor()
oe_data = editor.highlighter.get_outlineexplorer_data()
try:
cell_name = oe_data.get(line-1).def_name
except AttributeError:
cell_name = ''
if finfo.editor.is_python() and text:
self.run_cell_in_ipyclient.emit(text, cell_name,
finfo.filename,
self.run_cell_copy)
editor.setFocus() | python | def _run_cell_text(self, text, line):
"""Run cell code in the console.
Cell code is run in the console by copying it to the console if
`self.run_cell_copy` is ``True`` otherwise by using the `run_cell`
function.
Parameters
----------
text : str
The code in the cell as a string.
line : int
The starting line number of the cell in the file.
"""
finfo = self.get_current_finfo()
editor = self.get_current_editor()
oe_data = editor.highlighter.get_outlineexplorer_data()
try:
cell_name = oe_data.get(line-1).def_name
except AttributeError:
cell_name = ''
if finfo.editor.is_python() and text:
self.run_cell_in_ipyclient.emit(text, cell_name,
finfo.filename,
self.run_cell_copy)
editor.setFocus() | [
"def",
"_run_cell_text",
"(",
"self",
",",
"text",
",",
"line",
")",
":",
"finfo",
"=",
"self",
".",
"get_current_finfo",
"(",
")",
"editor",
"=",
"self",
".",
"get_current_editor",
"(",
")",
"oe_data",
"=",
"editor",
".",
"highlighter",
".",
"get_outlineexplorer_data",
"(",
")",
"try",
":",
"cell_name",
"=",
"oe_data",
".",
"get",
"(",
"line",
"-",
"1",
")",
".",
"def_name",
"except",
"AttributeError",
":",
"cell_name",
"=",
"''",
"if",
"finfo",
".",
"editor",
".",
"is_python",
"(",
")",
"and",
"text",
":",
"self",
".",
"run_cell_in_ipyclient",
".",
"emit",
"(",
"text",
",",
"cell_name",
",",
"finfo",
".",
"filename",
",",
"self",
".",
"run_cell_copy",
")",
"editor",
".",
"setFocus",
"(",
")"
] | Run cell code in the console.
Cell code is run in the console by copying it to the console if
`self.run_cell_copy` is ``True`` otherwise by using the `run_cell`
function.
Parameters
----------
text : str
The code in the cell as a string.
line : int
The starting line number of the cell in the file. | [
"Run",
"cell",
"code",
"in",
"the",
"console",
".",
"Cell",
"code",
"is",
"run",
"in",
"the",
"console",
"by",
"copying",
"it",
"to",
"the",
"console",
"if",
"self",
".",
"run_cell_copy",
"is",
"True",
"otherwise",
"by",
"using",
"the",
"run_cell",
"function",
".",
"Parameters",
"----------",
"text",
":",
"str",
"The",
"code",
"in",
"the",
"cell",
"as",
"a",
"string",
".",
"line",
":",
"int",
"The",
"starting",
"line",
"number",
"of",
"the",
"cell",
"in",
"the",
"file",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2479-L2504 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.dragEnterEvent | def dragEnterEvent(self, event):
"""Reimplement Qt method
Inform Qt about the types of data that the widget accepts"""
source = event.mimeData()
# The second check is necessary on Windows, where source.hasUrls()
# can return True but source.urls() is []
# The third check is needed since a file could be dropped from
# compressed files. In Windows mimedata2url(source) returns None
# Fixes issue 5218
if source.hasUrls() and source.urls() and mimedata2url(source):
all_urls = mimedata2url(source)
text = [encoding.is_text_file(url) for url in all_urls]
if any(text):
event.acceptProposedAction()
else:
event.ignore()
elif source.hasText():
event.acceptProposedAction()
elif os.name == 'nt':
# This covers cases like dragging from compressed files,
# which can be opened by the Editor if they are plain
# text, but doesn't come with url info.
# Fixes Issue 2032
event.acceptProposedAction()
else:
event.ignore() | python | def dragEnterEvent(self, event):
"""Reimplement Qt method
Inform Qt about the types of data that the widget accepts"""
source = event.mimeData()
# The second check is necessary on Windows, where source.hasUrls()
# can return True but source.urls() is []
# The third check is needed since a file could be dropped from
# compressed files. In Windows mimedata2url(source) returns None
# Fixes issue 5218
if source.hasUrls() and source.urls() and mimedata2url(source):
all_urls = mimedata2url(source)
text = [encoding.is_text_file(url) for url in all_urls]
if any(text):
event.acceptProposedAction()
else:
event.ignore()
elif source.hasText():
event.acceptProposedAction()
elif os.name == 'nt':
# This covers cases like dragging from compressed files,
# which can be opened by the Editor if they are plain
# text, but doesn't come with url info.
# Fixes Issue 2032
event.acceptProposedAction()
else:
event.ignore() | [
"def",
"dragEnterEvent",
"(",
"self",
",",
"event",
")",
":",
"source",
"=",
"event",
".",
"mimeData",
"(",
")",
"# The second check is necessary on Windows, where source.hasUrls()\r",
"# can return True but source.urls() is []\r",
"# The third check is needed since a file could be dropped from\r",
"# compressed files. In Windows mimedata2url(source) returns None\r",
"# Fixes issue 5218\r",
"if",
"source",
".",
"hasUrls",
"(",
")",
"and",
"source",
".",
"urls",
"(",
")",
"and",
"mimedata2url",
"(",
"source",
")",
":",
"all_urls",
"=",
"mimedata2url",
"(",
"source",
")",
"text",
"=",
"[",
"encoding",
".",
"is_text_file",
"(",
"url",
")",
"for",
"url",
"in",
"all_urls",
"]",
"if",
"any",
"(",
"text",
")",
":",
"event",
".",
"acceptProposedAction",
"(",
")",
"else",
":",
"event",
".",
"ignore",
"(",
")",
"elif",
"source",
".",
"hasText",
"(",
")",
":",
"event",
".",
"acceptProposedAction",
"(",
")",
"elif",
"os",
".",
"name",
"==",
"'nt'",
":",
"# This covers cases like dragging from compressed files,\r",
"# which can be opened by the Editor if they are plain\r",
"# text, but doesn't come with url info.\r",
"# Fixes Issue 2032\r",
"event",
".",
"acceptProposedAction",
"(",
")",
"else",
":",
"event",
".",
"ignore",
"(",
")"
] | Reimplement Qt method
Inform Qt about the types of data that the widget accepts | [
"Reimplement",
"Qt",
"method",
"Inform",
"Qt",
"about",
"the",
"types",
"of",
"data",
"that",
"the",
"widget",
"accepts"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2507-L2532 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorStack.dropEvent | def dropEvent(self, event):
"""Reimplement Qt method
Unpack dropped data and handle it"""
source = event.mimeData()
# The second check is necessary when mimedata2url(source)
# returns None.
# Fixes issue 7742
if source.hasUrls() and mimedata2url(source):
files = mimedata2url(source)
files = [f for f in files if encoding.is_text_file(f)]
files = set(files or [])
for fname in files:
self.plugin_load.emit(fname)
elif source.hasText():
editor = self.get_current_editor()
if editor is not None:
editor.insert_text(source.text())
else:
event.ignore()
event.acceptProposedAction() | python | def dropEvent(self, event):
"""Reimplement Qt method
Unpack dropped data and handle it"""
source = event.mimeData()
# The second check is necessary when mimedata2url(source)
# returns None.
# Fixes issue 7742
if source.hasUrls() and mimedata2url(source):
files = mimedata2url(source)
files = [f for f in files if encoding.is_text_file(f)]
files = set(files or [])
for fname in files:
self.plugin_load.emit(fname)
elif source.hasText():
editor = self.get_current_editor()
if editor is not None:
editor.insert_text(source.text())
else:
event.ignore()
event.acceptProposedAction() | [
"def",
"dropEvent",
"(",
"self",
",",
"event",
")",
":",
"source",
"=",
"event",
".",
"mimeData",
"(",
")",
"# The second check is necessary when mimedata2url(source)\r",
"# returns None.\r",
"# Fixes issue 7742\r",
"if",
"source",
".",
"hasUrls",
"(",
")",
"and",
"mimedata2url",
"(",
"source",
")",
":",
"files",
"=",
"mimedata2url",
"(",
"source",
")",
"files",
"=",
"[",
"f",
"for",
"f",
"in",
"files",
"if",
"encoding",
".",
"is_text_file",
"(",
"f",
")",
"]",
"files",
"=",
"set",
"(",
"files",
"or",
"[",
"]",
")",
"for",
"fname",
"in",
"files",
":",
"self",
".",
"plugin_load",
".",
"emit",
"(",
"fname",
")",
"elif",
"source",
".",
"hasText",
"(",
")",
":",
"editor",
"=",
"self",
".",
"get_current_editor",
"(",
")",
"if",
"editor",
"is",
"not",
"None",
":",
"editor",
".",
"insert_text",
"(",
"source",
".",
"text",
"(",
")",
")",
"else",
":",
"event",
".",
"ignore",
"(",
")",
"event",
".",
"acceptProposedAction",
"(",
")"
] | Reimplement Qt method
Unpack dropped data and handle it | [
"Reimplement",
"Qt",
"method",
"Unpack",
"dropped",
"data",
"and",
"handle",
"it"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2534-L2553 | train |
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",
"(",
"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",
"(",
")"
] | 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",
"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",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2655-L2676 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorSplitter.iter_editorstacks | def iter_editorstacks(self):
"""Return the editor stacks for this splitter and every first child.
Note: If a splitter contains more than one splitter as a direct
child, only the first child's editor stack is included.
Returns:
List of tuples containing (EditorStack instance, orientation).
"""
editorstacks = [(self.widget(0), self.orientation())]
if self.count() > 1:
editorsplitter = self.widget(1)
editorstacks += editorsplitter.iter_editorstacks()
return editorstacks | python | def iter_editorstacks(self):
"""Return the editor stacks for this splitter and every first child.
Note: If a splitter contains more than one splitter as a direct
child, only the first child's editor stack is included.
Returns:
List of tuples containing (EditorStack instance, orientation).
"""
editorstacks = [(self.widget(0), self.orientation())]
if self.count() > 1:
editorsplitter = self.widget(1)
editorstacks += editorsplitter.iter_editorstacks()
return editorstacks | [
"def",
"iter_editorstacks",
"(",
"self",
")",
":",
"editorstacks",
"=",
"[",
"(",
"self",
".",
"widget",
"(",
"0",
")",
",",
"self",
".",
"orientation",
"(",
")",
")",
"]",
"if",
"self",
".",
"count",
"(",
")",
">",
"1",
":",
"editorsplitter",
"=",
"self",
".",
"widget",
"(",
"1",
")",
"editorstacks",
"+=",
"editorsplitter",
".",
"iter_editorstacks",
"(",
")",
"return",
"editorstacks"
] | Return the editor stacks for this splitter and every first child.
Note: If a splitter contains more than one splitter as a direct
child, only the first child's editor stack is included.
Returns:
List of tuples containing (EditorStack instance, orientation). | [
"Return",
"the",
"editor",
"stacks",
"for",
"this",
"splitter",
"and",
"every",
"first",
"child",
".",
"Note",
":",
"If",
"a",
"splitter",
"contains",
"more",
"than",
"one",
"splitter",
"as",
"a",
"direct",
"child",
"only",
"the",
"first",
"child",
"s",
"editor",
"stack",
"is",
"included",
".",
"Returns",
":",
"List",
"of",
"tuples",
"containing",
"(",
"EditorStack",
"instance",
"orientation",
")",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2678-L2691 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorSplitter.get_layout_settings | def get_layout_settings(self):
"""Return the layout state for this splitter and its children.
Record the current state, including file names and current line
numbers, of the splitter panels.
Returns:
A dictionary containing keys {hexstate, sizes, splitsettings}.
hexstate: String of saveState() for self.
sizes: List for size() for self.
splitsettings: List of tuples of the form
(orientation, cfname, clines) for each EditorSplitter
and its EditorStack.
orientation: orientation() for the editor
splitter (which may be a child of self).
cfname: EditorStack current file name.
clines: Current line number for each file in the
EditorStack.
"""
splitsettings = []
for editorstack, orientation in self.iter_editorstacks():
clines = []
cfname = ''
# XXX - this overrides value from the loop to always be False?
orientation = False
if hasattr(editorstack, 'data'):
clines = [finfo.editor.get_cursor_line_number()
for finfo in editorstack.data]
cfname = editorstack.get_current_filename()
splitsettings.append((orientation == Qt.Vertical, cfname, clines))
return dict(hexstate=qbytearray_to_str(self.saveState()),
sizes=self.sizes(), splitsettings=splitsettings) | python | def get_layout_settings(self):
"""Return the layout state for this splitter and its children.
Record the current state, including file names and current line
numbers, of the splitter panels.
Returns:
A dictionary containing keys {hexstate, sizes, splitsettings}.
hexstate: String of saveState() for self.
sizes: List for size() for self.
splitsettings: List of tuples of the form
(orientation, cfname, clines) for each EditorSplitter
and its EditorStack.
orientation: orientation() for the editor
splitter (which may be a child of self).
cfname: EditorStack current file name.
clines: Current line number for each file in the
EditorStack.
"""
splitsettings = []
for editorstack, orientation in self.iter_editorstacks():
clines = []
cfname = ''
# XXX - this overrides value from the loop to always be False?
orientation = False
if hasattr(editorstack, 'data'):
clines = [finfo.editor.get_cursor_line_number()
for finfo in editorstack.data]
cfname = editorstack.get_current_filename()
splitsettings.append((orientation == Qt.Vertical, cfname, clines))
return dict(hexstate=qbytearray_to_str(self.saveState()),
sizes=self.sizes(), splitsettings=splitsettings) | [
"def",
"get_layout_settings",
"(",
"self",
")",
":",
"splitsettings",
"=",
"[",
"]",
"for",
"editorstack",
",",
"orientation",
"in",
"self",
".",
"iter_editorstacks",
"(",
")",
":",
"clines",
"=",
"[",
"]",
"cfname",
"=",
"''",
"# XXX - this overrides value from the loop to always be False?\r",
"orientation",
"=",
"False",
"if",
"hasattr",
"(",
"editorstack",
",",
"'data'",
")",
":",
"clines",
"=",
"[",
"finfo",
".",
"editor",
".",
"get_cursor_line_number",
"(",
")",
"for",
"finfo",
"in",
"editorstack",
".",
"data",
"]",
"cfname",
"=",
"editorstack",
".",
"get_current_filename",
"(",
")",
"splitsettings",
".",
"append",
"(",
"(",
"orientation",
"==",
"Qt",
".",
"Vertical",
",",
"cfname",
",",
"clines",
")",
")",
"return",
"dict",
"(",
"hexstate",
"=",
"qbytearray_to_str",
"(",
"self",
".",
"saveState",
"(",
")",
")",
",",
"sizes",
"=",
"self",
".",
"sizes",
"(",
")",
",",
"splitsettings",
"=",
"splitsettings",
")"
] | Return the layout state for this splitter and its children.
Record the current state, including file names and current line
numbers, of the splitter panels.
Returns:
A dictionary containing keys {hexstate, sizes, splitsettings}.
hexstate: String of saveState() for self.
sizes: List for size() for self.
splitsettings: List of tuples of the form
(orientation, cfname, clines) for each EditorSplitter
and its EditorStack.
orientation: orientation() for the editor
splitter (which may be a child of self).
cfname: EditorStack current file name.
clines: Current line number for each file in the
EditorStack. | [
"Return",
"the",
"layout",
"state",
"for",
"this",
"splitter",
"and",
"its",
"children",
".",
"Record",
"the",
"current",
"state",
"including",
"file",
"names",
"and",
"current",
"line",
"numbers",
"of",
"the",
"splitter",
"panels",
".",
"Returns",
":",
"A",
"dictionary",
"containing",
"keys",
"{",
"hexstate",
"sizes",
"splitsettings",
"}",
".",
"hexstate",
":",
"String",
"of",
"saveState",
"()",
"for",
"self",
".",
"sizes",
":",
"List",
"for",
"size",
"()",
"for",
"self",
".",
"splitsettings",
":",
"List",
"of",
"tuples",
"of",
"the",
"form",
"(",
"orientation",
"cfname",
"clines",
")",
"for",
"each",
"EditorSplitter",
"and",
"its",
"EditorStack",
".",
"orientation",
":",
"orientation",
"()",
"for",
"the",
"editor",
"splitter",
"(",
"which",
"may",
"be",
"a",
"child",
"of",
"self",
")",
".",
"cfname",
":",
"EditorStack",
"current",
"file",
"name",
".",
"clines",
":",
"Current",
"line",
"number",
"for",
"each",
"file",
"in",
"the",
"EditorStack",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2693-L2724 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorSplitter.set_layout_settings | def set_layout_settings(self, settings, dont_goto=None):
"""Restore layout state for the splitter panels.
Apply the settings to restore a saved layout within the editor. If
the splitsettings key doesn't exist, then return without restoring
any settings.
The current EditorSplitter (self) calls split() for each element
in split_settings, thus recreating the splitter panels from the saved
state. split() also clones the editorstack, which is then
iterated over to restore the saved line numbers on each file.
The size and positioning of each splitter panel is restored from
hexstate.
Args:
settings: A dictionary with keys {hexstate, sizes, orientation}
that define the layout for the EditorSplitter panels.
dont_goto: Defaults to None, which positions the cursor to the
end of the editor. If there's a value, positions the
cursor on the saved line number for each editor.
"""
splitsettings = settings.get('splitsettings')
if splitsettings is None:
return
splitter = self
editor = None
for index, (is_vertical, cfname, clines) in enumerate(splitsettings):
if index > 0:
splitter.split(Qt.Vertical if is_vertical else Qt.Horizontal)
splitter = splitter.widget(1)
editorstack = splitter.widget(0)
for index, finfo in enumerate(editorstack.data):
editor = finfo.editor
# TODO: go_to_line is not working properly (the line it jumps
# to is not the corresponding to that file). This will be fixed
# in a future PR (which will fix issue #3857)
if dont_goto is not None:
# skip go to line for first file because is already there
pass
else:
try:
editor.go_to_line(clines[index])
except IndexError:
pass
hexstate = settings.get('hexstate')
if hexstate is not None:
self.restoreState( QByteArray().fromHex(
str(hexstate).encode('utf-8')) )
sizes = settings.get('sizes')
if sizes is not None:
self.setSizes(sizes)
if editor is not None:
editor.clearFocus()
editor.setFocus() | python | def set_layout_settings(self, settings, dont_goto=None):
"""Restore layout state for the splitter panels.
Apply the settings to restore a saved layout within the editor. If
the splitsettings key doesn't exist, then return without restoring
any settings.
The current EditorSplitter (self) calls split() for each element
in split_settings, thus recreating the splitter panels from the saved
state. split() also clones the editorstack, which is then
iterated over to restore the saved line numbers on each file.
The size and positioning of each splitter panel is restored from
hexstate.
Args:
settings: A dictionary with keys {hexstate, sizes, orientation}
that define the layout for the EditorSplitter panels.
dont_goto: Defaults to None, which positions the cursor to the
end of the editor. If there's a value, positions the
cursor on the saved line number for each editor.
"""
splitsettings = settings.get('splitsettings')
if splitsettings is None:
return
splitter = self
editor = None
for index, (is_vertical, cfname, clines) in enumerate(splitsettings):
if index > 0:
splitter.split(Qt.Vertical if is_vertical else Qt.Horizontal)
splitter = splitter.widget(1)
editorstack = splitter.widget(0)
for index, finfo in enumerate(editorstack.data):
editor = finfo.editor
# TODO: go_to_line is not working properly (the line it jumps
# to is not the corresponding to that file). This will be fixed
# in a future PR (which will fix issue #3857)
if dont_goto is not None:
# skip go to line for first file because is already there
pass
else:
try:
editor.go_to_line(clines[index])
except IndexError:
pass
hexstate = settings.get('hexstate')
if hexstate is not None:
self.restoreState( QByteArray().fromHex(
str(hexstate).encode('utf-8')) )
sizes = settings.get('sizes')
if sizes is not None:
self.setSizes(sizes)
if editor is not None:
editor.clearFocus()
editor.setFocus() | [
"def",
"set_layout_settings",
"(",
"self",
",",
"settings",
",",
"dont_goto",
"=",
"None",
")",
":",
"splitsettings",
"=",
"settings",
".",
"get",
"(",
"'splitsettings'",
")",
"if",
"splitsettings",
"is",
"None",
":",
"return",
"splitter",
"=",
"self",
"editor",
"=",
"None",
"for",
"index",
",",
"(",
"is_vertical",
",",
"cfname",
",",
"clines",
")",
"in",
"enumerate",
"(",
"splitsettings",
")",
":",
"if",
"index",
">",
"0",
":",
"splitter",
".",
"split",
"(",
"Qt",
".",
"Vertical",
"if",
"is_vertical",
"else",
"Qt",
".",
"Horizontal",
")",
"splitter",
"=",
"splitter",
".",
"widget",
"(",
"1",
")",
"editorstack",
"=",
"splitter",
".",
"widget",
"(",
"0",
")",
"for",
"index",
",",
"finfo",
"in",
"enumerate",
"(",
"editorstack",
".",
"data",
")",
":",
"editor",
"=",
"finfo",
".",
"editor",
"# TODO: go_to_line is not working properly (the line it jumps\r",
"# to is not the corresponding to that file). This will be fixed\r",
"# in a future PR (which will fix issue #3857)\r",
"if",
"dont_goto",
"is",
"not",
"None",
":",
"# skip go to line for first file because is already there\r",
"pass",
"else",
":",
"try",
":",
"editor",
".",
"go_to_line",
"(",
"clines",
"[",
"index",
"]",
")",
"except",
"IndexError",
":",
"pass",
"hexstate",
"=",
"settings",
".",
"get",
"(",
"'hexstate'",
")",
"if",
"hexstate",
"is",
"not",
"None",
":",
"self",
".",
"restoreState",
"(",
"QByteArray",
"(",
")",
".",
"fromHex",
"(",
"str",
"(",
"hexstate",
")",
".",
"encode",
"(",
"'utf-8'",
")",
")",
")",
"sizes",
"=",
"settings",
".",
"get",
"(",
"'sizes'",
")",
"if",
"sizes",
"is",
"not",
"None",
":",
"self",
".",
"setSizes",
"(",
"sizes",
")",
"if",
"editor",
"is",
"not",
"None",
":",
"editor",
".",
"clearFocus",
"(",
")",
"editor",
".",
"setFocus",
"(",
")"
] | Restore layout state for the splitter panels.
Apply the settings to restore a saved layout within the editor. If
the splitsettings key doesn't exist, then return without restoring
any settings.
The current EditorSplitter (self) calls split() for each element
in split_settings, thus recreating the splitter panels from the saved
state. split() also clones the editorstack, which is then
iterated over to restore the saved line numbers on each file.
The size and positioning of each splitter panel is restored from
hexstate.
Args:
settings: A dictionary with keys {hexstate, sizes, orientation}
that define the layout for the EditorSplitter panels.
dont_goto: Defaults to None, which positions the cursor to the
end of the editor. If there's a value, positions the
cursor on the saved line number for each editor. | [
"Restore",
"layout",
"state",
"for",
"the",
"splitter",
"panels",
".",
"Apply",
"the",
"settings",
"to",
"restore",
"a",
"saved",
"layout",
"within",
"the",
"editor",
".",
"If",
"the",
"splitsettings",
"key",
"doesn",
"t",
"exist",
"then",
"return",
"without",
"restoring",
"any",
"settings",
".",
"The",
"current",
"EditorSplitter",
"(",
"self",
")",
"calls",
"split",
"()",
"for",
"each",
"element",
"in",
"split_settings",
"thus",
"recreating",
"the",
"splitter",
"panels",
"from",
"the",
"saved",
"state",
".",
"split",
"()",
"also",
"clones",
"the",
"editorstack",
"which",
"is",
"then",
"iterated",
"over",
"to",
"restore",
"the",
"saved",
"line",
"numbers",
"on",
"each",
"file",
".",
"The",
"size",
"and",
"positioning",
"of",
"each",
"splitter",
"panel",
"is",
"restored",
"from",
"hexstate",
".",
"Args",
":",
"settings",
":",
"A",
"dictionary",
"with",
"keys",
"{",
"hexstate",
"sizes",
"orientation",
"}",
"that",
"define",
"the",
"layout",
"for",
"the",
"EditorSplitter",
"panels",
".",
"dont_goto",
":",
"Defaults",
"to",
"None",
"which",
"positions",
"the",
"cursor",
"to",
"the",
"end",
"of",
"the",
"editor",
".",
"If",
"there",
"s",
"a",
"value",
"positions",
"the",
"cursor",
"on",
"the",
"saved",
"line",
"number",
"for",
"each",
"editor",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2726-L2780 | train |
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",
"actions",
"==",
"self",
".",
"toolbars",
"and",
"view_menu",
":",
"toolbars",
"=",
"[",
"]",
"for",
"toolbar",
"in",
"self",
".",
"toolbars",
":",
"action",
"=",
"toolbar",
".",
"toggleViewAction",
"(",
")",
"toolbars",
".",
"append",
"(",
"action",
")",
"add_actions",
"(",
"view_menu",
",",
"toolbars",
")"
] | 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 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorMainWindow.load_toolbars | def load_toolbars(self):
"""Loads the last visible toolbars from the .ini file."""
toolbars_names = CONF.get('main', 'last_visible_toolbars', default=[])
if toolbars_names:
dic = {}
for toolbar in self.toolbars:
dic[toolbar.objectName()] = toolbar
toolbar.toggleViewAction().setChecked(False)
toolbar.setVisible(False)
for name in toolbars_names:
if name in dic:
dic[name].toggleViewAction().setChecked(True)
dic[name].setVisible(True) | python | def load_toolbars(self):
"""Loads the last visible toolbars from the .ini file."""
toolbars_names = CONF.get('main', 'last_visible_toolbars', default=[])
if toolbars_names:
dic = {}
for toolbar in self.toolbars:
dic[toolbar.objectName()] = toolbar
toolbar.toggleViewAction().setChecked(False)
toolbar.setVisible(False)
for name in toolbars_names:
if name in dic:
dic[name].toggleViewAction().setChecked(True)
dic[name].setVisible(True) | [
"def",
"load_toolbars",
"(",
"self",
")",
":",
"toolbars_names",
"=",
"CONF",
".",
"get",
"(",
"'main'",
",",
"'last_visible_toolbars'",
",",
"default",
"=",
"[",
"]",
")",
"if",
"toolbars_names",
":",
"dic",
"=",
"{",
"}",
"for",
"toolbar",
"in",
"self",
".",
"toolbars",
":",
"dic",
"[",
"toolbar",
".",
"objectName",
"(",
")",
"]",
"=",
"toolbar",
"toolbar",
".",
"toggleViewAction",
"(",
")",
".",
"setChecked",
"(",
"False",
")",
"toolbar",
".",
"setVisible",
"(",
"False",
")",
"for",
"name",
"in",
"toolbars_names",
":",
"if",
"name",
"in",
"dic",
":",
"dic",
"[",
"name",
"]",
".",
"toggleViewAction",
"(",
")",
".",
"setChecked",
"(",
"True",
")",
"dic",
"[",
"name",
"]",
".",
"setVisible",
"(",
"True",
")"
] | Loads the last visible toolbars from the .ini file. | [
"Loads",
"the",
"last",
"visible",
"toolbars",
"from",
"the",
".",
"ini",
"file",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2940-L2952 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/editor.py | EditorMainWindow.resizeEvent | def resizeEvent(self, event):
"""Reimplement Qt method"""
if not self.isMaximized() and not self.isFullScreen():
self.window_size = self.size()
QMainWindow.resizeEvent(self, event) | python | def resizeEvent(self, event):
"""Reimplement Qt method"""
if not self.isMaximized() and not self.isFullScreen():
self.window_size = self.size()
QMainWindow.resizeEvent(self, event) | [
"def",
"resizeEvent",
"(",
"self",
",",
"event",
")",
":",
"if",
"not",
"self",
".",
"isMaximized",
"(",
")",
"and",
"not",
"self",
".",
"isFullScreen",
"(",
")",
":",
"self",
".",
"window_size",
"=",
"self",
".",
"size",
"(",
")",
"QMainWindow",
".",
"resizeEvent",
"(",
"self",
",",
"event",
")"
] | Reimplement Qt method | [
"Reimplement",
"Qt",
"method"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L2954-L2958 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.