summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core.py8
-rw-r--r--src/tabs.py16
-rw-r--r--src/windows.py23
3 files changed, 25 insertions, 22 deletions
diff --git a/src/core.py b/src/core.py
index 8de694f7..b2fde79d 100644
--- a/src/core.py
+++ b/src/core.py
@@ -787,7 +787,10 @@ class Core(object):
"""
main loop waiting for the user to press a key
"""
- # curses.ungetch(0) # FIXME
+ def replace_line_breaks(key):
+ if key == '^J':
+ return '\n'
+ return key
while self.running:
char_list = [common.replace_key_with_bound(key)\
for key in self.read_keyboard()]
@@ -812,8 +815,7 @@ class Core(object):
if res:
self.refresh_window()
else:
- for char in char_list:
- self.do_command(char, True)
+ self.do_command(''.join(list(map(replace_line_breaks, char_list))), True)
self.refresh_window()
self.doupdate()
diff --git a/src/tabs.py b/src/tabs.py
index f1f4fa16..65dabe20 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -941,7 +941,7 @@ class MucTab(ChatTab):
if not raw and key in self.key_func:
self.key_func[key]()
return False
- self.input.do_command(key)
+ self.input.do_command(key, raw=raw)
empty_after = self.input.get_text() == '' or (self.input.get_text().startswith('/') and not self.input.get_text().startswith('//'))
self.send_composing_chat_state(empty_after)
return False
@@ -1432,7 +1432,7 @@ class PrivateTab(ChatTab):
if not raw and key in self.key_func:
self.key_func[key]()
return False
- self.input.do_command(key)
+ self.input.do_command(key, raw=raw)
if not self.on:
return False
empty_after = self.input.get_text() == '' or (self.input.get_text().startswith('/') and not self.input.get_text().startswith('//'))
@@ -1901,12 +1901,12 @@ class RosterInfoTab(Tab):
return self.name
def on_input(self, key, raw):
- if key == '^M':
+ if raw and key == '^M':
selected_row = self.roster_win.get_selected_row()
- res = self.input.do_command(key)
+ res = self.input.do_command(key, raw=raw)
if res:
return True
- if key == '^M':
+ if raw and key == '^M':
self.core.on_roster_enter_key(selected_row)
return selected_row
elif not raw and key in self.key_func:
@@ -2173,7 +2173,7 @@ class ConversationTab(ChatTab):
if not raw and key in self.key_func:
self.key_func[key]()
return False
- self.input.do_command(key)
+ self.input.do_command(key, raw=raw)
empty_after = self.input.get_text() == '' or (self.input.get_text().startswith('/') and not self.input.get_text().startswith('//'))
self.send_composing_chat_state(empty_after)
return False
@@ -2355,7 +2355,7 @@ class MucListTab(Tab):
self.complete_commands(self.input)
def on_input(self, key, raw):
- res = self.input.do_command(key)
+ res = self.input.do_command(key, raw=raw)
if res:
return True
if not raw and key in self.key_func:
@@ -2400,7 +2400,7 @@ class SimpleTextTab(Tab):
self.input.do_command("/") # we add the slash
def on_input(self, key, raw):
- res = self.input.do_command(key)
+ res = self.input.do_command(key, raw=raw)
if res:
return True
if not raw and key in self.key_func:
diff --git a/src/windows.py b/src/windows.py
index 8b723b1e..e77bb18b 100644
--- a/src/windows.py
+++ b/src/windows.py
@@ -756,7 +756,7 @@ class HelpText(Win):
self.finish_line(get_theme().COLOR_INFORMATION_BAR)
self._refresh()
- def do_command(self, key):
+ def do_command(self, key, raw=False):
return False
class Input(Win):
@@ -796,7 +796,7 @@ class Input(Win):
"KEY_BACKSPACE": self.key_backspace,
"M-KEY_BACKSPACE": self.delete_word,
'^?': self.key_backspace,
- '^J': self.add_line_break,
+ # '^J': self.add_line_break,
}
Win.__init__(self)
self.text = ''
@@ -1088,22 +1088,23 @@ class Input(Win):
self.text += nick
self.key_end(False)
- def do_command(self, key, reset=True):
+ def do_command(self, key, reset=True, raw=False):
if key in self.key_func:
res = self.key_func[key]()
- if self.on_input:
+ if not raw and self.on_input:
self.on_input(self.get_text())
return res
- if not key or len(key) > 1:
+ if not raw and (not key or len(key) > 1):
return False # ignore non-handled keyboard shortcuts
if reset:
self.reset_completion()
self.text = self.text[:self.pos+self.line_pos]+key+self.text[self.pos+self.line_pos:]
(y, x) = self._win.getyx()
- if x == self.width-1:
- self.line_pos += 1 # wcwidth.wcswidth(key)
- else:
- self.pos += 1 # wcwidth.wcswidth(key)
+ for i in range(len(key)):
+ if x == self.width-1:
+ self.line_pos += 1 # wcwidth.wcswidth(key)
+ else:
+ self.pos += 1 # wcwidth.wcswidth(key)
if reset:
self.rewrite_text()
if self.on_input:
@@ -1269,8 +1270,8 @@ class CommandInput(Input):
self.key_func["M-B"] = self.key_down
self.histo_pos = -1
- def do_command(self, key):
- res = Input.do_command(self, key)
+ def do_command(self, key, refresh=True, raw=False):
+ res = Input.do_command(self, key, refresh, raw)
if self.on_input:
self.on_input(self.get_text())
return res