From 16139e4fa7318e6fde742b7c93ba169adb424ee5 Mon Sep 17 00:00:00 2001 From: Ilkka Halila Date: Tue, 11 Oct 2016 21:04:48 +0300 Subject: [PATCH] Added a platform specific pre_init() method. Allows for a setlocale call on Linux so that unicode output works correctly. --- src/lib.rs | 1 + src/unix/mod.rs | 6 +++++- src/windows/mod.rs | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 18a86e10..92e6a895 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -433,6 +433,7 @@ pub fn has_colors() -> bool { /// /// Returns a Window struct that is used to access Window specific functions. pub fn initscr() -> Window { + platform_specific::pre_init(); let window_pointer = unsafe { curses::initscr() }; Window { _window: window_pointer } } diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 7dcb7a24..cf29ae58 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -2,11 +2,15 @@ pub mod constants; use self::constants::*; -use ncurses::{box_, getmouse}; +use ncurses::{box_, getmouse, LcCategory, setlocale}; use ncurses::ll::{chtype, MEVENT, NCURSES_ATTR_T, WINDOW, wattron, wattroff, wattrset, ungetch}; use libc::c_int; use input::Input; +pub fn pre_init() { + setlocale(LcCategory::all, ""); +} + pub fn _attron(w: WINDOW, attributes: chtype) -> i32 { unsafe { wattron(w, attributes as NCURSES_ATTR_T) } } diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 5705d974..2b5b7c0c 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -8,6 +8,10 @@ use self::constants::*; use input::Input; +pub fn pre_init() { + // No need to do anything here +} + pub fn _attron(w: *mut WINDOW, attributes: chtype) -> i32 { unsafe { wattron(w, attributes) } }