|
|
@@ -11,7 +11,7 @@ use ratatui::{
|
|
|
layout::{Constraint, Direction, Layout, Rect},
|
|
|
style::{Color, Modifier, Style},
|
|
|
text::{Line, Span},
|
|
|
- widgets::{Block, Borders, Clear, List, ListItem, ListState, Paragraph},
|
|
|
+ widgets::{Block, BorderType, Borders, Clear, List, ListItem, ListState, Paragraph},
|
|
|
Frame, Terminal,
|
|
|
};
|
|
|
use std::io::{self, Write};
|
|
|
@@ -203,6 +203,8 @@ struct App {
|
|
|
checking_favorites: bool,
|
|
|
backups_enabled: bool,
|
|
|
backup_count: u32,
|
|
|
+ no_color: bool,
|
|
|
+ no_unicode: bool,
|
|
|
}
|
|
|
|
|
|
#[derive(Debug, Clone, Default)]
|
|
|
@@ -299,9 +301,61 @@ impl App {
|
|
|
checking_favorites: false,
|
|
|
backups_enabled: config.settings.backups,
|
|
|
backup_count: config.settings.backup_count,
|
|
|
+ no_color: args.no_color,
|
|
|
+ no_unicode: args.no_unicode,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// style with fg color, or plain style if no_color is on
|
|
|
+ fn fg(&self, color: Color) -> Style {
|
|
|
+ if self.no_color {
|
|
|
+ Style::default()
|
|
|
+ } else {
|
|
|
+ Style::default().fg(color)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// style with fg color + bold
|
|
|
+ fn fg_bold(&self, color: Color) -> Style {
|
|
|
+ if self.no_color {
|
|
|
+ Style::default().add_modifier(Modifier::BOLD)
|
|
|
+ } else {
|
|
|
+ Style::default().fg(color).add_modifier(Modifier::BOLD)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// resolve a color: returns Color::Reset when no_color is on
|
|
|
+ /// use this when chaining .bg() or .fg() on existing styles
|
|
|
+ fn c(&self, color: Color) -> Color {
|
|
|
+ if self.no_color { Color::Reset } else { color }
|
|
|
+ }
|
|
|
+
|
|
|
+ // unicode symbol helpers
|
|
|
+ fn sym_check(&self) -> &'static str {
|
|
|
+ if self.no_unicode { "+" } else { "\u{2713}" }
|
|
|
+ }
|
|
|
+ fn sym_cross(&self) -> &'static str {
|
|
|
+ if self.no_unicode { "x" } else { "\u{2717}" }
|
|
|
+ }
|
|
|
+ fn sym_sep(&self) -> &'static str {
|
|
|
+ if self.no_unicode { "|" } else { "\u{2502}" }
|
|
|
+ }
|
|
|
+ fn sym_bar_filled(&self) -> &'static str {
|
|
|
+ if self.no_unicode { "#" } else { "\u{2588}" }
|
|
|
+ }
|
|
|
+ fn sym_bar_empty(&self) -> &'static str {
|
|
|
+ if self.no_unicode { "-" } else { "\u{2591}" }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// preconfigured Block with ASCII or unicode borders
|
|
|
+ fn block(&self) -> Block<'static> {
|
|
|
+ let mut b = Block::default().borders(Borders::ALL);
|
|
|
+ if self.no_unicode {
|
|
|
+ b = b.border_type(BorderType::Plain);
|
|
|
+ }
|
|
|
+ b
|
|
|
+ }
|
|
|
+
|
|
|
fn get_effective_tlds(&self) -> Vec<&'static str> {
|
|
|
let mut tld_vec = self.base_tlds_for_selection();
|
|
|
|
|
|
@@ -1844,12 +1898,13 @@ fn start_search(app: &mut App) {
|
|
|
app.stream_rx = Some(stream.receiver);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
fn draw_ui(f: &mut Frame, app: &mut App) {
|
|
|
let size = f.area();
|
|
|
|
|
|
if terminal_too_small(size) {
|
|
|
app.panel_rects = PanelRects::default();
|
|
|
- draw_terminal_too_small(f, size);
|
|
|
+ draw_terminal_too_small(f, app, size);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -1978,7 +2033,7 @@ fn draw_ui(f: &mut Frame, app: &mut App) {
|
|
|
app.panel_rects.search = Some(main_chunks[2]);
|
|
|
|
|
|
// draw each panel
|
|
|
- draw_topbar(f, main_chunks[0]);
|
|
|
+ draw_topbar(f, app, main_chunks[0]);
|
|
|
if let Some(scratchpad_rect) = scratchpad_chunk {
|
|
|
draw_scratchpad(f, app, scratchpad_rect);
|
|
|
}
|
|
|
@@ -2005,10 +2060,9 @@ fn terminal_too_small(area: Rect) -> bool {
|
|
|
area.width < MIN_UI_WIDTH || area.height < MIN_UI_HEIGHT
|
|
|
}
|
|
|
|
|
|
-fn draw_terminal_too_small(f: &mut Frame, area: Rect) {
|
|
|
- let block = Block::default()
|
|
|
- .borders(Borders::ALL)
|
|
|
- .border_style(Style::default().fg(Color::Red))
|
|
|
+fn draw_terminal_too_small(f: &mut Frame, app: &App, area: Rect) {
|
|
|
+ let block = app.block()
|
|
|
+ .border_style(app.fg(Color::Red))
|
|
|
.title(" hoardom ");
|
|
|
|
|
|
let inner = block.inner(area);
|
|
|
@@ -2018,54 +2072,46 @@ fn draw_terminal_too_small(f: &mut Frame, area: Rect) {
|
|
|
let text = vec![
|
|
|
Line::from(Span::styled(
|
|
|
fit_cell_center("HELP ! HELP ! HELP !", content_width),
|
|
|
- Style::default()
|
|
|
- .fg(Color::White)
|
|
|
- .add_modifier(Modifier::BOLD),
|
|
|
+ app.fg_bold(Color::White),
|
|
|
)),
|
|
|
Line::from(Span::styled(
|
|
|
fit_cell_center("I AM BEING CRUSHED!", content_width),
|
|
|
- Style::default()
|
|
|
- .fg(Color::White)
|
|
|
- .add_modifier(Modifier::BOLD),
|
|
|
+ app.fg_bold(Color::White),
|
|
|
)),
|
|
|
Line::from(fit_cell_center("", content_width)),
|
|
|
Line::from(Span::styled(
|
|
|
fit_cell_center("Im claustrophobic! :'(", content_width),
|
|
|
- Style::default().fg(Color::White),
|
|
|
+ app.fg(Color::White),
|
|
|
)),
|
|
|
Line::from(Span::styled(
|
|
|
fit_cell_center(
|
|
|
&format!("Need {}x{} of space", MIN_UI_WIDTH, MIN_UI_HEIGHT),
|
|
|
content_width,
|
|
|
),
|
|
|
- Style::default().fg(Color::White),
|
|
|
+ app.fg(Color::White),
|
|
|
)),
|
|
|
Line::from(Span::styled(
|
|
|
fit_cell_center(
|
|
|
&format!("Current: {}x{}", area.width, area.height),
|
|
|
content_width,
|
|
|
),
|
|
|
- Style::default().fg(Color::DarkGray),
|
|
|
+ app.fg(Color::DarkGray),
|
|
|
)),
|
|
|
Line::from(fit_cell_center("", content_width)),
|
|
|
Line::from(Span::styled(
|
|
|
fit_cell_center("REFUSING TO WORK TILL YOU", content_width),
|
|
|
- Style::default()
|
|
|
- .fg(Color::White)
|
|
|
- .add_modifier(Modifier::BOLD),
|
|
|
+ app.fg_bold(Color::White),
|
|
|
)),
|
|
|
Line::from(Span::styled(
|
|
|
fit_cell_center("GIVE ME BACK MY SPACE! >:(", content_width),
|
|
|
- Style::default()
|
|
|
- .fg(Color::White)
|
|
|
- .add_modifier(Modifier::BOLD),
|
|
|
+ app.fg_bold(Color::White),
|
|
|
)),
|
|
|
];
|
|
|
|
|
|
f.render_widget(Paragraph::new(text), inner);
|
|
|
}
|
|
|
|
|
|
-fn draw_topbar(f: &mut Frame, area: Rect) {
|
|
|
+fn draw_topbar(f: &mut Frame, app: &App, area: Rect) {
|
|
|
let title = format!("{} - {}", APP_NAME, APP_DESC);
|
|
|
let width = area.width as usize;
|
|
|
let left = format!("{} {}", CLOSE_BUTTON_LABEL, title);
|
|
|
@@ -2074,46 +2120,31 @@ fn draw_topbar(f: &mut Frame, area: Rect) {
|
|
|
let paragraph = Paragraph::new(Line::from(vec![
|
|
|
Span::styled(
|
|
|
CLOSE_BUTTON_LABEL,
|
|
|
- Style::default()
|
|
|
- .fg(Color::Red)
|
|
|
- .bg(Color::Gray)
|
|
|
- .add_modifier(Modifier::BOLD),
|
|
|
+ app.fg_bold(Color::Red).bg(app.c(Color::Gray)),
|
|
|
),
|
|
|
Span::styled(
|
|
|
format!(" {}", title),
|
|
|
- Style::default()
|
|
|
- .fg(Color::White)
|
|
|
- .bg(Color::Red)
|
|
|
- .add_modifier(Modifier::BOLD),
|
|
|
+ app.fg_bold(Color::White).bg(app.c(Color::Red)),
|
|
|
),
|
|
|
Span::styled(
|
|
|
" ".repeat(gap),
|
|
|
- Style::default().bg(Color::Red).add_modifier(Modifier::BOLD),
|
|
|
+ Style::default().bg(app.c(Color::Red)).add_modifier(Modifier::BOLD),
|
|
|
),
|
|
|
Span::styled(
|
|
|
EXPORT_BUTTON_LABEL,
|
|
|
- Style::default()
|
|
|
- .fg(Color::LightGreen)
|
|
|
- .bg(Color::Red)
|
|
|
- .add_modifier(Modifier::BOLD),
|
|
|
+ app.fg_bold(Color::LightGreen).bg(app.c(Color::Red)),
|
|
|
),
|
|
|
Span::styled(
|
|
|
" ",
|
|
|
- Style::default().bg(Color::Red).add_modifier(Modifier::BOLD),
|
|
|
+ Style::default().bg(app.c(Color::Red)).add_modifier(Modifier::BOLD),
|
|
|
),
|
|
|
Span::styled(
|
|
|
HELP_BUTTON_LABEL,
|
|
|
- Style::default()
|
|
|
- .fg(Color::LightGreen)
|
|
|
- .bg(Color::Red)
|
|
|
- .add_modifier(Modifier::BOLD),
|
|
|
+ app.fg_bold(Color::LightGreen).bg(app.c(Color::Red)),
|
|
|
),
|
|
|
]))
|
|
|
.style(
|
|
|
- Style::default()
|
|
|
- .fg(Color::White)
|
|
|
- .bg(Color::Red)
|
|
|
- .add_modifier(Modifier::BOLD),
|
|
|
+ app.fg_bold(Color::White).bg(app.c(Color::Red)),
|
|
|
);
|
|
|
f.render_widget(paragraph, area);
|
|
|
}
|
|
|
@@ -2124,67 +2155,66 @@ fn draw_help_overlay(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
app.panel_rects.help_popup = Some(popup);
|
|
|
|
|
|
let text = vec![
|
|
|
- Line::from(Span::styled(" ", Style::default().fg(Color::White))),
|
|
|
- Line::from(Span::styled("Global :", Style::default().fg(Color::White))),
|
|
|
+ Line::from(Span::styled(" ", app.fg(Color::White))),
|
|
|
+ Line::from(Span::styled("Global :", app.fg(Color::White))),
|
|
|
Line::from(Span::styled(
|
|
|
"F1 or Help button Toggle this help",
|
|
|
- Style::default().fg(Color::White),
|
|
|
+ app.fg(Color::White),
|
|
|
)),
|
|
|
Line::from(Span::styled(
|
|
|
"F2 or Export button Open export popup",
|
|
|
- Style::default().fg(Color::White),
|
|
|
+ app.fg(Color::White),
|
|
|
)),
|
|
|
Line::from(Span::styled(
|
|
|
"Ctrl+C Quit the app",
|
|
|
- Style::default().fg(Color::White),
|
|
|
+ app.fg(Color::White),
|
|
|
)),
|
|
|
Line::from(Span::styled(
|
|
|
"s Stop/cancel running search",
|
|
|
- Style::default().fg(Color::White),
|
|
|
+ app.fg(Color::White),
|
|
|
)),
|
|
|
Line::from(Span::styled(
|
|
|
"Esc Clear selection or close help",
|
|
|
- Style::default().fg(Color::White),
|
|
|
+ app.fg(Color::White),
|
|
|
)),
|
|
|
Line::from(Span::styled(
|
|
|
"Tab or Shift+Tab Move between panels",
|
|
|
- Style::default().fg(Color::White),
|
|
|
+ app.fg(Color::White),
|
|
|
)),
|
|
|
Line::from(Span::styled(
|
|
|
"Up and Down arrows Navigate results",
|
|
|
- Style::default().fg(Color::White),
|
|
|
+ app.fg(Color::White),
|
|
|
)),
|
|
|
- Line::from(Span::styled(" ", Style::default().fg(Color::White))),
|
|
|
+ Line::from(Span::styled(" ", app.fg(Color::White))),
|
|
|
Line::from(Span::styled(
|
|
|
"Mouse Click Elements duh",
|
|
|
- Style::default().fg(Color::White),
|
|
|
+ app.fg(Color::White),
|
|
|
)),
|
|
|
Line::from(Span::styled(
|
|
|
"Scrolling Scroll through elements (yea)",
|
|
|
- Style::default().fg(Color::White),
|
|
|
+ app.fg(Color::White),
|
|
|
)),
|
|
|
- Line::from(Span::styled(" ", Style::default().fg(Color::White))),
|
|
|
+ Line::from(Span::styled(" ", app.fg(Color::White))),
|
|
|
Line::from(Span::styled(
|
|
|
"In Results :",
|
|
|
- Style::default().fg(Color::White),
|
|
|
+ app.fg(Color::White),
|
|
|
)),
|
|
|
Line::from(Span::styled(
|
|
|
"Enter Add highlighted result to Favorites",
|
|
|
- Style::default().fg(Color::White),
|
|
|
+ app.fg(Color::White),
|
|
|
)),
|
|
|
Line::from(Span::styled(
|
|
|
"In Favorites :",
|
|
|
- Style::default().fg(Color::White),
|
|
|
+ app.fg(Color::White),
|
|
|
)),
|
|
|
Line::from(Span::styled(
|
|
|
"Backspace or Delete Remove focused favorite",
|
|
|
- Style::default().fg(Color::White),
|
|
|
+ app.fg(Color::White),
|
|
|
)),
|
|
|
];
|
|
|
|
|
|
- let block = Block::default()
|
|
|
- .borders(Borders::ALL)
|
|
|
- .border_style(Style::default().fg(Color::Red))
|
|
|
+ let block = app.block()
|
|
|
+ .border_style(app.fg(Color::Red))
|
|
|
.title(" Help ");
|
|
|
|
|
|
f.render_widget(Clear, popup);
|
|
|
@@ -2199,9 +2229,8 @@ fn draw_export_popup(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
let popup = export_popup_rect(area);
|
|
|
app.panel_rects.export_popup = Some(popup);
|
|
|
|
|
|
- let block = Block::default()
|
|
|
- .borders(Borders::ALL)
|
|
|
- .border_style(Style::default().fg(Color::Red))
|
|
|
+ let block = app.block()
|
|
|
+ .border_style(app.fg(Color::Red))
|
|
|
.title(" Export ");
|
|
|
|
|
|
let inner = block.inner(popup);
|
|
|
@@ -2220,8 +2249,9 @@ fn draw_export_popup(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
])
|
|
|
.split(inner);
|
|
|
|
|
|
+ let white_style = app.fg(Color::White);
|
|
|
let mode_style = |mode: ExportMode| {
|
|
|
- let mut style = Style::default().fg(Color::White);
|
|
|
+ let mut style = white_style;
|
|
|
if popup_state.mode == mode {
|
|
|
style = style.add_modifier(Modifier::REVERSED | Modifier::BOLD);
|
|
|
} else if popup_state.selected_row == 0 {
|
|
|
@@ -2235,7 +2265,7 @@ fn draw_export_popup(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
chunks[0].width as usize,
|
|
|
);
|
|
|
f.render_widget(
|
|
|
- Paragraph::new(subtitle).style(Style::default().fg(Color::DarkGray)),
|
|
|
+ Paragraph::new(subtitle).style(app.fg(Color::DarkGray)),
|
|
|
chunks[0],
|
|
|
);
|
|
|
|
|
|
@@ -2268,34 +2298,29 @@ fn draw_export_popup(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
]);
|
|
|
f.render_widget(Paragraph::new(mode_line), chunks[1]);
|
|
|
|
|
|
- let path_block = Block::default()
|
|
|
- .borders(Borders::ALL)
|
|
|
+ let path_block = app.block()
|
|
|
.border_style(if popup_state.selected_row == 1 {
|
|
|
- Style::default().fg(Color::Red)
|
|
|
+ app.fg(Color::Red)
|
|
|
} else {
|
|
|
- Style::default().fg(Color::DarkGray)
|
|
|
+ app.fg(Color::DarkGray)
|
|
|
})
|
|
|
.title(" Save to ");
|
|
|
let path_inner = path_block.inner(chunks[2]);
|
|
|
app.panel_rects.export_path = Some(chunks[2]);
|
|
|
f.render_widget(path_block, chunks[2]);
|
|
|
f.render_widget(
|
|
|
- Paragraph::new(popup_state.path.as_str()).style(Style::default().fg(Color::White)),
|
|
|
+ Paragraph::new(popup_state.path.as_str()).style(app.fg(Color::White)),
|
|
|
path_inner,
|
|
|
);
|
|
|
|
|
|
let status_style = if popup_state.status_success {
|
|
|
- Style::default()
|
|
|
- .fg(Color::Green)
|
|
|
- .add_modifier(Modifier::BOLD)
|
|
|
+ app.fg_bold(Color::Green)
|
|
|
} else if popup_state.confirm_overwrite {
|
|
|
- Style::default()
|
|
|
- .fg(Color::Yellow)
|
|
|
- .add_modifier(Modifier::BOLD)
|
|
|
+ app.fg_bold(Color::Yellow)
|
|
|
} else if popup_state.status.is_some() {
|
|
|
- Style::default().fg(Color::Red)
|
|
|
+ app.fg(Color::Red)
|
|
|
} else {
|
|
|
- Style::default().fg(Color::DarkGray)
|
|
|
+ app.fg(Color::DarkGray)
|
|
|
};
|
|
|
let status_text = popup_state.status.as_deref().unwrap_or(" ");
|
|
|
f.render_widget(
|
|
|
@@ -2328,28 +2353,18 @@ fn draw_export_popup(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
Span::styled(
|
|
|
cancel_label,
|
|
|
if popup_state.selected_row == 2 {
|
|
|
- Style::default()
|
|
|
- .fg(Color::Green)
|
|
|
- .bg(Color::DarkGray)
|
|
|
- .add_modifier(Modifier::BOLD)
|
|
|
+ app.fg_bold(Color::Green).bg(app.c(Color::DarkGray))
|
|
|
} else {
|
|
|
- Style::default()
|
|
|
- .fg(Color::Green)
|
|
|
- .add_modifier(Modifier::BOLD)
|
|
|
+ app.fg_bold(Color::Green)
|
|
|
},
|
|
|
),
|
|
|
Span::raw(button_gap),
|
|
|
Span::styled(
|
|
|
save_label,
|
|
|
if popup_state.selected_row == 3 {
|
|
|
- Style::default()
|
|
|
- .fg(Color::Green)
|
|
|
- .bg(Color::DarkGray)
|
|
|
- .add_modifier(Modifier::BOLD)
|
|
|
+ app.fg_bold(Color::Green).bg(app.c(Color::DarkGray))
|
|
|
} else {
|
|
|
- Style::default()
|
|
|
- .fg(Color::Green)
|
|
|
- .add_modifier(Modifier::BOLD)
|
|
|
+ app.fg_bold(Color::Green)
|
|
|
},
|
|
|
),
|
|
|
]);
|
|
|
@@ -2366,9 +2381,9 @@ fn draw_export_popup(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
fn draw_results(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
let focused = app.focus == Focus::Results;
|
|
|
let border_style = if focused {
|
|
|
- Style::default().fg(Color::Red)
|
|
|
+ app.fg(Color::Red)
|
|
|
} else {
|
|
|
- Style::default().fg(Color::DarkGray)
|
|
|
+ app.fg(Color::DarkGray)
|
|
|
};
|
|
|
|
|
|
// show progress in title when searching
|
|
|
@@ -2395,8 +2410,7 @@ fn draw_results(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
)
|
|
|
};
|
|
|
|
|
|
- let block = Block::default()
|
|
|
- .borders(Borders::ALL)
|
|
|
+ let block = app.block()
|
|
|
.border_style(border_style)
|
|
|
.title(title);
|
|
|
|
|
|
@@ -2415,12 +2429,12 @@ fn draw_results(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
let (cur, tot) = app.search_progress;
|
|
|
let pct = (cur as f64 / tot as f64 * 100.0) as u16;
|
|
|
let filled = (chunks[0].width as u32 * cur as u32 / tot as u32) as u16;
|
|
|
- let bar: String = "\u{2588}".repeat(filled as usize)
|
|
|
- + &"\u{2591}".repeat((chunks[0].width.saturating_sub(filled)) as usize);
|
|
|
+ let bar: String = app.sym_bar_filled().repeat(filled as usize)
|
|
|
+ + &app.sym_bar_empty().repeat((chunks[0].width.saturating_sub(filled)) as usize);
|
|
|
let bar_text = format!(" {}% ", pct);
|
|
|
let gauge_line = Line::from(vec![
|
|
|
- Span::styled(bar, Style::default().fg(Color::Red)),
|
|
|
- Span::styled(bar_text, Style::default().fg(Color::DarkGray)),
|
|
|
+ Span::styled(bar, app.fg(Color::Red)),
|
|
|
+ Span::styled(bar_text, app.fg(Color::DarkGray)),
|
|
|
]);
|
|
|
f.render_widget(Paragraph::new(gauge_line), chunks[0]);
|
|
|
|
|
|
@@ -2437,6 +2451,7 @@ fn draw_results_list(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
let show_note_column = app.show_unavailable;
|
|
|
let selected_idx = app.results_state.selected();
|
|
|
let selected_bg = Color::Black;
|
|
|
+ let sep = format!(" {} ", app.sym_sep());
|
|
|
|
|
|
// collect visible results
|
|
|
let visible_data: Vec<(String, String, String, DomainStatus)> = if app.show_unavailable {
|
|
|
@@ -2472,7 +2487,7 @@ fn draw_results_list(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
} else {
|
|
|
"No available domains found"
|
|
|
};
|
|
|
- let p = Paragraph::new(msg).style(Style::default().fg(Color::DarkGray));
|
|
|
+ let p = Paragraph::new(msg).style(app.fg(Color::DarkGray));
|
|
|
f.render_widget(p, area);
|
|
|
return;
|
|
|
}
|
|
|
@@ -2519,35 +2534,27 @@ fn draw_results_list(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
let mut header_spans = vec![
|
|
|
Span::styled(
|
|
|
format!(" {}", fit_cell("Domain", domain_w)),
|
|
|
- Style::default()
|
|
|
- .fg(Color::Gray)
|
|
|
- .add_modifier(Modifier::BOLD),
|
|
|
+ app.fg_bold(Color::Gray),
|
|
|
),
|
|
|
- Span::styled(" │ ", Style::default().fg(Color::DarkGray)),
|
|
|
+ Span::styled(sep.clone(), app.fg(Color::DarkGray)),
|
|
|
Span::styled(
|
|
|
fit_cell("Status", status_w),
|
|
|
- Style::default()
|
|
|
- .fg(Color::Gray)
|
|
|
- .add_modifier(Modifier::BOLD),
|
|
|
+ app.fg_bold(Color::Gray),
|
|
|
),
|
|
|
];
|
|
|
|
|
|
if show_note_column {
|
|
|
- header_spans.push(Span::styled(" │ ", Style::default().fg(Color::DarkGray)));
|
|
|
+ header_spans.push(Span::styled(sep.clone(), app.fg(Color::DarkGray)));
|
|
|
header_spans.push(Span::styled(
|
|
|
fit_cell("Details", note_w),
|
|
|
- Style::default()
|
|
|
- .fg(Color::Gray)
|
|
|
- .add_modifier(Modifier::BOLD),
|
|
|
+ app.fg_bold(Color::Gray),
|
|
|
));
|
|
|
}
|
|
|
|
|
|
- header_spans.push(Span::styled(" │ ", Style::default().fg(Color::DarkGray)));
|
|
|
+ header_spans.push(Span::styled(sep.clone(), app.fg(Color::DarkGray)));
|
|
|
header_spans.push(Span::styled(
|
|
|
- " ✓ ",
|
|
|
- Style::default()
|
|
|
- .fg(Color::Gray)
|
|
|
- .add_modifier(Modifier::BOLD),
|
|
|
+ format!(" {} ", app.sym_check()),
|
|
|
+ app.fg_bold(Color::Gray),
|
|
|
));
|
|
|
|
|
|
f.render_widget(Paragraph::new(Line::from(header_spans)), header_area);
|
|
|
@@ -2561,20 +2568,20 @@ fn draw_results_list(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
let selection_bg = if is_selected { Some(selected_bg) } else { None };
|
|
|
|
|
|
let status_style = match status {
|
|
|
- DomainStatus::Available => Style::default().fg(Color::Green),
|
|
|
- DomainStatus::Registered { .. } => Style::default().fg(Color::Red),
|
|
|
+ DomainStatus::Available => app.fg(Color::Green),
|
|
|
+ DomainStatus::Registered { .. } => app.fg(Color::Red),
|
|
|
DomainStatus::Error { kind, .. } => match kind {
|
|
|
- ErrorKind::InvalidTld => Style::default().fg(Color::Yellow),
|
|
|
- _ => Style::default().fg(Color::Blue),
|
|
|
+ ErrorKind::InvalidTld => app.fg(Color::Yellow),
|
|
|
+ _ => app.fg(Color::Blue),
|
|
|
},
|
|
|
};
|
|
|
|
|
|
let domain_style = match status {
|
|
|
- DomainStatus::Available => Style::default().fg(Color::Green),
|
|
|
- DomainStatus::Registered { .. } => Style::default().fg(Color::Red),
|
|
|
+ DomainStatus::Available => app.fg(Color::Green),
|
|
|
+ DomainStatus::Registered { .. } => app.fg(Color::Red),
|
|
|
DomainStatus::Error { kind, .. } => match kind {
|
|
|
- ErrorKind::InvalidTld => Style::default().fg(Color::Yellow),
|
|
|
- _ => Style::default().fg(Color::Blue),
|
|
|
+ ErrorKind::InvalidTld => app.fg(Color::Yellow),
|
|
|
+ _ => app.fg(Color::Blue),
|
|
|
},
|
|
|
};
|
|
|
|
|
|
@@ -2591,37 +2598,37 @@ fn draw_results_list(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
format!(" {}", fit_cell(full, domain_w)),
|
|
|
apply_bg(domain_style),
|
|
|
),
|
|
|
- Span::styled(" \u{2502} ", apply_bg(Style::default().fg(Color::Gray))),
|
|
|
+ Span::styled(sep.clone(), apply_bg(app.fg(Color::Gray))),
|
|
|
Span::styled(fit_cell(status_str, status_w), apply_bg(status_style)),
|
|
|
];
|
|
|
|
|
|
if show_note_column {
|
|
|
spans.push(Span::styled(
|
|
|
- " \u{2502} ",
|
|
|
- apply_bg(Style::default().fg(Color::Gray)),
|
|
|
+ sep.clone(),
|
|
|
+ apply_bg(app.fg(Color::Gray)),
|
|
|
));
|
|
|
spans.push(Span::styled(
|
|
|
fit_cell(note, note_w),
|
|
|
- apply_bg(Style::default().fg(Color::White)),
|
|
|
+ apply_bg(app.fg(Color::White)),
|
|
|
));
|
|
|
}
|
|
|
|
|
|
spans.push(Span::styled(
|
|
|
- " \u{2502} ",
|
|
|
- apply_bg(Style::default().fg(Color::Gray)),
|
|
|
+ sep.clone(),
|
|
|
+ apply_bg(app.fg(Color::Gray)),
|
|
|
));
|
|
|
spans.push(match status {
|
|
|
DomainStatus::Available => {
|
|
|
- Span::styled(" ✓ ", apply_bg(Style::default().fg(Color::Green)))
|
|
|
+ Span::styled(format!(" {} ", app.sym_check()), apply_bg(app.fg(Color::Green)))
|
|
|
}
|
|
|
DomainStatus::Registered { .. } => {
|
|
|
- Span::styled(" ✗ ", apply_bg(Style::default().fg(Color::Red)))
|
|
|
+ Span::styled(format!(" {} ", app.sym_cross()), apply_bg(app.fg(Color::Red)))
|
|
|
}
|
|
|
DomainStatus::Error { kind, .. } => match kind {
|
|
|
ErrorKind::InvalidTld => {
|
|
|
- Span::styled(" ? ", apply_bg(Style::default().fg(Color::Yellow)))
|
|
|
+ Span::styled(" ? ", apply_bg(app.fg(Color::Yellow)))
|
|
|
}
|
|
|
- _ => Span::styled(" ! ", apply_bg(Style::default().fg(Color::Blue))),
|
|
|
+ _ => Span::styled(" ! ", apply_bg(app.fg(Color::Blue))),
|
|
|
},
|
|
|
});
|
|
|
|
|
|
@@ -2778,13 +2785,12 @@ fn move_scratchpad_cursor_vertical(app: &mut App, line_delta: i16) {
|
|
|
fn draw_scratchpad(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
let focused = app.focus == Focus::Scratchpad;
|
|
|
let border_style = if focused {
|
|
|
- Style::default().fg(Color::Red)
|
|
|
+ app.fg(Color::Red)
|
|
|
} else {
|
|
|
- Style::default().fg(Color::DarkGray)
|
|
|
+ app.fg(Color::DarkGray)
|
|
|
};
|
|
|
|
|
|
- let block = Block::default()
|
|
|
- .borders(Borders::ALL)
|
|
|
+ let block = app.block()
|
|
|
.border_style(border_style)
|
|
|
.title(" Scratchpad ");
|
|
|
|
|
|
@@ -2797,7 +2803,7 @@ fn draw_scratchpad(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
};
|
|
|
f.render_widget(block, area);
|
|
|
f.render_widget(
|
|
|
- Paragraph::new(text).style(Style::default().fg(Color::White)),
|
|
|
+ Paragraph::new(text).style(app.fg(Color::White)),
|
|
|
inner,
|
|
|
);
|
|
|
|
|
|
@@ -2812,9 +2818,9 @@ fn draw_scratchpad(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
fn draw_favorites(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
let focused = app.focus == Focus::Favorites;
|
|
|
let border_style = if focused {
|
|
|
- Style::default().fg(Color::Red)
|
|
|
+ app.fg(Color::Red)
|
|
|
} else {
|
|
|
- Style::default().fg(Color::DarkGray)
|
|
|
+ app.fg(Color::DarkGray)
|
|
|
};
|
|
|
|
|
|
let title = if app.checking_favorites {
|
|
|
@@ -2823,8 +2829,7 @@ fn draw_favorites(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
" Favorites "
|
|
|
};
|
|
|
|
|
|
- let block = Block::default()
|
|
|
- .borders(Borders::ALL)
|
|
|
+ let block = app.block()
|
|
|
.border_style(border_style)
|
|
|
.title(title);
|
|
|
|
|
|
@@ -2857,10 +2862,10 @@ fn draw_favorites(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
};
|
|
|
let mut spans = vec![Span::styled(
|
|
|
fav.domain.as_str(),
|
|
|
- Style::default().fg(status_color),
|
|
|
+ app.fg(status_color),
|
|
|
)];
|
|
|
if fav.changed {
|
|
|
- spans.push(Span::styled(" !", Style::default().fg(Color::Yellow)));
|
|
|
+ spans.push(Span::styled(" !", app.fg(Color::Yellow)));
|
|
|
}
|
|
|
ListItem::new(Line::from(spans))
|
|
|
})
|
|
|
@@ -2878,9 +2883,9 @@ fn draw_favorites(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
"[c]heck all"
|
|
|
};
|
|
|
let btn_style = if app.checking_favorites {
|
|
|
- Style::default().fg(Color::DarkGray)
|
|
|
+ app.fg(Color::DarkGray)
|
|
|
} else {
|
|
|
- Style::default().fg(Color::Green)
|
|
|
+ app.fg(Color::Green)
|
|
|
};
|
|
|
f.render_widget(
|
|
|
Paragraph::new(Line::from(Span::styled(btn_label, btn_style)))
|
|
|
@@ -2892,13 +2897,12 @@ fn draw_favorites(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
fn draw_settings(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
let focused = app.focus == Focus::Settings;
|
|
|
let border_style = if focused {
|
|
|
- Style::default().fg(Color::Red)
|
|
|
+ app.fg(Color::Red)
|
|
|
} else {
|
|
|
- Style::default().fg(Color::DarkGray)
|
|
|
+ app.fg(Color::DarkGray)
|
|
|
};
|
|
|
|
|
|
- let block = Block::default()
|
|
|
- .borders(Borders::ALL)
|
|
|
+ let block = app.block()
|
|
|
.border_style(border_style)
|
|
|
.title(" Settings ");
|
|
|
|
|
|
@@ -2910,9 +2914,9 @@ fn draw_settings(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
let selected = if focused { app.settings_selected } else { None };
|
|
|
let checkbox_style = |row: usize, checked: bool| {
|
|
|
let style = if checked {
|
|
|
- Style::default().fg(Color::Green)
|
|
|
+ app.fg(Color::Green)
|
|
|
} else {
|
|
|
- Style::default().fg(Color::DarkGray)
|
|
|
+ app.fg(Color::DarkGray)
|
|
|
};
|
|
|
|
|
|
if selected == Some(row) {
|
|
|
@@ -2926,13 +2930,13 @@ fn draw_settings(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
if selected == Some(row) {
|
|
|
Style::default().add_modifier(Modifier::REVERSED)
|
|
|
} else {
|
|
|
- Style::default().fg(Color::White)
|
|
|
+ app.fg(Color::White)
|
|
|
}
|
|
|
};
|
|
|
|
|
|
let tld_row_style = if selected == Some(0) {
|
|
|
Style::default()
|
|
|
- .bg(Color::DarkGray)
|
|
|
+ .bg(app.c(Color::DarkGray))
|
|
|
.add_modifier(Modifier::BOLD)
|
|
|
} else {
|
|
|
Style::default()
|
|
|
@@ -2940,7 +2944,7 @@ fn draw_settings(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
|
|
|
let jobs_row_style = if selected == Some(4) {
|
|
|
Style::default()
|
|
|
- .bg(Color::DarkGray)
|
|
|
+ .bg(app.c(Color::DarkGray))
|
|
|
.add_modifier(Modifier::BOLD)
|
|
|
} else {
|
|
|
Style::default()
|
|
|
@@ -2949,10 +2953,10 @@ fn draw_settings(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
let text = vec![
|
|
|
Line::from(vec![
|
|
|
Span::raw(" "),
|
|
|
- Span::styled("TLD List: [", tld_row_style.fg(Color::White)),
|
|
|
- Span::styled(app.tld_list_name.as_str(), tld_row_style.fg(Color::Cyan)),
|
|
|
- Span::styled("] ", tld_row_style.fg(Color::White)),
|
|
|
- Span::styled("V", tld_row_style.fg(Color::Green)),
|
|
|
+ Span::styled("TLD List: [", tld_row_style.fg(app.c(Color::White))),
|
|
|
+ Span::styled(app.tld_list_name.as_str(), tld_row_style.fg(app.c(Color::Cyan))),
|
|
|
+ Span::styled("] ", tld_row_style.fg(app.c(Color::White))),
|
|
|
+ Span::styled("V", tld_row_style.fg(app.c(Color::Green))),
|
|
|
]),
|
|
|
Line::from(vec![
|
|
|
Span::raw(" "),
|
|
|
@@ -2971,10 +2975,10 @@ fn draw_settings(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
]),
|
|
|
Line::from(vec![
|
|
|
Span::raw(" "),
|
|
|
- Span::styled("Jobs: [", jobs_row_style.fg(Color::White)),
|
|
|
- Span::styled(jobs_str, jobs_row_style.fg(Color::Cyan)),
|
|
|
- Span::styled("] ", jobs_row_style.fg(Color::White)),
|
|
|
- Span::styled("-/+", jobs_row_style.fg(Color::Green)),
|
|
|
+ Span::styled("Jobs: [", jobs_row_style.fg(app.c(Color::White))),
|
|
|
+ Span::styled(jobs_str, jobs_row_style.fg(app.c(Color::Cyan))),
|
|
|
+ Span::styled("] ", jobs_row_style.fg(app.c(Color::White))),
|
|
|
+ Span::styled("-/+", jobs_row_style.fg(app.c(Color::Green))),
|
|
|
]),
|
|
|
];
|
|
|
|
|
|
@@ -2985,9 +2989,9 @@ fn draw_settings(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
fn draw_search(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
let focused = app.focus == Focus::Search;
|
|
|
let border_style = if focused {
|
|
|
- Style::default().fg(Color::Red)
|
|
|
+ app.fg(Color::Red)
|
|
|
} else {
|
|
|
- Style::default().fg(Color::DarkGray)
|
|
|
+ app.fg(Color::DarkGray)
|
|
|
};
|
|
|
|
|
|
let title = match &app.status_msg {
|
|
|
@@ -2995,8 +2999,7 @@ fn draw_search(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
None => " Search (Enter to lookup) ".to_string(),
|
|
|
};
|
|
|
|
|
|
- let block = Block::default()
|
|
|
- .borders(Borders::ALL)
|
|
|
+ let block = app.block()
|
|
|
.border_style(border_style)
|
|
|
.title(title);
|
|
|
|
|
|
@@ -3041,32 +3044,23 @@ fn draw_search(f: &mut Frame, app: &mut App, area: Rect) {
|
|
|
|
|
|
let input_chunk = chunks[0];
|
|
|
let visible_input = fit_cell(&app.search_input, input_chunk.width as usize);
|
|
|
- let input = Paragraph::new(visible_input).style(Style::default().fg(Color::White));
|
|
|
+ let input = Paragraph::new(visible_input).style(app.fg(Color::White));
|
|
|
f.render_widget(input, input_chunk);
|
|
|
|
|
|
let search_enabled = !app.searching && !app.search_input.is_empty();
|
|
|
let cancel_enabled = app.searching;
|
|
|
|
|
|
let search_style = if search_enabled {
|
|
|
- Style::default()
|
|
|
- .fg(Color::Black)
|
|
|
- .bg(Color::Green)
|
|
|
- .add_modifier(Modifier::BOLD)
|
|
|
+ app.fg_bold(Color::Black).bg(app.c(Color::Green))
|
|
|
} else {
|
|
|
- Style::default().fg(Color::DarkGray).bg(Color::Black)
|
|
|
+ app.fg(Color::DarkGray).bg(app.c(Color::Black))
|
|
|
};
|
|
|
let stop_style = if cancel_enabled {
|
|
|
- Style::default()
|
|
|
- .fg(Color::Black)
|
|
|
- .bg(Color::Yellow)
|
|
|
- .add_modifier(Modifier::BOLD)
|
|
|
+ app.fg_bold(Color::Black).bg(app.c(Color::Yellow))
|
|
|
} else {
|
|
|
- Style::default().fg(Color::DarkGray).bg(Color::Black)
|
|
|
+ app.fg(Color::DarkGray).bg(app.c(Color::Black))
|
|
|
};
|
|
|
- let clear_style = Style::default()
|
|
|
- .fg(Color::White)
|
|
|
- .bg(Color::Red)
|
|
|
- .add_modifier(Modifier::BOLD);
|
|
|
+ let clear_style = app.fg_bold(Color::White).bg(app.c(Color::Red));
|
|
|
|
|
|
f.render_widget(
|
|
|
Paragraph::new(SEARCH_BUTTON_LABEL).style(search_style),
|
|
|
@@ -3121,22 +3115,18 @@ fn draw_dropdown(f: &mut Frame, app: &mut App, settings_area: Rect, selected: us
|
|
|
.map(|opt| {
|
|
|
ListItem::new(Line::from(Span::styled(
|
|
|
format!(" {} ", opt),
|
|
|
- Style::default().fg(Color::White),
|
|
|
+ app.fg(Color::White),
|
|
|
)))
|
|
|
})
|
|
|
.collect();
|
|
|
|
|
|
- let block = Block::default()
|
|
|
- .borders(Borders::ALL)
|
|
|
- .border_style(Style::default().fg(Color::Red))
|
|
|
+ let block = app.block()
|
|
|
+ .border_style(app.fg(Color::Red))
|
|
|
.title(" TLD List ");
|
|
|
|
|
|
f.render_widget(Clear, dropdown_full);
|
|
|
let list = List::new(items).block(block).highlight_style(
|
|
|
- Style::default()
|
|
|
- .fg(Color::White)
|
|
|
- .bg(Color::Red)
|
|
|
- .add_modifier(Modifier::BOLD),
|
|
|
+ app.fg_bold(Color::White).bg(app.c(Color::Red)),
|
|
|
);
|
|
|
let mut state = ListState::default();
|
|
|
state.select(Some(selected));
|