-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f35b45b
commit babe1c7
Showing
9 changed files
with
411 additions
and
354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
pub mod utils; | ||
|
||
use ratatui::{ | ||
layout::{Margin, Rect}, | ||
style::{Color, Style, Stylize}, | ||
text::{Span, Text}, | ||
widgets::{Block, BorderType, Paragraph, Wrap}, | ||
Frame, | ||
}; | ||
use utils::Layout; | ||
|
||
use crate::tamanoir_grpc::SessionResponse; | ||
|
||
#[derive(Debug)] | ||
pub struct KeyLoggerSection { | ||
layout: Layout, | ||
} | ||
impl KeyLoggerSection { | ||
pub fn new() -> Self { | ||
Self { | ||
layout: Layout::Azerty, | ||
} | ||
} | ||
pub fn render( | ||
&mut self, | ||
frame: &mut Frame, | ||
block: Rect, | ||
selected_session: &mut Option<SessionResponse>, | ||
is_focused: bool, | ||
) { | ||
let txt = match selected_session { | ||
Some(session) => match session.parse_keycodes(self.layout.clone()) { | ||
Ok(kc) => Text::from(SessionResponse::format_keys(kc)), | ||
|
||
Err(_) => Text::from("Error decoding keycodes".to_string()).centered(), | ||
}, | ||
_ => Text::from("No Session selected".to_string()).centered(), | ||
}; | ||
let highlight_color = if is_focused { | ||
Color::Yellow | ||
} else { | ||
Color::Blue | ||
}; | ||
let p = Paragraph::new(txt).wrap(Wrap { trim: true }).block( | ||
Block::bordered() | ||
.border_type(BorderType::Rounded) | ||
.border_style(Style::new().fg(highlight_color)) | ||
.title(Span::styled( | ||
"Keylogger", | ||
Style::default().fg(highlight_color).bold(), | ||
)), | ||
); | ||
|
||
frame.render_widget( | ||
p, | ||
block.inner(Margin { | ||
horizontal: 1, | ||
vertical: 0, | ||
}), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.