summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2012-10-09 06:00:43 +0000
committerFlorent Le Coz <louiz@louiz.org>2012-10-09 06:00:43 +0000
commitb50acaae0b4499aec0d06f91739d23e6aa212156 (patch)
tree3569ee25769679ef871b0a39a870d049bae7b27c /src
parentc9a244ceb02ae0fe6710ddb08f573deb6b0bbd3b (diff)
downloadpoezio-b50acaae0b4499aec0d06f91739d23e6aa212156.tar.gz
poezio-b50acaae0b4499aec0d06f91739d23e6aa212156.tar.bz2
poezio-b50acaae0b4499aec0d06f91739d23e6aa212156.tar.xz
poezio-b50acaae0b4499aec0d06f91739d23e6aa212156.zip
Send a real \t when pasting a text containing tabs.
Diffstat (limited to 'src')
-rw-r--r--src/core.py22
-rw-r--r--src/windows.py7
2 files changed, 16 insertions, 13 deletions
diff --git a/src/core.py b/src/core.py
index 4e7cb297..439fa219 100644
--- a/src/core.py
+++ b/src/core.py
@@ -354,10 +354,6 @@ class Core(object):
"""
main loop waiting for the user to press a key
"""
- def sanitize_input(key):
- if key == '^I':
- return ' '
- return key
def replace_line_breaks(key):
if key == '^J':
return '\n'
@@ -383,9 +379,16 @@ class Core(object):
if len(char) == 1:
current.append(char)
else:
- res.append(current)
+ # special case for the ^I key, it’s considered as \t
+ # only when pasting some text, otherwise that’s the ^I
+ # (or M-i) key, which stands for completion by default.
+ if char == '^I' and len(char_list) != 1:
+ current.append('\t')
+ continue
+ if current:
+ res.append(current)
+ current = []
res.append([char])
- current = []
if current:
res.append(current)
return res
@@ -393,8 +396,6 @@ class Core(object):
if self.paused: continue
big_char_list = [common.replace_key_with_bound(key)\
for key in self.read_keyboard()]
- log.debug(big_char_list)
- log.debug(separate_chars_from_bindings(big_char_list))
# whether to refresh after ALL keys have been handled
for char_list in separate_chars_from_bindings(big_char_list):
if self.paused:
@@ -421,10 +422,7 @@ class Core(object):
else:
res = self.do_command(replace_line_breaks(char), False)
else:
- self.do_command(''.join(map(
- lambda x: sanitize_input(x),
- char_list)
- ), True)
+ self.do_command(''.join(char_list), True)
self.doupdate()
def save_config(self):
diff --git a/src/windows.py b/src/windows.py
index a8af3b7f..cf341e28 100644
--- a/src/windows.py
+++ b/src/windows.py
@@ -1380,7 +1380,12 @@ class MessageInput(Input):
Refresh the line onscreen, from the pos and pos_line, with colors
"""
with g_lock:
- text = self.text.replace('\n', '|')
+ # Replace \t with ' ' just to make the input easily editable.
+ # That's not perfect, because we cannot differenciate a tab and
+ # a space. But at least it makes it possible to paste text
+ # containing a tab by sending a real tab, not just four spaces
+ # while still being able to edit the input in that case.
+ text = self.text.replace('\n', '|').replace('\t', ' ')
self._win.erase()
if self.color:
self._win.attron(to_curses_attr(self.color))