Skip to content

Commit

Permalink
auto_close argument
Browse files Browse the repository at this point in the history
  • Loading branch information
randy3k committed Aug 16, 2018
1 parent 73323dd commit ef81a73
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,11 @@ window.run_command(
"env": {}, # extra environmental variables
"title": None, # title of the view
"panel_name": None, # the name of the panel if terminal should be opened in panel
"tag": None, # a tag to identify the terminal
"tag": None, # a tag to idFentify the terminal
"pre_window_hooks": [], # a list of window hooks before opening terminal
"post_window_hooks": [] # a list of window hooks after opening terminal
"post_view_hooks": [] # a list of view hooks after opening terminal
"post_window_hooks": [], # a list of window hooks after opening terminal
"post_view_hooks": [], # a list of view hooks after opening terminal
"auto_close": True # auto close terminal if process exits successfully
}
)
```
Expand Down
6 changes: 4 additions & 2 deletions terminus/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ def run(
tag=None,
pre_window_hooks=[],
post_window_hooks=[],
post_view_hooks=[]):
post_view_hooks=[],
auto_close=True):
config = None

st_vars = self.window.extract_variables()
Expand Down Expand Up @@ -182,7 +183,8 @@ def run(
"env": _env,
"title": title,
"panel_name": panel_name,
"tag": tag
"tag": tag,
"auto_close": auto_close
}))

if panel_name:
Expand Down
8 changes: 6 additions & 2 deletions terminus/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,13 @@ def renderer():

threading.Thread(target=renderer).start()

def open(self, cmd, cwd=None, env=None, title=None, offset=0, panel_name=None, tag=None):
def open(
self, cmd, cwd=None, env=None, title=None, offset=0,
panel_name=None, tag=None, auto_close=True):

self.panel_name = panel_name
self.tag = tag
self.auto_close = auto_close
self.set_title(title)
self.offset = offset
self.viewport = (0, self.view.text_to_layout(self.view.text_point(offset, 0))[1])
Expand Down Expand Up @@ -172,7 +176,7 @@ def cleanup(self):
self.process.exitstatus)}),
self.view.set_read_only(True)

if self.process.exitstatus == 0:
if self.process.exitstatus == 0 and self.auto_close:
if self.panel_name:
window = self.view.window()
if window:
Expand Down

0 comments on commit ef81a73

Please sign in to comment.