Skip to content

Commit

Permalink
fix: scrolling in traffic tab when it's not visible
Browse files Browse the repository at this point in the history
  • Loading branch information
Chleba committed Oct 20, 2024
1 parent b351a56 commit 596753c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 23 deletions.
10 changes: 6 additions & 4 deletions src/components/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use pnet::packet::{
use pnet::util::MacAddr;

use core::str;
use ratatui::{prelude::*, widgets::*};
use ratatui::layout::Position;
use ratatui::{prelude::*, widgets::*};
use std::net::{IpAddr, Ipv4Addr};
use std::string;
use std::time::{Duration, Instant};
Expand All @@ -35,12 +35,12 @@ use crate::{
tui::Frame,
utils::{count_ipv4_net_length, get_ips4_from_cidr},
};
use crossterm::event::Event;
use crossterm::event::{KeyCode, KeyEvent};
use mac_oui::Oui;
use rand::random;
use tui_input::backend::crossterm::EventHandler;
use tui_input::Input;
use crossterm::event::Event;

static POOL_SIZE: usize = 32;
static INPUT_SIZE: usize = 30;
Expand Down Expand Up @@ -102,7 +102,7 @@ impl Discovery {

pub fn get_scanned_ips(&self) -> &Vec<ScannedIp> {
&self.scanned_ips
}
}

fn set_cidr(&mut self, cidr_str: String, scan: bool) {
match cidr_str.parse::<Ipv4Cidr>() {
Expand Down Expand Up @@ -137,7 +137,9 @@ impl Discovery {
Ok(_) => {
if let Some(tx_action) = &self.action_tx {
tx_action
.send(Action::Error("Unknown or unsupported channel type".into()))
.send(Action::Error(
"Unknown or unsupported channel type".into(),
))
.unwrap();
}
return;
Expand Down
6 changes: 1 addition & 5 deletions src/components/packetdump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,11 +849,7 @@ impl PacketDump {
rows
}

fn make_table(
rows: Vec<Row>,
packet_type: PacketTypeEnum,
dump_paused: bool,
) -> Table {
fn make_table(rows: Vec<Row>, packet_type: PacketTypeEnum, dump_paused: bool) -> Table {
let header = Row::new(vec!["time", "packet log"])
.style(Style::default().fg(Color::Yellow))
.top_margin(1)
Expand Down
12 changes: 7 additions & 5 deletions src/components/sniff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,14 @@ impl Component for Sniffer {
self.tab_changed(tab).unwrap();
}

if let Action::Down = action {
self.scroll_down();
}
if self.active_tab == TabsEnum::Traffic {
if let Action::Down = action {
self.scroll_down();
}

if let Action::Up = action {
self.scroll_up();
if let Action::Up = action {
self.scroll_up();
}
}

if let Action::ActiveInterface(ref interface) = action {
Expand Down
12 changes: 5 additions & 7 deletions src/components/tabs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,11 @@ impl Component for Tabs {
self.next_tab();
}

Action::TabChange(tab_enum) => {
TabsEnum::iter().enumerate().for_each(|(idx, t)| {
if tab_enum == t {
self.tab_index = idx;
}
})
}
Action::TabChange(tab_enum) => TabsEnum::iter().enumerate().for_each(|(idx, t)| {
if tab_enum == t {
self.tab_index = idx;
}
}),

_ => {}
}
Expand Down
3 changes: 1 addition & 2 deletions src/components/wifi_scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ use ratatui::{prelude::*, widgets::*};
use super::Component;
use crate::{
action::Action,
config::DEFAULT_BORDER_STYLE,
layout::{get_horizontal_layout, get_vertical_layout},
mode::Mode,
tui::Frame,
config::DEFAULT_BORDER_STYLE,
};

#[derive(Debug, PartialEq, Clone)]
Expand Down Expand Up @@ -42,7 +42,6 @@ pub struct WifiScan {
pub wifis: Vec<WifiInfo>,
pub signal_tick: [f64; 2],
show_graph: bool,
// pub mode: Mode,
}

impl Default for WifiScan {
Expand Down

0 comments on commit 596753c

Please sign in to comment.