Remove the xhtml-im that was inserted for debug, add the start of a method to enter attributes in Inputs, convert \n to <br /> in xhtml_im bodies and put that body in a <p> element
This commit is contained in:
parent
42f4d55512
commit
51cebe7bdc
4 changed files with 17 additions and 4 deletions
|
@ -665,6 +665,7 @@ class Core(object):
|
||||||
curses.curs_set(1)
|
curses.curs_set(1)
|
||||||
curses.noecho()
|
curses.noecho()
|
||||||
curses.nonl()
|
curses.nonl()
|
||||||
|
curses.raw()
|
||||||
theme.init_colors()
|
theme.init_colors()
|
||||||
stdscr.keypad(True)
|
stdscr.keypad(True)
|
||||||
curses.ungetch(" ") # H4X: without this, the screen is
|
curses.ungetch(" ") # H4X: without this, the screen is
|
||||||
|
|
|
@ -557,7 +557,6 @@ class MucTab(ChatTab):
|
||||||
msg = self.core.xmpp.make_message(self.get_name())
|
msg = self.core.xmpp.make_message(self.get_name())
|
||||||
msg['type'] = 'groupchat'
|
msg['type'] = 'groupchat'
|
||||||
msg['body'] = line
|
msg['body'] = line
|
||||||
msg['xhtml_im'] = "<body><p>coucou</p></body>"
|
|
||||||
if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates is not False:
|
if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates is not False:
|
||||||
msg['chat_state'] = 'active'
|
msg['chat_state'] = 'active'
|
||||||
msg.send()
|
msg.send()
|
||||||
|
|
|
@ -50,6 +50,8 @@ import wcwidth
|
||||||
import singleton
|
import singleton
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
|
from keyboard import read_char
|
||||||
|
|
||||||
Line = collections.namedtuple('Line', 'text text_offset nickname_color time nickname')
|
Line = collections.namedtuple('Line', 'text text_offset nickname_color time nickname')
|
||||||
|
|
||||||
g_lock = Lock()
|
g_lock = Lock()
|
||||||
|
@ -1065,8 +1067,10 @@ class MessageInput(Input):
|
||||||
"""
|
"""
|
||||||
The input featuring history and that is being used in
|
The input featuring history and that is being used in
|
||||||
Conversation, Muc and Private tabs
|
Conversation, Muc and Private tabs
|
||||||
|
Also letting the user enter colors or other text markups
|
||||||
"""
|
"""
|
||||||
history = list() # The history is common to all MessageInput
|
history = list() # The history is common to all MessageInput
|
||||||
|
text_attributes = set(('b', 'o', 'u'))
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Input.__init__(self)
|
Input.__init__(self)
|
||||||
|
@ -1076,6 +1080,7 @@ class MessageInput(Input):
|
||||||
self.key_func["M-A"] = self.key_up
|
self.key_func["M-A"] = self.key_up
|
||||||
self.key_func["KEY_DOWN"] = self.key_down
|
self.key_func["KEY_DOWN"] = self.key_down
|
||||||
self.key_func["M-B"] = self.key_down
|
self.key_func["M-B"] = self.key_down
|
||||||
|
self.key_func['^C'] = self.enter_attrib
|
||||||
|
|
||||||
def key_up(self):
|
def key_up(self):
|
||||||
"""
|
"""
|
||||||
|
@ -1092,6 +1097,14 @@ class MessageInput(Input):
|
||||||
self.text = MessageInput.history[self.histo_pos]
|
self.text = MessageInput.history[self.histo_pos]
|
||||||
self.key_end()
|
self.key_end()
|
||||||
|
|
||||||
|
def enter_attrib(self):
|
||||||
|
"""
|
||||||
|
Read one more char (c) and add \x19c to the string
|
||||||
|
"""
|
||||||
|
attr_char = read_char(self.core.stdscr)
|
||||||
|
if attr_char in self.text_attributes or attr_char.isdigit():
|
||||||
|
self.do_command('\x19%s' % attr_char)
|
||||||
|
|
||||||
def key_down(self):
|
def key_down(self):
|
||||||
"""
|
"""
|
||||||
Get the next line in the history
|
Get the next line in the history
|
||||||
|
|
|
@ -64,7 +64,7 @@ def poezio_colors_to_html(string):
|
||||||
# a list of all opened elements, e.g. ['strong', 'span']
|
# a list of all opened elements, e.g. ['strong', 'span']
|
||||||
# So that we know what we need to close
|
# So that we know what we need to close
|
||||||
opened_elements = []
|
opened_elements = []
|
||||||
res = "<body xmlns='http://www.w3.org/1999/html'>"
|
res = "<body xmlns='http://www.w3.org/1999/html'><p>"
|
||||||
next_attr_char = string.find('\x19')
|
next_attr_char = string.find('\x19')
|
||||||
while next_attr_char != -1:
|
while next_attr_char != -1:
|
||||||
attr_char = string[next_attr_char+1].lower()
|
attr_char = string[next_attr_char+1].lower()
|
||||||
|
@ -90,8 +90,8 @@ def poezio_colors_to_html(string):
|
||||||
res += string
|
res += string
|
||||||
for elem in opened_elements[::-1]:
|
for elem in opened_elements[::-1]:
|
||||||
res += '</%s>' % (elem,)
|
res += '</%s>' % (elem,)
|
||||||
res += "</body>"
|
res += "</p></body>"
|
||||||
return res
|
return res.replace('\n', '<br />')
|
||||||
|
|
||||||
def shell_colors_to_poezio_colors(string):
|
def shell_colors_to_poezio_colors(string):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue