mirror of
				https://github.com/python/cpython.git
				synced 2025-10-30 21:21:22 +00:00 
			
		
		
		
	Color preferences code by Loren Luke (massaged by me somewhat)
This commit is contained in:
		
							parent
							
								
									cfb819ee51
								
							
						
					
					
						commit
						7de697597e
					
				
					 4 changed files with 104 additions and 15 deletions
				
			
		|  | @ -4,6 +4,7 @@ | ||||||
| import keyword | import keyword | ||||||
| from Tkinter import * | from Tkinter import * | ||||||
| from Delegator import Delegator | from Delegator import Delegator | ||||||
|  | import IdlePrefs | ||||||
| 
 | 
 | ||||||
| #$ event <<toggle-auto-coloring>> | #$ event <<toggle-auto-coloring>> | ||||||
| #$ win <Control-slash> | #$ win <Control-slash> | ||||||
|  | @ -50,19 +51,29 @@ def config_colors(self): | ||||||
|                 apply(self.tag_configure, (tag,), cnf) |                 apply(self.tag_configure, (tag,), cnf) | ||||||
|         self.tag_raise('sel') |         self.tag_raise('sel') | ||||||
| 
 | 
 | ||||||
|  |     cprefs = IdlePrefs.ColorPrefs() | ||||||
|  | 
 | ||||||
|     tagdefs = { |     tagdefs = { | ||||||
|         "COMMENT":    {"foreground": "#dd0000"}, |         "COMMENT":    {"foreground": cprefs.CComment[0], | ||||||
|         "KEYWORD":    {"foreground": "#ff7700"}, |                        "background": cprefs.CComment[1]}, | ||||||
|         "STRING":     {"foreground": "#00aa00"}, |         "KEYWORD":    {"foreground": cprefs.CKeyword[0], | ||||||
|         "DEFINITION": {"foreground": "#0000ff"}, |                        "background": cprefs.CKeyword[1]}, | ||||||
|  |         "STRING":     {"foreground": cprefs.CString[0], | ||||||
|  |                        "background": cprefs.CString[1]}, | ||||||
|  |         "DEFINITION": {"foreground": cprefs.CDefinition[0], | ||||||
|  |                        "background": cprefs.CDefinition[1]}, | ||||||
| 
 | 
 | ||||||
|         "SYNC":       {}, #{"background": "#ffff00"}, |         "SYNC":       {"background": cprefs.CSync[0], | ||||||
|         "TODO":       {}, #{"background": "#cccccc"}, |                        "background": cprefs.CSync[1]}, | ||||||
|  |         "TODO":       {"background": cprefs.CTodo[0], | ||||||
|  |                        "background": cprefs.CTodo[1]}, | ||||||
| 
 | 
 | ||||||
|         "BREAK":      {"background": "#FF7777"}, |         "BREAK":      {"background": cprefs.CBreak[0], | ||||||
|  |                        "background": cprefs.CBreak[1]}, | ||||||
| 
 | 
 | ||||||
|         # The following is used by ReplaceDialog: |         # The following is used by ReplaceDialog: | ||||||
|         "hit":        {"foreground": "#FFFFFF", "background": "#000000"}, |         "hit":        {"foreground": cprefs.CHit[0], | ||||||
|  |                        "background": cprefs.CHit[1]}, | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|     def insert(self, index, chars, tags=None): |     def insert(self, index, chars, tags=None): | ||||||
|  |  | ||||||
|  | @ -89,6 +89,7 @@ class EditorWindow: | ||||||
|     vars = {} |     vars = {} | ||||||
| 
 | 
 | ||||||
|     def __init__(self, flist=None, filename=None, key=None, root=None): |     def __init__(self, flist=None, filename=None, key=None, root=None): | ||||||
|  |         cprefs = self.ColorDelegator.cprefs | ||||||
|         self.flist = flist |         self.flist = flist | ||||||
|         root = root or flist.root |         root = root or flist.root | ||||||
|         self.root = root |         self.root = root | ||||||
|  | @ -98,7 +99,12 @@ def __init__(self, flist=None, filename=None, key=None, root=None): | ||||||
|         self.top = top = self.Toplevel(root, menu=self.menubar) |         self.top = top = self.Toplevel(root, menu=self.menubar) | ||||||
|         self.vbar = vbar = Scrollbar(top, name='vbar') |         self.vbar = vbar = Scrollbar(top, name='vbar') | ||||||
|         self.text = text = Text(top, name='text', padx=5, |         self.text = text = Text(top, name='text', padx=5, | ||||||
|                                 background="white", wrap="none") |                                 foreground=cprefs.CNormal[0], | ||||||
|  |                                 background=cprefs.CNormal[1],  | ||||||
|  |                                 highlightcolor=cprefs.CHilite[0], | ||||||
|  |                                 highlightbackground=cprefs.CHilite[1], | ||||||
|  |                                 insertbackground=cprefs.CCursor[1], | ||||||
|  |                                 wrap="none") | ||||||
| 
 | 
 | ||||||
|         self.createmenubar() |         self.createmenubar() | ||||||
|         self.apply_bindings() |         self.apply_bindings() | ||||||
|  |  | ||||||
							
								
								
									
										65
									
								
								Tools/idle/IdlePrefs.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								Tools/idle/IdlePrefs.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,65 @@ | ||||||
|  | # Created on 4/15/99 by Loren Luke | ||||||
|  | # | ||||||
|  | # Color Prefs for idle | ||||||
|  | 
 | ||||||
|  | class ColorPrefs: | ||||||
|  |     CNormal     = "yellow", None | ||||||
|  |     CKeyword    = "medium sea green", None | ||||||
|  |     CComment    = "white", None | ||||||
|  |     CString     = "DarkOrange1", None | ||||||
|  |     CDefinition = "wheat1", None | ||||||
|  |     CHilite     = "#000068", "#006868" | ||||||
|  |     CSync       = "yellow", None | ||||||
|  |     CTodo       = "aquamarine4", None | ||||||
|  |     CBreak      = "white", None | ||||||
|  |     CHit        = "#000068", None | ||||||
|  |     CStdIn      = "yellow", None | ||||||
|  |     CStdOut     = "yellow", None | ||||||
|  |     CStdErr     = "firebrick3", None | ||||||
|  |     CConsole    = "yellow", None | ||||||
|  |     CError      = "white", "red" | ||||||
|  |     CCursor     = None, "yellow" | ||||||
|  |      | ||||||
|  |     def __init__(self, fg="yellow", bg="DodgerBlue4", ud=1): | ||||||
|  |         self.Default = fg, bg | ||||||
|  |          | ||||||
|  |         # Use Default Colors? | ||||||
|  |         if ud == 1: | ||||||
|  |             # Use Default fg, bg Colors | ||||||
|  |             # Define Screen Colors... | ||||||
|  |             # format: x = (fg, bg) | ||||||
|  |             self.CBreak      = "white", "#680000" | ||||||
|  |             self.CComment    = "white", self.Default[1] | ||||||
|  |             self.CConsole    = self.Default | ||||||
|  |             self.CCursor     = None, self.Default[0] | ||||||
|  |             self.CDefinition = "wheat1", self.Default[1] | ||||||
|  |             self.CError      = "white", "red" | ||||||
|  |             self.CHilite     = "#000068", "#006868" | ||||||
|  |             self.CHit        = "#000068", "#006868" | ||||||
|  |             self.CKeyword    = "medium sea green", self.Default[1] | ||||||
|  |             self.CNormal     = "yellow", self.Default[1] | ||||||
|  |             self.CStdErr     = "firebrick3", self.Default[1] | ||||||
|  |             self.CStdIn      = self.Default | ||||||
|  |             self.CStdOut     = self.Default | ||||||
|  |             self.CString     = "DarkOrange1", self.Default[1] | ||||||
|  |             self.CSync       = self.Default | ||||||
|  |             self.CTodo       = "aquamarine4", self.Default[1] | ||||||
|  |         else: | ||||||
|  |             #Define Screen Colors... | ||||||
|  |             # format: x = (fg, bg) | ||||||
|  |             self.CBreak      = "white", None | ||||||
|  |             self.CComment    = "white", None | ||||||
|  |             self.CConsole    = "yellow", None | ||||||
|  |             self.CCursor     = None, "yellow" | ||||||
|  |             self.CDefinition = "wheat1", None | ||||||
|  |             self.CError      = "white", "red" | ||||||
|  |             self.CHilite     = "#000068", "#006868" | ||||||
|  |             self.CHit        = "#000068", None | ||||||
|  |             self.CKeyword    = "medium sea green", None | ||||||
|  |             self.CNormal     = "yellow", None | ||||||
|  |             self.CStdErr     = "firebrick3", None | ||||||
|  |             self.CStdIn      = "yellow", None | ||||||
|  |             self.CStdOut     = "yellow", None | ||||||
|  |             self.CString     = "DarkOrange1", None | ||||||
|  |             self.CSync       = "yellow", None | ||||||
|  |             self.CTodo       = "aquamarine4", None | ||||||
|  | @ -113,14 +113,21 @@ def recolorize_main(self): | ||||||
|         ColorDelegator.recolorize_main(self) |         ColorDelegator.recolorize_main(self) | ||||||
| 
 | 
 | ||||||
|     tagdefs = ColorDelegator.tagdefs.copy() |     tagdefs = ColorDelegator.tagdefs.copy() | ||||||
|  |     cprefs = ColorDelegator.cprefs | ||||||
| 
 | 
 | ||||||
|     tagdefs.update({ |     tagdefs.update({ | ||||||
|         ##"stdin":   {"background": "yellow"}, |         "stdin":   {"foreground": cprefs.CStdIn[0], | ||||||
|         "stdout":  {"foreground": "blue"}, |                     "background": cprefs.CStdIn[1]}, | ||||||
|         "stderr":  {"foreground": "#007700"}, |         "stdout":  {"foreground": cprefs.CStdOut[0], | ||||||
|         "console": {"foreground": "#770000"}, |                     "background": cprefs.CStdOut[1]}, | ||||||
|         "ERROR":   {"background": "#FF7777"}, |         "stderr":  {"foreground": cprefs.CStdErr[0], | ||||||
|         None:      {"foreground": "purple"}, # default |                     "background": cprefs.CStdErr[1]}, | ||||||
|  |         "console": {"foreground": cprefs.CConsole[0], | ||||||
|  |                     "background": cprefs.CConsole[1]}, | ||||||
|  |         "ERROR":   {"background": cprefs.CError[0], | ||||||
|  |                     "background": cprefs.CError[1]}, | ||||||
|  |         None:      {"foreground": cprefs.CNormal[0], | ||||||
|  |                     "background": cprefs.CNormal[1]}, | ||||||
|     }) |     }) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Guido van Rossum
						Guido van Rossum