From 9545e033bbce1283d33325eb8710773adcffd52e Mon Sep 17 00:00:00 2001 From: engelsman Date: Sun, 18 Apr 2010 14:33:33 +0000 Subject: Fl_Text_Buffer/Display fixes for UTF-8 / STR-2158 (part 1) fixes to handle incorrect counting of UTF-8 characters by checking for complete UTF-8 encodings in char* rather than char by char. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7527 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- FL/Fl_Text_Buffer.H | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'FL/Fl_Text_Buffer.H') diff --git a/FL/Fl_Text_Buffer.H b/FL/Fl_Text_Buffer.H index c23a4a4e7..d74582deb 100644 --- a/FL/Fl_Text_Buffer.H +++ b/FL/Fl_Text_Buffer.H @@ -248,6 +248,18 @@ public: */ unsigned int character(int pos) const; + /** + Convert a byte offset in buffer into a memory address. + */ + const char *address(int pos) const + { return (pos < mGapStart) ? mBuf+pos : mBuf+pos+mGapEnd-mGapStart; } + + /** + Convert a byte offset in buffer into a memory address. + */ + char *address(int pos) + { return (pos < mGapStart) ? mBuf+pos : mBuf+pos+mGapEnd-mGapStart; } + /** Returns the text from the given rectangle. When you are done with the text, free it using the free() function. @@ -681,6 +693,7 @@ public: \return number of byte in substitution */ static int character_width(const char *src, int indent, int tabDist); + static int character_width(const char c, int indent, int tabDist); /** Count the number of displayed characters between buffer position @@ -934,18 +947,6 @@ protected: */ void update_selections(int pos, int nDeleted, int nInserted); - /** - Convert a byte offset in buffer into a memory address. - */ - const char *address(int pos) const - { return (pos < mGapStart) ? mBuf+pos : mBuf+pos+mGapEnd-mGapStart; } - - /** - Convert a byte offset in buffer into a memory address. - */ - char *address(int pos) - { return (pos < mGapStart) ? mBuf+pos : mBuf+pos+mGapEnd-mGapStart; } - Fl_Text_Selection mPrimary; /**< highlighted areas */ Fl_Text_Selection mSecondary; /**< highlighted areas */ Fl_Text_Selection mHighlight; /**< highlighted areas */ -- cgit v1.2.3