mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-13 20:53:07 +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]
|
[dependencies.termion]
|
||||||
optional = true
|
optional = true
|
||||||
# version = "1.1.1"
|
version = "1.1.1"
|
||||||
git = "https://github.com/gyscos/termion"
|
|
||||||
|
|
||||||
[dependencies.bear-lib-terminal]
|
[dependencies.bear-lib-terminal]
|
||||||
optional = true
|
optional = true
|
||||||
|
@ -10,6 +10,7 @@ use self::termion::raw::IntoRawMode;
|
|||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
use std::fmt;
|
||||||
|
|
||||||
use ::theme;
|
use ::theme;
|
||||||
|
|
||||||
@ -24,6 +25,22 @@ trait Effectable {
|
|||||||
fn off(&self);
|
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 {
|
impl Effectable for theme::Effect {
|
||||||
fn on(&self) {
|
fn on(&self) {
|
||||||
match *self {
|
match *self {
|
||||||
@ -41,7 +58,7 @@ impl Effectable for theme::Effect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn apply_colors(fg: &color::Color, bg: &color::Color) {
|
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 {
|
impl Concrete {
|
||||||
|
Loading…
Reference in New Issue
Block a user