Commits

Henning Schröder  committed 24762b0

added todo
added drawing primitives for folding (tree expander icon)
line highlighting now using extra selections

  • Participants
  • Parent commits 4127075

Comments (0)

Files changed (4)

File codeaide/base.py

 from PyQt4.QtGui import (
     QApplication, QWidget, QHBoxLayout, QToolTip,
     QTextBlockUserData, QPlainTextEdit, QCompleter, QTextCursor, 
-    QColor, QBrush, QPainter, QPen, QPalette)
+    QColor, QBrush, QPainter, QPen, QPalette, QTextEdit, QTextFormat)
 
 
 

File codeaide/modes/folding.py

 from codeaide.modes.sidebar import SidebarModeBase
 
 
+class FoldableLine(QWidget):
+
+    
+    def paintEvent(self, event):
+        painter = QPainter(self)
+        if self.foldable:
+            if self.hover:
+                painter.setPen(Qt.black) 
+            else:
+                painter.setPen(Qt.darkGray)
+            branchOption = QStyleOption()
+            i = 9 # hardcoded in qcommonstyle.cpp
+            r = option.rect
+            branchOption.rect = QRect(r.left() + i/2, r.top() + (r.height() - i)/2, i, i)
+            branchOption.palette = option.palette;
+            branchOption.state = QStyle.State_Children;
+            branchOption.state |= QStyle.State_Open
+            self.style().drawPrimitive(QStyle.PE_IndicatorBranch, branchOption, painter, self)
+        return QWidget.paintEvent(self, event)
+    
+
 class FoldingWidget(QWidget):
 
     

File codeaide/modes/lines.py

         painter.fillRect(self.rect, self.brush)
 
 
+        
 class HighlightLine(ModeBase):
+    """
+    Originally drawing was done in a paint event by fill a rect.
+    Now this mode uses an ExtraSelection (Is this better?)
+    """
 
 
     def init(self):
         cursor = self.textedit.textCursor()
         row = cursor.blockNumber()
         if row != self.old_row:
-            self.textedit.viewport().update()
+            # XXX: self.textedit.viewport().update()
             self.old_row = row
+            
+            self.sel = QTextEdit.ExtraSelection()
+            self.sel.cursor = QTextCursor(self.textedit.textCursor())
+            self.sel.cursor.select(QTextCursor.LineUnderCursor)
+            self.sel.format.setBackground(self.brush)
+            self.sel.format.setProperty(QTextFormat.FullWidthSelection, QVariant(True))
+            self.textedit.setExtraSelections([self.sel])
 
-
-    def paint_hook(self, event, painter, viewport):
+    
+    def XXXpaint_hook(self, event, painter, viewport):
         r = self.textedit.cursorRect()
         r.setX(0)
         r.setWidth(viewport.width())
+add color scheme
+add keyboard scheme
+add paint_event_before and paint_event_after
+modes should be able handle more than one state
+dispatch all key events depending on state
+clean up completer, async requests
+implement indenter
+paren matching highligher
+same word highlighter
+snippets: loader for gedit and textmate, integrate with completer
+add syntax highlighter (also load from textmate bundles?)
+flymake-mode with pylint implementation (threading!)