Changeset 1444
- Timestamp:
- 07/02/08 17:53:37 (5 months ago)
- Location:
- trunk/peppy
- Files:
-
- 7 added
- 8 modified
-
editra/eclib (added)
-
editra/eclib/colorsetter.py (added)
-
editra/eclib/__init__.py (added)
-
editra/ed_style.py (modified) (1 diff)
-
editra/profiler.py (modified) (2 diffs)
-
editra/stcmixin.py (modified) (3 diffs)
-
editra/styles/blue.ess (added)
-
editra/styles/BlueMonday.ess (added)
-
editra/styles/default.ess (modified) (1 diff)
-
editra/styles/Dessert.ess (added)
-
editra/styles/midnight.ess (modified) (7 diffs)
-
editra/styles/Mocha.ess (added)
-
editra/style_editor.py (modified) (26 diffs)
-
editra/util.py (modified) (3 diffs)
-
plugins/editra_styleeditor.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/peppy/editra/ed_style.py
r1421 r1444 523 523 self.LOG("[ed_style][err] Failed to open style sheet: %s" % style_sheet) 524 524 return False 525 ret_val = self.SetStyles(style_sheet, self.ParseStyleData(reader.read())) 525 526 # Start from a blank style dictionary so that the user specified 527 # styles don't always extent from the default styles. Otherwise 528 # there's no way to start from a blank style. 529 style_dict = MergeStyles(self.BlankStyleDictionary(), self.ParseStyleData(reader.read())) 530 ret_val = self.SetStyles(style_sheet, style_dict) 526 531 reader.close() 527 532 return ret_val -
trunk/peppy/editra/profiler.py
r1096 r1444 1 # Misc utility files from Editra that don't have any other dependencies 1 # Wrapper around Editra configuration get/set utilities to return the peppy 2 # equivalent 2 3 import os, sys 3 4 import wx … … 5 6 def Profile_Get(index, fmt=None, default=None): 6 7 app = wx.GetApp() 7 if index == 'FONT1':8 try:8 try: 9 if index == 'FONT1': 9 10 font = app.fonts.classprefs.primary_editing_font 10 11 return font 11 except: 12 # If we're running a mock object for testing purposes, just 13 # let this pass 14 pass 15 elif index == 'FONT2': 16 try: 12 elif index == 'FONT2': 17 13 font = app.fonts.classprefs.secondary_editing_font 18 14 return font 19 except: 20 # again, catch the exception if we're running a mock object 21 pass 15 elif index == 'SYNTHEME': 16 theme = 'Default' 17 return theme 18 except: 19 # catch the exception if we're running a mock object 20 pass 22 21 return None 23 22 -
trunk/peppy/editra/stcmixin.py
r1212 r1444 10 10 from peppy.debug import * 11 11 12 from profiler import Profile_Get as _PGET 13 12 14 class EditraSTCMixin(ed_style.StyleMgr, debugmixin): 13 15 _synmgr = syntax.SyntaxMgr() 16 # _synmgr._extreg is an ExtensionRegister instance that is a dictionary 17 # from the Editra pretty name to the extension list supported by that 18 # name. Editra doesn't provide a direct mapping from the pretty name to 19 # the primary extension, however, so this is created here. 20 _editra_lang_to_ext = {} 21 for lang, exts in _synmgr._extreg.iteritems(): 22 #dprint("%s: %s" % (lang, exts)) 23 _editra_lang_to_ext[lang] = exts[0] 24 _editra_lang_to_ext[lang.replace(' ', '_')] = exts[0] 14 25 15 26 def __init__(self, stylefile): … … 102 113 return 0 103 114 104 def getEditra SyntaxData(self, lang):105 """Get the Editra syntax datagiven the keyword of the major mode115 def getEditraExtFromLang(self, lang): 116 """Get the Editra extension given the keyword of the major mode 106 117 107 118 Editra uses the filename extension as the basis for most of its 108 119 lookups, but also has a pretty-printing name. For instance, 'Python' 109 120 is the pretty name of python mode, but Editra uses "py" as its main 110 designator for the mode internally. This method gets the syntax data 111 based on the peppy keyword, which is designed to be the same as the 112 Editra pretty-printing mode in most cases. 113 """ 114 # self._synmgr._extreg is an ExtensionRegister instance that is 115 # a dictionary from the Editra style sheet name to the extension 116 # list supported by that name. If the peppy keyword exists in this 117 # dictionary, we can directly find the filename extensions. 118 ext = "" 119 #dprint("before: %s" % lang) 120 #dprint(self._synmgr._extreg) 121 for guess in [lang, lang.replace('_', ' ')]: 122 #dprint(guess) 123 if guess in self._synmgr._extreg: 124 ext = self._synmgr._extreg[guess][0] 125 break 126 if not ext: 127 ext = lang 121 designator for the mode internally. 122 """ 123 return self._editra_lang_to_ext.get(lang, lang) 124 125 def getEditraSyntaxData(self, lang): 126 """Get the Editra syntax data given the keyword of the major mode 127 128 This method gets the syntax data based on the peppy keyword, which is 129 designed to be the same as the Editra pretty-printing mode in most 130 cases. 131 """ 132 ext = self.getEditraExtFromLang(lang) 128 133 #dprint("after: %s" % ext) 129 134 syn_data = self._synmgr.SyntaxData(ext) … … 417 422 return data[1] 418 423 return 'default_style' 424 425 def GetStyleSheet(self, sheet_name=None): 426 """Finds the current style sheet and returns its path. The 427 Lookup is done by first looking in the users config directory 428 and if it is not found there it looks for one on the system 429 level and if that fails it returns None. 430 @param sheet_name: style sheet to look for 431 @return: full path to style sheet 432 433 """ 434 if sheet_name: 435 style = sheet_name 436 if sheet_name.split(u'.')[-1] != u"ess": 437 style += u".ess" 438 elif _PGET('SYNTHEME', 'str').split(u'.')[-1] != u"ess": 439 style = (_PGET('SYNTHEME', 'str') + u".ess").lower() 440 else: 441 style = _PGET('SYNTHEME', 'str').lower() 442 443 # Get Correct Filename if it exists 444 for sheet in util.GetResourceFiles('styles', False, True, title=False): 445 if sheet.lower() == style.lower(): 446 style = sheet 447 break 448 dprint(style) 449 sysp = os.path.join(util.GetResourceDir('styles'), style) 450 if os.path.exists(sysp): 451 return sysp 452 # user = os.path.join(ed_glob.CONFIG['STYLES_DIR'], style) 453 # sysp = os.path.join(ed_glob.CONFIG['SYS_STYLES_DIR'], style) 454 # if os.path.exists(user): 455 # return user 456 # elif os.path.exists(sysp): 457 # return sysp 458 # else: 459 # return None -
trunk/peppy/editra/styles/default.ess
r621 r1444 1 default_style { 2 fore:#000000; 3 back:#F6F6F6; 4 face:%(primary)s; 5 size:%(size)d; 6 7 } 8 9 number2_style { 10 fore:#A020F0 bold; 11 } 12 13 stringeol_style { 14 fore:#000000 bold; 15 back:#EEC0EE eol; 16 } 17 18 comment_style { 19 fore:#FF0000; 20 size:%(size)d bold; 21 } 22 23 keyword_style { 24 fore:#000000 bold; 25 } 26 27 keyword3_style { 28 fore:#0000FF bold; 29 } 30 31 guide_style { 32 fore:#838383; 33 } 34 35 keyword4_style { 36 fore:#9D2424; 37 } 38 39 ideol_style { 40 fore:#E0C0E0; 41 } 42 43 array_style { 44 fore:#EE8B02 bold; 45 face:%(secondary)s; 46 } 47 48 global_style { 49 fore:#007F7F bold; 50 face:%(secondary)s; 51 } 52 53 line_num { 54 back:#C0C0C0; 55 face:%(secondary)s; 56 size:%(size3)d; 57 } 58 59 pre2_style { 60 fore:#AB39F2 bold; 61 back:#FFFFFF; 62 } 63 64 string_style { 65 fore:#1A701A; 66 } 67 68 class_style { 69 fore:#0000FF; 70 } 71 72 marker_style { 73 fore:#FFFFFF; 74 back:#000000; 75 } 76 77 keyword2_style { 78 fore:#2E8B57 bold; 79 } 80 81 class2_style { 82 fore:#2E8B57 bold; 83 } 84 85 unknown_style { 86 fore:#FFFFFF bold; 87 back:#DD0101 eol; 88 face:%(secondary)s; 89 } 90 91 calltip { 92 fore:#404040; 93 back:#FFFFB8; 94 } 95 96 scalar_style { 97 fore:#AB37F2 bold; 98 } 99 100 operator_style { 101 face:%(primary)s bold; 102 } 103 104 here_style { 105 fore:#CA61CA bold; 106 face:%(secondary)s; 107 } 108 109 number_style { 110 fore:#387082; 111 } 112 113 regex_style { 114 fore:#008B8B; 115 } 116 117 pre_style { 118 fore:#4939F2 bold; 119 } 120 121 whitespace_style { 122 fore:#838383; 123 } 124 125 decor_style { 126 fore:#BA0EEA; 127 } 128 129 scalar2_style { 130 fore:#AB37F2; 131 face:%(secondary)s; 132 } 133 134 funct_style { 135 fore:#008B8B italic; 136 } 137 1 138 brace_good { 2 fore: #FFFFFF; 3 back: #0000FF bold; 139 back:#75FFA3 bold; 140 } 141 142 error_style { 143 fore:#DD0101 bold; 144 face:%(secondary)s; 145 } 146 147 directive_style { 148 fore:#0000FF bold; 149 face:%(secondary)s; 150 } 151 152 btick_style { 153 fore:#8959F6 bold; 154 } 155 156 char_style { 157 fore:#FF3AFF; 158 } 159 160 folder_style { 161 fore:#FFFFFF; 162 back:#000000; 4 163 } 5 164 6 165 brace_bad { 7 back: #FF0000 bold;166 back:#FF0090 bold; 8 167 } 9 168 10 calltip { 11 fore: #404040; 12 back: #FFFFB8; 169 dockey_style { 170 fore:#0000FF; 13 171 } 14 172 15 ctrl_char {16 fore: #000000;17 back: #F6F6F6;18 face: %(primary)s;19 }20 21 line_num {22 back: #C0C0C0;23 face: %(secondary)s;24 size: %(size3)d;25 }26 27 array_style {28 fore: #EE8B02 bold;29 face: %(secondary)s;30 }31 32 btick_style {33 fore: #8959F6 bold;34 back: #FFFFFF;35 }36 37 default_style {38 fore: #000000;39 back: #F6F6F6;40 face: %(primary)s;41 size: %(size)d;42 }43 44 char_style {45 fore: #FF3AFF;46 back: #FFFFFF;47 }48 49 class_style {50 fore: #2E8B57 bold;51 }52 53 class2_style {54 fore: #2E8B57 bold;55 back: #FFFFFF;56 }57 58 comment_style {59 fore: #838383;60 }61 62 directive_style {63 fore: #0000FF bold;64 face: %(secondary)s;65 }66 67 dockey_style {68 fore: #0000FF;69 }70 71 error_style {72 fore: #DD0101 bold;73 face: %(secondary)s;74 }75 76 funct_style {77 fore: #008B8B italic;78 }79 80 global_style {81 fore: #007F7F bold;82 face: %(secondary)s;83 }84 85 here_style {86 fore: #CA61CA bold;87 face: %(secondary)s;88 }89 90 ideol_style {91 fore: #E0C0E0;92 face: %(secondary)s;93 }94 95 keyword_style {96 fore: #A52B2B bold;97 }98 99 keyword2_style {100 fore: #2E8B57 bold;101 }102 103 keyword3_style {104 fore: #008B8B bold;105 }106 107 keyword4_style {108 fore: #9D2424;109 }110 111 margin_style {112 fore: #FFFFFF;113 back: #000000;114 }115 116 number_style {117 fore: #DD0101;118 }119 120 number2_style {121 fore: #DD0101 bold;122 }123 124 operator_style {125 face: %(primary)s bold;126 }127 128 pre_style {129 fore: #AB39F2 bold;130 }131 132 pre2_style {133 fore: #AB39F2 bold;134 back: #FFFFFF;135 }136 137 regex_style {138 fore: #008B8B;139 }140 141 scalar_style {142 fore: #AB37F2 bold;143 face: %(secondary)s;144 }145 146 scalar2_style {147 fore: #AB37F2;148 face: %(secondary)s;149 }150 151 string_style {152 fore: #FF3AFF bold;153 back: #FFFFFF;154 }155 156 stringeol_style {157 back: #EEC0EE eol;158 face: %(secondary)s bold;159 }160 161 unknown_style {162 fore: #FFFFFF bold;163 back: #DD0101 eol;164 face: %(secondary)s;165 } -
trunk/peppy/editra/styles/midnight.ess
r621 r1444 1 /* Editra Style Sheet 2 * Name: Midnight 3 * Author: Cody Precord <cprecord@editra.org> 4 * License: wxWindows License 5 */ 6 1 7 default_style { 2 8 fore: #FFFFFF; … … 16 22 17 23 calltip { 18 fore: #FFE200; 19 back: #09026A; 24 fore: #FFE200; 25 back: #09026A; 26 } 27 28 caret_line { 29 back: #262626; 20 30 } 21 31 … … 43 53 } 44 54 55 decor_style { 56 fore: #BA0EEA italic; 57 face: %(secondary)s; 58 } 59 45 60 directive_style { 46 fore: #0000FF ;61 fore: #0000FF bold; 47 62 face: %(secondary)s; 48 63 } 49 64 50 65 dockey_style { 51 fore: #00 00FF;66 fore: #00A6FF; 52 67 } 53 68 … … 64 79 fore: #007F7F bold; 65 80 face: %(secondary)s; 81 } 82 83 guide_style { 84 fore: #F6F6F6; 66 85 } 67 86 … … 113 132 114 133 pre2_style { 115 fore: #AB39F2 bold;116 back: #666666134 fore: #AB39F2 bold; 135 back: #101010; 117 136 } 118 137 … … 131 150 } 132 151 152 select_style { 153 back: #03087D; 154 } 155 133 156 string_style { 134 157 fore: #FF3AFF bold; … … 145 168 fore: #FFFFFF bold; 146 169 back: #DD0101 eol; 147 face: %(secondary)s;148 170 } 149 171 172 whitespace_style { 173 fore: #626262; 174 } -
trunk/peppy/editra/style_editor.py
r812 r1444 1 ############################################################################ 2 # Copyright (C) 2007 Cody Precord # 3 # cprecord@editra.org # 4 # # 5 # Editra is free software; you can redistribute it and#or modify # 6 # it under the terms of the GNU General Public License as published by # 7 # the Free Software Foundation; either version 2 of the License, or # 8 # (at your option) any later version. # 9 # # 10 # Editra is distributed in the hope that it will be useful, # 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of # 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # 13 # GNU General Public License for more details. # 14 # # 15 # You should have received a copy of the GNU General Public License # 16 # along with this program; if not, write to the # 17 # Free Software Foundation, Inc., # 18 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # 19 ############################################################################ 1 ############################################################################### 2 # Name: style_editor.py # 3 # Purpose: Syntax Highlighting configuration dialog # 4 # Author: Cody Precord <cprecord@editra.org> # 5 # Copyright: (c) 2008 Cody Precord <staff@editra.org> # 6 # License: wxWindows License # 7 ############################################################################### 20 8 21 9 """ 10 Provides an editor dialog for graphically editing how the text is presented in 11 the editor when syntax highlighting is turned on. It does this by taking the 12 data from the controls and formating it into an Editra Style Sheet that the 13 editor can load to configure the styles of the text. 14 15 @summary: Gui for creating custom Editra Style Sheets 16 17 """ 18 19 __author__ = "Cody Precord <cprecord@editra.org>" 20 __svnid__ = "$Id: style_editor.py 53723 2008-05-23 15:53:53Z CJP $" 21 __revision__ = "$Revision: 53723 $" 22 22 23 #--------------------------------------------------------------------------# 23 # FILE: style_editor.py # 24 # AUTHOR: Cody Precord # 25 # LANGUAGE: Python # 26 # SUMMARY: # 27 # Provides an editor dialog for editing styles and generating style # 28 # sheets to use with editra's styled text controls. # 29 # # 30 # METHODS: 31 # 32 # 33 # 34 #--------------------------------------------------------------------------# 35 """ 36 37 __author__ = "Cody Precord <cprecord@editra.org>" 38 __svnid__ = "$Id: style_editor.py 579 2007-10-04 10:22:41Z CodyPrecord $" 39 __revision__ = "$Revision: 579 $" 40 41 #--------------------------------------------------------------------------# 42 # Dependancies 24 # Imports 43 25 import os 44 26 import glob 45 27 import wx 46 import wx.lib.colourselect as csel 28 29 # Editra Imports 47 30 #import ed_glob 48 31 class ed_glob: 49 32 ID_LEXER = wx.NewId() 50 33 ID_PREF_SYNTHEME = wx.NewId() 51 52 #from profiler import Profile_Get, Profile_Set 34 from peppy.major import * 35 from peppy.fundamental import * 36 37 from profiler import Profile_Get, Profile_Set 53 38 #import ed_stc 54 from ed_style import StyleItem, StyleMgr 55 import ed_event 39 from ed_style import StyleItem 56 40 import util 57 41 import syntax.syntax as syntax 58 59 from peppy.major import * 60 from peppy.fundamental import * 42 import eclib.colorsetter as colorsetter 61 43 62 44 # Function Aliases … … 93 75 wx.Dialog.__init__(self, parent, id_, title, style=style) 94 76 95 ## if wx.Platform == '__WXMAC__' and Profile_Get('METAL', 'bool', False):96 ## self.SetExtraStyle(wx.DIALOG_EX_METAL)97 98 77 # Attributes 99 78 self.LOG = wx.GetApp().GetLog() 100 # # self.preview = ed_stc.EDSTC(self, wx.ID_ANY, size=(-1, 200),101 # #style=wx.SUNKEN_BORDER, use_dt=False)79 # self.preview = ed_stc.EditraStc(self, wx.ID_ANY, size=(-1, 200), 80 # style=wx.SUNKEN_BORDER, use_dt=False) 102 81 self.preview = FundamentalSTC(self, None, size=(-1, 200)) 103 self.styles_new = self.preview.GetStyleSet() 104 self.styles_orig = self.DuplicateStyleDict(self.styles_new) 105 self.settings_enabled = True 82 #print("default style set = %s" % self.preview.style_set) 83 self.styles_orig = self.preview.GetStyleSet() 84 self.preview.SetCaretLineVisible(True) 85 self.styles_new = DuplicateStyleDict(self.styles_orig) 86 self.preview.SetStyles('preview', self.styles_new, True) 106 87 self.OpenPreviewFile('cpp') 88 # XXX On Windows the settings pane must be made before the 89 # sizer it is to be put in or it becomes unable to recieve 90 # focus. But is the exact opposite on mac/gtk. This is really 91 # a pain or possibly a bug? 92 if wx.Platform == '__WXMSW__': 93 self._settings = SettingsPanel(self) 107 94 108 95 # Main Sizer 109 self.sizer = wx.BoxSizer(wx.VERTICAL) 110 self.sizer.Add((10, 10)) # Spacer 96 sizer = wx.BoxSizer(wx.VERTICAL) 111 97 112 98 # Control Panel … … 116 102 right_colum = wx.BoxSizer(wx.VERTICAL) # Right Column 117 103 104 # XXX On Mac/GTK if panel is created before sizer all controls in 105 # it become unable to recieve focus from clicks, but it is the 106 # exact opposite on windows! 107 if wx.Platfor
