Add Effect::{Bold,Italic,Underline}

This commit is contained in:
Alexandre Bury 2018-01-05 13:57:39 +01:00
parent 5af367fa18
commit 2d7f8295cf
5 changed files with 24 additions and 2 deletions

View File

@ -177,6 +177,10 @@ impl backend::Backend for Concrete {
fn with_effect<F: FnOnce()>(&self, effect: Effect, f: F) {
match effect {
// TODO: does BLT support bold/italic/underline?
Effect::Bold |
Effect::Italic |
Effect::Underline |
Effect::Simple => f(),
// TODO: how to do this correctly?`
// BLT itself doesn't do this kind of thing,

View File

@ -229,6 +229,10 @@ impl backend::Backend for Concrete {
let style = match effect {
Effect::Reverse => ncurses::A_REVERSE(),
Effect::Simple => ncurses::A_NORMAL(),
Effect::Bold => ncurses::A_BOLD(),
// Effect::Italic => ncurses::A_ITALIC(),
Effect::Italic => ncurses::A_NORMAL(),
Effect::Underline => ncurses::A_UNDERLINE(),
};
ncurses::attron(style);
f();

View File

@ -187,8 +187,11 @@ impl backend::Backend for Concrete {
fn with_effect<F: FnOnce()>(&self, effect: Effect, f: F) {
let style = match effect {
Effect::Reverse => pancurses::Attribute::Reverse,
Effect::Simple => pancurses::Attribute::Normal,
Effect::Reverse => pancurses::Attribute::Reverse,
Effect::Bold => pancurses::Attribute::Bold,
Effect::Italic => pancurses::Attribute::Italic,
Effect::Underline => pancurses::Attribute::Underline,
};
self.window.attron(style);
f();

View File

@ -39,6 +39,9 @@ impl Effectable for theme::Effect {
match *self {
theme::Effect::Simple => (),
theme::Effect::Reverse => print!("{}", tstyle::Invert),
theme::Effect::Bold => print!("{}", tstyle::Bold),
theme::Effect::Italic => print!("{}", tstyle::Italic),
theme::Effect::Underline => print!("{}", tstyle::Underline),
}
}
@ -46,6 +49,9 @@ impl Effectable for theme::Effect {
match *self {
theme::Effect::Simple => (),
theme::Effect::Reverse => print!("{}", tstyle::NoInvert),
theme::Effect::Bold => print!("{}", tstyle::NoBold),
theme::Effect::Italic => print!("{}", tstyle::NoItalic),
theme::Effect::Underline => print!("{}", tstyle::NoUnderline),
}
}
}

View File

@ -127,7 +127,12 @@ pub enum Effect {
Simple,
/// Reverses foreground and background colors
Reverse,
// TODO: bold, italic, underline
/// Prints foreground in bold
Bold,
/// Prints foreground in italic
Italic,
/// Prints foreground with underline
Underline,
}
/// Combines a front and back color.