mirror of
https://github.com/markqvist/NomadNet.git
synced 2025-01-27 14:47:02 -05:00
Terminate log tail when view is inactive
This commit is contained in:
parent
691f4df098
commit
910e527cc7
@ -12,11 +12,22 @@ class LogDisplay():
|
|||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
import urwid
|
import urwid
|
||||||
self.app = app
|
self.app = app
|
||||||
self.log_term = LogTerminal(self.app)
|
self.log_term = None
|
||||||
|
|
||||||
self.shortcuts_display = LogDisplayShortcuts(self.app)
|
self.shortcuts_display = LogDisplayShortcuts(self.app)
|
||||||
|
self.widget = None
|
||||||
|
|
||||||
|
def show(self):
|
||||||
|
if self.log_term == None:
|
||||||
|
self.log_term = LogTerminal(self.app)
|
||||||
self.widget = urwid.LineBox(self.log_term)
|
self.widget = urwid.LineBox(self.log_term)
|
||||||
|
|
||||||
|
def kill(self):
|
||||||
|
if self.log_term != None:
|
||||||
|
self.log_term.terminate()
|
||||||
|
self.log_term = None
|
||||||
|
self.widget = None
|
||||||
|
|
||||||
def shortcuts(self):
|
def shortcuts(self):
|
||||||
return self.shortcuts_display
|
return self.shortcuts_display
|
||||||
|
|
||||||
@ -26,10 +37,14 @@ class LogTerminal(urwid.WidgetWrap):
|
|||||||
self.log_term = urwid.Terminal(
|
self.log_term = urwid.Terminal(
|
||||||
("tail", "-fn50", self.app.logfilepath),
|
("tail", "-fn50", self.app.logfilepath),
|
||||||
encoding='utf-8',
|
encoding='utf-8',
|
||||||
escape_sequence="up"
|
escape_sequence="up",
|
||||||
|
main_loop=self.app.ui.loop,
|
||||||
)
|
)
|
||||||
urwid.WidgetWrap.__init__(self, self.log_term)
|
urwid.WidgetWrap.__init__(self, self.log_term)
|
||||||
|
|
||||||
|
def terminate(self):
|
||||||
|
self.log_term.terminate()
|
||||||
|
|
||||||
|
|
||||||
def keypress(self, size, key):
|
def keypress(self, size, key):
|
||||||
if key == "up":
|
if key == "up":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user