From c007f1197e2b030e22fbaf1635315b0d5a58aa66 Mon Sep 17 00:00:00 2001 From: Sören Tempel Date: Sat, 29 May 2021 13:10:19 +0200 Subject: Limit amount of lines stored in buffer using command-line flag --- TODO.txt | 3 --- saneterm/__main__.py | 4 +++- saneterm/terminal.py | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/TODO.txt b/TODO.txt index 525704a..c6b1ed3 100644 --- a/TODO.txt +++ b/TODO.txt @@ -7,6 +7,3 @@ * 9term-like file name completions using ctrl+f * Support of a ctrl+l screen clear feature and/or scrolling beyond th end of the buffer like 9term supports -* Limit total amount of lines stored in buffer, should also fix - issue with GtkTextView going black if too many lines have - accumulated diff --git a/saneterm/__main__.py b/saneterm/__main__.py index ee71ca3..9764bb5 100644 --- a/saneterm/__main__.py +++ b/saneterm/__main__.py @@ -8,6 +8,8 @@ def get_parser(): default_cmd = os.environ["SHELL"] if "SHELL" in os.environ else "sh" parser = argparse.ArgumentParser() + parser.add_argument('-l', metavar='LIMIT', type=int, + default=5000, help='Amount of lines to store in scroback buffer') parser.add_argument('command', metavar='CMD', type=str, nargs='*', default=[default_cmd], help='Command to execute (defaults to $SHELL)') @@ -17,7 +19,7 @@ def main(): parser = get_parser() args = parser.parse_args() - win = Terminal(args.command) + win = Terminal(args.command, args.l) win.connect("destroy", Gtk.main_quit) win.show_all() Gtk.main() diff --git a/saneterm/terminal.py b/saneterm/terminal.py index 2fc92b2..7ff85ac 100644 --- a/saneterm/terminal.py +++ b/saneterm/terminal.py @@ -60,7 +60,7 @@ class Terminal(Gtk.Window): 'wordwrap': True, } - def __init__(self, cmd): + def __init__(self, cmd, limit): Gtk.Window.__init__(self, title=NAME) self.set_name(NAME) @@ -71,7 +71,7 @@ class Terminal(Gtk.Window): self.pty.set_callback(self.handle_pty) self.pty.attach(None) - self.termview = TermView() + self.termview = TermView(limit) # Block-wise reading from the PTY requires an incremental decoder. self.decoder = codecs.getincrementaldecoder('UTF-8')() -- cgit 1.4.1