Author: Matti Picus <matti.pi...@gmail.com>
Branch: py3.6
Changeset: r96082:2e2966805114
Date: 2019-02-19 09:40 +0200
http://bitbucket.org/pypy/pypy/changeset/2e2966805114/

Log:    redo 9387f96a5518 in two steps since file case changed (windows ...)

diff too long, truncating to 2000 out of 27878 lines

diff --git a/lib-python/3/idlelib/AutoComplete.py 
b/lib-python/3/idlelib/AutoComplete.py
deleted file mode 100644
--- a/lib-python/3/idlelib/AutoComplete.py
+++ /dev/null
@@ -1,232 +0,0 @@
-"""autocomplete.py - An IDLE extension for automatically completing names.
-
-This extension can complete either attribute names or file names. It can pop
-a window with all available names, for the user to select from.
-"""
-import os
-import string
-import sys
-
-# These constants represent the two different types of completions.
-# They must be defined here so autocomple_w can import them.
-COMPLETE_ATTRIBUTES, COMPLETE_FILES = range(1, 2+1)
-
-from idlelib import autocomplete_w
-from idlelib.config import idleConf
-from idlelib.hyperparser import HyperParser
-import __main__
-
-# This string includes all chars that may be in an identifier.
-# TODO Update this here and elsewhere.
-ID_CHARS = string.ascii_letters + string.digits + "_"
-
-SEPS = os.sep
-if os.altsep:  # e.g. '/' on Windows...
-    SEPS += os.altsep
-
-
-class AutoComplete:
-
-    menudefs = [
-        ('edit', [
-            ("Show Completions", "<<force-open-completions>>"),
-        ])
-    ]
-
-    popupwait = idleConf.GetOption("extensions", "AutoComplete",
-                                   "popupwait", type="int", default=0)
-
-    def __init__(self, editwin=None):
-        self.editwin = editwin
-        if editwin is not None:  # not in subprocess or test
-            self.text = editwin.text
-            self.autocompletewindow = None
-            # id of delayed call, and the index of the text insert when
-            # the delayed call was issued. If _delayed_completion_id is
-            # None, there is no delayed call.
-            self._delayed_completion_id = None
-            self._delayed_completion_index = None
-
-    def _make_autocomplete_window(self):
-        return autocomplete_w.AutoCompleteWindow(self.text)
-
-    def _remove_autocomplete_window(self, event=None):
-        if self.autocompletewindow:
-            self.autocompletewindow.hide_window()
-            self.autocompletewindow = None
-
-    def force_open_completions_event(self, event):
-        """Happens when the user really wants to open a completion list, even
-        if a function call is needed.
-        """
-        self.open_completions(True, False, True)
-
-    def try_open_completions_event(self, event):
-        """Happens when it would be nice to open a completion list, but not
-        really necessary, for example after a dot, so function
-        calls won't be made.
-        """
-        lastchar = self.text.get("insert-1c")
-        if lastchar == ".":
-            self._open_completions_later(False, False, False,
-                                         COMPLETE_ATTRIBUTES)
-        elif lastchar in SEPS:
-            self._open_completions_later(False, False, False,
-                                         COMPLETE_FILES)
-
-    def autocomplete_event(self, event):
-        """Happens when the user wants to complete his word, and if necessary,
-        open a completion list after that (if there is more than one
-        completion)
-        """
-        if hasattr(event, "mc_state") and event.mc_state or\
-                not self.text.get("insert linestart", "insert").strip():
-            # A modifier was pressed along with the tab or
-            # there is only previous whitespace on this line, so tab.
-            return None
-        if self.autocompletewindow and self.autocompletewindow.is_active():
-            self.autocompletewindow.complete()
-            return "break"
-        else:
-            opened = self.open_completions(False, True, True)
-            return "break" if opened else None
-
-    def _open_completions_later(self, *args):
-        self._delayed_completion_index = self.text.index("insert")
-        if self._delayed_completion_id is not None:
-            self.text.after_cancel(self._delayed_completion_id)
-        self._delayed_completion_id = \
-            self.text.after(self.popupwait, self._delayed_open_completions,
-                            *args)
-
-    def _delayed_open_completions(self, *args):
-        self._delayed_completion_id = None
-        if self.text.index("insert") == self._delayed_completion_index:
-            self.open_completions(*args)
-
-    def open_completions(self, evalfuncs, complete, userWantsWin, mode=None):
-        """Find the completions and create the AutoCompleteWindow.
-        Return True if successful (no syntax error or so found).
-        if complete is True, then if there's nothing to complete and no
-        start of completion, won't open completions and return False.
-        If mode is given, will open a completion list only in this mode.
-        """
-        # Cancel another delayed call, if it exists.
-        if self._delayed_completion_id is not None:
-            self.text.after_cancel(self._delayed_completion_id)
-            self._delayed_completion_id = None
-
-        hp = HyperParser(self.editwin, "insert")
-        curline = self.text.get("insert linestart", "insert")
-        i = j = len(curline)
-        if hp.is_in_string() and (not mode or mode==COMPLETE_FILES):
-            # Find the beginning of the string
-            # fetch_completions will look at the file system to determine 
whether the
-            # string value constitutes an actual file name
-            # XXX could consider raw strings here and unescape the string 
value if it's
-            # not raw.
-            self._remove_autocomplete_window()
-            mode = COMPLETE_FILES
-            # Find last separator or string start
-            while i and curline[i-1] not in "'\"" + SEPS:
-                i -= 1
-            comp_start = curline[i:j]
-            j = i
-            # Find string start
-            while i and curline[i-1] not in "'\"":
-                i -= 1
-            comp_what = curline[i:j]
-        elif hp.is_in_code() and (not mode or mode==COMPLETE_ATTRIBUTES):
-            self._remove_autocomplete_window()
-            mode = COMPLETE_ATTRIBUTES
-            while i and (curline[i-1] in ID_CHARS or ord(curline[i-1]) > 127):
-                i -= 1
-            comp_start = curline[i:j]
-            if i and curline[i-1] == '.':
-                hp.set_index("insert-%dc" % (len(curline)-(i-1)))
-                comp_what = hp.get_expression()
-                if not comp_what or \
-                   (not evalfuncs and comp_what.find('(') != -1):
-                    return None
-            else:
-                comp_what = ""
-        else:
-            return None
-
-        if complete and not comp_what and not comp_start:
-            return None
-        comp_lists = self.fetch_completions(comp_what, mode)
-        if not comp_lists[0]:
-            return None
-        self.autocompletewindow = self._make_autocomplete_window()
-        return not self.autocompletewindow.show_window(
-                comp_lists, "insert-%dc" % len(comp_start),
-                complete, mode, userWantsWin)
-
-    def fetch_completions(self, what, mode):
-        """Return a pair of lists of completions for something. The first list
-        is a sublist of the second. Both are sorted.
-
-        If there is a Python subprocess, get the comp. list there.  Otherwise,
-        either fetch_completions() is running in the subprocess itself or it
-        was called in an IDLE EditorWindow before any script had been run.
-
-        The subprocess environment is that of the most recently run script.  If
-        two unrelated modules are being edited some calltips in the current
-        module may be inoperative if the module was not the last to run.
-        """
-        try:
-            rpcclt = self.editwin.flist.pyshell.interp.rpcclt
-        except:
-            rpcclt = None
-        if rpcclt:
-            return rpcclt.remotecall("exec", "get_the_completion_list",
-                                     (what, mode), {})
-        else:
-            if mode == COMPLETE_ATTRIBUTES:
-                if what == "":
-                    namespace = __main__.__dict__.copy()
-                    namespace.update(__main__.__builtins__.__dict__)
-                    bigl = eval("dir()", namespace)
-                    bigl.sort()
-                    if "__all__" in bigl:
-                        smalll = sorted(eval("__all__", namespace))
-                    else:
-                        smalll = [s for s in bigl if s[:1] != '_']
-                else:
-                    try:
-                        entity = self.get_entity(what)
-                        bigl = dir(entity)
-                        bigl.sort()
-                        if "__all__" in bigl:
-                            smalll = sorted(entity.__all__)
-                        else:
-                            smalll = [s for s in bigl if s[:1] != '_']
-                    except:
-                        return [], []
-
-            elif mode == COMPLETE_FILES:
-                if what == "":
-                    what = "."
-                try:
-                    expandedpath = os.path.expanduser(what)
-                    bigl = os.listdir(expandedpath)
-                    bigl.sort()
-                    smalll = [s for s in bigl if s[:1] != '.']
-                except OSError:
-                    return [], []
-
-            if not smalll:
-                smalll = bigl
-            return smalll, bigl
-
-    def get_entity(self, name):
-        """Lookup name in a namespace spanning sys.modules and __main.dict__"""
-        namespace = sys.modules.copy()
-        namespace.update(__main__.__dict__)
-        return eval(name, namespace)
-
-
-if __name__ == '__main__':
-    from unittest import main
-    main('idlelib.idle_test.test_autocomplete', verbosity=2)
diff --git a/lib-python/3/idlelib/AutoCompleteWindow.py 
b/lib-python/3/idlelib/AutoCompleteWindow.py
deleted file mode 100644
--- a/lib-python/3/idlelib/AutoCompleteWindow.py
+++ /dev/null
@@ -1,416 +0,0 @@
-"""
-An auto-completion window for IDLE, used by the AutoComplete extension
-"""
-from tkinter import *
-from idlelib.MultiCall import MC_SHIFT
-from idlelib.AutoComplete import COMPLETE_FILES, COMPLETE_ATTRIBUTES
-
-HIDE_VIRTUAL_EVENT_NAME = "<<autocompletewindow-hide>>"
-HIDE_SEQUENCES = ("<FocusOut>", "<ButtonPress>")
-KEYPRESS_VIRTUAL_EVENT_NAME = "<<autocompletewindow-keypress>>"
-# We need to bind event beyond <Key> so that the function will be called
-# before the default specific IDLE function
-KEYPRESS_SEQUENCES = ("<Key>", "<Key-BackSpace>", "<Key-Return>", "<Key-Tab>",
-                      "<Key-Up>", "<Key-Down>", "<Key-Home>", "<Key-End>",
-                      "<Key-Prior>", "<Key-Next>")
-KEYRELEASE_VIRTUAL_EVENT_NAME = "<<autocompletewindow-keyrelease>>"
-KEYRELEASE_SEQUENCE = "<KeyRelease>"
-LISTUPDATE_SEQUENCE = "<B1-ButtonRelease>"
-WINCONFIG_SEQUENCE = "<Configure>"
-DOUBLECLICK_SEQUENCE = "<B1-Double-ButtonRelease>"
-
-class AutoCompleteWindow:
-
-    def __init__(self, widget):
-        # The widget (Text) on which we place the AutoCompleteWindow
-        self.widget = widget
-        # The widgets we create
-        self.autocompletewindow = self.listbox = self.scrollbar = None
-        # The default foreground and background of a selection. Saved because
-        # they are changed to the regular colors of list items when the
-        # completion start is not a prefix of the selected completion
-        self.origselforeground = self.origselbackground = None
-        # The list of completions
-        self.completions = None
-        # A list with more completions, or None
-        self.morecompletions = None
-        # The completion mode. Either AutoComplete.COMPLETE_ATTRIBUTES or
-        # AutoComplete.COMPLETE_FILES
-        self.mode = None
-        # The current completion start, on the text box (a string)
-        self.start = None
-        # The index of the start of the completion
-        self.startindex = None
-        # The last typed start, used so that when the selection changes,
-        # the new start will be as close as possible to the last typed one.
-        self.lasttypedstart = None
-        # Do we have an indication that the user wants the completion window
-        # (for example, he clicked the list)
-        self.userwantswindow = None
-        # event ids
-        self.hideid = self.keypressid = self.listupdateid = self.winconfigid \
-        = self.keyreleaseid = self.doubleclickid                         = None
-        # Flag set if last keypress was a tab
-        self.lastkey_was_tab = False
-
-    def _change_start(self, newstart):
-        min_len = min(len(self.start), len(newstart))
-        i = 0
-        while i < min_len and self.start[i] == newstart[i]:
-            i += 1
-        if i < len(self.start):
-            self.widget.delete("%s+%dc" % (self.startindex, i),
-                               "%s+%dc" % (self.startindex, len(self.start)))
-        if i < len(newstart):
-            self.widget.insert("%s+%dc" % (self.startindex, i),
-                               newstart[i:])
-        self.start = newstart
-
-    def _binary_search(self, s):
-        """Find the first index in self.completions where completions[i] is
-        greater or equal to s, or the last index if there is no such
-        one."""
-        i = 0; j = len(self.completions)
-        while j > i:
-            m = (i + j) // 2
-            if self.completions[m] >= s:
-                j = m
-            else:
-                i = m + 1
-        return min(i, len(self.completions)-1)
-
-    def _complete_string(self, s):
-        """Assuming that s is the prefix of a string in self.completions,
-        return the longest string which is a prefix of all the strings which
-        s is a prefix of them. If s is not a prefix of a string, return s."""
-        first = self._binary_search(s)
-        if self.completions[first][:len(s)] != s:
-            # There is not even one completion which s is a prefix of.
-            return s
-        # Find the end of the range of completions where s is a prefix of.
-        i = first + 1
-        j = len(self.completions)
-        while j > i:
-            m = (i + j) // 2
-            if self.completions[m][:len(s)] != s:
-                j = m
-            else:
-                i = m + 1
-        last = i-1
-
-        if first == last: # only one possible completion
-            return self.completions[first]
-
-        # We should return the maximum prefix of first and last
-        first_comp = self.completions[first]
-        last_comp = self.completions[last]
-        min_len = min(len(first_comp), len(last_comp))
-        i = len(s)
-        while i < min_len and first_comp[i] == last_comp[i]:
-            i += 1
-        return first_comp[:i]
-
-    def _selection_changed(self):
-        """Should be called when the selection of the Listbox has changed.
-        Updates the Listbox display and calls _change_start."""
-        cursel = int(self.listbox.curselection()[0])
-
-        self.listbox.see(cursel)
-
-        lts = self.lasttypedstart
-        selstart = self.completions[cursel]
-        if self._binary_search(lts) == cursel:
-            newstart = lts
-        else:
-            min_len = min(len(lts), len(selstart))
-            i = 0
-            while i < min_len and lts[i] == selstart[i]:
-                i += 1
-            newstart = selstart[:i]
-        self._change_start(newstart)
-
-        if self.completions[cursel][:len(self.start)] == self.start:
-            # start is a prefix of the selected completion
-            self.listbox.configure(selectbackground=self.origselbackground,
-                                   selectforeground=self.origselforeground)
-        else:
-            self.listbox.configure(selectbackground=self.listbox.cget("bg"),
-                                   selectforeground=self.listbox.cget("fg"))
-            # If there are more completions, show them, and call me again.
-            if self.morecompletions:
-                self.completions = self.morecompletions
-                self.morecompletions = None
-                self.listbox.delete(0, END)
-                for item in self.completions:
-                    self.listbox.insert(END, item)
-                self.listbox.select_set(self._binary_search(self.start))
-                self._selection_changed()
-
-    def show_window(self, comp_lists, index, complete, mode, userWantsWin):
-        """Show the autocomplete list, bind events.
-        If complete is True, complete the text, and if there is exactly one
-        matching completion, don't open a list."""
-        # Handle the start we already have
-        self.completions, self.morecompletions = comp_lists
-        self.mode = mode
-        self.startindex = self.widget.index(index)
-        self.start = self.widget.get(self.startindex, "insert")
-        if complete:
-            completed = self._complete_string(self.start)
-            start = self.start
-            self._change_start(completed)
-            i = self._binary_search(completed)
-            if self.completions[i] == completed and \
-               (i == len(self.completions)-1 or
-                self.completions[i+1][:len(completed)] != completed):
-                # There is exactly one matching completion
-                return completed == start
-        self.userwantswindow = userWantsWin
-        self.lasttypedstart = self.start
-
-        # Put widgets in place
-        self.autocompletewindow = acw = Toplevel(self.widget)
-        # Put it in a position so that it is not seen.
-        acw.wm_geometry("+10000+10000")
-        # Make it float
-        acw.wm_overrideredirect(1)
-        try:
-            # This command is only needed and available on Tk >= 8.4.0 for OSX
-            # Without it, call tips intrude on the typing process by grabbing
-            # the focus.
-            acw.tk.call("::tk::unsupported::MacWindowStyle", "style", acw._w,
-                        "help", "noActivates")
-        except TclError:
-            pass
-        self.scrollbar = scrollbar = Scrollbar(acw, orient=VERTICAL)
-        self.listbox = listbox = Listbox(acw, yscrollcommand=scrollbar.set,
-                                         exportselection=False, bg="white")
-        for item in self.completions:
-            listbox.insert(END, item)
-        self.origselforeground = listbox.cget("selectforeground")
-        self.origselbackground = listbox.cget("selectbackground")
-        scrollbar.config(command=listbox.yview)
-        scrollbar.pack(side=RIGHT, fill=Y)
-        listbox.pack(side=LEFT, fill=BOTH, expand=True)
-        acw.lift()  # work around bug in Tk 8.5.18+ (issue #24570)
-
-        # Initialize the listbox selection
-        self.listbox.select_set(self._binary_search(self.start))
-        self._selection_changed()
-
-        # bind events
-        self.hideid = self.widget.bind(HIDE_VIRTUAL_EVENT_NAME,
-                                       self.hide_event)
-        for seq in HIDE_SEQUENCES:
-            self.widget.event_add(HIDE_VIRTUAL_EVENT_NAME, seq)
-        self.keypressid = self.widget.bind(KEYPRESS_VIRTUAL_EVENT_NAME,
-                                           self.keypress_event)
-        for seq in KEYPRESS_SEQUENCES:
-            self.widget.event_add(KEYPRESS_VIRTUAL_EVENT_NAME, seq)
-        self.keyreleaseid = self.widget.bind(KEYRELEASE_VIRTUAL_EVENT_NAME,
-                                             self.keyrelease_event)
-        
self.widget.event_add(KEYRELEASE_VIRTUAL_EVENT_NAME,KEYRELEASE_SEQUENCE)
-        self.listupdateid = listbox.bind(LISTUPDATE_SEQUENCE,
-                                         self.listselect_event)
-        self.winconfigid = acw.bind(WINCONFIG_SEQUENCE, self.winconfig_event)
-        self.doubleclickid = listbox.bind(DOUBLECLICK_SEQUENCE,
-                                          self.doubleclick_event)
-
-    def winconfig_event(self, event):
-        if not self.is_active():
-            return
-        # Position the completion list window
-        text = self.widget
-        text.see(self.startindex)
-        x, y, cx, cy = text.bbox(self.startindex)
-        acw = self.autocompletewindow
-        acw_width, acw_height = acw.winfo_width(), acw.winfo_height()
-        text_width, text_height = text.winfo_width(), text.winfo_height()
-        new_x = text.winfo_rootx() + min(x, max(0, text_width - acw_width))
-        new_y = text.winfo_rooty() + y
-        if (text_height - (y + cy) >= acw_height # enough height below
-            or y < acw_height): # not enough height above
-            # place acw below current line
-            new_y += cy
-        else:
-            # place acw above current line
-            new_y -= acw_height
-        acw.wm_geometry("+%d+%d" % (new_x, new_y))
-
-    def hide_event(self, event):
-        if not self.is_active():
-            return
-        self.hide_window()
-
-    def listselect_event(self, event):
-        if not self.is_active():
-            return
-        self.userwantswindow = True
-        cursel = int(self.listbox.curselection()[0])
-        self._change_start(self.completions[cursel])
-
-    def doubleclick_event(self, event):
-        # Put the selected completion in the text, and close the list
-        cursel = int(self.listbox.curselection()[0])
-        self._change_start(self.completions[cursel])
-        self.hide_window()
-
-    def keypress_event(self, event):
-        if not self.is_active():
-            return
-        keysym = event.keysym
-        if hasattr(event, "mc_state"):
-            state = event.mc_state
-        else:
-            state = 0
-        if keysym != "Tab":
-            self.lastkey_was_tab = False
-        if (len(keysym) == 1 or keysym in ("underscore", "BackSpace")
-            or (self.mode == COMPLETE_FILES and keysym in
-                ("period", "minus"))) \
-           and not (state & ~MC_SHIFT):
-            # Normal editing of text
-            if len(keysym) == 1:
-                self._change_start(self.start + keysym)
-            elif keysym == "underscore":
-                self._change_start(self.start + '_')
-            elif keysym == "period":
-                self._change_start(self.start + '.')
-            elif keysym == "minus":
-                self._change_start(self.start + '-')
-            else:
-                # keysym == "BackSpace"
-                if len(self.start) == 0:
-                    self.hide_window()
-                    return
-                self._change_start(self.start[:-1])
-            self.lasttypedstart = self.start
-            self.listbox.select_clear(0, int(self.listbox.curselection()[0]))
-            self.listbox.select_set(self._binary_search(self.start))
-            self._selection_changed()
-            return "break"
-
-        elif keysym == "Return":
-            self.hide_window()
-            return
-
-        elif (self.mode == COMPLETE_ATTRIBUTES and keysym in
-              ("period", "space", "parenleft", "parenright", "bracketleft",
-               "bracketright")) or \
-             (self.mode == COMPLETE_FILES and keysym in
-              ("slash", "backslash", "quotedbl", "apostrophe")) \
-             and not (state & ~MC_SHIFT):
-            # If start is a prefix of the selection, but is not '' when
-            # completing file names, put the whole
-            # selected completion. Anyway, close the list.
-            cursel = int(self.listbox.curselection()[0])
-            if self.completions[cursel][:len(self.start)] == self.start \
-               and (self.mode == COMPLETE_ATTRIBUTES or self.start):
-                self._change_start(self.completions[cursel])
-            self.hide_window()
-            return
-
-        elif keysym in ("Home", "End", "Prior", "Next", "Up", "Down") and \
-             not state:
-            # Move the selection in the listbox
-            self.userwantswindow = True
-            cursel = int(self.listbox.curselection()[0])
-            if keysym == "Home":
-                newsel = 0
-            elif keysym == "End":
-                newsel = len(self.completions)-1
-            elif keysym in ("Prior", "Next"):
-                jump = self.listbox.nearest(self.listbox.winfo_height()) - \
-                       self.listbox.nearest(0)
-                if keysym == "Prior":
-                    newsel = max(0, cursel-jump)
-                else:
-                    assert keysym == "Next"
-                    newsel = min(len(self.completions)-1, cursel+jump)
-            elif keysym == "Up":
-                newsel = max(0, cursel-1)
-            else:
-                assert keysym == "Down"
-                newsel = min(len(self.completions)-1, cursel+1)
-            self.listbox.select_clear(cursel)
-            self.listbox.select_set(newsel)
-            self._selection_changed()
-            self._change_start(self.completions[newsel])
-            return "break"
-
-        elif (keysym == "Tab" and not state):
-            if self.lastkey_was_tab:
-                # two tabs in a row; insert current selection and close acw
-                cursel = int(self.listbox.curselection()[0])
-                self._change_start(self.completions[cursel])
-                self.hide_window()
-                return "break"
-            else:
-                # first tab; let AutoComplete handle the completion
-                self.userwantswindow = True
-                self.lastkey_was_tab = True
-                return
-
-        elif any(s in keysym for s in ("Shift", "Control", "Alt",
-                                       "Meta", "Command", "Option")):
-            # A modifier key, so ignore
-            return
-
-        elif event.char and event.char >= ' ':
-            # Regular character with a non-length-1 keycode
-            self._change_start(self.start + event.char)
-            self.lasttypedstart = self.start
-            self.listbox.select_clear(0, int(self.listbox.curselection()[0]))
-            self.listbox.select_set(self._binary_search(self.start))
-            self._selection_changed()
-            return "break"
-
-        else:
-            # Unknown event, close the window and let it through.
-            self.hide_window()
-            return
-
-    def keyrelease_event(self, event):
-        if not self.is_active():
-            return
-        if self.widget.index("insert") != \
-           self.widget.index("%s+%dc" % (self.startindex, len(self.start))):
-            # If we didn't catch an event which moved the insert, close window
-            self.hide_window()
-
-    def is_active(self):
-        return self.autocompletewindow is not None
-
-    def complete(self):
-        self._change_start(self._complete_string(self.start))
-        # The selection doesn't change.
-
-    def hide_window(self):
-        if not self.is_active():
-            return
-
-        # unbind events
-        for seq in HIDE_SEQUENCES:
-            self.widget.event_delete(HIDE_VIRTUAL_EVENT_NAME, seq)
-        self.widget.unbind(HIDE_VIRTUAL_EVENT_NAME, self.hideid)
-        self.hideid = None
-        for seq in KEYPRESS_SEQUENCES:
-            self.widget.event_delete(KEYPRESS_VIRTUAL_EVENT_NAME, seq)
-        self.widget.unbind(KEYPRESS_VIRTUAL_EVENT_NAME, self.keypressid)
-        self.keypressid = None
-        self.widget.event_delete(KEYRELEASE_VIRTUAL_EVENT_NAME,
-                                 KEYRELEASE_SEQUENCE)
-        self.widget.unbind(KEYRELEASE_VIRTUAL_EVENT_NAME, self.keyreleaseid)
-        self.keyreleaseid = None
-        self.listbox.unbind(LISTUPDATE_SEQUENCE, self.listupdateid)
-        self.listupdateid = None
-        self.autocompletewindow.unbind(WINCONFIG_SEQUENCE, self.winconfigid)
-        self.winconfigid = None
-
-        # destroy widgets
-        self.scrollbar.destroy()
-        self.scrollbar = None
-        self.listbox.destroy()
-        self.listbox = None
-        self.autocompletewindow.destroy()
-        self.autocompletewindow = None
diff --git a/lib-python/3/idlelib/AutoExpand.py 
b/lib-python/3/idlelib/AutoExpand.py
deleted file mode 100644
--- a/lib-python/3/idlelib/AutoExpand.py
+++ /dev/null
@@ -1,105 +0,0 @@
-'''Complete the current word before the cursor with words in the editor.
-
-Each menu selection or shortcut key selection replaces the word with a
-different word with the same prefix. The search for matches begins
-before the target and moves toward the top of the editor. It then starts
-after the cursor and moves down. It then returns to the original word and
-the cycle starts again.
-
-Changing the current text line or leaving the cursor in a different
-place before requesting the next selection causes AutoExpand to reset
-its state.
-
-This is an extension file and there is only one instance of AutoExpand.
-'''
-import re
-import string
-
-###$ event <<expand-word>>
-###$ win <Alt-slash>
-###$ unix <Alt-slash>
-
-class AutoExpand:
-
-    menudefs = [
-        ('edit', [
-            ('E_xpand Word', '<<expand-word>>'),
-         ]),
-    ]
-
-    wordchars = string.ascii_letters + string.digits + "_"
-
-    def __init__(self, editwin):
-        self.text = editwin.text
-        self.bell = self.text.bell
-        self.state = None
-
-    def expand_word_event(self, event):
-        "Replace the current word with the next expansion."
-        curinsert = self.text.index("insert")
-        curline = self.text.get("insert linestart", "insert lineend")
-        if not self.state:
-            words = self.getwords()
-            index = 0
-        else:
-            words, index, insert, line = self.state
-            if insert != curinsert or line != curline:
-                words = self.getwords()
-                index = 0
-        if not words:
-            self.bell()
-            return "break"
-        word = self.getprevword()
-        self.text.delete("insert - %d chars" % len(word), "insert")
-        newword = words[index]
-        index = (index + 1) % len(words)
-        if index == 0:
-            self.bell()            # Warn we cycled around
-        self.text.insert("insert", newword)
-        curinsert = self.text.index("insert")
-        curline = self.text.get("insert linestart", "insert lineend")
-        self.state = words, index, curinsert, curline
-        return "break"
-
-    def getwords(self):
-        "Return a list of words that match the prefix before the cursor."
-        word = self.getprevword()
-        if not word:
-            return []
-        before = self.text.get("1.0", "insert wordstart")
-        wbefore = re.findall(r"\b" + word + r"\w+\b", before)
-        del before
-        after = self.text.get("insert wordend", "end")
-        wafter = re.findall(r"\b" + word + r"\w+\b", after)
-        del after
-        if not wbefore and not wafter:
-            return []
-        words = []
-        dict = {}
-        # search backwards through words before
-        wbefore.reverse()
-        for w in wbefore:
-            if dict.get(w):
-                continue
-            words.append(w)
-            dict[w] = w
-        # search onwards through words after
-        for w in wafter:
-            if dict.get(w):
-                continue
-            words.append(w)
-            dict[w] = w
-        words.append(word)
-        return words
-
-    def getprevword(self):
-        "Return the word prefix before the cursor."
-        line = self.text.get("insert linestart", "insert")
-        i = len(line)
-        while i > 0 and line[i-1] in self.wordchars:
-            i = i-1
-        return line[i:]
-
-if __name__ == '__main__':
-    import unittest
-    unittest.main('idlelib.idle_test.test_autoexpand', verbosity=2)
diff --git a/lib-python/3/idlelib/Bindings.py b/lib-python/3/idlelib/Bindings.py
deleted file mode 100644
--- a/lib-python/3/idlelib/Bindings.py
+++ /dev/null
@@ -1,96 +0,0 @@
-"""Define the menu contents, hotkeys, and event bindings.
-
-There is additional configuration information in the EditorWindow class (and
-subclasses): the menus are created there based on the menu_specs (class)
-variable, and menus not created are silently skipped in the code here.  This
-makes it possible, for example, to define a Debug menu which is only present in
-the PythonShell window, and a Format menu which is only present in the Editor
-windows.
-
-"""
-from importlib.util import find_spec
-
-from idlelib.configHandler import idleConf
-
-#   Warning: menudefs is altered in macosxSupport.overrideRootMenu()
-#   after it is determined that an OS X Aqua Tk is in use,
-#   which cannot be done until after Tk() is first called.
-#   Do not alter the 'file', 'options', or 'help' cascades here
-#   without altering overrideRootMenu() as well.
-#       TODO: Make this more robust
-
-menudefs = [
- # underscore prefixes character to underscore
- ('file', [
-   ('_New File', '<<open-new-window>>'),
-   ('_Open...', '<<open-window-from-file>>'),
-   ('Open _Module...', '<<open-module>>'),
-   ('Class _Browser', '<<open-class-browser>>'),
-   ('_Path Browser', '<<open-path-browser>>'),
-   None,
-   ('_Save', '<<save-window>>'),
-   ('Save _As...', '<<save-window-as-file>>'),
-   ('Save Cop_y As...', '<<save-copy-of-window-as-file>>'),
-   None,
-   ('Prin_t Window', '<<print-window>>'),
-   None,
-   ('_Close', '<<close-window>>'),
-   ('E_xit', '<<close-all-windows>>'),
-  ]),
- ('edit', [
-   ('_Undo', '<<undo>>'),
-   ('_Redo', '<<redo>>'),
-   None,
-   ('Cu_t', '<<cut>>'),
-   ('_Copy', '<<copy>>'),
-   ('_Paste', '<<paste>>'),
-   ('Select _All', '<<select-all>>'),
-   None,
-   ('_Find...', '<<find>>'),
-   ('Find A_gain', '<<find-again>>'),
-   ('Find _Selection', '<<find-selection>>'),
-   ('Find in Files...', '<<find-in-files>>'),
-   ('R_eplace...', '<<replace>>'),
-   ('Go to _Line', '<<goto-line>>'),
-  ]),
-('format', [
-   ('_Indent Region', '<<indent-region>>'),
-   ('_Dedent Region', '<<dedent-region>>'),
-   ('Comment _Out Region', '<<comment-region>>'),
-   ('U_ncomment Region', '<<uncomment-region>>'),
-   ('Tabify Region', '<<tabify-region>>'),
-   ('Untabify Region', '<<untabify-region>>'),
-   ('Toggle Tabs', '<<toggle-tabs>>'),
-   ('New Indent Width', '<<change-indentwidth>>'),
-   ]),
- ('run', [
-   ('Python Shell', '<<open-python-shell>>'),
-   ]),
- ('shell', [
-   ('_View Last Restart', '<<view-restart>>'),
-   ('_Restart Shell', '<<restart-shell>>'),
-   None,
-   ('_Interrupt Execution', '<<interrupt-execution>>'),
-   ]),
- ('debug', [
-   ('_Go to File/Line', '<<goto-file-line>>'),
-   ('!_Debugger', '<<toggle-debugger>>'),
-   ('_Stack Viewer', '<<open-stack-viewer>>'),
-   ('!_Auto-open Stack Viewer', '<<toggle-jit-stack-viewer>>'),
-   ]),
- ('options', [
-   ('Configure _IDLE', '<<open-config-dialog>>'),
-   None,
-   ]),
- ('help', [
-   ('_About IDLE', '<<about-idle>>'),
-   None,
-   ('_IDLE Help', '<<help>>'),
-   ('Python _Docs', '<<python-docs>>'),
-   ]),
-]
-
-if find_spec('turtledemo'):
-    menudefs[-1][1].append(('Turtle Demo', '<<open-turtle-demo>>'))
-
-default_keydefs = idleConf.GetCurrentKeySet()
diff --git a/lib-python/3/idlelib/CallTipWindow.py 
b/lib-python/3/idlelib/CallTipWindow.py
deleted file mode 100644
--- a/lib-python/3/idlelib/CallTipWindow.py
+++ /dev/null
@@ -1,161 +0,0 @@
-"""A CallTip window class for Tkinter/IDLE.
-
-After ToolTip.py, which uses ideas gleaned from PySol
-Used by the CallTips IDLE extension.
-"""
-from tkinter import Toplevel, Label, LEFT, SOLID, TclError
-
-HIDE_VIRTUAL_EVENT_NAME = "<<calltipwindow-hide>>"
-HIDE_SEQUENCES = ("<Key-Escape>", "<FocusOut>")
-CHECKHIDE_VIRTUAL_EVENT_NAME = "<<calltipwindow-checkhide>>"
-CHECKHIDE_SEQUENCES = ("<KeyRelease>", "<ButtonRelease>")
-CHECKHIDE_TIME = 100 # milliseconds
-
-MARK_RIGHT = "calltipwindowregion_right"
-
-class CallTip:
-
-    def __init__(self, widget):
-        self.widget = widget
-        self.tipwindow = self.label = None
-        self.parenline = self.parencol = None
-        self.lastline = None
-        self.hideid = self.checkhideid = None
-        self.checkhide_after_id = None
-
-    def position_window(self):
-        """Check if needs to reposition the window, and if so - do it."""
-        curline = int(self.widget.index("insert").split('.')[0])
-        if curline == self.lastline:
-            return
-        self.lastline = curline
-        self.widget.see("insert")
-        if curline == self.parenline:
-            box = self.widget.bbox("%d.%d" % (self.parenline,
-                                              self.parencol))
-        else:
-            box = self.widget.bbox("%d.0" % curline)
-        if not box:
-            box = list(self.widget.bbox("insert"))
-            # align to left of window
-            box[0] = 0
-            box[2] = 0
-        x = box[0] + self.widget.winfo_rootx() + 2
-        y = box[1] + box[3] + self.widget.winfo_rooty()
-        self.tipwindow.wm_geometry("+%d+%d" % (x, y))
-
-    def showtip(self, text, parenleft, parenright):
-        """Show the calltip, bind events which will close it and reposition it.
-        """
-        # Only called in CallTips, where lines are truncated
-        self.text = text
-        if self.tipwindow or not self.text:
-            return
-
-        self.widget.mark_set(MARK_RIGHT, parenright)
-        self.parenline, self.parencol = map(
-            int, self.widget.index(parenleft).split("."))
-
-        self.tipwindow = tw = Toplevel(self.widget)
-        self.position_window()
-        # remove border on calltip window
-        tw.wm_overrideredirect(1)
-        try:
-            # This command is only needed and available on Tk >= 8.4.0 for OSX
-            # Without it, call tips intrude on the typing process by grabbing
-            # the focus.
-            tw.tk.call("::tk::unsupported::MacWindowStyle", "style", tw._w,
-                       "help", "noActivates")
-        except TclError:
-            pass
-        self.label = Label(tw, text=self.text, justify=LEFT,
-                           background="#ffffe0", relief=SOLID, borderwidth=1,
-                           font = self.widget['font'])
-        self.label.pack()
-        tw.lift()  # work around bug in Tk 8.5.18+ (issue #24570)
-
-        self.checkhideid = self.widget.bind(CHECKHIDE_VIRTUAL_EVENT_NAME,
-                                            self.checkhide_event)
-        for seq in CHECKHIDE_SEQUENCES:
-            self.widget.event_add(CHECKHIDE_VIRTUAL_EVENT_NAME, seq)
-        self.widget.after(CHECKHIDE_TIME, self.checkhide_event)
-        self.hideid = self.widget.bind(HIDE_VIRTUAL_EVENT_NAME,
-                                       self.hide_event)
-        for seq in HIDE_SEQUENCES:
-            self.widget.event_add(HIDE_VIRTUAL_EVENT_NAME, seq)
-
-    def checkhide_event(self, event=None):
-        if not self.tipwindow:
-            # If the event was triggered by the same event that unbinded
-            # this function, the function will be called nevertheless,
-            # so do nothing in this case.
-            return
-        curline, curcol = map(int, self.widget.index("insert").split('.'))
-        if curline < self.parenline or \
-           (curline == self.parenline and curcol <= self.parencol) or \
-           self.widget.compare("insert", ">", MARK_RIGHT):
-            self.hidetip()
-        else:
-            self.position_window()
-            if self.checkhide_after_id is not None:
-                self.widget.after_cancel(self.checkhide_after_id)
-            self.checkhide_after_id = \
-                self.widget.after(CHECKHIDE_TIME, self.checkhide_event)
-
-    def hide_event(self, event):
-        if not self.tipwindow:
-            # See the explanation in checkhide_event.
-            return
-        self.hidetip()
-
-    def hidetip(self):
-        if not self.tipwindow:
-            return
-
-        for seq in CHECKHIDE_SEQUENCES:
-            self.widget.event_delete(CHECKHIDE_VIRTUAL_EVENT_NAME, seq)
-        self.widget.unbind(CHECKHIDE_VIRTUAL_EVENT_NAME, self.checkhideid)
-        self.checkhideid = None
-        for seq in HIDE_SEQUENCES:
-            self.widget.event_delete(HIDE_VIRTUAL_EVENT_NAME, seq)
-        self.widget.unbind(HIDE_VIRTUAL_EVENT_NAME, self.hideid)
-        self.hideid = None
-
-        self.label.destroy()
-        self.label = None
-        self.tipwindow.destroy()
-        self.tipwindow = None
-
-        self.widget.mark_unset(MARK_RIGHT)
-        self.parenline = self.parencol = self.lastline = None
-
-    def is_active(self):
-        return bool(self.tipwindow)
-
-
-def _calltip_window(parent):  # htest #
-    from tkinter import Toplevel, Text, LEFT, BOTH
-
-    top = Toplevel(parent)
-    top.title("Test calltips")
-    top.geometry("200x100+%d+%d" % (parent.winfo_rootx() + 200,
-                  parent.winfo_rooty() + 150))
-    text = Text(top)
-    text.pack(side=LEFT, fill=BOTH, expand=1)
-    text.insert("insert", "string.split")
-    top.update()
-    calltip = CallTip(text)
-
-    def calltip_show(event):
-        calltip.showtip("(s=Hello world)", "insert", "end")
-    def calltip_hide(event):
-        calltip.hidetip()
-    text.event_add("<<calltip-show>>", "(")
-    text.event_add("<<calltip-hide>>", ")")
-    text.bind("<<calltip-show>>", calltip_show)
-    text.bind("<<calltip-hide>>", calltip_hide)
-    text.focus_set()
-
-if __name__=='__main__':
-    from idlelib.idle_test.htest import run
-    run(_calltip_window)
diff --git a/lib-python/3/idlelib/CallTips.py b/lib-python/3/idlelib/CallTips.py
deleted file mode 100644
--- a/lib-python/3/idlelib/CallTips.py
+++ /dev/null
@@ -1,185 +0,0 @@
-"""calltips.py - An IDLE Extension to Jog Your Memory
-
-Call Tips are floating windows which display function, class, and method
-parameter and docstring information when you type an opening parenthesis, and
-which disappear when you type a closing parenthesis.
-
-"""
-import inspect
-import re
-import sys
-import textwrap
-import types
-
-from idlelib import calltip_w
-from idlelib.hyperparser import HyperParser
-import __main__
-
-class CallTips:
-
-    menudefs = [
-        ('edit', [
-            ("Show call tip", "<<force-open-calltip>>"),
-        ])
-    ]
-
-    def __init__(self, editwin=None):
-        if editwin is None:  # subprocess and test
-            self.editwin = None
-        else:
-            self.editwin = editwin
-            self.text = editwin.text
-            self.active_calltip = None
-            self._calltip_window = self._make_tk_calltip_window
-
-    def close(self):
-        self._calltip_window = None
-
-    def _make_tk_calltip_window(self):
-        # See __init__ for usage
-        return calltip_w.CallTip(self.text)
-
-    def _remove_calltip_window(self, event=None):
-        if self.active_calltip:
-            self.active_calltip.hidetip()
-            self.active_calltip = None
-
-    def force_open_calltip_event(self, event):
-        "The user selected the menu entry or hotkey, open the tip."
-        self.open_calltip(True)
-
-    def try_open_calltip_event(self, event):
-        """Happens when it would be nice to open a CallTip, but not really
-        necessary, for example after an opening bracket, so function calls
-        won't be made.
-        """
-        self.open_calltip(False)
-
-    def refresh_calltip_event(self, event):
-        if self.active_calltip and self.active_calltip.is_active():
-            self.open_calltip(False)
-
-    def open_calltip(self, evalfuncs):
-        self._remove_calltip_window()
-
-        hp = HyperParser(self.editwin, "insert")
-        sur_paren = hp.get_surrounding_brackets('(')
-        if not sur_paren:
-            return
-        hp.set_index(sur_paren[0])
-        expression  = hp.get_expression()
-        if not expression:
-            return
-        if not evalfuncs and (expression.find('(') != -1):
-            return
-        argspec = self.fetch_tip(expression)
-        if not argspec:
-            return
-        self.active_calltip = self._calltip_window()
-        self.active_calltip.showtip(argspec, sur_paren[0], sur_paren[1])
-
-    def fetch_tip(self, expression):
-        """Return the argument list and docstring of a function or class.
-
-        If there is a Python subprocess, get the calltip there.  Otherwise,
-        either this fetch_tip() is running in the subprocess or it was
-        called in an IDLE running without the subprocess.
-
-        The subprocess environment is that of the most recently run script.  If
-        two unrelated modules are being edited some calltips in the current
-        module may be inoperative if the module was not the last to run.
-
-        To find methods, fetch_tip must be fed a fully qualified name.
-
-        """
-        try:
-            rpcclt = self.editwin.flist.pyshell.interp.rpcclt
-        except AttributeError:
-            rpcclt = None
-        if rpcclt:
-            return rpcclt.remotecall("exec", "get_the_calltip",
-                                     (expression,), {})
-        else:
-            return get_argspec(get_entity(expression))
-
-def get_entity(expression):
-    """Return the object corresponding to expression evaluated
-    in a namespace spanning sys.modules and __main.dict__.
-    """
-    if expression:
-        namespace = sys.modules.copy()
-        namespace.update(__main__.__dict__)
-        try:
-            return eval(expression, namespace)
-        except BaseException:
-            # An uncaught exception closes idle, and eval can raise any
-            # exception, especially if user classes are involved.
-            return None
-
-# The following are used in get_argspec and some in tests
-_MAX_COLS = 85
-_MAX_LINES = 5  # enough for bytes
-_INDENT = ' '*4  # for wrapped signatures
-_first_param = re.compile(r'(?<=\()\w*\,?\s*')
-_default_callable_argspec = "See source or doc"
-
-def _is_user_method(ob):
-    """Detect user methods on PyPy"""
-    return (isinstance(ob, types.MethodType) and
-        isinstance(ob.__code__, types.CodeType))
-
-def _is_user_function(ob):
-    """Detect user methods on PyPy"""
-    return (isinstance(ob, types.FunctionType) and
-        isinstance(ob.__code__, types.CodeType))
-
-def get_argspec(ob):
-    '''Return a string describing the signature of a callable object, or ''.
-
-    For Python-coded functions and methods, the first line is introspected.
-    Delete 'self' parameter for classes (.__init__) and bound methods.
-    The next lines are the first lines of the doc string up to the first
-    empty line or _MAX_LINES.    For builtins, this typically includes
-    the arguments in addition to the return value.
-    '''
-    argspec = ""
-    try:
-        ob_call = ob.__call__
-    except BaseException:
-        return argspec
-    if isinstance(ob, type):
-        fob = ob.__init__
-    elif _is_user_method(ob_call):
-        fob = ob_call
-    else:
-        fob = ob
-    if (isinstance(fob, (types.FunctionType, types.MethodType)) and
-            hasattr(fob.__code__, 'co_code')):  # PyPy: not on <builtin-code>
-        argspec = inspect.formatargspec(*inspect.getfullargspec(fob))
-        if (_is_user_method(ob) or _is_user_method(ob_call) or
-                (isinstance(ob, type) and _is_user_function(fob))):
-            argspec = _first_param.sub("", argspec)
-
-    lines = (textwrap.wrap(argspec, _MAX_COLS, subsequent_indent=_INDENT)
-            if len(argspec) > _MAX_COLS else [argspec] if argspec else [])
-
-    if _is_user_method(ob_call):
-        doc = ob_call.__doc__
-    else:
-        doc = getattr(ob, "__doc__", "")
-    if doc:
-        for line in doc.split('\n', _MAX_LINES)[:_MAX_LINES]:
-            line = line.strip()
-            if not line:
-                break
-            if len(line) > _MAX_COLS:
-                line = line[: _MAX_COLS - 3] + '...'
-            lines.append(line)
-        argspec = '\n'.join(lines)
-    if not argspec:
-        argspec = _default_callable_argspec
-    return argspec
-
-if __name__ == '__main__':
-    from unittest import main
-    main('idlelib.idle_test.test_calltips', verbosity=2)
diff --git a/lib-python/3/idlelib/ChangeLog b/lib-python/3/idlelib/ChangeLog
--- a/lib-python/3/idlelib/ChangeLog
+++ b/lib-python/3/idlelib/ChangeLog
@@ -27,9 +27,9 @@
 
        * INSTALLATION, setup.py: INSTALLATION: Remove the coexist.patch
        instructions
-       
+
        **************** setup.py:
-       
+
        Remove the idles script, add some words on IDLE Fork to the
        long_description, and clean up some line spacing.
 
@@ -42,30 +42,30 @@
        * PyShell.py, idle, idles: Implement idle command interface as
        suggested by GvR [idle-dev] 16 July **************** PyShell: Added
        functionality:
-       
+
        usage: idle.py [-c command] [-d] [-i] [-r script] [-s] [-t title]
        [arg] ...
-       
+
        idle file(s)    (without options) edit the file(s)
-       
+
        -c cmd     run the command in a shell -d         enable the
        debugger -i         open an interactive shell -i file(s) open a
        shell and also an editor window for each file -r script  run a file
        as a script in a shell -s         run $IDLESTARTUP or
        $PYTHONSTARTUP before anything else -t title   set title of shell
        window
-       
+
        Remaining arguments are applied to the command (-c) or script (-r).
-       
+
        ****************** idles: Removed the idles script, not needed
-       
+
        ****************** idle:  Removed the IdleConf references, not
        required anymore
 
 2001-07-16 17:08  kbk
 
        * INSTALLATION, coexist.patch: Added installation instructions.
-       
+
        Added a patch which modifies idlefork so that it can co-exist with
        "official" IDLE in the site-packages directory. This patch is not
        necessary if only idlefork IDLE is installed. See INSTALLATION for
@@ -74,7 +74,7 @@
 2001-07-16 15:50  kbk
 
        * idles: Add a script "idles" which opens a Python Shell window.
-       
+
        The default behaviour of idlefork idle is to open an editor window
        instead of a shell. Complex expressions may be run in a fresh
        environment by selecting "run".  There are times, however, when a
@@ -90,7 +90,7 @@
 
        * PyShell.py, setup.py: Add a script "idles" which opens a Python
        Shell window.
-       
+
        The default behaviour of idlefork idle is to open an editor window
        instead of a shell. Complex expressions may be run in a fresh
        environment by selecting "run".  There are times, however, when a
@@ -110,13 +110,13 @@
 
        * setup.py: Installing Idle to site-packages via Distutils does not
        copy the Idle help.txt file.
-       
+
        Ref SF Python Patch 422471
 
 2001-07-14 15:26  kbk
 
        * keydefs.py: py-cvs-2001_07_13 (Rev 1.3) merge
-       
+
        "Make copy, cut and paste events case insensitive.  Reported by
        Patrick K. O'Brien on idle-dev. (Should other bindings follow
        suit?)" --GvR
@@ -124,7 +124,7 @@
 2001-07-14 15:21  kbk
 
        * idle.py: py-cvs-2001_07_13 (Rev 1.4) merge
-       
+
        "Move the action of loading the configuration to the IdleConf
        module rather than the idle.py script.  This has advantages and
        disadvantages; the biggest advantage being that we can more easily
@@ -133,21 +133,21 @@
 2001-07-14 15:18  kbk
 
        * extend.txt: py-cvs-2001_07_13 (Rev 1.4) merge
-       
+
        "Quick update to the extension mechanism (extend.py is gone, long
        live config.txt)" --GvR
 
 2001-07-14 15:15  kbk
 
        * StackViewer.py: py-cvs-2001_07_13 (Rev 1.16) merge
-       
+
        "Refactored, with some future plans in mind. This now uses the new
        gotofileline() method defined in FileList.py"  --GvR
 
 2001-07-14 15:10  kbk
 
        * PyShell.py: py-cvs-2001_07_13 (Rev 1.34) merge
-       
+
        "Amazing.  A very subtle change in policy in descr-branch actually
        found a bug here.  Here's the deal: Class PyShell derives from
        class OutputWindow.  Method PyShell.close() wants to invoke its
@@ -166,19 +166,19 @@
 2001-07-14 14:59  kbk
 
        * PyParse.py: py-cvs-2001_07_13 (Rel 1.9) merge
-       
+
        "Taught IDLE's autoident parser that "yield" is a keyword that
        begins a stmt.  Along w/ the preceding change to keyword.py, making
        all this work w/ a future-stmt just looks harder and harder."
        --tim_one
-       
+
        (From Rel 1.8: "Hack to make this still work with Python 1.5.2.
        ;-( " --fdrake)
 
 2001-07-14 14:51  kbk
 
        * IdleConf.py: py-cvs-2001_07_13 (Rel 1.7) merge
-       
+
        "Move the action of loading the configuration to the IdleConf
        module rather than the idle.py script.  This has advantages and
        disadvantages; the biggest advantage being that we can more easily
@@ -187,11 +187,11 @@
 2001-07-14 14:45  kbk
 
        * FileList.py: py-cvs-2000_07_13 (Rev 1.9) merge
-       
+
        "Delete goodname() method, which is unused. Add gotofileline(), a
        convenience method which I intend to use in a variant. Rename
        test() to _test()."  --GvR
-       
+
        This was an interesting merge. The join completely missed removing
        goodname(), which was adjacent, but outside of, a small conflict.
        I only caught it by comparing the 1.1.3.2/1.1.3.3 diff.  CVS ain't
@@ -245,13 +245,13 @@
 2001-07-14 10:13  kbk
 
        * PyShell.py: cvs-py-rel2_1 (Rev 1.29 - 1.33) merge
-       
+
        Merged the following py-cvs revs without conflict: 1.29 Reduce
        copyright text output at startup 1.30 Delay setting sys.args until
        Tkinter is fully initialized 1.31 Whitespace normalization 1.32
        Turn syntax warning into error when interactive 1.33 Fix warning
        initialization bug
-       
+
        Note that module is extensively modified wrt py-cvs
 
 2001-07-14 06:33  kbk
@@ -317,14 +317,14 @@
 2001-07-13 13:35  kbk
 
        * EditorWindow.py: py-cvs-rel2_1 (Rev 1.33 - 1.37) merge
-       
+
        VP IDLE version depended on VP's ExecBinding.py and spawn.py to get
        the path to the Windows Doc directory (relative to python.exe).
        Removed this conflicting code in favor of py-cvs updates which on
        Windows use a hard coded path relative to the location of this
        module. py-cvs updates include support for webbrowser.py.  Module
        still has BrowserControl.py for 1.5.2 support.
-       
+
        At this point, the differences wrt py-cvs relate to menu
        functionality.
 
@@ -1194,7 +1194,7 @@
 ======================================================================
        Python release 1.5.2b2, IDLE version 0.3
 ======================================================================
-       
+
 Wed Feb 17 22:47:41 1999  Guido van Rossum  <gu...@cnri.reston.va.us>
 
        * NEWS.txt: News in 0.3.
@@ -1330,7 +1330,7 @@
 ======================================================================
        Python release 1.5.2b1, IDLE version 0.2
 ======================================================================
-       
+
 Fri Jan  8 17:26:02 1999  Guido van Rossum  <gu...@cnri.reston.va.us>
 
        * README.txt, NEWS.txt: What's new in this release.
diff --git a/lib-python/3/idlelib/ClassBrowser.py 
b/lib-python/3/idlelib/ClassBrowser.py
deleted file mode 100644
--- a/lib-python/3/idlelib/ClassBrowser.py
+++ /dev/null
@@ -1,236 +0,0 @@
-"""Class browser.
-
-XXX TO DO:
-
-- reparse when source changed (maybe just a button would be OK?)
-    (or recheck on window popup)
-- add popup menu with more options (e.g. doc strings, base classes, imports)
-- show function argument list? (have to do pattern matching on source)
-- should the classes and methods lists also be in the module's menu bar?
-- add base classes to class browser tree
-"""
-
-import os
-import sys
-import pyclbr
-
-from idlelib import PyShell
-from idlelib.WindowList import ListedToplevel
-from idlelib.TreeWidget import TreeNode, TreeItem, ScrolledCanvas
-from idlelib.configHandler import idleConf
-
-file_open = None  # Method...Item and Class...Item use this.
-# Normally PyShell.flist.open, but there is no PyShell.flist for htest.
-
-class ClassBrowser:
-
-    def __init__(self, flist, name, path, _htest=False):
-        # XXX This API should change, if the file doesn't end in ".py"
-        # XXX the code here is bogus!
-        """
-        _htest - bool, change box when location running htest.
-        """
-        global file_open
-        if not _htest:
-            file_open = PyShell.flist.open
-        self.name = name
-        self.file = os.path.join(path[0], self.name + ".py")
-        self._htest = _htest
-        self.init(flist)
-
-    def close(self, event=None):
-        self.top.destroy()
-        self.node.destroy()
-
-    def init(self, flist):
-        self.flist = flist
-        # reset pyclbr
-        pyclbr._modules.clear()
-        # create top
-        self.top = top = ListedToplevel(flist.root)
-        top.protocol("WM_DELETE_WINDOW", self.close)
-        top.bind("<Escape>", self.close)
-        if self._htest: # place dialog below parent if running htest
-            top.geometry("+%d+%d" %
-                (flist.root.winfo_rootx(), flist.root.winfo_rooty() + 200))
-        self.settitle()
-        top.focus_set()
-        # create scrolled canvas
-        theme = idleConf.CurrentTheme()
-        background = idleConf.GetHighlight(theme, 'normal')['background']
-        sc = ScrolledCanvas(top, bg=background, highlightthickness=0, 
takefocus=1)
-        sc.frame.pack(expand=1, fill="both")
-        item = self.rootnode()
-        self.node = node = TreeNode(sc.canvas, None, item)
-        node.update()
-        node.expand()
-
-    def settitle(self):
-        self.top.wm_title("Class Browser - " + self.name)
-        self.top.wm_iconname("Class Browser")
-
-    def rootnode(self):
-        return ModuleBrowserTreeItem(self.file)
-
-class ModuleBrowserTreeItem(TreeItem):
-
-    def __init__(self, file):
-        self.file = file
-
-    def GetText(self):
-        return os.path.basename(self.file)
-
-    def GetIconName(self):
-        return "python"
-
-    def GetSubList(self):
-        sublist = []
-        for name in self.listclasses():
-            item = ClassBrowserTreeItem(name, self.classes, self.file)
-            sublist.append(item)
-        return sublist
-
-    def OnDoubleClick(self):
-        if os.path.normcase(self.file[-3:]) != ".py":
-            return
-        if not os.path.exists(self.file):
-            return
-        PyShell.flist.open(self.file)
-
-    def IsExpandable(self):
-        return os.path.normcase(self.file[-3:]) == ".py"
-
-    def listclasses(self):
-        dir, file = os.path.split(self.file)
-        name, ext = os.path.splitext(file)
-        if os.path.normcase(ext) != ".py":
-            return []
-        try:
-            dict = pyclbr.readmodule_ex(name, [dir] + sys.path)
-        except ImportError:
-            return []
-        items = []
-        self.classes = {}
-        for key, cl in dict.items():
-            if cl.module == name:
-                s = key
-                if hasattr(cl, 'super') and cl.super:
-                    supers = []
-                    for sup in cl.super:
-                        if type(sup) is type(''):
-                            sname = sup
-                        else:
-                            sname = sup.name
-                            if sup.module != cl.module:
-                                sname = "%s.%s" % (sup.module, sname)
-                        supers.append(sname)
-                    s = s + "(%s)" % ", ".join(supers)
-                items.append((cl.lineno, s))
-                self.classes[s] = cl
-        items.sort()
-        list = []
-        for item, s in items:
-            list.append(s)
-        return list
-
-class ClassBrowserTreeItem(TreeItem):
-
-    def __init__(self, name, classes, file):
-        self.name = name
-        self.classes = classes
-        self.file = file
-        try:
-            self.cl = self.classes[self.name]
-        except (IndexError, KeyError):
-            self.cl = None
-        self.isfunction = isinstance(self.cl, pyclbr.Function)
-
-    def GetText(self):
-        if self.isfunction:
-            return "def " + self.name + "(...)"
-        else:
-            return "class " + self.name
-
-    def GetIconName(self):
-        if self.isfunction:
-            return "python"
-        else:
-            return "folder"
-
-    def IsExpandable(self):
-        if self.cl:
-            try:
-                return not not self.cl.methods
-            except AttributeError:
-                return False
-
-    def GetSubList(self):
-        if not self.cl:
-            return []
-        sublist = []
-        for name in self.listmethods():
-            item = MethodBrowserTreeItem(name, self.cl, self.file)
-            sublist.append(item)
-        return sublist
-
-    def OnDoubleClick(self):
-        if not os.path.exists(self.file):
-            return
-        edit = file_open(self.file)
-        if hasattr(self.cl, 'lineno'):
-            lineno = self.cl.lineno
-            edit.gotoline(lineno)
-
-    def listmethods(self):
-        if not self.cl:
-            return []
-        items = []
-        for name, lineno in self.cl.methods.items():
-            items.append((lineno, name))
-        items.sort()
-        list = []
-        for item, name in items:
-            list.append(name)
-        return list
-
-class MethodBrowserTreeItem(TreeItem):
-
-    def __init__(self, name, cl, file):
-        self.name = name
-        self.cl = cl
-        self.file = file
-
-    def GetText(self):
-        return "def " + self.name + "(...)"
-
-    def GetIconName(self):
-        return "python" # XXX
-
-    def IsExpandable(self):
-        return 0
-
-    def OnDoubleClick(self):
-        if not os.path.exists(self.file):
-            return
-        edit = file_open(self.file)
-        edit.gotoline(self.cl.methods[self.name])
-
-def _class_browser(parent): #Wrapper for htest
-    try:
-        file = __file__
-    except NameError:
-        file = sys.argv[0]
-        if sys.argv[1:]:
-            file = sys.argv[1]
-        else:
-            file = sys.argv[0]
-    dir, file = os.path.split(file)
-    name = os.path.splitext(file)[0]
-    flist = PyShell.PyShellFileList(parent)
-    global file_open
-    file_open = flist.open
-    ClassBrowser(flist, name, [dir], _htest=True)
-
-if __name__ == "__main__":
-    from idlelib.idle_test.htest import run
-    run(_class_browser)
diff --git a/lib-python/3/idlelib/CodeContext.py 
b/lib-python/3/idlelib/CodeContext.py
deleted file mode 100644
--- a/lib-python/3/idlelib/CodeContext.py
+++ /dev/null
@@ -1,178 +0,0 @@
-"""codecontext - Extension to display the block context above the edit window
-
-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
-variable in the codecontext section of config-extensions.def. Lines which do
-not open blocks are not shown in the context hints pane.
-
-"""
-import re
-from sys import maxsize as INFINITY
-
-import tkinter
-from tkinter.constants import TOP, LEFT, X, W, SUNKEN
-
-from idlelib.config import idleConf
-
-BLOCKOPENERS = {"class", "def", "elif", "else", "except", "finally", "for",
-                    "if", "try", "while", "with"}
-UPDATEINTERVAL = 100 # millisec
-FONTUPDATEINTERVAL = 1000 # millisec
-
-getspacesfirstword =\
-                   lambda s, c=re.compile(r"^(\s*)(\w*)"): c.match(s).groups()
-
-class CodeContext:
-    menudefs = [('options', [('!Code Conte_xt', '<<toggle-code-context>>')])]
-    context_depth = idleConf.GetOption("extensions", "CodeContext",
-                                       "numlines", type="int", default=3)
-    bgcolor = idleConf.GetOption("extensions", "CodeContext",
-                                 "bgcolor", type="str", default="LightGray")
-    fgcolor = idleConf.GetOption("extensions", "CodeContext",
-                                 "fgcolor", type="str", default="Black")
-    def __init__(self, editwin):
-        self.editwin = editwin
-        self.text = editwin.text
-        self.textfont = self.text["font"]
-        self.label = None
-        # self.info is a list of (line number, indent level, line text, block
-        # keyword) tuples providing the block structure associated with
-        # self.topvisible (the linenumber of the line displayed at the top of
-        # the edit window). self.info[0] is initialized as a 'dummy' line which
-        # starts the toplevel 'block' of the module.
-        self.info = [(0, -1, "", False)]
-        self.topvisible = 1
-        visible = idleConf.GetOption("extensions", "CodeContext",
-                                     "visible", type="bool", default=False)
-        if visible:
-            self.toggle_code_context_event()
-            self.editwin.setvar('<<toggle-code-context>>', True)
-        # Start two update cycles, one for context lines, one for font changes.
-        self.text.after(UPDATEINTERVAL, self.timer_event)
-        self.text.after(FONTUPDATEINTERVAL, self.font_timer_event)
-
-    def toggle_code_context_event(self, event=None):
-        if not self.label:
-            # Calculate the border width and horizontal padding required to
-            # align the context with the text in the main Text widget.
-            #
-            # All values are passed through getint(), since some
-            # values may be pixel objects, which can't simply be added to ints.
-            widgets = self.editwin.text, self.editwin.text_frame
-            # Calculate the required vertical padding
-            padx = 0
-            for widget in widgets:
-                padx += widget.tk.getint(widget.pack_info()['padx'])
-                padx += widget.tk.getint(widget.cget('padx'))
-            # Calculate the required border width
-            border = 0
-            for widget in widgets:
-                border += widget.tk.getint(widget.cget('border'))
-            self.label = tkinter.Label(self.editwin.top,
-                                       text="\n" * (self.context_depth - 1),
-                                       anchor=W, justify=LEFT,
-                                       font=self.textfont,
-                                       bg=self.bgcolor, fg=self.fgcolor,
-                                       width=1, #don't request more than we get
-                                       padx=padx, border=border,
-                                       relief=SUNKEN)
-            # Pack the label widget before and above the text_frame widget,
-            # thus ensuring that it will appear directly above text_frame
-            self.label.pack(side=TOP, fill=X, expand=False,
-                            before=self.editwin.text_frame)
-        else:
-            self.label.destroy()
-            self.label = None
-        idleConf.SetOption("extensions", "CodeContext", "visible",
-                           str(self.label is not None))
-        idleConf.SaveUserCfgFiles()
-
-    def get_line_info(self, linenum):
-        """Get the line indent value, text, and any block start keyword
-
-        If the line does not start a block, the keyword value is False.
-        The indentation of empty lines (or comment lines) is INFINITY.
-
-        """
-        text = self.text.get("%d.0" % linenum, "%d.end" % linenum)
-        spaces, firstword = getspacesfirstword(text)
-        opener = firstword in BLOCKOPENERS and firstword
-        if len(text) == len(spaces) or text[len(spaces)] == '#':
-            indent = INFINITY
-        else:
-            indent = len(spaces)
-        return indent, text, opener
-
-    def get_context(self, new_topvisible, stopline=1, stopindent=0):
-        """Get context lines, starting at new_topvisible and working backwards.
-
-        Stop when stopline or stopindent is reached. Return a tuple of context
-        data and the indent level at the top of the region inspected.
-
-        """
-        assert stopline > 0
-        lines = []
-        # The indentation level we are currently in:
-        lastindent = INFINITY
-        # For a line to be interesting, it must begin with a block opening
-        # keyword, and have less indentation than lastindent.
-        for linenum in range(new_topvisible, stopline-1, -1):
-            indent, text, opener = self.get_line_info(linenum)
-            if indent < lastindent:
-                lastindent = indent
-                if opener in ("else", "elif"):
-                    # We also show the if statement
-                    lastindent += 1
-                if opener and linenum < new_topvisible and indent >= 
stopindent:
-                    lines.append((linenum, indent, text, opener))
-                if lastindent <= stopindent:
-                    break
-        lines.reverse()
-        return lines, lastindent
-
-    def update_code_context(self):
-        """Update context information and lines visible in the context pane.
-
-        """
-        new_topvisible = int(self.text.index("@0,0").split('.')[0])
-        if self.topvisible == new_topvisible:      # haven't scrolled
-            return
-        if self.topvisible < new_topvisible:       # scroll down
-            lines, lastindent = self.get_context(new_topvisible,
-                                                 self.topvisible)
-            # retain only context info applicable to the region
-            # between topvisible and new_topvisible:
-            while self.info[-1][1] >= lastindent:
-                del self.info[-1]
-        elif self.topvisible > new_topvisible:     # scroll up
-            stopindent = self.info[-1][1] + 1
-            # retain only context info associated
-            # with lines above new_topvisible:
-            while self.info[-1][0] >= new_topvisible:
-                stopindent = self.info[-1][1]
-                del self.info[-1]
-            lines, lastindent = self.get_context(new_topvisible,
-                                                 self.info[-1][0]+1,
-                                                 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)
-
-    def timer_event(self):
-        if self.label:
-            self.update_code_context()
-        self.text.after(UPDATEINTERVAL, self.timer_event)
-
-    def font_timer_event(self):
-        newtextfont = self.text["font"]
-        if self.label and newtextfont != self.textfont:
-            self.textfont = newtextfont
-            self.label["font"] = self.textfont
-        self.text.after(FONTUPDATEINTERVAL, self.font_timer_event)
diff --git a/lib-python/3/idlelib/ColorDelegator.py 
b/lib-python/3/idlelib/ColorDelegator.py
deleted file mode 100644
--- a/lib-python/3/idlelib/ColorDelegator.py
+++ /dev/null
@@ -1,281 +0,0 @@
-import time
-import re
-import keyword
-import builtins
-from tkinter import TkVersion
-from idlelib.Delegator import Delegator
-from idlelib.configHandler import idleConf
-
-DEBUG = False
-
-def any(name, alternates):
-    "Return a named group pattern matching list of alternates."
-    return "(?P<%s>" % name + "|".join(alternates) + ")"
-
-def make_pat():
-    kw = r"\b" + any("KEYWORD", keyword.kwlist) + r"\b"
-    builtinlist = [str(name) for name in dir(builtins)
-                                        if not name.startswith('_') and \
-                                        name not in keyword.kwlist]
-    # self.file = open("file") :
-    # 1st 'file' colorized normal, 2nd as builtin, 3rd as string
-    builtin = r"([^.'\"\\#]\b|^)" + any("BUILTIN", builtinlist) + r"\b"
-    comment = any("COMMENT", [r"#[^\n]*"])
-    stringprefix = r"(\br|u|ur|R|U|UR|Ur|uR|b|B|br|Br|bR|BR|rb|rB|Rb|RB)?"
-    sqstring = stringprefix + r"'[^'\\\n]*(\\.[^'\\\n]*)*'?"
-    dqstring = stringprefix + r'"[^"\\\n]*(\\.[^"\\\n]*)*"?'
-    sq3string = stringprefix + r"'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?"
-    dq3string = stringprefix + r'"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?'
-    string = any("STRING", [sq3string, dq3string, sqstring, dqstring])
-    return kw + "|" + builtin + "|" + comment + "|" + string +\
-           "|" + any("SYNC", [r"\n"])
-
-prog = re.compile(make_pat(), re.S)
-idprog = re.compile(r"\s+(\w+)", re.S)
-
-def color_config(text):  # Called from htest, Editor, and Turtle Demo.
-    '''Set color opitons of Text widget.
-
-    Should be called whenever ColorDelegator is called.
-    '''
-    # Not automatic because ColorDelegator does not know 'text'.
-    theme = idleConf.CurrentTheme()
-    normal_colors = idleConf.GetHighlight(theme, 'normal')
-    cursor_color = idleConf.GetHighlight(theme, 'cursor', fgBg='fg')
-    select_colors = idleConf.GetHighlight(theme, 'hilite')
-    text.config(
-        foreground=normal_colors['foreground'],
-        background=normal_colors['background'],
-        insertbackground=cursor_color,
-        selectforeground=select_colors['foreground'],
-        selectbackground=select_colors['background'],
-        )
-    if TkVersion >= 8.5:
-        text.config(
-            inactiveselectbackground=select_colors['background'])
-
-
-class ColorDelegator(Delegator):
-
-    def __init__(self):
-        Delegator.__init__(self)
-        self.prog = prog
-        self.idprog = idprog
-        self.LoadTagDefs()
-
-    def setdelegate(self, delegate):
-        if self.delegate is not None:
-            self.unbind("<<toggle-auto-coloring>>")
-        Delegator.setdelegate(self, delegate)
-        if delegate is not None:
-            self.config_colors()
-            self.bind("<<toggle-auto-coloring>>", self.toggle_colorize_event)
-            self.notify_range("1.0", "end")
-        else:
-            # No delegate - stop any colorizing
-            self.stop_colorizing = True
-            self.allow_colorizing = False
-
-    def config_colors(self):
-        for tag, cnf in self.tagdefs.items():
-            if cnf:
-                self.tag_configure(tag, **cnf)
-        self.tag_raise('sel')
-
-    def LoadTagDefs(self):
-        theme = idleConf.CurrentTheme()
-        self.tagdefs = {
-            "COMMENT": idleConf.GetHighlight(theme, "comment"),
-            "KEYWORD": idleConf.GetHighlight(theme, "keyword"),
-            "BUILTIN": idleConf.GetHighlight(theme, "builtin"),
-            "STRING": idleConf.GetHighlight(theme, "string"),
-            "DEFINITION": idleConf.GetHighlight(theme, "definition"),
-            "SYNC": {'background':None,'foreground':None},
-            "TODO": {'background':None,'foreground':None},
-            "ERROR": idleConf.GetHighlight(theme, "error"),
-            # The following is used by ReplaceDialog:
-            "hit": idleConf.GetHighlight(theme, "hit"),
-            }
-
-        if DEBUG: print('tagdefs',self.tagdefs)
-
-    def insert(self, index, chars, tags=None):
-        index = self.index(index)
-        self.delegate.insert(index, chars, tags)
-        self.notify_range(index, index + "+%dc" % len(chars))
-
-    def delete(self, index1, index2=None):
-        index1 = self.index(index1)
-        self.delegate.delete(index1, index2)
-        self.notify_range(index1)
-
-    after_id = None
-    allow_colorizing = True
-    colorizing = False
-
-    def notify_range(self, index1, index2=None):
-        self.tag_add("TODO", index1, index2)
-        if self.after_id:
-            if DEBUG: print("colorizing already scheduled")
-            return
-        if self.colorizing:
-            self.stop_colorizing = True
-            if DEBUG: print("stop colorizing")
-        if self.allow_colorizing:
-            if DEBUG: print("schedule colorizing")
-            self.after_id = self.after(1, self.recolorize)
-
-    close_when_done = None # Window to be closed when done colorizing
-
-    def close(self, close_when_done=None):
-        if self.after_id:
-            after_id = self.after_id
-            self.after_id = None
-            if DEBUG: print("cancel scheduled recolorizer")
-            self.after_cancel(after_id)
-        self.allow_colorizing = False
-        self.stop_colorizing = True
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to