mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-08 01:10:23 +00:00
[windows] setlocale(LC_ALL, ".UTF8") #2117
This commit is contained in:
parent
4d40401344
commit
caa054cc43
@ -1,6 +1,6 @@
|
||||
# 3.14.0 introduced NAME_WLE
|
||||
cmake_minimum_required(VERSION 3.14.0)
|
||||
project(notcurses VERSION 2.4.8
|
||||
project(notcurses VERSION 2.4.99
|
||||
DESCRIPTION "Blingful UI for modern terminal emulators"
|
||||
HOMEPAGE_URL "https://nick-black.com/dankwiki/index.php/notcurses"
|
||||
LANGUAGES C)
|
||||
|
@ -909,6 +909,12 @@ int ncplane_destroy_family(ncplane *ncp){
|
||||
// called setlocale() themselves, and set the NCOPTION_INHIBIT_SETLOCALE flag.
|
||||
// if that flag is set, we take the locale and encoding as we get them.
|
||||
void init_lang(void){
|
||||
char* setret;
|
||||
#ifdef __MINGW64__
|
||||
if((setret = setlocale(LC_ALL, ".UTF8")) == NULL){
|
||||
logwarn("couldn't set LC_ALL to utf8\n");
|
||||
}
|
||||
#endif
|
||||
const char* encoding = nl_langinfo(CODESET);
|
||||
if(encoding && !strcmp(encoding, "UTF-8")){
|
||||
return; // already utf-8, great!
|
||||
@ -919,7 +925,11 @@ void init_lang(void){
|
||||
loginfo("LANG was explicitly set to %s, not changing locale\n", lang);
|
||||
return;
|
||||
}
|
||||
setlocale(LC_ALL, "");
|
||||
#ifndef __MINGW64__
|
||||
if((setret = setlocale(LC_ALL, "")) == NULL){
|
||||
logwarn("setting locale based on LANG failed\n");
|
||||
}
|
||||
#endif
|
||||
encoding = nl_langinfo(CODESET);
|
||||
if(encoding && !strcmp(encoding, "UTF-8")){
|
||||
loginfo("Set locale from LANG; client should call setlocale(2)!\n");
|
||||
@ -996,6 +1006,7 @@ notcurses* notcurses_core_init(const notcurses_options* opts, FILE* outfp){
|
||||
if(!(opts->flags & NCOPTION_INHIBIT_SETLOCALE)){
|
||||
init_lang();
|
||||
}
|
||||
//fprintf(stderr, "getenv LC_ALL: %s LC_CTYPE: %s\n", getenv("LC_ALL"), getenv("LC_CTYPE"));
|
||||
const char* encoding = nl_langinfo(CODESET);
|
||||
bool utf8;
|
||||
if(encoding && !strcmp(encoding, "UTF-8")){
|
||||
@ -1708,7 +1719,7 @@ int ncplane_putegc_yx(ncplane* n, int y, int x, const char* gclust, size_t* sbyt
|
||||
if(sbytes){
|
||||
*sbytes = bytes;
|
||||
}
|
||||
//fprintf(stderr, "cols: %d wcs: %d\n", cols, bytes);
|
||||
//fprintf(stderr, "glust: %s cols: %d wcs: %d\n", gclust, cols, bytes);
|
||||
return ncplane_put(n, y, x, gclust, cols, n->stylemask, n->channels, bytes);
|
||||
}
|
||||
|
||||
|
@ -1200,7 +1200,7 @@ rasterize_core(notcurses* nc, const ncpile* p, fbuf* f, unsigned phase){
|
||||
nc->rstate.bgdefelidable = false;
|
||||
nc->rstate.bgpalelidable = false;
|
||||
}
|
||||
//fprintf(stderr, "RAST %08x [%s] to %d/%d cols: %u %016lx\n", srccell->gcluster, pool_extended_gcluster(&nc->pool, srccell), y, x, srccell->width, srccell->channels);
|
||||
//fprintf(stderr, "RAST %08x [%s] to %d/%d cols: %u %016" PRIx64 "\n", srccell->gcluster, pool_extended_gcluster(&nc->pool, srccell), y, x, srccell->width, srccell->channels);
|
||||
// this is used to invalidate the sprixel in the first text round,
|
||||
// which is only necessary for sixel, not kitty.
|
||||
if(rvec[damageidx].sprixel){
|
||||
|
@ -677,6 +677,7 @@ apply_term_heuristics(tinfo* ti, const char* termname, queried_terminals_e qterm
|
||||
}else if(qterm == TERMINAL_MSTERMINAL){
|
||||
termname = "Windows Terminal";
|
||||
ti->caps.rgb = true;
|
||||
ti->caps.quadrants = true;
|
||||
}else if(qterm == TERMINAL_CONTOUR){
|
||||
termname = "Contour";
|
||||
ti->caps.quadrants = true;
|
||||
|
@ -79,6 +79,7 @@ int prepare_windows_terminal(tinfo* ti, size_t* tablelen, size_t* tableused){
|
||||
}
|
||||
// if we're a true Windows Terminal, SetConsoleMode() ought succeed.
|
||||
// otherwise, we're something else; go ahead and try.
|
||||
// FIXME handle redirection to a file, where this fails
|
||||
if(!SetConsoleMode(ti->outhandle, ENABLE_PROCESSED_OUTPUT
|
||||
| ENABLE_WRAP_AT_EOL_OUTPUT
|
||||
| ENABLE_VIRTUAL_TERMINAL_PROCESSING
|
||||
|
Loading…
Reference in New Issue
Block a user