Skip to content

Commit

Permalink
Merge branch 'main' of github.com:mrdgo/reedline
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Onciul committed Sep 11, 2024
2 parents 9d9060b + b450164 commit 43ab35b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,15 @@ impl Reedline {
}
}

/// Setup a queue for reedline events that can be written from other places.
pub fn with_reedline_event_queue(
mut self,
reedline_events: Arc<Mutex<Vec<ReedlineEvent>>>,
) -> Self {
self.reedline_event_queue = reedline_events;
self
}

/// Get a new history session id based on the current time and the first commit datetime of reedline
pub fn create_history_session_id() -> Option<HistorySessionId> {
let nanos = match SystemTime::now().duration_since(SystemTime::UNIX_EPOCH) {
Expand Down Expand Up @@ -804,6 +813,12 @@ impl Reedline {
reedline_events.push(ReedlineEvent::Edit(ec));
}

if let Ok(mut queue) = self.reedline_event_queue.lock() {
for event in queue.drain(..) {
reedline_events.push(event);
}
}

for event in reedline_events.drain(..) {
match self.handle_event(prompt, event)? {
EventStatus::Exits(signal) => {
Expand Down

0 comments on commit 43ab35b

Please sign in to comment.