mirror of
https://github.com/python/cpython.git
synced 2025-11-02 11:08:57 +00:00
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.
This commit is contained in:
parent
b287b3ad1b
commit
245ddc4b88
1 changed files with 23 additions and 7 deletions
|
|
@ -295,8 +295,12 @@ class EditorWindow:
|
||||||
import pyclbr
|
import pyclbr
|
||||||
if pyclbr._modules.has_key(base):
|
if pyclbr._modules.has_key(base):
|
||||||
del pyclbr._modules[base]
|
del pyclbr._modules[base]
|
||||||
|
save_cursor = self.text["cursor"]
|
||||||
|
self.text["cursor"] = "watch"
|
||||||
|
self.text.update_idletasks()
|
||||||
import ClassBrowser
|
import ClassBrowser
|
||||||
ClassBrowser.ClassBrowser(self.flist, base, [head])
|
ClassBrowser.ClassBrowser(self.flist, base, [head])
|
||||||
|
self.text["cursor"] = save_cursor
|
||||||
|
|
||||||
def gotoline(self, lineno):
|
def gotoline(self, lineno):
|
||||||
if lineno is not None and lineno > 0:
|
if lineno is not None and lineno > 0:
|
||||||
|
|
@ -393,13 +397,25 @@ class EditorWindow:
|
||||||
self.center()
|
self.center()
|
||||||
|
|
||||||
def center(self, mark="insert"):
|
def center(self, mark="insert"):
|
||||||
insert = float(self.text.index(mark + " linestart"))
|
text = self.text
|
||||||
end = float(self.text.index("end"))
|
top, bot = self.getwindowlines()
|
||||||
if insert > end-insert:
|
lineno = self.getlineno(mark)
|
||||||
self.text.see("1.0")
|
height = bot - top
|
||||||
else:
|
newtop = max(1, lineno - height/2)
|
||||||
self.text.see("end")
|
text.yview(float(newtop))
|
||||||
self.text.see(mark)
|
|
||||||
|
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):
|
def close_event(self, event):
|
||||||
self.close()
|
self.close()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue