Compare commits
2 Commits
3d47e4edd9
...
1da04a4d0c
| Author | SHA1 | Date | |
|---|---|---|---|
| 1da04a4d0c | |||
| 6f408b3c21 |
@@ -205,7 +205,7 @@ pub fn complete_builtin(node: Node, io_stack: &mut IoStack, job: &mut JobBldr) -
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn compgen_builtin(node: Node, io_stack: &mut IoStack, job: &mut JobBldr) -> ShResult<()> {
|
pub fn compgen_builtin(node: Node, io_stack: &mut IoStack, job: &mut JobBldr) -> ShResult<()> {
|
||||||
let blame = node.get_span().clone();
|
let _blame = node.get_span().clone();
|
||||||
let NdRule::Command {
|
let NdRule::Command {
|
||||||
assignments: _,
|
assignments: _,
|
||||||
argv,
|
argv,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use regex::Regex;
|
|||||||
|
|
||||||
use crate::libsh::error::{ShErr, ShErrKind, ShResult};
|
use crate::libsh::error::{ShErr, ShErrKind, ShResult};
|
||||||
use crate::parse::execute::exec_input;
|
use crate::parse::execute::exec_input;
|
||||||
use crate::parse::lex::{LexFlags, LexStream, Tk, TkFlags, TkRule, is_field_sep, is_hard_sep};
|
use crate::parse::lex::{LexFlags, LexStream, Tk, TkFlags, TkRule, is_hard_sep};
|
||||||
use crate::parse::{Redir, RedirType};
|
use crate::parse::{Redir, RedirType};
|
||||||
use crate::procio::{IoBuf, IoFrame, IoMode, IoStack};
|
use crate::procio::{IoBuf, IoFrame, IoMode, IoStack};
|
||||||
use crate::readline::markers;
|
use crate::readline::markers;
|
||||||
|
|||||||
11
src/jobs.rs
11
src/jobs.rs
@@ -6,7 +6,7 @@ use crate::{
|
|||||||
prelude::*,
|
prelude::*,
|
||||||
procio::{IoMode, borrow_fd},
|
procio::{IoMode, borrow_fd},
|
||||||
signal::{disable_reaping, enable_reaping},
|
signal::{disable_reaping, enable_reaping},
|
||||||
state::{self, read_jobs, set_status, write_jobs},
|
state::{self, set_status, write_jobs},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const SIG_EXIT_OFFSET: i32 = 128;
|
pub const SIG_EXIT_OFFSET: i32 = 128;
|
||||||
@@ -168,12 +168,7 @@ impl JobTab {
|
|||||||
}
|
}
|
||||||
pub fn curr_job(&self) -> Option<usize> {
|
pub fn curr_job(&self) -> Option<usize> {
|
||||||
// Find the most recent valid job (order can have stale entries)
|
// Find the most recent valid job (order can have stale entries)
|
||||||
for &id in self.order.iter().rev() {
|
self.order.iter().rev().find(|&&id| self.jobs.get(id).is_some_and(|slot| slot.is_some())).copied()
|
||||||
if self.jobs.get(id).is_some_and(|slot| slot.is_some()) {
|
|
||||||
return Some(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
pub fn prev_job(&self) -> Option<usize> {
|
pub fn prev_job(&self) -> Option<usize> {
|
||||||
// Find the second most recent valid job
|
// Find the second most recent valid job
|
||||||
@@ -794,7 +789,7 @@ pub fn attach_tty(pgid: Pid) -> ShResult<()> {
|
|||||||
|
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => Ok(()),
|
Ok(_) => Ok(()),
|
||||||
Err(e) => {
|
Err(_e) => {
|
||||||
tcsetpgrp(borrow_fd(0), getpgrp())?;
|
tcsetpgrp(borrow_fd(0), getpgrp())?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
getopt::Opt,
|
|
||||||
libsh::term::{Style, Styled},
|
libsh::term::{Style, Styled},
|
||||||
parse::lex::Span,
|
parse::lex::Span,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
@@ -423,7 +422,7 @@ impl Display for ShErrKind {
|
|||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let output = match self {
|
let output = match self {
|
||||||
Self::IoErr(e) => &format!("I/O Error: {e}"),
|
Self::IoErr(e) => &format!("I/O Error: {e}"),
|
||||||
Self::InvalidOpt => &format!("Invalid option"),
|
Self::InvalidOpt => "Invalid option",
|
||||||
Self::SyntaxErr => "Syntax Error",
|
Self::SyntaxErr => "Syntax Error",
|
||||||
Self::ParseErr => "Parse Error",
|
Self::ParseErr => "Parse Error",
|
||||||
Self::InternalErr => "Internal Error",
|
Self::InternalErr => "Internal Error",
|
||||||
|
|||||||
@@ -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")
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ impl TkVecUtils<Tk> for Vec<Tk> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn debug_tokens(&self) {
|
fn debug_tokens(&self) {
|
||||||
for token in self {}
|
for _token in self {}
|
||||||
}
|
}
|
||||||
fn split_at_separators(&self) -> Vec<Vec<Tk>> {
|
fn split_at_separators(&self) -> Vec<Vec<Tk>> {
|
||||||
let mut splits = vec![];
|
let mut splits = vec![];
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ use crate::{
|
|||||||
source::source,
|
source::source,
|
||||||
test::double_bracket_test,
|
test::double_bracket_test,
|
||||||
trap::{TrapTarget, trap},
|
trap::{TrapTarget, trap},
|
||||||
true_builtin,
|
|
||||||
varcmds::{export, local, readonly, unset},
|
varcmds::{export, local, readonly, unset},
|
||||||
zoltraak::zoltraak,
|
zoltraak::zoltraak,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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] = [
|
||||||
|
|||||||
@@ -1281,7 +1281,7 @@ impl ParseStream {
|
|||||||
let mut node_tks = vec![];
|
let mut node_tks = vec![];
|
||||||
let mut redirs = vec![];
|
let mut redirs = vec![];
|
||||||
let mut argv = vec![];
|
let mut argv = vec![];
|
||||||
let mut flags = NdFlags::empty();
|
let flags = NdFlags::empty();
|
||||||
let mut assignments = vec![];
|
let mut assignments = vec![];
|
||||||
|
|
||||||
while let Some(prefix_tk) = tk_iter.next() {
|
while let Some(prefix_tk) = tk_iter.next() {
|
||||||
|
|||||||
@@ -1,25 +1,22 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::HashSet, env, fmt::Debug, os::unix::fs::PermissionsExt, path::PathBuf, sync::Arc,
|
collections::HashSet, fmt::Debug, path::PathBuf, sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
builtin::{
|
builtin::complete::{CompFlags, CompOptFlags, CompOpts},
|
||||||
BUILTINS,
|
|
||||||
complete::{CompFlags, CompOptFlags, CompOpts},
|
|
||||||
},
|
|
||||||
libsh::{
|
libsh::{
|
||||||
error::{ShErr, ShErrKind, ShResult},
|
error::ShResult,
|
||||||
utils::TkVecUtils,
|
utils::TkVecUtils,
|
||||||
},
|
},
|
||||||
parse::{
|
parse::{
|
||||||
execute::{VarCtxGuard, exec_input},
|
execute::{VarCtxGuard, exec_input},
|
||||||
lex::{self, LexFlags, Tk, TkFlags, TkRule, ends_with_unescaped},
|
lex::{self, LexFlags, Tk, TkRule, ends_with_unescaped},
|
||||||
},
|
},
|
||||||
readline::{
|
readline::{
|
||||||
Marker, annotate_input, annotate_input_recursive, get_insertions,
|
Marker, annotate_input_recursive,
|
||||||
markers::{self, is_marker},
|
markers::{self, is_marker},
|
||||||
},
|
},
|
||||||
state::{VarFlags, VarKind, read_jobs, read_logic, read_meta, read_vars, write_vars},
|
state::{VarFlags, VarKind, read_jobs, read_meta, read_vars, write_vars},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn complete_jobs(start: &str) -> Vec<String> {
|
pub fn complete_jobs(start: &str) -> Vec<String> {
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
use std::{
|
use std::{
|
||||||
env,
|
|
||||||
os::unix::fs::PermissionsExt,
|
os::unix::fs::PermissionsExt,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
libsh::term::{Style, StyleSet, Styled},
|
libsh::term::{Style, StyleSet},
|
||||||
readline::{
|
readline::{
|
||||||
annotate_input,
|
annotate_input,
|
||||||
markers::{self, is_marker},
|
markers::{self, is_marker},
|
||||||
},
|
},
|
||||||
state::{read_logic, read_meta, read_shopts},
|
state::{read_meta, read_shopts},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Syntax highlighter for shell input using Unicode marker-based annotation
|
/// Syntax highlighter for shell input using Unicode marker-based annotation
|
||||||
@@ -442,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),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -11,10 +11,7 @@ use super::vicmd::{
|
|||||||
ViCmd, Word,
|
ViCmd, Word,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
libsh::{
|
libsh::error::ShResult,
|
||||||
error::ShResult,
|
|
||||||
term::{Style, Styled},
|
|
||||||
},
|
|
||||||
parse::lex::{LexFlags, LexStream, Tk, TkFlags, TkRule},
|
parse::lex::{LexFlags, LexStream, Tk, TkFlags, TkRule},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
readline::{
|
readline::{
|
||||||
@@ -950,7 +947,7 @@ impl LineBuf {
|
|||||||
| TextObj::Angle(bound) => self.text_obj_delim(count, text_obj, bound),
|
| TextObj::Angle(bound) => self.text_obj_delim(count, text_obj, bound),
|
||||||
|
|
||||||
// Other stuff
|
// Other stuff
|
||||||
TextObj::Tag(bound) => todo!(),
|
TextObj::Tag(_bound) => todo!(),
|
||||||
TextObj::Custom(_) => todo!(),
|
TextObj::Custom(_) => todo!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1027,12 +1024,12 @@ impl LineBuf {
|
|||||||
|
|
||||||
Some((start, end))
|
Some((start, end))
|
||||||
}
|
}
|
||||||
pub fn text_obj_paragraph(&mut self, count: usize, bound: Bound) -> Option<(usize, usize)> {
|
pub fn text_obj_paragraph(&mut self, _count: usize, _bound: Bound) -> Option<(usize, usize)> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
pub fn text_obj_delim(
|
pub fn text_obj_delim(
|
||||||
&mut self,
|
&mut self,
|
||||||
count: usize,
|
_count: usize,
|
||||||
text_obj: TextObj,
|
text_obj: TextObj,
|
||||||
bound: Bound,
|
bound: Bound,
|
||||||
) -> Option<(usize, usize)> {
|
) -> Option<(usize, usize)> {
|
||||||
@@ -1149,7 +1146,7 @@ impl LineBuf {
|
|||||||
}
|
}
|
||||||
pub fn text_obj_quote(
|
pub fn text_obj_quote(
|
||||||
&mut self,
|
&mut self,
|
||||||
count: usize,
|
_count: usize,
|
||||||
text_obj: TextObj,
|
text_obj: TextObj,
|
||||||
bound: Bound,
|
bound: Bound,
|
||||||
) -> Option<(usize, usize)> {
|
) -> Option<(usize, usize)> {
|
||||||
@@ -2285,14 +2282,14 @@ impl LineBuf {
|
|||||||
|
|
||||||
MotionKind::On(target_pos)
|
MotionKind::On(target_pos)
|
||||||
}
|
}
|
||||||
MotionCmd(count, Motion::ScreenLineUp) => todo!(),
|
MotionCmd(_count, Motion::ScreenLineUp) => todo!(),
|
||||||
MotionCmd(count, Motion::ScreenLineUpCharwise) => todo!(),
|
MotionCmd(_count, Motion::ScreenLineUpCharwise) => todo!(),
|
||||||
MotionCmd(count, Motion::ScreenLineDown) => todo!(),
|
MotionCmd(_count, Motion::ScreenLineDown) => todo!(),
|
||||||
MotionCmd(count, Motion::ScreenLineDownCharwise) => todo!(),
|
MotionCmd(_count, Motion::ScreenLineDownCharwise) => todo!(),
|
||||||
MotionCmd(count, Motion::BeginningOfScreenLine) => todo!(),
|
MotionCmd(_count, Motion::BeginningOfScreenLine) => todo!(),
|
||||||
MotionCmd(count, Motion::FirstGraphicalOnScreenLine) => todo!(),
|
MotionCmd(_count, Motion::FirstGraphicalOnScreenLine) => todo!(),
|
||||||
MotionCmd(count, Motion::HalfOfScreen) => todo!(),
|
MotionCmd(_count, Motion::HalfOfScreen) => todo!(),
|
||||||
MotionCmd(count, Motion::HalfOfScreenLineText) => todo!(),
|
MotionCmd(_count, Motion::HalfOfScreenLineText) => todo!(),
|
||||||
MotionCmd(_count, Motion::WholeBuffer) => {
|
MotionCmd(_count, Motion::WholeBuffer) => {
|
||||||
MotionKind::Exclusive((0, self.grapheme_indices().len()))
|
MotionKind::Exclusive((0, self.grapheme_indices().len()))
|
||||||
}
|
}
|
||||||
@@ -2314,9 +2311,9 @@ impl LineBuf {
|
|||||||
final_end = final_end.min(self.cursor.max);
|
final_end = final_end.min(self.cursor.max);
|
||||||
MotionKind::Exclusive((start, final_end))
|
MotionKind::Exclusive((start, final_end))
|
||||||
}
|
}
|
||||||
MotionCmd(count, Motion::RepeatMotion) => todo!(),
|
MotionCmd(_count, Motion::RepeatMotion) => todo!(),
|
||||||
MotionCmd(count, Motion::RepeatMotionRev) => todo!(),
|
MotionCmd(_count, Motion::RepeatMotionRev) => todo!(),
|
||||||
MotionCmd(count, Motion::Null) => MotionKind::Null,
|
MotionCmd(_count, Motion::Null) => MotionKind::Null,
|
||||||
};
|
};
|
||||||
|
|
||||||
self.set_buffer(buffer);
|
self.set_buffer(buffer);
|
||||||
@@ -2380,7 +2377,7 @@ impl LineBuf {
|
|||||||
end = self.cursor.get();
|
end = self.cursor.get();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
SelectMode::Block(anchor) => todo!(),
|
SelectMode::Block(_anchor) => todo!(),
|
||||||
}
|
}
|
||||||
if start >= end {
|
if start >= end {
|
||||||
mode.invert_anchor();
|
mode.invert_anchor();
|
||||||
@@ -2490,7 +2487,7 @@ impl LineBuf {
|
|||||||
match verb {
|
match verb {
|
||||||
Verb::Delete | Verb::Yank | Verb::Change => {
|
Verb::Delete | Verb::Yank | Verb::Change => {
|
||||||
log::debug!("Executing verb: {verb:?} with motion: {motion:?}");
|
log::debug!("Executing verb: {verb:?} with motion: {motion:?}");
|
||||||
let Some((mut start, mut end)) = self.range_from_motion(&motion) else {
|
let Some((start, end)) = self.range_from_motion(&motion) else {
|
||||||
log::debug!("No range from motion, nothing to do");
|
log::debug!("No range from motion, nothing to do");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
use history::History;
|
use history::History;
|
||||||
use keys::{KeyCode, KeyEvent, ModKeys};
|
use keys::{KeyCode, KeyEvent, ModKeys};
|
||||||
use linebuf::{LineBuf, SelectAnchor, SelectMode};
|
use linebuf::{LineBuf, SelectAnchor, SelectMode};
|
||||||
use nix::libc::STDOUT_FILENO;
|
|
||||||
use term::{KeyReader, Layout, LineWriter, PollReader, TermWriter, get_win_size};
|
use term::{KeyReader, Layout, LineWriter, PollReader, TermWriter, get_win_size};
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
use vicmd::{CmdFlags, Motion, MotionCmd, RegisterName, Verb, VerbCmd, ViCmd};
|
use vicmd::{CmdFlags, Motion, MotionCmd, RegisterName, Verb, VerbCmd, ViCmd};
|
||||||
@@ -14,10 +13,7 @@ use crate::prelude::*;
|
|||||||
use crate::readline::term::{Pos, calc_str_width};
|
use crate::readline::term::{Pos, calc_str_width};
|
||||||
use crate::state::read_shopts;
|
use crate::state::read_shopts;
|
||||||
use crate::{
|
use crate::{
|
||||||
libsh::{
|
libsh::error::ShResult,
|
||||||
error::ShResult,
|
|
||||||
term::{Style, Styled},
|
|
||||||
},
|
|
||||||
parse::lex::{self, LexFlags, Tk, TkFlags, TkRule},
|
parse::lex::{self, LexFlags, Tk, TkFlags, TkRule},
|
||||||
readline::{complete::Completer, highlight::Highlighter},
|
readline::{complete::Completer, highlight::Highlighter},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use std::{
|
|||||||
|
|
||||||
use nix::{
|
use nix::{
|
||||||
errno::Errno,
|
errno::Errno,
|
||||||
libc::{self, STDIN_FILENO},
|
libc::{self},
|
||||||
poll::{self, PollFlags, PollTimeout},
|
poll::{self, PollFlags, PollTimeout},
|
||||||
sys::termios::{self, tcgetattr, tcsetattr},
|
sys::termios::{self, tcgetattr, tcsetattr},
|
||||||
unistd::isatty,
|
unistd::isatty,
|
||||||
@@ -23,16 +23,14 @@ use crate::{
|
|||||||
sys::TTY_FILENO,
|
sys::TTY_FILENO,
|
||||||
},
|
},
|
||||||
readline::keys::{KeyCode, ModKeys},
|
readline::keys::{KeyCode, ModKeys},
|
||||||
shopt::ShedBellStyle,
|
|
||||||
state::read_shopts,
|
state::read_shopts,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
prelude::*,
|
|
||||||
procio::borrow_fd,
|
procio::borrow_fd,
|
||||||
state::{read_meta, write_meta},
|
state::{read_meta, write_meta},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{keys::KeyEvent, linebuf::LineBuf};
|
use super::keys::KeyEvent;
|
||||||
|
|
||||||
pub fn raw_mode() -> RawModeGuard {
|
pub fn raw_mode() -> RawModeGuard {
|
||||||
let orig = termios::tcgetattr(unsafe { BorrowedFd::borrow_raw(*TTY_FILENO) })
|
let orig = termios::tcgetattr(unsafe { BorrowedFd::borrow_raw(*TTY_FILENO) })
|
||||||
@@ -50,7 +48,7 @@ pub fn raw_mode() -> RawModeGuard {
|
|||||||
)
|
)
|
||||||
.expect("Failed to set terminal to raw mode");
|
.expect("Failed to set terminal to raw mode");
|
||||||
|
|
||||||
let (cols, rows) = get_win_size(*TTY_FILENO);
|
let (_cols, _rows) = get_win_size(*TTY_FILENO);
|
||||||
|
|
||||||
RawModeGuard {
|
RawModeGuard {
|
||||||
orig,
|
orig,
|
||||||
@@ -859,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};
|
||||||
@@ -9,7 +8,6 @@ use super::vicmd::{
|
|||||||
Anchor, Bound, CmdFlags, Dest, Direction, Motion, MotionCmd, RegisterName, TextObj, To, Verb,
|
Anchor, Bound, CmdFlags, Dest, Direction, Motion, MotionCmd, RegisterName, TextObj, To, Verb,
|
||||||
VerbCmd, ViCmd, Word,
|
VerbCmd, ViCmd, Word,
|
||||||
};
|
};
|
||||||
use crate::prelude::*;
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
pub enum ModeReport {
|
pub enum ModeReport {
|
||||||
@@ -995,7 +993,7 @@ impl ViNormal {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if 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);
|
||||||
@@ -1660,7 +1658,7 @@ impl ViVisual {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if 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);
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
use std::{collections::HashMap, fmt::Display, str::FromStr};
|
use std::{fmt::Display, str::FromStr};
|
||||||
|
|
||||||
use crate::{
|
use crate::libsh::error::{Note, ShErr, ShErrKind, ShResult};
|
||||||
libsh::error::{Note, ShErr, ShErrKind, ShResult},
|
|
||||||
state::ShFunc,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub enum ShedBellStyle {
|
pub enum ShedBellStyle {
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
use std::{
|
use std::{
|
||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
cmp::Ordering,
|
|
||||||
collections::{HashMap, HashSet, VecDeque, hash_map::Entry},
|
collections::{HashMap, HashSet, VecDeque, hash_map::Entry},
|
||||||
fmt::Display,
|
fmt::Display,
|
||||||
ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, Deref},
|
ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign},
|
||||||
os::unix::fs::PermissionsExt,
|
os::unix::fs::PermissionsExt,
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
time::Duration,
|
time::Duration,
|
||||||
@@ -1052,7 +1051,7 @@ impl MetaTab {
|
|||||||
&mut self.comp_specs
|
&mut self.comp_specs
|
||||||
}
|
}
|
||||||
pub fn get_comp_spec(&self, cmd: &str) -> Option<Box<dyn CompSpec>> {
|
pub fn get_comp_spec(&self, cmd: &str) -> Option<Box<dyn CompSpec>> {
|
||||||
self.comp_specs.get(cmd).map(|spec| spec.clone())
|
self.comp_specs.get(cmd).cloned()
|
||||||
}
|
}
|
||||||
pub fn set_comp_spec(&mut self, cmd: String, spec: Box<dyn CompSpec>) {
|
pub fn set_comp_spec(&mut self, cmd: String, spec: Box<dyn CompSpec>) {
|
||||||
self.comp_specs.insert(cmd, spec);
|
self.comp_specs.insert(cmd, spec);
|
||||||
|
|||||||
Reference in New Issue
Block a user