Mercurial > lcfOS
comparison python/ide.py @ 249:e41e4109addd
Added current position arrow
author | Windel Bouwman |
---|---|
date | Fri, 26 Jul 2013 20:26:05 +0200 |
parents | b10d46e5c8dd |
children | f5fba5b554d7 |
comparison
equal
deleted
inserted
replaced
248:b10d46e5c8dd | 249:e41e4109addd |
---|---|
10 import ppci | 10 import ppci |
11 from astviewer import AstViewer | 11 from astviewer import AstViewer |
12 from codeedit import CodeEdit | 12 from codeedit import CodeEdit |
13 stutil = __import__('st-util') | 13 stutil = __import__('st-util') |
14 import c3 | 14 import c3 |
15 import zcc | |
16 import outstream | |
15 | 17 |
16 | 18 |
17 class BuildOutput(QTextEdit): | 19 class BuildOutput(QTextEdit): |
18 """ Build output component """ | 20 """ Build output component """ |
19 def __init__(self, parent=None): | 21 def __init__(self, parent=None): |
89 self.helpMenu = mb.addMenu('Help') | 91 self.helpMenu = mb.addMenu('Help') |
90 | 92 |
91 # Create mdi area: | 93 # Create mdi area: |
92 self.mdiArea = QMdiArea() | 94 self.mdiArea = QMdiArea() |
93 self.mdiArea.setViewMode(QMdiArea.TabbedView) | 95 self.mdiArea.setViewMode(QMdiArea.TabbedView) |
96 self.mdiArea.setTabsClosable(True) | |
94 self.setCentralWidget(self.mdiArea) | 97 self.setCentralWidget(self.mdiArea) |
95 | 98 |
96 # Create components: | 99 # Create components: |
97 def addComponent(name, widget): | 100 def addComponent(name, widget): |
98 dw = QDockWidget(name) | 101 dw = QDockWidget(name) |
176 print('exception opening file', e) | 179 print('exception opening file', e) |
177 | 180 |
178 # MDI: | 181 # MDI: |
179 def newCodeEdit(self): | 182 def newCodeEdit(self): |
180 ce = CodeEdit() | 183 ce = CodeEdit() |
181 ce.textChanged.connect(self.buildFile) | 184 ce.textChanged.connect(self.parseFile) |
182 w = self.mdiArea.addSubWindow(ce) | 185 w = self.mdiArea.addSubWindow(ce) |
183 ce.show() | 186 self.mdiArea.setActiveSubWindow(w) |
187 ce.showMaximized() | |
184 return ce | 188 return ce |
185 | 189 |
186 def activeMdiChild(self): | 190 def activeMdiChild(self): |
187 aw = self.mdiArea.activeSubWindow() | 191 aw = self.mdiArea.activeSubWindow() |
188 if aw: | 192 if aw: |
231 ce.setFocus() | 235 ce.setFocus() |
232 else: | 236 else: |
233 ce.clearErrors() | 237 ce.clearErrors() |
234 | 238 |
235 def pointCode(self, p): | 239 def pointCode(self, p): |
236 print('PC', p) | 240 # Lookup pc in debug infos: |
241 loc = None | |
242 if hasattr(self, 'debugInfo'): | |
243 for di in self.debugInfo: | |
244 if di.address > p: | |
245 loc = di.info | |
246 break | |
247 if loc: | |
248 ce = self.activeMdiChild() | |
249 if ce: | |
250 ce.ic.arrow = loc | |
251 self.showLoc(loc) | |
237 | 252 |
238 # Build recepy: | 253 # Build recepy: |
239 def buildFile(self): | 254 def parseFile(self): |
240 ce = self.activeMdiChild() | 255 ce = self.activeMdiChild() |
241 if not ce: | 256 if not ce: |
242 return | 257 return |
243 self.buildOutput.clear() | |
244 self.diag.clear() | 258 self.diag.clear() |
245 self.buildOutput.append('Starting build') | 259 self.buildOutput.append('Starting parse') |
246 ir = self.c3front.build(ce.Source) | 260 ir = self.c3front.build(ce.Source) |
247 | 261 |
248 # Set errors: | 262 # Set errors: |
249 for err in self.diag.diags: | 263 for err in self.diag.diags: |
250 self.buildOutput.append(str(err)) | 264 self.buildOutput.append(str(err)) |
252 ce.setErrors(self.diag.diags) | 266 ce.setErrors(self.diag.diags) |
253 ast = self.c3front.pkg | 267 ast = self.c3front.pkg |
254 self.astViewer.setAst(ast) | 268 self.astViewer.setAst(ast) |
255 self.buildOutput.append("Done!") | 269 self.buildOutput.append("Done!") |
256 | 270 |
271 def buildFile(self): | |
272 ce = self.activeMdiChild() | |
273 if not ce: | |
274 return | |
275 self.diag.clear() | |
276 self.buildOutput.append('Starting build') | |
277 outs = outstream.TextOutputStream() | |
278 if not zcc.zcc(ce.Source, outs, self.diag): | |
279 # Set errors: | |
280 for err in self.diag.diags: | |
281 self.buildOutput.append(str(err)) | |
282 self.builderrors.setErrorList(self.diag.diags) | |
283 ce.setErrors(self.diag.diags) | |
284 return | |
285 | |
286 self.buildOutput.append("Flashing stm32f4 discovery") | |
287 code_s = outs.getSection('code') | |
288 self.debugInfo = code_s.debugInfos() | |
289 | |
290 self.buildOutput.append("Done!") | |
291 | |
257 if __name__ == '__main__': | 292 if __name__ == '__main__': |
258 app = QApplication(sys.argv) | 293 app = QApplication(sys.argv) |
259 ide = Ide() | 294 ide = Ide() |
260 ide.show() | 295 ide.show() |
261 app.exec_() | 296 app.exec_() |