Skip to content

Commit 58049ad

Browse files
committed
scxtop: Refactor network rendering into separate module (Phase 3)
Extract all network rendering logic (~687 lines) from app.rs into a new NetworkRenderer module in src/render/network.rs. This includes: - Full network view with interface table and traffic charts - Network summary for default view (top 5 interfaces) - Historical traffic visualization (bytes and packets) - Dual-axis mirrored charts (RX negative, TX positive) - Delta calculation for per-second rates - Comprehensive error handling and edge cases Add extensive test coverage with 13 tests covering: - Basic rendering, localization, themes - Edge cases: no interfaces, zero/high traffic, many interfaces - Small terminal compatibility - Multiple tick rates Signed-off-by: Daniel Hodges <[email protected]>
1 parent 7abe59b commit 58049ad

File tree

7 files changed

+1485
-829
lines changed

7 files changed

+1485
-829
lines changed

tools/scxtop/src/app.rs

Lines changed: 66 additions & 747 deletions
Large diffs are not rendered by default.

tools/scxtop/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub mod layered_util;
2020
mod llc_data;
2121
pub mod mangoapp;
2222
mod mem_stats;
23-
mod network_stats;
23+
pub mod network_stats;
2424
mod node_data;
2525
mod perfetto_trace;
2626
mod power_data;

tools/scxtop/src/render/memory.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ use anyhow::Result;
1414
use ratatui::layout::{Alignment, Constraint, Layout};
1515
use ratatui::symbols::line::THICK;
1616
use ratatui::text::{Line, Span};
17-
use ratatui::widgets::{
18-
Block, BorderType, Cell, LineGauge, Row, Table,
19-
};
20-
use ratatui::{Frame, layout::Rect};
17+
use ratatui::widgets::{Block, BorderType, Cell, LineGauge, Row, Table};
18+
use ratatui::{layout::Rect, Frame};
2119

2220
/// Renderer for memory views
2321
pub struct MemoryRenderer;
@@ -219,7 +217,9 @@ impl MemoryRenderer {
219217
Line::from(vec![
220218
Span::styled(
221219
&memory_key,
222-
theme.title_style().add_modifier(ratatui::style::Modifier::BOLD),
220+
theme
221+
.title_style()
222+
.add_modifier(ratatui::style::Modifier::BOLD),
223223
),
224224
Span::styled("emory Statistics", theme.text_color()),
225225
])

tools/scxtop/src/render/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
pub mod process;
88
// Memory rendering
99
pub mod memory;
10+
// Network rendering
11+
pub mod network;
1012

11-
pub use process::ProcessRenderer;
1213
pub use memory::MemoryRenderer;
14+
pub use network::NetworkRenderer;
15+
pub use process::ProcessRenderer;

0 commit comments

Comments
 (0)