cellcmp_and_dupfar(): unify paths

pull/922/head
nick black 4 years ago
parent 11287b6081
commit 73abc61f16
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -530,8 +530,11 @@ term_fg_palindex(const notcurses* nc, FILE* out, unsigned pal){
}
static inline const char*
extended_gcluster(const ncplane* n, const cell* c){
return egcpool_extended_gcluster(&n->pool, c);
pool_extended_gcluster(const egcpool* pool, const cell* c){
if(cell_simple_p(c)){
return (const char*)&c->gcluster;
}
return egcpool_extended_gcluster(pool, c);
}
cell* ncplane_cell_ref_yx(ncplane* n, int y, int x);
@ -596,7 +599,7 @@ cell_duplicate_far(egcpool* tpool, cell* targ, const ncplane* splane, const cell
return 0;
}
assert(splane);
const char* egc = extended_gcluster(splane, c);
const char* egc = cell_extended_gcluster(splane, c);
size_t ulen = strlen(egc);
int eoffset = egcpool_stash(tpool, egc, ulen);
if(eoffset < 0){

@ -1520,12 +1520,10 @@ int ncplane_cursor_at(const ncplane* n, cell* c, char** gclust){
}
const cell* src = &n->fb[nfbcellidx(n, n->y, n->x)];
memcpy(c, src, sizeof(*src));
*gclust = NULL;
if(!cell_simple_p(src)){
*gclust = strdup(extended_gcluster(n, src));
if(*gclust == NULL){
return -1;
}
if(cell_simple_p(c)){
*gclust = NULL;
}else if((*gclust = strdup(cell_extended_gcluster(n, src))) == NULL){
return -1;
}
return 0;
}

@ -139,20 +139,10 @@ cellcmp_and_dupfar(egcpool* dampool, cell* damcell,
const ncplane* srcplane, const cell* srccell){
if(damcell->stylemask == srccell->stylemask){
if(damcell->channels == srccell->channels){
bool srcsimple = cell_simple_p(srccell);
bool damsimple = cell_simple_p(damcell);
if(damsimple == srcsimple){
if(damsimple){
if(damcell->gcluster == srccell->gcluster){
return 0; // simple match
}
}else{
const char* damegc = egcpool_extended_gcluster(dampool, damcell);
const char* srcegc = extended_gcluster(srcplane, srccell);
if(strcmp(damegc, srcegc) == 0){
return 0; // EGC match
}
}
const char* srcegc = cell_extended_gcluster(srcplane, srccell);
const char* damegc = pool_extended_gcluster(dampool, damcell);
if(strcmp(damegc, srcegc) == 0){
return 0; // EGC match
}
}
}

Loading…
Cancel
Save