/
opt
/
imh
/
python3.13
/
lib
/
python3.13
/
idlelib
/
/opt/imh/python3.13/lib/python3.13/idlelib
mkdir
upload
Name
Size
Mode
Actions
Icons/
-
0755
rm
__pycache__/
-
0755
rm
autocomplete.py
9354
0644
edit
dl
rm
autocomplete_w.py
20863
0644
edit
dl
rm
autoexpand.py
3216
0644
edit
dl
rm
browser.py
8588
0644
edit
dl
rm
calltip.py
7267
0644
edit
dl
rm
calltip_w.py
7083
0644
edit
dl
rm
ChangeLog
56360
0644
edit
dl
rm
codecontext.py
11420
0644
edit
dl
rm
colorizer.py
14783
0644
edit
dl
rm
config-extensions.def
2266
0644
edit
dl
rm
config-highlight.def
2864
0644
edit
dl
rm
config-keys.def
10910
0644
edit
dl
rm
config-main.def
3168
0644
edit
dl
rm
config.py
38403
0644
edit
dl
rm
configdialog.py
105303
0644
edit
dl
rm
config_key.py
15230
0644
edit
dl
rm
CREDITS.txt
2148
0644
edit
dl
rm
debugger.py
20997
0644
edit
dl
rm
debugger_r.py
12115
0644
edit
dl
rm
debugobj.py
4177
0644
edit
dl
rm
debugobj_r.py
1082
0644
edit
dl
rm
delegator.py
1044
0644
edit
dl
rm
dynoption.py
1993
0644
edit
dl
rm
editor.py
69557
0644
edit
dl
rm
extend.txt
3632
0644
edit
dl
rm
filelist.py
3871
0644
edit
dl
rm
format.py
15777
0644
edit
dl
rm
grep.py
7521
0644
edit
dl
rm
help.html
60566
0644
edit
dl
rm
help.py
11843
0644
edit
dl
rm
help_about.py
9023
0644
edit
dl
rm
history.py
4065
0644
edit
dl
rm
HISTORY.txt
10313
0644
edit
dl
rm
hyperparser.py
12889
0644
edit
dl
rm
idle.bat
177
0644
edit
dl
rm
idle.py
454
0644
edit
dl
rm
idle.pyw
570
0644
edit
dl
rm
iomenu.py
16159
0644
edit
dl
rm
macosx.py
9290
0644
edit
dl
rm
mainmenu.py
3938
0644
edit
dl
rm
multicall.py
18652
0644
edit
dl
rm
NEWS2x.txt
27172
0644
edit
dl
rm
News3.txt
56818
0644
edit
dl
rm
outwin.py
5705
0644
edit
dl
rm
parenmatch.py
7204
0644
edit
dl
rm
pathbrowser.py
3093
0644
edit
dl
rm
percolator.py
3568
0644
edit
dl
rm
pyparse.py
19864
0644
edit
dl
rm
pyshell.py
62484
0755
edit
dl
rm
query.py
15067
0644
edit
dl
rm
README.txt
11653
0644
edit
dl
rm
redirector.py
6832
0644
edit
dl
rm
replace.py
9798
0644
edit
dl
rm
rpc.py
21078
0644
edit
dl
rm
run.py
21877
0644
edit
dl
rm
runscript.py
8273
0644
edit
dl
rm
scrolledlist.py
4478
0644
edit
dl
rm
search.py
5567
0644
edit
dl
rm
searchbase.py
7852
0644
edit
dl
rm
searchengine.py
7372
0644
edit
dl
rm
sidebar.py
20327
0644
edit
dl
rm
squeezer.py
12834
0644
edit
dl
rm
stackviewer.py
4016
0644
edit
dl
rm
statusbar.py
1474
0644
edit
dl
rm
textview.py
6808
0644
edit
dl
rm
TODO.txt
8477
0644
edit
dl
rm
tooltip.py
6665
0644
edit
dl
rm
tree.py
16773
0644
edit
dl
rm
undo.py
11016
0644
edit
dl
rm
util.py
1312
0644
edit
dl
rm
window.py
2616
0644
edit
dl
rm
zoomheight.py
4203
0644
edit
dl
rm
zzdummy.py
2005
0644
edit
dl
rm
__init__.py
396
0644
edit
dl
rm
__main__.py
107
0644
edit
dl
rm
Edit:
/opt/imh/python3.13/lib/python3.13/idlelib/history.py
(4065B)
"Implement Idle Shell history mechanism with History class" from idlelib.config import idleConf class History: ''' Implement Idle Shell history mechanism. store - Store source statement (called from pyshell.resetoutput). fetch - Fetch stored statement matching prefix already entered. history_next - Bound to <<history-next>> event (default Alt-N). history_prev - Bound to <<history-prev>> event (default Alt-P). ''' def __init__(self, text): '''Initialize data attributes and bind event methods. .text - Idle wrapper of tk Text widget, with .bell(). .history - source statements, possibly with multiple lines. .prefix - source already entered at prompt; filters history list. .pointer - index into history. .cyclic - wrap around history list (or not). ''' self.text = text self.history = [] self.prefix = None self.pointer = None self.cyclic = idleConf.GetOption("main", "History", "cyclic", 1, "bool") text.bind("<<history-previous>>", self.history_prev) text.bind("<<history-next>>", self.history_next) def history_next(self, event): "Fetch later statement; start with earliest if cyclic." self.fetch(reverse=False) return "break" def history_prev(self, event): "Fetch earlier statement; start with most recent." self.fetch(reverse=True) return "break" def fetch(self, reverse): '''Fetch statement and replace current line in text widget. Set prefix and pointer as needed for successive fetches. Reset them to None, None when returning to the start line. Sound bell when return to start line or cannot leave a line because cyclic is False. ''' nhist = len(self.history) pointer = self.pointer prefix = self.prefix if pointer is not None and prefix is not None: if self.text.compare("insert", "!=", "end-1c") or \ self.text.get("iomark", "end-1c") != self.history[pointer]: pointer = prefix = None self.text.mark_set("insert", "end-1c") # != after cursor move if pointer is None or prefix is None: prefix = self.text.get("iomark", "end-1c") if reverse: pointer = nhist # will be decremented else: if self.cyclic: pointer = -1 # will be incremented else: # abort history_next self.text.bell() return nprefix = len(prefix) while True: pointer += -1 if reverse else 1 if pointer < 0 or pointer >= nhist: self.text.bell() if not self.cyclic and pointer < 0: # abort history_prev return else: if self.text.get("iomark", "end-1c") != prefix: self.text.delete("iomark", "end-1c") self.text.insert("iomark", prefix, "stdin") pointer = prefix = None break item = self.history[pointer] if item[:nprefix] == prefix and len(item) > nprefix: self.text.delete("iomark", "end-1c") self.text.insert("iomark", item, "stdin") break self.text.see("insert") self.text.tag_remove("sel", "1.0", "end") self.pointer = pointer self.prefix = prefix def store(self, source): "Store Shell input statement into history list." source = source.strip() if len(source) > 2: # avoid duplicates try: self.history.remove(source) except ValueError: pass self.history.append(source) self.pointer = None self.prefix = None if __name__ == "__main__": from unittest import main main('idlelib.idle_test.test_history', verbosity=2, exit=False)
Save
cmd:
run