Cleaner version to check if char after a highlight is an alphanum or not

This commit is contained in:
Jean-Marie Traissard 2008-03-30 21:45:51 +00:00
parent 39d18c893d
commit d10e203255
1 changed files with 6 additions and 11 deletions

View File

@ -814,19 +814,14 @@ class GroupchatControl(ChatControlBase):
char_position = len(special_word)
refer_to_nick_char = \
word[char_position:char_position+1]
refer_to_nick_char = str(refer_to_nick_char)
if (refer_to_nick_char != ''):
refer_to_nick_char_code = ord(refer_to_nick_char)
if ((refer_to_nick_char_code < 65 or \
refer_to_nick_char_code > 122) or \
(refer_to_nick_char_code < 97 and \
refer_to_nick_char_code > 90)):
return True
else:
# This is A->Z or a->z, we can be sure our nick is the
# beginning of a real word, do not highlight. Note that we
# can probably do a better detection of non-punctuation
# characters
if refer_to_nick_char.isalpha():
# This is A->Z, a->z or 0-9, we can be sure our nick is the
# beginning of a real word, do not highlight.
return False
else:
return True
else: # Special word == word, no char after in word
return True
for special_word in special_words: