/
opt
/
alt
/
python36
/
lib64
/
python3.6
/
idlelib
/
/opt/alt/python36/lib64/python3.6/idlelib
mkdir
upload
Name
Size
Mode
Actions
Icons/
-
0755
rm
idle_test/
-
0755
rm
__pycache__/
-
0755
rm
autocomplete.py
9324
0644
edit
dl
rm
autocomplete_w.py
19829
0644
edit
dl
rm
autoexpand.py
3216
0644
edit
dl
rm
browser.py
8281
0644
edit
dl
rm
calltip.py
6067
0644
edit
dl
rm
calltip_w.py
7111
0644
edit
dl
rm
ChangeLog
56360
0644
edit
dl
rm
codecontext.py
10490
0644
edit
dl
rm
colorizer.py
11275
0644
edit
dl
rm
config-extensions.def
2266
0644
edit
dl
rm
config-highlight.def
2687
0644
edit
dl
rm
config-keys.def
10775
0644
edit
dl
rm
config-main.def
3128
0644
edit
dl
rm
config.py
38878
0644
edit
dl
rm
configdialog.py
101057
0644
edit
dl
rm
config_key.py
13408
0644
edit
dl
rm
CREDITS.txt
1866
0644
edit
dl
rm
debugger.py
19097
0644
edit
dl
rm
debugger_r.py
12140
0644
edit
dl
rm
debugobj.py
4055
0644
edit
dl
rm
debugobj_r.py
1082
0644
edit
dl
rm
delegator.py
1043
0644
edit
dl
rm
dynoption.py
2017
0644
edit
dl
rm
editor.py
67275
0644
edit
dl
rm
extend.txt
3642
0644
edit
dl
rm
filelist.py
3896
0644
edit
dl
rm
grep.py
6742
0644
edit
dl
rm
help.html
55114
0644
edit
dl
rm
help.py
11325
0644
edit
dl
rm
help_about.py
8981
0644
edit
dl
rm
history.py
4043
0644
edit
dl
rm
HISTORY.txt
10312
0644
edit
dl
rm
hyperparser.py
12882
0644
edit
dl
rm
idle.py
454
0644
edit
dl
rm
idle.pyw
570
0644
edit
dl
rm
iomenu.py
20734
0644
edit
dl
rm
macosx.py
9660
0644
edit
dl
rm
mainmenu.py
3703
0644
edit
dl
rm
multicall.py
18648
0644
edit
dl
rm
NEWS.txt
39839
0644
edit
dl
rm
NEWS2x.txt
27172
0644
edit
dl
rm
outwin.py
5808
0644
edit
dl
rm
paragraph.py
7167
0644
edit
dl
rm
parenmatch.py
7204
0644
edit
dl
rm
pathbrowser.py
3193
0644
edit
dl
rm
percolator.py
3130
0644
edit
dl
rm
pyparse.py
20118
0644
edit
dl
rm
pyshell.py
57728
0755
edit
dl
rm
query.py
12434
0644
edit
dl
rm
README.txt
9592
0644
edit
dl
rm
redirector.py
6875
0644
edit
dl
rm
replace.py
7502
0644
edit
dl
rm
rpc.py
21137
0644
edit
dl
rm
rstrip.py
868
0644
edit
dl
rm
run.py
17272
0644
edit
dl
rm
runscript.py
7841
0644
edit
dl
rm
scrolledlist.py
4458
0644
edit
dl
rm
search.py
3164
0644
edit
dl
rm
searchbase.py
7451
0644
edit
dl
rm
searchengine.py
7472
0644
edit
dl
rm
squeezer.py
13308
0644
edit
dl
rm
stackviewer.py
4454
0644
edit
dl
rm
statusbar.py
1441
0644
edit
dl
rm
textview.py
6121
0644
edit
dl
rm
TODO.txt
8478
0644
edit
dl
rm
tooltip.py
6486
0644
edit
dl
rm
tree.py
15089
0644
edit
dl
rm
undo.py
11047
0644
edit
dl
rm
window.py
2588
0644
edit
dl
rm
zoomheight.py
1340
0644
edit
dl
rm
zzdummy.py
961
0644
edit
dl
rm
_pyclbr.py
15199
0644
edit
dl
rm
__init__.py
396
0644
edit
dl
rm
__main__.py
159
0644
edit
dl
rm
Edit:
/opt/alt/python36/lib64/python3.6/idlelib/autoexpand.py
(3216B)
'''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. There is only one instance of Autoexpand. ''' import re import string class AutoExpand: 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__': from unittest import main main('idlelib.idle_test.test_autoexpand', verbosity=2)
Save
cmd:
run