예제 #1
0
def run_command(command, __cwd):

    _startupinfo = subprocess.STARTUPINFO()
    _startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
    process = subprocess.Popen(shlex.split(command),
                               startupinfo=_startupinfo,
                               stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE,
                               cwd=__cwd)
    _stdout, _stderr = process.communicate()

    console.show()
    if _stdout: console.write(_stdout)
    if _stderr: console.write(_stderr)
def run_command(command, __cwd):
    
    _startupinfo = subprocess.STARTUPINFO() 
    _startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
    process = subprocess.Popen(shlex.split(command),
                               startupinfo=_startupinfo,
                               stdout=subprocess.PIPE, 
                               stderr=subprocess.PIPE, 
                               cwd=__cwd)
    _stdout, _stderr = process.communicate()
    
    console.show()
    if _stdout: console.write(_stdout)
    if _stderr: console.write(_stderr)
예제 #3
0
def match_found(m):
    _m = m.span()
    if IGNORE_0_LENGTH_MATCHES and (_m[0] == _m[1]):
        return

    global IS_ODD
    global MATCH_POSITIONS
    global NO_MATCH_FOUND

    _match_positions = []
    if REPORT_MATCHES:
        console.show()
        editor.grabFocus()
        console.write('Match:{} = {}\n'.format(_m, editor1.getTextRange(*_m)))

    if m.lastindex > 0:
        editor1.setIndicatorCurrent(8)
        editor1.indicatorFillRange(m.span(0)[0], m.span(0)[1] - m.span(0)[0])
        _match_positions.append(m.span())
        for i in range(1, m.lastindex + 1):
            if (m.span(i)[0] != m.span(0)[0]) or (m.span(i)[1] != m.span(0)[1]):
                editor1.setIndicatorCurrent(9 if IS_ODD else 10)
                editor1.indicatorFillRange(m.span(i)[0], m.span(i)[1] - m.span(i)[0])

                IS_ODD = not IS_ODD
                if REPORT_MATCHES:
                    _textrange = editor1.getTextRange(*m.span(i)) if -1 not in m.span(i) else ''
                    console.write('  SubMatch:{} = {}\n'.format(m.span(i), _textrange))

    else:
        editor1.setIndicatorCurrent(9 if IS_ODD else 10)
        editor1.indicatorFillRange(_m[0], _m[1] - _m[0])

        IS_ODD = not IS_ODD
        _match_positions.append(m.span())

    MATCH_POSITIONS[CURRENT_BUFFER_ID].extend(_match_positions)

    NO_MATCH_FOUND = False
예제 #4
0
def match_found(m):
    _m = m.span()
    if IGNORE_0_LENGTH_MATCHES and (_m[0] == _m[1]):
        return

    global IS_ODD
    global MATCH_POSITIONS
    global NO_MATCH_FOUND

    _match_positions = []
    if REPORT_MATCHES:
        console.show()
        editor.grabFocus()
        console.write('Match:{} = {}\n'.format(_m, editor1.getTextRange(*_m)))

    if m.lastindex > 0:
        editor1.setIndicatorCurrent(8)
        editor1.indicatorFillRange(m.span(0)[0], m.span(0)[1] - m.span(0)[0])
        _match_positions.append(m.span())
        for i in range(1, m.lastindex + 1):
            if (m.span(i)[0] != m.span(0)[0]) or (m.span(i)[1] != m.span(0)[1]):
                editor1.setIndicatorCurrent(9 if IS_ODD else 10)
                editor1.indicatorFillRange(m.span(i)[0], m.span(i)[1] - m.span(i)[0])

                IS_ODD = not IS_ODD
                if REPORT_MATCHES:
                    _textrange = editor1.getTextRange(*m.span(i)) if -1 not in m.span(i) else ''
                    console.write('  SubMatch:{} = {}\n'.format(m.span(i), _textrange))

    else:
        editor1.setIndicatorCurrent(9 if IS_ODD else 10)
        editor1.indicatorFillRange(_m[0], _m[1] - _m[0])

        IS_ODD = not IS_ODD
        _match_positions.append(m.span())

    MATCH_POSITIONS[CURRENT_BUFFER_ID].extend(_match_positions)

    NO_MATCH_FOUND = False
예제 #5
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
예제 #6
0
    the <comment_or_delete> tags it is ready to be used

"""
from Npp import editor, notepad, console, MESSAGEBOXFLAGS
from itertools import izip_longest

try:
    import Tkinter as tk
    import ttk
except ImportError as e:
    notepad.messageBox(('Unable to import Tkinter libraries,\n'
                        'these are needed for the UI.\n\n'
                        'Check your installation.\n\n'
                        '{}'.format(e.message)), 'Missing Library',
                       MESSAGEBOXFLAGS.ICONERROR)
    console.show()
    raise


def main():

    list_of_separators = [('Comma', 0), ('Semicolon', 1), ('Space', 2),
                          ('Clipboard', 3)]
    separator_dict = {0: ',', 1: ';', 2: ' ', 3: 'clipboard'}

    list_of_areas = [('Whole document', 0), ('Selection only', 1),
                     ('Visible lines only', 2)]

    format_types_dict = {0: '\r\n', 1: '\r', 2: '\n'}

    def button_reformat():
예제 #7
0
    Note: By commenting or deleting everything, including,
    the <comment_or_delete> tags it is ready to be used

"""
from Npp import editor, notepad, console, MESSAGEBOXFLAGS
from itertools import izip_longest

try:
    import Tkinter as tk
    import ttk
except ImportError as e:
    notepad.messageBox(('Unable to import Tkinter libraries,\n'
                        'these are needed for the UI.\n\n'
                        'Check your installation.\n\n'
                        '{}'.format(e.message)),'Missing Library', MESSAGEBOXFLAGS.ICONERROR)   
    console.show()
    raise


def main():

    list_of_separators = [('Comma',0),('Semicolon',1),('Space',2),('Clipboard', 3)]
    separator_dict = {0:',', 1:';', 2:' ', 3:'clipboard'}

    list_of_areas = [('Whole document',0),('Selection only',1),('Visible lines only',2)]

    format_types_dict = {0:'\r\n',1:'\r',2:'\n'}


    def button_reformat():
        reformat(separator_value.get(), reformat_value.get())