sgr-direct PoC

pull/887/head
nick black 4 years ago
parent b315c31141
commit b980d7deee
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -320,7 +320,7 @@ reader_thread(void* vmarsh){
// we usually won't be done rendering the text before reaching our target row
size_t textpos = 0;
int ret;
const int MAXTOWRITE = 8;
const size_t MAXTOWRITE = 8;
bool collect_input = false;
while(textpos < textlen || y > targrow){
pthread_mutex_lock(lock);

@ -0,0 +1,30 @@
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <assert.h>
#include <notcurses/direct.h>
int main(int argc, char** argv){
(void)argc;
if(!setlocale(LC_ALL, "")){
return EXIT_FAILURE;
}
struct ncdirect* nc = ncdirect_init(NULL, stdout);
if(!nc){
return EXIT_FAILURE;
}
int e = 0;
for(unsigned i = 0 ; i < (NCSTYLE_ITALIC << 1u) ; ++i){
if(ncdirect_styles_set(nc, i)){
ncdirect_stop(nc);
return EXIT_FAILURE;
}
printf("%08x ", i);
if(++e % 6 == 0){
printf("\n");
}
}
printf("\n");
ncdirect_stop(nc);
return EXIT_SUCCESS;
}

@ -44,8 +44,8 @@ int main(int argc, char** argv){
fprintf(stderr, "Couldn't get terminfo entry for sgr\n");
return EXIT_FAILURE;
}
int sgrs[9] = { 0 };
int pivot = 8;
int sgrs[8] = { 0 };
int pivot = sizeof(sgrs) / sizeof(*sgrs);
if(DISABLE_ALTCHARSET){
--pivot;
}
@ -53,22 +53,21 @@ int main(int argc, char** argv){
// generate all values
int cols = 0;
while(pivot >= 0){
int i;
for(i = 0 ; i < 9 ; ++i){
for(size_t i = 0 ; i < sizeof(sgrs) / sizeof(*sgrs) ; ++i){
cols += printf("%c", sgrs[i] ? '1' : '0');
}
cols += printf(" (%02d)", pivot);
i = putp(tiparm(sgr, sgrs[0], sgrs[1], sgrs[2], sgrs[3], sgrs[4],
int r = putp(tiparm(sgr, sgrs[0], sgrs[1], sgrs[2], sgrs[3], sgrs[4],
sgrs[5], sgrs[6], sgrs[7], sgrs[8]));
if(i != OK){
if(r != OK){
return EXIT_FAILURE;
}
if((i = printf(" %s ", argv[0])) < 0){
if((r = printf(" %s ", argv[0])) < 0){
return EXIT_FAILURE;
}
cols += i;
i = putp(tiparm(sgr, 0, 0, 0, 0, 0, 0, 0, 0, 0));
if(i != OK){
cols += r;
r = putp(tiparm(sgr, 0, 0, 0, 0, 0, 0, 0, 0, 0));
if(r != OK){
return EXIT_FAILURE;
}
pivot = pivot_on(pivot, sgrs, sgrcount);

Loading…
Cancel
Save