mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
sixel_blit: use '$' to return carriage #200
This commit is contained in:
parent
310d8aeec9
commit
4533d42fa0
@ -52,7 +52,7 @@ char32_t demo_getc(struct notcurses* nc, const struct timespec* ts, ncinput* ni)
|
||||
// yes, i'd like CLOCK_MONOTONIC too, but pthread_cond_timedwait() is based off
|
||||
// of crappy CLOCK_REALTIME :/
|
||||
// abstime shouldn't be further out than our maximum sleep time -- this can
|
||||
// lead to 0 frames output during the wait (happening now with zoo FIXME)
|
||||
// lead to 0 frames output during the wait
|
||||
if(ts){
|
||||
ns = timespec_to_ns(ts);
|
||||
}else{
|
||||
|
@ -859,6 +859,7 @@ sixel_blit(ncplane* nc, int placey, int placex, int linesize,
|
||||
// FIXME find sixels with common colors for single register program
|
||||
unsigned bitsused = 0; // once 63, we're done
|
||||
int colorreg = 1; // leave 0 as background
|
||||
bool printed = false;
|
||||
for(int sy = y ; sy < dimy && sy < y + 6 ; ++sy){
|
||||
const uint32_t* rgb = (const uint32_t*)(data + (linesize * sy) + (visx * 4));
|
||||
if(ffmpeg_trans_p(ncpixel_a(*rgb))){
|
||||
@ -882,12 +883,14 @@ sixel_blit(ncplane* nc, int placey, int placex, int linesize,
|
||||
// FIXME use percentages(rgb)
|
||||
// bitstring is added to 63, resulting in [63, 126] aka '?'..'~'
|
||||
int n = snprintf(sixel + offset, sizeof(sixel) - offset,
|
||||
"#%d;2;%d;%d;%d%c", colorreg, 100, 100, 100, c);
|
||||
"%s#%d;2;%d;%d;%d#%d%c", printed ? "$" : "",
|
||||
colorreg, 100, 100, 100, colorreg, c);
|
||||
if(n < 0){
|
||||
return -1;
|
||||
}
|
||||
offset += n;
|
||||
++colorreg;
|
||||
printed = true;
|
||||
}
|
||||
if(bitsused == 63){
|
||||
break;
|
||||
|
@ -451,6 +451,7 @@ ncdirect_dump_plane(ncdirect* n, const ncplane* np, int xoff){
|
||||
if(term_emit(n->tcache.pixeloff, n->ttyfp, false)){
|
||||
return -1;
|
||||
}
|
||||
pixelmode = false;
|
||||
}
|
||||
// FIXME replace with a SGR clear
|
||||
ncdirect_set_fg_default(n);
|
||||
|
Loading…
x
Reference in New Issue
Block a user