Exemple #1
0
static void send_char(int x, int y, uint32_t c)
{
	char buf[7];
	int bw = tb_utf8_unicode_to_char(buf, c);
	if (x-1 != lastx || y != lasty)
		write_cursor(x, y);
	lastx = x; lasty = y;
	if(!c) buf[0] = ' '; // replace 0 with whitespace
	bytebuffer_append(&output_buffer, buf, bw);
}
Exemple #2
0
GhtErr
ght_write(GhtWriter *writer, const void *bytes, size_t bytesize)
{
    assert(writer);
    if ( writer->type == GHT_IO_MEM )
    {
        bytebuffer_append(writer->bytebuffer, bytes, bytesize);
        return GHT_OK;
    }
    else if (writer->type == GHT_IO_FILE )
    {
        size_t wsz;
        wsz = fwrite(bytes, 1, bytesize, writer->file);
        if ( wsz != bytesize )
            return GHT_ERROR;
        writer->filesize += wsz;
        return GHT_OK;
    }
    else
    {
        ght_error("%s: unknown writer type %d", __func__, writer->type);
        return GHT_ERROR;
    }    
}