diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-03-27 09:16:02 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-03-27 09:16:02 +0000 |
commit | 6ccd2bec9e2008a869ac6305cdae4d585ad871c5 (patch) | |
tree | 2277312b4b7e23cb133e7bc2285ca487b9f7bc3f /src/corelib | |
parent | 90cffcf2f8f191a91bc9fd876e7fad47c54281d0 (diff) | |
download | fpGUI-6ccd2bec9e2008a869ac6305cdae4d585ad871c5.tar.xz |
* TfpgEdit cursor position performance patch from Vladimir.
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/gfx_utf8utils.pas | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/corelib/gfx_utf8utils.pas b/src/corelib/gfx_utf8utils.pas index 21b78297..5d1661e4 100644 --- a/src/corelib/gfx_utf8utils.pas +++ b/src/corelib/gfx_utf8utils.pas @@ -21,6 +21,8 @@ function UTF8Length(p: PChar; ByteCount: integer): integer; function UTF8Pos(const SearchForText, SearchInText: string): integer; procedure UTF8Delete(var S: string; Index, Size: integer); procedure UTF8Insert(const Source: string; var S: string; Index: integer); +function UTF8CharAtByte(const s: string; BytePos: integer; var aChar: string): integer; + implementation @@ -216,6 +218,23 @@ begin S := b + Source + e; end; +function UTF8CharAtByte(const s: string; BytePos: integer; + var aChar: string): integer; +var + CharLen: Integer; +begin + if BytePos > 0 then + begin + CharLen := UTF8CharacterLength(@s[BytePos]); + aChar := Copy(s, BytePos, CharLen); + Result := BytePos + CharLen; + end else + begin + aChar := ''; + Result := 1; + end; +end; + procedure UTF8Delete(var S: string; Index, Size: integer); var ls: integer; |