summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/codecontext.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/idlelib/codecontext.py')
-rw-r--r--Lib/idlelib/codecontext.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/Lib/idlelib/codecontext.py b/Lib/idlelib/codecontext.py
index 635f68c..b061f3b 100644
--- a/Lib/idlelib/codecontext.py
+++ b/Lib/idlelib/codecontext.py
@@ -4,7 +4,7 @@ Once code has scrolled off the top of a window, it can be difficult to
determine which block you are in. This extension implements a pane at the top
of each IDLE edit window which provides block structure hints. These hints are
the lines which contain the block opening keywords, e.g. 'if', for the
-enclosing block. The number of hint lines is determined by the numlines
+enclosing block. The number of hint lines is determined by the maxlines
variable in the codecontext section of config-extensions.def. Lines which do
not open blocks are not shown in the context hints pane.
@@ -80,7 +80,7 @@ class CodeContext:
def reload(cls):
"Load class variables from config."
cls.context_depth = idleConf.GetOption("extensions", "CodeContext",
- "numlines", type="int", default=3)
+ "maxlines", type="int", default=15)
## cls.bgcolor = idleConf.GetOption("extensions", "CodeContext",
## "bgcolor", type="str", default="LightGray")
## cls.fgcolor = idleConf.GetOption("extensions", "CodeContext",
@@ -116,7 +116,7 @@ class CodeContext:
padx += widget.tk.getint(widget.cget('padx'))
border += widget.tk.getint(widget.cget('border'))
self.label = tkinter.Label(
- self.editwin.top, text="\n" * (self.context_depth - 1),
+ self.editwin.top, text="",
anchor=W, justify=LEFT, font=self.textfont,
bg=self.bgcolor, fg=self.fgcolor,
width=1, # Don't request more than we get.
@@ -191,11 +191,10 @@ class CodeContext:
stopindent)
self.info.extend(lines)
self.topvisible = new_topvisible
- # Empty lines in context pane.
- context_strings = [""] * max(0, self.context_depth - len(self.info))
- # Followed by the context hint lines.
- context_strings += [x[2] for x in self.info[-self.context_depth:]]
- self.label["text"] = '\n'.join(context_strings)
+ # Last context_depth context lines.
+ context_strings = [x[2] for x in self.info[-self.context_depth:]]
+ showfirst = 0 if context_strings[0] else 1
+ self.label["text"] = '\n'.join(context_strings[showfirst:])
def timer_event(self):
"Event on editor text widget triggered every UPDATEINTERVAL ms."