Mercurial > lcfOS
comparison python/codeedit.py @ 167:0b5b2ee6b435
Added 2 unit tests
author | Windel Bouwman |
---|---|
date | Fri, 22 Mar 2013 17:40:13 +0100 |
parents | 8104fc8b5e90 |
children | ee0d30533dae |
comparison
equal
deleted
inserted
replaced
166:da0087b82fbe | 167:0b5b2ee6b435 |
---|---|
68 def setRowCol(self, r, c): | 68 def setRowCol(self, r, c): |
69 prevRows = self.Rows[:r-1] | 69 prevRows = self.Rows[:r-1] |
70 txt = '\n'.join(prevRows) | 70 txt = '\n'.join(prevRows) |
71 c = clipVal(c, 1, len(self.getRow(r))) | 71 c = clipVal(c, 1, len(self.getRow(r))) |
72 self.CursorPosition = len(txt) + c + 1 | 72 self.CursorPosition = len(txt) + c + 1 |
73 self.showRow(self.CursorRow) | |
73 def getRow(self, r): | 74 def getRow(self, r): |
74 rows = self.Rows | 75 rows = self.Rows |
75 r = r - 1 | 76 r = r - 1 |
76 if r < 0 or r > len(rows) - 1: | 77 if r < 0 or r > len(rows) - 1: |
77 return '' | 78 return '' |
147 for e in curErrors: | 148 for e in curErrors: |
148 painter.drawPixmap(self.xposERR, ypos + ydt, self.errorPixmap) | 149 painter.drawPixmap(self.xposERR, ypos + ydt, self.errorPixmap) |
149 painter.setPen(errorPen) | 150 painter.setPen(errorPen) |
150 x = self.xposTXT + (e.loc.col - 1) * chw - 2 | 151 x = self.xposTXT + (e.loc.col - 1) * chw - 2 |
151 wt = e.loc.length * chw + 4 | 152 wt = e.loc.length * chw + 4 |
152 painter.drawRoundedRect(x, ypos + ydt, wt, chh, 7, 7) | 153 dy = self.charDescent |
154 painter.drawLine(x, ypos + dy, x + wt, ypos + dy) | |
155 #painter.drawRoundedRect(x, ypos + ydt, wt, chh, 7, 7) | |
153 # print error balloon | 156 # print error balloon |
154 painter.drawText(x, ypos + chh, e.msg) | 157 #painter.drawText(x, ypos + chh, e.msg) |
155 if len(curErrors) > 0: | 158 #if len(curErrors) > 0: |
156 ypos += chh | 159 # ypos += chh |
157 | 160 |
158 ypos += chh | 161 ypos += chh |
159 def keyPressEvent(self, event): | 162 def keyPressEvent(self, event): |
160 if event.matches(QKeySequence.MoveToNextChar): | 163 if event.matches(QKeySequence.MoveToNextChar): |
161 self.GotoNextChar() | 164 self.GotoNextChar() |
219 self.showRow = self.ic.showRow | 222 self.showRow = self.ic.showRow |
220 self.setRowCol = self.ic.setRowCol | 223 self.setRowCol = self.ic.setRowCol |
221 Source = property(lambda s: s.ic.getSource(), lambda s, v: s.ic.setSource(v)) | 224 Source = property(lambda s: s.ic.getSource(), lambda s, v: s.ic.setSource(v)) |
222 def setErrors(self, el): | 225 def setErrors(self, el): |
223 self.ic.setErrors(el) | 226 self.ic.setErrors(el) |
227 def setFocus(self): | |
228 self.ic.setFocus() | |
224 | 229 |
225 if __name__ == '__main__': | 230 if __name__ == '__main__': |
226 app = QApplication(sys.argv) | 231 app = QApplication(sys.argv) |
227 ce = CodeEdit() | 232 ce = CodeEdit() |
228 ce.show() | 233 ce.show() |