Changeset 1452
- Timestamp:
- 07/03/08 16:02:17 (5 months ago)
- Location:
- trunk/peppy
- Files:
-
- 9 modified
-
configprefs.py (modified) (1 diff)
-
editra/ed_style.py (modified) (6 diffs)
-
editra/profiler.py (modified) (2 diffs)
-
editra/stcmixin.py (modified) (4 diffs)
-
editra/style_editor.py (modified) (1 diff)
-
editra/util.py (modified) (3 diffs)
-
fundamental.py (modified) (2 diffs)
-
main.py (modified) (4 diffs)
-
plugins/editra_styleeditor.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/peppy/configprefs.py
r1423 r1452 65 65 d = self.dir 66 66 return os.path.exists(d) 67 68 def contents(self, subdir): 69 path = self.fullpath(subdir) 70 if os.path.exists(path): 71 return path, os.listdir(path) 72 return None, [] 67 73 68 74 def open(self, name, mode='r'): -
trunk/peppy/editra/ed_style.py
r1446 r1452 21 21 22 22 __author__ = "Cody Precord <cprecord@editra.org>" 23 __svnid__ = "$Id: ed_style.py 544 67 2008-07-02 19:51:00Z CJP $"24 __revision__ = "$Revision: 544 67$"23 __svnid__ = "$Id: ed_style.py 54472 2008-07-03 03:28:11Z CJP $" 24 __revision__ = "$Revision: 54472 $" 25 25 26 26 #--------------------------------------------------------------------------# … … 341 341 """ 342 342 sty_dict = dict() 343 for key in self.GetStyleSet().keys():343 for key in DefaultStyleDictionary().keys(): 344 344 if key in ('select_style', 'whitespace_style'): 345 345 sty_dict[key] = NullStyleItem() … … 424 424 return fore 425 425 426 def GetCurrentStyleSetName(self): 427 """Get the name of the currently set style 428 @return: string 429 430 """ 431 return self.style_set 432 426 433 def GetDefaultBackColour(self, as_hex=False): 427 434 """Gets the background color of the default style and returns … … 527 534 elif not StyleMgr.STYLES.has_key(style_sheet): 528 535 self.LOG("[ed_style][warn] Style sheet %s does not exists" % style_sheet) 536 # Reset to default style 537 Profile_Set('SYNTHEME', 'default') 529 538 self.SetStyles('default', DefaultStyleDictionary()) 530 539 return False … … 699 708 700 709 # For any undefined tags load them as empty items 701 for key in DefaultStyleDictionary().keys():702 if key not in style_dict:703 style_dict[key] = StyleItem()710 # for key in DefaultStyleDictionary().keys(): 711 # if key not in style_dict: 712 # style_dict[key] = StyleItem() 704 713 705 714 return style_dict … … 766 775 767 776 self.style_set = name 777 defaultd = DefaultStyleDictionary() 778 dstyle = style_dict.get('default_style', None) 779 if dstyle is None: 780 style_dict['default_style'] = defaultd['default_style'] 781 768 782 # Set any undefined styles to match the default_style 769 for tag, item in DefaultStyleDictionary().iteritems():783 for tag, item in defaultd.iteritems(): 770 784 if tag not in style_dict: 771 785 if tag in ['select_style', 'whitespace_style']: 772 786 style_dict[tag] = NullStyleItem() 773 el if tag in ['foldmargin_style']:787 else: 774 788 style_dict[tag] = style_dict['default_style'] 775 else:776 style_dict[tag] = item777 789 778 790 StyleMgr.STYLES[name] = self.PackStyleSet(style_dict) -
trunk/peppy/editra/profiler.py
r1444 r1452 14 14 return font 15 15 elif index == 'SYNTHEME': 16 theme = 'Default'16 theme = app.fonts.classprefs.editra_style_theme 17 17 return theme 18 18 except: … … 21 21 return None 22 22 23 def Profile_Set(index, val, fmt): 23 def Profile_Set(index, val, fmt=None): 24 app = wx.GetApp() 25 if index == 'SYNTHEME': 26 app.fonts.classprefs.editra_style_theme = val 24 27 return None -
trunk/peppy/editra/stcmixin.py
r1448 r1452 288 288 self.LOG(syn_lst) 289 289 valid_settings = list() 290 291 # Here's the global hack to fix the problem the first time styles are292 # modified by the style dialog.293 if self.global_style_set:294 self.style_set = self.global_style_set295 self.dprint(self.style_set)296 290 297 291 for syn in syn_lst: … … 369 363 370 364 """ 365 self.dprint("current=%s" % self.style_set) 371 366 self.StyleDefault() 372 367 self.SetMargins(0, 0) … … 396 391 397 392 """ 393 self.dprint("requested=%s current=%s" % (spec_style, self.style_set)) 398 394 if spec_style != self.style_set: 399 395 self.LoadStyleSheet(self.GetStyleSheet(spec_style), force=True) … … 463 459 style = sheet 464 460 break 465 dprint(style) 461 user = wx.GetApp().fonts.getStylePath(style) 462 if os.path.exists(user): 463 self.dprint("found user style %s at %s" % (style, user)) 464 return user 466 465 sysp = os.path.join(util.GetResourceDir('styles'), style) 467 466 if os.path.exists(sysp): 467 self.dprint("found system style %s at %s" % (style, sysp)) 468 468 return sysp 469 self.dprint("didn't find %s" % style) 469 470 # user = os.path.join(ed_glob.CONFIG['STYLES_DIR'], style) 470 471 # sysp = os.path.join(ed_glob.CONFIG['SYS_STYLES_DIR'], style) -
trunk/peppy/editra/style_editor.py
r1449 r1452 379 379 self.styles_new = DuplicateStyleDict(self.styles_orig) 380 380 self.preview.SetStyles('preview', self.styles_new, nomerge=True) 381 self.preview.Update BaseStyles()381 self.preview.UpdateAllStyles('preview') 382 382 383 383 # For some reason this causes the text display to refresh -
trunk/peppy/editra/util.py
r1444 r1452 23 23 return rec_dir 24 24 25 def GetResourceFiles(resource, trim=True, get_all=False, title= True):25 def GetResourceFiles(resource, trim=True, get_all=False, title=False): 26 26 """Gets a list of resource files from a directory and trims the 27 27 file extentions from the names if trim is set to True (default). … … 39 39 rec_dir = GetResourceDir(resource) 40 40 rec_list = list() 41 if not os.path.exists(rec_dir): 42 return -1 43 else: 41 if get_all: 42 user_dir, user_files = wx.GetApp().config.contents(resource) 43 #dprint("path=%s contents=%s" % (user_dir, user_files)) 44 for rec in user_files: 45 if os.path.isfile(os.path.join(user_dir, rec)): 46 if trim: 47 rec = rec.split(u".")[0] 48 if title: 49 rec = rec.title() 50 rec_list.append(rec) 51 if os.path.exists(rec_dir): 44 52 recs = os.listdir(rec_dir) 45 53 #dprint(recs) … … 51 59 rec = rec.title() 52 60 rec_list.append(rec) 53 rec_list.sort() 54 return list(set(rec_list)) 61 return list(set(rec_list)) 55 62 56 63 def GetExtension(file_str): -
trunk/peppy/fundamental.py
r1448 r1452 137 137 #: Default class preferences that relate to all instances of this major mode 138 138 default_classprefs = ( 139 StrParam('editra_style_sheet', '', 'Mode specific filename in the config directory containing Editra style sheet information. Used to override default styles with custom styles for this mode.'),140 139 BoolParam('use_tab_characters', False, 141 140 'True: insert tab characters when tab is pressed. False: insert the equivalent number of spaces instead.', local=True), … … 326 325 self.SetStyleFont(wx.GetApp().fonts.classprefs.secondary_editing_font, False) 327 326 self.dprint("font styling done in %0.5fs" % (time.time() - start)) 327 328 # Here's the global hack to fix the problem the first time styles are 329 # modified by the style dialog. 330 if self.global_style_set and self.global_style_set != self.style_set: 331 self.style_set = self.global_style_set 332 self.dprint("Changing style to global style %s" % self.style_set) 328 333 self.ConfigureLexer(self.editra_lang) 329 self.dprint(" styleSTC (if True)done in %0.5fs" % (time.time() - start))334 self.dprint("ConfigureLexer done in %0.5fs" % (time.time() - start)) 330 335 self.has_stc_styling = True 331 336 self.setEmacsAndVIM() -
trunk/peppy/main.py
r1448 r1452 5 5 """ 6 6 7 import os, sys, imp, platform, random, string 7 import os, sys, imp, platform, random, string, time 8 8 import __builtin__ 9 9 … … 78 78 FontParam('primary_editing_font', None, 'Font name of the primary editing font', fullwidth=True), 79 79 FontParam('secondary_editing_font', None, 'Font name of the secondary scintilla font', fullwidth=True), 80 StrParam('editra_style_ sheet', 'styles.ess', 'Filename in the config directory containing Editra style sheet information'),80 StrParam('editra_style_theme', 'Default', 'Current Editra style theme'), 81 81 ) 82 82 if wx.Platform == "__WXMAC__": … … 84 84 else: 85 85 default_fontsize = 10 86 87 first_time = True 86 88 87 89 def __init__(self): … … 93 95 self.classprefs.secondary_editing_font = wx.Font(self.default_fontsize, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) 94 96 97 def getStylePath(self, name=None): 98 c = wx.GetApp().config 99 path = c.fullpath('styles') 100 if not os.path.exists(path): 101 c.create('styles') 102 #dprint("created %s" % path) 103 104 # Handle conversion from old-style 'styles.ess' to new style 105 # directory of style files 106 if self.__class__.first_time: 107 source = c.fullpath('styles.ess') 108 #dprint("Looking for %s to rename" % source) 109 if os.path.exists(source): 110 dest = os.path.join(path, '%s.ess' % time.strftime("%Y%m%d", time.localtime(time.time()))) 111 os.rename(source, dest) 112 self.__class__.first_time = False 113 if name: 114 if not name.endswith(".ess"): 115 name += ".ess" 116 path = os.path.join(path, name) 117 return path 118 95 119 def getStyleFile(self, mode=None): 96 if mode: 97 # Find style sheet override if the mode specifies it 98 filename = mode.classprefs.editra_style_sheet 99 else: 100 filename = '' 101 if not filename: 102 filename = self.classprefs.editra_style_sheet 103 pathname = wx.GetApp().getConfigFilePath(filename) 120 pathname = self.getStylePath(self.classprefs.editra_style_theme) 104 121 #dprint(pathname) 105 122 return pathname -
trunk/peppy/plugins/editra_styleeditor.py
r1446 r1452 38 38 retval = dlg.ShowModal() 39 39 if retval == wx.ID_OK: 40 styles = ed_style.MergeStyles(dlg.preview.BlankStyleDictionary(), dlg.styles_new) 41 dlg.preview.SetStyles(stylesheet, styles, True) 42 EditraSTCMixin.global_style_set = stylesheet 43 sheet = dlg.GenerateStyleSheet() 44 dprint(sheet) 45 fh = wx.GetApp().config.open(stylesheet, 'wb') 46 fh.write(sheet) 47 Publisher().sendMessage('peppy.preferences.changed') 40 # Find style name from controls within the dialog 41 ctrl = dlg.FindWindowById(style_editor.ed_glob.ID_PREF_SYNTHEME) 42 tag = ctrl.GetStringSelection() 43 ctrl = dlg.FindWindowById(wx.ID_NEW) 44 if ctrl.GetValue(): 45 tag = "untitled" 46 dlg2 = wx.TextEntryDialog( 47 self.frame, message="Save Style Sheet", defaultValue=tag, 48 style=wx.OK|wx.CANCEL) 49 retval = dlg2.ShowModal() 50 tag = dlg2.GetValue() 51 if not tag: 52 tag = "untitled" 53 dlg2.Destroy() 54 55 if retval == wx.ID_OK: 56 #dprint("Saving style to %s" % tag) 57 filename = wx.GetApp().fonts.getStylePath(tag) 58 59 styles = ed_style.MergeStyles(dlg.preview.BlankStyleDictionary(), dlg.styles_new) 60 dlg.preview.SetStyles(filename, styles, True) 61 EditraSTCMixin.global_style_set = filename 62 sheet = dlg.GenerateStyleSheet() 63 #dprint(sheet) 64 fh = open(filename, 'wb') 65 fh.write(sheet) 66 wx.GetApp().fonts.classprefs.editra_style_theme = tag 67 Publisher().sendMessage('peppy.preferences.changed') 48 68 elif retval == wx.ID_SAVE: 49 69 dprint("Save!")
