chore(TODO): Add docs

Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
Awiteb 2024-12-25 11:37:15 +00:00
parent 21a792d57c
commit f439453526
Signed by: awiteb
GPG key ID: 3F6B55640AA6682F
4 changed files with 11 additions and 11 deletions

View file

@ -8,7 +8,7 @@ use termion::event::Key as TKey;
use crate::controller::EventQueue;
impl<W: Write> EventQueue<W> {
/// TODO
/// Remove the last character from the string.
fn pop_char(name: &str) -> Cow<'_, str> {
if name.is_empty() {
return Cow::Borrowed(name);
@ -18,7 +18,7 @@ impl<W: Write> EventQueue<W> {
Cow::Owned(chars.collect())
}
/// TODO
/// Add a character to the string, if it is not a control character.
fn push_char<'a>(name: &'a str, chr: &char) -> Cow<'a, str> {
if chr.is_control() {
return Cow::Borrowed(name);
@ -26,7 +26,7 @@ impl<W: Write> EventQueue<W> {
Cow::Owned(format!("{name}{chr}"))
}
/// TODO
/// Rename the current file to the new name.
pub fn do_rename_current_file(&mut self, new_name: &str) -> Option<()> {
let new_path = self.pager.current_entry.with_file_name(new_name);
if !new_path.exists() {
@ -35,7 +35,7 @@ impl<W: Write> EventQueue<W> {
Some(())
}
/// TODO
/// Handle the rename input, and return the new name.
pub fn do_handle_rename_input<'a>(&mut self, new_name: &'a str, key: &TKey) -> Cow<'a, str> {
match key {
TKey::Backspace => return Self::pop_char(new_name),

View file

@ -23,7 +23,7 @@ mod key_event_handler;
mod key_event_matcher;
mod resize_event_handler;
/// TODO
/// Entrie, a struct that represents a file or directory.
pub struct Entrie {
pub path: PathBuf,
pub display_text: String,
@ -115,7 +115,7 @@ impl<W: Write> EventQueue<W> {
}
impl Entrie {
/// TODO
/// Create a new `Entrie`.
pub fn new(path: impl AsRef<Path>, display_text: impl Into<String>) -> Self {
Self {
path: path.as_ref().to_path_buf(),

View file

@ -40,7 +40,7 @@ impl From<&String> for Key {
}
impl Key {
/// TODO
/// Returns the inner termion key event.
pub fn inner(&self) -> &TKey {
match &self.inner {
termion::event::Event::Key(tkey) => tkey,

View file

@ -1,17 +1,17 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2024 Awiteb <a@4rs.nl>
/// TODO
/// Mode of the pager.
#[derive(Clone)]
pub enum Mode {
/// TODO
/// Normal mode. Exploring the file system.
Normal,
/// TODO
/// Rename mode. Renaming a file.
Rename(String),
}
impl Mode {
/// TODO
/// Returns the new name of the file, if in rename mode.
pub fn new_name(&self) -> Option<&str> {
match &self {
Mode::Rename(new_name) => Some(new_name),