Ejemplo n.º 1
0
    def CDCTimer(self, event=None):
        try:
            if self.debugOutMessage != None:
                self.pinguinoCDC.write(self.debugOutMessage)
                self.debugOutMessage = None
            else:
                line = self.pinguinoCDC.readline()
                self.updateDebggingLog(line)

        except UnboundLocalError:
            self.logwindow.WriteText(_("No device connected") + "!")
            self.menu.menuItemDebugNone.Check()
            self.updateDebggingLog(None)

        except serial.serialutil.SerialException:
            self.logwindow.WriteText("\n" + _("device disconnected") + "!")
            self.debugCDC()
            return
        except:
            pass

        if self.closing or self.menu.menuItemDebugNone.IsChecked():
            self.pinguinoCDC.close()
        else:
            self.timer_CDC.Restart(10)
Ejemplo n.º 2
0
    def CloseTab(self):
        """ close the current tab """
        if len(self.onglet) <= 0:
            return False

        pageIdx = self.notebookEditor.GetSelection()
        if self.notebookEditor.GetPageText(pageIdx)[0] == "*":
            dlg = wx.MessageDialog(
                self,
                _("Save file ?\n" + self.filename[pageIdx]),
                _("Warning") + "!",
                wx.YES_NO | wx.ICON_WARNING | wx.CANCEL,
            )
            result = dlg.ShowModal()
            dlg.Destroy()
            if result == wx.ID_CANCEL:
                return True
            if result == wx.ID_YES:
                self.OnSaveAs()
        self.filename.remove(self.filename[pageIdx])
        self.onglet.remove(self.onglet[pageIdx])
        self.stcpage.remove(self.stcpage[pageIdx])
        self.notebookEditor.DeletePage(pageIdx)
        self.sheetFunctions.remove(self.sheetFunctions[pageIdx])
        # self.choiceFunctions.remove(self.choiceFunctions[page])
        if pageIdx > 0:
            self.notebookEditor.SetSelection(pageIdx - 1)
            self.notebookEditor.Update()
        return True
Ejemplo n.º 3
0
    def CDCTimer(self, event=None):
        try:
            if self.debugOutMessage != None:
                self.pinguinoCDC.write(self.debugOutMessage)
                self.debugOutMessage = None
            else:
                line = self.pinguinoCDC.readline()
                self.updateDebggingLog(line)

        except UnboundLocalError:
            self.logwindow.WriteText(_("No device connected") + "!")
            self.menu.menuItemDebugNone.Check()
            self.updateDebggingLog(None)

        except serial.serialutil.SerialException:
            self.logwindow.WriteText("\n" + _("device disconnected") + "!")
            self.debugCDC()
            return
        except:
            pass

        if self.closing or self.menu.menuItemDebugNone.IsChecked():
            self.pinguinoCDC.close()
        else:
            self.timer_CDC.Restart(10)
Ejemplo n.º 4
0
 def changeCDCPort(self, event):
     port = event.String
     try: self.pinguinoCDC.close()
     except: pass
     try:
         self.pinguinoCDC = serial.Serial(port, timeout=1)
         self.logwindow.WriteText(_("Connected")+": "+port+"\n")
     except:
         self.logwindow.WriteText(_("No device connected")+"!\n")
Ejemplo n.º 5
0
    def __initPinguino__(self, parent):
        sys.setrecursionlimit(1500)
        self.notebookEditor.Hide()
        self.boardlist = boardlist
        self.debugOutMessage = None
        self.closing = False
        self.currentLateralDir = os.path.join(os.getcwd(),"examples")
        self.autoCompleteWords = []
        self.recentsFiles = []
        self.otherWords = []
        self.autocompleteHide = False
        self.extraName = ""
	self.changingBoard = False

        if os.path.isdir(TEMP_DIR) == False: os.mkdir(TEMP_DIR)

        self._mgr = wx.aui.AuiManager(self)

        self.setOSvariables()
        self.configPanes()
        self.buildMenu()
        #self.loadSettings()
        self.morePreferences()
        self.ConnectAll()
        self.trees = []

        self.allVars_back = [] 
        self.allFunc_back = []
        self.allDefi_back = []	

        #Threads
        if DEV:
            EVT_RESULT_REVISION(self, self.setRevision)
            threadRevision = threading.Thread(target=self.getRevision, args=( ))
            threadRevision.start()

            self.SetTitle('Pinguino IDE ' + pinguino_version + " rev. ["+_("loading...")+"]")
            self.displaymsg(_("Welcome to Pinguino IDE")+" (rev. ["+_("loading...")+"])", 1)
        else:
            self.SetTitle("Pinguino IDE")
            self.displaymsg(_("Welcome to Pinguino IDE"), 1)            

        self.loadSettings()
        self.__initIDE__()

        ########################################
        #Auto-complete frame build 
        CharsCount = self.getElse("Completer", "charscount", 1)
        MaxItemsCount = self.getElse("Completer", "MaxItemsCount", 10)
        self.AutoCompleter = AutocompleterIDE(self)
        self.AutoCompleter.__initCompleter__(self, CharsCount, MaxItemsCount)
        self.AutoCompleter.Hide()

        #########################################

            
        self.DrawToolbar()
Ejemplo n.º 6
0
 def OnNew(self, event):
     self.background.Hide()
     
     try: self.intName += 1
     except: self.intName = 0
         
     file = os.path.join(TEMP_DIR, _("Newfile%d") %self.intName)
     while file + ".pde" in self.filename:
         self.intName += 1
         file = os.path.join(TEMP_DIR, _("Newfile%d") %self.intName)
     self.New(file)  #editeur.py
     self.updatenotebook()
Ejemplo n.º 7
0
 def loadStdout(self):
     # Need for local encoding info because Windows OS emits
     # its local multibyte strings when a system error occurs.
     enc = locale.getpreferredencoding()
     try:
         file = codecs.open(STDOUT_FILE, "r", enc)
         lines = "\n".join(file.readlines())
         file.close()
     except:
         lines = _("No utf8 file!\n%s") % STDOUT_FILE
     if lines == "": lines = _("Empty file...")
     self.m_richText2.AppendText(lines)
Ejemplo n.º 8
0
 def loadStdout(self):
     # Need for local encoding info because Windows OS emits
     # its local multibyte strings when a system error occurs.
     enc = locale.getpreferredencoding()
     try:
         file = codecs.open(STDOUT_FILE, "r", enc)
         lines = "\n".join(file.readlines())
         file.close()
     except:
         lines = _("No utf8 file!\n%s") % STDOUT_FILE
     if lines == "":
         lines = _("Empty file...")
     self.m_richText2.AppendText(lines)
Ejemplo n.º 9
0
    def OnNew(self, event):
        self.background.Hide()

        try:
            self.intName += 1
        except:
            self.intName = 0

        file = os.path.join(TEMP_DIR, _("Newfile%d") % self.intName)
        while file + ".pde" in self.filename:
            self.intName += 1
            file = os.path.join(TEMP_DIR, _("Newfile%d") % self.intName)
        self.New(file)  #editeur.py
        self.updatenotebook()
Ejemplo n.º 10
0
    def Open(self, path):
        file = os.path.basename(path)
        directory, extension = os.path.splitext(path)

        if path in self.filename:

            dlg = wx.MessageDialog(self,
                                   _("File is already opened, reload it ?"),
                                   _("Warning") + "!",
                                   wx.YES_NO | wx.ICON_WARNING)
            result = dlg.ShowModal()
            dlg.Destroy()
            if (result == wx.ID_NO):
                return
            else:
                index = self.filename.index(path)
                self.stcpage[index].ClearAll()
                fichier = open(path, 'r')
                self.stcpage[index].SetText(fichier.read())
                fichier.close()
                return

        self.inhibitChangeEvents = True
        self.New(file.replace(extension, ""))

        pageIdx = self.notebookEditor.GetSelection()
        self.stcpage[pageIdx].ClearAll()
        self.filename[pageIdx] = path
        fichier = codecs.open(path, 'r', 'utf8')
        #for line in fichier:
        #    self.stcpage[pageIdx].AddText(line)
        self.stcpage[pageIdx].SetText(fichier.read())
        fichier.close()
        self.notebookEditor.SetPageText(pageIdx, file.replace(extension, ""))
        self.editeur.GotoLine(self.editeur.LineFromPosition(0))

        if self.getElse("Main", "tools", "True") and self.getElse(
                "Tools", "files", "True"):
            self.Files.update_dockFiles()

        #self.notebookEditor.Update()
        self.stcpage[pageIdx].EmptyUndoBuffer()
        #self.stcpage[pageIdx].SetSavePoint()
        self.inhibitChangeEvents = False
        self.SendSizeEvent()

        self.addFile2Recent(path)
        self.updatenotebook()
Ejemplo n.º 11
0
    def initIDEobjects(self):
        """Constructor"""

        self.configAui()
        self.buildMenubar()
        self.BindEvents()
        self.loadFeatures()
        self.SetTitle("Pinguino IDE" + getRevisionNumber())
        if os.name == "posix":
            self.displaymsg(_("Welcome to Pinguino IDE"), 1)
        self.buildToolbar()
        self.notebookEditor.Hide()

        # self.updateIDE()
        self.__initEditor__()
        # self.__initDebugger__()  #TODO
        self.__initTesting__()  # TODO
        self.initTimers()

        # open last sesion
        if self.getElse("Main", "open-save", "True") and self.getElse("Open/Save", "openlast", "False"):
            self.openLast()

        # hide lateral tools and output
        if self.notebookEditor.PageCount == 0:
            self.updatenotebook()

        self.saveConfig()
Ejemplo n.º 12
0
    def findWord(self, word):
        if word == "": return

        textEdit = self.stcpage[self.notebookEditor.GetSelection()]
        if self.lat.checkBox_sensitive.IsChecked():
            plain = str(textEdit.GetTextUTF8())
            word = str(word)
        else:
            plain = str(textEdit.GetTextUTF8()).lower()
            word = str(word).lower()

        count = plain.count(word)
        finds = [plain.find(word)]
        while finds[-1] != -1:
            finds.append(plain.find(word, finds[-1] + 1))
        finds.pop(-1)

        result = {
            "word": word,
            "count": len(finds),
            "finds": finds,
        }

        self.lat.searchReplaceInfo.SetLabel(
            _("Finded %d matches in the file.") % len(finds))

        return result
Ejemplo n.º 13
0
    def setBoard(self, arch, mode, name):
        # clear all the lists before rebuild them
        del self.rw[:]
        del self.regobject[:]
        del self.keywordList[:]
        del self.reservedword[:]
        del self.libinstructions[:]

	if mode == "BOOT":
	    for board in boardlist:
		if name == board.name:
		    self.curBoard = board
	    self.extraName = ""
		    
	else:
	    self.curBoard = boardlist[0]
	    self.curBoard.proc = name
	    self.curBoard.board = "PIC"+name.upper()
	    self.extraName = " [" + self.curBoard.board + "]"
	    
	self.displaymsg(_("Changing board")+"...", 0)
	self.statusBarEditor.SetStatusText(number=2, text=self.curBoard.name+self.extraName+" - "+mode)
	if sys.platform=='darwin':
	    self.readlib(self.curBoard) #So slow
	else:
	    self.Thread_curBoard = threading.Thread(target=self.readlib, args=(self.curBoard, ))
	    self.Thread_curBoard.start()
Ejemplo n.º 14
0
    def new_choices_dev(self):
        try:
            self.radioBox_dev.Destroy()
            self.m_scrolledWindow1.Destroy()
        except:
            pass
        columns, self.radioBox_devChoices = self.IDE.getDevices(self.ARCH)

        self.m_scrolledWindow1 = wx.ScrolledWindow(self.m_panel37, wx.ID_ANY,
                                                   wx.DefaultPosition,
                                                   wx.DefaultSize,
                                                   wx.HSCROLL | wx.VSCROLL)
        self.m_scrolledWindow1.SetScrollRate(5, 5)
        self.sizer2 = wx.BoxSizer(wx.VERTICAL)

        if self.radioBox_devChoices:
            self.radioBox_dev = wx.RadioBox(self.m_scrolledWindow1,
                                            wx.ID_ANY,
                                            _(u"Devices"),
                                            wx.DefaultPosition,
                                            wx.DefaultSize,
                                            self.radioBox_devChoices,
                                            majorDimension=columns)
            self.radioBox_dev.SetSelection(0)
            self.radioBox_dev.Bind(wx.EVT_RADIOBOX, self.r_device)

            self.buildChoicesDev()
Ejemplo n.º 15
0
    def OnNew(self, event):
        self.background.Hide()

        #print self.filename

        file = os.path.join(TEMP_DIR, _("Newfile%d") % self.noname)
        while file + ".pde" in self.filename:
            self.noname += 1
            file = os.path.join(TEMP_DIR, _("Newfile%d") % self.noname)

        #self.addFile2Recent(file)
        #print file

        self.New(file)
        self.noname += 1
        self.updatenotebook()
Ejemplo n.º 16
0
    def initIDEobjects(self):
        """Constructor"""

        self.configAui()
        self.buildMenubar()
        self.BindEvents()
        self.loadFeatures()
        self.SetTitle("Pinguino IDE" + getRevisionNumber())
        if os.name == "posix": self.displaymsg(_("Welcome to Pinguino IDE"), 1)
        self.buildToolbar()
        self.notebookEditor.Hide()

        #self.updateIDE()
        self.__initEditor__()
        #self.__initDebugger__()  #TODO
        self.__initTesting__()  #TODO
        self.initTimers()

        #open last sesion
        if self.getElse("Main", "open-save", "True") and self.getElse(
                "Open/Save", "openlast", "False"):
            self.openLast()

        #hide lateral tools and output
        if self.notebookEditor.PageCount == 0: self.updatenotebook()

        self.saveConfig()
Ejemplo n.º 17
0
    def Open(self, path):
        file = os.path.basename(path)
        directory, extension = os.path.splitext(path)

        if path in self.filename:

            dlg = wx.MessageDialog(
                self, _("File is already opened, reload it ?"), _("Warning") + "!", wx.YES_NO | wx.ICON_WARNING
            )
            result = dlg.ShowModal()
            dlg.Destroy()
            if result == wx.ID_NO:
                return
            else:
                index = self.filename.index(path)
                self.stcpage[index].ClearAll()
                fichier = open(path, "r")
                self.stcpage[index].SetText(fichier.read())
                fichier.close()
                return

        self.inhibitChangeEvents = True
        self.New(file.replace(extension, ""))

        pageIdx = self.notebookEditor.GetSelection()
        self.stcpage[pageIdx].ClearAll()
        self.filename[pageIdx] = path
        fichier = codecs.open(path, "r", "utf8")
        # for line in fichier:
        #    self.stcpage[pageIdx].AddText(line)
        self.stcpage[pageIdx].SetText(fichier.read())
        fichier.close()
        self.notebookEditor.SetPageText(pageIdx, file.replace(extension, ""))
        self.editeur.GotoLine(self.editeur.LineFromPosition(0))

        if self.getElse("Main", "tools", "True") and self.getElse("Tools", "files", "True"):
            self.Files.update_dockFiles()

        # self.notebookEditor.Update()
        self.stcpage[pageIdx].EmptyUndoBuffer()
        # self.stcpage[pageIdx].SetSavePoint()
        self.inhibitChangeEvents = False
        self.SendSizeEvent()

        self.addFile2Recent(path)
        self.updatenotebook()
Ejemplo n.º 18
0
 def OnUpload(self, event=None, path=None):
     
     if path == None: path = self.GetPath()
     #else: path = filename
     
     if  path != -1:
         filename = path
         filename, extension = os.path.splitext(filename)
         if os.path.exists(filename + '.hex'):
             #u = Uploader(self.displaymsg, filename, self.curBoard)
             #"""
             if self.curBoard.arch == 8:
                 #try:
                 u = Uploader(self.displaymsg, filename, self.curBoard)
                 #except usb.USBError:  #No device
                 #self.displaymsg("No device",0)
                 #return
                 
             else:
                 fichier = open(os.path.join(SOURCE_DIR, 'stdout'), 'w+')
                 sortie=Popen([os.path.join(HOME_DIR, self.osdir, 'p32', 'bin', self.u32),
                               "-w",
                               filename+".hex",
                               "-r",
                               "-n"],
                              stdout=fichier, stderr=STDOUT)
                 sortie.communicate()
                 fichier.seek(0)
                 self.displaymsg(fichier.read(),0)
                 fichier.close()
             #"""
         else:# no file
             dlg = wx.MessageDialog(self,
                                    _('File must be verified/compiled before upload'),
                                    _('Warning!'),
                                    wx.OK | wx.ICON_WARNING)
             result=dlg.ShowModal()
             dlg.Destroy()
     else:# not saved
         dlg = wx.MessageDialog(self,
                                _('File must be saved before upload'),
                                _('Warning!'),
                                wx.OK | wx.ICON_WARNING)
         result=dlg.ShowModal()
         dlg.Destroy()
     if event != None: event.Skip()
Ejemplo n.º 19
0
 def OnNew(self, event):
     self.background.Hide()
     
     #print self.filename
     
     
     file = os.path.join(TEMP_DIR, _("Newfile%d") %self.noname)
     while file + ".pde" in self.filename:
         self.noname += 1
         file = os.path.join(TEMP_DIR, _("Newfile%d") %self.noname)
         
     #self.addFile2Recent(file)
     #print file              
         
     self.New(file)
     self.noname+=1
     self.updatenotebook()
Ejemplo n.º 20
0
    def OnUpload(self, event=None, path=None):

        if path == None: path = self.GetPath()
        #else: path = filename

        if path != -1:
            filename = path
            filename, extension = os.path.splitext(filename)
            if os.path.exists(filename + '.hex'):
                #u = Uploader(self.displaymsg, filename, self.curBoard)
                #"""
                if self.curBoard.arch == 8:
                    #try:
                    u = Uploader(self.displaymsg, filename, self.curBoard)
                    #except usb.USBError:  #No device
                    #self.displaymsg("No device",0)
                    #return

                else:
                    fichier = open(os.path.join(SOURCE_DIR, 'stdout'), 'w+')
                    sortie = Popen([
                        os.path.join(HOME_DIR, self.osdir, 'p32', 'bin',
                                     self.u32), "-w", filename + ".hex", "-r",
                        "-n"
                    ],
                                   stdout=fichier,
                                   stderr=STDOUT)
                    sortie.communicate()
                    fichier.seek(0)
                    self.displaymsg(fichier.read(), 0)
                    fichier.close()
                #"""
            else:  # no file
                dlg = wx.MessageDialog(
                    self, _('File must be verified/compiled before upload'),
                    _('Warning!'), wx.OK | wx.ICON_WARNING)
                result = dlg.ShowModal()
                dlg.Destroy()
        else:  # not saved
            dlg = wx.MessageDialog(self, _('File must be saved before upload'),
                                   _('Warning!'), wx.OK | wx.ICON_WARNING)
            result = dlg.ShowModal()
            dlg.Destroy()
        if event != None: event.Skip()
Ejemplo n.º 21
0
    def Open(self, path):
        """ Open file in a new editor """ 
        file = os.path.basename(path)
        directory,extension = os.path.splitext(path)

        if path in self.filename:

            dlg = wx.MessageDialog(self,
                                   _("File is already opened, reload it ?"), _("Warning")+"!",
                                   wx.YES_NO | wx.ICON_WARNING)
            result=dlg.ShowModal()
            dlg.Destroy()                        
            if (result==wx.ID_NO):
                return
            else:
                index = self.filename.index(path)
                self.stcpage[index].ClearAll()
                fichier=open(path,'r')
                self.stcpage[index].SetText(fichier.read())
                fichier.close()
                return
            
        self.inhibitChangeEvents = True
        self.New(file.replace(extension,""))

        pageIdx = self.notebookEditor.GetSelection()
        self.stcpage[pageIdx].ClearAll()
        self.filename[pageIdx]=path
        fichier=codecs.open(path,'r','utf8')
        #for line in fichier:
        #    self.stcpage[pageIdx].AddText(line)
        self.stcpage[pageIdx].SetText(fichier.read())
        fichier.close()
        self.notebookEditor.SetPageText(pageIdx,file.replace(extension,""))
        self.gotostart()
        self.update_dockFiles()
        #self.notebookEditor.Update()
        self.stcpage[pageIdx].EmptyUndoBuffer()
        #self.stcpage[pageIdx].SetSavePoint()
        self.inhibitChangeEvents = False
        self.SendSizeEvent()

        self.addFile2Recent(path)
Ejemplo n.º 22
0
    def b_acept(self, event=None):
        if self.ARCH == 32 and self.MODE == "ICSP":
            dlg = wx.MessageDialog(
                self,
                _("ICSP mode for 32-bit architecture not supported yet."),
                _("Warning") + "!", wx.YES_DEFAULT | wx.ICON_WARNING)
            result = dlg.ShowModal()
            dlg.Destroy()
            return

        self.IDE.setConfig("Board", "architecture", self.ARCH)
        self.IDE.setConfig("Board", "mode", self.MODE)
        self.IDE.setConfig("Board", "device", self.DEVICE)
        #self.IDE.setConfig("Board", "family", self.FAMILY)
        self.IDE.setConfig("Board", "bootloader", self.BOOTLOADER)
        self.IDE.saveConfig()
        self.IDE.setBoard(self.ARCH, self.MODE, self.DEVICE,
                          self.BOOTLOADER)  #To set board in wxgui/pinguino.py
        self.Close()
Ejemplo n.º 23
0
    def setRevision(self, event):
        if type(event.data) == type([]):
            self.OnCheck(event=None, back=True, svn=event.data[0])
            return

        self.localRev = event.data
        if DEV == True: rev = 'rev. ' + self.localRev
        else: rev = ""
        self.SetTitle('Pinguino IDE ' + pinguino_version + " " + rev)
        self.displaymsg(_("Welcome to Pinguino IDE")+" (rev. " + self.localRev + ")", 1)
        self.statusBarEditor.SetStatusText(number=2, text="Rev. %s" %self.localRev)
Ejemplo n.º 24
0
 def Save(self,wildcard):
     """save the content of the editor to filename""" 
     if len(self.onglet)>0: 
         pageIdx = self.notebookEditor.GetSelection()
         path=self.filename[pageIdx]
         # directory,extension=os.path.splitext(path) bug #01 2008-09-06
         directory,extension=os.path.split(path)
         file=os.path.basename(path)  
         filedlg = wx.FileDialog(
             self, 
             message=_("Save file as")+" ...", 
             defaultDir=directory, 
             defaultFile=file,
             wildcard=wildcard, 
             #wildcard=type+" (*"+extensionSave+")|*"+extensionSave,
             style=wx.SAVE)
         filedlg.SetFilterIndex(2)
         if filedlg.ShowModal() == wx.ID_OK:
             path = filedlg.GetPath() 
         else:
             return
         if (path!=""):
             if os.path.exists(path):
                 dlg = wx.MessageDialog(self,
                                        _("File already exist, Overwrite it ?"), _("Warning")+"!",
                                        wx.YES_NO | wx.ICON_WARNING
                                        )
                 result=dlg.ShowModal()
                 dlg.Destroy()                        
                 if (result!=wx.ID_YES):
                     return 0         
         self.filename[pageIdx]=path
         directory,extension=os.path.splitext(path)
         file=os.path.basename(path)                
         self.notebookEditor.SetPageText(pageIdx,file.replace(extension,""))
         fichier=codecs.open(path,'w','utf8')                        
         for i in range(0,self.stcpage[pageIdx].GetLineCount()):
             fichier.writelines(unicode(self.stcpage[pageIdx].GetLine(i)))
         fichier.close()
         self.stcpage[pageIdx].SetSavePoint()
         return
Ejemplo n.º 25
0
 def Save(self, wildcard):
     """save the content of the editor to filename"""
     if len(self.onglet) > 0:
         pageIdx = self.notebookEditor.GetSelection()
         path = self.filename[pageIdx]
         # directory,extension=os.path.splitext(path) bug #01 2008-09-06
         directory, extension = os.path.split(path)
         file = os.path.basename(path)
         filedlg = wx.FileDialog(
             self,
             message=_("Save file as") + " ...",
             defaultDir=directory,
             defaultFile=file,
             wildcard=wildcard,
             #wildcard=type+" (*"+extensionSave+")|*"+extensionSave,
             style=wx.SAVE)
         filedlg.SetFilterIndex(2)
         if filedlg.ShowModal() == wx.ID_OK:
             path = filedlg.GetPath()
         else:
             return
         if (path != ""):
             if os.path.exists(path):
                 dlg = wx.MessageDialog(
                     self, _("File already exist, Overwrite it ?"),
                     _("Warning") + "!", wx.YES_NO | wx.ICON_WARNING)
                 result = dlg.ShowModal()
                 dlg.Destroy()
                 if (result != wx.ID_YES):
                     return 0
         self.filename[pageIdx] = path
         directory, extension = os.path.splitext(path)
         file = os.path.basename(path)
         self.notebookEditor.SetPageText(pageIdx,
                                         file.replace(extension, ""))
         fichier = codecs.open(path, 'w', 'utf8')
         for i in range(0, self.stcpage[pageIdx].GetLineCount()):
             fichier.writelines(unicode(self.stcpage[pageIdx].GetLine(i)))
         fichier.close()
         self.stcpage[pageIdx].SetSavePoint()
         return
Ejemplo n.º 26
0
    def debugCDC(self):
        ports = self.updateCDCPorts()

        if len(ports) > 0:
            self.pinguinoCDC = serial.Serial(ports[0], timeout=0.01)
            self.updateDebggingLog(_("Connected") + ": " + ports[0] + "\n")

        if len(ports) > 0:
            self.timer_CDC = wx.CallLater(10, self.CDCTimer)

        elif not self.menu.menuItemDebugNone.IsChecked():
            wx.CallLater(250, self.debugCDC)
Ejemplo n.º 27
0
    def debugCDC(self):
        ports = self.updateCDCPorts()

        if len(ports) > 0:
            self.pinguinoCDC = serial.Serial(ports[0], timeout=0.01)
            self.updateDebggingLog(_("Connected") + ": " + ports[0] + "\n")

        if len(ports) > 0:
            self.timer_CDC = wx.CallLater(10, self.CDCTimer)

        elif not self.menu.menuItemDebugNone.IsChecked():
            wx.CallLater(250, self.debugCDC)
Ejemplo n.º 28
0
 def getCodeSize(self, filename, board):
     codesize = 0
     address_Hi = 0
     memfree = board.memend - board.memstart
     fichier = open(filename + ".hex", 'r')
     lines = fichier.readlines()
     for line in lines:
         byte_count = int(line[1:3], 16)
         address_Lo = int(line[3:7], 16)
         record_type= int(line[7:9], 16)
         # extended linear address record
         if record_type == 4:
             address_Hi = int(line[9:13], 16) << 16
                     # address calculation
         address = (address_Hi << 16) + address_Lo
         # code size
         if record_type == 0:
             if address >= board.memstart:
                 codesize = codesize + byte_count
     fichier.close()
     return _("code size: ") + str(codesize) + " / " + str(memfree) + " " + _("bytes") + " (" + str(100*codesize/memfree) + "% " +_("used")+ ")" 
Ejemplo n.º 29
0
    def getRevision(self):
        sw = SubversionWorkingCopy(HOME_DIR).current_version()
        try: sw = SubversionWorkingCopy(HOME_DIR).current_version()
        except: sw = _("unknown")
        wx.PostEvent(self, ResultEventRevision(sw))

        if self.getElse("IDE", "checkupgradeatstart", "False") == "True":
            try:
                svnRev = SubversionRepository(SVN_DIR)
                self.lastRevision = svnRev.current_version()
                #self.lastRevision = "<<TESTING>>" #To force a update at start
                wx.PostEvent(self, ResultEventRevision([svnRev]))
            except: self.lastRevision = False
Ejemplo n.º 30
0
    def OnContexMenuTools(self, event):
        menu = wx.Menu()
        self.popupIDhelp0 = wx.NewId()
        self.popupIDhelp1 = wx.NewId()
        self.popupIDhelp2 = wx.NewId()

        word = self.wordUnderCursor(True)

        if word in self.keywordList:
            self.Bind(wx.EVT_MENU,
                      lambda x: webbrowser.open(self.wikiDoc + word),
                      id=self.popupIDhelp1)
            self.Bind(wx.EVT_MENU,
                      lambda x: self.OnKeyword(keyword=word),
                      id=self.popupIDhelp2)

            help = wx.Menu()
            help.Append(self.popupIDhelp1,
                        _("Open wiki page in the web browser"))
            help.Append(self.popupIDhelp2, _("Read description"))

            menu.AppendMenu(self.popupIDhelp0, word, help)
            menu.AppendSeparator()

        menu.AppendItem(self.menu.menuItemComment_Uncomment)
        menu.AppendItem(self.menu.menuItemIndent)
        menu.AppendItem(self.menu.menuItemUnIndent)
        menu.AppendSeparator()
        menu.AppendItem(self.menu.menuItemUndo)
        menu.AppendItem(self.menu.menuItemRedo)
        menu.AppendSeparator()
        menu.AppendItem(self.menu.menuItemCut)
        menu.AppendItem(self.menu.menuItemCopy)
        menu.AppendItem(self.menu.menuItemPaste)
        menu.AppendSeparator()
        menu.AppendItem(self.menu.menuItemClear)

        self.PopupMenu(menu)
Ejemplo n.º 31
0
    def getCodeSize(self, filename, board):
        codesize = 0
        address_Hi = 0
        if board.arch == 32:
            memfree = board.memend - board.ebase  #memstart
        else:
            memfree = board.memend - board.memstart
        print "%X" % board.memstart
        print "%X" % board.memend
        fichier = open(filename + ".hex", 'r')
        lines = fichier.readlines()

        for line in lines:

            byte_count = int(line[1:3], 16)
            address_Lo = int(line[3:7], 16)
            record_type = int(line[7:9], 16)

            # extended linear address record
            if record_type == 4:
                address_Hi = int(line[9:13], 16) << 16

            # code size
            if record_type == 0:

                # address calculation
                address = address_Hi + address_Lo
                #print "address=%X"%address;
                #self.displaymsg(_("address = %X" % address),0)

                #if address >= board.memstart:
                if (address >= board.memstart) and (address < board.memend):
                    codesize = codesize + byte_count

        fichier.close()
        return _("code size: ") + str(codesize) + " / " + str(
            memfree) + " " + _("bytes") + " (" + str(
                100 * codesize / memfree) + "% " + _("used") + ")"
Ejemplo n.º 32
0
 def getCodeSize(self, filename, board):
     codesize = 0
     address_Hi = 0
     memfree = board.memend - board.memstart
     fichier = open(filename + ".hex", 'r')
     lines = fichier.readlines()
     for line in lines:
         byte_count = int(line[1:3], 16)
         address_Lo = int(line[3:7], 16)
         record_type = int(line[7:9], 16)
         # extended linear address record
         if record_type == 4:
             address_Hi = int(line[9:13], 16) << 16
             # address calculation
         address = (address_Hi << 16) + address_Lo
         # code size
         if record_type == 0:
             if address >= board.memstart:
                 codesize = codesize + byte_count
     fichier.close()
     return _("code size: ") + str(codesize) + " / " + str(
         memfree) + " " + _("bytes") + " (" + str(
             100 * codesize / memfree) + "% " + _("used") + ")"
Ejemplo n.º 33
0
    def CloseTab(self):
        """ close the current tab """
        if len(self.onglet) <= 0: return False

        pageIdx = self.notebookEditor.GetSelection()
        if self.notebookEditor.GetPageText(pageIdx)[0] == "*":
            dlg = wx.MessageDialog(self, _("Save file ?"),
                                   _("Warning") + "!",
                                   wx.YES_NO | wx.ICON_WARNING | wx.CANCEL)
            result = dlg.ShowModal()
            dlg.Destroy()
            if (result == wx.ID_CANCEL): return True
            if (result == wx.ID_YES): self.Save("Pde File", "pde")
        self.filename.remove(self.filename[pageIdx])
        self.onglet.remove(self.onglet[pageIdx])
        self.stcpage.remove(self.stcpage[pageIdx])
        self.notebookEditor.DeletePage(pageIdx)
        self.sheetFunctions.remove(self.sheetFunctions[pageIdx])
        #self.choiceFunctions.remove(self.choiceFunctions[page])
        if pageIdx > 0:
            self.notebookEditor.SetSelection(pageIdx - 1)
            self.notebookEditor.Update()
        return True
Ejemplo n.º 34
0
    def OnContexMenuTools(self, event):
        menu = wx.Menu()
        self.popupIDhelp0 = wx.NewId()
        self.popupIDhelp1 = wx.NewId()
        self.popupIDhelp2 = wx.NewId()

        word=self.wordUnderCursor(True)

        if word in self.keywordList:
            self.Bind(wx.EVT_MENU,
                      lambda x:webbrowser.open(self.wikiDoc+word),
                      id=self.popupIDhelp1)
            self.Bind(wx.EVT_MENU,
                      lambda x:self.OnKeyword(keyword=word),
                      id=self.popupIDhelp2)           

            help = wx.Menu()
            help.Append(self.popupIDhelp1, _("Open wiki page in the web browser"))
            help.Append(self.popupIDhelp2, _("Read description"))

            menu.AppendMenu(self.popupIDhelp0, word, help)          
            menu.AppendSeparator()

        menu.AppendItem(self.menu.menuItemComment_Uncomment)
        menu.AppendItem(self.menu.menuItemIndent)
        menu.AppendItem(self.menu.menuItemUnIndent)
        menu.AppendSeparator()
        menu.AppendItem(self.menu.menuItemUndo)
        menu.AppendItem(self.menu.menuItemRedo)
        menu.AppendSeparator()
        menu.AppendItem(self.menu.menuItemCut)
        menu.AppendItem(self.menu.menuItemCopy)
        menu.AppendItem(self.menu.menuItemPaste)
        menu.AppendSeparator()
        menu.AppendItem(self.menu.menuItemClear)

        self.PopupMenu(menu)
Ejemplo n.º 35
0
    def getCodeSize(self, filename, board):
        codesize = 0
        address_Hi = 0
        if board.arch == 32:
            memfree = board.memend - board.ebase #memstart
        else:
            memfree = board.memend - board.memstart
        print "%X"%board.memstart
        print "%X"%board.memend
        fichier = open(filename + ".hex", 'r')
        lines = fichier.readlines()

        for line in lines:

            byte_count = int(line[1:3], 16)
            address_Lo = int(line[3:7], 16)
            record_type= int(line[7:9], 16)

            # extended linear address record
            if record_type == 4:
                address_Hi = int(line[9:13], 16) << 16

            # code size
            if record_type == 0:

                # address calculation
                address = address_Hi + address_Lo
                #print "address=%X"%address;
                #self.displaymsg(_("address = %X" % address),0)
                
                #if address >= board.memstart:
                if (address >= board.memstart) and (address < board.memend):
                    codesize = codesize + byte_count

        fichier.close()
        return _("code size: ") + str(codesize) + " / " + str(memfree) + " " + _("bytes") + " (" + str(100*codesize/memfree) + "% " +_("used")+ ")" 
Ejemplo n.º 36
0
    def new_choices_fam(self):
        try:
            self.radioBox_fam.Destroy()
        except:
            pass
        #columns, self.radioBox_famChoices = self.IDE.getfamilies(self.ARCH, self.MODE)
        #if not self.radioBox_famChoices: #if no families dfined, then, {8-bit/boot, 32-bit}

        if self.ARCH == 8 and self.MODE == "BOOT":
            self.radioBox_botChoices = [
                "Bootloader v1.x or v2.x", "Bootloader v4.x"
            ]
            self.radioBox_fam = wx.RadioBox(self.m_panel37,
                                            wx.ID_ANY,
                                            _(u"Bootloader"),
                                            wx.DefaultPosition,
                                            wx.DefaultSize,
                                            self.radioBox_botChoices,
                                            majorDimension=2)
            self.r_fam()

            self.BOOTLOADER = self.getCurrentBootloader()
            index = self.Boot.index(self.BOOTLOADER)

            self.radioBox_fam.SetSelection(index - 1)

            self.buildChoicesFam()
            self.new_choices_dev()
            return

        else:
            self.new_choices_dev()
            return

        #if self.ARCH == 8:
        #self.radioBox_fam = wx.RadioBox( self.m_panel37, wx.ID_ANY, _(u"Family"), wx.DefaultPosition, wx.DefaultSize, self.radioBox_famChoices, majorDimension=columns)
        #self.radioBox_fam.SetSelection( 0 )
        #self.buildChoicesFam()
        #self.new_choices_dev()
        #if self.FAMILY in self.radioBox_famChoices:
        #index = self.radioBox_famChoices.index(self.FAMILY)
        #self.radioBox_fam.SetSelection(index)
        #return

        if self.ARCH == 8: self.new_choices_dev()
        else:
            if self.MODE == "BOOT": self.new_choices_dev()
            elif self.MODE == "ICSP": self.new_choices_dev()
Ejemplo n.º 37
0
    def setBoard(self, arch, mode, name, bootloader):

        self.changingBoard = True

        self.rw = []
        self.regobject = []
        self.keywordList = []
        self.reservedword = []
        self.libinstructions = []

        self.modeCompile = mode

        if mode == "BOOT":
            for board in boardlist:
                if name == board.name:
                    self.curBoard = board
                    if bootloader == "noboot":
                        self.curBoard.bldr = "noboot"
                        self.curBoard.memstart = 0x0000
                    else:
                        self.curBoard.bldr = bootloader[0]
                        self.curBoard.memstart = int(bootloader[1])

            if arch == 8: textStatus=self.curBoard.name + " [" + bootloader[0] + "]"
            if arch == 32: textStatus=self.curBoard.name

        else:
            self.curBoard = boardlist[0]
            self.curBoard.name = name
            for board in boardlist:
                if name == board.name: self.curBoard.proc = board.proc
            self.curBoard.board = "PIC"+name.upper()
            self.curBoard.memstart = 0x0000
            #self.curBoard.memend = devlist[self.curBoard.proc][1]*1024 
            warning = "\nWARNING!! this mode can overwrite the bootloader code.\n"
            textStatus = self.curBoard.name + " [ICSP]"

            
        self.displaymsg(_("Changing board")+"...", 0)
        self.statusBarEditor.SetStatusText(number=2, text=textStatus)
        if sys.platform=='darwin':
            self.readlib(self.curBoard, textStatus) #So slow
        else:
            self.Thread_curBoard = threading.Thread(target=self.readlib, args=(self.curBoard, textStatus))
            self.Thread_curBoard.start()

        if warning: self.displaymsg(warning, False)
 def replacealltext(self, event):
     textEdit = self.IDE.stcpage[self.IDE.notebookEditor.GetSelection()]
     word = str(self.FindText.GetValue())
     wordReplace = str(self.ReplaceText.GetValue())
     result = self.findWord(word)
     count = result["count"]
     
     plain = str(textEdit.GetTextUTF8())
     plain = plain.replace(word, wordReplace)
     
     pos = textEdit.CurrentPos
     
     textEdit.ClearAll()
     textEdit.AddText(plain)
     textEdit.GotoPos(pos)
     
     self.IDE.searchReplaceInfo.SetLabel(_("Replaced %d matches in the file.") %count)
Ejemplo n.º 39
0
    def new_choices_dev(self):
        try:
            self.radioBox_dev.Destroy()
            self.m_scrolledWindow1.Destroy()
        except: pass 
        columns, self.radioBox_devChoices = self.IDE.getDevices(self.ARCH)

        self.m_scrolledWindow1 = wx.ScrolledWindow( self.m_panel37, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.HSCROLL|wx.VSCROLL )
        self.m_scrolledWindow1.SetScrollRate( 5, 5 )
        self.sizer2 = wx.BoxSizer( wx.VERTICAL )
        
        if self.radioBox_devChoices:
            self.radioBox_dev = wx.RadioBox( self.m_scrolledWindow1, wx.ID_ANY, _(u"Devices"), wx.DefaultPosition, wx.DefaultSize, self.radioBox_devChoices, majorDimension=columns)
            self.radioBox_dev.SetSelection( 0 )
            self.radioBox_dev.Bind(wx.EVT_RADIOBOX, self.r_device)

            self.buildChoicesDev()
Ejemplo n.º 40
0
    def replacealltext(self, event):
        textEdit = self.stcpage[self.notebookEditor.GetSelection()]
        word = str(self.FindText.GetValue())
        wordReplace = str(self.ReplaceText.GetValue())
        result = self.findWord(word)
        count = result["count"]

        plain = str(textEdit.GetTextUTF8())
        plain = plain.replace(word, wordReplace)

        pos = textEdit.CurrentPos

        textEdit.ClearAll()
        textEdit.AddText(plain)
        textEdit.GotoPos(pos)

        self.lat.searchReplaceInfo.SetLabel(
            _("Replaced %d matches in the file.") % count)
Ejemplo n.º 41
0
    def OpenDialog(self,wildcard):
        """ Open Dialog and load file in a new editor """

        try: defaultDir=os.path.split(self.filename[self.notebookEditor.GetSelection()])[0]
        except: defaultDir = os.getcwd()

        opendlg = wx.FileDialog(self,
                                message=_("Choose a file"),
                                #defaultDir=os.getcwd(),
                                defaultDir=defaultDir, 
                                defaultFile="",
                                wildcard=wildcard,
                                style=wx.OPEN  | wx.CHANGE_DIR)

        if opendlg.ShowModal() == wx.ID_OK:
            paths = opendlg.GetPaths()
            for path in paths:
                self.Open(path)
Ejemplo n.º 42
0
 def __init__(self):
     """"""
     # bmp = wx.Image(os.path.join("theme", "logoX3.png")).ConvertToBitmap()
     image = wx.Image(os.path.join("theme", "logoX3.png"), wx.BITMAP_TYPE_PNG)
     image = image.Scale(500, 375, wx.IMAGE_QUALITY_HIGH)
     bmp = wx.BitmapFromImage(image)
     memDC = wx.MemoryDC()
     memDC.SetFont(wx.Font(10, wx.SWISS, wx.ITALIC, wx.NORMAL))
     memDC.SetTextForeground(wx.BLACK)
     memDC.SelectObject(bmp)
     memDC.DrawText(_("loading..."), 10, 355)
     memDC.SelectObject(wx.NullBitmap)
     # TODO : replace wx.BORDER_SIMPLE (windows only)
     wx.SplashScreen.__init__(
         self, bmp, wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT, 5000, None, -1, style=wx.BORDER_SIMPLE
     )
     self.Bind(wx.EVT_CLOSE, self.OnClose)
     self.fc = wx.FutureCall(2000, self.ShowMain)
Ejemplo n.º 43
0
 def b_acept(self, event=None):
     if self.ARCH == 32 and self.MODE == "ICSP":
         dlg = wx.MessageDialog(self,
                                 _("ICSP mode for 32-bit architecture not supported yet."), _("Warning")+"!",
                                 wx.YES_DEFAULT | wx.ICON_WARNING
                                 )
         result=dlg.ShowModal()
         dlg.Destroy()
         return
         
     self.IDE.setConfig("Board", "architecture", self.ARCH)
     self.IDE.setConfig("Board", "mode", self.MODE)
     self.IDE.setConfig("Board", "device", self.DEVICE)
     #self.IDE.setConfig("Board", "family", self.FAMILY)
     self.IDE.setConfig("Board", "bootloader", self.BOOTLOADER)
     self.IDE.saveConfig()
     self.IDE.setBoard(self.ARCH, self.MODE, self.DEVICE, self.BOOTLOADER)  #To set board in wxgui/pinguino.py
     self.Close()
Ejemplo n.º 44
0
    def updateCDCPorts(self, max_ports=20):
        list_ports = []
        for i in range(max_ports):
            try:
                port = serial.Serial(self.CDC_NAME_PORT %i)
                port.close()
                list_ports.append(self.CDC_NAME_PORT %i)
            except: pass
            
        self.choicePort.Enable()
        self.choicePort.Clear()
        self.choicePort.AppendItems(list_ports)
        self.choicePort.SetSelection(len(list_ports))
        
        if len(list_ports) == 0: self.choicePort.AppendItems([_("No ports")])

        if len(list_ports) <= 1:
            self.choicePort.SetSelection(0)
            self.choicePort.Disable()
            
        return list_ports
Ejemplo n.º 45
0
    def OpenDialog(self, wildcard):
        """ Open Dialog and load file in a new editor """

        try:
            defaultDir = os.path.split(
                self.filename[self.notebookEditor.GetSelection()])[0]
        except:
            defaultDir = os.getcwd()

        opendlg = wx.FileDialog(
            self,
            message=_("Choose a file"),
            #defaultDir=os.getcwd(),
            defaultDir=defaultDir,
            defaultFile="",
            wildcard=wildcard,
            style=wx.OPEN | wx.CHANGE_DIR)

        if opendlg.ShowModal() == wx.ID_OK:
            paths = opendlg.GetPaths()
            for path in paths:
                self.Open(path)
Ejemplo n.º 46
0
 def new_choices_fam(self):
     try: self.radioBox_fam.Destroy()
     except: pass 
     #columns, self.radioBox_famChoices = self.IDE.getfamilies(self.ARCH, self.MODE)
     #if not self.radioBox_famChoices: #if no families dfined, then, {8-bit/boot, 32-bit}
         
     if self.ARCH == 8 and self.MODE == "BOOT":
         self.radioBox_botChoices = ["Bootloader v1.x or v2.x", "Bootloader v4.x"]
         self.radioBox_fam = wx.RadioBox( self.m_panel37, wx.ID_ANY, _(u"Bootloader"), wx.DefaultPosition, wx.DefaultSize, self.radioBox_botChoices, majorDimension=2)
         self.r_fam()
         
         self.BOOTLOADER = self.getCurrentBootloader()
         index = self.Boot.index(self.BOOTLOADER)
         
         self.radioBox_fam.SetSelection( index-1 )
         
         self.buildChoicesFam()    
         self.new_choices_dev()
         return
     
     else:
         self.new_choices_dev()
         return
         
         
     #if self.ARCH == 8:
         #self.radioBox_fam = wx.RadioBox( self.m_panel37, wx.ID_ANY, _(u"Family"), wx.DefaultPosition, wx.DefaultSize, self.radioBox_famChoices, majorDimension=columns)
         #self.radioBox_fam.SetSelection( 0 )	
         #self.buildChoicesFam()
         #self.new_choices_dev()
         #if self.FAMILY in self.radioBox_famChoices:
             #index = self.radioBox_famChoices.index(self.FAMILY)
             #self.radioBox_fam.SetSelection(index)	
         #return
     
     if self.ARCH == 8: self.new_choices_dev()
     else:
         if self.MODE == "BOOT": self.new_choices_dev()
         elif self.MODE == "ICSP": self.new_choices_dev()
Ejemplo n.º 47
0
 def __init__(self):
     """"""
     #bmp = wx.Image(os.path.join("theme", "logoX3.png")).ConvertToBitmap()
     image = wx.Image(os.path.join("theme", "logoX3.png"),
                      wx.BITMAP_TYPE_PNG)
     image = image.Scale(500, 375, wx.IMAGE_QUALITY_HIGH)
     bmp = wx.BitmapFromImage(image)
     memDC = wx.MemoryDC()
     memDC.SetFont(wx.Font(10, wx.SWISS, wx.ITALIC, wx.NORMAL))
     memDC.SetTextForeground(wx.BLACK)
     memDC.SelectObject(bmp)
     memDC.DrawText(_("loading..."), 10, 355)
     memDC.SelectObject(wx.NullBitmap)
     # TODO : replace wx.BORDER_SIMPLE (windows only)
     wx.SplashScreen.__init__(self,
                              bmp,
                              wx.SPLASH_CENTRE_ON_SCREEN
                              | wx.SPLASH_TIMEOUT,
                              5000,
                              None,
                              -1,
                              style=wx.BORDER_SIMPLE)
     self.Bind(wx.EVT_CLOSE, self.OnClose)
     self.fc = wx.FutureCall(2000, self.ShowMain)
 def findWord(self, word):
     if word == "": return 
     
     textEdit = self.IDE.stcpage[self.IDE.notebookEditor.GetSelection()]
     if self.IDE.checkBox_sensitive.IsChecked():
         plain = str(textEdit.GetTextUTF8())
         word = str(word)
     else:
         plain = str(textEdit.GetTextUTF8()).lower()
         word = str(word).lower()
 
     count = plain.count(word)
     finds = [plain.find(word)]
     while finds[-1] != -1: finds.append(plain.find(word, finds[-1]+1))
     finds.pop(-1)
     
     
     result = {"word": word,
               "count": len(finds),
               "finds": finds,}
     
     self.IDE.searchReplaceInfo.SetLabel(_("Finded %d matches in the file.") %len(finds))
     
     return result
Ejemplo n.º 49
0
    def readlib(self, board, textStatus=""):
        """Load .pdl or .pdl32 files (keywords and libraries)
         trying to find PDL files to store reserved words."""

        self.keywordList = []
        if board.arch == 8:
            libext = '.pdl'
            libdir = P8_DIR
        else:
            libext = '.pdl32'
            libdir = P32_DIR
        #for fichier in os.listdir(os.path.join(libdir, 'lib')):
        for fichier in os.listdir(os.path.join(libdir, 'pdl')):
            filename, extension = os.path.splitext(fichier)
            if extension == libext:
                # check content of the PDL file
                #libfile=open(os.path.join(libdir, 'lib', fichier),'r')
                libfile = open(os.path.join(libdir, 'pdl', fichier), 'r')
                for line in libfile:
                    if line != "\n":
                        # arduino's instruction
                        instruction = line[0:line.find(" ")]
                        self.keywordList.append(instruction)
                        # library's instruction
                        cnvinstruction = line[line.find(" ") +
                                              1:line.find("#")]
                        # find #include & #define
                        #include=line[line.find("#")+1:len(line)]
                        include = ""
                        define = ""
                        explode = line.split("#")
                        if len(explode) >= 2:
                            include = explode[1]
                        if len(explode) == 3:
                            define = explode[2]
                        # append to the list
                        self.libinstructions.append(
                            [instruction, cnvinstruction, include, define])
                        #regex = re.compile(r"(^|[' ']|['=']|['{']|[',']|[\t]|['(']|['!'])"+str(instruction))+"[ ]*\(")
                        #regex = re.compile(r"(^|[' ']|['=']|['{']|[',']|[\t]|['(']|['!'])"+str(instruction)+r"([' ']|['=']|['}']|[',']|[';']|[\t]|[')'].*)")
                        #regex = re.compile(r"(^|[' ']|['=']|['{']|[',']|[\t]|['(']|['!'])"+str(instruction)+".*")
                        #regex = re.compile(r'\W%s\W' % re.escape(str(instruction)))
                        regex = re.compile(
                            r"(^|[' ']|['=']|['{']|[',']|[\t]|['(']|['!'])%s\W"
                            % re.escape(str(instruction)))
                        self.regobject.append(regex)
                libfile.close()
        # clean up the keyword list
        self.keywordList.sort()
        self.keywordList = self.ClearRedundancy(self.keywordList)
        self.keywordNum = len(self.keywordList)
        # make reserved words list
        if len(self.libinstructions) != 0:
            for i in range(len(self.libinstructions)):
                chaine = self.libinstructions[i][0]
                self.rw.append(chaine)
                pos = chaine.find(".")
                if pos != -1:
                    self.reservedword.append(chaine[0:pos])
                    self.reservedword.append(chaine[pos + 1:len(chaine)])
                else:
                    self.reservedword.append(chaine)
            # sort keywords for short key help
            self.rw.sort(key=lambda x: x.lower())
        # adding fixed reserved word
        fixed_rw = ("setup", "loop", "HIGH", "LOW", "INPUT", "OUTPUT", "void",
                    "FOSC", "MIPS", "ON", "OFF", "TRUE", "FALSE")
        for i in range(len(fixed_rw)):
            self.reservedword.append(fixed_rw[i])

        #if gui==True: # or AttributeError: 'Pinguino' object has no attribute 'extraName'
        #self.displaymsg(_("Board config")+":\t"+textStatus, 0, force_update=False)
        #else:
        self.displaymsg(_("Board config") + ":\t" + textStatus,
                        0,
                        force_update=False)

        self.changingBoard = False
Ejemplo n.º 50
0
    def OnVerify(self, event=None):
        if self.changingBoard:
            self.displaymsg(_("Please wait a moment.") + "\n", 0)
            return

        self.displaymsg("", 1)

        #self.in_verify=1
        t0 = time.time()
        if self.GetPath() == -1:
            dlg = wx.MessageDialog(self, _('Open file first !!'), _('Warning'),
                                   wx.OK | wx.ICON_WARNING)
            result = dlg.ShowModal()
            dlg.Destroy()
            return False

        self.displaymsg(_("Board:\t") + " " + self.curBoard.name, 1)
        self.displaymsg(_("Proc:\t") + " " + self.curBoard.proc, 0)
        self.displaymsg(_("File:\t") + " " + self.GetPath(), 0)
        self.displaymsg(_("compiling") + ("..."), 0)

        self.OnSave()
        filename = self.GetPath()
        filename, extension = os.path.splitext(filename)
        if os.path.exists(filename + ".hex"):
            os.remove(filename + ".hex")
        if os.path.exists(os.path.join(SOURCE_DIR, "user.c")):
            os.remove(os.path.join(SOURCE_DIR, "user.c"))
        retour = self.preprocess(filename, self.curBoard)
        if retour == "error":
            return False
        # compilation
        if self.curBoard.arch == 8:
            MAIN_FILE = "main.hex"
        else:
            MAIN_FILE = "main32.hex"
        retour = self.compile(filename, self.curBoard)
        if retour != 0:
            self.displaymsg(_("error while compiling"), 0)
            self.displaymsg(_("check highlighted lines in your code"), 0)
            self.displaymsg(
                _("You can review the file stdout (F8) for more information."),
                0)
        else:
            retour = self.link(filename, self.curBoard)
            if os.path.exists(os.path.join(SOURCE_DIR, MAIN_FILE)) != True:
                self.displaymsg(
                    _("error while linking") + " " + filename + ".o", 0)
                self.displaymsg(
                    _("You can review the file stdout (F8) for more information."
                      ), 0)
                return False
            else:
                shutil.copy(os.path.join(SOURCE_DIR, MAIN_FILE),
                            filename + ".hex")
                self.displaymsg(_("compilation done"), 0)
                self.displaymsg(self.getCodeSize(filename, self.curBoard), 0)
                t = "%.1f" % (time.time() - t0)
                self.displaymsg(t + " " + _("seconds process time"), 0)
                os.remove(os.path.join(SOURCE_DIR, MAIN_FILE))
                #os.remove(filename+".c")
                return True
        #self.in_verify=0
        self.focus()
Ejemplo n.º 51
0
    def setBoard(self, arch, mode, name, bootloader):

        self.changingBoard = True

        self.rw = []
        self.regobject = []
        self.keywordList = []
        self.reservedword = []
        self.libinstructions = []

        self.modeCompile = mode
        warning = ""

        # RB 17/09/2013
        for board in boardlist:
            if name == board.name:
                self.curBoard = board
                self.curBoard.bldr = bootloader[0]
                self.curBoard.memstart = int(bootloader[1])
                if arch == 32:
                    textStatus = self.curBoard.name
                else:
                    if mode != "BOOT":
                        self.curBoard.bldr = "noboot"
                        self.curBoard.memstart = 0x0000
                        warning = "\nWARNING!! Bootloader will be erased.\n"
                        textStatus = self.curBoard.name + " [ICSP]"
                    else:
                        textStatus = self.curBoard.name + " [" + bootloader[
                            0] + "]"
        """
        if mode == "BOOT":
            for board in boardlist:
                if name == board.name:
                    self.curBoard = board
                    if bootloader == "noboot":
                        self.curBoard.bldr = "noboot"
                        self.curBoard.memstart = 0x0000
                    else:
                        self.curBoard.bldr = bootloader[0]
                        self.curBoard.memstart = int(bootloader[1])
            
            if arch == 8: textStatus=self.curBoard.name + " [" + bootloader[0] + "]"
            if arch == 32: textStatus=self.curBoard.name
            
        else:
            self.curBoard = boardlist[0]
            self.curBoard.name = name
            for board in boardlist:
                if name == board.name: self.curBoard.proc = board.proc
            self.curBoard.board = "PIC"+name.upper()
            self.curBoard.memstart = 0x0000
            #self.curBoard.memend = devlist[self.curBoard.proc][1]*1024 
            warning = "\nWARNING!! this mode can overwrite the bootloader code.\n"
            textStatus = self.curBoard.name + " [ICSP]"
        """

        self.displaymsg(_("Changing board") + "...", 0)
        self.statusBarEditor.SetStatusText(number=2, text=textStatus)
        if sys.platform == 'darwin':
            self.readlib(self.curBoard, textStatus)  #So slow
        else:
            self.Thread_curBoard = threading.Thread(target=self.readlib,
                                                    args=(self.curBoard,
                                                          textStatus))
            self.Thread_curBoard.start()

        if warning: self.displaymsg(warning, False)
Ejemplo n.º 52
0
 def __initDockFile__(self):
     self.lateralFunc = self.lat.listCtrlFunc
     self.lateralVars = self.lat.listCtrlVars
     self.lateralDefi = self.lat.listCtrlDefi
     
     self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.moveToFunc, self.lateralFunc)
     self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.moveToVar, self.lateralVars)
     self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.moveToDefi, self.lateralDefi)
 
     self.lateralVars.InsertColumn(col=0, format=wx.LIST_FORMAT_LEFT, heading=_("Name"), width=-1)
     self.lateralVars.InsertColumn(col=1, format=wx.LIST_FORMAT_LEFT, heading=_("Type"), width=-1)
     self.lateralVars.InsertColumn(col=2, format=wx.LIST_FORMAT_LEFT, heading=_("Line"), width=1000)
 
     self.lateralFunc.InsertColumn(col=0, format=wx.LIST_FORMAT_LEFT, heading=_("Name"), width=-1) 
     self.lateralFunc.InsertColumn(col=1, format=wx.LIST_FORMAT_LEFT, heading=_("Return"), width=-1) 
     self.lateralFunc.InsertColumn(col=2, format=wx.LIST_FORMAT_LEFT, heading=_("Line"), width=40)
     self.lateralFunc.InsertColumn(col=3, format=wx.LIST_FORMAT_LEFT, heading=_("Parameters"), width=1000)
     
     self.lateralDefi.InsertColumn(col=0, format=wx.LIST_FORMAT_LEFT, heading=_("Directive"), width=130) 
     self.lateralDefi.InsertColumn(col=1, format=wx.LIST_FORMAT_LEFT, heading=_("Name"), width=130) 
     self.lateralDefi.InsertColumn(col=2, format=wx.LIST_FORMAT_LEFT, heading=_("Value"), width=130) 
     self.lateralDefi.InsertColumn(col=3, format=wx.LIST_FORMAT_LEFT, heading=_("Line"), width=1000)
Ejemplo n.º 53
0
    def contexMenuTools(self, event):
        textEdit = self.stcpage[self.notebookEditor.GetSelection()]
        menu = wx.Menu()
        self._initIDs_(self.stcpage[self.notebookEditor.GetSelection()])

        word=self.wordUnderCursor(True)

        if word in self.keywordList:
            self.Bind(wx.EVT_MENU,
                      lambda x:webbrowser.open(self.wikiDoc+word),
                      id=self.popupIDhelp1)
            self.Bind(wx.EVT_MENU,
                      lambda x:self.OnKeyword(keyword=word),
                      id=self.popupIDhelp2)           

            help = wx.Menu()
            help.Append(self.popupIDhelp1, _("Open wiki page in the web browser"))
            help.Append(self.popupIDhelp2, _("Read description"))

            menu.AppendMenu(self.popupIDhelp0, word, help)          
            menu.AppendSeparator()

        menu.Append(self.popupID8, _("Comment/Uncomment"))
        menu.Append(self.popupID9, _("Increase Indent"))
        menu.Append(self.popupID10, _("Decrease Indent"))

        menu.AppendSeparator()

        menu.Append(self.popupID1, _("Undo"))
        menu.Append(self.popupID2, _("Redo"))
        menu.AppendSeparator()
        menu.Append(self.popupID3, _("Cut"))
        menu.Append(self.popupID4, _("Copy"))
        menu.Append(self.popupID5, _("Paste"))
        menu.Append(self.popupID6, _("Clear"))
        menu.AppendSeparator()
        menu.Append(self.popupID7, _("Clear All"))

        self.PopupMenu(menu)
        menu.Destroy()
Ejemplo n.º 54
0
	def current_version(self):
		try :
			return str(self.repository._client.info(self.path).revision.number)
		except:
			return _("unknown")
Ejemplo n.º 55
0
 def debuggingTimer(self, mode):
     self.updateDebggingLog(_("Debugging!") + "\n")
     if mode == "CDC": self.debugCDC()
Ejemplo n.º 56
0
    def __initDockFile__(self):
        self.lateralFunc = self.lat.listCtrlFunc
        self.lateralVars = self.lat.listCtrlVars
        self.lateralDefi = self.lat.listCtrlDefi

        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.moveToFunc,
                  self.lateralFunc)
        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.moveToVar, self.lateralVars)
        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.moveToDefi,
                  self.lateralDefi)

        self.lateralVars.InsertColumn(col=0,
                                      format=wx.LIST_FORMAT_LEFT,
                                      heading=_("Name"),
                                      width=-1)
        self.lateralVars.InsertColumn(col=1,
                                      format=wx.LIST_FORMAT_LEFT,
                                      heading=_("Type"),
                                      width=-1)
        self.lateralVars.InsertColumn(col=2,
                                      format=wx.LIST_FORMAT_LEFT,
                                      heading=_("Line"),
                                      width=1000)

        self.lateralFunc.InsertColumn(col=0,
                                      format=wx.LIST_FORMAT_LEFT,
                                      heading=_("Name"),
                                      width=-1)
        self.lateralFunc.InsertColumn(col=1,
                                      format=wx.LIST_FORMAT_LEFT,
                                      heading=_("Return"),
                                      width=-1)
        self.lateralFunc.InsertColumn(col=2,
                                      format=wx.LIST_FORMAT_LEFT,
                                      heading=_("Line"),
                                      width=40)
        self.lateralFunc.InsertColumn(col=3,
                                      format=wx.LIST_FORMAT_LEFT,
                                      heading=_("Parameters"),
                                      width=1000)

        self.lateralDefi.InsertColumn(col=0,
                                      format=wx.LIST_FORMAT_LEFT,
                                      heading=_("Directive"),
                                      width=130)
        self.lateralDefi.InsertColumn(col=1,
                                      format=wx.LIST_FORMAT_LEFT,
                                      heading=_("Name"),
                                      width=130)
        self.lateralDefi.InsertColumn(col=2,
                                      format=wx.LIST_FORMAT_LEFT,
                                      heading=_("Value"),
                                      width=130)
        self.lateralDefi.InsertColumn(col=3,
                                      format=wx.LIST_FORMAT_LEFT,
                                      heading=_("Line"),
                                      width=1000)
Ejemplo n.º 57
0
 def connect(event=None):
     self.pinguinoCDC = serial.Serial(name, timeout=1)
     self.logwindow.WriteText(_("Connected") + ": " + name + "\n")