diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2020-03-15 19:58:10 +0100 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2020-03-15 19:58:10 +0100 |
commit | d9e323fd4f7ee4cae48bd786f94dd3ca6e2a800b (patch) | |
tree | 02db8fca50d1ba7a3d939fb01eeaca96388c862c /rcon.py | |
parent | 5f2a1d0f398a7159430b2bd877e91e020df5c76f (diff) |
Following (automatic scrolling)
Diffstat (limited to 'rcon.py')
-rw-r--r-- | rcon.py | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -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 |