From 2e7ea41af1c8ea8d2e60048c05ee0ffe29e67c7f Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Thu, 20 Nov 2003 14:00:36 +0000 Subject: [PATCH] With the help of Andrew Bachmann, I finally fixed the multi-byte charachter deleting / Undoing. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5421 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/BTextView/UndoBuffer.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/kits/interface/BTextView/UndoBuffer.cpp b/src/kits/interface/BTextView/UndoBuffer.cpp index 731d8a88e0..1d91e001fa 100644 --- a/src/kits/interface/BTextView/UndoBuffer.cpp +++ b/src/kits/interface/BTextView/UndoBuffer.cpp @@ -34,6 +34,7 @@ #include // Local Includes -------------------------------------------------------------- +#include "MoreUTF8.h" #include "UndoBuffer.h" @@ -337,23 +338,14 @@ _BTypingUndoBuffer_::Reset() } - -// TODO: This isn't completely safe and it's even slower than parsing byte -// by byte, but I'll change it later. -static inline int32 -UTF8_char_len(uchar c) -{ - return ((0xE5000000 >> ((c >> 3) & 0x1E)) & 3) + 1; -} - - void _BTypingUndoBuffer_::BackwardErase() { int32 start, end; fTextView->GetSelection(&start, &end); - int32 charLen = UTF8_char_len(fTextView->ByteAt(start - 1)); + const char *text = fTextView->Text(); + int32 charLen = UTF8CharLenBACK(text + start, text); printf("Char Len: %d\n", charLen); if (start != fTypedEnd || end != fTypedEnd) { @@ -384,8 +376,8 @@ _BTypingUndoBuffer_::ForwardErase() int32 start, end; fTextView->GetSelection(&start, &end); - - int32 charLen = UTF8_char_len(fTextView->ByteAt(start)); + + int32 charLen = UTF8CharLenFWD(fTextView->Text() + start); printf("Char Len: %d\n", charLen); if (start != fTypedEnd || end != fTypedEnd || fUndone > 0) {