mirror of
https://github.com/imsnif/bandwhich.git
synced 2026-02-09 01:59:18 +08:00
Rename ui_offset -> table_cycle_offset
This commit is contained in:
@@ -99,12 +99,15 @@ impl Layout<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render(&self, frame: &mut Frame, rect: Rect, ui_offset: usize) {
|
pub fn render(&self, frame: &mut Frame, rect: Rect, table_cycle_offset: usize) {
|
||||||
let (top, app, bottom) = top_app_and_bottom_split(rect);
|
let (top, app, bottom) = top_app_and_bottom_split(rect);
|
||||||
let layout_slots = self.build_layout(app);
|
let layout_slots = self.build_layout(app);
|
||||||
for i in 0..layout_slots.len() {
|
for i in 0..layout_slots.len() {
|
||||||
if let Some(rect) = layout_slots.get(i) {
|
if let Some(rect) = layout_slots.get(i) {
|
||||||
if let Some(child) = self.children.get((i + ui_offset) % self.children.len()) {
|
if let Some(child) = self
|
||||||
|
.children
|
||||||
|
.get((i + table_cycle_offset) % self.children.len())
|
||||||
|
{
|
||||||
child.render(frame, *rect);
|
child.render(frame, *rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ where
|
|||||||
write_to_stdout("");
|
write_to_stdout("");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw(&mut self, paused: bool, elapsed_time: Duration, ui_offset: usize) {
|
pub fn draw(&mut self, paused: bool, elapsed_time: Duration, table_cycle_offset: usize) {
|
||||||
let layout = Layout {
|
let layout = Layout {
|
||||||
header: HeaderDetails {
|
header: HeaderDetails {
|
||||||
state: &self.state,
|
state: &self.state,
|
||||||
@@ -141,7 +141,7 @@ where
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
self.terminal
|
self.terminal
|
||||||
.draw(|frame| layout.render(frame, frame.area(), ui_offset))
|
.draw(|frame| layout.render(frame, frame.area(), table_cycle_offset))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
14
src/main.rs
14
src/main.rs
@@ -93,7 +93,7 @@ where
|
|||||||
let paused = Arc::new(AtomicBool::new(false));
|
let paused = Arc::new(AtomicBool::new(false));
|
||||||
let last_start_time = Arc::new(RwLock::new(Instant::now()));
|
let last_start_time = Arc::new(RwLock::new(Instant::now()));
|
||||||
let cumulative_time = Arc::new(RwLock::new(Duration::new(0, 0)));
|
let cumulative_time = Arc::new(RwLock::new(Duration::new(0, 0)));
|
||||||
let ui_offset = Arc::new(AtomicUsize::new(0));
|
let table_cycle_offset = Arc::new(AtomicUsize::new(0));
|
||||||
|
|
||||||
let mut active_threads = vec![];
|
let mut active_threads = vec![];
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ where
|
|||||||
.spawn({
|
.spawn({
|
||||||
let running = running.clone();
|
let running = running.clone();
|
||||||
let paused = paused.clone();
|
let paused = paused.clone();
|
||||||
let ui_offset = ui_offset.clone();
|
let table_cycle_offset = table_cycle_offset.clone();
|
||||||
|
|
||||||
let network_utilization = network_utilization.clone();
|
let network_utilization = network_utilization.clone();
|
||||||
let last_start_time = last_start_time.clone();
|
let last_start_time = last_start_time.clone();
|
||||||
@@ -138,7 +138,7 @@ where
|
|||||||
{
|
{
|
||||||
let mut ui = ui.lock().unwrap();
|
let mut ui = ui.lock().unwrap();
|
||||||
let paused = paused.load(Ordering::SeqCst);
|
let paused = paused.load(Ordering::SeqCst);
|
||||||
let ui_offset = ui_offset.load(Ordering::SeqCst);
|
let table_cycle_offset = table_cycle_offset.load(Ordering::SeqCst);
|
||||||
if !paused {
|
if !paused {
|
||||||
ui.update_state(sockets_to_procs, utilization, ip_to_host);
|
ui.update_state(sockets_to_procs, utilization, ip_to_host);
|
||||||
}
|
}
|
||||||
@@ -151,7 +151,7 @@ where
|
|||||||
if raw_mode {
|
if raw_mode {
|
||||||
ui.output_text(&mut write_to_stdout);
|
ui.output_text(&mut write_to_stdout);
|
||||||
} else {
|
} else {
|
||||||
ui.draw(paused, elapsed_time, ui_offset);
|
ui.draw(paused, elapsed_time, table_cycle_offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let render_duration = render_start_time.elapsed();
|
let render_duration = render_start_time.elapsed();
|
||||||
@@ -187,7 +187,7 @@ where
|
|||||||
*cumulative_time.read().unwrap(),
|
*cumulative_time.read().unwrap(),
|
||||||
paused,
|
paused,
|
||||||
),
|
),
|
||||||
ui_offset.load(Ordering::SeqCst),
|
table_cycle_offset.load(Ordering::SeqCst),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Event::Key(KeyEvent {
|
Event::Key(KeyEvent {
|
||||||
@@ -248,8 +248,8 @@ where
|
|||||||
paused,
|
paused,
|
||||||
);
|
);
|
||||||
let table_count = ui.get_table_count();
|
let table_count = ui.get_table_count();
|
||||||
let new = ui_offset.load(Ordering::SeqCst) + 1 % table_count;
|
let new = table_cycle_offset.load(Ordering::SeqCst) + 1 % table_count;
|
||||||
ui_offset.store(new, Ordering::SeqCst);
|
table_cycle_offset.store(new, Ordering::SeqCst);
|
||||||
ui.draw(paused, elapsed_time, new);
|
ui.draw(paused, elapsed_time, new);
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
|
|||||||
Reference in New Issue
Block a user