"C or L Smith" <smi...@worksmail.net> wrote in message news:0bfe194edbb6410cb3b319cdda601...@kisc.edu.np...
The PyWin editor that comes with the Windows distribution is a great little workhorse. If you have used it you perhaps notice how it intelligently works with spaces and indentation, e.g. after typing the word 'pass' and pressing enter it dedents one level as you would probably desire. It also strips trailing space from every line that you enter...unless that line contains ONLY space.

The following modification to the AutoIndent.py file in the pythonwin\pywin\idle directory makes the editor strip all trailing space, even if that's all a line contains. With this modification, no line that you enter with the PyWin editor will ever contain trailing space (unless you purposely add it to the end of a line but then don't press <enter>).

Search for the word "inject" which appears only once in the file and add the line as indicated below:

if i == n:
   # the cursor is in or at leading indentation; just inject
   # an empty line at the start
   text.delete("insert - %d chars" % i, "insert")  <== add this line
   text.insert("insert linestart", '\n')
   return "break"

I like it!  You should post it to pywin32 sourceforge patches.

Here's one I did. I like to clear the interactive window with CTRL-A, DEL before running a script. However, if the script is run its output uses the blue, proportional font that the banner in that window uses when Pythonwin is first opened. This happens whenever the cursor is on the first line of the interactive window. So I would type CTRL-A,DEL, 2xEnter, 4xbackspace to move the cursor to the 2nd line and delete the prompt instead. The diff patch below adds four lines to pythonwin\pywin\framework\interact.py to correct this problem and use the fixed font used for script output.

(Also posted to pywin32 Patches @ http://sourceforge.net/tracker/?func=detail&aid=2813056&group_id=78018&atid=551956).

diff -r 108cdf7a1232 interact.py
--- a/interact.py Fri Jun 26 08:34:29 2009 -0700
+++ b/interact.py Fri Jun 26 08:36:48 2009 -0700
@@ -94,6 +94,7 @@
class InteractiveFormatter(FormatterParent):
 def __init__(self, scintilla):
  FormatterParent.__init__(self, scintilla)
+  self.bannerDisplayed = False

 def SetStyles(self):
  FormatterParent.SetStyles(self)
@@ -233,8 +234,11 @@
  if start > 0:
   stylenum = self.scintilla.SCIGetStyleAt(start - 1)
   styleStart = self.GetStyleByNum(stylenum).name
+  elif self.bannerDisplayed:
+   styleStart = STYLE_INTERACTIVE_EOL
  else:
   styleStart = STYLE_INTERACTIVE_BANNER
+   self.bannerDisplayed = True
  self.scintilla.SCIStartStyling(start, 31)
  self.style_buffer = array.array("b", (0,)*len(stringVal))
  self.ColorizeInteractiveCode(stringVal, styleStart, stylePyStart)

-Mark


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to