コード例 #1
0
    def __init__(self,
                 externalPython=None,
                 matplotlib_eventHandler=True,
                 cellHighlight=True,
                 popupForUnselectedVariable=True,
                 popupForSelectedExpression=False,
                 mouseDwellTime=200):
        '''Initializes PyPadPlusPlus to prepare Notepad++
        for interactive Python development'''
        console.show()
        editor.grabFocus()
        self.windowHandle = windll.user32.GetForegroundWindow()

        sys.stdout = PseudoFileOut(Npp.console.write)
        sys.stderr = PseudoFileOut(Npp.console.writeError)
        sys.stdout.outp = PseudoFileOut(Npp.console.write)

        self.matplotlib_eventHandler = matplotlib_eventHandler
        self.matplotlib_enabled = False
        self.popupForUnselectedVariable = popupForUnselectedVariable
        self.popupForSelectedExpression = popupForSelectedExpression
        self.mouseDwellTime = mouseDwellTime

        self.externalPython = bool(externalPython)
        if self.externalPython:
            from . import pyPadHost
            self.interp = pyPadHost.interpreter(externalPython,
                                                outBuffer=self.outBuffer)
        else:
            from . import pyPadClient
            self.interp = pyPadClient.interpreter()

        if cellHighlight:
            self.lexer = EnhancedPythonLexer()
            self.lexer.main()
        else:
            self.lexer = None

        self.thread = None
        self.threadMarker = None
        self.bufferActive = 1
        self.delayedMarker = False
        self.activeCalltip = None
        editor.setTargetStart(0)
        self.specialMarkers = None
        self.bufferMarkerAction = {}
        self.lastActiveBufferID = -1

        # Marker
        self.markerWidth = 3
        editor.setMarginWidthN(3, self.markerWidth)
        editor.setMarginMaskN(3, (256 + 128 + 64) * (1 + 2**3 + 2**6))
        self.markers = {}
        self.m_active, self.m_error, self.m_finish = [
            6 + 3 * i for i in [0, 1, 2]
        ]
        self.preCalculateMarkers()
        for iMarker in self.m_active, self.m_error, self.m_finish:
            self.drawMarker(iMarker)

        self.setCallbacks()

        editor.callTipSetBack((255, 255, 225))
        editor.autoCSetSeparator(ord('\t'))
        editor.autoCSetIgnoreCase(False)
        editor.autoCSetCaseInsensitiveBehaviour(False)
        editor.autoCSetCancelAtStart(False)
        editor.autoCSetDropRestOfWord(False)

        console.clear()
        console.editor.setReadOnly(0)

        self.tTimerFlush = 0.15
        self.tTimerMiddleButton = 0.1
        self.middleButton = 0

        self.bufferActive = 0
        self.onTimerFlush(
        )  # start periodic timer to check output of subprocess
        self.onTimerMiddleButton(
        )  # start periodic timer to check state of middleButton
コード例 #2
0
# define different ids otherwise npp
# would jump in and act accordingly
MARK_HIDELINESBEGIN = 15
MARK_HIDELINESEND = 14
MARK_HIDELINESUNDERLINE = 13

MARK_HIDELINESBEGIN_MASK = 1 << MARK_HIDELINESBEGIN
MARK_HIDELINESEND_MASK = 1 << MARK_HIDELINESEND
MARK_HIDELINESUNDERLINE_MASK = 1 << MARK_HIDELINESUNDERLINE
MARK_COMBINED_MASK = MARK_HIDELINESBEGIN_MASK + MARK_HIDELINESEND_MASK

editor.setMarginMaskN(1, (MARK_HIDELINESBEGIN_MASK
                          | MARK_HIDELINESEND_MASK
                          | MARK_HIDELINESUNDERLINE_MASK
                          | NPP_MARK_BOOKMARK_MASK
                          | NPP_MARK_HIDELINESBEGIN_MASK
                          | NPP_MARK_HIDELINESEND_MASK
                          | NPP_MARK_HIDELINESUNDERLINE_MASK))

editor.rGBAImageSetWidth(14)
editor.rGBAImageSetHeight(14)
editor.markerDefineRGBAImage(MARK_HIDELINESBEGIN, hidelines_begin14)
editor.markerDefineRGBAImage(MARK_HIDELINESEND, hidelines_end14)
editor.markerDefine(MARK_HIDELINESUNDERLINE, MARKERSYMBOL.UNDERLINE)
editor.markerSetBack(MARK_HIDELINESUNDERLINE, (0xF7, 0xCC, 0x77))


# ---------------------------------------------------------------------------------
# helper functions
# toggle_bookmark is only needed to cheat npp