From 8f6502a5fbf6c77dbef8d94a5ed6a851b8d3566a Mon Sep 17 00:00:00 2001 From: Daniel Francis Date: Sat, 08 Sep 2012 23:00:22 +0000 Subject: Complete word-chars setter --- diff --git a/sugarvte/vteview.py b/sugarvte/vteview.py index f4843f3..3a789c1 100644 --- a/sugarvte/vteview.py +++ b/sugarvte/vteview.py @@ -65,19 +65,29 @@ treat all graphic non-punctuation non-space characters as word characters. if spec == None or spec[0] == '\0': self.notify('word-chars') ubuf = unicode(spec) - count = 0 - for i in ubuf: - if i == '-': - range.start = i - range.end = i + i = -1 + while i < len(ubuf): + i += 1 + if ubuf[i] == '-': + range.start = ubuf[i] + range.end = ubuf[i] self.word_chars.append(range) logger.debug('Word charset includes hypen') continue - if ubuf[1] != '-' and ubuf[count + 1] != '-': - range.start = i - range.end = i + if ubuf[i] != '-' and ubuf[i + 1] != '-': + range.start = ubuf[i] + range.end = ubuf[i] self.word_chars.append(range) continue + if ubuf[i] != '-' and\ + ubuf[i + 1] == u'-' and\ + ubuf[i + 2] != u'-' and\ + ubuf[i + 2] != unichr(0): + range.start = ubuf[i] + range.end = ubuf[i + 1] + self.word_chars.append(range) + continue + self.notify('word-chars') if __name__ == "__main__": -- cgit v0.9.1