mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-01 04:41:14 -03:00
Move query-interrupt event-variant into query-result enum
I think the interruption event is grouped next to the check-exit one because it used to be implemented as check exit but with a global flag (I didn't check whether that applied to master). Move it to the logical place.
This commit is contained in:
@@ -101,7 +101,7 @@ fn process_input(
|
||||
}
|
||||
CharEvent::Key(kevt) => kevt,
|
||||
CharEvent::Readline(_) | CharEvent::Command(_) | CharEvent::Implicit(_) => continue,
|
||||
CharEvent::QueryResult(Timeout) => panic!("should not be querying"),
|
||||
CharEvent::QueryResult(Timeout | Interrupted) => panic!("should not be querying"),
|
||||
CharEvent::QueryResult(Response(_)) => continue,
|
||||
};
|
||||
if verbose {
|
||||
|
||||
@@ -318,8 +318,6 @@ pub enum ImplicitEvent {
|
||||
/// An event was handled internally, or an interrupt was received. Check to see if the reader
|
||||
/// loop should exit.
|
||||
CheckExit,
|
||||
/// A blocking terminal query was interrupterd with ctrl-c.
|
||||
QueryInterrupted,
|
||||
/// Our terminal window gained focus.
|
||||
FocusIn,
|
||||
/// Our terminal window lost focus.
|
||||
@@ -338,6 +336,8 @@ pub enum QueryResponse {
|
||||
pub enum QueryResultEvent {
|
||||
Response(QueryResponse),
|
||||
Timeout,
|
||||
/// Canceled with ctrl-c.
|
||||
Interrupted,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -726,8 +726,7 @@ fn try_pop(&mut self) -> Option<CharEvent> {
|
||||
if self.is_blocked_querying() {
|
||||
use ImplicitEvent::*;
|
||||
match self.get_input_data().queue.front()? {
|
||||
CharEvent::QueryResult(_)
|
||||
| CharEvent::Implicit(CheckExit | Eof | QueryInterrupted) => {}
|
||||
CharEvent::QueryResult(_) | CharEvent::Implicit(CheckExit | Eof) => {}
|
||||
CharEvent::Key(_)
|
||||
| CharEvent::Readline(_)
|
||||
| CharEvent::Command(_)
|
||||
@@ -869,7 +868,7 @@ fn readch(&mut self) -> CharEvent {
|
||||
let ok = stop_query(self.blocking_query());
|
||||
assert!(ok);
|
||||
self.get_input_data_mut().queue.clear();
|
||||
self.push_front(CharEvent::Implicit(ImplicitEvent::QueryInterrupted));
|
||||
self.push_front(CharEvent::QueryResult(QueryResultEvent::Interrupted));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -1547,7 +1546,7 @@ fn enqueue_interrupt_key(&mut self) {
|
||||
"Received interrupt, giving up on waiting for terminal response"
|
||||
);
|
||||
self.get_input_data_mut().queue.clear();
|
||||
self.push_front(CharEvent::Implicit(ImplicitEvent::QueryInterrupted));
|
||||
self.push_front(CharEvent::QueryResult(QueryResultEvent::Interrupted));
|
||||
} else {
|
||||
self.push_front(interrupt_evt);
|
||||
}
|
||||
|
||||
@@ -274,15 +274,15 @@ pub fn terminal_init(vars: &dyn Environment, inputfd: RawFd) -> InputEventQueue
|
||||
|
||||
while !check_exit_loop_maybe_warning(None) {
|
||||
use CharEvent::{Command, Implicit, Key, Readline};
|
||||
use ImplicitEvent::{CheckExit, Eof, QueryInterrupted};
|
||||
use ImplicitEvent::{CheckExit, Eof};
|
||||
use QueryResultEvent::*;
|
||||
match input_queue.readch() {
|
||||
Implicit(Eof) => reader_sighup(),
|
||||
Implicit(CheckExit) => {}
|
||||
Implicit(QueryInterrupted) => break,
|
||||
CharEvent::QueryResult(Response(QueryResponse::PrimaryDeviceAttribute)) => {
|
||||
break;
|
||||
}
|
||||
CharEvent::QueryResult(Response(_)) => (),
|
||||
CharEvent::QueryResult(Timeout) => {
|
||||
let program = get_program_name();
|
||||
FLOG!(
|
||||
@@ -304,7 +304,7 @@ pub fn terminal_init(vars: &dyn Environment, inputfd: RawFd) -> InputEventQueue
|
||||
.replace(Duration::from_millis(30));
|
||||
break;
|
||||
}
|
||||
CharEvent::QueryResult(Response(_)) => (),
|
||||
CharEvent::QueryResult(Interrupted) => break,
|
||||
Key(_) | Readline(_) | Command(_) | Implicit(_) => panic!(),
|
||||
};
|
||||
}
|
||||
@@ -2614,7 +2614,6 @@ fn handle_char_event(&mut self, injected_event: Option<CharEvent>) -> ControlFlo
|
||||
CharEvent::Implicit(implicit_event) => match implicit_event {
|
||||
ImplicitEvent::Eof => reader_sighup(),
|
||||
ImplicitEvent::CheckExit => (),
|
||||
ImplicitEvent::QueryInterrupted => (),
|
||||
ImplicitEvent::FocusIn => {
|
||||
event::fire_generic(self.parser, L!("fish_focus_in").to_owned(), vec![]);
|
||||
self.save_screen_state();
|
||||
@@ -2647,7 +2646,7 @@ fn handle_char_event(&mut self, injected_event: Option<CharEvent>) -> ControlFlo
|
||||
}
|
||||
(
|
||||
Some(TerminalQuery::CursorPosition(cursor_pos_query)),
|
||||
Response(PrimaryDeviceAttribute) | Timeout,
|
||||
Response(PrimaryDeviceAttribute) | Timeout | Interrupted,
|
||||
) => {
|
||||
let cursor_pos_query = cursor_pos_query.clone();
|
||||
drop(maybe_query);
|
||||
|
||||
Reference in New Issue
Block a user