1
2
3
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
13 "Plugin bindlist"
14
15 NAME = u"bindlist"
16 AUTHOR = u"Max E. Kuznecov <syhpoon@syhpoon.name>"
17 VERSION = u"0.2"
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 EVENTS = [("show_binds",
24 _(u"Event is fired before showing dialog. "\
25 u"Receives no arguments.")),
26 ]
27
34
35
36
38 """
39 Show keybindings
40 """
41
42 self.fire_event("show_binds")
43
44 _data = self.xyz.km.get_binds()
45
46 _entries = []
47
48 _divattr = self.xyz.skin.attr(uilib.XYZListBox.resolution, u"border")
49
50 _entries.append(lowui.Text(u"%-10s %-20s %s" %
51 (_(u"Context"), _(u"Bind"),
52 _(u"Method / Description"))))
53 _entries.append(uilib.Separator(div_attr=_divattr))
54
55 for _context in sorted(_data.keys()):
56 for _bind in sorted(_data[_context].keys(),
57 cmp=lambda x, y: cmp(bstring(x), bstring(y))):
58 if _data[_context][_bind] is None:
59 continue
60
61 _entries.append(lowui.Text(u"%-10s %-20s %s" %
62 (_context, _bind, _data[_context][_bind].ns)))
63
64 _walker = lowui.SimpleListWalker(_entries)
65
66 _dim = tuple([x - 2 for x in self.xyz.screen.get_cols_rows()])
67
68 uilib.XYZListBox(self.xyz, self.xyz.top, _walker,
69 _(u"Keybindings"), _dim).show()
70