List of User-submitted PyPN Scripts

UPDATE: NEW SCRIPT SHARING SITE

It's a bit more organized and allows for easier browsing/uploading/viewing/downloading. If you have any comments/suggestions on that site, please use the feedback link. Eventually the scriptshare website's functionality will be incorporated into pnotepad.org, but for now it exists on a separate domain.

If you've already uploaded scripts to this page, consider registering on the scriptshare site and re-uploading your script there. That will allow for things like comments, sorting, etc.

This wiki page is now obsolete

List of User-Submitted PyPN Scripts

This page served as a temporary home for user-submitted scripts. If you are adding a new script, please consider using the http://scriptshare.rocketmonkeys.com/ site instead. This page is now obsolete.
* Please do not modify someone else's script. If you modify someone else's script, repost it under your name or send your changes to the original author so they can update it. Otherwise it's chaos... chaos!

NickDMax - ClipStack

ClipStack is a Programmer's Notepad clipboard stack. It allows the user to select text and copy the text, which gets pushed onto a stack. Later this text can be pasted, which then pops the text off of this stack.

So, for example, if the user copies item A, then item B, and then item C, all using ClipStack; then they could then paste these items back in the order: Item C, Item B, Item A.

ClipStack does copy the the text into the clipboard so that you can paste the current selection in another application, but this will not pop an item off of the stack.

When pasting using ClipStack the current contents of the clipboard are replaced with the item on the top of the stack. This means that anything currently in the clipboard will be lost.

What ClipStack does not do is push the current clipboard onto the stack.

ClipStack could be improved by the addition of a clipboard aware python module that would allow the current clipboard to be used as the top item of the stack. This would allow the snippet to better interact with other applications.

################################################################################# ClipStack.py -- A clipboard stack allowing you to copy items into a stack## and then paste them back in a FILO way. So the first item copied to the stack## is the last item pasted from it.## Copy item #1, Copy item #2, Copy item #3## Paste #3, #2, #1#### The last item copied is placed onto the regular OS clipboard## The last item pasted is ALSO placed into the regular OS clipboard## So take care not to confuse this with the regular OS clipboard and## The standard Copy/Paste operations.## By: NickDMaximportpnimportscintillafrompypn.decoratorsimportscriptclassPNClipStack:""" Maintains a stack of text to paste """def__init__(self):""" initialize inner data: stack -- the internal list used to store clipboard items """self.stack=[]defpush(self,text):self.stack.append(text)defpop(self):retValue=''iflen(self.stack)>0:retValue=self.stack.pop()returnretValuedefclear(self):self.stack=[]defgetSize(self):returnlen(self.stack)ClipStack=PNClipStack()@script('Stack Count','ClipStack')defclstkCount():""" Prints out the size of the current ClipStack """pn.AddOutput('ClipStack Size: '+str(ClipStack.getSize())+'\n')@script('Copy','ClipStack')defclstkCopy():""" Adds the current selection to the ClipStack """doc=pn.CurrentDoc()ifdocisnotNone:#Lets try not to crash our scripteditor=scintilla.Scintilla(doc)start=editor.SelectionStartend=editor.SelectionEndif(start==end):#nothing is selected lets try to grab the current word.start=editor.WordStartPosition(start,True)end=editor.WordEndPosition(end,True)text=Noneif(start!=end):text=editor.GetTextRange(start,end)iftextisnotNone:ClipStack.push(text)editor.CopyText(len(text),text)#clstkCount()@script('Cut','ClipStack')defclstkCut():""" Adds the current selection to the ClipStack -- cuts it from document"""doc=pn.CurrentDoc()ifdocisnotNone:#Lets try not to crash our scripteditor=scintilla.Scintilla(doc)start=editor.SelectionStartend=editor.SelectionEndif(start==end):#nothing is selected lets try to grab the current word.start=editor.WordStartPosition(start,True)end=editor.WordEndPosition(end,True)text=Noneif(start!=end):text=editor.GetTextRange(start,end)iftextisnotNone:ClipStack.push(text)editor.SetSel(start,end)editor.Cut()#clstkCount()@script('Paste','ClipStack')defclstkPaste():""" Pastes the top item from the ClipStack into the document """doc=pn.CurrentDoc()ifdocisnotNone:#Lets try not to crash our scripteditor=scintilla.Scintilla(doc)text=ClipStack.pop()editor.CopyText(len(text),text)editor.Paste()#clstkCount()@script('Clear','ClipStack')defclstkCear():""" Clears the current ClipStack """ClipStack.clear()#clstkCount()

NickDMax - Base64Utils

Use this script to encode/decode selections using base64. This can be very useful for embedding Base64 images into HTML. Simply open a small gif/png in PN, select all, and then Base64Encode. This creates a Base64 Version of your image in a new document. Prefix the encoding with ''data:image/gif;base64,'' and you have a Base64 version of your image that you can paste directly into and HTML IMG tag's source.

################################################################################# base64Utils.py -- PnPy utility script to encode and decode base64. ## tested on Python 2.6.1. This utility will take the current selection## (or document if there is no selection) and create a base 64 encoded document## It will also take a base 64 encoded document and return the unencoded text.## -- Note: No verification is done to ensure that the unencoded data is ## ASCII or valid unicode textual data. ## By: NickDMaximportpnimportscintillafrompypn.decoratorsimportscriptimportbase64@script("Base64Encode","DocUtils")defdoBase64():""" This method will grab the curent selection/document and create a new document that is a base64 vesion of the text """doc=pn.CurrentDoc()ifdocisnotNone:#Lets try not to crash pn too often...editor=scintilla.Scintilla(doc)start=editor.SelectionStartend=editor.SelectionEndif(start==end):#nothing is selected so we will just grab it all...start=0end=editor.Lengthtext=editor.GetTextRange(start,end)newDoc=pn.NewDocument(None)newEditor=scintilla.Scintilla(newDoc)newEditor.BeginUndoAction()encoded=base64.b64encode(text)l=len(encoded)m=0whilel>80:str=encoded[m:m+80]+'\n'newEditor.AppendText(len(str),str)l,m=l-80,m+80str=encoded[m:m+l]newEditor.AppendText(len(str),str)newEditor.EndUndoAction()@script("DecodeBase64","DocUtils")defundoBase64():""" This method will grab the curent selection/document and create a new document that is the base64 decoded vesion of the text """doc=pn.CurrentDoc()ifdocisnotNone:#Lets try not to crash pn too often...editor=scintilla.Scintilla(doc)start=editor.SelectionStartend=editor.SelectionEndif(start==end):#nothing is selected so we will just grab it all...start=0end=editor.Lengthtext=editor.GetTextRange(start,end)decoded=base64.b64decode(text)newDoc=pn.NewDocument(None)newEditor=scintilla.Scintilla(newDoc)newEditor.BeginUndoAction()newEditor.AppendText(len(decoded),decoded)newEditor.EndUndoAction()

NickDMax - "As New" Utils

Functions to extract the current selection as a new document, or paste the contents of the clipboard as a new document.

################################################################################# AsNewUtils scripts -- the purpose of this script is to provide functions for## extracting /pasting text as new documents.## By: NickDMaximportpnimportscintillafrompypn.decoratorsimportscript@script("Extract As New","DocUtils")defdupDocument():""" This script will extract the current selection to a new document. """""" if there is no selection then it will duplicate the entire document. """doc=pn.CurrentDoc()ifdocisnotNone:#Lets try not to crash pn too often...editor=scintilla.Scintilla(doc)start=editor.SelectionStartend=editor.SelectionEndsch=doc.CurrentSchemeif(start==end):#nothing is selected so we will just grab it all...start=0end=editor.Lengthtext=editor.GetTextRange(start,end)newDoc=pn.NewDocument(sch)newEditor=scintilla.Scintilla(newDoc)newEditor.BeginUndoAction()newEditor.AppendText(len(text),text)newEditor.EndUndoAction()@script("Paste As New","DocUtils")defpasteAsNew():""" This script will paste the current contense of the clipboard into a new document """newDoc=pn.NewDocument(None)newEditor=scintilla.Scintilla(newDoc)newEditor.BeginUndoAction()newEditor.Paste()newEditor.EndUndoAction()

NickDMax - Hex Dump Utility

Extracts the current selection as a hex dump in a new document.

################################################################################# Doc2Hex v0.1 -- Will extract the current selection into a new document## Formatting the text as a Hex Dump. ## By: NickDMaximportpnimportscintillafrompypn.decoratorsimportscriptdefHexEncode(text):output=""iftextisnotNone:lineLength=0position=0whilelen(text)>0:output+="%08X |"%positioniflen(text)<=16:lineLength=len(text)else:lineLength=16snippet=text[0:lineLength]forxinsnippet:output+=" %02X"%ord(x)output+="\n"position+=16;text=text[lineLength:]returnoutput@script("Doc2Hex","DocUtils")defDoc2Hex():""" Doc2Hex will convert the current document into a HexDump """doc=pn.CurrentDoc()ifdocisnotNone:#Lets try not to crash pn too often...editor=scintilla.Scintilla(pn.CurrentDoc())start=editor.SelectionStartend=editor.SelectionEndif(start==end):#nothing is selected so we will just grab it all...start=0end=editor.Lengthtext=editor.GetTextRange(start,end)newDoc=pn.NewDocument(None)newEditor=scintilla.Scintilla(newDoc)newEditor.BeginUndoAction()encoded=HexEncode(text)newEditor.AppendText(len(encoded),encoded)newEditor.EndUndoAction()

Simon Steele - Number Converter

This script converts the number you have selected into Decimal, Hexadecimal, Octal and Binary and shows the results in the output window.