Permalink
Browse files

FS#386 correct horisontal scrolling for more-than-one-byte utf chars

  • Loading branch information...
1 parent ff9f584 commit 2c4cf711d4b0cb74fc8b956ce87d1ff47f0b45b0 @vershov vershov committed Nov 16, 2010
Showing with 12 additions and 2 deletions.
  1. +8 −1 src/FixedLine.cpp
  2. +4 −1 src/Utf.cpp
View
@@ -721,7 +721,14 @@ unsigned int FixedLine::DrawText(int xoffset, int x, int y, unsigned int start,
const unsigned int right_border = width - xoffset;
vector<unsigned int>::iterator p_start = m_extents.begin() + start;
vector<unsigned int>::iterator p = lower_bound(p_start, m_extents.end(), right_border);
- ++p; // may be partially visible
+
+ unsigned short tmp = utf8_len(buf[distance(m_extents.begin(), p)]);
+ if ((5 == tmp) || (tmp > distance(p, m_extents.end()))) {
+ // bad symbol or incomplete string
+ wxFAIL;
+ } else {
+ p += tmp; // may be partially visible
+ }
const unsigned int seglen = distance(p_start, p);
const unsigned int segend = start + seglen;
View
@@ -104,7 +104,10 @@ size_t ConvertFromUTF8toString(const wxCharBuffer& utf8_buff, size_t utf8_buff_l
// Convert to widechar
const size_t wchar_len = UTF8ToWChar(buff, utf8_buff_len, utf8_buff, utf8_buff_len);
- if (wchar_len == wxCONV_FAILED) return wxCONV_FAILED; // invalid conversion
+ if (wchar_len == wxCONV_FAILED) { // invalid conversion
+ text.UngetWriteBuf(0);
+ return wxCONV_FAILED;
+ }
text.UngetWriteBuf(wchar_len);

0 comments on commit 2c4cf71

Please sign in to comment.