mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Back to upstream termion
Just figured I could implement Color for a custom wrapper struct.
This commit is contained in:
parent
949b1e9632
commit
ce009d0e5f
@ -33,8 +33,7 @@ version = "0.6"
|
||||
|
||||
[dependencies.termion]
|
||||
optional = true
|
||||
# version = "1.1.1"
|
||||
git = "https://github.com/gyscos/termion"
|
||||
version = "1.1.1"
|
||||
|
||||
[dependencies.bear-lib-terminal]
|
||||
optional = true
|
||||
|
@ -10,6 +10,7 @@ use self::termion::raw::IntoRawMode;
|
||||
use std::cell::Cell;
|
||||
use std::collections::BTreeMap;
|
||||
use std::io::Write;
|
||||
use std::fmt;
|
||||
|
||||
use ::theme;
|
||||
|
||||
@ -24,6 +25,22 @@ trait Effectable {
|
||||
fn off(&self);
|
||||
}
|
||||
|
||||
struct ColorRef<'a>(&'a color::Color);
|
||||
|
||||
impl <'a> color::Color for ColorRef<'a> {
|
||||
|
||||
#[inline]
|
||||
fn write_fg(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
self.0.write_fg(f)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn write_bg(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
self.0.write_bg(f)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl Effectable for theme::Effect {
|
||||
fn on(&self) {
|
||||
match *self {
|
||||
@ -41,7 +58,7 @@ impl Effectable for theme::Effect {
|
||||
}
|
||||
|
||||
fn apply_colors(fg: &color::Color, bg: &color::Color) {
|
||||
print!("{}{}", color::Fg(fg), color::Bg(bg));
|
||||
print!("{}{}", color::Fg(ColorRef(fg)), color::Bg(ColorRef(bg)));
|
||||
}
|
||||
|
||||
impl Concrete {
|
||||
|
Loading…
Reference in New Issue
Block a user