mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-20 03:25:47 +00:00
sgr-direct PoC
This commit is contained in:
parent
b315c31141
commit
b980d7deee
@ -320,7 +320,7 @@ reader_thread(void* vmarsh){
|
|||||||
// we usually won't be done rendering the text before reaching our target row
|
// we usually won't be done rendering the text before reaching our target row
|
||||||
size_t textpos = 0;
|
size_t textpos = 0;
|
||||||
int ret;
|
int ret;
|
||||||
const int MAXTOWRITE = 8;
|
const size_t MAXTOWRITE = 8;
|
||||||
bool collect_input = false;
|
bool collect_input = false;
|
||||||
while(textpos < textlen || y > targrow){
|
while(textpos < textlen || y > targrow){
|
||||||
pthread_mutex_lock(lock);
|
pthread_mutex_lock(lock);
|
||||||
|
30
src/poc/sgr-direct.c
Normal file
30
src/poc/sgr-direct.c
Normal file
@ -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");
|
fprintf(stderr, "Couldn't get terminfo entry for sgr\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
int sgrs[9] = { 0 };
|
int sgrs[8] = { 0 };
|
||||||
int pivot = 8;
|
int pivot = sizeof(sgrs) / sizeof(*sgrs);
|
||||||
if(DISABLE_ALTCHARSET){
|
if(DISABLE_ALTCHARSET){
|
||||||
--pivot;
|
--pivot;
|
||||||
}
|
}
|
||||||
@ -53,22 +53,21 @@ int main(int argc, char** argv){
|
|||||||
// generate all values
|
// generate all values
|
||||||
int cols = 0;
|
int cols = 0;
|
||||||
while(pivot >= 0){
|
while(pivot >= 0){
|
||||||
int i;
|
for(size_t i = 0 ; i < sizeof(sgrs) / sizeof(*sgrs) ; ++i){
|
||||||
for(i = 0 ; i < 9 ; ++i){
|
|
||||||
cols += printf("%c", sgrs[i] ? '1' : '0');
|
cols += printf("%c", sgrs[i] ? '1' : '0');
|
||||||
}
|
}
|
||||||
cols += printf(" (%02d)", pivot);
|
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]));
|
sgrs[5], sgrs[6], sgrs[7], sgrs[8]));
|
||||||
if(i != OK){
|
if(r != OK){
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
if((i = printf(" %s ", argv[0])) < 0){
|
if((r = printf(" %s ", argv[0])) < 0){
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
cols += i;
|
cols += r;
|
||||||
i = putp(tiparm(sgr, 0, 0, 0, 0, 0, 0, 0, 0, 0));
|
r = putp(tiparm(sgr, 0, 0, 0, 0, 0, 0, 0, 0, 0));
|
||||||
if(i != OK){
|
if(r != OK){
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
pivot = pivot_on(pivot, sgrs, sgrcount);
|
pivot = pivot_on(pivot, sgrs, sgrcount);
|
||||||
|
Loading…
Reference in New Issue
Block a user