/
usr
/
lib64
/
python2.6
/
idlelib
/
/usr/lib64/python2.6/idlelib
mkdir
upload
Name
Size
Mode
Actions
Icons/
-
0755
rm
aboutDialog.py
6825
0644
edit
dl
rm
aboutDialog.pyc
6965
0644
edit
dl
rm
aboutDialog.pyo
6965
0644
edit
dl
rm
AutoComplete.py
9061
0644
edit
dl
rm
AutoComplete.pyc
8023
0644
edit
dl
rm
AutoComplete.pyo
8023
0644
edit
dl
rm
AutoCompleteWindow.py
17201
0644
edit
dl
rm
AutoCompleteWindow.pyc
12580
0644
edit
dl
rm
AutoCompleteWindow.pyo
12517
0644
edit
dl
rm
AutoExpand.py
2483
0644
edit
dl
rm
AutoExpand.pyc
2587
0644
edit
dl
rm
AutoExpand.pyo
2587
0644
edit
dl
rm
Bindings.py
3502
0644
edit
dl
rm
Bindings.pyc
5064
0644
edit
dl
rm
Bindings.pyo
5064
0644
edit
dl
rm
CallTips.py
7608
0644
edit
dl
rm
CallTips.pyc
10287
0644
edit
dl
rm
CallTips.pyo
10287
0644
edit
dl
rm
CallTipWindow.py
5924
0644
edit
dl
rm
CallTipWindow.pyc
6217
0644
edit
dl
rm
CallTipWindow.pyo
6217
0644
edit
dl
rm
ChangeLog
56393
0644
edit
dl
rm
ClassBrowser.py
6369
0644
edit
dl
rm
ClassBrowser.pyc
9220
0644
edit
dl
rm
ClassBrowser.pyo
9220
0644
edit
dl
rm
CodeContext.py
8347
0644
edit
dl
rm
CodeContext.pyc
6733
0644
edit
dl
rm
CodeContext.pyo
6687
0644
edit
dl
rm
ColorDelegator.py
10150
0644
edit
dl
rm
ColorDelegator.pyc
8976
0644
edit
dl
rm
ColorDelegator.pyo
8976
0644
edit
dl
rm
config-extensions.def
2697
0644
edit
dl
rm
config-highlight.def
1740
0644
edit
dl
rm
config-keys.def
7517
0644
edit
dl
rm
config-main.def
2512
0644
edit
dl
rm
configDialog.py
53229
0644
edit
dl
rm
configDialog.pyc
44986
0644
edit
dl
rm
configDialog.pyo
44986
0644
edit
dl
rm
configHandler.py
28803
0644
edit
dl
rm
configHandler.pyc
27360
0644
edit
dl
rm
configHandler.pyo
27360
0644
edit
dl
rm
configHelpSourceEdit.py
6680
0644
edit
dl
rm
configHelpSourceEdit.pyc
6751
0644
edit
dl
rm
configHelpSourceEdit.pyo
6751
0644
edit
dl
rm
configSectionNameDialog.py
3720
0644
edit
dl
rm
configSectionNameDialog.pyc
4321
0644
edit
dl
rm
configSectionNameDialog.pyo
4321
0644
edit
dl
rm
CREDITS.txt
1856
0644
edit
dl
rm
Debugger.py
15818
0644
edit
dl
rm
Debugger.pyc
17074
0644
edit
dl
rm
Debugger.pyo
17074
0644
edit
dl
rm
Delegator.py
831
0644
edit
dl
rm
Delegator.pyc
1623
0644
edit
dl
rm
Delegator.pyo
1623
0644
edit
dl
rm
dynOptionMenuWidget.py
1302
0644
edit
dl
rm
dynOptionMenuWidget.pyc
1707
0644
edit
dl
rm
dynOptionMenuWidget.pyo
1707
0644
edit
dl
rm
EditorWindow.py
59734
0644
edit
dl
rm
EditorWindow.pyc
53007
0644
edit
dl
rm
EditorWindow.pyo
52904
0644
edit
dl
rm
extend.txt
3652
0644
edit
dl
rm
FileList.py
3660
0644
edit
dl
rm
FileList.pyc
4010
0644
edit
dl
rm
FileList.pyo
3975
0644
edit
dl
rm
FormatParagraph.py
5734
0644
edit
dl
rm
FormatParagraph.pyc
4827
0644
edit
dl
rm
FormatParagraph.pyo
4827
0644
edit
dl
rm
GrepDialog.py
4052
0644
edit
dl
rm
GrepDialog.pyc
5061
0644
edit
dl
rm
GrepDialog.pyo
5061
0644
edit
dl
rm
help.txt
11223
0644
edit
dl
rm
HISTORY.txt
10317
0644
edit
dl
rm
HyperParser.py
10310
0644
edit
dl
rm
HyperParser.pyc
6640
0644
edit
dl
rm
HyperParser.pyo
6640
0644
edit
dl
rm
idle.py
664
0644
edit
dl
rm
idle.pyc
596
0644
edit
dl
rm
idle.pyo
596
0644
edit
dl
rm
idle.pyw
664
0644
edit
dl
rm
IdleHistory.py
3145
0644
edit
dl
rm
IdleHistory.pyc
3231
0644
edit
dl
rm
IdleHistory.pyo
3231
0644
edit
dl
rm
idlever.py
23
0644
edit
dl
rm
idlever.pyc
159
0644
edit
dl
rm
idlever.pyo
159
0644
edit
dl
rm
IOBinding.py
20972
0644
edit
dl
rm
IOBinding.pyc
17791
0644
edit
dl
rm
IOBinding.pyo
17791
0644
edit
dl
rm
keybindingDialog.py
12407
0644
edit
dl
rm
keybindingDialog.pyc
12416
0644
edit
dl
rm
keybindingDialog.pyo
12416
0644
edit
dl
rm
macosxSupport.py
4724
0644
edit
dl
rm
macosxSupport.pyc
4886
0644
edit
dl
rm
macosxSupport.pyo
4886
0644
edit
dl
rm
MultiCall.py
17470
0644
edit
dl
rm
MultiCall.pyc
16208
0644
edit
dl
rm
MultiCall.pyo
16132
0644
edit
dl
rm
MultiStatusBar.py
789
0644
edit
dl
rm
MultiStatusBar.pyc
1548
0644
edit
dl
rm
MultiStatusBar.pyo
1548
0644
edit
dl
rm
NEWS.txt
27165
0644
edit
dl
rm
ObjectBrowser.py
4156
0644
edit
dl
rm
ObjectBrowser.pyc
6747
0644
edit
dl
rm
ObjectBrowser.pyo
6747
0644
edit
dl
rm
OutputWindow.py
4392
0644
edit
dl
rm
OutputWindow.pyc
5020
0644
edit
dl
rm
OutputWindow.pyo
5020
0644
edit
dl
rm
ParenMatch.py
6627
0644
edit
dl
rm
ParenMatch.pyc
7007
0644
edit
dl
rm
ParenMatch.pyo
7007
0644
edit
dl
rm
PathBrowser.py
2646
0644
edit
dl
rm
PathBrowser.pyc
4165
0644
edit
dl
rm
PathBrowser.pyo
4165
0644
edit
dl
rm
Percolator.py
2616
0644
edit
dl
rm
Percolator.pyc
3660
0644
edit
dl
rm
Percolator.pyo
3466
0644
edit
dl
rm
PyParse.py
19510
0644
edit
dl
rm
PyParse.pyc
10213
0644
edit
dl
rm
PyParse.pyo
9745
0644
edit
dl
rm
PyShell.py
51909
0644
edit
dl
rm
PyShell.pyc
46688
0644
edit
dl
rm
PyShell.pyo
46587
0644
edit
dl
rm
README.txt
2623
0644
edit
dl
rm
RemoteDebugger.py
11660
0644
edit
dl
rm
RemoteDebugger.pyc
16414
0644
edit
dl
rm
RemoteDebugger.pyo
16259
0644
edit
dl
rm
RemoteObjectBrowser.py
942
0644
edit
dl
rm
RemoteObjectBrowser.pyc
2167
0644
edit
dl
rm
RemoteObjectBrowser.pyo
2167
0644
edit
dl
rm
ReplaceDialog.py
5134
0644
edit
dl
rm
ReplaceDialog.pyc
5984
0644
edit
dl
rm
ReplaceDialog.pyo
5984
0644
edit
dl
rm
rpc.py
20215
0644
edit
dl
rm
rpc.pyc
21937
0644
edit
dl
rm
rpc.pyo
21827
0644
edit
dl
rm
run.py
11337
0644
edit
dl
rm
run.pyc
12214
0644
edit
dl
rm
run.pyo
12214
0644
edit
dl
rm
ScriptBinding.py
7783
0644
edit
dl
rm
ScriptBinding.pyc
7607
0644
edit
dl
rm
ScriptBinding.pyo
7607
0644
edit
dl
rm
ScrolledList.py
3995
0644
edit
dl
rm
ScrolledList.pyc
6193
0644
edit
dl
rm
ScrolledList.pyo
6193
0644
edit
dl
rm
SearchDialog.py
2040
0644
edit
dl
rm
SearchDialog.pyc
3026
0644
edit
dl
rm
SearchDialog.pyo
3026
0644
edit
dl
rm
SearchDialogBase.py
4385
0644
edit
dl
rm
SearchDialogBase.pyc
5518
0644
edit
dl
rm
SearchDialogBase.pyo
5518
0644
edit
dl
rm
SearchEngine.py
6731
0644
edit
dl
rm
SearchEngine.pyc
7257
0644
edit
dl
rm
SearchEngine.pyo
7257
0644
edit
dl
rm
StackViewer.py
3857
0644
edit
dl
rm
StackViewer.pyc
5958
0644
edit
dl
rm
StackViewer.pyo
5958
0644
edit
dl
rm
tabbedpages.py
18188
0644
edit
dl
rm
tabbedpages.pyc
18163
0644
edit
dl
rm
tabbedpages.pyo
18163
0644
edit
dl
rm
textView.py
3246
0644
edit
dl
rm
textView.pyc
3983
0644
edit
dl
rm
textView.pyo
3983
0644
edit
dl
rm
TODO.txt
8478
0644
edit
dl
rm
ToolTip.py
2736
0644
edit
dl
rm
ToolTip.pyc
4160
0644
edit
dl
rm
ToolTip.pyo
4160
0644
edit
dl
rm
TreeWidget.py
15237
0644
edit
dl
rm
TreeWidget.pyc
18014
0644
edit
dl
rm
TreeWidget.pyo
18014
0644
edit
dl
rm
UndoDelegator.py
10277
0644
edit
dl
rm
UndoDelegator.pyc
12646
0644
edit
dl
rm
UndoDelegator.pyo
12646
0644
edit
dl
rm
WidgetRedirector.py
4476
0644
edit
dl
rm
WidgetRedirector.pyc
5366
0644
edit
dl
rm
WidgetRedirector.pyo
5366
0644
edit
dl
rm
WindowList.py
2473
0644
edit
dl
rm
WindowList.pyc
3654
0644
edit
dl
rm
WindowList.pyo
3654
0644
edit
dl
rm
ZoomHeight.py
1307
0644
edit
dl
rm
ZoomHeight.pyc
1661
0644
edit
dl
rm
ZoomHeight.pyo
1661
0644
edit
dl
rm
__init__.py
37
0644
edit
dl
rm
__init__.pyc
127
0644
edit
dl
rm
__init__.pyo
127
0644
edit
dl
rm
Edit:
/usr/lib64/python2.6/idlelib/ColorDelegator.py
(10150B)
import time import re import keyword import __builtin__ from Tkinter import * 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(__builtin__) if not name.startswith('_')] # self.file = file("file") : # 1st 'file' colorized normal, 2nd as builtin, 3rd as string builtin = r"([^.'\"\\#]\b|^)" + any("BUILTIN", builtinlist) + r"\b" comment = any("COMMENT", [r"#[^\n]*"]) sqstring = r"(\b[rRuU])?'[^'\\\n]*(\\.[^'\\\n]*)*'?" dqstring = r'(\b[rRuU])?"[^"\\\n]*(\\.[^"\\\n]*)*"?' sq3string = r"(\b[rRuU])?'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?" dq3string = r'(\b[rRuU])?"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?' 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) asprog = re.compile(r".*?\b(as)\b") class ColorDelegator(Delegator): def __init__(self): Delegator.__init__(self) self.prog = prog self.idprog = idprog self.asprog = asprog 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") 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.GetOption('main','Theme','name') 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}, "BREAK": idleConf.GetHighlight(theme, "break"), "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 if close_when_done: if not self.colorizing: close_when_done.destroy() else: self.close_when_done = close_when_done def toggle_colorize_event(self, event): if self.after_id: after_id = self.after_id self.after_id = None if DEBUG: print "cancel scheduled recolorizer" self.after_cancel(after_id) if self.allow_colorizing and self.colorizing: if DEBUG: print "stop colorizing" self.stop_colorizing = True self.allow_colorizing = not self.allow_colorizing if self.allow_colorizing and not self.colorizing: self.after_id = self.after(1, self.recolorize) if DEBUG: print "auto colorizing turned",\ self.allow_colorizing and "on" or "off" return "break" def recolorize(self): self.after_id = None if not self.delegate: if DEBUG: print "no delegate" return if not self.allow_colorizing: if DEBUG: print "auto colorizing is off" return if self.colorizing: if DEBUG: print "already colorizing" return try: self.stop_colorizing = False self.colorizing = True if DEBUG: print "colorizing..." t0 = time.clock() self.recolorize_main() t1 = time.clock() if DEBUG: print "%.3f seconds" % (t1-t0) finally: self.colorizing = False if self.allow_colorizing and self.tag_nextrange("TODO", "1.0"): if DEBUG: print "reschedule colorizing" self.after_id = self.after(1, self.recolorize) if self.close_when_done: top = self.close_when_done self.close_when_done = None top.destroy() def recolorize_main(self): next = "1.0" while True: item = self.tag_nextrange("TODO", next) if not item: break head, tail = item self.tag_remove("SYNC", head, tail) item = self.tag_prevrange("SYNC", head) if item: head = item[1] else: head = "1.0" chars = "" next = head lines_to_get = 1 ok = False while not ok: mark = next next = self.index(mark + "+%d lines linestart" % lines_to_get) lines_to_get = min(lines_to_get * 2, 100) ok = "SYNC" in self.tag_names(next + "-1c") line = self.get(mark, next) ##print head, "get", mark, next, "->", repr(line) if not line: return for tag in self.tagdefs.keys(): self.tag_remove(tag, mark, next) chars = chars + line m = self.prog.search(chars) while m: for key, value in m.groupdict().items(): if value: a, b = m.span(key) self.tag_add(key, head + "+%dc" % a, head + "+%dc" % b) if value in ("def", "class"): m1 = self.idprog.match(chars, b) if m1: a, b = m1.span(1) self.tag_add("DEFINITION", head + "+%dc" % a, head + "+%dc" % b) elif value == "import": # color all the "as" words on same line, except # if in a comment; cheap approximation to the # truth if '#' in chars: endpos = chars.index('#') else: endpos = len(chars) while True: m1 = self.asprog.match(chars, b, endpos) if not m1: break a, b = m1.span(1) self.tag_add("KEYWORD", head + "+%dc" % a, head + "+%dc" % b) m = self.prog.search(chars, m.end()) if "SYNC" in self.tag_names(next + "-1c"): head = next chars = "" else: ok = False if not ok: # We're in an inconsistent state, and the call to # update may tell us to stop. It may also change # the correct value for "next" (since this is a # line.col string, not a true mark). So leave a # crumb telling the next invocation to resume here # in case update tells us to leave. self.tag_add("TODO", next) self.update() if self.stop_colorizing: if DEBUG: print "colorizing stopped" return def removecolors(self): for tag in self.tagdefs.keys(): self.tag_remove(tag, "1.0", "end") def main(): from idlelib.Percolator import Percolator root = Tk() root.wm_protocol("WM_DELETE_WINDOW", root.quit) text = Text(background="white") text.pack(expand=1, fill="both") text.focus_set() p = Percolator(text) d = ColorDelegator() p.insertfilter(d) root.mainloop() if __name__ == "__main__": main()
Save
cmd:
run