Package plugins :: Package core :: Package bindlist :: Module main
[hide private]
[frames] | no frames]

Source Code for Module plugins.core.bindlist.main

 1  #-*- coding: utf8 -* 
 2  # 
 3  # Max E. Kuznecov <syhpoon@syhpoon.name> 2008 
 4  # 
 5   
 6  from libxyz.core.plugins import BasePlugin 
 7  from libxyz.core.utils import bstring 
 8  from libxyz.ui import lowui 
 9   
10  import libxyz.ui as uilib 
11   
12 -class XYZPlugin(BasePlugin):
13 "Plugin bindlist" 14 15 NAME = u"bindlist" 16 AUTHOR = u"Max E. Kuznecov <syhpoon@syhpoon.name>" 17 VERSION = u"0.1" 18 BRIEF_DESCRIPTION = u"Show keybindings" 19 FULL_DESCRIPTION = u"Plugin is used to display all current keybindings "\ 20 u"along with corresponding contextes and methods" 21 NAMESPACE = u"core" 22 HOMEPAGE = u"xyzcmd.syhpoon.name" 23
24 - def __init__(self, xyz):
25 super(XYZPlugin, self).__init__(xyz) 26 27 self.export(self.show_binds) 28 29 self._keys = uilib.Keys()
30 31 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 32
33 - def show_binds(self):
34 """ 35 Show keybindings 36 """ 37 38 _data = self.xyz.km.get_binds() 39 40 _entries = [] 41 42 _divattr = self.xyz.skin.attr(uilib.XYZListBox.resolution, u"border") 43 44 _entries.append(lowui.Text(u"%-10s %-20s %s" % 45 (_(u"Context"), _(u"Bind"), _(u"Method")))) 46 _entries.append(uilib.Separator(div_attr=_divattr)) 47 48 for _context in sorted(_data.keys()): 49 for _bind in sorted(_data[_context].keys(), 50 cmp=lambda x, y: cmp(bstring(x), bstring(y))): 51 if _data[_context][_bind] is None: 52 continue 53 54 _entries.append(lowui.Text(u"%-10s %-20s %s" % 55 (_context, _bind, _data[_context][_bind].ns))) 56 57 _walker = lowui.SimpleListWalker(_entries) 58 59 _dim = tuple([x - 2 for x in self.xyz.screen.get_cols_rows()]) 60 61 uilib.XYZListBox(self.xyz, self.xyz.top, _walker, 62 _(u"Keybindings"), _dim).show()
63