One thing I often do is extract a section of a file from one file open a new document and paste the result into it for later processing... I call this "clipboarding" and I do a good bit of it.
Here is a script that will automate that process. If you select a section of text and run the duplicate script it will open a new document and write in the content. If you do not have a selection this will duplicate the current document in an new window.
The file also contains a simple function to paste the contents of the clipboard into the a new document.
docUtils.py:
###############################################################################
## DocUtils scripts -- the purpose of this script is to provide functions for
## dealing with new documents.
## By: NickDMax
import pn
import scintilla
from pypn.decorators import script
@script("Duplicate", "DocUtils")
def dupDocument():
""" 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()
if doc is not None: #Lets try not to crash pn too often...
editor = scintilla.Scintilla(pn.CurrentDoc())
start = editor.SelectionStart
end = editor.SelectionEnd
sch = doc.CurrentScheme
if (start == end): #nothing is selected so we will just grab it all...
start = 0
end = editor.Length
text = editor.GetTextRange(start, end)
newDoc = pn.NewDocument(sch)
newEditor = scintilla.Scintilla(newDoc)
newEditor.BeginUndoAction()
newEditor.AppendText(len(text), text)
newEditor.EndUndoAction()
pass
@script("PasteAs New", "DocUtils")
def pasteAsNew():
""" This script will paste the current contense of the clipboard into a new document """
doc = pn.CurrentDoc()
if doc is not None: #Lets try not to crash pn too often...
newDoc = pn.NewDocument(None)
newEditor = scintilla.Scintilla(newDoc)
newEditor.BeginUndoAction()
newEditor.Paste()
newEditor.EndUndoAction()
pass