def testGetDescriptionFromId(self): """Test GetDescriptionFromId""" desc = synglob.GetDescriptionFromId(synglob.ID_LANG_PYTHON) self.assertEquals(desc, synglob.LANG_PYTHON) desc = synglob.GetDescriptionFromId(synglob.ID_LANG_JAVA) self.assertEquals(desc, synglob.LANG_JAVA) # Test that some unknown id's always return Plain Text desc = synglob.GetDescriptionFromId(0) self.assertEquals(desc, synglob.LANG_TXT) desc = synglob.GetDescriptionFromId(100) self.assertEquals(desc, synglob.LANG_TXT)
def OnSaveProfile(self, reset=False): #profile key should be in language name #d = dict([(synglob.GetDescriptionFromId(k),v) for k,v in tempd.iteritems()]) #translate template objects into their dict instead of CodeTemplate objects self.edpanel.ApplyTemplateInfo(updatelistind=self.edpanel.lastind) newd = {} for lang, ld in self.edpanel.plugin.templates.iteritems(): newld = {} for k, v in ld.iteritems(): newld[k] = v.__dict__.copy() newld[k]['templ'] = newld[k]['templ'].template newd[synglob.GetDescriptionFromId(lang)] = newld Profile_Set(PROFILE_KEY_TEMPLATES, newd)
class meta: langid = ftype name = synglob.GetDescriptionFromId(ftype)
def __init__(self): super(FileTypeHandler, self).__init__() if self.meta.typeid != -1: self.meta.name = synglob.GetDescriptionFromId(self.meta.typeid)
def get_language_list(): #ids = [v[0] for v in synglob.LANG_MAP.values()] ids = syntax.SyntaxIds() names = [synglob.GetDescriptionFromId(id) for id in ids] names.sort() return names
def __init__(self, parent, plugin, initiallang=None, *args, **kwargs): super(TemplateEditorPanel, self).__init__(parent, *args, **kwargs) # Attributes self.plugin = plugin self.removing = False self.lastind = None self.lastname = '' # Layout left side of panel to display and alter list of templates basesizer = wx.BoxSizer(wx.HORIZONTAL) listsizer = wx.BoxSizer(wx.VERTICAL) staticbox = wx.StaticBox(self, label=_("Code Templates")) boxsz = wx.StaticBoxSizer(staticbox, wx.VERTICAL) langchoices = get_language_list() if isinstance(initiallang, basestring): id = synglob.GetIdFromDescription(initiallang) else: id = initiallang initiallang = synglob.GetDescriptionFromId(initiallang) if initiallang is None or initiallang not in langchoices: initiallang = langchoices[0] self.lastlangstr = initiallang self.langchoice = wx.Choice(self, wx.ID_ANY, choices=langchoices) self.langchoice.SetSelection(self.langchoice.FindString(initiallang)) self.Bind(wx.EVT_CHOICE, self.OnLangChange, self.langchoice) listsizer.Add(self.langchoice, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.listbox = wx.ListBox(self, wx.ID_ANY, size=(150, 300), choices=self.GetTemplateNames(), style=wx.LB_SINGLE) self.Bind(wx.EVT_LISTBOX, self.OnListChange, self.listbox) listsizer.Add(self.listbox, 1, wx.ALIGN_CENTRE | wx.ALL, 5) buttonsizer = wx.BoxSizer(wx.HORIZONTAL) addbutton = wx.Button(self, wx.ID_ADD) addbutton.SetToolTipString(_("Add a New Template")) self.Bind(wx.EVT_BUTTON, self.OnAdd, addbutton) buttonsizer.Add(addbutton, 1, wx.ALIGN_CENTRE | wx.ALL, 5) self.rembutton = wx.Button(self, wx.ID_DELETE) self.rembutton.SetToolTipString(_("Remove the selected Template")) self.Bind(wx.EVT_BUTTON, self.OnRemove, self.rembutton) self.rembutton.Enable(False) buttonsizer.Add(self.rembutton, 1, wx.ALIGN_CENTRE | wx.ALL, 5) listsizer.Add(buttonsizer, 0, wx.ALIGN_CENTRE | wx.ALL, 2) boxsz.Add(listsizer, 1, wx.EXPAND) basesizer.Add(boxsz, 0, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) # Layout right side of panel to display the selected template templateinfo = wx.BoxSizer(wx.VERTICAL) namesizer = wx.BoxSizer(wx.HORIZONTAL) helplabel = wx.StaticText(self, wx.ID_ANY, _("Name:")) namesizer.Add(helplabel, 0, wx.ALIGN_CENTRE | wx.ALL, 2) self.nametxt = wx.TextCtrl(self, wx.ID_ANY) namesizer.Add(self.nametxt, 1, wx.GROW | wx.ALIGN_CENTRE | wx.ALL, 2) templateinfo.Add(namesizer, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 2) self.nametxt.Enable(False) helpsizer = wx.BoxSizer(wx.HORIZONTAL) helplabel = wx.StaticText(self, wx.ID_ANY, _("Help Text:")) helpsizer.Add(helplabel, 0, wx.ALIGN_CENTRE | wx.ALL, 2) self.helptxt = wx.TextCtrl(self, wx.ID_ANY) helpsizer.Add(self.helptxt, 1, wx.GROW | wx.ALIGN_CENTRE | wx.ALL, 2) templateinfo.Add(helpsizer, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 2) self.helptxt.Enable(False) indsizer = wx.BoxSizer(wx.HORIZONTAL) self.indentcb = wx.CheckBox(self, label=_("Obey Indentation?")) tooltip = _( "Check to have all lines of the template be indented to match the indentation at which the template is inserted" ) self.indentcb.SetToolTipString(tooltip) indsizer.Add(self.indentcb, 0, wx.ALIGN_CENTRE | wx.ALL, 2) templateinfo.Add(indsizer, 0, wx.ALIGN_CENTER | wx.ALL, 2) self.indentcb.Enable(False) templabel = wx.StaticText( self, wx.ID_ANY, _("Template Codes:\n") + '"${same}": ' + _('Replace with selected text.\n"') + '${upper}":' + _('Replace with selected, first character upper case.\n') + '"${lower}":' + _('Replace with selected, first character lower case.\n') + '"$$":' + _('An "$" character.') + u'\n' + '"#CUR":' + _('Move cursor to this location after inserting template.') + '\n' + _('tabs will be replaced by the appropriate indent.')) templateinfo.Add(templabel, 0, wx.ALIGN_CENTER | wx.ALL, 2) self.temptxt = wx.TextCtrl(self, wx.ID_ANY, size=(300, 200), style=wx.TE_MULTILINE) templateinfo.Add(self.temptxt, 1, wx.EXPAND | wx.ALL, 2) self.temptxt.Enable(False) basesizer.Add(templateinfo, 1, wx.EXPAND | wx.ALIGN_CENTER | wx.ALL, 5) self.SetSizer(basesizer)