mirror of https://github.com/python/cpython.git
First work on making config changes dynamic,
dynamic theme changes
This commit is contained in:
parent
03b18834c3
commit
b77d343bc8
|
@ -37,6 +37,7 @@ def __init__(self):
|
||||||
self.prog = prog
|
self.prog = prog
|
||||||
self.idprog = idprog
|
self.idprog = idprog
|
||||||
self.asprog = asprog
|
self.asprog = asprog
|
||||||
|
self.LoadTagDefs()
|
||||||
|
|
||||||
def setdelegate(self, delegate):
|
def setdelegate(self, delegate):
|
||||||
if self.delegate is not None:
|
if self.delegate is not None:
|
||||||
|
@ -53,9 +54,9 @@ def config_colors(self):
|
||||||
apply(self.tag_configure, (tag,), cnf)
|
apply(self.tag_configure, (tag,), cnf)
|
||||||
self.tag_raise('sel')
|
self.tag_raise('sel')
|
||||||
|
|
||||||
|
def LoadTagDefs(self):
|
||||||
theme = idleConf.GetOption('main','Theme','name')
|
theme = idleConf.GetOption('main','Theme','name')
|
||||||
|
self.tagdefs = {
|
||||||
tagdefs = {
|
|
||||||
"COMMENT": idleConf.GetHighlight(theme, "comment"),
|
"COMMENT": idleConf.GetHighlight(theme, "comment"),
|
||||||
"KEYWORD": idleConf.GetHighlight(theme, "keyword"),
|
"KEYWORD": idleConf.GetHighlight(theme, "keyword"),
|
||||||
"STRING": idleConf.GetHighlight(theme, "string"),
|
"STRING": idleConf.GetHighlight(theme, "string"),
|
||||||
|
|
|
@ -102,6 +102,9 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
|
||||||
self.vars = flist.vars
|
self.vars = flist.vars
|
||||||
self.menubar = Menu(root)
|
self.menubar = Menu(root)
|
||||||
self.top = top = self.Toplevel(root, menu=self.menubar)
|
self.top = top = self.Toplevel(root, menu=self.menubar)
|
||||||
|
#self.top.instanceDict makes flist.inversedict avalable to
|
||||||
|
#configDialog.py so it can access all EditorWindow instaces
|
||||||
|
self.top.instanceDict=flist.inversedict
|
||||||
self.vbar = vbar = Scrollbar(top, name='vbar')
|
self.vbar = vbar = Scrollbar(top, name='vbar')
|
||||||
self.text_frame = text_frame = Frame(top)
|
self.text_frame = text_frame = Frame(top)
|
||||||
self.text = text = Text(text_frame, name='text', padx=5, wrap=None,
|
self.text = text = Text(text_frame, name='text', padx=5, wrap=None,
|
||||||
|
@ -468,6 +471,13 @@ def rmcolorizer(self):
|
||||||
self.color = None
|
self.color = None
|
||||||
self.per.insertfilter(self.undo)
|
self.per.insertfilter(self.undo)
|
||||||
|
|
||||||
|
def ResetColorizer(self):
|
||||||
|
#this function is called from configDialog.py
|
||||||
|
#to update the colour theme if it is changed
|
||||||
|
if self.color:
|
||||||
|
self.color = self.ColorDelegator()
|
||||||
|
self.per.insertfilter(self.color)
|
||||||
|
|
||||||
def saved_change_hook(self):
|
def saved_change_hook(self):
|
||||||
short = self.short_title()
|
short = self.short_title()
|
||||||
long = self.long_title()
|
long = self.long_title()
|
||||||
|
|
|
@ -135,15 +135,19 @@ class ModifiedColorDelegator(ColorDelegator):
|
||||||
|
|
||||||
# Colorizer for the shell window itself
|
# Colorizer for the shell window itself
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
ColorDelegator.__init__(self)
|
||||||
|
self.LoadTagDefs()
|
||||||
|
|
||||||
def recolorize_main(self):
|
def recolorize_main(self):
|
||||||
self.tag_remove("TODO", "1.0", "iomark")
|
self.tag_remove("TODO", "1.0", "iomark")
|
||||||
self.tag_add("SYNC", "1.0", "iomark")
|
self.tag_add("SYNC", "1.0", "iomark")
|
||||||
ColorDelegator.recolorize_main(self)
|
ColorDelegator.recolorize_main(self)
|
||||||
|
|
||||||
tagdefs = ColorDelegator.tagdefs.copy()
|
def LoadTagDefs(self):
|
||||||
|
ColorDelegator.LoadTagDefs(self)
|
||||||
theme = idleConf.GetOption('main','Theme','name')
|
theme = idleConf.GetOption('main','Theme','name')
|
||||||
|
self.tagdefs.update({
|
||||||
tagdefs.update({
|
|
||||||
"stdin": {'background':None,'foreground':None},
|
"stdin": {'background':None,'foreground':None},
|
||||||
"stdout": idleConf.GetHighlight(theme, "stdout"),
|
"stdout": idleConf.GetHighlight(theme, "stdout"),
|
||||||
"stderr": idleConf.GetHighlight(theme, "stderr"),
|
"stderr": idleConf.GetHighlight(theme, "stderr"),
|
||||||
|
|
|
@ -23,8 +23,6 @@ def __init__(self,parent,title):
|
||||||
#Theme Elements. Each theme element key is it's display name.
|
#Theme Elements. Each theme element key is it's display name.
|
||||||
#The first value of the tuple is the sample area tag name.
|
#The first value of the tuple is the sample area tag name.
|
||||||
#The second value is the display name list sort index.
|
#The second value is the display name list sort index.
|
||||||
#The third value indicates whether the element can have a foreground
|
|
||||||
#or background colour or both.
|
|
||||||
self.themeElements={'Normal Text':('normal','00'),
|
self.themeElements={'Normal Text':('normal','00'),
|
||||||
'Python Keywords':('keyword','01'),
|
'Python Keywords':('keyword','01'),
|
||||||
'Python Definitions':('definition','02'),
|
'Python Definitions':('definition','02'),
|
||||||
|
@ -180,8 +178,8 @@ def CreatePageHighlight(self):
|
||||||
frameTheme=Frame(frame,borderwidth=2,relief=GROOVE)
|
frameTheme=Frame(frame,borderwidth=2,relief=GROOVE)
|
||||||
#frameCustom
|
#frameCustom
|
||||||
self.textHighlightSample=Text(frameCustom,relief=SOLID,borderwidth=1,
|
self.textHighlightSample=Text(frameCustom,relief=SOLID,borderwidth=1,
|
||||||
font=('courier',12,''),cursor='hand2',width=10,height=10,
|
font=('courier',12,''),cursor='hand2',width=21,height=10,
|
||||||
takefocus=FALSE,highlightthickness=0)
|
takefocus=FALSE,highlightthickness=0,wrap=NONE)
|
||||||
text=self.textHighlightSample
|
text=self.textHighlightSample
|
||||||
text.bind('<Double-Button-1>',lambda e: 'break')
|
text.bind('<Double-Button-1>',lambda e: 'break')
|
||||||
text.bind('<B1-Motion>',lambda e: 'break')
|
text.bind('<B1-Motion>',lambda e: 'break')
|
||||||
|
@ -514,7 +512,7 @@ def VarChanged_startupEdit(self,*params):
|
||||||
self.AddChangedItem('main','General','editor-on-startup',value)
|
self.AddChangedItem('main','General','editor-on-startup',value)
|
||||||
|
|
||||||
def ResetChangedItems(self):
|
def ResetChangedItems(self):
|
||||||
#changedItems. When any config item is changed in this dialog, an entry
|
#When any config item is changed in this dialog, an entry
|
||||||
#should be made in the relevant section (config type) of this
|
#should be made in the relevant section (config type) of this
|
||||||
#dictionary. The key should be the config file section name and the
|
#dictionary. The key should be the config file section name and the
|
||||||
#value a dictionary, whose key:value pairs are item=value pairs for
|
#value a dictionary, whose key:value pairs are item=value pairs for
|
||||||
|
@ -1086,13 +1084,14 @@ def SaveAllChangedConfigs(self):
|
||||||
def ActivateConfigChanges(self):
|
def ActivateConfigChanges(self):
|
||||||
#things that need to be done to make
|
#things that need to be done to make
|
||||||
#applied config changes dynamic:
|
#applied config changes dynamic:
|
||||||
#
|
|
||||||
#update editor/shell font and repaint
|
#update editor/shell font and repaint
|
||||||
#dynamically update indentation setttings
|
#dynamically update indentation setttings
|
||||||
#update theme and repaint
|
#update theme and repaint
|
||||||
#update keybindings and re-bind
|
#update keybindings and re-bind
|
||||||
#update user help sources menu
|
#update user help sources menu
|
||||||
pass
|
winInstances=self.parent.instanceDict.keys()
|
||||||
|
for instance in winInstances:
|
||||||
|
instance.ResetColorizer()
|
||||||
|
|
||||||
def Cancel(self):
|
def Cancel(self):
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
|
@ -110,6 +110,13 @@ def SetOption(self,section,option,value):
|
||||||
self.set(section,option,value)
|
self.set(section,option,value)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
def RemoveFile(self):
|
||||||
|
"""
|
||||||
|
Removes the user config file from disk if it exists.
|
||||||
|
"""
|
||||||
|
if os.path.exists(self.file):
|
||||||
|
os.remove(self.file)
|
||||||
|
|
||||||
def Save(self):
|
def Save(self):
|
||||||
"""
|
"""
|
||||||
If config isn't empty, write file to disk. If config is empty,
|
If config isn't empty, write file to disk. If config is empty,
|
||||||
|
@ -119,8 +126,7 @@ def Save(self):
|
||||||
cfgFile=open(self.file,'w')
|
cfgFile=open(self.file,'w')
|
||||||
self.write(cfgFile)
|
self.write(cfgFile)
|
||||||
else:
|
else:
|
||||||
if os.path.exists(self.file):
|
self.RemoveFile()
|
||||||
os.remove(self.file)
|
|
||||||
|
|
||||||
class IdleConf:
|
class IdleConf:
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue