1
2
3
4
5
6 from libxyz.core.plugins import BasePlugin
7 from libxyz.core.utils import ustring, bstring
8
9 import libxyz.ui as uilib
10
12 """
13 Plugin testinput
14 """
15
16 NAME = u"testinput"
17 AUTHOR = u"Max E. Kuznecov <syhpoon@syhpoon.name>"
18 VERSION = u"0.2"
19 BRIEF_DESCRIPTION = _(u"Test input")
20 FULL_DESCRIPTION = _(u"Simple dialog to show pressed keys.\n"\
21 u"Shortcut is what XYZCommander expects to see in "\
22 u"configuration files.\n"\
23 u"Raw is what low-level library emits to focus "\
24 u"widget.\n"\
25 u"If any keybinding currently exists for key it is "\
26 u"shown on the bottom line"
27 )
28 NAMESPACE = u"ui"
29 MIN_XYZ_VERSION = None
30 DOC = None
31 HOMEPAGE = u"xyzcmd.syhpoon.name"
32
39
40
41
43 """
44 Show test_box dialog
45 @param use_wrap: Whether to use input wrapper which honours
46 learned keys
47 """
48
49 _msg = _(u"Press any key. Escape twice to quit.")
50
51 _escape = 0
52 _escape_key = uilib.Shortcut(sc=[self._keys.ESCAPE])
53
54 while True:
55 shortcut = InputBox(self.xyz, self.xyz.top, bstring(_msg),
56 _(u"Input test")).show(use_wrap=use_wrap)
57
58 if shortcut == _escape_key:
59 _escape += 1
60 if _escape == 2:
61 return
62 else:
63 _escape = 0
64
65 method = self.xyz.km.get_method_by_key(shortcut)
66
67 _msg = u"Shortcut: '%s'. Raw: '%s'" % (
68 (u" ".join([ustring(x) for x in shortcut.sc]),
69 u" ".join([ustring(x) for x in shortcut.raw])))
70
71 if method is not None:
72 _msg = u"%s\n[%s]" % (_msg, method.ns)
73
74
75
103