Skip to content

Commit

Permalink
Version 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bitagoras committed Nov 20, 2018
1 parent 82fcd59 commit 4a9e7c2
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 15 deletions.
12 changes: 6 additions & 6 deletions demo/featureDemo.py → demo/pyPadDemo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

#%% Execution with Keyboard and Mouse

# <Ctrl> + <Return> executes the smalles possible piece of code
# <Shift> + <Return> executes the smalles possible piece of code
# that includes the line at the cursor or next to the cursor.

print "hello world"

# With <Ctrl> + <Shift> + <Return> the cursor stays at its position
# and the same line can be executed several times.

# The value of a single expression line will be printed
1+2

Expand All @@ -18,7 +21,7 @@
s = str(i) * 8
print "loop", s

# Multiple lines can be executed by selection and <Ctrl> + <Return>.
# Multiple lines can be executed by selection and <Shift> + <Return>.
# The selection doesn't have to cover the whole line.
# With the middle mouse button (mouse wheel button) a single or
# multi line command or a selection can be executed.
Expand Down Expand Up @@ -60,7 +63,7 @@ def test(x):
print 'The result is:'
print x / 0
print "Now you"
print 'removed the '
print 'removed the'
print 'runtime error'

test(5) # runtime error
Expand Down Expand Up @@ -151,6 +154,3 @@ def twice(x, factor=2):
plt.plot(x, y, color=plt.cm.plasma(float(i)/n), alpha=0.9, lw=0.8)
plt.show()




2 changes: 1 addition & 1 deletion pyPadExecute.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# PyPadPlusPlus: Execute command
#
# Put a shortcut on this script to start the interactive programming
# Put a shortcut on this script to start the interactive programming.
# Recommended is <Shift> + <Enter>

try: Npp.pypad != None
Expand Down
2 changes: 1 addition & 1 deletion pyPadExecuteFix.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# PyPadPlusPlus: Execute command while cursor stays at position
#
# Put a shortcut on this script to start the interactive programming
# Put a shortcut on this script to start the interactive programming.
# Recommended is <Ctrl> + <Shift> + <Enter>

try: Npp.pypad != None
Expand Down
9 changes: 8 additions & 1 deletion pyPadPlusPlus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
__author__ = "Christian Schirm"
__copyright__ = "Copyright 2018"
__license__ = "GPLv3"
__version__ = "0.8"
__version__ = "1.0"

import Npp
from Npp import editor, console, notepad
Expand Down Expand Up @@ -111,6 +111,7 @@ def clearCallbacks(self):
editor.clearCallbacks([Npp.SCINTILLANOTIFICATION.DWELLSTART])
editor.clearCallbacks([Npp.SCINTILLANOTIFICATION.MODIFIED])
notepad.clearCallbacks([Npp.NOTIFICATION.BUFFERACTIVATED])
notepad.clearCallbacks([Npp.NOTIFICATION.SHUTDOWN])
if self.lexer:
notepad.clearCallbacks([Npp.SCINTILLANOTIFICATION.UPDATEUI])
notepad.clearCallbacks([Npp.NOTIFICATION.LANGCHANGED])
Expand All @@ -123,6 +124,8 @@ def setCallbacks(self):
editor.callback(self.onMouseDwell, [Npp.SCINTILLANOTIFICATION.DWELLSTART])
editor.callback(self.textModified, [Npp.SCINTILLANOTIFICATION.MODIFIED])
notepad.callback(self.onBufferActivated, [Npp.NOTIFICATION.BUFFERACTIVATED])
notepad.callback(self.onShutdown, [Npp.NOTIFICATION.SHUTDOWN])

if self.lexer:
editor.callbackSync(self.lexer.on_updateui, [Npp.SCINTILLANOTIFICATION.UPDATEUI])
notepad.callback(self.lexer.on_langchanged, [Npp.NOTIFICATION.LANGCHANGED])
Expand All @@ -133,6 +136,10 @@ def __del__(self):
except: pass
self.clearCallbacks()

def onShutdown(self, args):
try: self.interp.proc.terminate()
except: pass

def restartKernel(self):
if self.externalPython:
bufferID = self.bufferBusy
Expand Down
6 changes: 6 additions & 0 deletions pyPadPlusPlus/pyPadHost.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ def pipeWrapper(self, *param):

class interpreter:
def __init__(self, pythonPath='pythonw', outBuffer=None):
if not pythonPath.endswith('.exe'):
if pythonPath.strip().endswith('pythonw'):
pythonPath = pythonPath.strip() + '.exe'
else:
pythonPath = os.path.join(pythonPath.strip(),'pythonw.exe')
assert os.path.exists(pythonPath), 'file pythonw.exe not found.'
self.outBuffer = outBuffer
clientPath = os.path.join(os.path.dirname(__file__), 'pyPadClient.py')
self.StartCommand = pythonPath + ' -u ' + '"' + clientPath + '"'
Expand Down
17 changes: 11 additions & 6 deletions pyPadStart.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@
# PyPadPlusPlus: Startup script
#

# Set the path to pythonw.exe, e.g. "C:\\programs\\Anaconda2\\pythonw.exe".
# If pythonPath is None, the internal python of Notepad++ PythonScript
# is used. Some features are only available for the external python kernel.
# Python 3 is not supported, only Python 2.
# Set the path to the folder that contains pythonw.exe, e.g.
# "C:\\programs\\Anaconda2". If pythonPath is None, the internal Python
# distribution of Notepad++ PythonScript is used. Some features are only
# available for the external Python kernel. Python 3 is currently not
# supported, only Python 2.

pythonPath = "C:\\prog\\Anaconda2\\pythonw.exe"
pythonPath = None

# To use multiple interactive matplotlib windows, pyPadPlusPlus
# runs an internal matplotlib event handler during idle time.
# In case this causes problems, set to False
# If this cases any problems, set it to False.
# The matplotlib event handler is activated when matplotlib
# is imported. In case matplotlib is imported implicitly by
# another module, you must add to a code line a comment that
# contains the word "matplotlib".

matplotlib_EventHandler = True

Expand Down

0 comments on commit 4a9e7c2

Please sign in to comment.