diff options
author | Guido van Rossum <guido@python.org> | 1999-01-11 14:51:32 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1999-01-11 14:51:32 (GMT) |
commit | 245ddc4b88dffbe066ee222e0722faa6d6107fab (patch) | |
tree | aca16866c41facfa5f7e17278f82f90db7da0c0e /Tools | |
parent | b287b3ad1bd8c82e03240cbb466f51a7b9c244a6 (diff) | |
download | cpython-245ddc4b88dffbe066ee222e0722faa6d6107fab.zip cpython-245ddc4b88dffbe066ee222e0722faa6d6107fab.tar.gz cpython-245ddc4b88dffbe066ee222e0722faa6d6107fab.tar.bz2 |
Set the cursor to a watch when opening the class browser (which may
take quite a while, browsing multiple files).
Newer, better center() -- but assumes no wrapping.
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/idle/EditorWindow.py | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/Tools/idle/EditorWindow.py b/Tools/idle/EditorWindow.py index ead0e8a..8c0ba00 100644 --- a/Tools/idle/EditorWindow.py +++ b/Tools/idle/EditorWindow.py @@ -295,8 +295,12 @@ class EditorWindow: import pyclbr if pyclbr._modules.has_key(base): del pyclbr._modules[base] + save_cursor = self.text["cursor"] + self.text["cursor"] = "watch" + self.text.update_idletasks() import ClassBrowser ClassBrowser.ClassBrowser(self.flist, base, [head]) + self.text["cursor"] = save_cursor def gotoline(self, lineno): if lineno is not None and lineno > 0: @@ -393,13 +397,25 @@ class EditorWindow: self.center() def center(self, mark="insert"): - insert = float(self.text.index(mark + " linestart")) - end = float(self.text.index("end")) - if insert > end-insert: - self.text.see("1.0") - else: - self.text.see("end") - self.text.see(mark) + text = self.text + top, bot = self.getwindowlines() + lineno = self.getlineno(mark) + height = bot - top + newtop = max(1, lineno - height/2) + text.yview(float(newtop)) + + def getwindowlines(self): + text = self.text + top = self.getlineno("@0,0") + bot = self.getlineno("@0,65535") + if top == bot: + height = int(text['height']) + bot = top + height - 1 + return top, bot + + def getlineno(self, mark="insert"): + text = self.text + return int(float(text.index(mark))) def close_event(self, event): self.close() |