Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ztroop committed Apr 2, 2024
1 parent 187dc9c commit 26cb0b3
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub struct EventHandler {
}

impl EventHandler {
/// Create a new event handler with the specified tick rate.
pub fn new(tick_rate: u64) -> Self {
let tick_rate = Duration::from_millis(tick_rate);
let (sender, receiver) = mpsc::channel();
Expand Down
3 changes: 3 additions & 0 deletions src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ use std::{
path::Path,
};

/// Read the contents of a file into a vector of bytes.
pub fn read_file<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
let mut file = File::open(path)?;
let mut buffer = Vec::new();
file.read_to_end(&mut buffer)?;
Ok(buffer)
}

/// Compare two files and return a vector of tuples containing the index of the
/// differing byte and the byte itself.
pub fn diff_files(file1: &[u8], file2: &[u8]) -> Vec<(usize, u8)> {
file1
.iter()
Expand Down
1 change: 1 addition & 0 deletions src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crossterm::event::{KeyCode, KeyEvent};

use crate::{app::App, tui::TerminalSize};

/// Handle key events and update the app state accordingly.
pub fn handle_key_events(
key_event: KeyEvent,
app: &mut App,
Expand Down
2 changes: 0 additions & 2 deletions src/tui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ use std::panic;
/// Representation of a terminal user interface.
#[derive(Debug)]
pub struct Tui<B: Backend> {
/// Interface to the Terminal.
terminal: Terminal<B>,
/// Terminal event handler.
pub events: EventHandler,
}

Expand Down
1 change: 1 addition & 0 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use ratatui::{

use crate::app::App;

/// Render the user interface.
pub fn render(app: &mut App, frame: &mut Frame) {
let size = frame.size();

Expand Down

0 comments on commit 26cb0b3

Please sign in to comment.