Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Relaunch command option on held open after child exit #333

Merged
merged 3 commits into from
Dec 28, 2020
Merged
Show file tree
Hide file tree
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
17 changes: 16 additions & 1 deletion terminatorlib/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self):
self.config = Config()
### inactive_color_offset is the opposite of alpha level
self.dim_p = float(self.config['inactive_color_offset'])
self.dim_l = round(1.0 - self.dim_p,3)
self.dim_l = round(1.0 - self.dim_p,3)
def dim(self,b):
self.overpaint = b

Expand Down Expand Up @@ -126,8 +126,11 @@ class Terminal(Gtk.VBox):
custom_encoding = None
custom_font_size = None
layout_command = None
relaunch_command = None
directory = None

is_held_open = False

fgcolor_active = None
bgcolor = None
palette_active = None
Expand Down Expand Up @@ -676,6 +679,8 @@ def reconfigure(self, _widget=None):

if self.config['exit_action'] == 'restart':
self.cnxids.new(self.vte, 'child-exited', self.spawn_child, True)
elif self.config['exit_action'] == 'hold':
self.cnxids.new(self.vte, 'child-exited', self.held_open, True)
elif self.config['exit_action'] in ('close', 'left'):
self.cnxids.new(self.vte, 'child-exited',
lambda x, y: self.emit('close-term'))
Expand Down Expand Up @@ -1429,6 +1434,10 @@ def set_cwd(self, cwd=None):
if cwd is not None:
self.cwd = cwd

def held_open(self, widget=None, respawn=False, debugserver=False):
self.is_held_open = True
self.titlebar.update()

def spawn_child(self, widget=None, respawn=False, debugserver=False):
args = []
shell = None
Expand All @@ -1441,13 +1450,19 @@ def spawn_child(self, widget=None, respawn=False, debugserver=False):
if respawn == False:
self.vte.grab_focus()

self.is_held_open = False

options = self.config.options_get()
if options and options.command:
command = options.command
self.relaunch_command = command
options.command = None
elif options and options.execute:
command = options.execute
self.relaunch_command = command
options.execute = None
elif self.relaunch_command:
command = self.relaunch_command
elif self.config['use_custom_command']:
command = self.config['custom_command']
elif self.layout_command:
Expand Down
6 changes: 6 additions & 0 deletions terminatorlib/terminal_popup_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ def show(self, widget, event=None):
menu.append(item)
menu.append(Gtk.SeparatorMenuItem())

if terminal.is_held_open:
item = Gtk.MenuItem.new_with_mnemonic(_('Relaunch Command'))
item.connect('activate', lambda x: terminal.spawn_child())
menu.append(item)
menu.append(Gtk.SeparatorMenuItem())

item = Gtk.CheckMenuItem.new_with_mnemonic(_('Show _scrollbar'))
item.set_active(terminal.scrollbar.get_property('visible'))
item.connect('toggled', lambda x: terminal.do_scrollbar_toggle())
Expand Down
13 changes: 9 additions & 4 deletions terminatorlib/titlebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,15 @@ def connect_icon(self, func):
def update(self, other=None):
"""Update our contents"""
default_bg = False
if self.config['title_hide_sizetext']:
self.label.set_text("%s" % self.termtext)
else:
self.label.set_text("%s %s" % (self.termtext, self.sizetext))

temp_heldtext_str = ''
temp_sizetext_str = ''

if self.terminal.is_held_open:
temp_heldtext_str = _('[INACTIVE: Right-Click for Relaunch option] ')
if not self.config['title_hide_sizetext']:
temp_sizetext_str = " %s" % (self.sizetext)
self.label.set_text("%s%s%s" % (temp_heldtext_str, self.termtext, temp_sizetext_str))

if (not self.config['title_use_system_font']) and self.config['title_font']:
title_font = Pango.FontDescription(self.config['title_font'])
Expand Down