def edit_file(self, name, syntax): editor = editors.get(name, None) if editor is None: editor = editors[name] = editor_from_syntax(syntax, self.gui.editor_tabs) data = current_container().raw_data(name) self.init_editor(name, editor, data) self.show_editor(name)
def edit_file(self, name, syntax, use_template=None): editor = editors.get(name, None) if editor is None: if use_template is None: data = current_container().raw_data(name) if isbytestring(data) and syntax in { 'html', 'css', 'text', 'xml' }: try: data = data.decode('utf-8') except UnicodeDecodeError: return error_dialog( self.gui, _('Cannot decode'), _('Cannot edit %s as it appears to be in an unknown character encoding' ) % name, show=True) else: data = use_template editor = editors[name] = editor_from_syntax( syntax, self.gui.editor_tabs) self.init_editor(name, editor, data, use_template=bool(use_template)) self.show_editor(name) return editor
def edit_file(self, name, syntax): editor = self.editors.get(name, None) if editor is None: editor = self.editors[name] = editor_from_syntax(syntax, self.gui.editor_tabs) self.gui.central.add_editor(name, editor) c = current_container() editor.load_text(c.decode(c.open(name).read())) self.gui.central.show_editor(editor)
def edit_file(self, name, syntax, use_template=None): editor = editors.get(name, None) if editor is None: editor = editors[name] = editor_from_syntax(syntax, self.gui.editor_tabs) if use_template is None: data = current_container().raw_data(name) else: data = use_template self.init_editor(name, editor, data, use_template=bool(use_template)) self.show_editor(name) return editor
def edit_file(self, name, syntax, use_template=None): editor = editors.get(name, None) if editor is None: if use_template is None: data = current_container().raw_data(name) if isbytestring(data) and syntax in {'html', 'css', 'text', 'xml'}: try: data = data.decode('utf-8') except UnicodeDecodeError: return error_dialog(self.gui, _('Cannot decode'), _( 'Cannot edit %s as it appears to be in an unknown character encoding') % name, show=True) else: data = use_template editor = editors[name] = editor_from_syntax(syntax, self.gui.editor_tabs) self.init_editor(name, editor, data, use_template=bool(use_template)) self.show_editor(name) return editor