|
|
@ -1,5 +1,52 @@
|
|
|
|
#include "internal.h"
|
|
|
|
#include "internal.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// sixel is in a sense simpler to edit in-place than kitty, as it has neither
|
|
|
|
|
|
|
|
// chunking nor base64 to worry about. in another sense, it's waaay suckier,
|
|
|
|
|
|
|
|
// because you effectively have to lex through a byte at a time (since the
|
|
|
|
|
|
|
|
// color bands have varying size). le sigh! we work geometrically here,
|
|
|
|
|
|
|
|
// blasting through each band and scrubbing the necessary cells therein.
|
|
|
|
|
|
|
|
// define a rectangle that will be scrubbed.
|
|
|
|
|
|
|
|
int sprite_sixel_cell_wipe(notcurses* nc, sprixel* s, int ycell, int xcell){
|
|
|
|
|
|
|
|
if(ycell >= s->dimy){
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(xcell >= s->dimx){
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const int xpixels = nc->tcache.cellpixx;
|
|
|
|
|
|
|
|
const int ypixels = nc->tcache.cellpixy;
|
|
|
|
|
|
|
|
const int top = ypixels * ycell; // start scrubbing on this row
|
|
|
|
|
|
|
|
int bottom = ypixels * (ycell + 1); // do *not* scrub this row
|
|
|
|
|
|
|
|
const int left = xpixels * xcell; // start scrubbing on this column
|
|
|
|
|
|
|
|
int right = xpixels * (xcell + 1); // do *not* scrub this column
|
|
|
|
|
|
|
|
// if the cell is on the right or bottom borders, it might only be partially
|
|
|
|
|
|
|
|
// filled by actual graphic data, and we need to cap our target area.
|
|
|
|
|
|
|
|
if(right > s->pixx){
|
|
|
|
|
|
|
|
right = s->pixx;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(bottom > s->pixy){
|
|
|
|
|
|
|
|
bottom = s->pixy;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(stderr, "TARGET AREA: [ %dx%d -> %dx%d ] of %dx%d\n", top, left, bottom - 1, right - 1, s->pixy, s->pixx);
|
|
|
|
|
|
|
|
char* c = s->glyph;
|
|
|
|
|
|
|
|
// lines of sixels are broken by a hyphen. if we were guaranteed to already
|
|
|
|
|
|
|
|
// be in the meat of the sixel, it would be sufficient to count hyphens, but
|
|
|
|
|
|
|
|
// we must distinguish the introductory material from the sixmap, alas
|
|
|
|
|
|
|
|
// (after that, simply count hyphens). FIXME store loc in sprixel metadata?
|
|
|
|
|
|
|
|
// it seems sufficient to look for the first #d not followed by a semicolon.
|
|
|
|
|
|
|
|
// remember, these are sixels *we've* created internally, not random ones.
|
|
|
|
|
|
|
|
do{
|
|
|
|
|
|
|
|
while(*c != '#'){
|
|
|
|
|
|
|
|
++c;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
while(isdigit(*c)){
|
|
|
|
|
|
|
|
++c;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}while(*c == ';');
|
|
|
|
|
|
|
|
fprintf(stderr, "FOUND SIXMAP AT %zd\n", c - s->glyph);
|
|
|
|
|
|
|
|
return 0; // FIXME
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define RGBSIZE 3
|
|
|
|
#define RGBSIZE 3
|
|
|
|
#define CENTSIZE (RGBSIZE + 1) // size of a color table entry
|
|
|
|
#define CENTSIZE (RGBSIZE + 1) // size of a color table entry
|
|
|
|
|
|
|
|
|
|
|
|