Trees | Indices | Help |
|
---|
|
1 #-*- coding: utf8 -* 2 # 3 # Max E. Kuznecov ~syhpoon <syhpoon@syhpoon.name> 2008 4 # 5 # This file is part of XYZCommander. 6 # XYZCommander is free software: you can redistribute it and/or modify 7 # it under the terms of the GNU Lesser Public License as published by 8 # the Free Software Foundation, either version 3 of the License, or 9 # (at your option) any later version. 10 # XYZCommander is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU Lesser Public License for more details. 14 # You should have received a copy of the GNU Lesser Public License 15 # along with XYZCommander. If not, see <http://www.gnu.org/licenses/>. 16 17 from libxyz.ui.display import is_lowui_ge_0_9_9 1820 """ 21 Wrap get_input and seek in user-defined keycodes before return keys 22 """ 23 24 WIN_RESIZE = 'window resize' 2510927 self.xyz = xyz 28 self.plugin = xyz.pm.load(u":core:keycodes") 29 self.keycodes = {} 30 self._resized = False 31 32 self.update()33 34 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3537 """ 38 Set/load keycodes data 39 @param data: Keycodes data. If not provided load via get_keys() 40 @type data: dict 41 """ 42 43 if data is not None: 44 self.keycodes = data 45 else: 46 self.keycodes = self.plugin.get_keys()47 48 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4951 """ 52 Get input from screen and search if it matches any user-defined 53 keycodes 54 55 @param allow_empty: If set return empty list if nothing was typed 56 """ 57 58 _input = None 59 60 if allow_empty: 61 if is_lowui_ge_0_9_9(): 62 self.xyz.screen.set_input_timeouts(0) 63 64 while True: 65 _in = self.xyz.screen.get_input() 66 67 if not _in: 68 if allow_empty: 69 _input = _in 70 break 71 else: 72 continue 73 74 if self.WIN_RESIZE in _in: 75 self._resized = True 76 77 try: 78 _input = [self.keycodes[tuple(_in)]] 79 except KeyError: 80 _input = _in 81 82 break 83 84 if allow_empty: 85 if is_lowui_ge_0_9_9(): 86 self.xyz.screen.set_input_timeouts(None) 87 88 return _input89 90 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 91 99 100 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 101 107 108 resized = property(_resized_get, _resized_set)
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu Sep 16 01:51:58 2010 | http://epydoc.sourceforge.net |