summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2020-03-15 19:58:10 +0100
committerPaweł Redman <pawel.redman@gmail.com>2020-03-15 19:58:10 +0100
commitd9e323fd4f7ee4cae48bd786f94dd3ca6e2a800b (patch)
tree02db8fca50d1ba7a3d939fb01eeaca96388c862c
parent5f2a1d0f398a7159430b2bd877e91e020df5c76f (diff)
Following (automatic scrolling)
-rw-r--r--rcon.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/rcon.py b/rcon.py
index 3df49ab..0185f12 100644
--- a/rcon.py
+++ b/rcon.py
@@ -20,12 +20,24 @@ class JournalViewer:
self.root = self.list_box
self.proc = None
+ self.following = True
+
+ # FIXME: call this whenever the user scrolls through the log
+ def update(self):
+ lc = len(self.list_walker)
+
+ if self.following:
+ self.list_box.set_focus(lc - 1)
+
+ self.status.set_text("%d/%d line%s, [F]ollow: %s" % (
+ self.list_box.focus_position + 1,
+ lc, "" if lc == 1 else "s",
+ "on" if self.following else "off"))
+
def write(self, text):
for line in str(text).split("\n"):
self.list_walker.append(urwid.Text(line))
-
- lc = len(self.list_walker)
- self.status.set_text("%d line%s" % (lc, "" if lc == 1 else "s"))
+ self.update()
def proc_open(self, argv):
if self.proc is not None:
@@ -129,6 +141,9 @@ class Console:
command = self.edit.get_edit_text()
self.edit.set_edit_text("")
self.execute(command)
+ elif text == "f":
+ self.viewer.following = not self.viewer.following
+ self.viewer.update()
def select_server(self, server):
self.server = server