diff options
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/src/main.rs b/src/main.rs index 3687cd0..c2cf375 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,6 +27,7 @@ use linebuf::LineBuf; use raw::*; use crate::cursor::{Direction, move_cursor}; +use crate::history::HistoryEntry; use crate::parse::{Ast, PreExpansion}; macro_rules! print { @@ -59,28 +60,6 @@ type BString = Vec<u8>; #[allow(non_camel_case_types)] type bstr = [u8]; -#[derive(Clone)] -struct HistoryEntry { - /// time of execution - pub time: date::DateTime, - - /// absolute path where the command was executed - pub loc: BString, - - /// the command - pub cmd: BString, -} - -impl HistoryEntry { - pub fn new(cmd: BString) -> Self { - Self { - time: date::DateTime::now(), - loc: current_dir().unwrap().as_os_str().as_encoded_bytes().to_vec(), - cmd, - } - } -} - pub struct Session { raw: ScopedRawMode, line: LineBuf, @@ -259,6 +238,8 @@ fn read1() -> u8 { } fn event_loop() { + history::setup(); + let stdin = io::stdin(); let stdout = io::stdout(); @@ -335,7 +316,9 @@ fn event_loop() { let line = se.line.dump(); if !line.is_empty() { print!("\r\n"); - se.history.push(HistoryEntry::new(line.clone())); + let entry = HistoryEntry::new(line.clone()); + history::persist(&entry); + se.history.push(entry); se.history_visit = 0; drop(se); run::run(session.clone(), line); |
