Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/Widgets/Terminal.vala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ public class Code.Terminal : Gtk.Box {
}

terminal.child_exited.connect (() => {
GLib.Application.get_default ().activate_action (Scratch.MainWindow.ACTION_PREFIX + Scratch.MainWindow.ACTION_TOGGLE_TERMINAL, null);
//Hide the exited terminal
var win_group = get_action_group (Scratch.MainWindow.ACTION_GROUP);
win_group.activate_action (Scratch.MainWindow.ACTION_TOGGLE_TERMINAL, null);
//Get ready to resume at last saved location
spawn_shell (Scratch.saved_state.get_string ("last-opened-path"));
//Clear screen of new shell
terminal.feed_child ("clear -x\n".data);
});

var copy_action = new SimpleAction (ACTION_COPY, null);
Expand Down Expand Up @@ -89,16 +95,15 @@ public class Code.Terminal : Gtk.Box {
copy_action.set_enabled (terminal.get_has_selection ());
});

var settings = new Settings (Constants.PROJECT_NAME + ".saved-state");
spawn_shell (settings.get_string ("last-opened-path"));
spawn_shell (Scratch.saved_state.get_string ("last-opened-path"));

var scrolled_window = new Gtk.ScrolledWindow (null, terminal.get_vadjustment ());
scrolled_window.add (terminal);

add (scrolled_window);

destroy.connect (() => {
settings.set_string ("last-opened-path", get_shell_location ());
Scratch.saved_state.set_string ("last-opened-path", get_shell_location ());
});

show_all ();
Expand All @@ -125,6 +130,7 @@ public class Code.Terminal : Gtk.Box {
Posix.kill (child_pid, Posix.Signal.TERM);
terminal.reset (true, true);
spawn_shell (dir);
Scratch.saved_state.set_string ("last-opened-path", dir);
}

private string get_shell_location () {
Expand Down