Skip to content

Update dependencies #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exclude = [
name = "rustbox"

[dependencies]
bitflags = "0.2.1"
bitflags = "1"
termbox-sys = "0.2.9"
gag = "0.1.6"
num-traits = "0.1.13"
num-traits = "0.2"
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extern crate rustbox;
use std::error::Error;
use std::default::Default;

use rustbox::{Color, RustBox};
use rustbox::{Color, RustBox, Style};
use rustbox::Key;

fn main() {
Expand All @@ -44,8 +44,8 @@ fn main() {
Result::Err(e) => panic!("{}", e),
};

rustbox.print(1, 1, rustbox::RB_BOLD, Color::White, Color::Black, "Hello, world!");
rustbox.print(1, 3, rustbox::RB_BOLD, Color::White, Color::Black,
rustbox.print(1, 1, Style::RB_BOLD, Color::White, Color::Black, "Hello, world!");
rustbox.print(1, 3, Style::RB_BOLD, Color::White, Color::Black,
"Press 'q' to quit.");
rustbox.present();
loop {
Expand Down
6 changes: 3 additions & 3 deletions examples/hello-256-world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ extern crate rustbox;

use std::default::Default;

use rustbox::{Color, RustBox, OutputMode};
use rustbox::{Color, RustBox, OutputMode, Style};
use rustbox::Key;

fn main() {
Expand All @@ -12,8 +12,8 @@ fn main() {
};
rustbox.set_output_mode(OutputMode::EightBit);

rustbox.print(1, 1, rustbox::RB_BOLD, Color::Byte(0xa2), Color::Black, "Hello, world!");
rustbox.print(1, 3, rustbox::RB_NORMAL, Color::Black, Color::Byte(0x9a), "Press 'q' to quit.");
rustbox.print(1, 1, Style::RB_BOLD, Color::Byte(0xa2), Color::Black, "Hello, world!");
rustbox.print(1, 3, Style::RB_NORMAL, Color::Black, Color::Byte(0x9a), "Press 'q' to quit.");
loop {
rustbox.present();
match rustbox.poll_event(false) {
Expand Down
6 changes: 3 additions & 3 deletions examples/hello-world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ extern crate rustbox;

use std::default::Default;

use rustbox::{Color, RustBox};
use rustbox::{Color, RustBox, Style};
use rustbox::Key;

fn main() {
Expand All @@ -11,8 +11,8 @@ fn main() {
Result::Err(e) => panic!("{}", e),
};

rustbox.print(1, 1, rustbox::RB_BOLD, Color::White, Color::Black, "Hello, world!");
rustbox.print(1, 3, rustbox::RB_BOLD, Color::White, Color::Black,
rustbox.print(1, 1, Style::RB_BOLD, Color::White, Color::Black, "Hello, world!");
rustbox.print(1, 3, Style::RB_BOLD, Color::White, Color::Black,
"Press 'q' to quit.");
loop {
rustbox.present();
Expand Down
44 changes: 20 additions & 24 deletions src/rustbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ extern crate num_traits;
extern crate termbox_sys as termbox;
#[macro_use] extern crate bitflags;

pub use self::style::{Style, RB_BOLD, RB_UNDERLINE, RB_REVERSE, RB_NORMAL};

use std::error::Error;
use std::fmt;
use std::io;
Expand Down Expand Up @@ -112,27 +110,25 @@ impl Default for Color {
}
}

mod style {
bitflags! {
#[repr(C)]
flags Style: u16 {
const TB_NORMAL_COLOR = 0x000F,
const RB_BOLD = 0x0100,
const RB_UNDERLINE = 0x0200,
const RB_REVERSE = 0x0400,
const RB_NORMAL = 0x0000,
const TB_ATTRIB = RB_BOLD.bits | RB_UNDERLINE.bits | RB_REVERSE.bits,
}
bitflags! {
#[repr(C)]
pub struct Style: u16 {
const TB_NORMAL_COLOR = 0x000F;
const RB_BOLD = 0x0100;
const RB_UNDERLINE = 0x0200;
const RB_REVERSE = 0x0400;
const RB_NORMAL = 0x0000;
const TB_ATTRIB = Style::RB_BOLD.bits | Style::RB_UNDERLINE.bits | Style::RB_REVERSE.bits;
}
}

impl Style {
pub fn from_color(color: super::Color) -> Style {
Style { bits: color.as_16color() & TB_NORMAL_COLOR.bits }
}
impl Style {
pub fn from_color(color: Color) -> Style {
Style { bits: color.as_16color() & Style::TB_NORMAL_COLOR.bits }
}

pub fn from_256color(color: super::Color) -> Style {
Style { bits: color.as_256color() }
}
pub fn from_256color(color: Color) -> Style {
Style { bits: color.as_256color() }
}
}

Expand Down Expand Up @@ -460,13 +456,13 @@ impl RustBox {
match self.output_mode {
// 256 color mode
OutputMode::EightBit => {
fg_int = Style::from_256color(fg) | (sty & style::TB_ATTRIB);
fg_int = Style::from_256color(fg) | (sty & Style::TB_ATTRIB);
bg_int = Style::from_256color(bg);
},

// 16 color mode
_ => {
fg_int = Style::from_color(fg) | (sty & style::TB_ATTRIB);
fg_int = Style::from_color(fg) | (sty & Style::TB_ATTRIB);
bg_int = Style::from_color(bg);
}
}
Expand All @@ -487,13 +483,13 @@ impl RustBox {
match self.output_mode {
// 256 color mode
OutputMode::EightBit => {
fg_int = Style::from_256color(fg) | (sty & style::TB_ATTRIB);
fg_int = Style::from_256color(fg) | (sty & Style::TB_ATTRIB);
bg_int = Style::from_256color(bg);
},

// 16 color mode
_ => {
fg_int = Style::from_color(fg) | (sty & style::TB_ATTRIB);
fg_int = Style::from_color(fg) | (sty & Style::TB_ATTRIB);
bg_int = Style::from_color(bg);
}
}
Expand Down