mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
Checking in IDLE 0.2.
Much has changed -- too much, in fact, to write down. The big news is that there's a standard way to write IDLE extensions; see extend.txt. Some sample extensions have been provided, and some existing code has been converted to extensions. Probably the biggest new user feature is a new search dialog with more options, search and replace, and even search in files (grep). This is exactly as downloaded from my laptop after returning from the holidays -- it hasn't even been tested on Unix yet.
This commit is contained in:
parent
f07c328c07
commit
504b0bf066
38 changed files with 2204 additions and 899 deletions
|
|
@ -2,125 +2,59 @@ import os
|
|||
from Tkinter import *
|
||||
import tkMessageBox
|
||||
|
||||
from EditorWindow import EditorWindow, fixwordbreaks
|
||||
from IOBinding import IOBinding
|
||||
import WindowList
|
||||
|
||||
#$ event <<open-new-window>>
|
||||
#$ win <Control-n>
|
||||
#$ unix <Control-x><Control-n>
|
||||
|
||||
class MultiIOBinding(IOBinding):
|
||||
|
||||
def open(self, event):
|
||||
filename = self.askopenfile()
|
||||
if filename:
|
||||
self.flist.open(filename, self.edit)
|
||||
return "break"
|
||||
|
||||
|
||||
class MultiEditorWindow(EditorWindow):
|
||||
|
||||
IOBinding = MultiIOBinding
|
||||
|
||||
# Override menu bar specs
|
||||
menu_specs = EditorWindow.menu_specs[:]
|
||||
menu_specs.insert(len(menu_specs)-1, ("windows", "_Windows"))
|
||||
|
||||
def __init__(self, flist, filename, key):
|
||||
self.flist = flist
|
||||
flist.inversedict[self] = key
|
||||
if key:
|
||||
flist.dict[key] = self
|
||||
EditorWindow.__init__(self, flist.root, filename)
|
||||
self.io.flist = flist
|
||||
self.io.edit = self
|
||||
self.text.bind("<<open-new-window>>", self.flist.new_callback)
|
||||
self.text.bind("<<close-all-windows>>", self.flist.close_all_callback)
|
||||
self.text.bind("<<open-class-browser>>", self.open_class_browser)
|
||||
|
||||
def close_hook(self):
|
||||
self.flist.close_edit(self)
|
||||
|
||||
def filename_change_hook(self):
|
||||
self.flist.filename_changed_edit(self)
|
||||
EditorWindow.filename_change_hook(self)
|
||||
|
||||
def wakeup(self):
|
||||
self.top.tkraise()
|
||||
self.top.wm_deiconify()
|
||||
self.text.focus_set()
|
||||
|
||||
def createmenubar(self):
|
||||
EditorWindow.createmenubar(self)
|
||||
self.menudict['windows'].configure(postcommand=self.postwindowsmenu)
|
||||
|
||||
def postwindowsmenu(self):
|
||||
wmenu = self.menudict['windows']
|
||||
wmenu.delete(0, 'end')
|
||||
self.fixedwindowsmenu(wmenu)
|
||||
files = self.flist.dict.keys()
|
||||
files.sort()
|
||||
for file in files:
|
||||
def openit(self=self, file=file):
|
||||
self.flist.open(file)
|
||||
wmenu.add_command(label=file, command=openit)
|
||||
|
||||
def open_class_browser(self, event=None):
|
||||
filename = self.io.filename
|
||||
if not filename:
|
||||
tkMessageBox.showerror(
|
||||
"No filename",
|
||||
"This buffer has no associated filename",
|
||||
master=self.text)
|
||||
return None
|
||||
head, tail = os.path.split(filename)
|
||||
base, ext = os.path.splitext(tail)
|
||||
import pyclbr
|
||||
if pyclbr._modules.has_key(base):
|
||||
del pyclbr._modules[base]
|
||||
import ClassBrowser
|
||||
ClassBrowser.ClassBrowser(self.flist, base, [head])
|
||||
|
||||
# (This is labeled as 'Exit'in the File menu)
|
||||
#$ event <<close-all-windows>>
|
||||
#$ win <Control-q>
|
||||
#$ unix <Control-x><Control-c>
|
||||
|
||||
class FileList:
|
||||
|
||||
EditorWindow = MultiEditorWindow
|
||||
|
||||
|
||||
from EditorWindow import EditorWindow
|
||||
EditorWindow.Toplevel = WindowList.ListedToplevel # XXX Patch it!
|
||||
|
||||
def __init__(self, root):
|
||||
self.root = root
|
||||
self.dict = {}
|
||||
self.inversedict = {}
|
||||
|
||||
def new(self):
|
||||
return self.open(None)
|
||||
|
||||
def open(self, filename, edit=None):
|
||||
if filename:
|
||||
def goodname(self, filename):
|
||||
filename = self.canonize(filename)
|
||||
if os.path.isdir(filename):
|
||||
tkMessageBox.showerror(
|
||||
"Is A Directory",
|
||||
"The path %s is a directory." % `filename`,
|
||||
master=self.root)
|
||||
return None
|
||||
key = os.path.normcase(filename)
|
||||
if self.dict.has_key(key):
|
||||
edit = self.dict[key]
|
||||
edit.wakeup()
|
||||
return edit
|
||||
if not os.path.exists(filename):
|
||||
tkMessageBox.showinfo(
|
||||
"New File",
|
||||
"Opening non-existent file %s" % `filename`,
|
||||
master=self.root)
|
||||
if edit and not edit.io.filename and edit.undo.get_saved():
|
||||
# Reuse existing Untitled window for new file
|
||||
edit.io.loadfile(filename)
|
||||
self.dict[key] = edit
|
||||
self.inversedict[edit] = key
|
||||
edit.wakeup()
|
||||
return edit
|
||||
else:
|
||||
key = None
|
||||
edit = self.EditorWindow(self, filename, key)
|
||||
return edit
|
||||
filename = edit.io.filename or filename
|
||||
return filename
|
||||
|
||||
def open(self, filename):
|
||||
assert filename
|
||||
filename = self.canonize(filename)
|
||||
if os.path.isdir(filename):
|
||||
tkMessageBox.showerror(
|
||||
"Is A Directory",
|
||||
"The path %s is a directory." % `filename`,
|
||||
master=self.root)
|
||||
return None
|
||||
key = os.path.normcase(filename)
|
||||
if self.dict.has_key(key):
|
||||
edit = self.dict[key]
|
||||
edit.wakeup()
|
||||
return edit
|
||||
if not os.path.exists(filename):
|
||||
tkMessageBox.showinfo(
|
||||
"New File",
|
||||
"Opening non-existent file %s" % `filename`,
|
||||
master=self.root)
|
||||
return self.EditorWindow(self, filename, key)
|
||||
|
||||
def new(self):
|
||||
return self.EditorWindow(self)
|
||||
|
||||
def new_callback(self, event):
|
||||
self.new()
|
||||
|
|
@ -189,6 +123,7 @@ class FileList:
|
|||
|
||||
|
||||
def test():
|
||||
from EditorWindow import fixwordbreaks
|
||||
import sys
|
||||
root = Tk()
|
||||
fixwordbreaks(root)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue