aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs45
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()
+ }
+ }
}
}