From 18c728a84a06133c224139adc9b9917b90788164 Mon Sep 17 00:00:00 2001 From: nabijaczleweli Date: Thu, 7 Jan 2016 07:23:46 +0100 Subject: [PATCH] Merge terminal.rs into mod.rs --- src/terminal/state/mod.rs | 55 +++++++++++++++++++++++++++++++--- src/terminal/state/terminal.rs | 54 --------------------------------- 2 files changed, 51 insertions(+), 58 deletions(-) delete mode 100644 src/terminal/state/terminal.rs diff --git a/src/terminal/state/mod.rs b/src/terminal/state/mod.rs index 2ce709a9..24dfb69e 100644 --- a/src/terminal/state/mod.rs +++ b/src/terminal/state/mod.rs @@ -13,15 +13,62 @@ //! ``` -mod terminal; - pub mod mouse; -use terminal::KeyCode; +use Color; +use std::char; +use geometry::Size; +use terminal::{self, Event, KeyCode}; use bear_lib_terminal_sys as ffi; -pub use self::terminal::*; +/// Get the terminal size in cells. +pub fn size() -> Size { + Size::new(ffi::state(ffi::TK_WIDTH), ffi::state(ffi::TK_HEIGHT)) +} + +/// Get cell size in pixels. +pub fn cell_size() -> Size { + Size::new(ffi::state(ffi::TK_CELL_WIDTH), ffi::state(ffi::TK_CELL_HEIGHT)) +} + +/// Get the currently selected foreground colour. +/// +/// Foreground colours are changed by using the [`terminal::*_foreground()`](../index.html) function family. +pub fn foreground() -> Color { + terminal::from_color_t(ffi::state(ffi::TK_COLOR) as ffi::ColorT) +} + +/// Get the currently selected background colour. +/// +/// Background colours are changed by using the [`terminal::*_background()`](../index.html) function family. +pub fn background() -> Color { + terminal::from_color_t(ffi::state(ffi::TK_BKCOLOR) as ffi::ColorT) +} + +/// Get the currently selected layer. +/// +/// Layer is selected by using the [`terminal::layer()`](../fn.layer.html) function. +pub fn layer() -> i32 { + ffi::state(ffi::TK_LAYER) +} + +/// Most-recent-event-produced unicode character. +pub fn char() -> char { + char::from_u32(ffi::state(ffi::TK_WCHAR) as u32).unwrap() +} + +/// Get last dequeued event. +/// +/// Returns `None` iff no events have been dequeued yet. +pub fn event() -> Option { + terminal::to_event(ffi::state(ffi::TK_EVENT)) +} + +/// Check, whether the terminal is currently full-screen. +pub fn fullscreen() -> bool { + ffi::check(ffi::TK_FULLSCREEN) +} /// Check, whether a [`KeyCode`](../enum.KeyCode.html)-specified key is currently pressed. pub fn key_pressed(key: KeyCode) -> bool { diff --git a/src/terminal/state/terminal.rs b/src/terminal/state/terminal.rs deleted file mode 100644 index 4e5878e0..00000000 --- a/src/terminal/state/terminal.rs +++ /dev/null @@ -1,54 +0,0 @@ -use Color; -use terminal::{self, Event}; -use std::char; -use geometry::Size; -use bear_lib_terminal_sys as ffi; - - -/// Get the terminal size in cells. -pub fn size() -> Size { - Size::new(ffi::state(ffi::TK_WIDTH), ffi::state(ffi::TK_HEIGHT)) -} - -/// Get cell size in pixels. -pub fn cell_size() -> Size { - Size::new(ffi::state(ffi::TK_CELL_WIDTH), ffi::state(ffi::TK_CELL_HEIGHT)) -} - -/// Get the currently selected foreground colour. -/// -/// Foreground colours are changed by using the [`terminal::*_foreground()`](../index.html) function family. -pub fn foreground() -> Color { - terminal::from_color_t(ffi::state(ffi::TK_COLOR) as ffi::ColorT) -} - -/// Get the currently selected background colour. -/// -/// Background colours are changed by using the [`terminal::*_background()`](../index.html) function family. -pub fn background() -> Color { - terminal::from_color_t(ffi::state(ffi::TK_BKCOLOR) as ffi::ColorT) -} - -/// Get the currently selected layer. -/// -/// Layer is selected by using the [`terminal::layer()`](../fn.layer.html) function. -pub fn layer() -> i32 { - ffi::state(ffi::TK_LAYER) -} - -/// Most-recent-event-produced unicode character. -pub fn char() -> char { - char::from_u32(ffi::state(ffi::TK_WCHAR) as u32).unwrap() -} - -/// Get last dequeued event. -/// -/// Returns `None` iff no events have been dequeued yet. -pub fn event() -> Option { - terminal::to_event(ffi::state(ffi::TK_EVENT)) -} - -/// Check, whether the terminal is currently full-screen. -pub fn fullscreen() -> bool { - ffi::check(ffi::TK_FULLSCREEN) -}