mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Read one input event at a time
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
// Sub modules
|
// Sub modules
|
||||||
mod bookmarks;
|
mod bookmarks;
|
||||||
|
mod callbacks;
|
||||||
mod input;
|
mod input;
|
||||||
mod layout;
|
mod layout;
|
||||||
|
|
||||||
@@ -117,6 +118,8 @@ pub struct AuthActivity {
|
|||||||
redraw: bool, // Should ui actually be redrawned?
|
redraw: bool, // Should ui actually be redrawned?
|
||||||
input_txt: String, // Input text
|
input_txt: String, // Input text
|
||||||
choice_opt: DialogYesNoOption, // Dialog popup selected option
|
choice_opt: DialogYesNoOption, // Dialog popup selected option
|
||||||
|
bookmarks_idx: usize, // Index of selected bookmark
|
||||||
|
recents_idx: usize, // Index of selected recent
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for AuthActivity {
|
impl Default for AuthActivity {
|
||||||
@@ -147,6 +150,8 @@ impl AuthActivity {
|
|||||||
redraw: true, // True at startup
|
redraw: true, // True at startup
|
||||||
input_txt: String::new(),
|
input_txt: String::new(),
|
||||||
choice_opt: DialogYesNoOption::Yes,
|
choice_opt: DialogYesNoOption::Yes,
|
||||||
|
bookmarks_idx: 0,
|
||||||
|
recents_idx: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -180,14 +185,13 @@ impl Activity for AuthActivity {
|
|||||||
if self.context.is_none() {
|
if self.context.is_none() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Start catching Input Events
|
// Read one event
|
||||||
if let Ok(input_events) = self.context.as_ref().unwrap().input_hnd.fetch_events() {
|
if let Ok(event) = self.context.as_ref().unwrap().input_hnd.read_event() {
|
||||||
if !input_events.is_empty() {
|
if let Some(event) = event {
|
||||||
self.redraw = true; // Set redraw to true if there is at least one event
|
// Set redraw to true
|
||||||
}
|
self.redraw = true;
|
||||||
// Iterate over input events
|
// Handle event
|
||||||
for event in input_events.iter() {
|
self.handle_input_event(&event);
|
||||||
self.handle_input_event(event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Redraw if necessary
|
// Redraw if necessary
|
||||||
|
|||||||
Reference in New Issue
Block a user