diff options
author | Florent Le Coz <louiz@louiz.org> | 2011-02-15 21:03:24 +0100 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2011-02-15 21:03:24 +0100 |
commit | 32d8a5281db726abd80df4e87a013eafc985c502 (patch) | |
tree | a1f465c16f9dd35fadcf6fbdd98485f9e2ecefec /src/keyboard.py | |
parent | d184c555803b564148d8391b7a433acf891a8c87 (diff) | |
download | poezio-32d8a5281db726abd80df4e87a013eafc985c502.tar.gz poezio-32d8a5281db726abd80df4e87a013eafc985c502.tar.bz2 poezio-32d8a5281db726abd80df4e87a013eafc985c502.tar.xz poezio-32d8a5281db726abd80df4e87a013eafc985c502.zip |
Line ^M are now converted to ^J if we are pasting
from the clipboard, making it possible to paste huge multi-lines
texts in only one message
Diffstat (limited to 'src/keyboard.py')
-rw-r--r-- | src/keyboard.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/keyboard.py b/src/keyboard.py index 188e65eb..ba845b83 100644 --- a/src/keyboard.py +++ b/src/keyboard.py @@ -21,6 +21,10 @@ of the time ONE char, but may be longer if it's a keyboard shortcut, like ^A, M-a or KEY_RESIZE) """ +import time + +last_char_time = None + def get_next_byte(s): """ Read the next byte of the utf-8 char @@ -41,6 +45,10 @@ def read_char(s): Read one utf-8 char see http://en.wikipedia.org/wiki/UTF-8#Description """ + # We use a timer to know if we are pasting from the + # clipboard or not + global last_char_time + last_char_time = time.time() (first, char) = get_next_byte(s) if not isinstance(first, int): # Keyboard special, like KEY_HOME etc return char @@ -48,7 +56,10 @@ def read_char(s): return "KEY_BACKSPACE" if first < 127: # ASCII char on one byte if first <= 26: # transform Ctrl+* keys - return "^"+chr(first + 64) + char = chr(first + 64) + if char == 'M' and time.time() - last_char_time < 0.0001: + char = 'J' + return "^"+char if first == 27: second = read_char(s) res = 'M-%s' % (second,) |