majc: support history #3

Merged
cadey merged 4 commits from majc-history into main 2020-07-27 22:16:59 +00:00
1 changed files with 12 additions and 8 deletions
Showing only changes of commit 37a9a1347c - Show all commits

View File

@ -1,7 +1,7 @@
use cursive::{ use cursive::{
event::Key, event::Key,
menu::MenuTree, menu::MenuTree,
theme::{Effect, Style, Color, PaletteColor, Theme}, theme::{BaseColor, BorderStyle, Color, Effect, PaletteColor, Style, Theme},
traits::*, traits::*,
utils::markup::StyledString, utils::markup::StyledString,
views::{Dialog, EditView, Panel, ResizedView, TextView}, views::{Dialog, EditView, Panel, ResizedView, TextView},
@ -38,9 +38,8 @@ fn main() {
env!("CARGO_PKG_AUTHORS"), env!("CARGO_PKG_AUTHORS"),
))); )));
}) })
.leaf("Help", move |s| { .leaf("Help", help)
help(s); .leaf("Quit", cursive::Cursive::quit),
}),
) )
.add_leaf("Open", |s| open_prompt(s)); .add_leaf("Open", |s| open_prompt(s));
@ -170,10 +169,9 @@ fn render_gemini(body: &str) -> StyledString {
Text(line) => styled.append(StyledString::plain(line)), Text(line) => styled.append(StyledString::plain(line)),
Link { to, name } => match name { Link { to, name } => match name {
None => styled.append(StyledString::styled(to, Style::from(Effect::Underline))), None => styled.append(StyledString::styled(to, Style::from(Effect::Underline))),
Some(name) => styled.append(StyledString::styled( Some(name) => {
format!("{}: {}", to, name), styled.append(StyledString::styled(name, Style::from(Effect::Underline)))
Style::from(Effect::Underline), }
)),
}, },
Preformatted(data) => styled.append(StyledString::plain(data)), Preformatted(data) => styled.append(StyledString::plain(data)),
Heading { level: _, body } => { Heading { level: _, body } => {
@ -193,6 +191,12 @@ fn custom_theme_from_cursive(siv: &Cursive) -> Theme {
let mut theme = siv.current_theme().clone(); let mut theme = siv.current_theme().clone();
theme.palette[PaletteColor::Background] = Color::TerminalDefault; theme.palette[PaletteColor::Background] = Color::TerminalDefault;
theme.palette[PaletteColor::View] = Color::TerminalDefault;
theme.palette[PaletteColor::Primary] = Color::Dark(BaseColor::White);
theme.palette[PaletteColor::TitlePrimary] = Color::Light(BaseColor::White);
theme.shadow = false;
theme.borders = BorderStyle::Simple;
theme theme
} }