Merge branch 'master' of github.com:dankamongmen/notcurses

pull/907/head
joseLuís 4 years ago
commit 4b9a8d130f

@ -320,15 +320,11 @@ 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 size_t MAXTOWRITE = 8;
bool collect_input = false;
while(textpos < textlen || y > targrow){
pthread_mutex_lock(lock);
ncplane_move_yx(rplane, y, x);
size_t towrite = strcspn(text + textpos, " \t\n") + 1;
if(towrite > MAXTOWRITE){
towrite = MAXTOWRITE;
}
if(towrite){
char* duped = strndup(text + textpos, towrite);
size_t bytes;

@ -445,11 +445,10 @@ ncdirect* ncdirect_init(const char* termtype, FILE* outfp){
ret->fgdefault = ret->bgdefault = true;
ret->fgrgb = ret->bgrgb = 0;
ncdirect_styles_set(ret, 0);
init_lang(nullptr);
const char* encoding = nl_langinfo(CODESET);
if(encoding && strcmp(encoding, "UTF-8") == 0){
ret->utf8 = true;
}else if(encoding && strcmp(encoding, "ANSI_X3.4-1968") == 0){
ret->utf8 = false;
}
return ret;
}

@ -314,6 +314,7 @@ typedef struct notcurses {
void sigwinch_handler(int signo);
void init_lang(struct notcurses* nc); // nc may be NULL, only used for logging
int terminfostr(char** gseq, const char* name);
int interrogate_terminfo(tinfo* ti);

@ -774,25 +774,22 @@ init_banner(const notcurses* nc){
// practice is for the client code to have called setlocale() themselves, and
// set the NCOPTION_INHIBIT_SETLOCALE flag. if that flag is set, we take the
// locale as we get it.
static void
init_lang(const notcurses_options* opts){
if(!(opts->flags & NCOPTION_INHIBIT_SETLOCALE)){
const char* locale = setlocale(LC_ALL, "");
if(locale && (!strcmp(locale, "C") || !strcmp(locale, "POSIX"))){
const char* lang = getenv("LANG");
if(lang){
// if LANG was explicitly set to C/POSIX, roll with it
if(strcmp(locale, "C") && strcmp(locale, "POSIX")){
if(!locale){ // otherwise, generate diagnostic
fprintf(stderr, "Couldn't set locale based off LANG %s\n", lang);
}else{
fprintf(stderr, "Set %s locale from LANG; client should call setlocale(2)!\n",
lang ? lang : "???");
}
void init_lang(struct notcurses* nc){
const char* locale = setlocale(LC_ALL, "");
if(locale && (!strcmp(locale, "C") || !strcmp(locale, "POSIX"))){
const char* lang = getenv("LANG");
if(lang){
// if LANG was explicitly set to C/POSIX, roll with it
if(strcmp(locale, "C") && strcmp(locale, "POSIX")){
if(!locale){ // otherwise, generate diagnostic
logerror(nc, "Couldn't set locale based off LANG %s\n", lang);
}else{
loginfo(nc, "Set %s locale from LANG; client should call setlocale(2)!\n",
lang ? lang : "???");
}
}else{
fprintf(stderr, "No LANG environment variable was set, ick :/\n");
}
}else{
logwarn(nc, "No LANG environment variable was set, ick :/\n");
}
}
}
@ -842,7 +839,9 @@ notcurses* notcurses_init(const notcurses_options* opts, FILE* outfp){
return ret;
}
ret->loglevel = opts->loglevel;
init_lang(opts);
if(!(opts->flags & NCOPTION_INHIBIT_SETLOCALE)){
init_lang(ret);
}
const char* encoding = nl_langinfo(CODESET);
if(encoding && strcmp(encoding, "UTF-8") == 0){
ret->utf8 = true;

@ -106,6 +106,7 @@ int main(void){
ncdirect_stop(nc);
return EXIT_FAILURE;
}
ncdirect_styles_on(nc, NCSTYLE_ITALIC);
printf("dank\n");
if(ncdirect_stop(nc)){
return EXIT_FAILURE;

Loading…
Cancel
Save