From 6e6150b05185f476019256605a9f2421849a3f3a Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Thu, 11 Oct 2012 23:37:26 -0700 Subject: [PATCH] Limit scrollback buffer size. --- apps/modes_gui | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/modes_gui b/apps/modes_gui index 0c0de85..d9bbbea 100755 --- a/apps/modes_gui +++ b/apps/modes_gui @@ -324,6 +324,13 @@ class mainwindow(QtGui.QMainWindow): #slot to catch signal emitted by output_live_data (necessary for #thread safety since output_live_data is called by another thread) def on_append_live_data(self, msgstr): + #limit scrollback buffer size -- is there a faster way? + if(self.ui.text_livedata.document().lineCount() > 500): + cursor = self.ui.text_livedata.textCursor() + cursor.movePosition(QtGui.QTextCursor.Start) + cursor.select(QtGui.QTextCursor.LineUnderCursor) + cursor.removeSelectedText() + self.ui.text_livedata.append(msgstr) self.ui.text_livedata.verticalScrollBar().setSliderPosition(self.ui.text_livedata.verticalScrollBar().maximum())