Creates a new editor file.

        :return: File name.
        :rtype: unicode
963190
def new_file(self):
        

        file = self.get_untitled_file_name()
        LOGGER.debug("> Creating '{0}' file.".format(file))
        self.set_file(file, is_modified=False, is_untitled=True)
        self.__set_document_signals()
        return file
41157
def do_edit(self, arg):
        ""
        if arg == '':
            filename, lineno = self._get_current_position()
        else:
            filename, lineno, _ = self._get_position_of_arg(arg)
            if filename is None:
                return
        # this case handles code generated with py.code.Source()
        # filename is something like '<0-codegen foo.py:18>'
        match = re.match(r'.*<\d+-codegen (.*):(\d+)>', filename)
        if match:
            filename = match.group(1)
            lineno = int(match.group(2))

        try:
            self._open_editor(self._get_editor_cmd(filename, lineno))
        except Exception as exc:
            self.error(exc)
1001779
def createEditor(self, delegate, parent, option):
        
        return ChoiceCtiEditor(self, delegate, parent=parent)
652854
def createEditor(self, delegate, parent, option):
        
        return IntCtiEditor(self, delegate, parent=parent)
1356275
def save_file(self, file=None):
        

        editor = file and self.get_editor(file) or self.get_current_editor()
        if not editor:
            return False

        LOGGER.info("{0} | Saving '{1}' file!".format(self.__class__.__name__, editor.file))
        self.__lock_editor(editor)
        if not editor.is_untitled and foundations.common.path_exists(editor.file):
            return editor.save_file()
        else:
            return self.save_fileAs()
294240
def create_file(self, fileName, contents=""):
        
        with open(fileName, "w") as written_file:
            written_file.write(contents)
676853
def get_editor(self, file):
        

        for editor in self.__model.list_editors():
            if editor.file == file:
                return editor
720397
def _make_writeable(filename):
    
    import stat
    if sys.platform.startswith('java'):
        # On Jython there is no os.access()
        return
    if not os.access(filename, os.W_OK):
        st = os.stat(filename)
        new_permissions = stat.S_IMODE(st.st_mode) | stat.S_IWUSR
        os.chmod(filename, new_permissions)
108933
def get_editor(self):
		
		env_search = ['EDITOR']
		if 'xml' in self.content_type:
			env_search.insert(0, 'XML_EDITOR')
		default_editor = self.platform_default_editors[sys.platform]
		return self._search_env(env_search) or default_editor
1226330
def do_edit(self, arg, arguments):
        

        def _create_file(filename):
            if not os.path.exists(filename):
                file(filename, 'w+').close()

        def _edit(prefix, editors, filename):
            for editor in editors:
                if os.path.exists(editor):
                    _create_file(filename)
                    os.system("{:} {:} {:}".format(prefix, editor, filename))
                    return True
            return False


        filename = arg

        what =  platform.system().lower()
        prefix = ""

        print (what)
        if 'darwin' in what:

            editors = ["/Applications/Aquamacs.app",
                       "/Applications/Emacs.app"]
            prefix = "open -a "

        elif "linux" in what:

            editors = ["/usr/bin/emacs",
                       "/usr/bin/vi",
                       "/usr/bin/vim",
                       "/usr/bin/nano"]

        elif "windows" in what:

            editors = ["emacs",
                       "vi",
                       "vim",
                       "nano",
                       "notepad",
                       "notepad++"]

        else:
            Console.error("Please contact the developers to add an "
                          "editor for your platform")
            return

        if not _edit(prefix, editors, filename):
            Console.error("Could not find working editor in {0}"
                          .format(str(editors)))
636308
def create_file(self):
        
        src = self.get_current_path()
        name, status = QtWidgets.QInputDialog.getText(
            self.tree_view, _('Create new file'), _('File name:'),
            QtWidgets.QLineEdit.Normal, '')
        if status:
            fatal_names = ['.', '..', os.sep]
            for i in fatal_names:
                if i == name:
                    QtWidgets.QMessageBox.critical(
                        self.tree_view, _("Error"), _("Wrong directory name"))
                    return

            if os.path.isfile(src):
                src = os.path.dirname(src)
            path = os.path.join(src, name)
            try:
                with open(path, 'w'):
                    pass
            except OSError as e:
                QtWidgets.QMessageBox.warning(
                    self.tree_view, _('Failed to create new file'),
                    _('Failed to create file: "%s".\n\n%s') % (path, str(e)))
            else:
                self.tree_view.file_created.emit(os.path.normpath(path))
1029434
def createEditor(self, delegate, parent, option):
        
        return FontChoiceCtiEditor(self, delegate, parent=parent)
935923
def _open_file_in_editor(self, filename):
        
        # If the 'VISUAL' or 'EDITOR' environment variable has been set, use that.
        # Otherwise, fall back to the first available editor that we can find.
        visual = os.environ.get('VISUAL')
        editor = os.environ.get('EDITOR')

        editors = [
            visual,
            editor,

            # Order of preference.
            '/usr/bin/editor',
            '/usr/bin/nano',
            '/usr/bin/pico',
            '/usr/bin/vi',
            '/usr/bin/emacs',
        ]

        for e in editors:
            if e:
                try:
                    # Use 'shlex.split()', because $VISUAL can contain spaces
                    # and quotes.
                    returncode = subprocess.call(shlex.split(e) + [filename])
                    return returncode == 0

                except OSError:
                    # Executable does not exist, try the next one.
                    pass

        return False
882579
def _get_or_create_editor_buffer(self, location=None, text=None):
        
        assert location is None or text is None  # Don't pass two of them.
        assert location is None or isinstance(location, string_types)

        if location is None:
            # Create and add an empty EditorBuffer
            eb = EditorBuffer(self.editor, text=text)
            self._add_editor_buffer(eb)

            return eb
        else:
            # When a location is given, first look whether the file was already
            # opened.
            eb = self.get_editor_buffer_for_location(location)

            # Not found? Create one.
            if eb is None:
                # Create and add EditorBuffer
                eb = EditorBuffer(self.editor, location)
                self._add_editor_buffer(eb)

                return eb
            else:
                # Found! Return it.
                return eb
1805
def create_new_file(help_string=NO_HELP, default=NO_DEFAULT, suffixes=None):
        # type: (str, Union[str, NO_DEFAULT_TYPE], Union[List[str], None]) -> str
        
        # noinspection PyTypeChecker
        return ParamFilename(
            help_string=help_string,
            default=default,
            type_name="new_file",
            suffixes=suffixes,
        )
1045954
def editorValue(self, editor):
        
        value, success = projexui.widgetValue(editor)
        if not success:
            return None
        return value
430555
def save_fileAs(self):
        

        editor = self.get_current_editor()
        if not editor:
            return False

        file = umbra.ui.common.store_last_browsed_path(QFileDialog.getSaveFileName(self, "Save As:", editor.file))
        if not file:
            return False

        candidate_editor = self.get_editor(file)
        if candidate_editor:
            if not candidate_editor is editor:
                raise foundations.exceptions.UserError("{0} | '{1}' file is already opened!".format(
                    self.__class__.__name__, file))
            else:
                return self.save_file(file)

        LOGGER.info("{0} | Saving '{1}' file!".format(self.__class__.__name__, file))
        self.__lock_editor(editor)
        self.unregister_node_path(editor)
        if editor.save_fileAs(file):
            self.__model.update_authoring_nodes(editor)
            language = self.__languages_model.get_file_language(
                file) or self.__languages_model.get_language(self.__default_language)
            if editor.language.name != language.name:
                self.set_language(editor, language)
            return True