1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#![cfg(not(windows))]
#![deny(warnings)]
#![doc(test(attr(deny(warnings))))]
#![doc(test(attr(allow(dead_code))))]
#![doc(test(attr(allow(unused_variables))))]
#![allow(clippy::collapsible_if)]
#![allow(clippy::many_single_char_names)]
#![feature(negative_impls)]
#![feature(extern_types)]
#![no_std]
extern crate alloc;
#[allow(non_camel_case_types)]
#[allow(non_snake_case)]
mod ncurses;
mod common;
mod non_unicode;
mod unicode;
use alloc::boxed::Box;
use errno_no_std::Errno;
use libc::{CODESET, setlocale, strcmp, nl_langinfo, LC_ALL};
use tuifw_screen_base::{Screen};
pub unsafe fn init() -> Result<Box<dyn Screen>, Errno> {
setlocale(LC_ALL, "\0".as_ptr() as _);
let unicode = strcmp(nl_langinfo(CODESET), b"UTF-8\0".as_ptr() as _) == 0;
let screen = if unicode {
Box::new(unicode::Screen::new()?) as Box<dyn Screen>
} else {
Box::new(non_unicode::Screen::new()?) as Box<dyn Screen>
};
Ok(screen)
}