tui.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:stig 作者: rndusr 项目源码 文件源码
def run(self, context, KEY, ACTION):
        keymap = self.tui.keymap

        key = KEY
        if len(ACTION) == 1 and ACTION[0][0] == '<' and ACTION[0][-1] == '>':
            # ACTION is another key (e.g. 'j' -> 'down')
            action = keymap.mkkey(ACTION[0])
        else:
            action = ' '.join(shlex.quote(x) for x in ACTION)

        if context is None:
            from ...tui.keymap import DEFAULT_CONTEXT
            context = DEFAULT_CONTEXT
        elif context not in _get_KEYMAP_CONTEXTS():
            log.error('Invalid context: {!r}'.format(context))
            return False

        try:
            keymap.bind(key, action, context=context)
        except ValueError as e:
            log.error(e)
            return False
        else:
            return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号