<s> """<STR_LIT>""" <EOL> import os , sys , string , pprint , copy <EOL> from wxPython . wx import * <EOL> from wxPython . help import * <EOL> from wxPython . lib . anchors import LayoutAnchors <EOL> from wxPython . stc import * <EOL> from wxPython import stc <EOL> settingsIdNames = { - <NUM_LIT:1> : '<STR_LIT>' , - <NUM_LIT:2> : '<STR_LIT>' , - <NUM_LIT:3> : '<STR_LIT>' } <EOL> commonPropDefs = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:size>' : <NUM_LIT:8> , <EOL> '<STR_LIT>' : wxSystemSettings_GetSystemFont ( wxSYS_DEFAULT_GUI_FONT ) . GetFaceName ( ) } <EOL> styleCategoryDescriptions = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> [ wxID_STCSTYLEEDITDLG , wxID_STCSTYLEEDITDLGADDCOMMONITEMBTN , <EOL> wxID_STCSTYLEEDITDLGBGCOLBTN , wxID_STCSTYLEEDITDLGBGCOLCB , <EOL> wxID_STCSTYLEEDITDLGBGCOLDEFCB , wxID_STCSTYLEEDITDLGBGCOLOKBTN , <EOL> wxID_STCSTYLEEDITDLGCANCELBTN , wxID_STCSTYLEEDITDLGCONTEXTHELPBUTTON1 , <EOL> wxID_STCSTYLEEDITDLGELEMENTLB , wxID_STCSTYLEEDITDLGFACECB , <EOL> wxID_STCSTYLEEDITDLGFACEDEFCB , wxID_STCSTYLEEDITDLGFACEOKBTN , <EOL> wxID_STCSTYLEEDITDLGFGCOLBTN , wxID_STCSTYLEEDITDLGFGCOLCB , <EOL> wxID_STCSTYLEEDITDLGFGCOLDEFCB , wxID_STCSTYLEEDITDLGFGCOLOKBTN , <EOL> wxID_STCSTYLEEDITDLGFIXEDWIDTHCHK , wxID_STCSTYLEEDITDLGOKBTN , <EOL> wxID_STCSTYLEEDITDLGPANEL1 , wxID_STCSTYLEEDITDLGPANEL2 , <EOL> wxID_STCSTYLEEDITDLGPANEL3 , wxID_STCSTYLEEDITDLGPANEL4 , <EOL> wxID_STCSTYLEEDITDLGREMOVECOMMONITEMBTN , wxID_STCSTYLEEDITDLGSIZECB , <EOL> wxID_STCSTYLEEDITDLGSIZEOKBTN , wxID_STCSTYLEEDITDLGSPEEDSETTINGCH , <EOL> wxID_STCSTYLEEDITDLGSTATICBOX1 , wxID_STCSTYLEEDITDLGSTATICBOX2 , <EOL> wxID_STCSTYLEEDITDLGSTATICLINE1 , wxID_STCSTYLEEDITDLGSTATICTEXT2 , <EOL> wxID_STCSTYLEEDITDLGSTATICTEXT3 , wxID_STCSTYLEEDITDLGSTATICTEXT4 , <EOL> wxID_STCSTYLEEDITDLGSTATICTEXT6 , wxID_STCSTYLEEDITDLGSTATICTEXT7 , <EOL> wxID_STCSTYLEEDITDLGSTATICTEXT8 , wxID_STCSTYLEEDITDLGSTATICTEXT9 , <EOL> wxID_STCSTYLEEDITDLGSTC , wxID_STCSTYLEEDITDLGSTYLEDEFST , <EOL> wxID_STCSTYLEEDITDLGTABOLDCB , wxID_STCSTYLEEDITDLGTABOLDDEFCB , <EOL> wxID_STCSTYLEEDITDLGTAEOLFILLEDCB , wxID_STCSTYLEEDITDLGTAEOLFILLEDDEFCB , <EOL> wxID_STCSTYLEEDITDLGTAITALICCB , wxID_STCSTYLEEDITDLGTAITALICDEFCB , <EOL> wxID_STCSTYLEEDITDLGTASIZEDEFCB , wxID_STCSTYLEEDITDLGTAUNDERLINEDCB , <EOL> wxID_STCSTYLEEDITDLGTAUNDERLINEDDEFCB , <EOL> ] = map ( lambda _init_ctrls : wxNewId ( ) , range ( <NUM_LIT> ) ) <EOL> class STCStyleEditDlg ( wxDialog ) : <EOL> """<STR_LIT>""" <EOL> _custom_classes = { '<STR_LIT>' : [ '<STR_LIT>' ] } <EOL> def _init_utils ( self ) : <EOL> pass <EOL> def _init_ctrls ( self , prnt ) : <EOL> wxDialog . __init__ ( self , id = wxID_STCSTYLEEDITDLG , name = '<STR_LIT>' , <EOL> parent = prnt , pos = wxPoint ( <NUM_LIT> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , <EOL> style = wxWANTS_CHARS | wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER , <EOL> title = self . stc_title ) <EOL> self . _init_utils ( ) <EOL> self . SetClientSize ( wxSize ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . SetAutoLayout ( true ) <EOL> self . SetSizeHints ( <NUM_LIT> , <NUM_LIT> , - <NUM_LIT:1> , - <NUM_LIT:1> ) <EOL> self . Center ( wxBOTH ) <EOL> EVT_SIZE ( self , self . OnStcstyleeditdlgSize ) <EOL> self . speedsettingCh = wxChoice ( choices = [ ] , <EOL> id = wxID_STCSTYLEEDITDLGSPEEDSETTINGCH , name = '<STR_LIT>' , <EOL> parent = self , pos = wxPoint ( <NUM_LIT> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> , <EOL> validator = wxDefaultValidator ) <EOL> self . speedsettingCh . SetConstraints ( LayoutAnchors ( self . speedsettingCh , <EOL> true , true , true , false ) ) <EOL> self . speedsettingCh . SetHelpText ( '<STR_LIT>' ) <EOL> EVT_CHOICE ( self . speedsettingCh , wxID_STCSTYLEEDITDLGSPEEDSETTINGCH , <EOL> self . OnSpeedsettingchChoice ) <EOL> self . elementLb = wxListBox ( choices = [ ] , id = wxID_STCSTYLEEDITDLGELEMENTLB , <EOL> name = '<STR_LIT>' , parent = self , pos = wxPoint ( <NUM_LIT:8> , <NUM_LIT> ) , <EOL> size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> , validator = wxDefaultValidator ) <EOL> self . elementLb . SetConstraints ( LayoutAnchors ( self . elementLb , true , true , <EOL> true , false ) ) <EOL> self . elementLb . SetHelpText ( '<STR_LIT>' ) <EOL> EVT_LISTBOX ( self . elementLb , wxID_STCSTYLEEDITDLGELEMENTLB , <EOL> self . OnElementlbListbox ) <EOL> self . addCommonItemBtn = wxButton ( id = wxID_STCSTYLEEDITDLGADDCOMMONITEMBTN , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self , pos = wxPoint ( <NUM_LIT:8> , <EOL> <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> ) <EOL> self . addCommonItemBtn . SetToolTipString ( '<STR_LIT>' ) <EOL> EVT_BUTTON ( self . addCommonItemBtn , wxID_STCSTYLEEDITDLGADDCOMMONITEMBTN , <EOL> self . OnAddsharebtnButton ) <EOL> self . removeCommonItemBtn = wxButton ( id = wxID_STCSTYLEEDITDLGREMOVECOMMONITEMBTN , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self , <EOL> pos = wxPoint ( <NUM_LIT> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> ) <EOL> self . removeCommonItemBtn . SetToolTipString ( '<STR_LIT>' ) <EOL> EVT_BUTTON ( self . removeCommonItemBtn , <EOL> wxID_STCSTYLEEDITDLGREMOVECOMMONITEMBTN , <EOL> self . OnRemovesharebtnButton ) <EOL> self . styleDefST = wxStaticText ( id = wxID_STCSTYLEEDITDLGSTYLEDEFST , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self , <EOL> pos = wxPoint ( <NUM_LIT> , <NUM_LIT:8> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT:16> ) , <EOL> style = wxST_NO_AUTORESIZE ) <EOL> self . styleDefST . SetFont ( wxFont ( self . style_font_size , wxSWISS , wxNORMAL , <EOL> wxBOLD , false , '<STR_LIT>' ) ) <EOL> self . styleDefST . SetConstraints ( LayoutAnchors ( self . styleDefST , true , <EOL> true , true , false ) ) <EOL> self . staticLine1 = wxStaticLine ( id = wxID_STCSTYLEEDITDLGSTATICLINE1 , <EOL> name = '<STR_LIT>' , parent = self , pos = wxPoint ( <NUM_LIT> , <NUM_LIT> ) , <EOL> size = wxSize ( <NUM_LIT> , <NUM_LIT:2> ) , style = wxLI_HORIZONTAL ) <EOL> self . staticLine1 . SetConstraints ( LayoutAnchors ( self . staticLine1 , true , <EOL> true , true , false ) ) <EOL> self . staticText6 = wxStaticText ( id = wxID_STCSTYLEEDITDLGSTATICTEXT6 , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self , pos = wxPoint ( <NUM_LIT:8> , <EOL> <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> ) <EOL> self . staticText8 = wxStaticText ( id = wxID_STCSTYLEEDITDLGSTATICTEXT8 , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self , <EOL> pos = wxPoint ( <NUM_LIT:8> , <NUM_LIT:8> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> ) <EOL> self . staticText9 = wxStaticText ( id = wxID_STCSTYLEEDITDLGSTATICTEXT9 , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self , <EOL> pos = wxPoint ( <NUM_LIT:8> , <NUM_LIT:32> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> ) <EOL> self . panel3 = wxPanel ( id = wxID_STCSTYLEEDITDLGPANEL3 , name = '<STR_LIT>' , <EOL> parent = self , pos = wxPoint ( <NUM_LIT> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , <EOL> style = wxTAB_TRAVERSAL ) <EOL> self . panel3 . SetConstraints ( LayoutAnchors ( self . panel3 , false , true , true , <EOL> false ) ) <EOL> self . panel4 = wxPanel ( id = wxID_STCSTYLEEDITDLGPANEL4 , name = '<STR_LIT>' , <EOL> parent = self , pos = wxPoint ( <NUM_LIT> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , <EOL> style = wxTAB_TRAVERSAL ) <EOL> self . panel4 . SetConstraints ( LayoutAnchors ( self . panel4 , false , true , true , <EOL> false ) ) <EOL> self . panel1 = wxPanel ( id = wxID_STCSTYLEEDITDLGPANEL1 , name = '<STR_LIT>' , <EOL> parent = self , pos = wxPoint ( <NUM_LIT> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , <EOL> style = wxTAB_TRAVERSAL ) <EOL> self . panel1 . SetConstraints ( LayoutAnchors ( self . panel1 , false , true , true , <EOL> false ) ) <EOL> self . panel2 = wxPanel ( id = wxID_STCSTYLEEDITDLGPANEL2 , name = '<STR_LIT>' , <EOL> parent = self , pos = wxPoint ( <NUM_LIT> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , <EOL> style = wxTAB_TRAVERSAL ) <EOL> self . panel2 . SetConstraints ( LayoutAnchors ( self . panel2 , false , true , true , <EOL> false ) ) <EOL> self . stc = wxStyledTextCtrl ( id = wxID_STCSTYLEEDITDLGSTC , name = '<STR_LIT>' , <EOL> parent = self , pos = wxPoint ( <NUM_LIT:8> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , <EOL> style = wxSUNKEN_BORDER ) <EOL> self . stc . SetConstraints ( LayoutAnchors ( self . stc , true , true , true , true ) ) <EOL> self . stc . SetHelpText ( '<STR_LIT>' ) <EOL> EVT_LEFT_UP ( self . stc , self . OnUpdateUI ) <EOL> EVT_KEY_UP ( self . stc , self . OnUpdateUI ) <EOL> self . contextHelpButton1 = wxContextHelpButton ( parent = self , <EOL> pos = wxPoint ( <NUM_LIT:8> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = wxBU_AUTODRAW ) <EOL> self . contextHelpButton1 . SetConstraints ( LayoutAnchors ( self . contextHelpButton1 , <EOL> true , false , false , true ) ) <EOL> self . okBtn = wxButton ( id = wxID_STCSTYLEEDITDLGOKBTN , label = '<STR_LIT:OK>' , <EOL> name = '<STR_LIT>' , parent = self , pos = wxPoint ( <NUM_LIT> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <EOL> <NUM_LIT> ) , style = <NUM_LIT:0> ) <EOL> self . okBtn . SetConstraints ( LayoutAnchors ( self . okBtn , false , false , true , <EOL> true ) ) <EOL> self . okBtn . SetToolTipString ( '<STR_LIT>' ) <EOL> EVT_BUTTON ( self . okBtn , wxID_STCSTYLEEDITDLGOKBTN , self . OnOkbtnButton ) <EOL> self . cancelBtn = wxButton ( id = wxID_STCSTYLEEDITDLGCANCELBTN , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self , pos = wxPoint ( <NUM_LIT> , <EOL> <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> ) <EOL> self . cancelBtn . SetConstraints ( LayoutAnchors ( self . cancelBtn , false , <EOL> false , true , true ) ) <EOL> self . cancelBtn . SetToolTipString ( '<STR_LIT>' ) <EOL> EVT_BUTTON ( self . cancelBtn , wxID_STCSTYLEEDITDLGCANCELBTN , <EOL> self . OnCancelbtnButton ) <EOL> self . staticText4 = wxStaticText ( id = wxID_STCSTYLEEDITDLGSTATICTEXT4 , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self . panel1 , <EOL> pos = wxPoint ( <NUM_LIT:0> , <NUM_LIT:0> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> ) <EOL> self . fixedWidthChk = wxCheckBox ( id = wxID_STCSTYLEEDITDLGFIXEDWIDTHCHK , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self . panel1 , pos = wxPoint ( <NUM_LIT:0> , <EOL> <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> ) <EOL> self . fixedWidthChk . SetToolTipString ( '<STR_LIT>' ) <EOL> EVT_CHECKBOX ( self . fixedWidthChk , wxID_STCSTYLEEDITDLGFIXEDWIDTHCHK , <EOL> self . OnFixedwidthchkCheckbox ) <EOL> self . faceCb = wxComboBox ( choices = [ ] , id = wxID_STCSTYLEEDITDLGFACECB , <EOL> name = '<STR_LIT>' , parent = self . panel1 , pos = wxPoint ( <NUM_LIT> , <NUM_LIT> ) , <EOL> size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> , validator = wxDefaultValidator , <EOL> value = '<STR_LIT>' ) <EOL> self . staticText7 = wxStaticText ( id = wxID_STCSTYLEEDITDLGSTATICTEXT7 , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self . panel2 , <EOL> pos = wxPoint ( <NUM_LIT:0> , <NUM_LIT:0> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> ) <EOL> self . sizeCb = wxComboBox ( choices = [ ] , id = wxID_STCSTYLEEDITDLGSIZECB , <EOL> name = '<STR_LIT>' , parent = self . panel2 , pos = wxPoint ( <NUM_LIT:0> , <NUM_LIT> ) , <EOL> size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> , validator = wxDefaultValidator , <EOL> value = '<STR_LIT>' ) <EOL> self . sizeOkBtn = wxButton ( id = wxID_STCSTYLEEDITDLGSIZEOKBTN , label = '<STR_LIT>' , <EOL> name = '<STR_LIT>' , parent = self . panel2 , pos = wxPoint ( <NUM_LIT> , <NUM_LIT> ) , <EOL> size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> ) <EOL> self . faceOkBtn = wxButton ( id = wxID_STCSTYLEEDITDLGFACEOKBTN , label = '<STR_LIT>' , <EOL> name = '<STR_LIT>' , parent = self . panel1 , pos = wxPoint ( <NUM_LIT> , <NUM_LIT> ) , <EOL> size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> ) <EOL> self . fgColBtn = wxButton ( id = wxID_STCSTYLEEDITDLGFGCOLBTN , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self . panel3 , <EOL> pos = wxPoint ( <NUM_LIT:8> , <NUM_LIT:16> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT:16> ) , style = <NUM_LIT:0> ) <EOL> EVT_BUTTON ( self . fgColBtn , wxID_STCSTYLEEDITDLGFGCOLBTN , <EOL> self . OnFgcolbtnButton ) <EOL> self . fgColCb = wxComboBox ( choices = [ ] , id = wxID_STCSTYLEEDITDLGFGCOLCB , <EOL> name = '<STR_LIT>' , parent = self . panel3 , pos = wxPoint ( <NUM_LIT:8> , <NUM_LIT:32> ) , <EOL> size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> , validator = wxDefaultValidator , <EOL> value = '<STR_LIT>' ) <EOL> self . fgColOkBtn = wxButton ( id = wxID_STCSTYLEEDITDLGFGCOLOKBTN , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self . panel3 , pos = wxPoint ( <NUM_LIT> , <EOL> <NUM_LIT:32> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> ) <EOL> self . staticText3 = wxStaticText ( id = wxID_STCSTYLEEDITDLGSTATICTEXT3 , <EOL> label = '<STR_LIT:default>' , name = '<STR_LIT>' , parent = self . panel3 , <EOL> pos = wxPoint ( <NUM_LIT:100> , <NUM_LIT:16> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT:16> ) , style = <NUM_LIT:0> ) <EOL> self . fgColDefCb = wxCheckBox ( id = wxID_STCSTYLEEDITDLGFGCOLDEFCB , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self . panel3 , <EOL> pos = wxPoint ( <NUM_LIT> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT:16> , <NUM_LIT:16> ) , style = <NUM_LIT:0> ) <EOL> self . bgColBtn = wxButton ( id = wxID_STCSTYLEEDITDLGBGCOLBTN , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self . panel3 , <EOL> pos = wxPoint ( <NUM_LIT:8> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT:16> ) , style = <NUM_LIT:0> ) <EOL> EVT_BUTTON ( self . bgColBtn , wxID_STCSTYLEEDITDLGBGCOLBTN , <EOL> self . OnBgcolbtnButton ) <EOL> self . bgColCb = wxComboBox ( choices = [ ] , id = wxID_STCSTYLEEDITDLGBGCOLCB , <EOL> name = '<STR_LIT>' , parent = self . panel3 , pos = wxPoint ( <NUM_LIT:8> , <NUM_LIT> ) , <EOL> size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> , validator = wxDefaultValidator , <EOL> value = '<STR_LIT>' ) <EOL> self . bgColOkBtn = wxButton ( id = wxID_STCSTYLEEDITDLGBGCOLOKBTN , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self . panel3 , pos = wxPoint ( <NUM_LIT> , <EOL> <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> ) <EOL> self . staticBox2 = wxStaticBox ( id = wxID_STCSTYLEEDITDLGSTATICBOX2 , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self . panel4 , <EOL> pos = wxPoint ( <NUM_LIT:0> , <NUM_LIT:0> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> ) <EOL> self . staticBox2 . SetConstraints ( LayoutAnchors ( self . staticBox2 , false , <EOL> true , true , false ) ) <EOL> self . staticBox2 . SetHelpText ( '<STR_LIT>' ) <EOL> self . staticText2 = wxStaticText ( id = wxID_STCSTYLEEDITDLGSTATICTEXT2 , <EOL> label = '<STR_LIT:default>' , name = '<STR_LIT>' , parent = self . panel4 , <EOL> pos = wxPoint ( <NUM_LIT> , <NUM_LIT:11> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT:16> ) , style = <NUM_LIT:0> ) <EOL> self . taBoldDefCb = wxCheckBox ( id = wxID_STCSTYLEEDITDLGTABOLDDEFCB , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self . panel4 , <EOL> pos = wxPoint ( <NUM_LIT> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT:16> , <NUM_LIT:16> ) , style = <NUM_LIT:0> ) <EOL> self . taItalicDefCb = wxCheckBox ( id = wxID_STCSTYLEEDITDLGTAITALICDEFCB , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self . panel4 , <EOL> pos = wxPoint ( <NUM_LIT> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT:16> , <NUM_LIT:16> ) , style = <NUM_LIT:0> ) <EOL> self . taUnderlinedDefCb = wxCheckBox ( id = wxID_STCSTYLEEDITDLGTAUNDERLINEDDEFCB , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self . panel4 , <EOL> pos = wxPoint ( <NUM_LIT> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT:16> , <NUM_LIT:16> ) , style = <NUM_LIT:0> ) <EOL> self . taEOLfilledDefCb = wxCheckBox ( id = wxID_STCSTYLEEDITDLGTAEOLFILLEDDEFCB , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self . panel4 , <EOL> pos = wxPoint ( <NUM_LIT> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT:16> , <NUM_LIT:16> ) , style = <NUM_LIT:0> ) <EOL> self . taEOLfilledCb = wxCheckBox ( id = wxID_STCSTYLEEDITDLGTAEOLFILLEDCB , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self . panel4 , <EOL> pos = wxPoint ( <NUM_LIT:8> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT:16> ) , style = <NUM_LIT:0> ) <EOL> EVT_CHECKBOX ( self . taEOLfilledCb , wxID_STCSTYLEEDITDLGTAEOLFILLEDCB , <EOL> self . OnTaeoffilledcbCheckbox ) <EOL> self . taUnderlinedCb = wxCheckBox ( id = wxID_STCSTYLEEDITDLGTAUNDERLINEDCB , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self . panel4 , <EOL> pos = wxPoint ( <NUM_LIT:8> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT:16> ) , style = <NUM_LIT:0> ) <EOL> EVT_CHECKBOX ( self . taUnderlinedCb , wxID_STCSTYLEEDITDLGTAUNDERLINEDCB , <EOL> self . OnTaunderlinedcbCheckbox ) <EOL> self . taItalicCb = wxCheckBox ( id = wxID_STCSTYLEEDITDLGTAITALICCB , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self . panel4 , <EOL> pos = wxPoint ( <NUM_LIT:8> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT:16> ) , style = <NUM_LIT:0> ) <EOL> EVT_CHECKBOX ( self . taItalicCb , wxID_STCSTYLEEDITDLGTAITALICCB , <EOL> self . OnTaitaliccbCheckbox ) <EOL> self . taBoldCb = wxCheckBox ( id = wxID_STCSTYLEEDITDLGTABOLDCB , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self . panel4 , pos = wxPoint ( <NUM_LIT:8> , <EOL> <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT:16> ) , style = <NUM_LIT:0> ) <EOL> EVT_CHECKBOX ( self . taBoldCb , wxID_STCSTYLEEDITDLGTABOLDCB , <EOL> self . OnTaboldcbCheckbox ) <EOL> self . bgColDefCb = wxCheckBox ( id = wxID_STCSTYLEEDITDLGBGCOLDEFCB , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self . panel3 , <EOL> pos = wxPoint ( <NUM_LIT> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT:16> , <NUM_LIT:16> ) , style = <NUM_LIT:0> ) <EOL> self . staticBox1 = wxStaticBox ( id = wxID_STCSTYLEEDITDLGSTATICBOX1 , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self . panel3 , <EOL> pos = wxPoint ( <NUM_LIT:0> , <NUM_LIT:0> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> ) <EOL> self . staticBox1 . SetConstraints ( LayoutAnchors ( self . staticBox1 , false , <EOL> true , true , false ) ) <EOL> self . faceDefCb = wxCheckBox ( id = wxID_STCSTYLEEDITDLGFACEDEFCB , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self . panel1 , <EOL> pos = wxPoint ( <NUM_LIT> , <NUM_LIT:0> ) , size = wxSize ( <NUM_LIT:16> , <NUM_LIT:16> ) , style = <NUM_LIT:0> ) <EOL> self . taSizeDefCb = wxCheckBox ( id = wxID_STCSTYLEEDITDLGTASIZEDEFCB , <EOL> label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self . panel2 , <EOL> pos = wxPoint ( <NUM_LIT> , <NUM_LIT:0> ) , size = wxSize ( <NUM_LIT:16> , <NUM_LIT:16> ) , style = <NUM_LIT:0> ) <EOL> def __init__ ( self , parent , langTitle , lang , configFile , STCsToUpdate = ( ) ) : <EOL> self . stc_title = '<STR_LIT>' <EOL> self . stc_title = '<STR_LIT>' % langTitle <EOL> if wxPlatform == '<STR_LIT>' : <EOL> self . style_font_size = <NUM_LIT:8> <EOL> else : <EOL> self . style_font_size = <NUM_LIT:10> <EOL> self . _init_ctrls ( parent ) <EOL> self . lang = lang <EOL> self . configFile = configFile <EOL> self . style = '<STR_LIT>' <EOL> self . styleNum = <NUM_LIT:0> <EOL> self . names = [ ] <EOL> self . values = { } <EOL> self . STCsToUpdate = STCsToUpdate <EOL> self . _blockUpdate = false <EOL> for combo , okBtn , evtRet , evtCB , evtRDC in ( <EOL> ( self . fgColCb , self . fgColOkBtn , self . OnfgColRet , self . OnfgColCombobox , self . OnGotoCommonDef ) , <EOL> ( self . bgColCb , self . bgColOkBtn , self . OnbgColRet , self . OnbgColCombobox , self . OnGotoCommonDef ) , <EOL> ( self . faceCb , self . faceOkBtn , self . OnfaceRet , self . OnfaceCombobox , self . OnGotoCommonDef ) , <EOL> ( self . sizeCb , self . sizeOkBtn , self . OnsizeRet , self . OnsizeCombobox , self . OnGotoCommonDef ) ) : <EOL> self . bindComboEvts ( combo , okBtn , evtRet , evtCB , evtRDC ) <EOL> ( self . config , self . commonDefs , self . styleIdNames , self . styles , <EOL> self . styleGroupNames , self . predefStyleGroups , <EOL> self . otherLangStyleGroupNames , self . otherLangStyleGroups , <EOL> self . displaySrc , self . lexer , self . keywords , self . braceInfo ) = initFromConfig ( configFile , lang ) <EOL> self . currSpeedSetting = '<STR_LIT>' % self . lang <EOL> for grp in [ self . currSpeedSetting ] + self . styleGroupNames : <EOL> self . speedsettingCh . Append ( grp ) <EOL> self . speedsettingCh . SetSelection ( <NUM_LIT:0> ) <EOL> margin = <NUM_LIT:0> <EOL> self . stc . SetMarginType ( margin , wxSTC_MARGIN_NUMBER ) <EOL> self . stc . SetMarginWidth ( margin , <NUM_LIT> ) <EOL> self . stc . SetMarginSensitive ( margin , true ) <EOL> EVT_STC_MARGINCLICK ( self . stc , wxID_STCSTYLEEDITDLGSTC , self . OnMarginClick ) <EOL> self . stc . SetUseTabs ( false ) <EOL> self . stc . SetTabWidth ( <NUM_LIT:4> ) <EOL> self . stc . SetIndentationGuides ( true ) <EOL> self . stc . SetEdgeMode ( wxSTC_EDGE_BACKGROUND ) <EOL> self . stc . SetEdgeColumn ( <NUM_LIT> ) <EOL> self . setStyles ( ) <EOL> self . populateStyleSelector ( ) <EOL> self . defNames , self . defValues = parseProp ( self . styleDict . get ( wxSTC_STYLE_DEFAULT , '<STR_LIT>' ) ) <EOL> self . stc . SetText ( self . displaySrc ) <EOL> self . stc . EmptyUndoBuffer ( ) <EOL> self . stc . SetCurrentPos ( self . stc . GetTextLength ( ) ) <EOL> self . stc . SetAnchor ( self . stc . GetTextLength ( ) ) <EOL> self . populateCombosWithCommonDefs ( ) <EOL> self . allCtrls = [ ( ( self . fgColBtn , self . fgColCb , self . fgColOkBtn ) , self . fgColDefCb , <EOL> '<STR_LIT>' , wxID_STCSTYLEEDITDLGFGCOLDEFCB ) , <EOL> ( ( self . bgColBtn , self . bgColCb , self . bgColOkBtn ) , self . bgColDefCb , <EOL> '<STR_LIT>' , wxID_STCSTYLEEDITDLGBGCOLDEFCB ) , <EOL> ( self . taBoldCb , self . taBoldDefCb , <EOL> '<STR_LIT>' , wxID_STCSTYLEEDITDLGTABOLDDEFCB ) , <EOL> ( self . taItalicCb , self . taItalicDefCb , <EOL> '<STR_LIT>' , wxID_STCSTYLEEDITDLGTAITALICDEFCB ) , <EOL> ( self . taUnderlinedCb , self . taUnderlinedDefCb , <EOL> '<STR_LIT>' , wxID_STCSTYLEEDITDLGTAUNDERLINEDDEFCB ) , <EOL> ( self . taEOLfilledCb , self . taEOLfilledDefCb , <EOL> '<STR_LIT>' , wxID_STCSTYLEEDITDLGTAEOLFILLEDDEFCB ) , <EOL> ( ( self . sizeCb , self . sizeOkBtn ) , self . taSizeDefCb , <EOL> '<STR_LIT:size>' , wxID_STCSTYLEEDITDLGTASIZEDEFCB ) , <EOL> ( ( self . faceCb , self . faceOkBtn , self . fixedWidthChk ) , self . faceDefCb , <EOL> '<STR_LIT>' , wxID_STCSTYLEEDITDLGFACEDEFCB ) ] <EOL> self . clearCtrls ( disableDefs = true ) <EOL> self . chbIdMap = { } <EOL> for ctrl , chb , prop , wid in self . allCtrls : <EOL> self . chbIdMap [ wid ] = ctrl , chb , prop , wid <EOL> EVT_CHECKBOX ( chb , wid , self . OnDefaultCheckBox ) <EOL> chb . SetToolTipString ( '<STR_LIT>' ) <EOL> self . Center ( wxBOTH ) <EOL> def getCtrlForProp ( self , findprop ) : <EOL> for ctrl , chb , prop , wid in self . allCtrls : <EOL> if findprop == prop : <EOL> return ctrl , chb <EOL> raise Exception ( '<STR_LIT>' , findprop ) <EOL> def editProp ( self , on , prop , val = '<STR_LIT>' ) : <EOL> oldstyle = self . rememberStyles ( ) <EOL> if on : <EOL> if not self . names . count ( prop ) : <EOL> self . names . append ( prop ) <EOL> self . values [ prop ] = val <EOL> else : <EOL> try : self . names . remove ( prop ) <EOL> except ValueError : pass <EOL> try : del self . values [ prop ] <EOL> except KeyError : pass <EOL> try : <EOL> self . updateStyle ( ) <EOL> return true <EOL> except KeyError , errkey : <EOL> wxLogError ( '<STR_LIT>' '<STR_LIT>' % errkey ) <EOL> self . restoreStyles ( oldstyle ) <EOL> return false <EOL> def setStyles ( self ) : <EOL> if self . _blockUpdate : return <EOL> self . styles , self . styleDict , self . styleNumIdxMap = setSTCStyles ( self . stc , self . styles , self . styleIdNames , <EOL> self . commonDefs , self . lang , self . lexer , self . keywords ) <EOL> def updateStyle ( self ) : <EOL> if self . styleNum == '<STR_LIT>' : <EOL> strVal = self . style [ <NUM_LIT:2> ] = self . values . values ( ) [ <NUM_LIT:0> ] <EOL> if self . style [ <NUM_LIT:1> ] == '<STR_LIT:size>' : self . style [ <NUM_LIT:2> ] = int ( strVal ) <EOL> self . commonDefs [ self . style [ <NUM_LIT:0> ] ] = self . style [ <NUM_LIT:2> ] <EOL> self . styleDefST . SetLabel ( strVal ) <EOL> else : <EOL> self . style = writePropVal ( self . names , self . values ) <EOL> styleDecl = writeProp ( self . styleNum , self . style , self . lang ) <EOL> self . styles [ self . styleNumIdxMap [ self . styleNum ] ] = styleDecl <EOL> self . styleDefST . SetLabel ( self . style ) <EOL> self . setStyles ( ) <EOL> def findInStyles ( self , txt , styles ) : <EOL> for style in styles : <EOL> if string . find ( style , txt ) != - <NUM_LIT:1> : <EOL> return true <EOL> return false <EOL> def rememberStyles ( self ) : <EOL> return self . names [ : ] , copy . copy ( self . values ) <EOL> def restoreStyles ( self , style ) : <EOL> self . names , self . values = style <EOL> self . updateStyle ( ) <EOL> def clearCtrls ( self , isDefault = false , disableDefs = false ) : <EOL> self . _blockUpdate = true <EOL> try : <EOL> for ctrl , chb , prop , wid in self . allCtrls : <EOL> if prop in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> cbtn , txt , btn = ctrl <EOL> cbtn . SetBackgroundColour ( wxSystemSettings_GetSystemColour ( wxSYS_COLOUR_BTNFACE ) ) <EOL> cbtn . SetForegroundColour ( wxColour ( <NUM_LIT:255> , <NUM_LIT:255> , <NUM_LIT:255> ) ) <EOL> cbtn . Enable ( isDefault ) <EOL> txt . SetValue ( '<STR_LIT>' ) <EOL> txt . Enable ( isDefault ) <EOL> btn . Enable ( isDefault ) <EOL> elif prop == '<STR_LIT:size>' : <EOL> cmb , btn = ctrl <EOL> cmb . SetValue ( '<STR_LIT>' ) <EOL> cmb . Enable ( isDefault ) <EOL> btn . Enable ( isDefault ) <EOL> elif prop == '<STR_LIT>' : <EOL> cmb , btn , chk = ctrl <EOL> cmb . SetValue ( '<STR_LIT>' ) <EOL> cmb . Enable ( isDefault ) <EOL> btn . Enable ( isDefault ) <EOL> chk . Enable ( isDefault ) <EOL> chk . SetValue ( false ) <EOL> elif prop in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> ctrl . SetValue ( false ) <EOL> ctrl . Enable ( isDefault ) <EOL> chb . Enable ( not isDefault and not disableDefs ) <EOL> chb . SetValue ( true ) <EOL> finally : <EOL> self . _blockUpdate = false <EOL> def populateProp ( self , items , default , forceDisable = false ) : <EOL> self . _blockUpdate = true <EOL> try : <EOL> for name , val in items : <EOL> if name : <EOL> ctrl , chb = self . getCtrlForProp ( name ) <EOL> if name in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> cbtn , txt , btn = ctrl <EOL> repval = val % self . commonDefs <EOL> cbtn . SetBackgroundColour ( strToCol ( repval ) ) <EOL> cbtn . SetForegroundColour ( wxColour ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> cbtn . Enable ( not forceDisable ) <EOL> txt . SetValue ( val ) <EOL> txt . Enable ( not forceDisable ) <EOL> btn . Enable ( not forceDisable ) <EOL> chb . SetValue ( default ) <EOL> elif name == '<STR_LIT:size>' : <EOL> cmb , btn = ctrl <EOL> cmb . SetValue ( val ) <EOL> cmb . Enable ( not forceDisable ) <EOL> btn . Enable ( not forceDisable ) <EOL> chb . SetValue ( default ) <EOL> elif name == '<STR_LIT>' : <EOL> cmb , btn , chk = ctrl <EOL> cmb . SetValue ( val ) <EOL> cmb . Enable ( not forceDisable ) <EOL> btn . Enable ( not forceDisable ) <EOL> chk . Enable ( not forceDisable ) <EOL> chb . SetValue ( default ) <EOL> elif name in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> ctrl . Enable ( not forceDisable ) <EOL> ctrl . SetValue ( true ) <EOL> chb . SetValue ( default ) <EOL> finally : <EOL> self . _blockUpdate = false <EOL> def valIsCommonDef ( self , val ) : <EOL> return len ( val ) >= <NUM_LIT:5> and val [ : <NUM_LIT:2> ] == '<STR_LIT>' <EOL> def populateCtrls ( self ) : <EOL> self . clearCtrls ( self . styleNum == wxSTC_STYLE_DEFAULT , <EOL> disableDefs = self . styleNum < <NUM_LIT:0> ) <EOL> if self . styleNum < <NUM_LIT:0> : <EOL> self . fgColDefCb . Enable ( true ) <EOL> if self . styleNum == - <NUM_LIT:1> : <EOL> self . bgColDefCb . Enable ( true ) <EOL> self . populateProp ( self . defValues . items ( ) , true , <EOL> self . styleNum != wxSTC_STYLE_DEFAULT ) <EOL> self . populateProp ( self . values . items ( ) , false ) <EOL> def getCommonDefPropType ( self , commonDefName ) : <EOL> val = self . commonDefs [ commonDefName ] <EOL> if type ( val ) == type ( <NUM_LIT:0> ) : return '<STR_LIT:size>' <EOL> if len ( val ) == <NUM_LIT:7> and val [ <NUM_LIT:0> ] == '<STR_LIT:#>' : return '<STR_LIT>' <EOL> return '<STR_LIT>' <EOL> def bindComboEvts ( self , combo , btn , btnEvtMeth , comboEvtMeth , rdclickEvtMeth ) : <EOL> EVT_COMBOBOX ( combo , combo . GetId ( ) , comboEvtMeth ) <EOL> EVT_BUTTON ( btn , btn . GetId ( ) , btnEvtMeth ) <EOL> EVT_RIGHT_DCLICK ( combo , rdclickEvtMeth ) <EOL> combo . SetToolTipString ( '<STR_LIT>' '<STR_LIT>' ) <EOL> btn . SetToolTipString ( '<STR_LIT>' ) <EOL> def populateCombosWithCommonDefs ( self , fixedWidthOnly = None ) : <EOL> self . _blockUpdate = true <EOL> try : <EOL> commonDefs = { '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] , '<STR_LIT:size>' : [ ] } <EOL> if self . elementLb . GetSelection ( ) < self . commonDefsStartIdx : <EOL> for common in self . commonDefs . keys ( ) : <EOL> prop = self . getCommonDefPropType ( common ) <EOL> commonDefs [ prop ] . append ( '<STR_LIT>' % ( common , <EOL> prop == '<STR_LIT:size>' and '<STR_LIT:d>' or '<STR_LIT:s>' ) ) <EOL> currFg , currBg = self . fgColCb . GetValue ( ) , self . bgColCb . GetValue ( ) <EOL> self . fgColCb . Clear ( ) ; self . bgColCb . Clear ( ) <EOL> for colCommonDef in commonDefs [ '<STR_LIT>' ] : <EOL> self . fgColCb . Append ( colCommonDef ) <EOL> self . bgColCb . Append ( colCommonDef ) <EOL> self . fgColCb . SetValue ( currFg ) ; self . bgColCb . SetValue ( currBg ) <EOL> if fixedWidthOnly is None : <EOL> fixedWidthOnly = self . fixedWidthChk . GetValue ( ) <EOL> fontEnum = wxFontEnumerator ( ) <EOL> fontEnum . EnumerateFacenames ( fixedWidthOnly = fixedWidthOnly ) <EOL> fontNameList = fontEnum . GetFacenames ( ) <EOL> currFace = self . faceCb . GetValue ( ) <EOL> self . faceCb . Clear ( ) <EOL> for colCommonDef in [ '<STR_LIT>' ] + fontNameList + commonDefs [ '<STR_LIT>' ] : <EOL> self . faceCb . Append ( colCommonDef ) <EOL> self . faceCb . SetValue ( currFace ) <EOL> currSize = self . sizeCb . GetValue ( ) <EOL> self . sizeCb . Clear ( ) <EOL> for colCommonDef in commonDefs [ '<STR_LIT:size>' ] : <EOL> self . sizeCb . Append ( colCommonDef ) <EOL> self . sizeCb . SetValue ( currSize ) <EOL> finally : <EOL> self . _blockUpdate = false <EOL> def populateStyleSelector ( self ) : <EOL> numStyles = self . styleIdNames . items ( ) <EOL> numStyles . sort ( ) <EOL> self . styleNumLookup = { } <EOL> stdStart = - <NUM_LIT:1> <EOL> stdOffset = <NUM_LIT:0> <EOL> extrOffset = <NUM_LIT:0> <EOL> for num , name in numStyles : <EOL> if num == wxSTC_STYLE_DEFAULT : <EOL> self . elementLb . InsertItems ( [ name , '<STR_LIT>' ] , <NUM_LIT:0> ) <EOL> self . elementLb . Append ( '<STR_LIT>' ) <EOL> stdStart = stdPos = self . elementLb . Number ( ) <EOL> else : <EOL> if num >= <NUM_LIT> and num < <NUM_LIT> : <EOL> self . elementLb . InsertItems ( [ name ] , stdStart + stdOffset ) <EOL> stdOffset = stdOffset + <NUM_LIT:1> <EOL> elif num >= <NUM_LIT> : <EOL> self . elementLb . InsertItems ( [ name ] , stdStart + extrOffset - <NUM_LIT:1> ) <EOL> extrOffset = extrOffset + <NUM_LIT:1> <EOL> else : <EOL> self . elementLb . Append ( name ) <EOL> self . styleNumLookup [ name ] = num <EOL> self . elementLb . Append ( '<STR_LIT>' ) <EOL> settings = settingsIdNames . items ( ) <EOL> settings . sort ( ) ; settings . reverse ( ) <EOL> for num , name in settings : <EOL> self . elementLb . Append ( name ) <EOL> self . styleNumLookup [ name ] = num <EOL> self . elementLb . Append ( '<STR_LIT>' ) <EOL> self . commonDefsStartIdx = self . elementLb . Number ( ) <EOL> for common in self . commonDefs . keys ( ) : <EOL> tpe = type ( self . commonDefs [ common ] ) <EOL> self . elementLb . Append ( '<STR_LIT>' + common + '<STR_LIT:)>' + ( tpe is type ( '<STR_LIT>' ) and '<STR_LIT:s>' or '<STR_LIT:d>' ) ) <EOL> self . styleNumLookup [ common ] = num <EOL> def getColourDlg ( self , colour , title = '<STR_LIT>' ) : <EOL> data = wxColourData ( ) <EOL> data . SetColour ( colour ) <EOL> data . SetChooseFull ( true ) <EOL> dlg = wxColourDialog ( self , data ) <EOL> try : <EOL> dlg . SetTitle ( title ) <EOL> if dlg . ShowModal ( ) == wxID_OK : <EOL> data = dlg . GetColourData ( ) <EOL> return data . GetColour ( ) <EOL> finally : <EOL> dlg . Destroy ( ) <EOL> return None <EOL> colDlgTitles = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } <EOL> def editColProp ( self , colBtn , colCb , prop ) : <EOL> col = self . getColourDlg ( colBtn . GetBackgroundColour ( ) , <EOL> self . colDlgTitles [ prop ] + '<STR_LIT>' ) <EOL> if col : <EOL> colBtn . SetForegroundColour ( wxColour ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> colBtn . SetBackgroundColour ( col ) <EOL> colStr = colToStr ( col ) <EOL> colCb . SetValue ( colStr ) <EOL> self . editProp ( true , prop , colStr ) <EOL> def OnFgcolbtnButton ( self , event ) : <EOL> self . editColProp ( self . fgColBtn , self . fgColCb , '<STR_LIT>' ) <EOL> def OnBgcolbtnButton ( self , event ) : <EOL> self . editColProp ( self . bgColBtn , self . bgColCb , '<STR_LIT>' ) <EOL> def editColTCProp ( self , colCb , colBtn , prop , val = None ) : <EOL> if val is None : <EOL> colStr = colCb . GetValue ( ) <EOL> else : <EOL> colStr = val <EOL> if colStr : <EOL> col = strToCol ( colStr % self . commonDefs ) <EOL> if self . editProp ( colStr != '<STR_LIT>' , prop , colStr ) : <EOL> if colStr : <EOL> colBtn . SetForegroundColour ( wxColour ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> colBtn . SetBackgroundColour ( col ) <EOL> else : <EOL> colBtn . SetForegroundColour ( wxColour ( <NUM_LIT:255> , <NUM_LIT:255> , <NUM_LIT:255> ) ) <EOL> colBtn . SetBackgroundColour ( wxSystemSettings_GetSystemColour ( wxSYS_COLOUR_BTNFACE ) ) <EOL> def OnfgColRet ( self , event ) : <EOL> try : self . editColTCProp ( self . fgColCb , self . fgColBtn , '<STR_LIT>' ) <EOL> except AssertionError : wxLogError ( '<STR_LIT>' ) <EOL> def OnfgColCombobox ( self , event ) : <EOL> if self . _blockUpdate : return <EOL> try : self . editColTCProp ( self . fgColCb , self . fgColBtn , '<STR_LIT>' , event . GetString ( ) ) <EOL> except AssertionError : wxLogError ( '<STR_LIT>' ) <EOL> def OnbgColRet ( self , event ) : <EOL> try : self . editColTCProp ( self . bgColCb , self . bgColBtn , '<STR_LIT>' ) <EOL> except AssertionError : wxLogError ( '<STR_LIT>' ) <EOL> def OnbgColCombobox ( self , event ) : <EOL> if self . _blockUpdate : return <EOL> try : self . editColTCProp ( self . bgColCb , self . bgColBtn , '<STR_LIT>' , event . GetString ( ) ) <EOL> except AssertionError : wxLogError ( '<STR_LIT>' ) <EOL> def OnTaeoffilledcbCheckbox ( self , event ) : <EOL> self . editProp ( event . IsChecked ( ) , '<STR_LIT>' ) <EOL> def OnTaitaliccbCheckbox ( self , event ) : <EOL> self . editProp ( event . IsChecked ( ) , '<STR_LIT>' ) <EOL> def OnTaboldcbCheckbox ( self , event ) : <EOL> self . editProp ( event . IsChecked ( ) , '<STR_LIT>' ) <EOL> def OnTaunderlinedcbCheckbox ( self , event ) : <EOL> self . editProp ( event . IsChecked ( ) , '<STR_LIT>' ) <EOL> def OnGotoCommonDef ( self , event ) : <EOL> val = event . GetEventObject ( ) . GetValue ( ) <EOL> if self . valIsCommonDef ( val ) : <EOL> idx = self . elementLb . FindString ( val ) <EOL> if idx != - <NUM_LIT:1> : <EOL> self . elementLb . SetSelection ( idx , true ) <EOL> self . OnElementlbListbox ( None ) <EOL> def OnfaceRet ( self , event ) : <EOL> self . setFace ( self . faceCb . GetValue ( ) ) <EOL> def OnfaceCombobox ( self , event ) : <EOL> if self . _blockUpdate : return <EOL> self . setFace ( event . GetString ( ) ) <EOL> def setFace ( self , val ) : <EOL> try : val % self . commonDefs <EOL> except KeyError : wxLogError ( '<STR_LIT>' ) <EOL> else : self . editProp ( val != '<STR_LIT>' , '<STR_LIT>' , val ) <EOL> def OnsizeRet ( self , event ) : <EOL> self . setSize ( self . sizeCb . GetValue ( ) ) <EOL> def OnsizeCombobox ( self , event ) : <EOL> if self . _blockUpdate : return <EOL> self . setSize ( event . GetString ( ) ) <EOL> def setSize ( self , val ) : <EOL> try : int ( val % self . commonDefs ) <EOL> except ValueError : wxLogError ( '<STR_LIT>' ) <EOL> except KeyError : wxLogError ( '<STR_LIT>' ) <EOL> else : self . editProp ( val != '<STR_LIT>' , '<STR_LIT:size>' , val ) <EOL> def OnElementlbListbox ( self , event ) : <EOL> isCommon = self . elementLb . GetSelection ( ) >= self . commonDefsStartIdx <EOL> self . removeCommonItemBtn . Enable ( isCommon ) <EOL> styleIdent = self . elementLb . GetStringSelection ( ) <EOL> if isCommon : <EOL> common = styleIdent [ <NUM_LIT:2> : - <NUM_LIT:2> ] <EOL> prop = self . getCommonDefPropType ( common ) <EOL> self . clearCtrls ( disableDefs = true ) <EOL> if prop == '<STR_LIT>' : <EOL> self . fgColBtn . Enable ( true ) <EOL> self . fgColCb . Enable ( true ) <EOL> self . fgColOkBtn . Enable ( true ) <EOL> elif prop == '<STR_LIT>' : <EOL> self . faceCb . Enable ( true ) <EOL> self . fixedWidthChk . Enable ( true ) <EOL> self . faceOkBtn . Enable ( true ) <EOL> elif prop == '<STR_LIT:size>' : <EOL> self . sizeCb . Enable ( true ) <EOL> self . sizeOkBtn . Enable ( true ) <EOL> commonDefVal = str ( self . commonDefs [ common ] ) <EOL> self . styleDefST . SetLabel ( commonDefVal ) <EOL> self . populateProp ( [ ( prop , commonDefVal ) ] , true ) <EOL> self . styleNum = '<STR_LIT>' <EOL> self . style = [ common , prop , commonDefVal ] <EOL> self . names , self . values = [ prop ] , { prop : commonDefVal } <EOL> elif len ( styleIdent ) >= <NUM_LIT:2> and styleIdent [ : <NUM_LIT:2> ] != '<STR_LIT>' : <EOL> self . styleNum = self . styleNumLookup [ styleIdent ] <EOL> self . style = self . styleDict [ self . styleNum ] <EOL> self . names , self . values = parseProp ( self . style ) <EOL> if self . styleNum == wxSTC_STYLE_DEFAULT : <EOL> self . defNames , self . defValues = self . names , self . values <EOL> self . checkBraces ( self . styleNum ) <EOL> self . styleDefST . SetLabel ( self . style ) <EOL> self . populateCtrls ( ) <EOL> else : <EOL> self . clearCtrls ( disableDefs = true ) <EOL> if styleIdent : <EOL> self . styleDefST . SetLabel ( styleCategoryDescriptions [ styleIdent ] ) <EOL> self . populateCombosWithCommonDefs ( ) <EOL> def OnDefaultCheckBox ( self , event ) : <EOL> if self . chbIdMap . has_key ( event . GetId ( ) ) : <EOL> ctrl , chb , prop , wid = self . chbIdMap [ event . GetId ( ) ] <EOL> restore = not event . IsChecked ( ) <EOL> if prop in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> cbtn , cmb , btn = ctrl <EOL> cbtn . Enable ( restore ) <EOL> cmb . Enable ( restore ) <EOL> btn . Enable ( restore ) <EOL> if restore : <EOL> colStr = cmb . GetValue ( ) <EOL> if colStr : self . editProp ( true , prop , colStr ) <EOL> else : <EOL> self . editProp ( false , prop ) <EOL> elif prop == '<STR_LIT:size>' : <EOL> cmb , btn = ctrl <EOL> val = cmb . GetValue ( ) <EOL> if val : self . editProp ( restore , prop , val ) <EOL> cmb . Enable ( restore ) <EOL> btn . Enable ( restore ) <EOL> elif prop == '<STR_LIT>' : <EOL> cmb , btn , chk = ctrl <EOL> val = cmb . GetStringSelection ( ) <EOL> if val : self . editProp ( restore , prop , val ) <EOL> cmb . Enable ( restore ) <EOL> btn . Enable ( restore ) <EOL> chk . Enable ( restore ) <EOL> elif prop in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> ctrl . Enable ( restore ) <EOL> if ctrl . GetValue ( ) : self . editProp ( restore , prop ) <EOL> def OnOkbtnButton ( self , event ) : <EOL> wxBeginBusyCursor ( ) <EOL> try : <EOL> writeStylesToConfig ( self . config , '<STR_LIT>' % self . lang , self . styles ) <EOL> self . config . SetPath ( '<STR_LIT>' ) <EOL> self . config . Write ( commonDefsFile , ` self . commonDefs ` ) <EOL> self . config . Flush ( ) <EOL> for stc in self . STCsToUpdate : <EOL> setSTCStyles ( stc , self . styles , self . styleIdNames , self . commonDefs , <EOL> self . lang , self . lexer , self . keywords ) <EOL> finally : <EOL> wxEndBusyCursor ( ) <EOL> self . EndModal ( wxID_OK ) <EOL> def OnCancelbtnButton ( self , event ) : <EOL> self . EndModal ( wxID_CANCEL ) <EOL> def OnCommondefsbtnButton ( self , event ) : <EOL> dlg = wxTextEntryDialog ( self , '<STR_LIT>' , <EOL> '<STR_LIT>' , pprint . pformat ( self . commonDefs ) , <EOL> style = wxTE_MULTILINE | wxOK | wxCANCEL | wxCENTRE ) <EOL> try : <EOL> if dlg . ShowModal ( ) == wxID_OK : <EOL> answer = eval ( dlg . GetValue ( ) , stc . __dict__ ) <EOL> assert type ( answer ) is type ( { } ) , '<STR_LIT>' <EOL> oldDefs = self . commonDefs <EOL> self . commonDefs = answer <EOL> try : <EOL> self . setStyles ( ) <EOL> except KeyError , badkey : <EOL> wxLogError ( str ( badkey ) + '<STR_LIT>' '<STR_LIT>' ) <EOL> self . commonDefs = oldDefs <EOL> self . setStyles ( ) <EOL> self . populateCombosWithCommonDefs ( ) <EOL> finally : <EOL> dlg . Destroy ( ) <EOL> def OnSpeedsettingchChoice ( self , event ) : <EOL> group = event . GetString ( ) <EOL> if group : <EOL> userStyles = '<STR_LIT>' % self . lang <EOL> if self . currSpeedSetting == userStyles : <EOL> self . predefStyleGroups [ userStyles ] = self . styles <EOL> self . styles = self . predefStyleGroups [ group ] <EOL> self . setStyles ( ) <EOL> self . defNames , self . defValues = parseProp ( self . styleDict . get ( wxSTC_STYLE_DEFAULT , '<STR_LIT>' ) ) <EOL> self . OnElementlbListbox ( None ) <EOL> self . currSpeedSetting = group <EOL> def OnFixedwidthchkCheckbox ( self , event ) : <EOL> self . populateCombosWithCommonDefs ( event . Checked ( ) ) <EOL> def OnAddsharebtnButton ( self , event ) : <EOL> dlg = CommonDefDlg ( self ) <EOL> try : <EOL> if dlg . ShowModal ( ) == wxID_OK : <EOL> prop , name = dlg . result <EOL> if not self . commonDefs . has_key ( name ) : <EOL> self . commonDefs [ name ] = commonPropDefs [ prop ] <EOL> self . elementLb . Append ( '<STR_LIT>' + name + '<STR_LIT:)>' + ( type ( commonPropDefs [ prop ] ) is type ( '<STR_LIT>' ) and '<STR_LIT:s>' or '<STR_LIT:d>' ) ) <EOL> self . elementLb . SetSelection ( self . elementLb . Number ( ) - <NUM_LIT:1> , true ) <EOL> self . populateCombosWithCommonDefs ( ) <EOL> self . OnElementlbListbox ( None ) <EOL> finally : <EOL> dlg . Destroy ( ) <EOL> def OnRemovesharebtnButton ( self , event ) : <EOL> ownGroup = '<STR_LIT>' % self . lang <EOL> comDef = self . elementLb . GetStringSelection ( ) <EOL> srchDct = { ownGroup : self . styles } <EOL> srchDct . update ( self . predefStyleGroups ) <EOL> srchDct . update ( self . otherLangStyleGroups ) <EOL> matchList = [ ] <EOL> for grpName , styles in srchDct . items ( ) : <EOL> if self . findInStyles ( comDef , styles ) : <EOL> matchList . append ( grpName ) <EOL> if matchList : <EOL> wxLogError ( '<STR_LIT>' + comDef + '<STR_LIT>' '<STR_LIT>' + string . join ( matchList , '<STR_LIT:\n>' ) ) <EOL> else : <EOL> del self . commonDefs [ comDef [ <NUM_LIT:2> : - <NUM_LIT:2> ] ] <EOL> self . setStyles ( ) <EOL> self . populateCombosWithCommonDefs ( ) <EOL> selIdx = self . elementLb . GetSelection ( ) <EOL> self . elementLb . Delete ( selIdx ) <EOL> if selIdx == self . elementLb . Number ( ) : <EOL> selIdx = selIdx - <NUM_LIT:1> <EOL> self . elementLb . SetSelection ( selIdx , true ) <EOL> self . OnElementlbListbox ( None ) <EOL> def OnUpdateUI ( self , event ) : <EOL> styleBefore = self . stc . GetStyleAt ( self . stc . GetCurrentPos ( ) ) <EOL> if self . styleIdNames . has_key ( styleBefore ) : <EOL> self . elementLb . SetStringSelection ( self . styleIdNames [ styleBefore ] , <EOL> true ) <EOL> else : <EOL> self . elementLb . SetSelection ( <NUM_LIT:0> , false ) <EOL> self . styleDefST . SetLabel ( '<STR_LIT>' % styleBefore ) <EOL> self . OnElementlbListbox ( None ) <EOL> event . Skip ( ) <EOL> def checkBraces ( self , style ) : <EOL> if style == wxSTC_STYLE_BRACELIGHT and self . braceInfo . has_key ( '<STR_LIT>' ) : <EOL> line , col = self . braceInfo [ '<STR_LIT>' ] <EOL> pos = self . stc . PositionFromLine ( line - <NUM_LIT:1> ) + col <EOL> braceOpposite = self . stc . BraceMatch ( pos ) <EOL> if braceOpposite != - <NUM_LIT:1> : <EOL> self . stc . BraceHighlight ( pos , braceOpposite ) <EOL> elif style == wxSTC_STYLE_BRACEBAD and self . braceInfo . has_key ( '<STR_LIT>' ) : <EOL> line , col = self . braceInfo [ '<STR_LIT>' ] <EOL> pos = self . stc . PositionFromLine ( line - <NUM_LIT:1> ) + col <EOL> self . stc . BraceBadLight ( pos ) <EOL> else : <EOL> self . stc . BraceBadLight ( - <NUM_LIT:1> ) <EOL> return <EOL> def OnStcstyleeditdlgSize ( self , event ) : <EOL> self . Layout ( ) <EOL> self . Refresh ( <NUM_LIT:1> ) <EOL> event . Skip ( ) <EOL> def OnMarginClick ( self , event ) : <EOL> self . elementLb . SetStringSelection ( '<STR_LIT>' , true ) <EOL> self . OnElementlbListbox ( None ) <EOL> [ wxID_COMMONDEFDLG , wxID_COMMONDEFDLGCANCELBTN , wxID_COMMONDEFDLGCOMDEFNAMETC , wxID_COMMONDEFDLGOKBTN , wxID_COMMONDEFDLGPROPTYPERBX , wxID_COMMONDEFDLGSTATICBOX1 ] = map ( lambda _init_ctrls : wxNewId ( ) , range ( <NUM_LIT:6> ) ) <EOL> class CommonDefDlg ( wxDialog ) : <EOL> def _init_ctrls ( self , prnt ) : <EOL> wxDialog . __init__ ( self , id = wxID_COMMONDEFDLG , name = '<STR_LIT>' , parent = prnt , pos = wxPoint ( <NUM_LIT> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = wxDEFAULT_DIALOG_STYLE , title = '<STR_LIT>' ) <EOL> self . SetClientSize ( wxSize ( <NUM_LIT> , <NUM_LIT:200> ) ) <EOL> self . propTypeRBx = wxRadioBox ( choices = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , id = wxID_COMMONDEFDLGPROPTYPERBX , label = '<STR_LIT>' , majorDimension = <NUM_LIT:1> , name = '<STR_LIT>' , parent = self , point = wxPoint ( <NUM_LIT:8> , <NUM_LIT:8> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = wxRA_SPECIFY_COLS , validator = wxDefaultValidator ) <EOL> self . propTypeRBx . SetSelection ( self . _propTypeIdx ) <EOL> self . staticBox1 = wxStaticBox ( id = wxID_COMMONDEFDLGSTATICBOX1 , label = '<STR_LIT:Name>' , name = '<STR_LIT>' , parent = self , pos = wxPoint ( <NUM_LIT:8> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> ) <EOL> self . comDefNameTC = wxTextCtrl ( id = wxID_COMMONDEFDLGCOMDEFNAMETC , name = '<STR_LIT>' , parent = self , pos = wxPoint ( <NUM_LIT:16> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> , value = '<STR_LIT>' ) <EOL> self . comDefNameTC . SetLabel ( self . _comDefName ) <EOL> self . okBtn = wxButton ( id = wxID_COMMONDEFDLGOKBTN , label = '<STR_LIT:OK>' , name = '<STR_LIT>' , parent = self , pos = wxPoint ( <NUM_LIT:8> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> ) <EOL> EVT_BUTTON ( self . okBtn , wxID_COMMONDEFDLGOKBTN , self . OnOkbtnButton ) <EOL> self . cancelBtn = wxButton ( id = wxID_COMMONDEFDLGCANCELBTN , label = '<STR_LIT>' , name = '<STR_LIT>' , parent = self , pos = wxPoint ( <NUM_LIT> , <NUM_LIT> ) , size = wxSize ( <NUM_LIT> , <NUM_LIT> ) , style = <NUM_LIT:0> ) <EOL> EVT_BUTTON ( self . cancelBtn , wxID_COMMONDEFDLGCANCELBTN , self . OnCancelbtnButton ) <EOL> def __init__ ( self , parent , name = '<STR_LIT>' , propIdx = <NUM_LIT:0> ) : <EOL> self . _comDefName = '<STR_LIT>' <EOL> self . _comDefName = name <EOL> self . _propTypeIdx = <NUM_LIT:0> <EOL> self . _propTypeIdx = propIdx <EOL> self . _init_ctrls ( parent ) <EOL> self . propMap = { <NUM_LIT:0> : '<STR_LIT>' , <NUM_LIT:1> : '<STR_LIT>' , <NUM_LIT:2> : '<STR_LIT:size>' } <EOL> self . result = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . Center ( wxBOTH ) <EOL> def OnOkbtnButton ( self , event ) : <EOL> self . result = ( self . propMap [ self . propTypeRBx . GetSelection ( ) ] , <EOL> self . comDefNameTC . GetValue ( ) ) <EOL> self . EndModal ( wxID_OK ) <EOL> def OnCancelbtnButton ( self , event ) : <EOL> self . result = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . EndModal ( wxID_CANCEL ) <EOL> def setSelectionColour ( stc , style ) : <EOL> names , values = parseProp ( style ) <EOL> if '<STR_LIT>' in names : <EOL> stc . SetSelForeground ( true , strToCol ( values [ '<STR_LIT>' ] ) ) <EOL> if '<STR_LIT>' in names : <EOL> stc . SetSelBackground ( true , strToCol ( values [ '<STR_LIT>' ] ) ) <EOL> def setCursorColour ( stc , style ) : <EOL> names , values = parseProp ( style ) <EOL> if '<STR_LIT>' in names : <EOL> stc . SetCaretForeground ( strToCol ( values [ '<STR_LIT>' ] ) ) <EOL> def setEdgeColour ( stc , style ) : <EOL> names , values = parseProp ( style ) <EOL> if '<STR_LIT>' in names : <EOL> stc . SetEdgeColour ( strToCol ( values [ '<STR_LIT>' ] ) ) <EOL> def strToCol ( strCol ) : <EOL> assert len ( strCol ) == <NUM_LIT:7> and strCol [ <NUM_LIT:0> ] == '<STR_LIT:#>' , '<STR_LIT>' <EOL> return wxColour ( string . atoi ( '<STR_LIT>' + strCol [ <NUM_LIT:1> : <NUM_LIT:3> ] , <NUM_LIT:16> ) , <EOL> string . atoi ( '<STR_LIT>' + strCol [ <NUM_LIT:3> : <NUM_LIT:5> ] , <NUM_LIT:16> ) , <EOL> string . atoi ( '<STR_LIT>' + strCol [ <NUM_LIT:5> : <NUM_LIT:7> ] , <NUM_LIT:16> ) ) <EOL> def colToStr ( col ) : <EOL> return '<STR_LIT>' % ( string . zfill ( string . upper ( hex ( col . Red ( ) ) [ <NUM_LIT:2> : ] ) , <NUM_LIT:2> ) , <EOL> string . zfill ( string . upper ( hex ( col . Green ( ) ) [ <NUM_LIT:2> : ] ) , <NUM_LIT:2> ) , <EOL> string . zfill ( string . upper ( hex ( col . Blue ( ) ) [ <NUM_LIT:2> : ] ) , <NUM_LIT:2> ) ) <EOL> def writeProp ( num , style , lang ) : <EOL> if num >= <NUM_LIT:0> : <EOL> return '<STR_LIT>' % ( lang , string . zfill ( ` num ` , <NUM_LIT:3> ) ) + style <EOL> else : <EOL> return '<STR_LIT>' % ( lang , num ) + style <EOL> def writePropVal ( names , values ) : <EOL> res = [ ] <EOL> for name in names : <EOL> if name : <EOL> res . append ( values [ name ] and name + '<STR_LIT::>' + values [ name ] or name ) <EOL> return string . join ( res , '<STR_LIT:U+002C>' ) <EOL> def parseProp ( prop ) : <EOL> items = string . split ( prop , '<STR_LIT:U+002C>' ) <EOL> names = [ ] <EOL> values = { } <EOL> for item in items : <EOL> nameVal = string . split ( item , '<STR_LIT::>' ) <EOL> names . append ( string . strip ( nameVal [ <NUM_LIT:0> ] ) ) <EOL> if len ( nameVal ) == <NUM_LIT:1> : <EOL> values [ nameVal [ <NUM_LIT:0> ] ] = '<STR_LIT>' <EOL> else : <EOL> values [ nameVal [ <NUM_LIT:0> ] ] = string . strip ( nameVal [ <NUM_LIT:1> ] ) <EOL> return names , values <EOL> def parsePropLine ( prop ) : <EOL> name , value = string . split ( prop , '<STR_LIT:=>' ) <EOL> return int ( string . split ( name , '<STR_LIT:.>' ) [ - <NUM_LIT:1> ] ) , value <EOL> def setSTCStyles ( stc , styles , styleIdNames , commonDefs , lang , lexer , keywords ) : <EOL> styleDict = { } <EOL> styleNumIdxMap = { } <EOL> for numStyle in styles : <EOL> num , style = parsePropLine ( numStyle ) <EOL> styleDict [ num ] = style <EOL> newStyles = [ ] <EOL> styleItems = styleIdNames . items ( ) + settingsIdNames . items ( ) <EOL> styleItems . sort ( ) <EOL> idx = <NUM_LIT:0> <EOL> for num , name in styleItems : <EOL> styleNumIdxMap [ num ] = idx <EOL> if not styleDict . has_key ( num ) : <EOL> styleDict [ num ] = '<STR_LIT>' <EOL> newStyles . append ( writeProp ( num , styleDict [ num ] , lang ) ) <EOL> idx = idx + <NUM_LIT:1> <EOL> bkCol = None <EOL> if styleDict . has_key ( <NUM_LIT:0> ) : prop = styleDict [ <NUM_LIT:0> ] <EOL> else : prop = styleDict [ wxSTC_STYLE_DEFAULT ] <EOL> names , vals = parseProp ( prop ) <EOL> if '<STR_LIT>' in names : <EOL> bkCol = strToCol ( vals [ '<STR_LIT>' ] ) <EOL> if bkCol is None : <EOL> bkCol = wxWHITE <EOL> stc . SetBackgroundColour ( bkCol ) <EOL> stc . StyleResetDefault ( ) <EOL> stc . ClearDocumentStyle ( ) <EOL> stc . SetLexer ( lexer ) <EOL> stc . SetKeyWords ( <NUM_LIT:0> , keywords ) <EOL> stc . StyleSetSpec ( wxSTC_STYLE_DEFAULT , <EOL> styleDict [ wxSTC_STYLE_DEFAULT ] % commonDefs ) <EOL> stc . StyleClearAll ( ) <EOL> for num , style in styleDict . items ( ) : <EOL> if num >= <NUM_LIT:0> : <EOL> stc . StyleSetSpec ( num , style % commonDefs ) <EOL> elif num == - <NUM_LIT:1> : <EOL> setSelectionColour ( stc , style % commonDefs ) <EOL> elif num == - <NUM_LIT:2> : <EOL> setCursorColour ( stc , style % commonDefs ) <EOL> elif num == - <NUM_LIT:3> : <EOL> setEdgeColour ( stc , style % commonDefs ) <EOL> stc . Colourise ( <NUM_LIT:0> , stc . GetTextLength ( ) ) <EOL> return newStyles , styleDict , styleNumIdxMap <EOL> commonDefsFile = '<STR_LIT>' % ( wxPlatform == '<STR_LIT>' and '<STR_LIT>' or '<STR_LIT>' ) <EOL> def readPyValFromConfig ( conf , name ) : <EOL> return eval ( string . replace ( conf . Read ( name ) , '<STR_LIT:\r\n>' , '<STR_LIT:\n>' ) + '<STR_LIT:\n>' , stc . __dict__ ) <EOL> configCache = None <EOL> def initFromConfig ( configFile , lang ) : <EOL> global configCache <EOL> if configCache is None : <EOL> configCache = __initFromConfig ( configFile , lang ) <EOL> return configCache <EOL> def __initFromConfig ( configFile , lang ) : <EOL> cfg = wxFileConfig ( localFilename = configFile , style = wxCONFIG_USE_LOCAL_FILE ) <EOL> cfg . SetExpandEnvVars ( false ) <EOL> groupPrefix = '<STR_LIT>' % lang <EOL> gpLen = len ( groupPrefix ) <EOL> predefStyleGroupNames , otherLangStyleGroupNames = [ ] , [ ] <EOL> cont , val , idx = cfg . GetFirstGroup ( ) <EOL> while cont : <EOL> if val != groupPrefix and len ( val ) >= <NUM_LIT:5> and val [ : <NUM_LIT:5> ] == '<STR_LIT>' : <EOL> if len ( val ) > gpLen and val [ : gpLen ] == groupPrefix : <EOL> predefStyleGroupNames . append ( val ) <EOL> else : <EOL> otherLangStyleGroupNames . append ( val ) <EOL> cont , val , idx = cfg . GetNextGroup ( idx ) <EOL> commonDefs = readPyValFromConfig ( cfg , commonDefsFile ) <EOL> assert type ( commonDefs ) is type ( { } ) , '<STR_LIT>' % commonDefsFile <EOL> commonStyleIdNames = readPyValFromConfig ( cfg , '<STR_LIT>' ) <EOL> assert type ( commonStyleIdNames ) is type ( { } ) , '<STR_LIT>' % '<STR_LIT>' <EOL> cfg . SetPath ( lang ) <EOL> styleIdNames = readPyValFromConfig ( cfg , '<STR_LIT>' ) <EOL> assert type ( commonStyleIdNames ) is type ( { } ) , '<STR_LIT>' % lang <EOL> styleIdNames . update ( commonStyleIdNames ) <EOL> braceInfo = readPyValFromConfig ( cfg , '<STR_LIT>' ) <EOL> assert type ( commonStyleIdNames ) is type ( { } ) , '<STR_LIT>' % lang <EOL> displaySrc = cfg . Read ( '<STR_LIT>' ) <EOL> lexer = readPyValFromConfig ( cfg , '<STR_LIT>' ) <EOL> keywords = cfg . Read ( '<STR_LIT>' ) <EOL> cfg . SetPath ( '<STR_LIT>' ) <EOL> styles = readStylesFromConfig ( cfg , groupPrefix ) <EOL> predefStyleGroups = { } <EOL> for group in predefStyleGroupNames : <EOL> predefStyleGroups [ group ] = readStylesFromConfig ( cfg , group ) <EOL> otherLangStyleGroups = { } <EOL> for group in otherLangStyleGroupNames : <EOL> otherLangStyleGroups [ group ] = readStylesFromConfig ( cfg , group ) <EOL> return ( cfg , commonDefs , styleIdNames , styles , predefStyleGroupNames , <EOL> predefStyleGroups , otherLangStyleGroupNames , otherLangStyleGroups , <EOL> displaySrc , lexer , keywords , braceInfo ) <EOL> def readStylesFromConfig ( config , group ) : <EOL> config . SetPath ( '<STR_LIT>' ) <EOL> config . SetPath ( group ) <EOL> styles = [ ] <EOL> cont , val , idx = config . GetFirstEntry ( ) <EOL> while cont : <EOL> t = config . Read ( val ) <EOL> styles . append ( val + '<STR_LIT:=>' + t ) <EOL> cont , val , idx = config . GetNextEntry ( idx ) <EOL> config . SetPath ( '<STR_LIT>' ) <EOL> return styles <EOL> def writeStylesToConfig ( config , group , styles ) : <EOL> config . SetPath ( '<STR_LIT>' ) <EOL> config . DeleteGroup ( group ) <EOL> config . SetPath ( group ) <EOL> for style in styles : <EOL> name , value = string . split ( style , '<STR_LIT:=>' ) <EOL> config . Write ( name , string . strip ( value ) ) <EOL> config . SetPath ( '<STR_LIT>' ) <EOL> def initSTC ( stc , config , lang ) : <EOL> """<STR_LIT>""" <EOL> ( cfg , commonDefs , styleIdNames , styles , predefStyleGroupNames , <EOL> predefStyleGroups , otherLangStyleGroupNames , otherLangStyleGroups , <EOL> displaySrc , lexer , keywords , braceInfo ) = initFromConfig ( config , lang ) <EOL> setSTCStyles ( stc , styles , styleIdNames , commonDefs , lang , lexer , keywords ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from wxPython . help import * <EOL> app = wxPySimpleApp ( ) <EOL> provider = wxSimpleHelpProvider ( ) <EOL> wxHelpProvider_Set ( provider ) <EOL> home = os . environ . get ( '<STR_LIT>' ) <EOL> if home : <EOL> home = os . path . join ( home , '<STR_LIT>' ) <EOL> else : <EOL> home = '<STR_LIT>' <EOL> config = os . path . abspath ( os . path . join ( home , '<STR_LIT>' ) ) <EOL> if <NUM_LIT:0> : <EOL> f = wxFrame ( None , - <NUM_LIT:1> , '<STR_LIT>' ) <EOL> stc = wxStyledTextCtrl ( f , - <NUM_LIT:1> ) <EOL> def OnDblClick ( evt , stc = stc ) : <EOL> dlg = STCStyleEditDlg ( None , '<STR_LIT>' , '<STR_LIT>' , config , ( stc , ) ) <EOL> try : dlg . ShowModal ( ) <EOL> finally : dlg . Destroy ( ) <EOL> stc . SetText ( open ( '<STR_LIT>' ) . read ( ) ) <EOL> EVT_LEFT_DCLICK ( stc , OnDblClick ) <EOL> initSTC ( stc , config , '<STR_LIT>' ) <EOL> f . Show ( true ) <EOL> app . MainLoop ( ) <EOL> else : <EOL> dlg = STCStyleEditDlg ( None , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> config ) <EOL> try : dlg . ShowModal ( ) <EOL> finally : dlg . Destroy ( ) </s>
