'Load a text file
editorwindow: load in this editorwindow (useful when clicking on
outline explorer with multiple editor windows)
processevents: determines if processEvents() should be called at the
end of this method (set to False to prevent keyboard events from
creeping through to the editor during debugging)'

@Slot()
@Slot(str)
@Slot(str, int, str)
@Slot(str, int, str, object)
def load(self, filenames=None, goto=None, word='', editorwindow=None, processevents=True):

    editor0 = self.get_current_editor()
    if (editor0 is not None):
        position0 = editor0.get_position('cursor')
        filename0 = self.get_current_filename()
    else:
        (position0, filename0) = (None, None)
    if (not filenames):
        action = self.sender()
        if isinstance(action, QAction):
            filenames = from_qvariant(action.data(), to_text_string)
    if (not filenames):
        basedir = getcwd()
        if (self.edit_filetypes is None):
            self.edit_filetypes = get_edit_filetypes()
        if (self.edit_filters is None):
            self.edit_filters = get_edit_filters()
        c_fname = self.get_current_filename()
        if ((c_fname is not None) and (c_fname != self.TEMPFILE_PATH)):
            basedir = osp.dirname(c_fname)
        self.redirect_stdio.emit(False)
        parent_widget = self.get_current_editorstack()
        if (filename0 is not None):
            selectedfilter = get_filter(self.edit_filetypes, osp.splitext(filename0)[1])
        else:
            selectedfilter = ''
        if (not PYTEST):
            (filenames, _sf) = getopenfilenames(parent_widget, _('Open    file'), basedir, self.edit_filters, selectedfilter=selectedfilter, options=QFileDialog.HideNameFilterDetails)
        else:
            dialog = QFileDialog(parent_widget, _('Open    file'), options=QFileDialog.DontUseNativeDialog)
            if dialog.exec_():
                filenames = dialog.selectedFiles()
        self.redirect_stdio.emit(True)
        if filenames:
            filenames = [osp.normpath(fname) for fname in filenames]
        else:
            return
    focus_widget = QApplication.focusWidget()
    if (self.dockwidget and (not self.ismaximized) and ((not self.dockwidget.isAncestorOf(focus_widget)) and (not isinstance(focus_widget, CodeEditor)))):
        self.dockwidget.setVisible(True)
        self.dockwidget.setFocus()
        self.dockwidget.raise_()
    def _convert(fname):
        fname = osp.abspath(encoding.to_unicode_from_fs(fname))
        if ((os.name == 'nt') and (len(fname) >= 2) and (fname[1] == ':')):
            fname = (fname[0].upper() + fname[1:])
        return fname
    if hasattr(filenames, 'replaceInStrings'):
        filenames = list(filenames)
    if (not isinstance(filenames, list)):
        filenames = [_convert(filenames)]
    else:
        filenames = [_convert(fname) for fname in list(filenames)]
    if isinstance(goto, int):
        goto = [goto]
    elif ((goto is not None) and (len(goto) != len(filenames))):
        goto = None
    for (index, filename) in enumerate(filenames):
        if (index == 0):
            focus = True
        else:
            focus = False
        current_editor = self.set_current_filename(filename, editorwindow, focus=focus)
        if (current_editor is None):
            if (not osp.isfile(filename)):
                continue
            current_es = self.get_current_editorstack(editorwindow)
            finfo = self.editorstacks[0].load(filename, set_current=False)
            finfo.path = self.main.get_spyder_pythonpath()
            self._clone_file_everywhere(finfo)
            current_editor = current_es.set_current_filename(filename, focus=focus)
            current_editor.set_breakpoints(load_breakpoints(filename))
            self.register_widget_shortcuts(current_editor)
            current_es.analyze_script()
            self.__add_recent_file(filename)
        if (goto is not None):
            current_editor.go_to_line(goto[index], word=word)
            position = current_editor.get_position('cursor')
            self.cursor_moved(filename0, position0, filename, position)
        current_editor.clearFocus()
        current_editor.setFocus()
        current_editor.window().raise_()
        if processevents:
            QApplication.processEvents()
