Beispiel #1
0
def poshl(s, e):
    st = "\\%%%dl\\%%%dc" % s
    en = "\\%%%dl\\%%%dc" % e
    cmd = 'syntax region Todo start=/%s/ end=/%s/' % (st, en)
    logging.info(cmd)

    vim.command(cmd)
Beispiel #2
0
def handle(key, value):
    if key == "wubi":
        if value == 'true':
            rc.IM_Wubi = True
        else:
            rc.IM_Wubi = False
        log.info("IM Setting: %s: %s", key, value)
Beispiel #3
0
 def refresh( self ):
     if self.tag_root_dir:
         os.popen("cd %s;ctags -R *"  % self.tag_root_dir )
         vim.command("echo 'the ctags is ok'")
         self.open( )
     else:
         logging.info("this is not a project" )
Beispiel #4
0
def Init():
    ftpath = os.path.realpath(__file__)
    ftpath = os.path.dirname(ftpath)
    ftpath = os.path.join(ftpath, 'prompt')

    plugins = Plugins(ftpath)
    plugins.loads()
    log.info(__Handles)
Beispiel #5
0
 def cb_space(self):
     log.info("status.name %s", Status.name)
     if Status.name == 'wubi':
         feedkeys('\<C-N>')
         feedkeys('\<C-Y>')
         return True
     else:
         #feedkeys('\<C-Y>')
         feedkeys(' ')
         return True
Beispiel #6
0
 def open(self):
     self.items = None
     self.funs= None
     tagsfile = self.tags
     if os.path.isfile(tagsfile):
         self.tagsfile = tagsfile;
         self.tagfile = ctags.CTags(self.tagsfile)
         self.entry = ctags.TagEntry()
         return True
     else:
         logging.info( '%s is no tags.' % tagsfile)
         return False
Beispiel #7
0
def Debug(level):
    if not level in subcmd:
        return

    level = level.upper()
    if not hasattr(logging, level):
        return

    level = getattr(logging, level)
    log.setLevel(level)


    log.debug('debug')
    log.info('info')
    log.warning('warning')
    log.error('error')
    log.critical('critical')
Beispiel #8
0
def get_child(Node):
    path = Node.ctx
    log.info("get child path: %s", path)

    dirs, names = libpath.listdir(path)
    if dirs == None:
        return []

    ######## handle for new file
    dels = []
    for f in BufNewFile.get(path, []):
        if f in names:
            dels.append(f)
            continue
        names.append(f)
    if dels:
        for f in dels:
            BufNewFile.get(path).remove(f)


    names = black_filter_files(names)
    names = sorted_by_expand_name(names)

    dirs  = sorted(black_filter_files(dirs))

    def delete(leaf):
        leaf.father.refresh()

    for n in names:
        p = libpath.join(path, n)
        l = frainui.Leaf(n, p, leaf_handle)
        l.FREventBind('delete', delete)
        Node.append(l)

    for d in dirs:
        p = libpath.join(path, d)
        Node.append(frainui.Node(d, p, get_child))
Beispiel #9
0
def BufEnter(FrainList):
    if vim.current.buffer.options[ 'buftype' ] != '':
        return -1

    if vim.current.buffer.name == '':
        return -1

    """显示当前的 buffer 对应的文件在 win list 中的位置
    如果, buffer 不属于任何一个 project, 返回 `NROOT'
    之后生成当前 buffer 在 win list 中的 url, 由 win list 进行查询.
    """
    path = utils.bufferpath()
    if not path:
        return
    log.info('path: %s', path)

    for p in project.Project.All:
        if path.startswith(p.root):
            break
    else:
        return

    names = utils.getnames(p.root, path)
    FrainList.listwin.find(names)
Beispiel #10
0
 def log(self):
     for ft, v in self.ft.items():
         log.info("Redirects: %s: %s", ft, v)
Beispiel #11
0
def event_callback( cbid ):#事件回调函数  @event: 当前的事件
    cb = __Event_Map.get(cbid)
    if not cb:
        logging.info("Not Found cb for: %s" % cbid)
        return
    cb()
Beispiel #12
0
    def open_tag(self):
        taginfo         = self.taginfo()
        taglist         = taginfo["taglist"]
        tagname         = taginfo["tagname"]
        num_total       = taginfo["num_total"]
        pos_for_taglist = taginfo["pos_for_taglist"]

        if taginfo["num_total"]  == 0:
            vim.command("echo 'not find'")
            return 0

        #echo
        vim.command("echo '%s %s %s/%s'"  % (
            taginfo['tagname'],
            taglist[pos_for_taglist]['kind'],
            pos_for_taglist  + 1,
            num_total))

        taginfo_path = taglist[pos_for_taglist]['filename']
        if taginfo_path != vim.current.buffer.name:
                #保存文件
                vim.command('silent update')
                vim.command("silent edit %s"  %  taginfo_path)
        #cmd  #go to the tag
        try:
            cmd = taglist[pos_for_taglist]['cmd']

            #定位光标到tag上
            show_enco=vim.eval('&encoding')
            file_enco=vim.eval('&fileencoding')
            if file_enco != show_enco:
                if file_enco:
                    cmd = cmd.decode(file_enco)\
                        .encode(show_enco)
            line_nu = 0
            found = [  ]
            if cmd.isdigit():
                line_nu = int(cmd)   - 1
                found.append( line_nu )
            else:
                patten = cmd[2: -2].replace(r'\/','/')
                patten = patten.replace(r'\r','')
                for line in vim.current.buffer:
                    if line.startswith(patten):
                        found.append( line_nu  )
                    line_nu+=1

            if found:
                line_nu = found.pop( )
                line = vim.current.buffer[line_nu]
                col_nu = line.find(tagname)
                if col_nu < 0:
                    col_nu = 0

                vim.current.window.cursor = (line_nu  + 1, 0)
                vim.command("normal %sl"  % col_nu)
            else:
                logging.info('patten'+patten)

        except vim.error, e:
            logging.error(e)
            return  -1