Changeset 1444

Show
Ignore:
Timestamp:
07/02/08 17:53:37 (5 months ago)
Author:
rob
Message:

Fixed #474 and #475: synced style editor with Editra svn 54465
* peppy.preferences.changed message moved inside the ID_OK check
* added new themes from Editra
* the "New" style button in the dialog now creates a blank style
* fixed LoadStyleSheet? to merge the imported style from a blank style so that everything doesn't always inherit from the built-in defaults

Location:
trunk/peppy
Files:
7 added
8 modified

Legend:

Unmodified
Added
Removed
  • trunk/peppy/editra/ed_style.py

    r1421 r1444  
    523523                self.LOG("[ed_style][err] Failed to open style sheet: %s" % style_sheet) 
    524524                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) 
    526531            reader.close() 
    527532            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 
    23import os, sys 
    34import wx 
     
    56def Profile_Get(index, fmt=None, default=None): 
    67    app = wx.GetApp() 
    7     if index == 'FONT1': 
    8         try: 
     8    try: 
     9        if index == 'FONT1': 
    910            font = app.fonts.classprefs.primary_editing_font 
    1011            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': 
    1713            font = app.fonts.classprefs.secondary_editing_font 
    1814            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 
    2221    return None 
    2322 
  • trunk/peppy/editra/stcmixin.py

    r1212 r1444  
    1010from peppy.debug import * 
    1111 
     12from profiler import Profile_Get as _PGET 
     13 
    1214class EditraSTCMixin(ed_style.StyleMgr, debugmixin): 
    1315    _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] 
    1425     
    1526    def __init__(self, stylefile): 
     
    102113        return 0 
    103114     
    104     def getEditraSyntaxData(self, lang): 
    105         """Get the Editra syntax data given the keyword of the major mode 
     115    def getEditraExtFromLang(self, lang): 
     116        """Get the Editra extension given the keyword of the major mode 
    106117         
    107118        Editra uses the filename extension as the basis for most of its 
    108119        lookups, but also has a pretty-printing name.  For instance, 'Python' 
    109120        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) 
    128133        #dprint("after: %s" % ext) 
    129134        syn_data = self._synmgr.SyntaxData(ext) 
     
    417422                return data[1] 
    418423        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  
     1default_style { 
     2                fore:#000000; 
     3                back:#F6F6F6; 
     4                face:%(primary)s; 
     5                size:%(size)d; 
     6 
     7} 
     8 
     9number2_style { 
     10                fore:#A020F0 bold; 
     11} 
     12 
     13stringeol_style { 
     14                fore:#000000 bold; 
     15                back:#EEC0EE eol; 
     16} 
     17 
     18comment_style { 
     19                fore:#FF0000; 
     20                size:%(size)d bold; 
     21} 
     22 
     23keyword_style { 
     24                fore:#000000 bold; 
     25} 
     26 
     27keyword3_style { 
     28                fore:#0000FF bold; 
     29} 
     30 
     31guide_style { 
     32                fore:#838383; 
     33} 
     34 
     35keyword4_style { 
     36                fore:#9D2424; 
     37} 
     38 
     39ideol_style { 
     40                fore:#E0C0E0; 
     41} 
     42 
     43array_style { 
     44                fore:#EE8B02 bold; 
     45                face:%(secondary)s; 
     46} 
     47 
     48global_style { 
     49                fore:#007F7F bold; 
     50                face:%(secondary)s; 
     51} 
     52 
     53line_num { 
     54                back:#C0C0C0; 
     55                face:%(secondary)s; 
     56                size:%(size3)d; 
     57} 
     58 
     59pre2_style { 
     60                fore:#AB39F2 bold; 
     61                back:#FFFFFF; 
     62} 
     63 
     64string_style { 
     65                fore:#1A701A; 
     66} 
     67 
     68class_style { 
     69                fore:#0000FF; 
     70} 
     71 
     72marker_style { 
     73                fore:#FFFFFF; 
     74                back:#000000; 
     75} 
     76 
     77keyword2_style { 
     78                fore:#2E8B57 bold; 
     79} 
     80 
     81class2_style { 
     82                fore:#2E8B57 bold; 
     83} 
     84 
     85unknown_style { 
     86                fore:#FFFFFF bold; 
     87                back:#DD0101 eol; 
     88                face:%(secondary)s; 
     89} 
     90 
     91calltip { 
     92                fore:#404040; 
     93                back:#FFFFB8; 
     94} 
     95 
     96scalar_style { 
     97                fore:#AB37F2 bold; 
     98} 
     99 
     100operator_style { 
     101                face:%(primary)s bold; 
     102} 
     103 
     104here_style { 
     105                fore:#CA61CA bold; 
     106                face:%(secondary)s; 
     107} 
     108 
     109number_style { 
     110                fore:#387082; 
     111} 
     112 
     113regex_style { 
     114                fore:#008B8B; 
     115} 
     116 
     117pre_style { 
     118                fore:#4939F2 bold; 
     119} 
     120 
     121whitespace_style { 
     122                fore:#838383; 
     123} 
     124 
     125decor_style { 
     126                fore:#BA0EEA; 
     127} 
     128 
     129scalar2_style { 
     130                fore:#AB37F2; 
     131                face:%(secondary)s; 
     132} 
     133 
     134funct_style { 
     135                fore:#008B8B italic; 
     136} 
     137 
    1138brace_good { 
    2         fore: #FFFFFF; 
    3         back: #0000FF bold; 
     139                back:#75FFA3 bold; 
     140} 
     141 
     142error_style { 
     143                fore:#DD0101 bold; 
     144                face:%(secondary)s; 
     145} 
     146 
     147directive_style { 
     148                fore:#0000FF bold; 
     149                face:%(secondary)s; 
     150} 
     151 
     152btick_style { 
     153                fore:#8959F6 bold; 
     154} 
     155 
     156char_style { 
     157                fore:#FF3AFF; 
     158} 
     159 
     160folder_style { 
     161                fore:#FFFFFF; 
     162                back:#000000; 
    4163} 
    5164 
    6165brace_bad { 
    7         back: #FF0000 bold; 
     166                back:#FF0090 bold; 
    8167} 
    9168 
    10 calltip {  
    11         fore: #404040; 
    12         back: #FFFFB8; 
     169dockey_style { 
     170                fore:#0000FF; 
    13171} 
    14172 
    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 
    17default_style { 
    28                fore: #FFFFFF; 
     
    1622 
    1723calltip {  
    18            fore: #FFE200; 
    19            back: #09026A; 
     24        fore: #FFE200; 
     25        back: #09026A; 
     26} 
     27 
     28caret_line { 
     29        back: #262626; 
    2030} 
    2131 
     
    4353} 
    4454 
     55decor_style { 
     56        fore: #BA0EEA italic; 
     57        face: %(secondary)s; 
     58} 
     59 
    4560directive_style { 
    46                 fore: #0000FF; 
     61                fore: #0000FF bold; 
    4762                face: %(secondary)s; 
    4863} 
    4964 
    5065dockey_style { 
    51                 fore: #0000FF; 
     66                fore: #00A6FF; 
    5267} 
    5368 
     
    6479                fore: #007F7F bold; 
    6580                face: %(secondary)s; 
     81} 
     82 
     83guide_style { 
     84        fore: #F6F6F6; 
    6685} 
    6786 
     
    113132 
    114133pre2_style { 
    115         fore: #AB39F2 bold; 
    116                 back: #666666 
     134        fore: #AB39F2 bold; 
     135        back: #101010; 
    117136} 
    118137 
     
    131150} 
    132151 
     152select_style { 
     153        back: #03087D; 
     154} 
     155 
    133156string_style { 
    134157                fore: #FF3AFF bold; 
     
    145168                fore: #FFFFFF bold; 
    146169                back: #DD0101 eol; 
    147                 face: %(secondary)s; 
    148170} 
    149171 
     172whitespace_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############################################################################### 
    208 
    219""" 
     10Provides an editor dialog for graphically editing how the text is presented in  
     11the editor when syntax highlighting is turned on. It does this by taking the  
     12data from the controls and formating it into an Editra Style Sheet that the  
     13editor 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 
    2223#--------------------------------------------------------------------------# 
    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 
    4325import os 
    4426import glob 
    4527import wx 
    46 import wx.lib.colourselect as  csel 
     28 
     29# Editra Imports 
    4730#import ed_glob 
    4831class ed_glob: 
    4932    ID_LEXER = wx.NewId() 
    5033    ID_PREF_SYNTHEME = wx.NewId() 
    51      
    52 #from profiler import Profile_Get, Profile_Set 
     34from peppy.major import * 
     35from peppy.fundamental import * 
     36 
     37from profiler import Profile_Get, Profile_Set 
    5338#import ed_stc 
    54 from ed_style import StyleItem, StyleMgr 
    55 import ed_event 
     39from ed_style import StyleItem 
    5640import util 
    5741import syntax.syntax as syntax 
    58  
    59 from peppy.major import * 
    60 from peppy.fundamental import * 
     42import eclib.colorsetter as colorsetter 
    6143 
    6244# Function Aliases 
     
    9375        wx.Dialog.__init__(self, parent, id_, title, style=style) 
    9476 
    95 ##        if wx.Platform == '__WXMAC__' and Profile_Get('METAL', 'bool', False): 
    96 ##            self.SetExtraStyle(wx.DIALOG_EX_METAL) 
    97  
    9877        # Attributes 
    9978        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) 
    10281        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) 
    10687        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) 
    10794 
    10895        # Main Sizer 
    109         self.sizer = wx.BoxSizer(wx.VERTICAL) 
    110         self.sizer.Add((10, 10)) # Spacer 
     96        sizer = wx.BoxSizer(wx.VERTICAL) 
    11197 
    11298        # Control Panel 
     
    116102        right_colum = wx.BoxSizer(wx.VERTICAL)   # Right Column 
    117103 
     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