Source

thg-qt-mq / logwidget-truncate.diff

# HG changeset patch
# Parent 43053ebafc45bb6b3b282d7423dcf36b7f108830
diff --git a/tortoisehg/hgqt/qtlib.py b/tortoisehg/hgqt/qtlib.py
--- a/tortoisehg/hgqt/qtlib.py
+++ b/tortoisehg/hgqt/qtlib.py
@@ -538,6 +538,7 @@ class LogWidget(QsciScintilla):
         self.append(msg)
         self._setmarker(xrange(self.lines() - unicode(msg).count('\n') - 1,
                                self.lines() - 1), label)
+        self._truncate()
         self.setCursorPosition(self.lines() - 1, 0)
 
     def _setmarker(self, lines, label):
@@ -549,6 +550,15 @@ class LogWidget(QsciScintilla):
         return iter(self._markers[l] for l in str(label).split()
                     if l in self._markers)
 
+    def _truncate(self):
+        self._maxlines = 5
+        if self.lines() > self._maxlines:
+            self.setReadOnly(False)
+            self.setSelection(0, 0, self.lines() - self._maxlines, 0)
+            print self.getSelection()
+            self.removeSelectedText()
+            self.setReadOnly(True)
+
 class SharedWidget(QWidget):
     """Share a single widget by many parents