Просмотр исходного кода

Removed background highlighting in shell.

Juan Pablo Caram 9 лет назад
Родитель
Сommit
05a9e05c97
1 измененных файлов с 22 добавлено и 39 удалено
  1. 22 39
      termwidget.py

+ 22 - 39
termwidget.py

@@ -19,13 +19,13 @@ class _ExpandableTextEdit(QTextEdit):
     historyNext = pyqtSignal()
     historyNext = pyqtSignal()
     historyPrev = pyqtSignal()
     historyPrev = pyqtSignal()
 
 
-    def __init__(self, termWidget, *args):
+    def __init__(self, termwidget, *args):
         QTextEdit.__init__(self, *args)
         QTextEdit.__init__(self, *args)
         self.setStyleSheet("font: 9pt \"Courier\";")
         self.setStyleSheet("font: 9pt \"Courier\";")
         self._fittedHeight = 1
         self._fittedHeight = 1
         self.textChanged.connect(self._fit_to_document)
         self.textChanged.connect(self._fit_to_document)
         self._fit_to_document()
         self._fit_to_document()
-        self._termWidget = termWidget
+        self._termWidget = termwidget
 
 
     def sizeHint(self):
     def sizeHint(self):
         """
         """
@@ -39,10 +39,10 @@ class _ExpandableTextEdit(QTextEdit):
         """
         """
         Update widget height to fit all text
         Update widget height to fit all text
         """
         """
-        documentSize = self.document().size().toSize()
-        self._fittedHeight = documentSize.height() + (self.height() - self.viewport().height())
+        documentsize = self.document().size().toSize()
+        self._fittedHeight = documentsize.height() + (self.height() - self.viewport().height())
         self.setMaximumHeight(self._fittedHeight)
         self.setMaximumHeight(self._fittedHeight)
-        self.updateGeometry();
+        self.updateGeometry()
 
 
     def keyPressEvent(self, event):
     def keyPressEvent(self, event):
         """
         """
@@ -55,26 +55,26 @@ class _ExpandableTextEdit(QTextEdit):
                 return
                 return
         elif event.matches(QKeySequence.MoveToNextLine):
         elif event.matches(QKeySequence.MoveToNextLine):
             text = self.toPlainText()
             text = self.toPlainText()
-            cursorPos = self.textCursor().position()
-            textBeforeEnd = text[cursorPos:]
+            cursor_pos = self.textCursor().position()
+            textBeforeEnd = text[cursor_pos:]
             # if len(textBeforeEnd.splitlines()) <= 1:
             # if len(textBeforeEnd.splitlines()) <= 1:
             if len(textBeforeEnd.split('\n')) <= 1:
             if len(textBeforeEnd.split('\n')) <= 1:
                 self.historyNext.emit()
                 self.historyNext.emit()
                 return
                 return
         elif event.matches(QKeySequence.MoveToPreviousLine):
         elif event.matches(QKeySequence.MoveToPreviousLine):
             text = self.toPlainText()
             text = self.toPlainText()
-            cursorPos = self.textCursor().position()
-            textBeforeStart = text[:cursorPos]
+            cursor_pos = self.textCursor().position()
+            text_before_start = text[:cursor_pos]
             # lineCount = len(textBeforeStart.splitlines())
             # lineCount = len(textBeforeStart.splitlines())
-            lineCount = len(textBeforeStart.split('\n'))
-            if len(textBeforeStart) > 0 and \
-                    (textBeforeStart[-1] == '\n' or textBeforeStart[-1] == '\r'):
-                lineCount += 1
-            if lineCount <= 1:
+            line_count = len(text_before_start.split('\n'))
+            if len(text_before_start) > 0 and \
+                    (text_before_start[-1] == '\n' or text_before_start[-1] == '\r'):
+                line_count += 1
+            if line_count <= 1:
                 self.historyPrev.emit()
                 self.historyPrev.emit()
                 return
                 return
         elif event.matches(QKeySequence.MoveToNextPage) or \
         elif event.matches(QKeySequence.MoveToNextPage) or \
-             event.matches(QKeySequence.MoveToPreviousPage):
+                event.matches(QKeySequence.MoveToPreviousPage):
             return self._termWidget.browser().keyPressEvent(event)
             return self._termWidget.browser().keyPressEvent(event)
 
 
         QTextEdit.keyPressEvent(self, event)
         QTextEdit.keyPressEvent(self, event)
@@ -94,8 +94,9 @@ class TermWidget(QWidget):
         self._browser = QTextEdit(self)
         self._browser = QTextEdit(self)
         self._browser.setStyleSheet("font: 9pt \"Courier\";")
         self._browser.setStyleSheet("font: 9pt \"Courier\";")
         self._browser.setReadOnly(True)
         self._browser.setReadOnly(True)
-        self._browser.document().setDefaultStyleSheet(self._browser.document().defaultStyleSheet() +
-                                                      "span {white-space:pre;}")
+        self._browser.document().setDefaultStyleSheet(
+            self._browser.document().defaultStyleSheet() +
+            "span {white-space:pre;}")
 
 
         self._edit = _ExpandableTextEdit(self, self)
         self._edit = _ExpandableTextEdit(self, self)
         self._edit.historyNext.connect(self._on_history_next)
         self._edit.historyNext.connect(self._on_history_next)
@@ -120,30 +121,12 @@ class TermWidget(QWidget):
         assert style in ('in', 'out', 'err')
         assert style in ('in', 'out', 'err')
 
 
         text = cgi.escape(text)
         text = cgi.escape(text)
-
         text = text.replace('\n', '<br/>')
         text = text.replace('\n', '<br/>')
 
 
-        if style != 'out':
-            def_bg = self._browser.palette().color(QPalette.Base)
-            h, s, v, a = def_bg.getHsvF()
-
-            if style == 'in':
-                if v > 0.5:  # white background
-                    v = v - (v / 8)  # make darker
-                else:
-                    v = v + ((1 - v) / 4)  # make ligher
-            else:  # err
-                if v < 0.5:
-                    v = v + ((1 - v) / 4)  # make ligher
-
-                if h == -1:  # make red
-                    h = 0
-                    s = .4
-                else:
-                    h = h + ((1 - h) * 0.5)  # make more red
-
-            bg = QColor.fromHsvF(h, s, v).name()
-            text = '<span style="background-color: %s; font-weight: bold;">%s</span>' % (str(bg), text)
+        if style == 'in':
+            text = '<span style="font-weight: bold;">%s</span>' % text
+        elif style == 'err':
+            text = '<span style="font-weight: bold; color: red;">%s</span>' % text
         else:
         else:
             text = '<span>%s</span>' % text  # without span <br/> is ignored!!!
             text = '<span>%s</span>' % text  # without span <br/> is ignored!!!