<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>untidy blog &#187; python</title>
	<atom:link href="http://untidy.net/blog/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://untidy.net/blog</link>
	<description>simon steele writes about stuff...</description>
	<lastBuildDate>Fri, 28 May 2010 13:28:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>PyPN Script Repository</title>
		<link>http://untidy.net/blog/2009/05/13/pypn-script-repository/</link>
		<comments>http://untidy.net/blog/2009/05/13/pypn-script-repository/#comments</comments>
		<pubDate>Wed, 13 May 2009 09:07:00 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Programmer's Notepad]]></category>
		<category><![CDATA[PyPN]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://untidy.net/blog/?p=343</guid>
		<description><![CDATA[Like the idea of using Python scripts to enhance Programmer&#8217;s Notepad but not sure where to start? James Yoneda has created the awesome ScriptShare website for exactly this purpose: There are a bunch of scripts already there, and hopefully you will add yours too! We&#8217;re working on getting this moved over to pnotepad.org eventually. My [...]]]></description>
			<content:encoded><![CDATA[<p>Like the idea of using Python scripts to enhance <a href="http://pnotepad.org/">Programmer&#8217;s Notepad</a> but not sure where to start? <a href="http://rocketmonkeys.com/">James Yoneda</a> has created the awesome <a href="http://scriptshare.rocketmonkeys.com/">ScriptShare</a> website for exactly this purpose:<br />
<div id="attachment_344" class="wp-caption alignnone" style="width: 445px"><a href="http://scriptshare.rocketmonkeys.com/"><img src="http://untidy.net/blog/wp-content/uploads/2009/05/scriptshare-google-chrome-3.png" alt="Scriptshare in Google Chrome" title="Scriptshare" width="435" height="344" class="size-medium wp-image-344" /></a><p class="wp-caption-text">Scriptshare in Google Chrome</p></div></p>
<p>There are a bunch of scripts already there, and hopefully you will add yours too! We&#8217;re working on getting this moved over to pnotepad.org eventually.</p>
<p>My thanks to James for putting this effort in and creating such a useful site in such short time!</p>
]]></content:encoded>
			<wfw:commentRss>http://untidy.net/blog/2009/05/13/pypn-script-repository/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PyPN 0.10.973 Released</title>
		<link>http://untidy.net/blog/2009/05/13/pypn-010973-released/</link>
		<comments>http://untidy.net/blog/2009/05/13/pypn-010973-released/#comments</comments>
		<pubDate>Wed, 13 May 2009 08:58:42 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Programmer's Notepad]]></category>
		<category><![CDATA[PyPN]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://untidy.net/blog/?p=340</guid>
		<description><![CDATA[I&#8217;m happy to announce a minor bug fix release for PyPN, the Python extension for Programmer&#8217;s Notepad. This release fixes a PN crash if you tried to create a Scintilla object with no active document, and also the exception syntax problem preventing PyPN from working in Python 2.4-2.5. Downloads PyPN 0.10.973 for Python 2.6 PyPN [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m happy to announce a minor bug fix release for PyPN, the <a href="http://python.org/">Python</a> extension for <a href="http://pnotepad.org/">Programmer&#8217;s Notepad</a>. This release fixes a PN crash if you tried to create a Scintilla object with no active document, and also the exception syntax problem preventing PyPN from working in Python 2.4-2.5.</p>
<p><b>Downloads</b></p>
<ul>
<li><a href="http://pnotepad.googlecode.com/files/pypn-0.10.973-py26.zip">PyPN 0.10.973 for Python 2.6</a></li>
<li><a href="http://pnotepad.googlecode.com/files/pypn-0.10.973-py25.zip">PyPN 0.10.973 for Python 2.5</a></li>
<li><a href="http://pnotepad.googlecode.com/files/pypn-0.10.973-py24.zip">PyPN 0.10.973 for Python 2.4</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://untidy.net/blog/2009/05/13/pypn-010973-released/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Programmer’s Notepad 2 0.9.921 Released</title>
		<link>http://untidy.net/blog/2009/02/11/programmer%e2%80%99s-notepad-2-09921-released/</link>
		<comments>http://untidy.net/blog/2009/02/11/programmer%e2%80%99s-notepad-2-09921-released/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 21:48:25 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Programmer's Notepad]]></category>
		<category><![CDATA[PyPN]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://untidy.net/blog/?p=271</guid>
		<description><![CDATA[The latest testing release of Programmer’s Notepad 2 is finally out. There are plenty of fixes in this release, and a few minor new features too. Of particular note are the following: Updates to the extensions interface allowing extensions to create menu items International input fixed (I know this will please a whole bunch of [...]]]></description>
			<content:encoded><![CDATA[<p>The latest testing release of Programmer’s Notepad 2 is finally out. There are plenty of fixes in this release, and a few minor new features too. Of particular note are the following:</p>
<ol>
<li>Updates to the extensions interface allowing extensions to create menu items</li>
<li>International input fixed (I know this will please a whole bunch of users)</li>
<li>Read only edit protection cleaned up</li>
<li>More text transforms, also available from context menu</li>
<li>Tab to space and vice versa conversions fixed</li>
<li>Notepad’s .LOG feature natively supported</li>
<li>Fix a problem using PN on the Windows 7 beta causing PN to hang on exit</li>
</ol>
<p><strong>Downloads</strong></p>
<ul>
<li><a href="http://pnotepad.googlecode.com/files/pn209921.exe">0.9.921 Installer</a></li>
<li><a href="http://pnotepad.googlecode.com/files/portable-pn209921.zip">0.9.921 Portable</a></li>
</ul>
<p>There is a new PyPN release supporting the updated plugin interface:</p>
<ul>
<li><a href="http://pnotepad.googlecode.com/files/pypn-0.11.921-py24.zip">PyPN 0.11.921 for Python 2.4</a></li>
<li><a href="http://pnotepad.googlecode.com/files/pypn-0.11.921-py25.zip">PyPN 0.11.921 for Python 2.5</a></li>
<li><a href="http://pnotepad.googlecode.com/files/pypn-0.11.921-py26.zip">PyPN 0.11.921 for Python 2.6</a></li>
</ul>
<p>Thanks to all the users who have put time and effort into reporting and following up on bugs, testing, and contributing patches.</p>
]]></content:encoded>
			<wfw:commentRss>http://untidy.net/blog/2009/02/11/programmer%e2%80%99s-notepad-2-09921-released/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Line Movement Commands with PyPN</title>
		<link>http://untidy.net/blog/2008/06/03/line-movement-commands-with-pypn/</link>
		<comments>http://untidy.net/blog/2008/06/03/line-movement-commands-with-pypn/#comments</comments>
		<pubDate>Tue, 03 Jun 2008 21:41:15 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Programmer's Notepad]]></category>
		<category><![CDATA[PyPN]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://untidy.net/blog/2008/06/03/line-movement-commands-with-pypn/</guid>
		<description><![CDATA[A bug on Google Code asked for an alternative to the built-in Transpose Lines command in Programmer&#8217;s Notepad, allowing a single command to move the current line up or down, allowing repeated use to shift a line through the current document. To look at implementing this, I started with a python script &#8211; it&#8217;s so [...]]]></description>
			<content:encoded><![CDATA[<p>A bug on Google Code asked for an alternative to the built-in Transpose Lines command in <a href="http://pnotepad.org/">Programmer&#8217;s Notepad</a>, allowing a single command to move the current line up or down, allowing repeated use to shift a line through the current document.</p>
<p>To look at implementing this, I started with a python script &#8211; it&#8217;s so much quicker than writing C++ code to add these commands and going through compile/test for every change.</p>
<p>Here&#8217;s how to add these commands as a couple of scripts (which of course can have keyboard shortcuts):</p>
<pre class="brush: python;">import pn, scintilla, pypn.glue

@script(&quot;Move Line Up&quot;, &quot;Text&quot;)
def MoveLineUp():
	s = scintilla.Scintilla(pn.CurrentDoc())
	l = s.LineFromPosition(s.CurrentPos)
	if (l == 0):
		return

	s.BeginUndoAction()
	s.LineTranspose()
	s.LineUp()
	s.EndUndoAction()

@script(&quot;Move Line Down&quot;, &quot;Text&quot;)
def MoveLineDown():
	s = scintilla.Scintilla(pn.CurrentDoc())
	l = s.LineFromPosition(s.CurrentPos)
	if (l == (s.LineCount-1)):
		return

	s.BeginUndoAction()
	s.LineDown()
	s.LineTranspose()
	s.EndUndoAction()
</pre>
<p>Drop this in a file in your scripts directory to use it (remember you need PyPN installed), or wait for the next version of PN which has these commands built in.</p>
]]></content:encoded>
			<wfw:commentRss>http://untidy.net/blog/2008/06/03/line-movement-commands-with-pypn/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Implementing Notepad&#8217;s .LOG Feature with PyPN</title>
		<link>http://untidy.net/blog/2008/05/28/implementing-notepads-log-feature-with-pypn/</link>
		<comments>http://untidy.net/blog/2008/05/28/implementing-notepads-log-feature-with-pypn/#comments</comments>
		<pubDate>Wed, 28 May 2008 22:20:46 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Programmer's Notepad]]></category>
		<category><![CDATA[PyPN]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://untidy.net/blog/?p=225</guid>
		<description><![CDATA[Notepad has a little-known feature where if you start a file with .LOG then every time the file is loaded the current date and time will be appended to the end of the file &#8211; allowing you to use a simple text file as a sort of diary. A feature request came in for this [...]]]></description>
			<content:encoded><![CDATA[<p>Notepad has a little-known feature where if you start a file with .LOG then every time the file is loaded the current date and time will be appended to the end of the file &#8211; allowing you to use a simple text file as a sort of diary.</p>
<p>A feature request came in for this and, pending a decision on whether to support it directly in <a href="http://pnotepad.org/">Programmer&#8217;s Notepad</a>, I decided to show how it could be implemented using the latest PyPN bits:</p>
<p><strong>Updated:</strong> Fixed a couple of minor bugs thanks to Jeff Rivett:</p>
<p><pre class="brush: python;">
import scintilla, pn, pypn.glue, time

oldDocLoad = pypn.glue.onDocLoad

def docLoad(doc):
    &quot;&quot;&quot; docLoad handler to implement notepad .LOG functionality&quot;&quot;&quot;

    # Get the edit component:
    s = scintilla.Scintilla(doc)

    # Get the first line:
    lineLength = s.LineLength(0)
    text = s.GetText(0, lineLength)

    # If we have .LOG then add a blank line and then the date and time
    if text.startswith(&quot;.LOG&quot;):
        timestr = &quot;\r\n\r\n&quot; + time.asctime(time.localtime()) + &quot;\r\n&quot;
        s.AppendText(len(timestr), timestr)

        # Jump to the end of the document
        s.DocumentEnd()

    oldDocLoad(doc)

pypn.glue.onDocLoad = docLoad
</pre>
</p>
<p>Just drop this code in a file called dotlog.py under Programmer&#8217;s Notepad\scripts and you&#8217;ll have the .LOG functionality. This all uses the very latest 2.0.9 unstable bits and the related PyPN build.</p>
]]></content:encoded>
			<wfw:commentRss>http://untidy.net/blog/2008/05/28/implementing-notepads-log-feature-with-pypn/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Context-Sensitive Python Help</title>
		<link>http://untidy.net/blog/2008/04/24/context-sensitive-python-help/</link>
		<comments>http://untidy.net/blog/2008/04/24/context-sensitive-python-help/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 22:10:24 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Programmer's Notepad]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://untidy.net/blog/2008/04/24/context-sensitive-python-help/</guid>
		<description><![CDATA[Over on the forums, Michel Claveau shows how he gets context-sensitive help for Python code in Programmer&#8217;s Notepad: Check where your python help file is (e.g. c:\python25\doc\Python25.chm) Install keyHH from http://www.keyworks.net/keyhh.htm Create a new tool in PN: &#160;&#160;&#160; &#8211; name: Python context Help &#160;&#160;&#160; &#8211; command: c:\windows\keyhh &#160;&#160;&#160; &#8211; parameters: -MyHelp -#klink &#8220;%w&#8221; c:\python25\doc\Python25.chm &#160;&#160;&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Over on the <a href="http://pnotepad.org/forums/">forums</a>, Michel Claveau shows how he gets context-sensitive help for Python code in Programmer&#8217;s Notepad:</p>
<ol>
<li>Check where your python help file is (e.g. c:\python25\doc\Python25.chm)</li>
<li>Install keyHH from <a href="http://www.keyworks.net/keyhh.htm">http://www.keyworks.net/keyhh.htm</a> </li>
<li>Create a new tool in PN: <br />&nbsp;&nbsp;&nbsp; &#8211; name: Python context Help <br />&nbsp;&nbsp;&nbsp; &#8211; command: c:\windows\keyhh <br />&nbsp;&nbsp;&nbsp; &#8211; parameters: -MyHelp -#klink &#8220;%w&#8221; c:\python25\doc\Python25.chm <br />&nbsp;&nbsp;&nbsp; &#8211; shortcut: F1 </li>
<li>Use it!</li>
</ol>
<p>Open a Python-source-file, click on the middle of a &#8220;strategic&#8221; word (examples: &#8220;time&#8221;, &#8220;sys&#8221;, &#8220;open&#8221;, etc.) or select the entire word, like &#8220;time.sleep&#8221;, and finally press [F1] and [Enter]</p>
<p>[<a href="http://pnotepad.org/forums/topic/384?replies=1">Forum Post</a>]</p>
]]></content:encoded>
			<wfw:commentRss>http://untidy.net/blog/2008/04/24/context-sensitive-python-help/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programmer&#8217;s Notepad &#8211; Calculator Part 2</title>
		<link>http://untidy.net/blog/2007/10/27/programmers-notepad-calculator-part-2/</link>
		<comments>http://untidy.net/blog/2007/10/27/programmers-notepad-calculator-part-2/#comments</comments>
		<pubDate>Sat, 27 Oct 2007 08:00:58 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Programmer's Notepad]]></category>
		<category><![CDATA[PyPN]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://untidy.net/blog/2007/10/27/programmers-notepad-calculator-part-2/</guid>
		<description><![CDATA[This time we&#8217;re going to use a PyPN script to evaluate maths expressions. We&#8217;re cheating a little, because we&#8217;re just going to ask python to evaluate a string and get a number back out. import pn, scintilla @script(&#34;Calculator&#34;) def DoMaths(): s = scintilla.Scintilla(pn.CurrentDoc()) if s.SelectionEnd - s.SelectionStart &#60; 1: return sel = s.SelText i = [...]]]></description>
			<content:encoded><![CDATA[<p>This time we&#8217;re going to use a PyPN script to evaluate maths expressions. We&#8217;re cheating a little, because we&#8217;re just going to ask python to evaluate a string and get a number back out.</p>
<pre class="brush: python;">
import pn, scintilla

@script(&quot;Calculator&quot;)
def DoMaths():
    s = scintilla.Scintilla(pn.CurrentDoc())

    if s.SelectionEnd - s.SelectionStart &lt; 1:
        return

    sel = s.SelText

    i = eval(sel)
    if type(i) in [int, float, complex]:
        pn.AddOutput(str(i))
</pre>
<p>To use this, simply select an expression like &#8220;5+5&#8243; in the editor, run the script, and the output window will contain the evaluation of the expression.</p>
<p>This script is very simple, and in fact could be generalised to a python expression evaluator, but it serves the intended purpose well. It could also be adapted to make sure that expressions are of the form &quot;exp=&quot; and then put the result after the = sign, or perhaps to replace the selected expression with the result. These changes are left as exercises for the reader!</p>
]]></content:encoded>
			<wfw:commentRss>http://untidy.net/blog/2007/10/27/programmers-notepad-calculator-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programmer&#8217;s Notepad &#8211; a Calculator?!</title>
		<link>http://untidy.net/blog/2007/10/26/programmers-notepad-a-calculator/</link>
		<comments>http://untidy.net/blog/2007/10/26/programmers-notepad-a-calculator/#comments</comments>
		<pubDate>Fri, 26 Oct 2007 11:00:56 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Programmer's Notepad]]></category>
		<category><![CDATA[PyPN]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://untidy.net/blog/2007/10/26/programmers-notepad-a-calculator/</guid>
		<description><![CDATA[One of the recent feature requests for Programmer&#8217;s Notepad was to add the ability in PN to perform basic numeric conversions, e.g. decimal to hex. Also the ability to evaluate simple mathematical expressions like 2+3=. With the PyPN extension this is very easy, and the required features can even be bound to keyboard shortcuts. Number [...]]]></description>
			<content:encoded><![CDATA[<p>One of the recent feature requests for Programmer&#8217;s Notepad was to add the ability in PN to perform basic numeric conversions, e.g. decimal to hex. Also the ability to evaluate simple mathematical expressions like 2+3=.</p>
<p>With the PyPN extension this is very easy, and the required features can even be bound to keyboard shortcuts.</p>
<p><strong>Number Conversions:</strong></p>
<p>The first thing we might want to do is see hex, decimal, octal or even binary representations of a selected number. The following script plus helper functions does this for decimal or hex selections:</p>
<pre class="brush: python;">
import pn, scintilla 

def hex2dec(s):
    &quot;&quot;&quot;return the integer value of a hexadecimal string s&quot;&quot;&quot;
    return int(s, 16) 

def Denary2Binary(n):
    &quot;&quot;&quot;convert denary integer n to binary string bStr&quot;&quot;&quot;
    bStr = ''
    if n &lt; 0:
        raise ValueError, &quot;must be a positive integer&quot;
    if n == 0:
        return '0'
    while n &gt; 0:
        bStr = str(n % 2) + bStr
        n = n &gt;&gt; 1
    return bStr 

@script(&quot;ConvertNumber&quot;)
def ConvertNumber():
    s = scintilla.Scintilla(pn.CurrentDoc())
    if s.SelectionEnd - s.SelectionStart &lt; 1:
        return sel = s.SelText
    if sel.find('0x') != -1:
        sel = sel.replace(&quot;0x&quot;, &quot;&quot;)
        sel = hex2dec(sel)
    else:
        sel = int(sel)
    pn.AddOutput(&quot;Dec: %d\n&quot; % sel)
    pn.AddOutput(&quot;Hex: 0x%X\n&quot; % sel)
    pn.AddOutput(&quot;Oct: %o\n&quot; % sel)
    pn.AddOutput(&quot;Bin: %s&quot; % Denary2Binary(sel))
</pre>
<p>In the next post we&#8217;ll look at evaluating simple math expressions.</p>
]]></content:encoded>
			<wfw:commentRss>http://untidy.net/blog/2007/10/26/programmers-notepad-a-calculator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Build 667 and PyPN 0.5</title>
		<link>http://untidy.net/blog/2007/04/17/build-667-and-pypn-05/</link>
		<comments>http://untidy.net/blog/2007/04/17/build-667-and-pypn-05/#comments</comments>
		<pubDate>Tue, 17 Apr 2007 22:28:26 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Programmer's Notepad]]></category>
		<category><![CDATA[PyPN]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://untidy.net/blog/2007/04/17/build-667-and-pypn-05/</guid>
		<description><![CDATA[A new development build is available on Sourceforge, get it here: Download PN 2.0.7.667 Also: Zip Distribution &#124; Portable Edition Zip This build introduces the global scheme management changes that have been promised for a long time. This means that (where the schemes have been updated already) you can change a single colour and have [...]]]></description>
			<content:encoded><![CDATA[<p>A new development build is available on Sourceforge, get it here:</p>
<p><a href="http://downloads.sourceforge.net/pnotepad/pn207667.exe">Download PN 2.0.7.667</a></p>
<p>Also: <a href="http://downloads.sourceforge.net/pnotepad/pn207667.zip">Zip Distribution</a> | <a href="http://downloads.sourceforge.net/pnotepad/portable-pn207667.zip">Portable Edition Zip</a></p>
<p>This build introduces the global scheme management changes that have been promised for a long time. This means that (where the schemes have been updated already) you can change a single colour and have keywords, numbers, properties and the like&nbsp;use that colour in all schemes. It does need some schemes to be updated to work properly which is ongoing work.</p>
<p><a href="http://untidy.net/blog/wp-content/uploads/2007/04/WindowsLiveWriter/Build667andPyPN0.5_CFAC/globalstyles%5B2%5D.png" atomicselection="true"><img style="border-right: 0px; border-top: 0px; margin: 0px 10px 0px 0px; border-left: 0px; border-bottom: 0px" height="161" alt="Styles Options" src="http://untidy.net/blog/wp-content/uploads/2007/04/WindowsLiveWriter/Build667andPyPN0.5_CFAC/globalstyles_thumb.png" width="240" align="left" border="0"/></a> </p>
<p>The build also finally seperates HTML/PHP schemes from the original Hypertext and adds a PHP Script scheme for pure PHP files (i.e. ones with no &lt;?php?&gt;) in them.</p>
<p>Other changes are of more interest to extension developers. The tagging interface has been removed and a new one created within the standard extensions framework. The ctags tagger is now an extension &#8211; users should notice no difference. </p>
<p>There is&nbsp;a new extension discovery mechanism, simply run PN with the &#8220;&#8211;findexts&#8221; argument and config.xml will be updated with all found extensions.</p>
<p>Finally there are a couple of new extension points in the interface allowing extensions to respond to events when documents are saved and loaded (before and after respectively).</p>
<p><a href="http://downloads.sourceforge.net/pnotepad/pypn-0.5.667.zip">PyPN 0.5</a> has been released at the same time, providing compatibility with the new build along with some minor fixes and support for the new events.</p>
]]></content:encoded>
			<wfw:commentRss>http://untidy.net/blog/2007/04/17/build-667-and-pypn-05/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tabs to Spaces with PyPN</title>
		<link>http://untidy.net/blog/2007/04/10/tabs-to-spaces-with-pypn/</link>
		<comments>http://untidy.net/blog/2007/04/10/tabs-to-spaces-with-pypn/#comments</comments>
		<pubDate>Tue, 10 Apr 2007 12:05:07 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Programmer's Notepad]]></category>
		<category><![CDATA[PyPN]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://untidy.net/blog/2007/04/10/tabs-to-spaces-with-pypn/</guid>
		<description><![CDATA[Want to convert your tabs to spaces and annoyed that your editor author hasn&#8217;t implemented that feature in a handy menu item yet? Add a PyPN script to do it: import pn import scintilla from pypn.decorators import script def SetTarget(e, x, y): e.TargetStart = x e.TargetEnd = y @script("Tabs to Spaces", "Text") def TabsToSpaces(): editor [...]]]></description>
			<content:encoded><![CDATA[<p>Want to convert your tabs to spaces and annoyed that your editor author hasn&#8217;t implemented that feature in a handy menu item yet?</p>
<p>Add a PyPN script to do it:</p>
<pre><code>import pn
import scintilla
from pypn.decorators import script

def SetTarget(e, x, y):
	e.TargetStart = x
	e.TargetEnd = y

@script("Tabs to Spaces", "Text")
def TabsToSpaces():
	editor = scintilla.Scintilla(pn.CurrentDoc())

	tabSpaces = editor.TabWidth
	spaces = ""
	for x in range(tabSpaces):
		spaces = spaces + " "

	end = editor.Length

	SetTarget(editor, 0, end)
	editor.SearchFlags = 0
	editor.BeginUndoAction()

	pos = editor.SearchInTarget(1, "\t")

	while(pos != -1):
		l1 = editor.TargetEnd - editor.TargetStart
		editor.ReplaceTarget(tabSpaces, spaces)

		# adjust doc length
		end = end + tabSpaces - l1
		start = pos + tabSpaces

		if start &gt;= end:
			pos = -1
		else:
			SetTarget(editor, start, end)
			pos = editor.SearchInTarget(1, "\t")

	editor.EndUndoAction()</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://untidy.net/blog/2007/04/10/tabs-to-spaces-with-pypn/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
