This is my first python script. It should sort the current selection. Any pointers on improving it are greatly appreciated. Also any pointers on developing these scripts? Right now I'm restarting PN after each change to force it to reload.
Thanks,
Scott
import pn
import scintilla
import string
from pypn.decorators import script
@script("Sort Lines")
def SortLines():
editor = scintilla.Scintilla(pn.CurrentDoc())
editor.BeginUndoAction()
lsSelection = editor.GetText(editor.SelectionStart, editor.SelectionEnd)
laLines = lsSelection.splitlines(0)
laLines.sort()
lsReplace = string.join(laLines, '\r\n' )
#pn.AddOutput(text + '\r\n')
#pn.AddOutput('Lines\r\n')
#pn.AddOutput(str(lines))
editor.ReplaceSel(lsReplace)
editor.EndUndoAction()