run cell_load_char()/egc32() through cell_load() #1176

pull/1178/head
nick black 4 years ago
parent 01e4f7de5a
commit 0645fb3931
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -729,22 +729,20 @@ cellcmp(const struct ncplane* n1, const cell* RESTRICT c1,
// Load a 7-bit char 'ch' into the cell 'c'.
static inline int
cell_load_char(struct ncplane* n, cell* c, char ch){
cell_release(n, c);
// FIXME don't allow non-printing garbage
c->channels &= ~(CELL_WIDEASIAN_MASK | CELL_NOBACKGROUND_MASK);
c->gcluster = htole((uint32_t)ch);
return 1;
char gcluster[2];
gcluster[0] = ch;
gcluster[1] = '\0';
return cell_load(n, c, gcluster);
}
// Load a UTF-8 encoded EGC of up to 4 bytes into the cell 'c'.
static inline int
cell_load_egc32(struct ncplane* n, cell* c, uint32_t egc){
cell_release(n, c);
// FIXME don't allow non-printing garbage, nor invalid forms
// FIXME this might well be a wide egc, augh
c->channels &= ~(CELL_WIDEASIAN_MASK | CELL_NOBACKGROUND_MASK);
c->gcluster = htole(egc);
return 1;
char gcluster[sizeof(egc) + 1];
egc = htole(egc);
memcpy(gcluster, &egc, sizeof(egc));
gcluster[4] = '\0';
return cell_load(n, c, gcluster);
}
// These log levels consciously map cleanly to those of libav; Notcurses itself
@ -1406,9 +1404,6 @@ ncplane_putc(struct ncplane* n, const cell* c){
return ncplane_putc_yx(n, -1, -1, c);
}
// Replace the EGC underneath us, but retain the styling. The current styling
// of the plane will not be changed.
//
// Replace the cell at the specified coordinates with the provided 7-bit char
// 'c'. Advance the cursor by 1. On success, returns 1. On failure, returns -1.
// This works whether the underlying char is signed or unsigned.

@ -104,8 +104,8 @@ TEST_CASE("Wide") {
}
}
// Placing a wide char to the immediate left of any other char ought obliterate
// that cell.
// Placing a wide char to the immediate left of any other char ought
// obliterate that cell.
SUBCASE("WideCharAnnihilatesRight") {
const char* w = FROG;
const char* wbashed = SCORPION;

Loading…
Cancel
Save