mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 09:09:03 -04:00
rtl--increment *bytes in rtl_egc() #1174
This commit is contained in:
parent
61e51043a2
commit
d2e39cca85
@ -950,10 +950,13 @@ egc_rtl(const char* egc, int* bytes){
|
||||
}
|
||||
// insert U+200E, "LEFT-TO-RIGHT MARK". This ought reset the text direction
|
||||
// after emitting a potentially RTL EGC.
|
||||
const char LTRMARK[] = "\xe2\x80\x8e";
|
||||
char* s = (char*)malloc(*bytes + sizeof(LTRMARK)); // cast for C++ callers
|
||||
memcpy(s, egc, *bytes);
|
||||
memcpy(s + *bytes, LTRMARK, sizeof(LTRMARK));
|
||||
const char LTRMARK[] = "\xe2\x80\xad";
|
||||
char* s = (char*)malloc(*bytes + strlen(LTRMARK) + 1); // cast for C++ callers
|
||||
memcpy(s, LTRMARK, strlen(LTRMARK));
|
||||
memcpy(s + strlen(LTRMARK), egc, *bytes);
|
||||
s[strlen(LTRMARK) + *bytes] = '\0';
|
||||
//fprintf(stderr, "\nLTR: [%s] (\xe2\x80\xad%s) (%zu) (%d)\n", s, egc, strlen(s), *bytes);
|
||||
*bytes += strlen(LTRMARK);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -20,11 +20,11 @@ TEST_CASE("Bidi") {
|
||||
uint64_t channels;
|
||||
auto egc = ncplane_at_yx(n_, 0, 0, &stylemask, &channels);
|
||||
REQUIRE(nullptr != egc);
|
||||
CHECK(0 == strcmp(egc, "ה"));
|
||||
CHECK(0 == strcmp(egc, "\xe2\x80\xadה"));
|
||||
free(egc);
|
||||
egc = ncplane_at_yx(n_, 0, 4, &stylemask, &channels);
|
||||
REQUIRE(nullptr != egc);
|
||||
CHECK(0 == strcmp(egc, "ך"));
|
||||
CHECK(0 == strcmp(egc, "\xe2\x80\xadך"));
|
||||
free(egc);
|
||||
// FIXME yes, we place this at 0,0 in our internal view...and yet it
|
||||
// is actually placed at the rightmost cell :/
|
||||
|
Loading…
x
Reference in New Issue
Block a user