[Patches] [ python-Patches-936169 ] CodeContext - an extension to show you where you are

SourceForge.net noreply at sourceforge.net
Thu Apr 22 16:11:47 EDT 2004


Patches item #936169, was opened at 2004-04-16 11:40
Message generated for change (Comment added) made by noamr
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=936169&group_id=5470

Category: IDLE
Group: None
>Status: Open
Resolution: Accepted
Priority: 5
Submitted By: Noam Raphael (noamr)
Assigned to: Kurt B. Kaiser (kbk)
Summary: CodeContext - an extension to show you where you are

Initial Comment:
Have you ever edited a code, and did not know exactly
which block you were closing? Or didn't know exactly
even in which block you were?
This extension solves this problem, by adding a few
lines (3 by default) above the IDLE edit box, which
show you exactly where you are in your code.
For example, you may be editing a code with three
indentation levels (has three tabs on its left), but to
find the reason for this - to find what is the meaning
of your block - you have to scroll upwards a long distance.
CodeContext will add three lines of text above your
edit box, so your editing window will look like this:
----------------------------------
Class MyClass:
    def myMethod(self, arg1, arg2):   <- auto-updated
        if something_happens:
----------------------------------
            i += 1
            print "hello"                       <- You
edit here
            ...
----------------------------------
So you can know that i is incremented by 1, in the
method myMethod of class MyClass, and only if
something_happens.

To make this extension work, you have to put the
attached file, CodeContext.py, in your IDLE directory,
and add these lines to config-extensions.def:
----------------------------------
[CodeContext]
enable=1
numlines=3
bgcolor=LightGray
fgcolor=Black
----------------------------------

A note to KBK: I think this extension can go into the
Python distribution. If you don't like it, or if you
want a testing period, you can put "enable=0" instead
of "enable=1". In this way, most users will not even
know CodeContext exists, but "power users" will be able
to put "enable=1" and have CodeContext if they like it
(- I like it).

Best wishes,
Noam Raphael

----------------------------------------------------------------------

>Comment By: Noam Raphael (noamr)
Date: 2004-04-22 23:11

Message:
Logged In: YES 
user_id=679426

I'm glad you like it!
Thanks for the changes - your English is certainly better
than mine.

A buglet you made - in line 91 you added "elif" as a block
opener which should show the previous block opener of the
same indentation, which is a good idea, but you wrote:
    if opener == "else" or "elif":
which is an expression which always yields True. It caused
all block openers to be displayed, not only the relevant ones.
Change it to
    if opener in ("else", "elif"):
and it will work fine.

Happy Israel Independence Day!
(I know you probably don't celebrate it, but it is on 27
April this year)
Noam

----------------------------------------------------------------------

Comment By: Kurt B. Kaiser (kbk)
Date: 2004-04-21 23:09

Message:
Logged In: YES 
user_id=149084

Cool Extension!  Thanks!

CodeContext.py 1.1
config-extensions.def 1.13

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=936169&group_id=5470



More information about the Patches mailing list