Monster commit: native version
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
use minimad::{Composite, CompositeStyle, Compound, Line};
|
||||
use ratatui::layout::{Constraint, Layout, Rect};
|
||||
use ratatui::style::{Color, Modifier, Style, Stylize};
|
||||
use ratatui::style::{Modifier, Style};
|
||||
use ratatui::text::{Line as RLine, Span};
|
||||
use ratatui::widgets::{Block, Borders, List, ListItem, Padding, Paragraph, Wrap};
|
||||
use ratatui::Frame;
|
||||
use tui_big_text::{BigText, PixelSize};
|
||||
|
||||
use crate::app::App;
|
||||
use crate::theme::{dict, markdown, search, ui};
|
||||
use crate::views::highlight;
|
||||
|
||||
// To add a new help topic: drop a .md file in docs/ and add one line here.
|
||||
@@ -37,9 +38,9 @@ fn render_topics(frame: &mut Frame, app: &App, area: Rect) {
|
||||
.map(|(i, (name, _))| {
|
||||
let selected = i == app.ui.help_topic;
|
||||
let style = if selected {
|
||||
Style::new().fg(Color::Cyan).add_modifier(Modifier::BOLD)
|
||||
Style::new().fg(dict::CATEGORY_SELECTED).add_modifier(Modifier::BOLD)
|
||||
} else {
|
||||
Style::new().fg(Color::White)
|
||||
Style::new().fg(ui::TEXT_PRIMARY)
|
||||
};
|
||||
let prefix = if selected { "> " } else { " " };
|
||||
ListItem::new(format!("{prefix}{name}")).style(style)
|
||||
@@ -63,13 +64,13 @@ fn render_content(frame: &mut Frame, app: &App, area: Rect) {
|
||||
.areas(area);
|
||||
let big_title = BigText::builder()
|
||||
.pixel_size(PixelSize::Quadrant)
|
||||
.style(Style::new().cyan().bold())
|
||||
.style(Style::new().fg(markdown::H1).bold())
|
||||
.lines(vec!["CAGIRE".into()])
|
||||
.centered()
|
||||
.build();
|
||||
let subtitle = Paragraph::new(RLine::from(Span::styled(
|
||||
"A Forth Sequencer",
|
||||
Style::new().fg(Color::White),
|
||||
Style::new().fg(ui::TEXT_PRIMARY),
|
||||
)))
|
||||
.alignment(ratatui::layout::Alignment::Center);
|
||||
let [big_area, subtitle_area] =
|
||||
@@ -126,9 +127,9 @@ fn render_content(frame: &mut Frame, app: &App, area: Rect) {
|
||||
|
||||
fn render_search_bar(frame: &mut Frame, app: &App, area: Rect) {
|
||||
let style = if app.ui.help_search_active {
|
||||
Style::new().fg(Color::Yellow)
|
||||
Style::new().fg(search::ACTIVE)
|
||||
} else {
|
||||
Style::new().fg(Color::DarkGray)
|
||||
Style::new().fg(search::INACTIVE)
|
||||
};
|
||||
let cursor = if app.ui.help_search_active { "█" } else { "" };
|
||||
let text = format!(" /{}{cursor}", app.ui.help_search_query);
|
||||
@@ -145,7 +146,7 @@ fn highlight_line<'a>(line: RLine<'a>, query: &str) -> RLine<'a> {
|
||||
}
|
||||
let content = span.content.to_string();
|
||||
let base_style = span.style;
|
||||
let hl_style = base_style.bg(Color::Yellow).fg(Color::Black);
|
||||
let hl_style = base_style.bg(search::MATCH_BG).fg(search::MATCH_FG);
|
||||
let mut start = 0;
|
||||
let lower_bytes = lower.as_bytes();
|
||||
let query_bytes = query.as_bytes();
|
||||
@@ -185,7 +186,7 @@ pub fn find_match(query: &str) -> Option<(usize, usize)> {
|
||||
}
|
||||
|
||||
fn code_border_style() -> Style {
|
||||
Style::new().fg(Color::Rgb(60, 60, 70))
|
||||
Style::new().fg(markdown::CODE_BORDER)
|
||||
}
|
||||
|
||||
fn preprocess_underscores(md: &str) -> String {
|
||||
@@ -270,14 +271,14 @@ fn parse_markdown(md: &str) -> Vec<RLine<'static>> {
|
||||
fn composite_to_line(composite: Composite) -> RLine<'static> {
|
||||
let base_style = match composite.style {
|
||||
CompositeStyle::Header(1) => Style::new()
|
||||
.fg(Color::Cyan)
|
||||
.fg(markdown::H1)
|
||||
.add_modifier(Modifier::BOLD | Modifier::UNDERLINED),
|
||||
CompositeStyle::Header(2) => Style::new().fg(Color::Yellow).add_modifier(Modifier::BOLD),
|
||||
CompositeStyle::Header(_) => Style::new().fg(Color::Magenta).add_modifier(Modifier::BOLD),
|
||||
CompositeStyle::ListItem(_) => Style::new().fg(Color::White),
|
||||
CompositeStyle::Quote => Style::new().fg(Color::Rgb(150, 150, 150)),
|
||||
CompositeStyle::Code => Style::new().fg(Color::Green),
|
||||
CompositeStyle::Paragraph => Style::new().fg(Color::White),
|
||||
CompositeStyle::Header(2) => Style::new().fg(markdown::H2).add_modifier(Modifier::BOLD),
|
||||
CompositeStyle::Header(_) => Style::new().fg(markdown::H3).add_modifier(Modifier::BOLD),
|
||||
CompositeStyle::ListItem(_) => Style::new().fg(markdown::LIST),
|
||||
CompositeStyle::Quote => Style::new().fg(markdown::QUOTE),
|
||||
CompositeStyle::Code => Style::new().fg(markdown::CODE),
|
||||
CompositeStyle::Paragraph => Style::new().fg(markdown::TEXT),
|
||||
};
|
||||
|
||||
let prefix = match composite.style {
|
||||
@@ -308,7 +309,7 @@ fn compound_to_spans(compound: Compound, base: Style, out: &mut Vec<Span<'static
|
||||
style = style.add_modifier(Modifier::ITALIC);
|
||||
}
|
||||
if compound.code {
|
||||
style = Style::new().fg(Color::Green);
|
||||
style = Style::new().fg(markdown::CODE);
|
||||
}
|
||||
if compound.strikeout {
|
||||
style = style.add_modifier(Modifier::CROSSED_OUT);
|
||||
@@ -316,7 +317,7 @@ fn compound_to_spans(compound: Compound, base: Style, out: &mut Vec<Span<'static
|
||||
|
||||
let src = compound.src.to_string();
|
||||
let link_style = Style::new()
|
||||
.fg(Color::Rgb(120, 200, 180))
|
||||
.fg(markdown::LINK)
|
||||
.add_modifier(Modifier::UNDERLINED);
|
||||
|
||||
let mut rest = src.as_str();
|
||||
@@ -336,7 +337,7 @@ fn compound_to_spans(compound: Compound, base: Style, out: &mut Vec<Span<'static
|
||||
out.push(Span::styled(text.to_string(), link_style));
|
||||
out.push(Span::styled(
|
||||
format!(" ({url})"),
|
||||
Style::new().fg(Color::Rgb(100, 100, 100)),
|
||||
Style::new().fg(markdown::LINK_URL),
|
||||
));
|
||||
}
|
||||
rest = &rest[url_start + url_end + 1..];
|
||||
|
||||
Reference in New Issue
Block a user