Skip to content

Commit

Permalink
Merge terminal.rs into mod.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
nabijaczleweli committed Jan 6, 2016
1 parent 4ee8b4a commit 18c728a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 58 deletions.
55 changes: 51 additions & 4 deletions src/terminal/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Event> {
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 {
Expand Down
54 changes: 0 additions & 54 deletions src/terminal/state/terminal.rs

This file was deleted.

0 comments on commit 18c728a

Please sign in to comment.