Do not try to interpret keys as key shortcuts when pasting text.
Avoiding, for example, nickname completions when pasting a text containing the \t char. Also, pasting is a little because it doesn’t search an associated command for each pasted char. AWESOME.
This commit is contained in:
parent
27e587118b
commit
18dbc880e1
2 changed files with 20 additions and 17 deletions
|
@ -808,12 +808,12 @@ class Core(object):
|
||||||
if char in self.key_func:
|
if char in self.key_func:
|
||||||
self.key_func[char]()
|
self.key_func[char]()
|
||||||
else:
|
else:
|
||||||
res = self.do_command(char)
|
res = self.do_command(char, False)
|
||||||
if res:
|
if res:
|
||||||
self.refresh_window()
|
self.refresh_window()
|
||||||
else:
|
else:
|
||||||
for char in char_list:
|
for char in char_list:
|
||||||
self.do_command(char)
|
self.do_command(char, True)
|
||||||
self.refresh_window()
|
self.refresh_window()
|
||||||
self.doupdate()
|
self.doupdate()
|
||||||
|
|
||||||
|
@ -1807,10 +1807,10 @@ class Core(object):
|
||||||
roster.save_to_config_file()
|
roster.save_to_config_file()
|
||||||
config.set_and_save('info_win_height', self.information_win_size, 'var')
|
config.set_and_save('info_win_height', self.information_win_size, 'var')
|
||||||
|
|
||||||
def do_command(self, key):
|
def do_command(self, key, raw):
|
||||||
if not key:
|
if not key:
|
||||||
return
|
return
|
||||||
return self.current_tab().on_input(key)
|
return self.current_tab().on_input(key, raw)
|
||||||
|
|
||||||
def on_roster_enter_key(self, roster_row):
|
def on_roster_enter_key(self, roster_row):
|
||||||
"""
|
"""
|
||||||
|
|
29
src/tabs.py
29
src/tabs.py
|
@ -258,7 +258,10 @@ class Tab(object):
|
||||||
"""
|
"""
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def on_input(self, key):
|
def on_input(self, key, raw):
|
||||||
|
"""
|
||||||
|
raw indicates if the key should activate the associated command or not.
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def update_commands(self):
|
def update_commands(self):
|
||||||
|
@ -934,8 +937,8 @@ class MucTab(ChatTab):
|
||||||
self.info_win.refresh()
|
self.info_win.refresh()
|
||||||
self.input.refresh()
|
self.input.refresh()
|
||||||
|
|
||||||
def on_input(self, key):
|
def on_input(self, key, raw):
|
||||||
if key in self.key_func:
|
if not raw and key in self.key_func:
|
||||||
self.key_func[key]()
|
self.key_func[key]()
|
||||||
return False
|
return False
|
||||||
self.input.do_command(key)
|
self.input.do_command(key)
|
||||||
|
@ -1425,8 +1428,8 @@ class PrivateTab(ChatTab):
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def on_input(self, key):
|
def on_input(self, key, raw):
|
||||||
if key in self.key_func:
|
if not raw and key in self.key_func:
|
||||||
self.key_func[key]()
|
self.key_func[key]()
|
||||||
return False
|
return False
|
||||||
self.input.do_command(key)
|
self.input.do_command(key)
|
||||||
|
@ -1897,7 +1900,7 @@ class RosterInfoTab(Tab):
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def on_input(self, key):
|
def on_input(self, key, raw):
|
||||||
if key == '^M':
|
if key == '^M':
|
||||||
selected_row = self.roster_win.get_selected_row()
|
selected_row = self.roster_win.get_selected_row()
|
||||||
res = self.input.do_command(key)
|
res = self.input.do_command(key)
|
||||||
|
@ -1906,7 +1909,7 @@ class RosterInfoTab(Tab):
|
||||||
if key == '^M':
|
if key == '^M':
|
||||||
self.core.on_roster_enter_key(selected_row)
|
self.core.on_roster_enter_key(selected_row)
|
||||||
return selected_row
|
return selected_row
|
||||||
elif key in self.key_func:
|
elif not raw and key in self.key_func:
|
||||||
return self.key_func[key]()
|
return self.key_func[key]()
|
||||||
|
|
||||||
def toggle_offline_show(self):
|
def toggle_offline_show(self):
|
||||||
|
@ -2166,8 +2169,8 @@ class ConversationTab(ChatTab):
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
def on_input(self, key):
|
def on_input(self, key, raw):
|
||||||
if key in self.key_func:
|
if not raw and key in self.key_func:
|
||||||
self.key_func[key]()
|
self.key_func[key]()
|
||||||
return False
|
return False
|
||||||
self.input.do_command(key)
|
self.input.do_command(key)
|
||||||
|
@ -2351,11 +2354,11 @@ class MucListTab(Tab):
|
||||||
if isinstance(self.input, windows.CommandInput):
|
if isinstance(self.input, windows.CommandInput):
|
||||||
self.complete_commands(self.input)
|
self.complete_commands(self.input)
|
||||||
|
|
||||||
def on_input(self, key):
|
def on_input(self, key, raw):
|
||||||
res = self.input.do_command(key)
|
res = self.input.do_command(key)
|
||||||
if res:
|
if res:
|
||||||
return True
|
return True
|
||||||
if key in self.key_func:
|
if not raw and key in self.key_func:
|
||||||
return self.key_func[key]()
|
return self.key_func[key]()
|
||||||
|
|
||||||
def on_lose_focus(self):
|
def on_lose_focus(self):
|
||||||
|
@ -2396,11 +2399,11 @@ class SimpleTextTab(Tab):
|
||||||
self.input.resize(1, self.width, self.height-1, 0)
|
self.input.resize(1, self.width, self.height-1, 0)
|
||||||
self.input.do_command("/") # we add the slash
|
self.input.do_command("/") # we add the slash
|
||||||
|
|
||||||
def on_input(self, key):
|
def on_input(self, key, raw):
|
||||||
res = self.input.do_command(key)
|
res = self.input.do_command(key)
|
||||||
if res:
|
if res:
|
||||||
return True
|
return True
|
||||||
if key in self.key_func:
|
if not raw and key in self.key_func:
|
||||||
return self.key_func[key]()
|
return self.key_func[key]()
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
|
|
Loading…
Reference in a new issue