INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
Find next occurrence | def find_next(self):
"""Find next occurrence"""
state = self.find(changed=False, forward=True, rehighlight=False,
multiline_replace_check=False)
self.editor.setFocus()
self.search_text.add_current_text()
return state |
Find previous occurrence | def find_previous(self):
"""Find previous occurrence"""
state = self.find(changed=False, forward=False, rehighlight=False,
multiline_replace_check=False)
self.editor.setFocus()
return state |
Find text has been edited (this slot won't be triggered when
setting the search pattern combo box text programmatically) | def text_has_been_edited(self, text):
"""Find text has been edited (this slot won't be triggered when
setting the search pattern combo box text programmatically)"""
self.find(changed=True, forward=True, start_highlight_timer=True) |
Highlight found results | def highlight_matches(self):
"""Highlight found results"""
if self.is_code_editor and self.highlight_button.isChecked():
text = self.search_text.currentText()
words = self.words_button.isChecked()
regexp = self.re_button.isChecked()
self.editor.highl... |
Call the find function | def find(self, changed=True, forward=True,
rehighlight=True, start_highlight_timer=False, multiline_replace_check=True):
"""Call the find function"""
# When several lines are selected in the editor and replace box is activated,
# dynamic search is deactivated to prevent changin... |
Replace and find | def replace_find(self, focus_replace_text=False, replace_all=False):
"""Replace and find"""
if (self.editor is not None):
replace_text = to_text_string(self.replace_text.currentText())
search_text = to_text_string(self.search_text.currentText())
re_pattern = None... |
Replace and find in the current selection | def replace_find_selection(self, focus_replace_text=False):
"""Replace and find in the current selection"""
if self.editor is not None:
replace_text = to_text_string(self.replace_text.currentText())
search_text = to_text_string(self.search_text.currentText())
cas... |
Change number of match and total matches. | def change_number_matches(self, current_match=0, total_matches=0):
"""Change number of match and total matches."""
if current_match and total_matches:
matches_string = u"{} {} {}".format(current_match, _(u"of"),
total_matches)
s... |
Monkey patching rope
See [1], [2], [3], [4] and [5] in module docstring. | def apply():
"""Monkey patching rope
See [1], [2], [3], [4] and [5] in module docstring."""
from spyder.utils.programs import is_module_installed
if is_module_installed('rope', '<0.9.4'):
import rope
raise ImportError("rope %s can't be patched" % rope.VERSION)
# [1] Patchi... |
Override Qt method. | def paintEvent(self, event):
"""Override Qt method."""
painter = QPainter(self)
color = QColor(self.color)
color.setAlphaF(.5)
painter.setPen(color)
offset = self.editor.document().documentMargin() + \
self.editor.contentOffset().x()
for _, line_numb... |
Return a list of actions related to plugin | def get_plugin_actions(self):
"""Return a list of actions related to plugin"""
return [self.rich_text_action, self.plain_text_action,
self.show_source_action, MENU_SEPARATOR,
self.auto_import_action] |
Register plugin in Spyder's main window | def register_plugin(self):
"""Register plugin in Spyder's main window"""
self.focus_changed.connect(self.main.plugin_focus_changed)
self.main.add_dockwidget(self)
self.main.console.set_help(self)
self.internal_shell = self.main.console.shell
self.console = self.ma... |
Refresh widget | def refresh_plugin(self):
"""Refresh widget"""
if self._starting_up:
self._starting_up = False
self.switch_to_rich_text()
self.show_intro_message() |
Update font from Preferences | def update_font(self):
"""Update font from Preferences"""
color_scheme = self.get_color_scheme()
font = self.get_plugin_font()
rich_font = self.get_plugin_font(rich_text=True)
self.set_plain_text_font(font, color_scheme=color_scheme)
self.set_rich_text_font(rich_f... |
Apply configuration file's plugin settings | def apply_plugin_settings(self, options):
"""Apply configuration file's plugin settings"""
color_scheme_n = 'color_scheme_name'
color_scheme_o = self.get_color_scheme()
connect_n = 'connect_to_oi'
wrap_n = 'wrap'
wrap_o = self.get_option(wrap_n)
self.wrap_a... |
Set rich text mode font | def set_rich_text_font(self, font):
"""Set rich text mode font"""
self.rich_text.set_font(font, fixed_font=self.get_plugin_font()) |
Set plain text mode font | def set_plain_text_font(self, font, color_scheme=None):
"""Set plain text mode font"""
self.plain_text.set_font(font, color_scheme=color_scheme) |
Toggle wrap mode | def toggle_wrap_mode(self, checked):
"""Toggle wrap mode"""
self.plain_text.editor.toggle_wrap_mode(checked)
self.set_option('wrap', checked) |
Switch to plain text mode | def switch_to_plain_text(self):
"""Switch to plain text mode"""
self.rich_help = False
self.plain_text.show()
self.rich_text.hide()
self.plain_text_action.setChecked(True) |
Switch to rich text mode | def switch_to_rich_text(self):
"""Switch to rich text mode"""
self.rich_help = True
self.plain_text.hide()
self.rich_text.show()
self.rich_text_action.setChecked(True)
self.show_source_action.setChecked(False) |
Set plain text docs | def set_plain_text(self, text, is_code):
"""Set plain text docs"""
# text is coming from utils.dochelpers.getdoc
if type(text) is dict:
name = text['name']
if name:
rst_title = ''.join(['='*len(name), '\n', name, '\n',
... |
Set rich text | def set_rich_text_html(self, html_text, base_url):
"""Set rich text"""
self.rich_text.set_html(html_text, base_url)
self.save_text([self.rich_text.set_html, html_text, base_url]) |
Show text in rich mode | def show_rich_text(self, text, collapse=False, img_path=''):
"""Show text in rich mode"""
self.switch_to_plugin()
self.switch_to_rich_text()
context = generate_context(collapse=collapse, img_path=img_path,
css_path=self.css_path)
self.rend... |
Show text in plain mode | def show_plain_text(self, text):
"""Show text in plain mode"""
self.switch_to_plugin()
self.switch_to_plain_text()
self.set_plain_text(text, is_code=False) |
Show the Spyder tutorial in the Help plugin, opening it if needed | def show_tutorial(self):
"""Show the Spyder tutorial in the Help plugin, opening it if needed"""
self.switch_to_plugin()
tutorial_path = get_module_source_path('spyder.plugins.help.utils')
tutorial = osp.join(tutorial_path, 'tutorial.rst')
text = open(tutorial).read()
... |
Set object analyzed by Help | def set_object_text(self, text, force_refresh=False, ignore_unknown=False):
"""Set object analyzed by Help"""
if (self.locked and not force_refresh):
return
self.switch_to_console_source()
add_to_combo = True
if text is None:
text = to_text_string... |
Use the help plugin to show docstring dictionary computed
with introspection plugin from the Editor plugin | def set_editor_doc(self, doc, force_refresh=False):
"""
Use the help plugin to show docstring dictionary computed
with introspection plugin from the Editor plugin
"""
if (self.locked and not force_refresh):
return
self.switch_to_editor_source()
... |
Load history from a text file in user home directory | def load_history(self, obj=None):
"""Load history from a text file in user home directory"""
if osp.isfile(self.LOG_PATH):
history = [line.replace('\n', '')
for line in open(self.LOG_PATH, 'r').readlines()]
else:
history = []
return h... |
Save history to a text file in user home directory | def save_history(self):
"""Save history to a text file in user home directory"""
# Don't fail when saving search history to disk
# See issues 8878 and 6864
try:
search_history = [to_text_string(self.combo.itemText(index))
for index in range... |
Toggle plain text docstring | def toggle_plain_text(self, checked):
"""Toggle plain text docstring"""
if checked:
self.docstring = checked
self.switch_to_plain_text()
self.force_refresh()
self.set_option('rich_mode', not checked) |
Toggle show source code | def toggle_show_source(self, checked):
"""Toggle show source code"""
if checked:
self.switch_to_plain_text()
self.docstring = not checked
self.force_refresh()
self.set_option('rich_mode', not checked) |
Toggle between sphinxified docstrings or plain ones | def toggle_rich_text(self, checked):
"""Toggle between sphinxified docstrings or plain ones"""
if checked:
self.docstring = not checked
self.switch_to_rich_text()
self.set_option('rich_mode', checked) |
Toggle automatic import feature | def toggle_auto_import(self, checked):
"""Toggle automatic import feature"""
self.combo.validate_current_text()
self.set_option('automatic_import', checked)
self.force_refresh() |
Update locked state icon | def _update_lock_icon(self):
"""Update locked state icon"""
icon = ima.icon('lock') if self.locked else ima.icon('lock_open')
self.locked_button.setIcon(icon)
tip = _("Unlock") if self.locked else _("Lock")
self.locked_button.setToolTip(tip) |
Return shell which is currently bound to Help,
or another running shell if it has been terminated | def get_shell(self):
"""
Return shell which is currently bound to Help,
or another running shell if it has been terminated
"""
if (not hasattr(self.shell, 'get_doc') or
(hasattr(self.shell, 'is_running') and
not self.shell.is_running())):
... |
Transform doc string dictionary to HTML and show it | 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.dirnam... |
Set our sphinx documentation based on thread result | 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)) |
Display error message on Sphinx rich text failure | 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,
_(... |
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 \
... |
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 | 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 =... |
Select the entire line but starts at the first non whitespace character
and stops at the non-whitespace character.
:return: | 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(te... |
Underlines the text.
:param color: underline color. | def set_as_underlined(self, color=Qt.blue):
"""
Underlines the text.
:param color: underline color.
"""
self.format.setUnderlineStyle(
QTextCharFormat.SingleUnderline)
self.format.setUnderlineColor(color) |
Underlines text as a spellcheck error.
:param color: Underline color
:type color: QtGui.QColor | 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... |
Highlights text as a syntax error.
:param color: Underline color
:type color: QtGui.QColor | 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) |
Highlights text as a syntax warning.
:param color: Underline color
:type color: QtGui.QColor | 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) |
Run analysis | def run(self):
"""Run analysis"""
try:
self.results = self.checker(self.source_code)
except Exception as e:
logger.error(e, exc_info=True) |
Close threads associated to parent_id | 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.sta... |
Add thread to queue | 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))
logg... |
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... |
Editor's text has 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')) |
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) |
Set TODO results and update markers in editor | def set_todo_results(self, results):
"""Set TODO results and update markers in editor"""
self.todo_results = results
self.editor.process_todo(results) |
Bookmarks list has 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)) |
Update list of corresponpding ids and tabs. | 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())] |
Remove editors that are not longer open. | 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) |
Insert the widget (at tab index) in the position i (index). | 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) |
Remove the widget at the corresponding tab_index. | 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) |
Remove previous entrances of a tab, and add it as the latest. | 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) |
Fill ListWidget with the tabs texts.
Add elements in inverse order of stack_history. | 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(i... |
Change to the selected document and hide this widget. | 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 IndexErro... |
Move selected row a number of steps.
Iterates in a cyclic behaviour. | 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) |
Positions the tab switcher in the top-center of the editor. | 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))) |
Reimplement Qt method.
Handle "most recent used" tab behavior,
When ctrl is released and tab_switcher is visible, tab will be changed. | 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')
... |
Reimplement Qt method to allow cyclic behavior. | 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) |
Reimplement Qt method to close the widget when loosing focus. | 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... |
Create local 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_c... |
Setup editorstack's layout | 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 = creat... |
Upadte file name 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... |
Overrides QWidget 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:
... |
Clone EditorStack from other instance | 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()) |
Open file list management dialog box | 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_vis... |
Go to line dialog | 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:
... |
Set/clear breakpoint | def set_or_clear_breakpoint(self):
"""Set/clear breakpoint"""
if self.data:
editor = self.get_current_editor()
editor.debugger.toogle_breakpoint() |
Set 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) |
Bookmark current position to given slot. | 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) |
Inspect current object in the Help plugin | 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) |
This method is called separately from 'set_oulineexplorer' to avoid
doing unnecessary updates when there are multiple editor windows | 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._... |
Return tab title. | 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_readonl... |
Return tab menu title | 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 f... |
Setup tab context menu before showing it | 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
... |
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. | 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.... |
Set current filename and return the associated editor instance. | 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].edit... |
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 a... | 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.
... |
Return the position index of a file in the tab bar of the editorstack
from its name. | 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) |
Reorder editorstack.data so it is synchronized with the tab bar when
tabs are moved. | 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 rig... |
Close file (index=None -> close current file)
Keep current file index unchanged (if current file
that is being closed) | 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:
... |
Get list of current opened files' 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) |
Notify language server availability to code editors. | 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) |
Close all files opened to the 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) |
Close all files but the current one | 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) |
Sort open 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)):
... |
Utility function for sort_file_tabs_alphabetically(). | 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 |
Add to last closed file list. | 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) |
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... | 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(... |
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 ... | 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 t... |
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... | 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 stac... |
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.
Fal... | 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... |
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. | 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
... |
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,
... | 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 sele... |
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 chose... | 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 n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.