summaryrefslogtreecommitdiff
path: root/poezio/keyboard.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2017-11-12 15:03:09 +0100
committermathieui <mathieui@mathieui.net>2017-11-12 15:03:09 +0100
commitd55cc5872503567775f0d7a7731d6f489bf2299b (patch)
tree725f9e7b8144d36054447b3c82edfb45bda8df1d /poezio/keyboard.py
parent92496db823db34f7f7fb1ab31eaef093a707c3e8 (diff)
downloadpoezio-d55cc5872503567775f0d7a7731d6f489bf2299b.tar.gz
poezio-d55cc5872503567775f0d7a7731d6f489bf2299b.tar.bz2
poezio-d55cc5872503567775f0d7a7731d6f489bf2299b.tar.xz
poezio-d55cc5872503567775f0d7a7731d6f489bf2299b.zip
yapf -ir
Diffstat (limited to 'poezio/keyboard.py')
-rwxr-xr-xpoezio/keyboard.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/poezio/keyboard.py b/poezio/keyboard.py
index ccf9e752..fe0dde08 100755
--- a/poezio/keyboard.py
+++ b/poezio/keyboard.py
@@ -5,7 +5,6 @@
#
# Poezio is free software: you can redistribute it and/or modify
# it under the terms of the zlib license. See the COPYING file.
-
"""
Functions to interact with the keyboard
Mainly, read keys entered and return a string (most
@@ -27,6 +26,7 @@ log = logging.getLogger(__name__)
# processing of keys)
continuation_keys_callback = None
+
def get_next_byte(s):
"""
Read the next byte of the utf-8 char
@@ -40,7 +40,8 @@ def get_next_byte(s):
return (None, None)
if len(c) >= 4:
return (None, c)
- return (ord(c), c.encode('latin-1')) # returns a number and a bytes object
+ return (ord(c), c.encode('latin-1')) # returns a number and a bytes object
+
def get_char_list(s):
ret_list = []
@@ -50,7 +51,7 @@ def get_char_list(s):
except curses.error:
# No input, this means a timeout occurs.
return ret_list
- except ValueError: # invalid input
+ except ValueError: # invalid input
log.debug('Invalid character entered.')
return ret_list
# Set to non-blocking. We try to read more bytes. If there are no
@@ -68,10 +69,11 @@ def get_char_list(s):
part = s.get_wch()
if part == '[':
# CTRL+arrow and meta+arrow keys have a long format
- part += s.get_wch() + s.get_wch() + s.get_wch() + s.get_wch()
+ part += s.get_wch() + s.get_wch() + s.get_wch(
+ ) + s.get_wch()
except curses.error:
pass
- except ValueError: # invalid input
+ except ValueError: # invalid input
log.debug('Invalid character entered.')
else:
key = 'M-%s' % part
@@ -93,6 +95,7 @@ def get_char_list(s):
key = '^M'
ret_list.append(key)
+
class Keyboard(object):
def __init__(self):
self.escape = False
@@ -132,6 +135,7 @@ class Keyboard(object):
self.escape = False
return ret_list
+
if __name__ == '__main__':
import sys
keyboard = Keyboard()