Add strikethrough effect (#360)

This commit is contained in:
cubetastic 2019-07-30 01:29:58 +05:30 committed by Alexandre Bury
parent ef60cd0a76
commit 9ca3f50bd6
6 changed files with 14 additions and 2 deletions

View File

@ -261,10 +261,11 @@ impl backend::Backend for Backend {
fn set_effect(&self, effect: Effect) { fn set_effect(&self, effect: Effect) {
match effect { match effect {
// TODO: does BLT support bold/italic/underline? // TODO: does BLT support bold/italic/strikethrough/underline?
Effect::Bold Effect::Bold
| Effect::Italic | Effect::Italic
| Effect::Underline | Effect::Underline
| Effect::Strikethrough
| Effect::Simple => {} | Effect::Simple => {}
// 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,
@ -278,10 +279,11 @@ impl backend::Backend for Backend {
fn unset_effect(&self, effect: Effect) { fn unset_effect(&self, effect: Effect) {
match effect { match effect {
// TODO: does BLT support bold/italic/underline? // TODO: does BLT support bold/italic/strikethrough/underline?
Effect::Bold Effect::Bold
| Effect::Italic | Effect::Italic
| Effect::Underline | Effect::Underline
| Effect::Strikethrough
| Effect::Simple => {} | Effect::Simple => {}
// The process of reversing is the same as unreversing // The process of reversing is the same as unreversing
Effect::Reverse => { Effect::Reverse => {

View File

@ -234,6 +234,7 @@ impl backend::Backend for Backend {
theme::Effect::Reverse => self.write(Attribute::Reverse), theme::Effect::Reverse => self.write(Attribute::Reverse),
theme::Effect::Bold => self.write(Attribute::Bold), theme::Effect::Bold => self.write(Attribute::Bold),
theme::Effect::Italic => self.write(Attribute::Italic), theme::Effect::Italic => self.write(Attribute::Italic),
theme::Effect::Strikethrough => self.write(Attribute::CrossedOut),
theme::Effect::Underline => self.write(Attribute::Underlined), theme::Effect::Underline => self.write(Attribute::Underlined),
} }
} }
@ -244,6 +245,7 @@ impl backend::Backend for Backend {
theme::Effect::Reverse => self.write(Attribute::Reverse), theme::Effect::Reverse => self.write(Attribute::Reverse),
theme::Effect::Bold => self.write(Attribute::NoBold), theme::Effect::Bold => self.write(Attribute::NoBold),
theme::Effect::Italic => self.write(Attribute::NoItalic), theme::Effect::Italic => self.write(Attribute::NoItalic),
theme::Effect::Strikethrough => self.write(Attribute::NotCrossedOut),
theme::Effect::Underline => self.write(Attribute::Underlined), theme::Effect::Underline => self.write(Attribute::Underlined),
} }
} }

View File

@ -343,6 +343,7 @@ impl backend::Backend for Backend {
Effect::Simple => ncurses::A_NORMAL(), Effect::Simple => ncurses::A_NORMAL(),
Effect::Bold => ncurses::A_BOLD(), Effect::Bold => ncurses::A_BOLD(),
Effect::Italic => ncurses::A_ITALIC(), Effect::Italic => ncurses::A_ITALIC(),
Effect::Strikethrough => ncurses::A_NORMAL(),
Effect::Underline => ncurses::A_UNDERLINE(), Effect::Underline => ncurses::A_UNDERLINE(),
}; };
ncurses::attron(style); ncurses::attron(style);
@ -354,6 +355,7 @@ impl backend::Backend for Backend {
Effect::Simple => ncurses::A_NORMAL(), Effect::Simple => ncurses::A_NORMAL(),
Effect::Bold => ncurses::A_BOLD(), Effect::Bold => ncurses::A_BOLD(),
Effect::Italic => ncurses::A_ITALIC(), Effect::Italic => ncurses::A_ITALIC(),
Effect::Strikethrough => ncurses::A_NORMAL(),
Effect::Underline => ncurses::A_UNDERLINE(), Effect::Underline => ncurses::A_UNDERLINE(),
}; };
ncurses::attroff(style); ncurses::attroff(style);

View File

@ -388,6 +388,7 @@ impl backend::Backend for Backend {
Effect::Reverse => pancurses::Attribute::Reverse, Effect::Reverse => pancurses::Attribute::Reverse,
Effect::Bold => pancurses::Attribute::Bold, Effect::Bold => pancurses::Attribute::Bold,
Effect::Italic => pancurses::Attribute::Italic, Effect::Italic => pancurses::Attribute::Italic,
Effect::Strikethrough => pancurses::Attribute::Strikeout,
Effect::Underline => pancurses::Attribute::Underline, Effect::Underline => pancurses::Attribute::Underline,
}; };
self.window.attron(style); self.window.attron(style);
@ -399,6 +400,7 @@ impl backend::Backend for Backend {
Effect::Reverse => pancurses::Attribute::Reverse, Effect::Reverse => pancurses::Attribute::Reverse,
Effect::Bold => pancurses::Attribute::Bold, Effect::Bold => pancurses::Attribute::Bold,
Effect::Italic => pancurses::Attribute::Italic, Effect::Italic => pancurses::Attribute::Italic,
Effect::Strikethrough => pancurses::Attribute::Strikeout,
Effect::Underline => pancurses::Attribute::Underline, Effect::Underline => pancurses::Attribute::Underline,
}; };
self.window.attroff(style); self.window.attroff(style);

View File

@ -223,6 +223,7 @@ impl backend::Backend for Backend {
theme::Effect::Reverse => self.write(tstyle::Invert), theme::Effect::Reverse => self.write(tstyle::Invert),
theme::Effect::Bold => self.write(tstyle::Bold), theme::Effect::Bold => self.write(tstyle::Bold),
theme::Effect::Italic => self.write(tstyle::Italic), theme::Effect::Italic => self.write(tstyle::Italic),
theme::Effect::Strikethrough => self.write(tstyle::CrossedOut),
theme::Effect::Underline => self.write(tstyle::Underline), theme::Effect::Underline => self.write(tstyle::Underline),
} }
} }
@ -233,6 +234,7 @@ impl backend::Backend for Backend {
theme::Effect::Reverse => self.write(tstyle::NoInvert), theme::Effect::Reverse => self.write(tstyle::NoInvert),
theme::Effect::Bold => self.write(tstyle::NoBold), theme::Effect::Bold => self.write(tstyle::NoBold),
theme::Effect::Italic => self.write(tstyle::NoItalic), theme::Effect::Italic => self.write(tstyle::NoItalic),
theme::Effect::Strikethrough => self.write(tstyle::NoCrossedOut),
theme::Effect::Underline => self.write(tstyle::NoUnderline), theme::Effect::Underline => self.write(tstyle::NoUnderline),
} }
} }

View File

@ -11,6 +11,8 @@ pub enum Effect {
Bold, Bold,
/// Prints foreground in italic /// Prints foreground in italic
Italic, Italic,
/// Prints foreground with strikethrough
Strikethrough,
/// Prints foreground with underline /// Prints foreground with underline
Underline, Underline,
} }