undo support for words with unicode symbols of length 2 in the buffer
svn: r15843
This commit is contained in:
parent
fa6014f4c0
commit
19950c616d
@ -54,8 +54,10 @@ class UndoableInsert(object):
|
||||
def __init__(self, text_iter, text, length, text_buffer):
|
||||
self.offset = text_iter.get_offset()
|
||||
self.text = str(text)
|
||||
self.length = length
|
||||
if self.length > 1 or self.text in ("\r", "\n", " "):
|
||||
#unicode char can have length > 1 as it points in the buffer
|
||||
charlength = len(unicode(text))
|
||||
self.length = charlength
|
||||
if charlength > 1 or self.text in ("\r", "\n", " "):
|
||||
self.mergeable = False
|
||||
else:
|
||||
self.mergeable = True
|
||||
|
@ -54,8 +54,11 @@ class UndoableInsertEntry(object):
|
||||
def __init__(self, text, length, position, editable):
|
||||
self.offset = position
|
||||
self.text = str(text)
|
||||
self.length = length
|
||||
if self.length > 1 or self.text in ("\r", "\n", " "):
|
||||
#unicode char can have length > 1 as it points in the buffer
|
||||
charlength = len(unicode(text))
|
||||
self.length = charlength
|
||||
print text, length, unicode(text)[0], len(unicode(text))
|
||||
if charlength > 1 or self.text in ("\r", "\n", " "):
|
||||
self.mergeable = False
|
||||
else:
|
||||
self.mergeable = True
|
||||
@ -139,6 +142,7 @@ class UndoableEntry(gtk.Entry):
|
||||
WHITESPACE = (' ', '\t')
|
||||
if not cur.mergeable or not prev.mergeable:
|
||||
return False
|
||||
# offset is char offset, not byte, so length is the char length!
|
||||
elif cur.offset != (prev.offset + prev.length):
|
||||
return False
|
||||
elif cur.text in WHITESPACE and not prev.text in WHITESPACE:
|
||||
|
@ -38,20 +38,7 @@ class UndoableInsertStyled(UndoableInsert):
|
||||
"""something that has been inserted into our styledtextbuffer"""
|
||||
def __init__(self, text_iter, text, length, text_buffer):
|
||||
#we obtain the buffer before the text has been inserted
|
||||
if text_iter is None:
|
||||
#style change
|
||||
self.mergeable = False
|
||||
self.offset = text_buffer.get_iter_at_mark(text_buffer.get_insert()).get_offset()
|
||||
self.text = None
|
||||
self.length = 0
|
||||
else:
|
||||
self.offset = text_iter.get_offset()
|
||||
self.text = str(text)
|
||||
self.length = length
|
||||
if self.length > 1 or self.text in ("\r", "\n", " "):
|
||||
self.mergeable = False
|
||||
else:
|
||||
self.mergeable = True
|
||||
UndoableInsert.__init__(self, text_iter, text, length, text_buffer)
|
||||
self.tags = text_buffer.get_text(text_buffer.get_start_iter(),
|
||||
text_buffer.get_end_iter()).get_tags()
|
||||
self.tagsafter = None
|
||||
|
Loading…
Reference in New Issue
Block a user