def call_lexer(win, oldfilename, filename, language):

    #    if oldfilename == filename and filename:
    #        return
    lexer_obj = None
    flag = False
    for lexer in win.mainframe.lexers.lexobjs:
        prjfile = common.getProjectFile(filename)
        ini = dict4ini.DictIni(prjfile)
        ext = os.path.splitext(filename)[1]
        lexname = ini.highlight[ext]

        if lexname and lexname == lexer.name:  #find acp option
            if not hasattr(win, 'lexer') or lexname != win.lexer.name:
                lexer_obj = lexer
                flag = True
                break

        if not lexname and (language and language == lexer.name
                            or lexer.matchfile(filename)):
            if not hasattr(win, 'lexer') or lexer.name != win.lexer.name:
                lexer_obj = lexer
                flag = True
                break

    else:
        #        if filename:
        #            win.mainframe.lexers.getNamedLexer('text').colourize(win)
        #        else:
        if not hasattr(win, 'lexer'):
            lexer_obj = Globals.mainframe.lexers.getDefaultLexer()
            flag = True
    if flag:
        lexer_obj.colourize(win)
        wx.CallAfter(Globals.mainframe.editctrl.switch, win)
示例#2
0
def OnSearchJumpDef(win, event):
    global _mlist

    word = getword(win)
    from modules import ctags

    flag = False
    prjfile = common.getProjectFile(win.document.getFilename())
    if prjfile:
        path = os.path.dirname(prjfile)
        ini = dict4ini.DictIni(prjfile)
        s = []
        for c in ini.ctags.values():
            c = os.path.join(path, c)
            p = os.path.dirname(c)
            try:
                s.extend(ctags.get_def(c, word, p))
            except:
                error.traceback()
        if len(s) == 1:
            d, f, m = s[0]
            win.editctrl.new(f)
            flag = jump_to_file(win, d, f, m)
        elif len(s) > 1:
            text = []
            _mlist = {}
            for i, v in enumerate(s):
                d, f, m = v
                key = str(i + 1) + '|' + d + '|' + os.path.basename(f)
                text.append(key)
                _mlist[key] = (d, f, m)
            win.document.UserListShow(2, " ".join(text))
            flag = True
    if not flag:
        win.document.callplugin('on_jump_definition', win.document, word)
示例#3
0
def OnSearchJumpDef(win, event):
    global _mlist
    
    word = getword(win)
    from modules import ctags
    
    flag = False
    prjfile = common.getProjectFile(win.document.getFilename())
    if prjfile:
        path = os.path.dirname(prjfile)
        ini = dict4ini.DictIni(prjfile)
        s = []
        for c in ini.ctags.values():
            c = os.path.join(path, c)
            p = os.path.dirname(c)
            try:
                s.extend(ctags.get_def(c, word, p))
            except:
                error.traceback()
        if len(s) == 1:
            d, f, m = s[0]
            win.editctrl.new(f)
            flag = jump_to_file(win, d, f, m)
        elif len(s) > 1:
            text = []
            _mlist = {}
            for i, v in enumerate(s):
                d, f, m = v
                key = str(i+1)+'|'+d+'|'+os.path.basename(f)
                text.append(key)
                _mlist[key] = (d, f, m)
            win.document.UserListShow(2, " ".join(text))
            flag = True
    if not flag:
        win.document.callplugin('on_jump_definition', win.document, word)
示例#4
0
def call_lexer(win, oldfilename, filename, language):
    i = get_inputassistant_obj(win)
#    i.install_acp(win, win.languagename)

    files = []
    objs = i.get_acp(win.languagename)
    if objs:
        files = [obj.filename for obj in objs]

    b = glob.glob(os.path.join(Globals.workpath, '*.acp')) + glob.glob(os.path.join(Globals.confpath, '*.acp'))
    afiles = set(b)
    afiles.difference_update(files)
    afiles = list(afiles)
    afiles.sort()

    prjfile = common.getProjectFile(filename)
    ini = dict4ini.DictIni(prjfile)
    ext = os.path.splitext(filename)[1]

    acps = ini.acp[ext]
    if acps:
        if isinstance(acps, str):
            acps = [acps]

        for f in acps:
            for acpf in afiles:
                if os.path.basename(acpf) == f:
                    win.custom_assistant.append(i.get_assistant(acpf))
                    
    i.install_acp(win, win.languagename)
示例#5
0
def call_lexer(win, oldfilename, filename, language):
    
#    if oldfilename == filename and filename:
#        return
    lexer_obj = None
    flag = False
    for lexer in win.mainframe.lexers.lexobjs:
        prjfile = common.getProjectFile(filename)
        ini = dict4ini.DictIni(prjfile)
        ext = os.path.splitext(filename)[1]
        lexname = ini.highlight[ext]
        
        if lexname and lexname == lexer.name:   #find acp option
            if not hasattr(win, 'lexer') or lexname != win.lexer.name:
                lexer_obj = lexer
                flag = True
                break
            
        if not lexname and (language and language == lexer.name or lexer.matchfile(filename)):
            if not hasattr(win, 'lexer') or lexer.name != win.lexer.name:
                lexer_obj = lexer
                flag = True
                break
            
    else:
#        if filename:
#            win.mainframe.lexers.getNamedLexer('text').colourize(win)
#        else:
        if not hasattr(win, 'lexer'):
            lexer_obj = Globals.mainframe.lexers.getDefaultLexer()
            flag = True
    if flag:
        lexer_obj.colourize(win)
        wx.CallAfter(Globals.mainframe.editctrl.switch, win)
def call_lexer(win, oldfilename, filename, language):
    i = get_inputassistant_obj(win)
    #    i.install_acp(win, win.languagename)

    files = []
    objs = i.get_acp(win.languagename)
    if objs:
        files = [obj.filename for obj in objs]

    b = glob.glob(os.path.join(Globals.workpath, '*.acp')) + glob.glob(
        os.path.join(Globals.confpath, '*.acp'))
    afiles = set(b)
    afiles.difference_update(files)
    afiles = list(afiles)
    afiles.sort()

    prjfile = common.getProjectFile(filename)
    ini = dict4ini.DictIni(prjfile)
    ext = os.path.splitext(filename)[1]

    acps = ini.acp[ext]
    if acps:
        if isinstance(acps, str):
            acps = [acps]

        for f in acps:
            for acpf in afiles:
                if os.path.basename(acpf) == f:
                    win.custom_assistant.append(i.get_assistant(acpf))

    i.install_acp(win, win.languagename)