emoticons work now

This commit is contained in:
Nikos Kouremenos 2005-03-11 12:55:38 +00:00
parent a833209a9b
commit 3b876f4e77

View file

@ -696,16 +696,23 @@ class tabbed_chat_window:
conversation_textview = self.xmls[jid].get_widget('conversation_textview') conversation_textview = self.xmls[jid].get_widget('conversation_textview')
conversation_buffer = conversation_textview.get_buffer() conversation_buffer = conversation_textview.get_buffer()
removed_spaces = False
print text print text
if text[0] == ' ': # that happens ATM only with formating detection if not text[0] == '*': # workaround until lookbehind regexp is here
text = text.lstrip() # remove ALL leading spaces if text[0] == ' ': # that happens ATM only with formating detection
#(I add those in the formating detection later) text = text.lstrip() # remove ALL leading spaces
print 'removed spaces'
removed_spaces = True
#(I add those in the formating detection later)
print 'text after' print 'text after'
print text print text
if text in self.plugin.emoticons.keys(): # make it CAPS (emoticons keys are are CAPS)
possible_emot_ascii_caps = text.upper()
if possible_emot_ascii_caps in self.plugin.emoticons.keys():
#it's an emoticon #it's an emoticon
text = text.upper() # make it CAPS (emoticons keys are are CAPS) text = possible_emot_ascii_caps
print 'emoticon:', text print 'emoticon:', text
end_iter = conversation_buffer.get_end_iter() end_iter = conversation_buffer.get_end_iter()
conversation_buffer.insert_pixbuf(end_iter, \ conversation_buffer.insert_pixbuf(end_iter, \
@ -734,7 +741,10 @@ class tabbed_chat_window:
#it's an underlined text #it's an underlined text
tag = 'underline' tag = 'underline'
text = text[1:-1] # remove _ _ text = text[1:-1] # remove _ _
text = ' ' + text # add the first space print 'removed_spaces', removed_spaces
if removed_spaces:
print 'adding one leading space'
text = ' ' + text # add the first space
print tag print tag
else: else:
#it's a url #it's a url
@ -3556,8 +3566,8 @@ class plugin:
#2nd one: at_least_one_char@at_least_one_char.at_least_one_char #2nd one: at_least_one_char@at_least_one_char.at_least_one_char
mail = r'\bmailto:\S+|' r'\b\S+@\S+\.\S+' mail = r'\bmailto:\S+|' r'\b\S+@\S+\.\S+'
#detects eg. *b* *bold* *bold bold* #detects eg. *b* *bold* *bold bold* test *bold*
#doesn't detect (it's a feature :P) * bold* *bold * * bold * #doesn't detect (it's a feature :P) * bold* *bold * * bold * test*bold*
formatting = r'(\s+|^)\*[^\s*]([^*]*[^\s*])?\*|' r'(\s+|^)/[^\s*]([^/]*[^\s*])?/|' r'(\s+|^)_[^\s*]([^_]*[^\s*])?_' formatting = r'(\s+|^)\*[^\s*]([^*]*[^\s*])?\*|' r'(\s+|^)/[^\s*]([^/]*[^\s*])?/|' r'(\s+|^)_[^\s*]([^_]*[^\s*])?_'
if formatting_on: if formatting_on: