mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 01:29:05 -04:00
move cell_egc_copy() to internal.h
This commit is contained in:
parent
e81e58035e
commit
35aa7f6e85
@ -457,6 +457,7 @@ API int ncplane_at_cursor(struct ncplane* n, cell* c);
|
||||
|
||||
// Retrieve the cell at the specified location on the specified plane, returning
|
||||
// it in 'c'. This copy is safe to use until the ncplane is destroyed/erased.
|
||||
// Returns the length of the EGC in bytes.
|
||||
API int ncplane_at_yx(struct ncplane* n, int y, int x, cell* c);
|
||||
|
||||
// Manipulate the opaque user pointer associated with this plane.
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
@ -209,6 +210,22 @@ fbcellidx(const ncplane* n, int row, int col){
|
||||
return row * n->lenx + col;
|
||||
}
|
||||
|
||||
// copy the UTF8-encoded EGC out of the cell, whether simple or complex. the
|
||||
// result is not tied to the ncplane, and persists across erases / destruction.
|
||||
static inline char*
|
||||
cell_egc_copy(const ncplane* n, const cell* c){
|
||||
char* ret;
|
||||
if(cell_simple_p(c)){
|
||||
if( (ret = (char*)malloc(2)) ){ // cast required for c++ unit tests
|
||||
ret[0] = c->gcluster;
|
||||
ret[1] = '\0';
|
||||
}
|
||||
}else{
|
||||
ret = strdup(cell_extended_gcluster(n, c));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// For our first attempt, O(1) uniform conversion from 8-bit r/g/b down to
|
||||
// ~2.4-bit 6x6x6 cube + greyscale (assumed on entry; I know no way to
|
||||
// even semi-portably recover the palette) proceeds via: map each 8-bit to
|
||||
|
Loading…
x
Reference in New Issue
Block a user