示例#1
0
def OnDocbookEnclose(editor):
    #find the docbook.acp file
    docbookini = common.getConfigPathFile('docbook_xml.ini')
    from modules import dict4ini
    x = dict4ini.DictIni(docbookini)
    taglist = x.default.taglist
    taglist.sort()
    #popup a selection win
    if taglist:
        from modules.EasyGuider import EasyDialog
        dialog = [
            ('single', 'tagname', taglist[0], tr('Select a tag:'), taglist),
        ]
        dlg = EasyDialog.EasyDialog(editor, tr('Select a DocBook Element Name'), dialog)
        values = None
        if dlg.ShowModal() == wx.ID_OK:
            values = dlg.GetValue()
        dlg.Destroy()
        if values:
            tagname = values['tagname']
            text = editor.GetSelectedText()
            editor.BeginUndoAction()
            if text:
                editor.ReplaceSelection('')
            if x.tag_values.has_key(tagname):
                settext(editor, [x.tag_values[tagname]])
            else:
                editor.AddText('<%s>%s</%s>' % (tagname, text, tagname))
                pos = editor.GetCurrentPos() - len(values['tagname']) - 3
                editor.GotoPos(pos)
            editor.EndUndoAction()
    else:
        common.showerror(editor, tr("There are not tags defined in conf/docbook_xml.ini."))
示例#2
0
    def install_acp(self, editor, language, changeflag=False):
#        changeflag = False
        filename = common.getConfigPathFile('%s.acp' % language)
        if not os.path.exists(filename):
            if assistant.has_key(language):
                del assistant[language]
                changeflag = True
        else:
            if not changeflag:
                changeflag = self.install_assistant(language, filename)
        self.editor = editor

        try:
            self.lasteditor
        except:
            error.traceback()
            self.lasteditor = None
            self.lastlanguage = None

        if changeflag or not self.lasteditor is editor or self.lastlanguage != editor.languagename:
            self.lasteditor = editor
            self.lastlanguage = editor.languagename
            #re cal all the default auto indentifier list
            editor.default_auto_identifier = {}
            editor.input_calltip = []
            editor.input_autodot = []
            editor.input_locals = []
            editor.input_analysis = []
            for obj in self.get_acp(language) + editor.custom_assistant:
                self.install_default_auto_identifier(obj)
                self.install_calltip(obj)
                self.install_autodot(obj)
                self.install_locals(obj)
                self.install_analysis(obj)
        return True
示例#3
0
    def install_acp(self, editor, language, changeflag=False):
        #        changeflag = False
        filename = common.getConfigPathFile('%s.acp' % language)
        if not os.path.exists(filename):
            if assistant.has_key(language):
                del assistant[language]
                changeflag = True
        else:
            if not changeflag:
                changeflag = self.install_assistant(language, filename)
        self.editor = editor

        try:
            self.lasteditor
        except:
            error.traceback()
            self.lasteditor = None
            self.lastlanguage = None

        if changeflag or not self.lasteditor is editor or self.lastlanguage != editor.languagename:
            self.lasteditor = editor
            self.lastlanguage = editor.languagename
            #re cal all the default auto indentifier list
            editor.default_auto_identifier = {}
            editor.input_calltip = []
            editor.input_autodot = []
            editor.input_locals = []
            editor.input_analysis = []
            for obj in self.get_acp(language) + editor.custom_assistant:
                self.install_default_auto_identifier(obj)
                self.install_calltip(obj)
                self.install_autodot(obj)
                self.install_locals(obj)
                self.install_analysis(obj)
        return True
示例#4
0
def getinstance():
    global _instance, _cmdfile_fmttime
    filename = common.getConfigPathFile(_cmdfile)
    if not _instance or _cmdfile_fmttime < os.path.getmtime(filename):
        _instance = Commands(filename)
        _cmdfile_fmttime = os.path.getmtime(filename)
    return _instance
示例#5
0
def getinstance():
    global _instance, _cmdfile_fmttime
    filename = common.getConfigPathFile(_cmdfile)
    if not _instance or _cmdfile_fmttime < os.path.getmtime(filename):
        _instance = Commands(filename)
        _cmdfile_fmttime = os.path.getmtime(filename)
    return _instance
示例#6
0
 def install_assistant(self, language, filename):
     flag = False
     if not assistant.has_key(language):
         flag = True
         assistant[language] = [self.get_assistant(filename)]
         obj = assistant[language][0]
         #install include files
         for f in obj.ini.include.values():
             fname = common.getConfigPathFile(f)
             if fname:
                 assistant[language].insert(-1, self.get_assistant(fname))
     else:
         objs = assistant[language]
         for i, obj in enumerate(objs):
             if os.path.getmtime(obj.filename) > obj.ftime:
                 del assistant[language]
                 self.install_assistant(language, filename)
                 flag = True
                 break
     return flag
示例#7
0
 def install_assistant(self, language, filename):
     flag = False
     if not assistant.has_key(language):
         flag = True
         assistant[language] = [self.get_assistant(filename)]
         obj = assistant[language][0]
         #install include files
         for f in obj.ini.include.values():
             fname = common.getConfigPathFile(f)
             if fname:
                 assistant[language].insert(-1, self.get_assistant(fname))
     else:
         objs = assistant[language]
         for i, obj in enumerate(objs):
             if os.path.getmtime(obj.filename) > obj.ftime:
                 del assistant[language]
                 self.install_assistant(language, filename)
                 flag = True
                 break
     return flag
示例#8
0
    def __init__(self, name, filewildchar, syntaxtype, stxfile=''):
        self.initmixin()

        self.name = name
        if filewildchar:
            self.wildcharprompt, self.wildchar = filewildchar.split('|')
        else:
            self.wildchar = self.wildchar = ''
            
        #stx files will save in conf/stx folder
        self.stxfile = common.getConfigPathFile(stxfile, prefix='stx')
        if not self.stxfile:
            from modules import Globals
            path = os.path.join(Globals.confpath, 'stx')
            if not os.path.exists(path):
                os.makedirs(path)
            self.stxfile = os.path.join(path, stxfile)
        self.syntaxtype = syntaxtype
        
        self.init()
示例#9
0
    def __init__(self, name, filewildchar, syntaxtype, stxfile=''):
        self.initmixin()

        self.name = name
        if filewildchar:
            self.wildcharprompt, self.wildchar = filewildchar.split('|')
        else:
            self.wildchar = self.wildchar = ''

        #stx files will save in conf/stx folder
        self.stxfile = common.getConfigPathFile(stxfile, prefix='stx')
        if not self.stxfile:
            from modules import Globals
            path = os.path.join(Globals.confpath, 'stx')
            if not os.path.exists(path):
                os.makedirs(path)
            self.stxfile = os.path.join(path, stxfile)
        self.syntaxtype = syntaxtype

        self.init()
示例#10
0
def new_file(win, lexname=None):
    if not lexname:
        lexname = win.pref.last_new_type
    if lexname:
        lexer = win.lexers.getNamedLexer(lexname)
        text = ''
        if lexer:
            templatefile = common.getConfigPathFile('template.%s' % lexer.name)
            if os.path.exists(templatefile):
                text = file(templatefile).read()
                text = common.decode_string(text)
                import re
                eolstring = {0: '\n', 1: '\r\n', 2: '\r'}
                eol = eolstring[Globals.pref.default_eol_mode]
                text = re.sub(r'\r\n|\r|\n', eol, text)
            else:
                text = ''
        document = win.editctrl.new(defaulttext=text, language=lexer.name)
        if document:
            document.goto(document.GetTextLength())
    else:
        win.editctrl.new()
示例#11
0
文件: mFileNew.py 项目: hfpiao/ulipad
def new_file(win, lexname=None):
    if not lexname:
        lexname = win.pref.last_new_type
    if lexname:
        lexer = win.lexers.getNamedLexer(lexname)
        text = ""
        if lexer:
            templatefile = common.getConfigPathFile("template.%s" % lexer.name)
            if os.path.exists(templatefile):
                text = file(templatefile).read()
                text = common.decode_string(text)
                import re

                eolstring = {0: "\n", 1: "\r\n", 2: "\r"}
                eol = eolstring[Globals.pref.default_eol_mode]
                text = re.sub(r"\r\n|\r|\n", eol, text)
            else:
                text = ""
        document = win.editctrl.new(defaulttext=text, language=lexer.name)
        if document:
            document.goto(document.GetTextLength())
    else:
        win.editctrl.new()
示例#12
0
def OnDocbookEnclose(editor):
    #find the docbook.acp file
    docbookini = common.getConfigPathFile('docbook_xml.ini')
    from modules import dict4ini
    x = dict4ini.DictIni(docbookini)
    taglist = x.default.taglist
    taglist.sort()
    #popup a selection win
    if taglist:
        from modules.EasyGuider import EasyDialog
        dialog = [
            ('single', 'tagname', taglist[0], tr('Select a tag:'), taglist),
        ]
        dlg = EasyDialog.EasyDialog(editor,
                                    tr('Select a DocBook Element Name'),
                                    dialog)
        values = None
        if dlg.ShowModal() == wx.ID_OK:
            values = dlg.GetValue()
        dlg.Destroy()
        if values:
            tagname = values['tagname']
            text = editor.GetSelectedText()
            editor.BeginUndoAction()
            if text:
                editor.ReplaceSelection('')
            if x.tag_values.has_key(tagname):
                settext(editor, [x.tag_values[tagname]])
            else:
                editor.AddText('<%s>%s</%s>' % (tagname, text, tagname))
                pos = editor.GetCurrentPos() - len(values['tagname']) - 3
                editor.GotoPos(pos)
            editor.EndUndoAction()
    else:
        common.showerror(
            editor, tr("There are not tags defined in conf/docbook_xml.ini."))