示例#1
0
    def readFileName(self):

        #fileName=self.clientSocket.readData(bytesInSocket)
        fileName = self.clientSocket.read(self.clientSocket.bytesAvailable())
        dbgMsg("THIS IS FILENAME READ FROM CLIENT=", fileName)
        self.clientSocket.disconnectFromHost()
        self.newlyReadFileName.emit(fileName)
    def readFileName(self):

        # fileName=self.clientSocket.readData(bytesInSocket)
        fileName = self.clientSocket.read(self.clientSocket.bytesAvailable())
        dbgMsg("THIS IS FILENAME READ FROM CLIENT=", fileName)
        self.clientSocket.disconnectFromHost()
        self.newlyReadFileName.emit(fileName)
示例#3
0
    def updateShortcutDisplay(self):
        # s=self.keySequence.toString(QKeySequence.NativeText)
        s = ''
        dbgMsg("key=", self.key)
        dbgMsg("shiftPeessed=%x" % (Qt.SHIFT & self.key))
        dbgMsg("Qt.SHIFT = %x" % (Qt.SHIFT & ~Qt.SHIFT))
        dbgMsg("Qt.SHIFT = %x" % ~(Qt.SHIFT + 1))
        if self.modifiers:
            dbgMsg("GOT MODIFIERS")

            if self.modifiers & (Qt.CTRL):
                s += "Ctrl+"

            if self.modifiers & (Qt.SHIFT):
                s += "Shift+"

            if self.modifiers & (Qt.ALT):
                s += "Alt+"

            if self.modifiers & (Qt.META):
                s += "Meta+"
            # pressing non modifier key ends recording
            if self.key != Qt.Key_Shift and self.key != Qt.Key_Control and self.key != Qt.Key_Alt and self.key != Qt.Key_Meta:
                # dbgMsg("REGULAR KEY=", QChar(self.key).toAscii())
                self.doneRecording()

        if not self.sequence:
            self.keyLabel.setText(s)
        else:
            self.keyLabel.setText(
                self.sequence.toString(QKeySequence.NativeText))
示例#4
0
    def setSetting(self, _key, _value):
        if _key in ["UseTabSpaces","DisplayLineNumbers","FoldText","TabGuidelines","DisplayWhitespace","DisplayEOL","WrapLines","ShowWrapSymbol","DontShowWrapLinesWarning",\
        "RestoreTabsOnStartup","EnableAutocompletion","EnableQuickTextDecoding","FRInSelection","FRInAllSubfolders","FRTransparencyEnable","FROnLosingFocus","FRAlways"]: # Boolean values
            self.settings.setValue(_key, QVariant(_value))

        elif _key in [
                "TabSpaces", "ZoomRange", "ZoomRangeFindDisplayWidget",
                "AutocompletionThreshold", "FRSyntaxIndex", "FROpacity",
                "CurrentTabIndex", "CurrentPanelIndex"
        ]:  # integer values
            self.settings.setValue(_key, _value)

        elif _key in ["BaseFontName", "BaseFontSize",
                      "Theme"]:  # string values
            self.settings.setValue(_key, QVariant(_value))

        elif _key in [
                "RecentDocuments", "RecentDirectories", "InitialSize",
                "InitialPosition", "ListOfOpenFiles",
                "ListOfOpenFilesAndPanels", "FRSyntax", "FRFindHistory",
                "FRReplaceHistory", "FRFiltersHistory", "FRDirectoryHistory",
                "KeyboardShortcuts", "PluginAutoloadData"
        ]:  # QSize, QPoint,QStringList , QString values
            self.settings.setValue(_key, QVariant(_value))
        elif _key in ["PanelSplitterState"]:  # QByteArray
            self.settings.setValue(_key, QVariant(_value))

        else:
            dbgMsg("Wrong format of configuration option:", _key, ":", _value)
示例#5
0
    def cycleTabs(self):
        dbgMsg("QLabel cycleTabs")
        #highlightedItem is a list - [fileName,editor]
        highlightTextFlag = False
        if self.highlightedItem == self.openFileNames[
                -1]:  # we start highlighting cycle from the begining
            highlightTextFlag = True
        highlightingChanged = False

        if self.openFileNames:
            labelContent = ''
            for fileName in self.openFileNames:

                if highlightTextFlag:
                    dbgMsg("GOT HIGHLIGHT TEXT FLAG")
                    labelContent += "<b>" + fileName[0] + "</b><br>"
                    highlightTextFlag = False
                    self.highlightedItem = fileName
                    highlightingChanged = True
                    # dbgMsg("label content=",labelContent)

                else:
                    labelContent += fileName[0] + "<br>"
                # if firstName=='':
                if self.highlightedItem[0] == fileName[
                        0] and not highlightingChanged:
                    highlightTextFlag = True

            self.setText(labelContent)
            self.adjustSize()
示例#6
0
 def keyPressEvent(self, event):
     if event.key() == self.CtrlKeyEquivalent:
         dbgMsg("CTRL key pressed")
         self.ctrlPressed = True
         # if event.modifiers()==Qt.CtrlModifier:
         # dbgMsg("CTRL key pressed")
         self.ctrlPressed = True
    def cycleTabs(self):
        dbgMsg("QLabel cycleTabs")
        #highlightedItem is a list - [fileName,editor]
        highlightTextFlag=False
        if self.highlightedItem==self.openFileNames[-1]:# we start highlighting cycle from the begining
            highlightTextFlag=True
        highlightingChanged=False
        
        if self.openFileNames:
            labelContent=''
            for fileName in self.openFileNames:

               
                if highlightTextFlag:    
                    dbgMsg("GOT HIGHLIGHT TEXT FLAG")
                    labelContent+="<b>"+fileName[0]+"</b><br>"
                    highlightTextFlag=False 
                    self.highlightedItem=fileName
                    highlightingChanged=True
                    # dbgMsg("label content=",labelContent)
                    
                else:
                    labelContent+=fileName[0]+"<br>"    
                # if firstName=='':
                if self.highlightedItem[0]==fileName[0] and not highlightingChanged:
                    highlightTextFlag=True    
                    
            self.setText(labelContent)
示例#8
0
def writeBOM(_fh, _encoding=None):

    # dealing with big endian/little endian BOM

    if not _encoding:

        return

    if _encoding == "utf-16be":

        _fh.write('\ufeff')

        dbgMsg(
            "WRITING utf-16be BOM *********************************************"
        )

    elif _encoding == "utf-16le":

        _fh.write('\ufffe')

    elif _encoding == "utf-32be":

        _fh.write('\u0000\ufeff')

    elif _encoding == "utf-32le":

        _fh.write('\ufffe\u0000')

    # elif _encoding=="utf-8-bom":

    # _fh.write(u'\uefbb\ubf00')

    else:

        return
示例#9
0
 def __init__(self, parent=None):
     super(CycleTabsPopup, self).__init__(parent)
     self.editorWindow=parent
     self.setText("THIS IS CYCLE WINDOWS TAB")
     # self.__text = unicode(text)
     self.setWindowFlags(Qt.Popup|Qt.FramelessWindowHint)
     # palette = QPalette()
     palette=self.palette()
     palette.setColor(self.backgroundRole(),QColor('#F5F6CE'))
     self.setPalette(palette)
     font=self.font()
     font.setPointSize(9)
     # on mac base size font has to be gibber than on linux or windows - otherwise letters are too small
     if sys.platform.startswith('darwin'):
         font.setPointSize(11)
     
     self.setFont(font)
     # self.setBackgroundRole(QtPalette.Light)
     # self.setWindowFlags(Qt.FramelessWindowHint)
     self.setTextFormat(Qt.RichText)
     # self.setupUi(self)        
     
     self.ctrlTabShortcut=QShortcut(QKeySequence("Ctrl+Tab") ,self)
     self.CtrlKeyEquivalent=Qt.Key_Control
     
     if sys.platform.startswith("darwin"):
         self.ctrlTabShortcut=QShortcut(QKeySequence("Alt+Tab") ,self)
         self.CtrlKeyEquivalent=Qt.Key_Alt
         
     self.connect( self.ctrlTabShortcut, SIGNAL("activated()"), self.cycleTabs )
     self.highlightedItem=''
     self.openFileNames=None
     self.cycleTabFilesList=None
     
     dbgMsg("self.editorWindow.pos()=",str(self.editorWindow.pos())+"\n\n\n\n")
示例#10
0
    def updateShortcutDisplay(self):
        # s=self.keySequence.toString(QKeySequence.NativeText)
        s = ''
        dbgMsg("key=", self.key)
        dbgMsg("shiftPeessed=%x" % (Qt.SHIFT & self.key))
        dbgMsg("Qt.SHIFT = %x" % (Qt.SHIFT & ~Qt.SHIFT))
        dbgMsg("Qt.SHIFT = %x" % ~(Qt.SHIFT + 1))
        if self.modifiers:
            dbgMsg("GOT MODIFIERS")

            if self.modifiers & (Qt.CTRL):
                s += "Ctrl+"

            if self.modifiers & (Qt.SHIFT):
                s += "Shift+"

            if self.modifiers & (Qt.ALT):
                s += "Alt+"

            if self.modifiers & (Qt.META):
                s += "Meta+"
            # pressing non modifier key ends recording    
            if self.key != Qt.Key_Shift and self.key != Qt.Key_Control and self.key != Qt.Key_Alt and self.key != Qt.Key_Meta:
                # dbgMsg("REGULAR KEY=", QChar(self.key).toAscii())
                self.doneRecording()

        if not self.sequence:
            self.keyLabel.setText(s)
        else:
            self.keyLabel.setText(self.sequence.toString(QKeySequence.NativeText))
示例#11
0
 def initializeTabFileList(self):
     
     if not len(self.tabList): # initialize from scratch if the list is empty - this is done on startup
         dbgMsg("INITIALIZE FILE TAB LIST\n\n\n\n")
         openFileDict={}
         for tabWidget in self.editorWindow.panels:
             for i in range(tabWidget.count()):
                 editor=tabWidget.widget(i)
                 if editor==tabWidget.currentWidget():
                     if self.editorWindow.getEditorFileName(editor)!="":
                         self.tabList.insert(0,[self.editorWindow.getEditorFileName(editor),editor])
                     else:
                         documentName=tabWidget.tabText(tabWidget.indexOf(editor)) 
                         self.tabList.insert(0,[documentName,editor])
                     self.tabDict[editor]=self.tabList[0][0]
                 else: 
                     if self.editorWindow.getEditorFileName(editor)!="":
                         self.tabList.append([self.editorWindow.getEditorFileName(editor),editor])
                     else:
                         documentName=tabWidget.tabText(tabWidget.indexOf(editor)) 
                         self.tabList.append([documentName,editor])                
                     # self.tabList.append([self.editorWindow.fileDict[editor][0],editor])
                     self.tabDict[editor]=self.tabList[-1][0]
                     
                 #storing items in the tabDict. tab dict will be used to compare if new items have been added to self.editorWindow.fileDict
                 # self.tabDict[editor]=self.editorWindow.fileDict[editor][0] 
                 # self.tabDict[editor]=self.tabList[-1] 
     else:
         self.refresh()
示例#12
0
 def installAutocompletionAPIs(self):
     # first determine where APIs are located
     # initial guess is in the "APIs" subrirestory of the directory which holds Configuration.py        
     tweditRootPath = os.path.dirname(Configuration.__file__)
     apisPath=os.path.join(tweditRootPath,"APIs")
     # check if it exists
     if not os.path.exists(apisPath):
         # when packaging on Windows with pyinstaller the path to executable is accesible via sys.executable as Python is bundled with the distribution
         # os.path.dirname(Configuration.__file__) returned by pyInstaller will not work without some modifications so it is best tu use os.path.dirname(sys.executable) approach
         tweditRootPath=os.path.dirname(sys.executable)
         apisPath=os.path.join(tweditRootPath,"APIs")
     
     
     
     dbgMsg("apisPath=",os.path.abspath(apisPath))
     
     
     self.loadSingleAPI("QsciLexerCPP",os.path.abspath(os.path.join(apisPath,"cplusplus.api")))
     self.loadSingleAPI("QsciLexerCSharp",os.path.abspath(os.path.join(apisPath,"csharp.api")))
     self.loadSingleAPI("QsciLexerCSS",os.path.abspath(os.path.join(apisPath,"css.api")))
     self.loadSingleAPI("QsciLexerHTML",os.path.abspath(os.path.join(apisPath,"html.api")))
     self.loadSingleAPI("QsciLexerJava",os.path.abspath(os.path.join(apisPath,"java.api")))
     self.loadSingleAPI("QsciLexerJavaScript",os.path.abspath(os.path.join(apisPath,"javascript.api")))
     self.loadSingleAPI("QsciLexerPearl",os.path.abspath(os.path.join(apisPath,"perl.api")))
     self.loadSingleAPI("QsciLexerPython",os.path.abspath(os.path.join(apisPath,"python.api")))
     self.loadSingleAPI("QsciLexerRuby",os.path.abspath(os.path.join(apisPath,"ruby.api")))
示例#13
0
 def keyPressEvent(self, event):
     if event.key()==self.CtrlKeyEquivalent:
         dbgMsg("CTRL key pressed")
         self.ctrlPressed=True
     # if event.modifiers()==Qt.CtrlModifier:
         # dbgMsg("CTRL key pressed")
         self.ctrlPressed=True
示例#14
0
 def startRecording(self):
     dbgMsg("start recording")
     self.grabKeyboard()
     self.keyLabel.setText('')
     self.nonShiftModifierPreseed = False
     self.grabButton.setEnabled(False)
     self.keySequence = QKeySequence()
     self.sequence = None
     self.recording = True
示例#15
0
 def keyReleaseEvent(self, event):
     if event.key() == self.CtrlKeyEquivalent:
         dbgMsg("CTRL RELEASED in QTextEdit")
         self.ctrlPressed = False
         self.close()
         # make lastly selected tab current
         self.cycleTabFilesList.makeItemCurrent(self.highlightedItem)
         self.openFileNames = None
         self.cycleTabFilesList = None
示例#16
0
 def keyReleaseEvent(self, event):
     if event.key()==self.CtrlKeyEquivalent:
         dbgMsg("CTRL RELEASED in QTextEdit")
         self.ctrlPressed=False
         self.close()
         # make lastly selected tab current
         self.cycleTabFilesList.makeItemCurrent(self.highlightedItem)
         self.openFileNames=None
         self.cycleTabFilesList=None
示例#17
0
 def startRecording(self):
     dbgMsg("start recording")
     self.grabKeyboard()
     self.keyLabel.setText('')
     self.nonShiftModifierPreseed = False
     self.grabButton.setEnabled(False)
     self.keySequence = QKeySequence()
     self.sequence = None
     self.recording = True
示例#18
0
 def reassignNewShortcuts(self):
     for changeIdx in range(0,len(self.changesInActionShortcutList),2):
         dbgMsg("actionText=",self.changesInActionShortcutList[changeIdx])
         dbgMsg("sequence=",str(self.changesInActionShortcutList[changeIdx+1].toString()))
         
         am.setActionKeyboardShortcut(self.changesInActionShortcutList[changeIdx],self.changesInActionShortcutList[changeIdx+1])
 
     # for actionText,keySequence in self.changesInActionShortcutDict.iteritems():
         # am.setActionKeyboardShortcut(actionText,keySequence)
         
 def reassignNewShortcuts(self):
     for changeIdx in range(0,len(self.changesInActionShortcutList),2):
         dbgMsg("actionText=",self.changesInActionShortcutList[changeIdx])
         dbgMsg("sequence=",str(self.changesInActionShortcutList[changeIdx+1].toString()))
         
         am.setActionKeyboardShortcut(self.changesInActionShortcutList[changeIdx],self.changesInActionShortcutList[changeIdx+1])
 
     # for actionText,keySequence in self.changesInActionShortcutDict.iteritems():
         # am.setActionKeyboardShortcut(actionText,keySequence)
         
示例#20
0
 def onMarginClick(self, _pos, _modifier, _margin):
     dbgMsg("_pos:", _pos, " modifier:", _modifier, " _margin:", _margin)
     lineClick = self.SendScintilla(QsciScintilla.SCI_LINEFROMPOSITION, _pos)
     dbgMsg("lineClick=", lineClick)
     levelClick = self.SendScintilla(QsciScintilla.SCI_GETFOLDLEVEL, lineClick)
     dbgMsg("levelClick=", levelClick)
     if levelClick & QsciScintilla.SC_FOLDLEVELHEADERFLAG:
         dbgMsg("Clicked Fold Header")
         self.SendScintilla(QsciScintilla.SCI_TOGGLEFOLD, lineClick)
示例#21
0
    def send(self):

        self.tcpSocket.abort()
        # on some linux distros QHostAddress.LocalHost does not work
        #self.tcpSocket.connectToHost(QHostAddress.LocalHost,47405)
        self.tcpSocket.connectToHost(QHostAddress("127.0.0.1"), 47405)

        if self.tcpSocket.waitForConnected(3000):
            self.tcpSocket.writeData(self.fileName)
        else:
            dbgMsg("Connection timed out")

        # wait here for tcp server to read fileName
        if self.tcpSocket.waitForDisconnected(3000):
            pass
        else:
            dbgMsg("server busy - did not respond within 3 secs")
    def send(self):

        self.tcpSocket.abort()
        # on some linux distros QHostAddress.LocalHost does not work
        # self.tcpSocket.connectToHost(QHostAddress.LocalHost,47405)
        self.tcpSocket.connectToHost(QHostAddress("127.0.0.1"), 47405)

        if self.tcpSocket.waitForConnected(3000):
            self.tcpSocket.writeData(self.fileName)
        else:
            dbgMsg("Connection timed out")

        # wait here for tcp server to read fileName
        if self.tcpSocket.waitForDisconnected(3000):
            pass
        else:
            dbgMsg("server busy - did not respond within 3 secs")
示例#23
0
def writeBOM(_fh,_encoding=None):
    # dealing with big endian/little endian BOM
    if not _encoding:
        return
    if _encoding=="utf-16be":
        _fh.write(u'\ufeff')
        dbgMsg("WRITING utf-16be BOM *********************************************")
    elif _encoding=="utf-16le":
        _fh.write(u'\ufffe')        
    elif _encoding=="utf-32be":
        _fh.write(u'\u0000\ufeff')
    elif _encoding=="utf-32le":
        _fh.write(u'\ufffe\u0000')
    # elif _encoding=="utf-8-bom":
        # _fh.write(u'\uefbb\ubf00')
        
    else:
        return
 def onMarginClick(self, _pos, _modifier, _margin):
     dbgMsg("_pos:", _pos, " modifier:", _modifier, " _margin:", _margin)
     lineClick = self.SendScintilla(QsciScintilla.SCI_LINEFROMPOSITION,
                                    _pos)
     dbgMsg("lineClick=", lineClick)
     levelClick = self.SendScintilla(QsciScintilla.SCI_GETFOLDLEVEL,
                                     lineClick)
     dbgMsg("levelClick=", levelClick)
     if levelClick & QsciScintilla.SC_FOLDLEVELHEADERFLAG:
         dbgMsg("Clicked Fold Header")
         self.SendScintilla(QsciScintilla.SCI_TOGGLEFOLD, lineClick)
示例#25
0
    def setSetting(self,_key,_value):
        if _key in ["UseTabSpaces","DisplayLineNumbers","FoldText","TabGuidelines","DisplayWhitespace","DisplayEOL","WrapLines","ShowWrapSymbol","DontShowWrapLinesWarning",\
        "RestoreTabsOnStartup","EnableAutocompletion","EnableQuickTextDecoding","FRInSelection","FRInAllSubfolders","FRTransparencyEnable","FROnLosingFocus","FRAlways"]: # Boolean values
            self.settings.setValue(_key,QVariant(_value))
            
        elif _key in ["TabSpaces","ZoomRange","ZoomRangeFindDisplayWidget","AutocompletionThreshold","FRSyntaxIndex","FROpacity","CurrentTabIndex","CurrentPanelIndex"]: # integer values
            self.settings.setValue(_key,_value)

            
        elif _key in ["BaseFontName","BaseFontSize","Theme"]: # string values
            self.settings.setValue(_key,QVariant(_value))
            
        elif _key in ["RecentDocuments","RecentDirectories","InitialSize","InitialPosition","ListOfOpenFiles","ListOfOpenFilesAndPanels","FRSyntax","FRFindHistory","FRReplaceHistory","FRFiltersHistory","FRDirectoryHistory","KeyboardShortcuts","PluginAutoloadData"]: # QSize, QPoint,QStringList , QString values
            self.settings.setValue(_key,QVariant(_value))
        elif _key in ["PanelSplitterState"]: # QByteArray
            self.settings.setValue(_key,QVariant(_value))
            
        else:
            dbgMsg("Wrong format of configuration option:",_key,":",_value)
示例#26
0
    def shortcutCellClicked(self, _row, _column):

        if _column == 1:
            #display grab shortcut widget
            shortcutItem = self.shortcutTable.item(_row, 1)
            actionItem = self.shortcutTable.item(_row, 0)

            shortcutText = shortcutItem.text()
            actionText = actionItem.text()
            keyShortcutDlg = KeyShortcutDlg(self, str(actionText),
                                            str(shortcutText))

            ret = keyShortcutDlg.exec_()
            if ret:
                newKeySequence = keyShortcutDlg.getKeySequence()
                dbgMsg("THIS IS NEW SHORTCUT:", str(newKeySequence.toString()))
                # dbgMsg("THIS IS NEW SHORTCUT:",str(newKeySequence.toString(QKeySequence.NativeText))) # QKeySequence.NativeText does not work well on OSX
                self.assignNewShortcut(newKeySequence, actionItem,
                                       shortcutItem)
 def shortcutCellClicked(self,_row,_column):
     
     if _column==1:
         #display grab shortcut widget
         shortcutItem=self.shortcutTable.item(_row,1)
         actionItem=self.shortcutTable.item(_row,0)
         
         shortcutText=shortcutItem.text()
         actionText=actionItem.text()
         keyShortcutDlg=KeyShortcutDlg(self,str(actionText),str(shortcutText))
         
         
         
         ret=keyShortcutDlg.exec_()
         if ret:
             newKeySequence=keyShortcutDlg.getKeySequence()
             dbgMsg("THIS IS NEW SHORTCUT:",str(newKeySequence.toString())) 
             # dbgMsg("THIS IS NEW SHORTCUT:",str(newKeySequence.toString(QKeySequence.NativeText))) # QKeySequence.NativeText does not work well on OSX
             self.assignNewShortcut(newKeySequence,actionItem,shortcutItem)
示例#28
0
 def refresh(self): 
     dbgMsg("REFRESH FILE TAB LIST\n\n\n\n")
     for tabWidget in self.editorWindow.panels:
         for i in range(tabWidget.count()):
             editor=tabWidget.widget(i)
             try:
                 self.tabDict[editor]
                 #checking if file name has not changed
                 documentName=self.editorWindow.getEditorFileName(editor)
                 if documentName=="":
                     documentName=tabWidget.tabText(tabWidget.indexOf(editor)) 
                 if documentName!=self.tabDict[editor]:
                     dbgMsg("fileName has changed in the open tab")
                     #linear search for item entry with matchin editor entry
                     for i in range(len(self.tabList)):
                         if self.tabList[i][1]==editor:
                             self.tabList[i][0]=documentName
                             self.tabDict[editor]=self.tabList[i][0]    
                             break
                             
                     # sys.exit()
             except KeyError,e:
                 # found new editor window
                 dbgMsg("# found new editor window")
                 if self.editorWindow.getEditorFileName(editor)!="": # if the name of the item is non empty 
                     self.insertNewItem([self.editorWindow.getEditorFileName(editor),editor])
                     # self.tabDict[editor]=self.tabList.insert[1][0] # new item was inserted at position 1
                     # self.tabDict[editor]=self.editorWindow.fileDict[editor][0]
                 else:#otherwise get tab text
                     documentName=tabWidget.tabText(tabWidget.indexOf(editor))
                     self.insertNewItem([documentName,editor])
示例#29
0
    def onDoubleClick(self, _position, _line, _modifiers):
        dbgMsg("position=", _position, " line=", _line, " modifiers=", _modifiers)
        lineText = str(self.text(_line))
        dbgMsg("line text=", lineText)
        lineNumberGroups = self.lineNumberExtractRegex.search(lineText)
        lineNumber = -1
        colNumber = -1
        lineNumberWithFileName = -1
        fileName = ""
        try:
            if lineNumberGroups:
                lineNumber = int(lineNumberGroups.group(1))
                dbgMsg("Error at line=", lineNumber)
                lineNumberWithFileName = self.SendScintilla(QsciScintilla.SCI_GETFOLDPARENT, _line)
        except IndexError, e:

            dbgMsg("Line number not found")
    def onDoubleClick(self, _position, _line, _modifiers):
        dbgMsg("position=", _position, " line=", _line, " modifiers=",
               _modifiers)
        lineText = str(self.text(_line))
        dbgMsg("line text=", lineText)
        lineNumberGroups = self.lineNumberExtractRegex.search(lineText)
        lineNumber = -1
        colNumber = -1
        lineNumberWithFileName = -1
        fileName = ""
        try:
            if lineNumberGroups:
                lineNumber = int(lineNumberGroups.group(1))
                dbgMsg("Error at line=", lineNumber)
                lineNumberWithFileName = self.SendScintilla(
                    QsciScintilla.SCI_GETFOLDPARENT, _line)
        except IndexError, e:

            dbgMsg("Line number not found")
def removeExistingShortcut(_keySequence):
    shortcutText=str(QKeySequence(_keySequence).toString())
    dbgMsg("shortcutText=",shortcutText)
    if str(shortcutText)=='':
        return
    if shortcutText in shortcutToActionDict.keys():
        dbgMsg("FOUND EXISTING SHORTCUT=",shortcutText)
        try:
            actionDict[shortcutToActionDict[shortcutText]].setShortcut('')
            actionToShortcutDict[shortcutToActionDict[shortcutText]]=''
                
            del shortcutToActionDict[shortcutText]
            dbgMsg("Removing shortcutText=",shortcutText)
        except KeyError:
            
            pass
示例#32
0
    def styleText(self, start, end):
        editor = self.editor()
        if editor is None:
            return

        # scintilla works with encoded bytes, not decoded characters.
        # this matters if the source contains non-ascii characters and
        # a multi-byte encoding is used (e.g. utf-8)
        source = ""
        if end > editor.length():
            end = editor.length()
        if end > start:
            if sys.hexversion >= 0x02060000:
                # faster when styling big files, but needs python 2.6
                source = bytearray(end - start)
                editor.SendScintilla(editor.SCI_GETTEXTRANGE, start, end, source)
            else:
                # source = unicode(editor.text()
                # ).encode('utf-8')[start:end]
                source = unicode(editor.text()).encode(
                    "utf-8"
                )  # scanning entire text is way more efficient that doing it on demand especially when folding top level text (Search)
        if not source:
            return

        # the line index will also be needed to implement folding
        index = editor.SendScintilla(editor.SCI_LINEFROMPOSITION, start)
        if index > 0:
            # the previous state may be needed for multi-line styling
            pos = editor.SendScintilla(editor.SCI_GETLINEENDPOSITION, index - 1)
            state = editor.SendScintilla(editor.SCI_GETSTYLEAT, pos)
        else:
            state = self.Default

        set_style = self.setStyling
        self.startStyling(start, 0x1F)

        # SCI = self.SendScintilla
        SCI = self.editorWidget.SendScintilla
        GETFOLDLEVEL = QsciScintilla.SCI_GETFOLDLEVEL
        SETFOLDLEVEL = QsciScintilla.SCI_SETFOLDLEVEL
        HEADERFLAG = QsciScintilla.SC_FOLDLEVELHEADERFLAG
        LEVELBASE = QsciScintilla.SC_FOLDLEVELBASE
        NUMBERMASK = QsciScintilla.SC_FOLDLEVELNUMBERMASK
        WHITEFLAG = QsciScintilla.SC_FOLDLEVELWHITEFLAG
        # scintilla always asks to style whole lines

        for line in source.splitlines(True):
            length = len(line)
            # dbgMsg("line=",line)
            # dbgMsg(line)
            if line.startswith("\n"):
                style = self.Default
                dbgMsg("GOT EMPTY LINE")
                # sys.exit()
            else:
                if line.startswith("Error"):
                    state = self.ErrorInfo

                    # searchGroups =re.search('"([\s\S]*)"', line) # we have to use search instead of match - match matches onle beginning of the string , search searches through entire string

                    # # dbgMsg("searchGroups=",searchGroups)

                    # try:

                    # if searchGroups:
                    # # dbgMsg(searchGroups.group(1))
                    # self.searchText=searchGroups.group(1)

                    # # dbgMsg("self.searchText=",self.searchText)
                    # except IndexError,e:
                    # self.searchText=""
                    # dbgMsg("COULD NOT EXTRACT TEXT")

                # elif line.startswith('  File'):
                elif line.startswith("  F"):
                    state = self.FileInfo

                # elif line.startswith('    Line'):
                elif line.startswith("   "):

                    if self.searchText != "":
                        # dbgMsg("self.searchText=",self.searchText)
                        searchTextLength = len(self.searchText)
                        # pos = line.find(self.searchText)
                        # set_style(pos, self.LineInfo) # styling begining of the line
                        # set_style(searchTextLength, self.TextToFind) # styling searchText of the line
                        # length = length - pos - searchTextLength  # Default styling is applied to RHS
                        # state = self.ErrorInfo
                        # dbgMsg("LENGTH=",length)

                        # length = length - pos
                        # dbgMsg("line=",line)
                        startPos = 0
                        # string line is not use to output to the screen it is local to this fcn therefore it is safe to use lower
                        pos = line.lower().find(self.searchText.lower())
                        while pos != -1:

                            set_style(pos - startPos, self.LineInfo)  # styling begining of the line
                            set_style(searchTextLength, self.TextToFind)  # styling searchText of the line
                            startPos = pos + searchTextLength
                            pos = line.find(self.searchText, startPos)
                            state = self.LineInfo

                        state = self.LineInfo
                        length = (
                            length - startPos
                        )  # last value startPos if startPos point to the location right after last found searchText - to continue styling we tell lexer to style reminder of the line (length-startPos) with LineInfo style
                    else:
                        dbgMsg("DID NOT FIND SEARCH TEXT")
                        # state = self.Default
                        state = self.LineInfo

                    # # the following will style lines like "x = 0"

                    # pos = line.find('\tFile')

                    # if pos > 0:
                    # set_style(pos, self.ErrorInfo) #styling LHS pos is the length of styled text
                    # set_style(1, self.FileInfo)#styling = 1 is the length of styled text
                    # length = length - pos - 1
                    # state = self.ErrorInfo
                    # else:
                    # state = self.Default
                else:
                    # state = self.Default
                    state = self.LineInfo

            set_style(length, state)
            # folding implementation goes here
            headerLevel = LEVELBASE | HEADERFLAG
            # dbgMsg("HEADER LEVEL",headerLevel)

            # if index==0:
            if state == self.ErrorInfo:
                SCI(SETFOLDLEVEL, index, headerLevel)
            elif state == self.FileInfo:
                SCI(
                    SETFOLDLEVEL, index, headerLevel + 1
                )  # this subheader - inside header for ErrorInfo style - have to add +1 to folding level
            elif state == self.LineInfo:
                SCI(
                    SETFOLDLEVEL, index, LEVELBASE + 2
                )  # this is non-header fold line - since it is inside header level and headerLevel +1 i had to add +3 to the  LEVELBASE+2
            else:
                SCI(
                    SETFOLDLEVEL, index, LEVELBASE + 2
                )  # this is non-header fold line - since it is inside header level and headerLevel +1 i had to add +3 to the  LEVELBASE+2

            index += 1
示例#33
0
 def keyReleaseEvent(self, e):
     dbgMsg("keyReleaseEvent")
示例#34
0
def decode(_fh,_testTextLength=0): #taking fileHandle as first argument
    """
    Function to decode a text.
    
    # @param text text to decode (string)
    # @return decoded text and encoding
    # passing file.read() to decode causes improper detection of encoding
    # we have to first store file content localy and then pass the string to decode fcn
    
    """    
    text=""
    textFullyRead=False
    try:
        text=_fh.read(16) # reading first 16 bytes - thin should be more than enough for detecting BOM charcters
        
        if text.startswith(BOM_UTF8):
            # UTF-8 with BOM
            # return unicode(text[len(BOM_UTF8):], 'utf-8'), 'utf-8-bom'
            return unicode(text[len(BOM_UTF8):], 'utf-8'), 'utf-8-sig'
        elif text.startswith(BOM_UTF16):
            # UTF-16 with BOM
            return unicode(text[len(BOM_UTF16):], 'utf-16'), 'utf-16'
        elif text.startswith(BOM_UTF32):
            # UTF-32 with BOM
            return unicode(text[len(BOM_UTF32):], 'utf-32'), 'utf-32'
        elif text.startswith(BOM_BE):
            # UTF-16BE with BOM
            return unicode(text[len(BOM_BE):], 'utf-16be'), 'utf-16be'
        elif text.startswith(BOM_UTF16_BE):
            # UTF-16BE with BOM
            return unicode(text[len(BOM_UTF16_BE):], 'utf-16be'), 'utf-16be'            
        elif text.startswith(BOM_LE):
            # UTF-16LE with BOM
            return unicode(text[len(BOM_LE):], 'utf-16le'), 'utf-16le'            
        elif text.startswith(BOM_UTF32_BE):
            # UTF-32BE with BOM
            return unicode(text[len(BOM_UTF32_BE):], 'utf-32be'), 'utf-32be'
        elif text.startswith(BOM_UTF32_LE):
            # UTF-32LE with BOM
            return unicode(text[len(BOM_UTF32_LE):], 'utf-32le'), 'utf-32le'
        
        #put file pointer at the beginning    
        _fh.seek(0)
        text=_fh.read()
        textFullyRead=True    
        dbgMsg("GUESSING ENCODING **************************************************************")
        # this part makes opening of the documents very slow - decided to use guessed encoding instead
        # coding = get_coding(text)
        # if coding:
            # return unicode(text, coding), coding
    except (UnicodeError, LookupError):
        dbgMsg("UnicodeError encountered *************************************************\n\n\n\n")
        pass
        
    #  check it just in case  
    if not textFullyRead:
        #put file pointer at the beginning    
        _fh.seek(0)        
        text=_fh.read()                
    guess = None
    
    if True:
        # Try the universal character encoding detector
        
        try:
            import Encoding.EncodingDetector.chardet
            if  not _testTextLength:                
                guess = Encoding.EncodingDetector.chardet.detect(text)
            else:
                textLength=len(text)
                guess = Encoding.EncodingDetector.chardet.detect(text[0:min(textLength,abs(_testTextLength))])
            if guess and guess['confidence'] > 0.95 and guess['encoding'] is not None:
                codec = guess['encoding'].lower()
                return unicode(text, codec), '%s-guessed' % codec
        except (UnicodeError, LookupError):
            pass
        except ImportError:
            pass
    
    # Try default encoding
    try:
        codec = unicode(default_coding)
        return unicode(text, codec), '%s-default' % codec
    except (UnicodeError, LookupError):
        pass
    
    # Assume UTF-8
    try:
        return unicode(text, 'utf-8'), 'utf-8-guessed'
    except (UnicodeError, LookupError):
        pass
    
    if True:
        # Use the guessed one even if confifence level is low
        if guess and guess['encoding'] is not None:
            try:
                codec = guess['encoding'].lower()
                return unicode(text, codec), '%s-guessed' % codec
            except (UnicodeError, LookupError):
                pass
    
    # Assume Latin-1 (behaviour before 3.7.1)
    return unicode(text, "latin-1"), 'latin-1-guessed'
示例#35
0
    def __init__(self, parent=None):
        """
        Constructor
        
        @param parent reference to the parent widget (QWidget) - here it is EditorWindow class
        """
        self.editorWindow = parent

        self.playerMainWidget = None

        QsciScintilla.__init__(self, parent)
        # # self.setFolding(5)
        self.setFolding(QsciScintilla.BoxedTreeFoldStyle)
        # self.setMarginSensitivity(3,True)
        lexer = QsciLexerPython()
        dbgMsg(lexer.keywords(1), "\n\n\n\n")
        syntaxErrorLexer = SyntaxErrorLexer(self)
        self.setLexer(syntaxErrorLexer)

        self.setReadOnly(True)
        #         self.setReadOnly(False)

        self.setCaretLineVisible(True)
        # font=self.font()
        font = QFont("Courier New", 10)

        if sys.platform.startswith("da"):
            font = QFont("Courier New", 12)
        # font.setFixedPitch(True)
        self.setFont(font)

        self.setCaretLineBackgroundColor(QtGui.QColor("#E0E0F8"))  # current line has this color
        self.setSelectionBackgroundColor(
            QtGui.QColor("#E0E0F8")
        )  # any selection in the current line due to double click has the same color too
        # connecting SCN_DOUBLECLICK(int,int,int) to editor double-click
        # notice  QsciScintilla.SCN_DOUBLECLICK(int,int,int) is not the right name
        # self.connect(self, SIGNAL("SCN_DOUBLECLICK(int,int,int)"), self.onDoubleClick)

        GETFOLDLEVEL = QsciScintilla.SCI_GETFOLDLEVEL
        SETFOLDLEVEL = QsciScintilla.SCI_SETFOLDLEVEL
        HEADERFLAG = QsciScintilla.SC_FOLDLEVELHEADERFLAG
        LEVELBASE = QsciScintilla.SC_FOLDLEVELBASE
        NUMBERMASK = QsciScintilla.SC_FOLDLEVELNUMBERMASK
        WHITEFLAG = QsciScintilla.SC_FOLDLEVELWHITEFLAG

        headerLevel = LEVELBASE | HEADERFLAG
        lineStart = 1
        lineEnd = 3

        # self.SendScintilla(QsciScintilla.SCI_SETCARETSTYLE, QsciScintilla.CARETSTYLE_INVISIBLE) # make caret invisible

        self.lineNumberExtractRegex = re.compile("^[\s\S]*[L|l]ine:[\s]*([0-9]*)")
        self.colNumberExtractRegex = re.compile("^[\s\S]*[C|c]ol:[\s]*([0-9]*)")

        self.fileNameExtractRegex = re.compile("^[\s]*File:[\s]*([\S][\s\S]*)")

        # self.zoomRange=self.editorWindow.configuration.setting("ZoomRangeFindDisplayWidget")
        # self.zoomTo(self.zoomRange)

        dbgMsg("marginSensitivity=", self.marginSensitivity(0))

        self.cc3dSender = CC3DSender.CC3DSender(self)
示例#36
0
    def drawField(self, _bsd, fieldType):   

        # print 'drawField ', fieldType
        dbgMsg('drawField ', fieldType)
        resetCamera = False # we reset camera only for visualizations for which camera settings are not in the dictionary and users have not requested custom cameras
        
        if self.drawingFcnHasChanged:            
            self.clearDisplay()
            
        drawField = getattr(self, "draw" + fieldType[1])   # e.g. "drawCellField"
        
        
        cs = None #camera settings
        
        if self.currentDrawingFunction != drawField: # changing type of drawing function e.g. from drawCellField to drawConField- need to remove actors that are currently displayed            

            for actorName in self.currentActors.keys():                                                
                self.graphicsFrameWidget.ren.RemoveActor(self.currentActors[actorName])
                del self.currentActors[actorName]
                
            # to prevent cyclic reference we user weakre
            from weakref import ref    
            self.currentDrawingFunction = ref(drawField)
            
            # # # self.currentDrawingFunction = drawField   
        
        
        
        currentDrawingFunction=self.currentDrawingFunction() # obtaining object from weakref
        if not currentDrawingFunction:return
        # print 'currentDrawingFunction=',currentDrawingFunction
        # import time
        # time.sleep(2)
        # return
        
        # here we handle actors for custom visualization when the name of the function does not change (it is drawCustomVis) but the name of the plot changes (hence actors have to be replaced with new actors)
        drawFieldCustomVis = getattr(self, "drawCustomVis")
        if currentDrawingFunction==drawFieldCustomVis:
            #check if actors the name of the custom vis has changed            
            if self.currentCustomVisName != self.currentDrawingParameters.fieldName:
                self.currentCustomVisName = self.currentDrawingParameters.fieldName

                for actorName in self.currentActors.keys():
                    self.graphicsFrameWidget.ren.RemoveActor(self.currentActors[actorName])
                    del self.currentActors[actorName]
                
        try:
        
            fieldName = self.currentDrawingParameters.fieldName                                   
            cs = self.cameraSettingsDict[fieldName]
            
            if self.checkIfCameraSettingsHaveChanged(cs):
                if self.currentVisName==self.currentDrawingParameters.fieldName: # this section is called when camera setings have changed between calls to this fcn (e.g. when screen refreshes with new MCS data) and the visualzation field was not change by the user                    
                    cs = self.getCurrentCameraSettings()
                    self.cameraSettingsDict[fieldName] = cs
                    
                    
                    self.setCurrentCameraSettings(cs)
                else:                    # this section is called when camera settings have changed between calls to this function and visualization field changes. Before initializing camera with cs for new vis field setting we store cs for  previous vis field
                    self.cameraSettingsDict[self.currentVisName] = self.getCurrentCameraSettings()         
                    
                    self.setCurrentCameraSettings(cs)
        except LookupError,e:
            resetCamera=True
            
            if self.currentVisName!=self.currentDrawingParameters.fieldName and self.currentVisName!='': # this is called when user modifies camera in one vis and then changes vis to another  for which camera has not been set up                 
                self.cameraSettingsDict[self.currentVisName] = self.getCurrentCameraSettings()
        except IndexError, e:

            dbgMsg("Line number not found")

        colNumberGroups = self.colNumberExtractRegex.search(lineText)
        try:
            if colNumberGroups:
                colNumber = int(colNumberGroups.group(1))
                dbgMsg("Error at column=", colNumber)

        except IndexError, e:

            dbgMsg("Col number not found")

        if lineNumberWithFileName >= 0:
            dbgMsg("THIS IS LINE WITH FILE NAME:")
            lineWithFileName = str(self.text(lineNumberWithFileName))

            dbgMsg(lineWithFileName)
            fileNameGroups = self.fileNameExtractRegex.search(lineWithFileName)
            print "fileNameGroups=", fileNameGroups
            if fileNameGroups:
                try:
                    fileName = fileNameGroups.group(1)
                    fileName = fileName.strip(
                    )  # removing trailing white spaces
                    fileNameOrig = fileName  # store original file name as found by regex - it is used to locate unsaved files
                    # "normalizing" file name to make sure \ and / are used in a consistent manner
                    fileName1 = os.path.abspath(fileNameOrig)
                    # dbgMsg("FILE NAME :",fileName)
                    print "*******fileNameOrig=", fileNameOrig
示例#38
0
 def cancelRecording(self):
     dbgMsg("Recording Cancelled")
     self.doneRecording()
     self.keySequence = QKeySequence()
     self.sequence = None
     self.recording = False
示例#39
0
 def doneRecording(self):
     dbgMsg(" Done recording")
     self.releaseKeyboard()
     self.recording = False
     self.grabButton.setEnabled(True)
    def __init__(self, parent=None):
        """
        Constructor
        
        @param parent reference to the parent widget (QWidget) - here it is EditorWindow class
        """
        self.editorWindow = parent

        self.playerMainWidget = None

        QsciScintilla.__init__(self, parent)
        # # self.setFolding(5)
        self.setFolding(QsciScintilla.BoxedTreeFoldStyle)
        # self.setMarginSensitivity(3,True)
        lexer = QsciLexerPython()
        dbgMsg(lexer.keywords(1), "\n\n\n\n")
        syntaxErrorLexer = SyntaxErrorLexer(self)
        self.setLexer(syntaxErrorLexer)

        self.setReadOnly(True)
        #         self.setReadOnly(False)

        self.setCaretLineVisible(True)
        # font=self.font()
        font = QFont("Courier New", 10)

        if sys.platform.startswith('da'):
            font = QFont("Courier New", 12)
        # font.setFixedPitch(True)
        self.setFont(font)

        self.setCaretLineBackgroundColor(
            QtGui.QColor('#E0E0F8'))  #current line has this color
        self.setSelectionBackgroundColor(
            QtGui.QColor('#E0E0F8')
        )  # any selection in the current line due to double click has the same color too
        #connecting SCN_DOUBLECLICK(int,int,int) to editor double-click
        #notice  QsciScintilla.SCN_DOUBLECLICK(int,int,int) is not the right name
        # self.connect(self, SIGNAL("SCN_DOUBLECLICK(int,int,int)"), self.onDoubleClick)

        GETFOLDLEVEL = QsciScintilla.SCI_GETFOLDLEVEL
        SETFOLDLEVEL = QsciScintilla.SCI_SETFOLDLEVEL
        HEADERFLAG = QsciScintilla.SC_FOLDLEVELHEADERFLAG
        LEVELBASE = QsciScintilla.SC_FOLDLEVELBASE
        NUMBERMASK = QsciScintilla.SC_FOLDLEVELNUMBERMASK
        WHITEFLAG = QsciScintilla.SC_FOLDLEVELWHITEFLAG

        headerLevel = LEVELBASE | HEADERFLAG
        lineStart = 1
        lineEnd = 3

        # self.SendScintilla(QsciScintilla.SCI_SETCARETSTYLE, QsciScintilla.CARETSTYLE_INVISIBLE) # make caret invisible

        self.lineNumberExtractRegex = re.compile(
            '^[\s\S]*[L|l]ine:[\s]*([0-9]*)')
        self.colNumberExtractRegex = re.compile(
            '^[\s\S]*[C|c]ol:[\s]*([0-9]*)')

        self.fileNameExtractRegex = re.compile('^[\s]*File:[\s]*([\S][\s\S]*)')

        # self.zoomRange=self.editorWindow.configuration.setting("ZoomRangeFindDisplayWidget")
        # self.zoomTo(self.zoomRange)

        dbgMsg("marginSensitivity=", self.marginSensitivity(0))

        self.cc3dSender = CC3DSender.CC3DSender(self)
示例#41
0
    def keyPressEvent(self, e):
        dbgMsg("keyPressEvent")
        if e.key() == -1:
            self.cancelRecording()

        e.accept()
        newModifiers = e.modifiers() & (Qt.SHIFT | Qt.CTRL | Qt.ALT | Qt.META)
        dbgMsg("newModifiers=", newModifiers)
        # if newModifiers and not self.recording and not self.grabKey.isEnabled():
        # self.startRecording()

        dbgMsg("self.recording=", self.recording)
        if not self.recording:
            return

            # check if non-SHIFT modifier has been presed - this affects whether we can use shift in the shortcut or not
        # e.g. SHIFT with a letter is not a valid shortcut but if there is additional modifier pressed than is it valid e.g. Ctrl+Shift+F
        if newModifiers & (Qt.CTRL | Qt.ALT | Qt.META):
            self.nonShiftModifierPreseed = True

        self.key = e.key()

        self.modifiers = int(newModifiers)
        if self.key == Qt.Key_AltGr:  # or else we get unicode salad
            return
        elif self.key == Qt.Key_Shift:
            self.updateShortcutDisplay()
        elif self.key == Qt.Key_Control:
            self.updateShortcutDisplay()
        elif self.key == Qt.Key_Alt:
            self.updateShortcutDisplay()
        elif self.key == Qt.Key_Meta:
            self.updateShortcutDisplay()
        else:
            if self.modifiers & (Qt.SHIFT | Qt.CTRL | Qt.ALT | Qt.META
                                 ):  # check if any of the modifiers is chc
                if self.isShiftAsModifierAllowed(self.key):
                    self.key |= (self.modifiers)
                else:  # filter out shift
                    self.key |= (self.modifiers & ~Qt.SHIFT)
                self.sequence = QKeySequence(self.key)
                dbgMsg("\t\t\t self.sequence=", self.sequence.toString())
                dbgMsg("self.modifiers=%x" % self.modifiers)

                self.updateShortcutDisplay()
                dbgMsg("GOT THIS KEY", self.key)
            else:  # pressing non-modifier key but none of modifier keys are pressed - not a valid shortcut
                self.cancelRecording()

        dbgMsg("END OF KEY PRESS EVENT")
示例#42
0
def encode(text, orig_coding):
    """
    Function to encode a text.
    
    @param text text to encode (string)
    @param orig_coding type of the original coding (string)
    @return encoded text and encoding
    """
    if orig_coding == 'utf-8-bom':
        # return BOM_UTF8 + text.encode("utf-8"), 'utf-8-bom'
        return unicode(text),orig_coding
    dbgMsg("ENCODING is ",orig_coding," *********************************************")
    
    # use orig_coding without any modifications
    try:
        # return text.encode(orig_coding), orig_coding
        # since I am using codec.open() I dont have to encode text it is enough if I converti it to unicode
        return unicode(text),orig_coding
    except (UnicodeError, LookupError):
        pass
        
    # if it does not work then    
    # try declared coding spec
    coding = get_coding(text)
    if coding:
        try:
            return text.encode(coding), coding
        except (UnicodeError, LookupError):
            # Error: Declared encoding is incorrect
            raise CodingError(coding)
    
    if orig_coding and orig_coding.endswith('-selected'):
        coding = orig_coding.replace("-selected", "")
        try:
            return text.encode(coding), coding
        except (UnicodeError, LookupError):
            pass
    if orig_coding and orig_coding.endswith('-default'):
        coding = orig_coding.replace("-default", "")
        try:
            return text.encode(coding), coding
        except (UnicodeError, LookupError):
            pass
    if orig_coding and orig_coding.endswith('-guessed'):
        coding = orig_coding.replace("-guessed", "")
        try:
            return text.encode(coding), coding
        except (UnicodeError, LookupError):
            pass
    
    # Try configured default
    try:
        codec = unicode(default_coding)
        return text.encode(codec), codec
    except (UnicodeError, LookupError):
        pass
    
    # Try saving as ASCII
    try:
        return text.encode('ascii'), 'ascii'
    except UnicodeError:
        pass
    
    # Save as UTF-8 without BOM
    return text.encode('utf-8'), 'utf-8'
示例#43
0
 def cancelRecording(self):
     dbgMsg("Recording Cancelled")
     self.doneRecording()
     self.keySequence = QKeySequence()
     self.sequence = None
     self.recording = False
示例#44
0
        except IndexError, e:

            dbgMsg("Line number not found")

        colNumberGroups = self.colNumberExtractRegex.search(lineText)
        try:
            if colNumberGroups:
                colNumber = int(colNumberGroups.group(1))
                dbgMsg("Error at column=", colNumber)

        except IndexError, e:

            dbgMsg("Col number not found")

        if lineNumberWithFileName >= 0:
            dbgMsg("THIS IS LINE WITH FILE NAME:")
            lineWithFileName = str(self.text(lineNumberWithFileName))

            dbgMsg(lineWithFileName)
            fileNameGroups = self.fileNameExtractRegex.search(lineWithFileName)
            print "fileNameGroups=", fileNameGroups
            if fileNameGroups:
                try:
                    fileName = fileNameGroups.group(1)
                    fileName = fileName.strip()  # removing trailing white spaces
                    fileNameOrig = (
                        fileName
                    )  # store original file name as found by regex - it is used to locate unsaved files
                    # "normalizing" file name to make sure \ and / are used in a consistent manner
                    fileName1 = os.path.abspath(fileNameOrig)
                    # dbgMsg("FILE NAME :",fileName)
示例#45
0
    def keyPressEvent(self, e):
        dbgMsg("keyPressEvent")
        if e.key() == -1:
            self.cancelRecording()

        e.accept()
        newModifiers = e.modifiers() & (Qt.SHIFT | Qt.CTRL | Qt.ALT | Qt.META)
        dbgMsg("newModifiers=", newModifiers)
        # if newModifiers and not self.recording and not self.grabKey.isEnabled():
        # self.startRecording()

        dbgMsg("self.recording=", self.recording)
        if not self.recording:
            return

            # check if non-SHIFT modifier has been presed - this affects whether we can use shift in the shortcut or not
        # e.g. SHIFT with a letter is not a valid shortcut but if there is additional modifier pressed than is it valid e.g. Ctrl+Shift+F
        if newModifiers & (Qt.CTRL | Qt.ALT | Qt.META):
            self.nonShiftModifierPreseed = True

        self.key = e.key()

        self.modifiers = int(newModifiers)
        if self.key == Qt.Key_AltGr:  # or else we get unicode salad
            return
        elif self.key == Qt.Key_Shift:
            self.updateShortcutDisplay()
        elif self.key == Qt.Key_Control:
            self.updateShortcutDisplay()
        elif self.key == Qt.Key_Alt:
            self.updateShortcutDisplay()
        elif self.key == Qt.Key_Meta:
            self.updateShortcutDisplay()
        else:
            if self.modifiers & (Qt.SHIFT | Qt.CTRL | Qt.ALT | Qt.META):  # check if any of the modifiers is chc
                if self.isShiftAsModifierAllowed(self.key):
                    self.key |= (self.modifiers)
                else:  # filter out shift
                    self.key |= (self.modifiers & ~Qt.SHIFT)
                self.sequence = QKeySequence(self.key)
                dbgMsg("\t\t\t self.sequence=", self.sequence.toString())
                dbgMsg("self.modifiers=%x" % self.modifiers)

                self.updateShortcutDisplay()
                dbgMsg("GOT THIS KEY", self.key)
            else:  # pressing non-modifier key but none of modifier keys are pressed - not a valid shortcut
                self.cancelRecording()

        dbgMsg("END OF KEY PRESS EVENT")
示例#46
0
# -*- coding: utf-8 -*-
示例#47
0
def checkBlacklistedVersions():
    """
    Module functions to check for blacklisted versions of the prerequisites.
    
    @return flag indicating good versions were found (boolean)
    """
    from install import BlackLists

    # check version of sip
    try:
        import sipconfig
        sipVersion = sipconfig.Configuration().sip_version_str
        # always assume, that snapshots are good
        if "snapshot" not in sipVersion:
            # check for blacklisted versions
            for vers in BlackLists["sip"]:
                if vers == sipVersion:
                    dbgMsg(
                        'Sorry, sip version %s is not compatible with eric4.' %
                        vers)
                    dbgMsg('Please install another version.')
                    return False
    except ImportError:
        pass

    # check version of PyQt
    from PyQt4.QtCore import PYQT_VERSION_STR
    pyqtVersion = PYQT_VERSION_STR
    # always assume, that snapshots are good
    if "snapshot" not in pyqtVersion:
        # check for blacklisted versions
        for vers in BlackLists["PyQt4"]:
            if vers == pyqtVersion:
                dbgMsg(
                    'Sorry, PyQt4 version %s is not compatible with eric4.' %
                    vers)
                dbgMsg('Please install another version.')
                return False

    # check version of QScintilla
    from PyQt4.Qsci import QSCINTILLA_VERSION_STR
    scintillaVersion = QSCINTILLA_VERSION_STR
    # always assume, that snapshots are new enough
    if "snapshot" not in scintillaVersion:
        # check for blacklisted versions
        for vers in BlackLists["QScintilla2"]:
            if vers == scintillaVersion:
                dbgMsg(
                    'Sorry, QScintilla2 version %s is not compatible with eric4.'
                    % vers)
                dbgMsg('Please install another version.')
                return False

    return True
 def acceptConnection(self):
     dbgMsg("ACCEPTING NEW CONNECTION")
     self.clientSocket = self.tcpServer.nextPendingConnection()  # this is connecting tcp socket from the client
     self.clientSocket.disconnected.connect(self.clientSocket.deleteLater)
     self.clientSocket.readyRead.connect(self.readFileName)
class ErrorConsole(QsciScintilla):
    """
    Class providing a specialized text edit for displaying logging information.
    """
    __pyqtSignals__ = ("closeCC3D()", )

    @QtCore.pyqtSignature("closeCC3D()")
    def emitCloseCC3D(self):
        self.emit(SIGNAL("closeCC3D()"))

    def __init__(self, parent=None):
        """
        Constructor
        
        @param parent reference to the parent widget (QWidget) - here it is EditorWindow class
        """
        self.editorWindow = parent

        self.playerMainWidget = None

        QsciScintilla.__init__(self, parent)
        # # self.setFolding(5)
        self.setFolding(QsciScintilla.BoxedTreeFoldStyle)
        # self.setMarginSensitivity(3,True)
        lexer = QsciLexerPython()
        dbgMsg(lexer.keywords(1), "\n\n\n\n")
        syntaxErrorLexer = SyntaxErrorLexer(self)
        self.setLexer(syntaxErrorLexer)

        self.setReadOnly(True)
        #         self.setReadOnly(False)

        self.setCaretLineVisible(True)
        # font=self.font()
        font = QFont("Courier New", 10)

        if sys.platform.startswith('da'):
            font = QFont("Courier New", 12)
        # font.setFixedPitch(True)
        self.setFont(font)

        self.setCaretLineBackgroundColor(
            QtGui.QColor('#E0E0F8'))  #current line has this color
        self.setSelectionBackgroundColor(
            QtGui.QColor('#E0E0F8')
        )  # any selection in the current line due to double click has the same color too
        #connecting SCN_DOUBLECLICK(int,int,int) to editor double-click
        #notice  QsciScintilla.SCN_DOUBLECLICK(int,int,int) is not the right name
        # self.connect(self, SIGNAL("SCN_DOUBLECLICK(int,int,int)"), self.onDoubleClick)

        GETFOLDLEVEL = QsciScintilla.SCI_GETFOLDLEVEL
        SETFOLDLEVEL = QsciScintilla.SCI_SETFOLDLEVEL
        HEADERFLAG = QsciScintilla.SC_FOLDLEVELHEADERFLAG
        LEVELBASE = QsciScintilla.SC_FOLDLEVELBASE
        NUMBERMASK = QsciScintilla.SC_FOLDLEVELNUMBERMASK
        WHITEFLAG = QsciScintilla.SC_FOLDLEVELWHITEFLAG

        headerLevel = LEVELBASE | HEADERFLAG
        lineStart = 1
        lineEnd = 3

        # self.SendScintilla(QsciScintilla.SCI_SETCARETSTYLE, QsciScintilla.CARETSTYLE_INVISIBLE) # make caret invisible

        self.lineNumberExtractRegex = re.compile(
            '^[\s\S]*[L|l]ine:[\s]*([0-9]*)')
        self.colNumberExtractRegex = re.compile(
            '^[\s\S]*[C|c]ol:[\s]*([0-9]*)')

        self.fileNameExtractRegex = re.compile('^[\s]*File:[\s]*([\S][\s\S]*)')

        # self.zoomRange=self.editorWindow.configuration.setting("ZoomRangeFindDisplayWidget")
        # self.zoomTo(self.zoomRange)

        dbgMsg("marginSensitivity=", self.marginSensitivity(0))

        self.cc3dSender = CC3DSender.CC3DSender(self)

    def setPlayerMainWidget(self, _playerMainWidget):

        self.playerMainWidget = _playerMainWidget

    def addNewFindInFilesResults(self, _str):
        self.setFolding(QsciScintilla.BoxedTreeFoldStyle
                        )  # stray fold character workaround
        self.insertAt(_str, 0, 0)
        self.setCursorPosition(0, 0)
        # self.append(_str)

    # context menu handling
    def contextMenuEvent(self, event):
        menu = QMenu(self)
        copyAct = menu.addAction("Copy")
        selectAllAct = menu.addAction("Select All")
        clearAllAct = menu.addAction("Clear All")
        self.connect(copyAct, SIGNAL("triggered()"), self.copy)
        self.connect(selectAllAct, SIGNAL("triggered()"), self.selectAll)
        self.connect(clearAllAct, SIGNAL("triggered()"), self.clearAll)

        menu.exec_(event.globalPos())

    def wheelEvent(self, event):
        if qApp.keyboardModifiers() == Qt.ControlModifier:
            # Forwarding wheel event to editor windowwheelEvent
            if event.delta() > 0:
                self.zoomIn()
                # self.zoomRange+=1
            else:
                self.zoomOut()
                # self.zoomRange-=1
            # self.editorWindow.configuration.setSetting("ZoomRangeFindDisplayWidget",self.zoomRange)
        else:
            # # calling wheelEvent from base class - regular scrolling
            super(QsciScintilla, self).wheelEvent(event)

    def clearAll(self):
        self.clear()
        self.setFolding(
            QsciScintilla.NoFoldStyle)  # stray fold character workaround

    def onMarginClick(self, _pos, _modifier, _margin):
        dbgMsg("_pos:", _pos, " modifier:", _modifier, " _margin:", _margin)
        lineClick = self.SendScintilla(QsciScintilla.SCI_LINEFROMPOSITION,
                                       _pos)
        dbgMsg("lineClick=", lineClick)
        levelClick = self.SendScintilla(QsciScintilla.SCI_GETFOLDLEVEL,
                                        lineClick)
        dbgMsg("levelClick=", levelClick)
        if levelClick & QsciScintilla.SC_FOLDLEVELHEADERFLAG:
            dbgMsg("Clicked Fold Header")
            self.SendScintilla(QsciScintilla.SCI_TOGGLEFOLD, lineClick)

    # to prevent QScintilla from selecting words on double click we implement mouseDoubleClisk event -
    # in fact this is only necessary when using popup window (which we do)
    def mouseDoubleClickEvent(self, event):
        # self.setCursorPosition(0,0)
        x = event.x()
        y = event.y()
        position = self.SendScintilla(QsciScintilla.SCI_POSITIONFROMPOINT, x,
                                      y)
        line = self.SendScintilla(QsciScintilla.SCI_LINEFROMPOSITION, position)
        self.onDoubleClick(position, line, None)
        event.accept()

    def onDoubleClick(self, _position, _line, _modifiers):
        dbgMsg("position=", _position, " line=", _line, " modifiers=",
               _modifiers)
        lineText = str(self.text(_line))
        dbgMsg("line text=", lineText)
        lineNumberGroups = self.lineNumberExtractRegex.search(lineText)
        lineNumber = -1
        colNumber = -1
        lineNumberWithFileName = -1
        fileName = ""
        try:
            if lineNumberGroups:
                lineNumber = int(lineNumberGroups.group(1))
                dbgMsg("Error at line=", lineNumber)
                lineNumberWithFileName = self.SendScintilla(
                    QsciScintilla.SCI_GETFOLDPARENT, _line)
        except IndexError, e:

            dbgMsg("Line number not found")

        colNumberGroups = self.colNumberExtractRegex.search(lineText)
        try:
            if colNumberGroups:
                colNumber = int(colNumberGroups.group(1))
                dbgMsg("Error at column=", colNumber)

        except IndexError, e:

            dbgMsg("Col number not found")
示例#50
0
def decode(_fh, _testTextLength=0):  #taking fileHandle as first argument
    """
    Function to decode a text.
    
    # @param text text to decode (string)
    # @return decoded text and encoding
    # passing file.read() to decode causes improper detection of encoding
    # we have to first store file content localy and then pass the string to decode fcn
    
    """
    text = ""
    textFullyRead = False
    try:
        text = _fh.read(
            16
        )  # reading first 16 bytes - thin should be more than enough for detecting BOM charcters

        if text.startswith(BOM_UTF8):
            # UTF-8 with BOM
            # return unicode(text[len(BOM_UTF8):], 'utf-8'), 'utf-8-bom'
            return unicode(text[len(BOM_UTF8):], 'utf-8'), 'utf-8-sig'
        elif text.startswith(BOM_UTF16):
            # UTF-16 with BOM
            return unicode(text[len(BOM_UTF16):], 'utf-16'), 'utf-16'
        elif text.startswith(BOM_UTF32):
            # UTF-32 with BOM
            return unicode(text[len(BOM_UTF32):], 'utf-32'), 'utf-32'
        elif text.startswith(BOM_BE):
            # UTF-16BE with BOM
            return unicode(text[len(BOM_BE):], 'utf-16be'), 'utf-16be'
        elif text.startswith(BOM_UTF16_BE):
            # UTF-16BE with BOM
            return unicode(text[len(BOM_UTF16_BE):], 'utf-16be'), 'utf-16be'
        elif text.startswith(BOM_LE):
            # UTF-16LE with BOM
            return unicode(text[len(BOM_LE):], 'utf-16le'), 'utf-16le'
        elif text.startswith(BOM_UTF32_BE):
            # UTF-32BE with BOM
            return unicode(text[len(BOM_UTF32_BE):], 'utf-32be'), 'utf-32be'
        elif text.startswith(BOM_UTF32_LE):
            # UTF-32LE with BOM
            return unicode(text[len(BOM_UTF32_LE):], 'utf-32le'), 'utf-32le'

        #put file pointer at the beginning
        _fh.seek(0)
        text = _fh.read()
        textFullyRead = True
        dbgMsg(
            "GUESSING ENCODING **************************************************************"
        )
        # this part makes opening of the documents very slow - decided to use guessed encoding instead
        # coding = get_coding(text)
        # if coding:
        # return unicode(text, coding), coding
    except (UnicodeError, LookupError):
        dbgMsg(
            "UnicodeError encountered *************************************************\n\n\n\n"
        )
        pass

    #  check it just in case
    if not textFullyRead:
        #put file pointer at the beginning
        _fh.seek(0)
        text = _fh.read()
    guess = None

    if True:
        # Try the universal character encoding detector

        try:
            import Encoding.EncodingDetector.chardet
            if not _testTextLength:
                guess = Encoding.EncodingDetector.chardet.detect(text)
            else:
                textLength = len(text)
                guess = Encoding.EncodingDetector.chardet.detect(
                    text[0:min(textLength, abs(_testTextLength))])
            if guess and guess['confidence'] > 0.95 and guess[
                    'encoding'] is not None:
                codec = guess['encoding'].lower()
                return unicode(text, codec), '%s-guessed' % codec
        except (UnicodeError, LookupError):
            pass
        except ImportError:
            pass

    # Try default encoding
    try:
        codec = unicode(default_coding)
        return unicode(text, codec), '%s-default' % codec
    except (UnicodeError, LookupError):
        pass

    # Assume UTF-8
    try:
        return unicode(text, 'utf-8'), 'utf-8-guessed'
    except (UnicodeError, LookupError):
        pass

    if True:
        # Use the guessed one even if confifence level is low
        if guess and guess['encoding'] is not None:
            try:
                codec = guess['encoding'].lower()
                return unicode(text, codec), '%s-guessed' % codec
            except (UnicodeError, LookupError):
                pass

    # Assume Latin-1 (behaviour before 3.7.1)
    return unicode(text, "latin-1"), 'latin-1-guessed'
    def styleText(self, start, end):
        editor = self.editor()
        if editor is None:
            return

        # scintilla works with encoded bytes, not decoded characters.
        # this matters if the source contains non-ascii characters and
        # a multi-byte encoding is used (e.g. utf-8)
        source = ''
        if end > editor.length():
            end = editor.length()
        if end > start:
            if sys.hexversion >= 0x02060000:
                # faster when styling big files, but needs python 2.6
                source = bytearray(end - start)
                editor.SendScintilla(editor.SCI_GETTEXTRANGE, start, end,
                                     source)
            else:
                # source = unicode(editor.text()
                # ).encode('utf-8')[start:end]
                source = unicode(editor.text()).encode(
                    'utf-8'
                )  # scanning entire text is way more efficient that doing it on demand especially when folding top level text (Search)
        if not source:
            return

        # the line index will also be needed to implement folding
        index = editor.SendScintilla(editor.SCI_LINEFROMPOSITION, start)
        if index > 0:
            # the previous state may be needed for multi-line styling
            pos = editor.SendScintilla(editor.SCI_GETLINEENDPOSITION,
                                       index - 1)
            state = editor.SendScintilla(editor.SCI_GETSTYLEAT, pos)
        else:
            state = self.Default

        set_style = self.setStyling
        self.startStyling(start, 0x1f)

        # SCI = self.SendScintilla
        SCI = self.editorWidget.SendScintilla
        GETFOLDLEVEL = QsciScintilla.SCI_GETFOLDLEVEL
        SETFOLDLEVEL = QsciScintilla.SCI_SETFOLDLEVEL
        HEADERFLAG = QsciScintilla.SC_FOLDLEVELHEADERFLAG
        LEVELBASE = QsciScintilla.SC_FOLDLEVELBASE
        NUMBERMASK = QsciScintilla.SC_FOLDLEVELNUMBERMASK
        WHITEFLAG = QsciScintilla.SC_FOLDLEVELWHITEFLAG
        # scintilla always asks to style whole lines

        for line in source.splitlines(True):
            length = len(line)
            # dbgMsg("line=",line)
            # dbgMsg(line)
            if line.startswith('\n'):
                style = self.Default
                dbgMsg("GOT EMPTY LINE")
                # sys.exit()
            else:
                if line.startswith('Error'):
                    state = self.ErrorInfo

                    # searchGroups =re.search('"([\s\S]*)"', line) # we have to use search instead of match - match matches onle beginning of the string , search searches through entire string

                    # # dbgMsg("searchGroups=",searchGroups)

                    # try:

                    # if searchGroups:
                    # # dbgMsg(searchGroups.group(1))
                    # self.searchText=searchGroups.group(1)

                    # # dbgMsg("self.searchText=",self.searchText)
                    # except IndexError,e:
                    # self.searchText=""
                    # dbgMsg("COULD NOT EXTRACT TEXT")

                # elif line.startswith('  File'):
                elif line.startswith('  F'):
                    state = self.FileInfo

                # elif line.startswith('    Line'):
                elif line.startswith('   '):

                    if self.searchText != "":
                        # dbgMsg("self.searchText=",self.searchText)
                        searchTextLength = len(self.searchText)
                        # pos = line.find(self.searchText)
                        # set_style(pos, self.LineInfo) # styling begining of the line
                        # set_style(searchTextLength, self.TextToFind) # styling searchText of the line
                        # length = length - pos - searchTextLength  # Default styling is applied to RHS
                        # state = self.ErrorInfo
                        # dbgMsg("LENGTH=",length)

                        # length = length - pos
                        # dbgMsg("line=",line)
                        startPos = 0
                        # string line is not use to output to the screen it is local to this fcn therefore it is safe to use lower
                        pos = line.lower().find(self.searchText.lower())
                        while pos != -1:

                            set_style(
                                pos - startPos,
                                self.LineInfo)  # styling begining of the line
                            set_style(searchTextLength, self.TextToFind
                                      )  # styling searchText of the line
                            startPos = pos + searchTextLength
                            pos = line.find(self.searchText, startPos)
                            state = self.LineInfo

                        state = self.LineInfo
                        length = length - startPos  # last value startPos if startPos point to the location right after last found searchText - to continue styling we tell lexer to style reminder of the line (length-startPos) with LineInfo style
                    else:
                        dbgMsg("DID NOT FIND SEARCH TEXT")
                        # state = self.Default
                        state = self.LineInfo

                    # # the following will style lines like "x = 0"

                    # pos = line.find('\tFile')

                    # if pos > 0:
                    # set_style(pos, self.ErrorInfo) #styling LHS pos is the length of styled text
                    # set_style(1, self.FileInfo)#styling = 1 is the length of styled text
                    # length = length - pos - 1
                    # state = self.ErrorInfo
                    # else:
                    # state = self.Default
                else:
                    # state = self.Default
                    state = self.LineInfo

            set_style(length, state)
            # folding implementation goes here
            headerLevel = LEVELBASE | HEADERFLAG
            # dbgMsg("HEADER LEVEL",headerLevel)

            # if index==0:
            if state == self.ErrorInfo:
                SCI(SETFOLDLEVEL, index, headerLevel)
            elif state == self.FileInfo:
                SCI(
                    SETFOLDLEVEL, index, headerLevel + 1
                )  # this subheader - inside header for ErrorInfo style - have to add +1 to folding level
            elif state == self.LineInfo:
                SCI(
                    SETFOLDLEVEL, index, LEVELBASE + 2
                )  # this is non-header fold line - since it is inside header level and headerLevel +1 i had to add +3 to the  LEVELBASE+2
            else:
                SCI(
                    SETFOLDLEVEL, index, LEVELBASE + 2
                )  # this is non-header fold line - since it is inside header level and headerLevel +1 i had to add +3 to the  LEVELBASE+2

            index += 1
示例#52
0
def encode(text, orig_coding):
    """
    Function to encode a text.
    
    @param text text to encode (string)
    @param orig_coding type of the original coding (string)
    @return encoded text and encoding
    """
    if orig_coding == 'utf-8-bom':
        # return BOM_UTF8 + text.encode("utf-8"), 'utf-8-bom'
        return unicode(text), orig_coding
    dbgMsg("ENCODING is ", orig_coding,
           " *********************************************")

    # use orig_coding without any modifications
    try:
        # return text.encode(orig_coding), orig_coding
        # since I am using codec.open() I dont have to encode text it is enough if I converti it to unicode
        return unicode(text), orig_coding
    except (UnicodeError, LookupError):
        pass

    # if it does not work then
    # try declared coding spec
    coding = get_coding(text)
    if coding:
        try:
            return text.encode(coding), coding
        except (UnicodeError, LookupError):
            # Error: Declared encoding is incorrect
            raise CodingError(coding)

    if orig_coding and orig_coding.endswith('-selected'):
        coding = orig_coding.replace("-selected", "")
        try:
            return text.encode(coding), coding
        except (UnicodeError, LookupError):
            pass
    if orig_coding and orig_coding.endswith('-default'):
        coding = orig_coding.replace("-default", "")
        try:
            return text.encode(coding), coding
        except (UnicodeError, LookupError):
            pass
    if orig_coding and orig_coding.endswith('-guessed'):
        coding = orig_coding.replace("-guessed", "")
        try:
            return text.encode(coding), coding
        except (UnicodeError, LookupError):
            pass

    # Try configured default
    try:
        codec = unicode(default_coding)
        return text.encode(codec), codec
    except (UnicodeError, LookupError):
        pass

    # Try saving as ASCII
    try:
        return text.encode('ascii'), 'ascii'
    except UnicodeError:
        pass

    # Save as UTF-8 without BOM
    return text.encode('utf-8'), 'utf-8'
def setActionKeyboardShortcut(_name,_keySequence):        
    try:        
        dbgMsg("BEFORE actionToShortcutDict=",len(actionToShortcutDict))
        dbgMsg("_name=",_name," sequence=",_keySequence.toString())
        
        shortcutText=str(QKeySequence(_keySequence).toString())
        
        removeExistingShortcut(shortcutText)
        
        # remove shortcut for the action for which we are doing reassignment
        removeExistingShortcut(actionToShortcutDict[str(_name)])
        actionDict[str(_name)].setShortcut(QKeySequence(shortcutText))        
        dbgMsg("_name=",_name)
        dbgMsg("before assign actionToShortcutDict=",len(actionToShortcutDict))
        actionToShortcutDict[str(_name)]=shortcutText
        shortcutToActionDict[shortcutText]=str(_name)
        dbgMsg("actionToShortcutDict=",len(actionToShortcutDict))
        dbgMsg("shortcutToActionDict=",len(shortcutToActionDict))
        dbgMsg("actionDict=",len(actionDict))
        
        
    except KeyError:
        dbgMsg("KeyError setActionKeyboardShortcut(")
        return None
示例#54
0
 def doneRecording(self):
     dbgMsg(" Done recording")
     self.releaseKeyboard()
     self.recording = False
     self.grabButton.setEnabled(True)