Skip to content

Commit

Permalink
Added a platform specific pre_init() method.
Browse files Browse the repository at this point in the history
Allows for a setlocale call on Linux so that unicode output works correctly.
  • Loading branch information
ihalila committed Oct 11, 2016
1 parent 0d26e59 commit 16139e4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/lib.rs
Expand Up @@ -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 }
}
Expand Down
6 changes: 5 additions & 1 deletion src/unix/mod.rs
Expand Up @@ -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) }
}
Expand Down
4 changes: 4 additions & 0 deletions src/windows/mod.rs
Expand Up @@ -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) }
}
Expand Down

0 comments on commit 16139e4

Please sign in to comment.