mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-12 20:23:35 +00:00
Add Effect::{Bold,Italic,Underline}
This commit is contained in:
parent
5af367fa18
commit
2d7f8295cf
@ -177,6 +177,10 @@ impl backend::Backend for Concrete {
|
|||||||
|
|
||||||
fn with_effect<F: FnOnce()>(&self, effect: Effect, f: F) {
|
fn with_effect<F: FnOnce()>(&self, effect: Effect, f: F) {
|
||||||
match effect {
|
match effect {
|
||||||
|
// TODO: does BLT support bold/italic/underline?
|
||||||
|
Effect::Bold |
|
||||||
|
Effect::Italic |
|
||||||
|
Effect::Underline |
|
||||||
Effect::Simple => f(),
|
Effect::Simple => f(),
|
||||||
// TODO: how to do this correctly?`
|
// TODO: how to do this correctly?`
|
||||||
// BLT itself doesn't do this kind of thing,
|
// BLT itself doesn't do this kind of thing,
|
||||||
|
@ -229,6 +229,10 @@ impl backend::Backend for Concrete {
|
|||||||
let style = match effect {
|
let style = match effect {
|
||||||
Effect::Reverse => ncurses::A_REVERSE(),
|
Effect::Reverse => ncurses::A_REVERSE(),
|
||||||
Effect::Simple => ncurses::A_NORMAL(),
|
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);
|
ncurses::attron(style);
|
||||||
f();
|
f();
|
||||||
|
@ -187,8 +187,11 @@ impl backend::Backend for Concrete {
|
|||||||
|
|
||||||
fn with_effect<F: FnOnce()>(&self, effect: Effect, f: F) {
|
fn with_effect<F: FnOnce()>(&self, effect: Effect, f: F) {
|
||||||
let style = match effect {
|
let style = match effect {
|
||||||
Effect::Reverse => pancurses::Attribute::Reverse,
|
|
||||||
Effect::Simple => pancurses::Attribute::Normal,
|
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);
|
self.window.attron(style);
|
||||||
f();
|
f();
|
||||||
|
@ -39,6 +39,9 @@ impl Effectable for theme::Effect {
|
|||||||
match *self {
|
match *self {
|
||||||
theme::Effect::Simple => (),
|
theme::Effect::Simple => (),
|
||||||
theme::Effect::Reverse => print!("{}", tstyle::Invert),
|
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 {
|
match *self {
|
||||||
theme::Effect::Simple => (),
|
theme::Effect::Simple => (),
|
||||||
theme::Effect::Reverse => print!("{}", tstyle::NoInvert),
|
theme::Effect::Reverse => print!("{}", tstyle::NoInvert),
|
||||||
|
theme::Effect::Bold => print!("{}", tstyle::NoBold),
|
||||||
|
theme::Effect::Italic => print!("{}", tstyle::NoItalic),
|
||||||
|
theme::Effect::Underline => print!("{}", tstyle::NoUnderline),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,12 @@ pub enum Effect {
|
|||||||
Simple,
|
Simple,
|
||||||
/// Reverses foreground and background colors
|
/// Reverses foreground and background colors
|
||||||
Reverse,
|
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.
|
/// Combines a front and back color.
|
||||||
|
Loading…
Reference in New Issue
Block a user