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):
|
def __init__(self, text_iter, text, length, text_buffer):
|
||||||
self.offset = text_iter.get_offset()
|
self.offset = text_iter.get_offset()
|
||||||
self.text = str(text)
|
self.text = str(text)
|
||||||
self.length = length
|
#unicode char can have length > 1 as it points in the buffer
|
||||||
if self.length > 1 or self.text in ("\r", "\n", " "):
|
charlength = len(unicode(text))
|
||||||
|
self.length = charlength
|
||||||
|
if charlength > 1 or self.text in ("\r", "\n", " "):
|
||||||
self.mergeable = False
|
self.mergeable = False
|
||||||
else:
|
else:
|
||||||
self.mergeable = True
|
self.mergeable = True
|
||||||
|
@ -54,8 +54,11 @@ class UndoableInsertEntry(object):
|
|||||||
def __init__(self, text, length, position, editable):
|
def __init__(self, text, length, position, editable):
|
||||||
self.offset = position
|
self.offset = position
|
||||||
self.text = str(text)
|
self.text = str(text)
|
||||||
self.length = length
|
#unicode char can have length > 1 as it points in the buffer
|
||||||
if self.length > 1 or self.text in ("\r", "\n", " "):
|
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
|
self.mergeable = False
|
||||||
else:
|
else:
|
||||||
self.mergeable = True
|
self.mergeable = True
|
||||||
@ -139,6 +142,7 @@ class UndoableEntry(gtk.Entry):
|
|||||||
WHITESPACE = (' ', '\t')
|
WHITESPACE = (' ', '\t')
|
||||||
if not cur.mergeable or not prev.mergeable:
|
if not cur.mergeable or not prev.mergeable:
|
||||||
return False
|
return False
|
||||||
|
# offset is char offset, not byte, so length is the char length!
|
||||||
elif cur.offset != (prev.offset + prev.length):
|
elif cur.offset != (prev.offset + prev.length):
|
||||||
return False
|
return False
|
||||||
elif cur.text in WHITESPACE and not prev.text in WHITESPACE:
|
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"""
|
"""something that has been inserted into our styledtextbuffer"""
|
||||||
def __init__(self, text_iter, text, length, text_buffer):
|
def __init__(self, text_iter, text, length, text_buffer):
|
||||||
#we obtain the buffer before the text has been inserted
|
#we obtain the buffer before the text has been inserted
|
||||||
if text_iter is None:
|
UndoableInsert.__init__(self, text_iter, text, length, text_buffer)
|
||||||
#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
|
|
||||||
self.tags = text_buffer.get_text(text_buffer.get_start_iter(),
|
self.tags = text_buffer.get_text(text_buffer.get_start_iter(),
|
||||||
text_buffer.get_end_iter()).get_tags()
|
text_buffer.get_end_iter()).get_tags()
|
||||||
self.tagsafter = None
|
self.tagsafter = None
|
||||||
|
Loading…
Reference in New Issue
Block a user