pass TAM down through iterm2 graphics stack #1950

dankamongmen/iterm2complete
nick black 3 years ago committed by nick black
parent 9779dd9fef
commit c5398e09e1

@ -9,7 +9,7 @@
#include <sys/types.h>
#if defined(__linux__) || defined(__gnu_hurd__)
#include <sys/sysinfo.h>
#else
#elif !defined(__MINGW64__)
#include <sys/sysctl.h>
#endif
#include <sys/utsname.h>
@ -81,7 +81,7 @@ static distro_info distros[] = {
static int
fetch_bsd_cpuinfo(fetched_info* fi){
#if defined(__linux__) || defined(__gnu_hurd__)
#if defined(__linux__) || defined(__gnu_hurd__) || defined(__MINGW64__)
(void)fi;
#else
size_t len = sizeof(fi->core_count);

@ -41,12 +41,11 @@ int iterm_draw(const tinfo* ti, const ncpile *p, sprixel* s, fbuf* f, int y, int
}
static int
write_iterm_graphic(const void* data, int leny, int stride, int lenx, fbuf *f){
write_iterm_graphic(tament* tam, const void* data, int leny, int stride, int lenx, fbuf *f){
if(fbuf_puts(f, "\e]1337;File=inline=1:") < 0){
return -1;
}
// FIXME won't we need to pass TAM into write_png_b64()?
if(write_png_b64(data, leny, stride, lenx, f)){
if(write_png_b64(tam, data, leny, stride, lenx, f)){
return -1;
}
if(fbuf_puts(f, "\x1b\\") < 0){
@ -83,7 +82,7 @@ int iterm_blit(ncplane* n, int linesize, const void* data,
free(tam);
return -1;
}
if(write_iterm_graphic(data, leny, linesize, lenx, &s->glyph)){
if(write_iterm_graphic(tam, data, leny, linesize, lenx, &s->glyph)){
if(!reuse){
free(tam);
}

@ -228,7 +228,7 @@ fbuf_putn64(fbuf* f, const void* src, size_t osize, struct b64ctx* bctx){
}
static size_t
fwrite_idats(fbuf* f, const unsigned char* data, size_t dlen,
fwrite_idats(tament* tam, fbuf* f, const unsigned char* data, size_t dlen,
struct b64ctx* bctx){
static const char ctype[] = "IDAT";
uint32_t written = 0;
@ -244,6 +244,8 @@ fwrite_idats(fbuf* f, const unsigned char* data, size_t dlen,
fbuf_putn64(f, data + dwritten, thischunk, bctx) != 1){
return 0;
}
// FIXME use the TAM!
(void)tam;
// FIXME horrible; PoC; do not retain!
unsigned char* crcbuf = malloc(thischunk + 8);
memcpy(crcbuf, &nclen, 4);
@ -262,7 +264,8 @@ free(crcbuf); // FIXME well a bit more
return written;
}
int write_png_b64(const void* data, int rows, int rowstride, int cols, fbuf* f){
int write_png_b64(tament* tam, const void* data, int rows, int rowstride,
int cols, fbuf* f){
void* deflated;
size_t dlen;
compute_png_size(data, rows, rowstride, cols, &deflated, &dlen);
@ -280,7 +283,7 @@ int write_png_b64(const void* data, int rows, int rowstride, int cols, fbuf* f){
free(deflated);
return -1;
}
if(fwrite_idats(f, deflated, dlen, &bctx) == 0){
if(fwrite_idats(tam, f, deflated, dlen, &bctx) == 0){
free(deflated);
return -1;
}

@ -8,10 +8,11 @@ extern "C" {
#include <stdio.h>
struct fbuf;
struct ncvisual;
struct tament;
// create the PNG, encode it using base64, and write it to |fp|
int write_png_b64(const void* data, int rows, int rowstride, int cols, fbuf* f);
int write_png_b64(struct tament* tam, const void* data, int rows, int rowstride,
int cols, struct fbuf* f);
#ifdef __cplusplus
}

Loading…
Cancel
Save