cleaned up all compiler warnings
This commit is contained in:
@@ -3,35 +3,6 @@ use std::sync::LazyLock;
|
|||||||
use termios::{LocalFlags, Termios};
|
use termios::{LocalFlags, Termios};
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
///
|
|
||||||
/// The previous state of the terminal options.
|
|
||||||
///
|
|
||||||
/// This variable stores the terminal settings at the start of the program and
|
|
||||||
/// restores them when the program exits. It is initialized exactly once at the
|
|
||||||
/// start of the program and accessed exactly once at the end of the program. It
|
|
||||||
/// will not be mutated or accessed under any other circumstances.
|
|
||||||
///
|
|
||||||
/// This ended up being necessary because wrapping Termios in a thread-safe way
|
|
||||||
/// was unreasonably tricky.
|
|
||||||
///
|
|
||||||
/// The possible states of this variable are:
|
|
||||||
/// - `None`: The terminal options have not been set yet (before
|
|
||||||
/// initialization).
|
|
||||||
/// - `Some(None)`: There were no terminal options to save (i.e., no terminal
|
|
||||||
/// input detected).
|
|
||||||
/// - `Some(Some(Termios))`: The terminal options (as `Termios`) have been
|
|
||||||
/// saved.
|
|
||||||
///
|
|
||||||
/// **Important:** This static variable is mutable and accessed via unsafe code.
|
|
||||||
/// It is only safe to use because:
|
|
||||||
/// - It is set once during program startup and accessed once during program
|
|
||||||
/// exit.
|
|
||||||
/// - It is not mutated or accessed after the initial setup and final read.
|
|
||||||
///
|
|
||||||
/// **Caution:** Future changes to this code should respect these constraints to
|
|
||||||
/// ensure safety. Modifying or accessing this variable outside the defined
|
|
||||||
/// lifecycle could lead to undefined behavior.
|
|
||||||
pub(crate) static mut SAVED_TERMIOS: Option<Option<Termios>> = None;
|
|
||||||
|
|
||||||
pub static TTY_FILENO: LazyLock<RawFd> = LazyLock::new(|| {
|
pub static TTY_FILENO: LazyLock<RawFd> = LazyLock::new(|| {
|
||||||
open("/dev/tty", OFlag::O_RDWR, Mode::empty()).expect("Failed to open /dev/tty")
|
open("/dev/tty", OFlag::O_RDWR, Mode::empty()).expect("Failed to open /dev/tty")
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ use crate::{
|
|||||||
error::{ShErr, ShErrKind, ShResult},
|
error::{ShErr, ShErrKind, ShResult},
|
||||||
utils::CharDequeUtils,
|
utils::CharDequeUtils,
|
||||||
},
|
},
|
||||||
prelude::*,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const KEYWORDS: [&str; 16] = [
|
pub const KEYWORDS: [&str; 16] = [
|
||||||
|
|||||||
@@ -441,3 +441,9 @@ impl Highlighter {
|
|||||||
.replace(markers::OPERATOR, "\x1b[35m");
|
.replace(markers::OPERATOR, "\x1b[35m");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for Highlighter {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,14 +9,11 @@ use std::{
|
|||||||
time::{Duration, SystemTime, UNIX_EPOCH},
|
time::{Duration, SystemTime, UNIX_EPOCH},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::prelude::*;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
libsh::error::{ShErr, ShErrKind, ShResult},
|
libsh::error::{ShErr, ShErrKind, ShResult},
|
||||||
readline::linebuf::LineBuf,
|
readline::linebuf::LineBuf,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::vicmd::Direction; // surprisingly useful
|
|
||||||
|
|
||||||
#[derive(Default, Clone, Copy, Debug)]
|
#[derive(Default, Clone, Copy, Debug)]
|
||||||
pub enum SearchKind {
|
pub enum SearchKind {
|
||||||
Fuzzy,
|
Fuzzy,
|
||||||
@@ -215,7 +212,7 @@ pub struct History {
|
|||||||
search_mask: Vec<HistEntry>,
|
search_mask: Vec<HistEntry>,
|
||||||
no_matches: bool,
|
no_matches: bool,
|
||||||
pub cursor: usize,
|
pub cursor: usize,
|
||||||
search_direction: Direction,
|
//search_direction: Direction,
|
||||||
ignore_dups: bool,
|
ignore_dups: bool,
|
||||||
max_size: Option<u32>,
|
max_size: Option<u32>,
|
||||||
}
|
}
|
||||||
@@ -242,7 +239,7 @@ impl History {
|
|||||||
search_mask,
|
search_mask,
|
||||||
no_matches: false,
|
no_matches: false,
|
||||||
cursor,
|
cursor,
|
||||||
search_direction: Direction::Backward,
|
//search_direction: Direction::Backward,
|
||||||
ignore_dups,
|
ignore_dups,
|
||||||
max_size: Some(max_hist as u32),
|
max_size: Some(max_hist as u32),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -857,18 +857,15 @@ pub struct TermWriter {
|
|||||||
out: RawFd,
|
out: RawFd,
|
||||||
pub t_cols: Col, // terminal width
|
pub t_cols: Col, // terminal width
|
||||||
buffer: String,
|
buffer: String,
|
||||||
w_calc: Box<dyn WidthCalculator>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TermWriter {
|
impl TermWriter {
|
||||||
pub fn new(out: RawFd) -> Self {
|
pub fn new(out: RawFd) -> Self {
|
||||||
let w_calc = width_calculator();
|
|
||||||
let (t_cols, _) = get_win_size(out);
|
let (t_cols, _) = get_win_size(out);
|
||||||
Self {
|
Self {
|
||||||
out,
|
out,
|
||||||
t_cols,
|
t_cols,
|
||||||
buffer: String::new(),
|
buffer: String::new(),
|
||||||
w_calc,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn get_cursor_movement(&self, old: Pos, new: Pos) -> ShResult<String> {
|
pub fn get_cursor_movement(&self, old: Pos, new: Pos) -> ShResult<String> {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
use std::iter::Peekable;
|
use std::iter::Peekable;
|
||||||
use std::str::Chars;
|
use std::str::Chars;
|
||||||
|
|
||||||
use nix::NixPath;
|
|
||||||
use unicode_segmentation::UnicodeSegmentation;
|
use unicode_segmentation::UnicodeSegmentation;
|
||||||
|
|
||||||
use super::keys::{KeyCode as K, KeyEvent as E, ModKeys as M};
|
use super::keys::{KeyCode as K, KeyEvent as E, ModKeys as M};
|
||||||
@@ -994,7 +993,7 @@ impl ViNormal {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
chars.peek().is_some();
|
let _ = chars; // suppresses unused warnings, creates an error if we decide to use chars later
|
||||||
|
|
||||||
let verb_ref = verb.as_ref().map(|v| &v.1);
|
let verb_ref = verb.as_ref().map(|v| &v.1);
|
||||||
let motion_ref = motion.as_ref().map(|m| &m.1);
|
let motion_ref = motion.as_ref().map(|m| &m.1);
|
||||||
@@ -1659,7 +1658,7 @@ impl ViVisual {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
chars.peek().is_some();
|
let _ = chars; // suppresses unused warnings, creates an error if we decide to use chars later
|
||||||
|
|
||||||
let verb_ref = verb.as_ref().map(|v| &v.1);
|
let verb_ref = verb.as_ref().map(|v| &v.1);
|
||||||
let motion_ref = motion.as_ref().map(|m| &m.1);
|
let motion_ref = motion.as_ref().map(|m| &m.1);
|
||||||
|
|||||||
Reference in New Issue
Block a user