about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSören Tempel <soeren+git@soeren-tempel.net>2021-05-29 13:10:19 +0200
committerSören Tempel <soeren+git@soeren-tempel.net>2021-05-29 13:10:19 +0200
commitc007f1197e2b030e22fbaf1635315b0d5a58aa66 (patch)
tree626fd2d87ccf6536451ca03ca77ff0dac9516af0
parent1ac38d76ad55f8438e9871925fbdec25a14a7069 (diff)
Limit amount of lines stored in buffer using command-line flag
-rw-r--r--TODO.txt3
-rw-r--r--saneterm/__main__.py4
-rw-r--r--saneterm/terminal.py4
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')()