aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorJonas Maier <>2026-05-24 12:52:44 +0200
committerJonas Maier <>2026-05-24 12:52:44 +0200
commit183aee63b56be098efad606df9cf39ae637c4117 (patch)
treea80f65eca7368e3999e1f880e928b0bdb685d2ef /src/lib.rs
parent36cbfcaafcb8a3b1c47650439531a35c99b203ea (diff)
downloadpish-183aee63b56be098efad606df9cf39ae637c4117.tar.gz
add logic to query cursor position
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/lib.rs b/src/lib.rs
index c2b4a4a..05c8479 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,7 +1,8 @@
#![feature(
unix_socket_ancillary_data,
peer_credentials_unix_socket,
- associated_type_defaults
+ associated_type_defaults,
+ slice_split_once
)]
#![allow(clippy::needless_range_loop)]
@@ -112,14 +113,14 @@ pub struct Session {
/// byte literals to command invocation
ascii_keybinds: HashMap<BString, parse::Command<PostExpansion>>,
- debug_keystrokes: bool,
-
/// n before end of history.len()
/// 0 == not checking history
history_visit: usize,
highlighter: syntax_highlighting::Highlighter,
prompt: Prompt,
+
+ terminal_input: Option<ansi::TerminalInput>,
}
impl Session {
@@ -140,11 +141,11 @@ impl Session {
ctrlc: Default::default(),
ti_keybinds: HashMap::new(),
ascii_keybinds: HashMap::new(),
- debug_keystrokes: false,
history_visit: 0,
highlighter: syntax_highlighting::Highlighter::new(),
prompt,
vars,
+ terminal_input: None,
}
}
}
@@ -390,6 +391,7 @@ pub fn event_loop() {
socket_running: None,
path_cache: Default::default(),
ctrlc: Default::default(),
+ terminal_input: Some(ansi::TerminalInput::new()),
..Session::new_noninteractive()
};
@@ -408,11 +410,11 @@ pub fn event_loop() {
'repl: loop {
let mut se = session.lock().unwrap();
- let Some(key) = ansi::read(se.debug_keystrokes) else {
+ let Some(key) = se.terminal_input.as_mut().unwrap().read() else {
break;
};
- if se.debug_keystrokes {
+ if se.terminal_input.as_mut().unwrap().debug {
println!("{key:?}");
}