1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-10-24 10:27:45 +00:00

correct text handling in SDL2

This commit is contained in:
Zeno Rogue
2024-06-28 12:20:26 +02:00
parent 920ed4bb86
commit 8a45b7e1e7
5 changed files with 74 additions and 11 deletions

View File

@@ -89,7 +89,7 @@ EX unsigned backcolor = 0;
EX unsigned bordcolor = 0;
EX unsigned forecolor = 0xFFFFFF;
int utfsize(char c) {
EX int utfsize(char c) {
unsigned char cu = c;
if(cu < 128) return 1;
if(cu < 224) return 2;
@@ -97,6 +97,13 @@ int utfsize(char c) {
return 4;
}
EX int utfsize_before(const string& s, int pos) {
if(!pos) return 0;
int npos = pos - 1;
while(npos && ((unsigned char)s[npos]) >= 128 && ((unsigned char)s[npos]) < 192) npos--;
return pos - npos;
}
EX int get_sightrange() { return getDistLimit() + sightrange_bonus; }
EX int get_sightrange_ambush() {