comparison python/ide.py @ 162:d8c735dc31f9

Used new editor in ide
author Windel Bouwman
date Sun, 10 Mar 2013 11:36:55 +0100
parents 81e08e2e7777
children 8104fc8b5e90
comparison
equal deleted inserted replaced
161:956f8e5ee48a 162:d8c735dc31f9
8 8
9 # Compiler imports: 9 # Compiler imports:
10 from project import Project 10 from project import Project
11 import ppci 11 import ppci
12 from astviewer import AstViewer 12 from astviewer import AstViewer
13 from codeeditor import CodeEdit 13 #from codeeditor import CodeEdit
14 from codeedit import CodeEdit
14 stutil = __import__('st-util') 15 stutil = __import__('st-util')
15 import testc3 16 import testc3
16 17
17 lcfospng = base64.decodestring(b'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A\n/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJEhMKBk7B678AAAA/SURBVFjD\n7dbBCQAgDATBi9h/y7EFA4Kf2QLCwH1S6XQu6sqoujublc8BAAAAAAAAAAB8B+zXT6YJAAAAAKYd\nWSgFQNUyijIAAAAASUVORK5CYII=\n') 18 lcfospng = base64.decodestring(b'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A\n/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJEhMKBk7B678AAAA/SURBVFjD\n7dbBCQAgDATBi9h/y7EFA4Kf2QLCwH1S6XQu6sqoujublc8BAAAAAAAAAAB8B+zXT6YJAAAAAKYd\nWSgFQNUyijIAAAAASUVORK5CYII=\n')
18 19
193 # Load settings: 194 # Load settings:
194 self.settings = QSettings('windelsoft', 'lcfoside') 195 self.settings = QSettings('windelsoft', 'lcfoside')
195 self.loadSettings() 196 self.loadSettings()
196 197
197 ce = self.newFile() 198 ce = self.newFile()
198 ce.setSource(testc3.testsrc) 199 ce.Source = testc3.testsrc
199 200
200 self.diag = ppci.DiagnosticsManager() 201 self.diag = ppci.DiagnosticsManager()
201 202
202 # File handling: 203 # File handling:
203 def newProject(self): 204 def newProject(self):
208 self.project.filename = filename 209 self.project.filename = filename
209 self.project.save() 210 self.project.save()
210 211
211 def newFile(self): 212 def newFile(self):
212 ce = CodeEdit() 213 ce = CodeEdit()
213 self.mdiArea.addSubWindow(ce) 214 ce.textChanged.connect(self.buildProject)
215 w = self.mdiArea.addSubWindow(ce)
214 ce.show() 216 ce.show()
217 w.resize(500, 700)
215 return ce 218 return ce
216 def openFile(self): 219 def openFile(self):
217 filename = QFileDialog.getOpenFileName(self, "Open K# file...", "*.ks", "K# source files (*.ks)") 220 filename = QFileDialog.getOpenFileName(self, "Open K# file...", "*.ks", "K# source files (*.ks)")
218 if filename: 221 if filename:
219 self.loadFile(filename) 222 self.loadFile(filename)
299 #if self.project: 302 #if self.project:
300 # self.settings.setValue('openedproject', self.project.filename) 303 # self.settings.setValue('openedproject', self.project.filename)
301 # # TODO: ask for save of opened files 304 # # TODO: ask for save of opened files
302 ac = self.activeMdiChild() 305 ac = self.activeMdiChild()
303 if ac: 306 if ac:
304 if ac.filename: 307 if hasattr(ac, 'filename') and ac.filename:
305 self.settings.setValue('lastfile', ac.filename) 308 self.settings.setValue('lastfile', ac.filename)
306 else: 309 else:
307 self.settings.remove('lastfile') 310 self.settings.remove('lastfile')
308 else: 311 else:
309 self.settings.remove('lastfile') 312 self.settings.remove('lastfile')
331 # Build recepy: 334 # Build recepy:
332 def buildFile(self): 335 def buildFile(self):
333 ce = self.activeMdiChild() 336 ce = self.activeMdiChild()
334 print('BUILD file') 337 print('BUILD file')
335 if ce: 338 if ce:
336 source = ce.source 339 source = ce.Source
337 self.buildOutput.clear() 340 self.buildOutput.clear()
338 self.buildOutput.append(str(self.compiler)) 341 self.buildOutput.append(str(self.compiler))
339 ast = testc3.c3compile(source, self.diag) 342 ast = testc3.c3compile(source, self.diag)
340 #ast = self.compiler.compilesource(source) 343 #ast = self.compiler.compilesource(source)
341 self.astViewer.setAst(ast) 344 self.astViewer.setAst(ast)