Conversation
|
Hi, Adam I like the idea very much and I feel eager to apply this functionality in Newsraft. However, I see several points that could be improved in the current patch.
Make developer decide the mask for their user attributes. Imagine they only need 3 custom attributes on bits 42, 51 and 53 (i.e.
To avoid introducing callbacks for memory management, I'd make developer write to the Here's an example: int my_mega_userattr_callback(uintattr_t fg, uintattr_t bg, uintattr_t *mask, int (*add)(const char *, size_t))
{
bool is_attr1_set = fg & (1 << 42);
bool is_attr2_set = fg & (1 << 51);
bool is_attr3_set = fg & (1 << 53);
char *my_sequence = generate_sequence(is_attr1_set, is_attr2_set, is_attr3_set);
// termbox2 gives us the function to write data into internal buffer
int status = add(my_sequence, strlen(my_sequence));
// all memory management is done by the user
free(my_sequence);
*mask = (1 << 42) | (1 << 51) | (1 << 53);
return status;
}Let me know what you think :^) Best regards, Grigory |
|
Hi Grigory, thanks for the review. I haven't forgot about your comment, just haven't had time yet to review it. |
|
I wonder if one could implement sixel support using this... |
Agree, good point. My first thought was to pass a generously sized buffer to the callback, however it may not be big enough if the caller wants to output a large sixel image or something. At the moment I can't think of a better solution than what you've provided.
What do you think about not applying a mask at all? The caller can simply avoid whichever attrs they don't need, and steal those bits for use in their callback. We can define a macro that resembles the first available bit for those that don't want to sacrifice any built-in ones. Any downside to this?
Fair. I was going for something like Thanks again for the feedback and apologies for the long delay! |
See #120 (review)