Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiapple852 committed Oct 4, 2024
1 parent 26ba624 commit 75384f7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
39 changes: 27 additions & 12 deletions crates/trippy-tui/src/frontend/render/bottom.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::borrow::Cow;
use std::net::IpAddr;
use ratatui::Frame;
use crate::config::AddressMode;
use crate::frontend::tui_app::TuiApp;
use crate::t;
use ratatui::layout::{Alignment, Rect};
use ratatui::prelude::{Color, Line, Modifier, Span, Style};
use ratatui::widgets::{Block, BorderType, Borders, Paragraph};
use ratatui::Frame;
use std::borrow::Cow;
use std::net::IpAddr;
use trippy_core::{PrivilegeMode, Protocol};
use trippy_dns::ResolveMethod;
use crate::config::AddressMode;
use crate::frontend::tui_app::TuiApp;
use crate::t;

pub fn render(f: &mut Frame<'_>, rect: Rect, app: &TuiApp) {
let footer_block = Block::default()
Expand Down Expand Up @@ -49,27 +49,42 @@ pub fn render(f: &mut Frame<'_>, rect: Rect, app: &TuiApp) {
ResolveMethod::System => Span::styled("asn", Style::default()),
ResolveMethod::Resolv | ResolveMethod::Google | ResolveMethod::Cloudflare => {
if app.tui_config.lookup_as_info {
Span::styled("asn", Style::default().fg(Color::Green).add_modifier(Modifier::BOLD))
Span::styled(
"asn",
Style::default()
.fg(Color::Green)
.add_modifier(Modifier::BOLD),
)
} else {
Span::styled("asn", Style::default())
}
}
};

let details = if app.show_hop_details {
Span::styled("detail", Style::default().fg(Color::Green).add_modifier(Modifier::BOLD))
Span::styled(
"detail",
Style::default()
.fg(Color::Green)
.add_modifier(Modifier::BOLD),
)
} else {
Span::styled("detail", Style::default())
};

// needs to be padded to length of translation of "auto".
let max_hosts = app
.tui_config
.max_addrs
.map_or_else(|| Span::raw(t!("auto")), |m| Span::raw(format!("{:4}", m)));

.map_or_else(|| Span::raw(t!("auto")), |m| Span::raw(format!("{m:4}")));

let privacy = if app.hide_private_hops && app.tui_config.privacy_max_ttl > 0 {
Span::styled("private", Style::default().fg(Color::Green).add_modifier(Modifier::BOLD))
Span::styled(
"private",
Style::default()
.fg(Color::Green)
.add_modifier(Modifier::BOLD),
)
} else {
Span::styled("private", Style::default())
};
Expand Down Expand Up @@ -126,4 +141,4 @@ const fn fmt_target_family(target: IpAddr) -> &'static str {
IpAddr::V4(_) => "v4",
IpAddr::V6(_) => "v6",
}
}
}
4 changes: 1 addition & 3 deletions crates/trippy-tui/src/frontend/render/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ use ratatui::style::{Modifier, Style};
use ratatui::text::{Line, Span};
use ratatui::widgets::{Block, BorderType, Borders, Paragraph};
use ratatui::Frame;
use std::borrow::Cow;
use std::net::IpAddr;
use std::time::Duration;
use trippy_core::{Hop, PortDirection, PrivilegeMode, Protocol};
use trippy_core::{Hop, PortDirection};
use trippy_dns::Resolver;

/// Render the title, config, target, clock and keyboard controls.
Expand Down

0 comments on commit 75384f7

Please sign in to comment.