def default_formatted_text(msg): 'Returns a fmtstr object with the text of msg and the formatting from prefs' from util.primitives.fmtstr import fmtstr from gui.uberwidgets.formattedinput import get_default_format return fmtstr.singleformat(msg, get_default_format())
def send_from_popup(text, options, convo = convo, win = win, opts = fire_opts.copy()): if not text: return CallLater(200, stop_notify) # if the window's still around, use its formatting convo.send_message(fmtstr.singleformat(text, format=_get_format(win))) if not wx.GetKeyState(wx.WXK_CONTROL): # returning a string appends it to the popup's content. return '> ' + text
def test_singleformat(self): from util.primitives.fmtstr import fmtstr s = fmtstr.singleformat(u'lgkjsdg df gd fg df d', {'foregroundcolor': wx.Colour(0, 0, 0, 255), 'bold': False, 'family': u'default', 'face': u'arial', 'italic': False, 'backgroundcolor': wx.Colour (255, 255, 255, 255), 'underline': False, 'size': 11}) # test that wxColors get turned into tuples import simplejson simplejson.dumps(s.asDict())
def _incoming_blob_profile(self, profile_str_or_fmtstr): from util.primitives.fmtstr import fmtstr # self.profile used to be a string, but now it is a fmtstr, and goes out # over the wire as a JSON dict. # # assume that if we cannot parse the incoming profile blob as JSON, then # it must be an old-style string profile. if isinstance(profile_str_or_fmtstr, dict): fstr = fmtstr.fromDict(profile_str_or_fmtstr) else: from gui.uberwidgets.formattedinput import get_default_format fstr = fmtstr.singleformat(profile_str_or_fmtstr, format=get_default_format('profile.formatting')) self.profile = fstr
def test_singleformat(self): from util.primitives.fmtstr import fmtstr s = fmtstr.singleformat( u'lgkjsdg df gd fg df d', { 'foregroundcolor': wx.Colour(0, 0, 0, 255), 'bold': False, 'family': u'default', 'face': u'arial', 'italic': False, 'backgroundcolor': wx.Colour(255, 255, 255, 255), 'underline': False, 'size': 11 }) # test that wxColors get turned into tuples import simplejson simplejson.dumps(s.asDict())