Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions Lib/idlelib/__main__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
"""
IDLE main entry point

Run IDLE as python -m idlelib
"""
# IDLE main entry point
# Run IDLE as python -m idlelib
import idlelib.pyshell
idlelib.pyshell.main()
41 changes: 20 additions & 21 deletions Lib/idlelib/autocomplete.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Complete either attribute names or file names.
# Complete either attribute names or file names.

# Either on demand or after a user-selected delay after a key character,
# pop up a list of candidates.

Either on demand or after a user-selected delay after a key character,
pop up a list of candidates.
"""
import __main__
import keyword
import os
Expand Down Expand Up @@ -93,18 +93,17 @@ def try_open_completions_event(self, event=None):
self.popupwait, self._delayed_open_completions, args)

def _delayed_open_completions(self, args):
"Call open_completions if index unchanged."
# Call open_completions if index unchanged.
self._delayed_completion_id = None
if self.text.index("insert") == self._delayed_completion_index:
self.open_completions(args)

def open_completions(self, args):
"""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.
"""
# 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.

evalfuncs, complete, wantwin, mode = args
# Cancel another delayed call, if it exists.
if self._delayed_completion_id is not None:
Expand All @@ -115,11 +114,13 @@ def open_completions(self, args):
curline = self.text.get("insert linestart", "insert")
i = j = len(curline)
if hp.is_in_string() and (not mode or mode==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 = FILES
# Find last separator or string start
Expand Down Expand Up @@ -159,17 +160,16 @@ def open_completions(self, args):
complete, mode, wantwin)

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.
# 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.
# 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.
"""
# 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:
Expand Down Expand Up @@ -220,7 +220,6 @@ def get_entity(self, name):
"Lookup name in a namespace spanning sys.modules and __main.dict__."
return eval(name, {**sys.modules, **__main__.__dict__})


AutoComplete.reload()

if __name__ == '__main__':
Expand Down
29 changes: 12 additions & 17 deletions Lib/idlelib/autocomplete_w.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
An auto-completion window for IDLE, used by the autocomplete extension
"""
# An auto-completion window for IDLE, used by the autocomplete extension
import platform

from tkinter import *
Expand Down Expand Up @@ -76,9 +74,8 @@ def _change_start(self, newstart):
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.
"""
# 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.

i = 0; j = len(self.completions)
while j > i:
m = (i + j) // 2
Expand All @@ -89,10 +86,10 @@ def _binary_search(self, s):
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.
"""
# 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.
Expand Down Expand Up @@ -121,10 +118,8 @@ def _complete_string(self, s):
return first_comp[:i]

def _selection_changed(self):
"""Call when the selection of the Listbox has changed.
# Call when the selection of the Listbox has changed.Updates the Listbox display and calls _change_start.

Updates the Listbox display and calls _change_start.
"""
cursel = int(self.listbox.curselection()[0])

self.listbox.see(cursel)
Expand Down Expand Up @@ -159,11 +154,11 @@ def _selection_changed(self):
self._selection_changed()

def show_window(self, comp_lists, index, complete, mode, userWantsWin):
"""Show the autocomplete list, bind events.
# 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.

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
Expand Down
13 changes: 6 additions & 7 deletions Lib/idlelib/browser.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""Module browser.
#Module browser.

XXX TO DO:
# 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)
- add base classes to class browser tree
"""
# - 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)
# - add base classes to class browser tree

import os
import pyclbr
Expand Down
16 changes: 7 additions & 9 deletions Lib/idlelib/config_key.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""
Dialog for building Tkinter accelerator key bindings
"""
# Dialog for building Tkinter accelerator key bindings

from tkinter import Toplevel, Listbox, StringVar, TclError
from tkinter.ttk import Frame, Button, Checkbutton, Entry, Label, Scrollbar
from tkinter import messagebox
Expand Down Expand Up @@ -167,13 +166,12 @@ def create_widgets(self):
self.toggle_level()

def set_modifiers_for_platform(self):
"""Determine list of names of key modifiers for this platform.
# Determine list of names of key modifiers for this platform.
# The names are used to build Tk bindings -- it doesn't matter if the
# keyboard has these keys; it matters if Tk understands them. The
# order is also important: key binding equality depends on it, so
# config-keys.def must use the same ordering.

The names are used to build Tk bindings -- it doesn't matter if the
keyboard has these keys; it matters if Tk understands them. The
order is also important: key binding equality depends on it, so
config-keys.def must use the same ordering.
"""
if sys.platform == "darwin":
self.modifiers = ['Shift', 'Control', 'Option', 'Command']
else:
Expand Down
Loading
Loading