Mercurial > lcfOS
comparison python/codeeditor.py @ 101:af0d7913677a
Fixes and splitting into 3 stage
author | windel |
---|---|
date | Mon, 24 Dec 2012 17:55:08 +0100 |
parents | fe145e42259d |
children | 81e08e2e7777 |
comparison
equal
deleted
inserted
replaced
100:fe145e42259d | 101:af0d7913677a |
---|---|
66 | 66 |
67 def setFileName(self, filename): | 67 def setFileName(self, filename): |
68 self.filename = filename | 68 self.filename = filename |
69 self.isUntitled = False | 69 self.isUntitled = False |
70 self.setWindowTitle(filename) | 70 self.setWindowTitle(filename) |
71 | |
71 def setSource(self, source): | 72 def setSource(self, source): |
72 self.setPlainText(source) | 73 self.setPlainText(source) |
74 def getSource(self): | |
75 return self.toPlainText() | |
76 source = property(getSource, setSource) | |
73 | 77 |
74 def save(self): | 78 def save(self): |
75 pass | 79 self.saveFile() |
76 def saveAs(self): | 80 def saveAs(self): |
77 pass | 81 print('save as') |
78 | 82 |
79 def saveFile(self): | 83 def saveFile(self): |
80 if self.isUntitled: | 84 if self.isUntitled: |
81 self.saveAs() | 85 self.saveAs() |
82 else: | 86 else: |
83 source = str(self.toPlainText()) | 87 source = str(self.toPlainText()) |
84 f = open(self.filename, 'w') | 88 with open(self.filename, 'w') as f: |
85 f.write(source) | 89 f.write(source) |
86 f.close() | |
87 | 90 |
88 def highlightErrorLocation(self, row, col): | 91 def highlightErrorLocation(self, row, col): |
89 tc = QTextCursor(self.document()) | 92 tc = QTextCursor(self.document()) |
90 tc.clearSelection() | 93 tc.clearSelection() |
91 tc.movePosition(tc.Down, tc.MoveAnchor, row - 1) | 94 tc.movePosition(tc.Down, tc.MoveAnchor, row - 1) |