mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Add strikethrough effect (#360)
This commit is contained in:
parent
ef60cd0a76
commit
9ca3f50bd6
@ -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 => {
|
||||||
|
@ -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),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
@ -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);
|
||||||
|
@ -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),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user