def change_directory(self, uri): """Change the current directory in the shell if it is not busy. Args: uri -- The URI of the destination directory. """ if settings.get_enum("default-follow-mode") in (0, 2): return self._path = self._uri_to_path(uri) if self._path == "": return if not self._shell_is_busy(): # Clear any input eraselinekeys = settings.get_string("terminal-erase-line").decode( 'string_escape') self.feed_child(eraselinekeys) # Change directory cdcmd_nonewline = settings.get_string("terminal-change-directory-command") \ % GLib.shell_quote(self._path) cdcmd = "%s\n" % cdcmd_nonewline self.feed_child(cdcmd) # Restore user input restorelinekeys = settings.get_string( "terminal-restore-line").decode('string_escape') self.feed_child(restorelinekeys)
def _on_launcher_created_cb(self, pipeline, launcher): # Set RUSTFLAGS so that we can parse error formats if launcher.getenv('RUSTFLAGS') is None: eq_srcdir = '=' + pipeline.get_srcdir() escaped = GLib.shell_quote(eq_srcdir) flags = '--error-format=short --remap-path-prefix ' + escaped launcher.setenv('RUSTFLAGS', flags, False)
def _paste_filenames_clipboard(self): """Convert URIs from clipboard to paths and paste into VTE.""" clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) if clipboard.wait_is_uris_available(): uris = clipboard.wait_for_uris() for idx, uri in enumerate(uris): path = Gio.file_parse_name(uri).get_path() quoted = GLib.shell_quote(path) self.term.feed_child(quoted, len(quoted)) if idx + 1 != len(uris): self.term.feed_child(" ", 1)
def _paste_filenames_clipboard(self): """Paste to the VTE clipboard, converting URIs to literal filenames first. """ gtkClipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) if gtkClipboard.wait_is_uris_available(): uris = gtkClipboard.wait_for_uris() concatfilenames = "" for idx, uri in enumerate(uris): path = Gio.file_parse_name(uri).get_path() quoted = GLib.shell_quote(path) self.term.feed_child(quoted, len(quoted)) if idx != (len(uris)-1): self.term.feed_child(' ', 1) return
def change_directory(self, uri): """Change the current directory in the shell if it is not busy. Args: uri -- The URI of the destination directory. """ self._path = self._uri_to_path(uri) if not self._shell_is_busy(): # Clear any input eraselinekeys = settings.get_string("terminal-erase-line").decode('string_escape') self.term.feed_child(eraselinekeys, len(eraselinekeys)) # Change directory cdcmd_nonewline = settings.get_string("terminal-change-directory-command") \ % GLib.shell_quote(self._path) cdcmd = "%s\n" % cdcmd_nonewline self.term.feed_child(cdcmd, len(cdcmd)) # Restore user input restorelinekeys = settings.get_string("terminal-restore-line").decode('string_escape') self.term.feed_child(restorelinekeys, len(restorelinekeys))
def change_directory(self, uri): """Change the current directory in the shell if it is not busy. Args: uri -- The URI of the destination directory. """ self._path = self._uri_to_path(uri) if not self._shell_is_busy(): # clear any input erase_line_keys = settings.get_string("terminal-erase-line") erase_line_keys = erase_line_keys.encode().decode("unicode_escape") self.term.feed_child(erase_line_keys, len(erase_line_keys)) # change directory cd_cmd = settings.get_string("terminal-change-directory-command") cd_cmd_nonewline = cd_cmd % GLib.shell_quote(self._path) cd_cmd = "%s\n" % cd_cmd_nonewline self.term.feed_child(cd_cmd, len(cd_cmd)) # restore user input restore_line_keys = settings.get_string("terminal-restore-line") restore_line_keys = restore_line_keys.encode().decode( "unicode_escape") self.term.feed_child(restore_line_keys, len(restore_line_keys))