diff options
| author | Jonas Maier <jonas@x77.dev> | 2026-03-05 23:54:56 +0100 |
|---|---|---|
| committer | Jonas Maier <jonas@x77.dev> | 2026-03-05 23:54:56 +0100 |
| commit | fb80e9c1cd4c2dcbb2d2ba1e2be8c7e19b9f0ce1 (patch) | |
| tree | e6980a3ae362de33f1521c647e18dad16b02363e /src/main.rs | |
| parent | f03a0863ba3da7cf34e938a7de1cf92675b09c41 (diff) | |
| download | pish-fb80e9c1cd4c2dcbb2d2ba1e2be8c7e19b9f0ce1.tar.gz | |
very buggy beginning of tab completion
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs index 5b195e4..a5820e7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,14 +5,14 @@ use std::os::unix::io::AsRawFd; use std::path::Path; use std::process::{Command, Stdio}; +pub mod completion; pub mod cursor; pub mod linebuf; pub mod panic; pub mod parse; pub mod raw; -pub mod run; pub mod reload; -pub mod completion; +pub mod run; use linebuf::LineBuf; use raw::*; @@ -181,7 +181,40 @@ fn event_loop() { } b'\t' => { - todo!() + let cmd = se.line.into_bytes(); + let comp = parse::completion_context(&cmd); + match comp.kind { + parse::CompletionKind::Command => todo!(), + parse::CompletionKind::Argument => { + let suggestions = completion::path_completion(comp.partial); + if suggestions.len() == 0 { + continue; + } + + if suggestions.len() == 1 { + // apply suggestion + todo!("apply suggestion"); + } + + cursor::save(); + + // one line below + print!("\r\n"); + for s in suggestions { + io::stdout().lock().write_all(&s.display).unwrap(); + println!(); + } + + cursor::restore(); + stdout.lock().flush().unwrap(); + } + parse::CompletionKind::None => { + for _ in 0..4 { + se.line.add(b' '); + print!(" ") + } + } + } } // Escape sequence @@ -265,8 +298,10 @@ fn main() { Ok(_) => break, Err(_) => { #[cfg(debug_assertions)] - unsafe { reload::continue_reload() } - }, + unsafe { + reload::continue_reload() + } + } } } |
