Carry over input to actions
This commit is contained in:
parent
a207a38101
commit
e2f81df3dc
2 changed files with 23 additions and 7 deletions
27
src/main.rs
27
src/main.rs
|
@ -1,7 +1,5 @@
|
||||||
use log::{debug, trace};
|
use log::{debug, trace};
|
||||||
use std::cell::RefCell;
|
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::rc::Rc;
|
|
||||||
|
|
||||||
use winit::window::{Window, WindowBuilder};
|
use winit::window::{Window, WindowBuilder};
|
||||||
use winit::event_loop::{ControlFlow, EventLoop};
|
use winit::event_loop::{ControlFlow, EventLoop};
|
||||||
|
@ -140,7 +138,7 @@ impl RoftlLoop {
|
||||||
{
|
{
|
||||||
let actions = self.roftl.actions(self.selection);
|
let actions = self.roftl.actions(self.selection);
|
||||||
debug!{"Actions for current selection: {:?}", actions}
|
debug!{"Actions for current selection: {:?}", actions}
|
||||||
ui::draw_actions(&self.window, actions);
|
ui::draw_actions(&self.window, actions, &self.input_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => ()
|
_ => ()
|
||||||
|
@ -255,9 +253,26 @@ impl RoftlLoop {
|
||||||
self.roftl.do_action(self.selection, roftl::Action::Quaternary);
|
self.roftl.do_action(self.selection, roftl::Action::Quaternary);
|
||||||
ControlFlow::Exit
|
ControlFlow::Exit
|
||||||
},
|
},
|
||||||
_ => {
|
|
||||||
trace!{"Retrieved unknown action selection. Processing character {}", character}
|
'q' | 'Q' => ControlFlow::Exit,
|
||||||
self.process_character(character)
|
|
||||||
|
// Escape
|
||||||
|
c if c == char::from(0x1b) => ControlFlow::Exit,
|
||||||
|
|
||||||
|
// tab
|
||||||
|
c if c == char::from(0x09) => {
|
||||||
|
debug!{"Received actions"}
|
||||||
|
match self.mode {
|
||||||
|
Mode::Selection => { self.mode = Mode::Actions; self.input_changed = true },
|
||||||
|
Mode::Actions => { self.mode = Mode::Selection; self.input_changed = true }
|
||||||
|
}
|
||||||
|
self.window.request_redraw();
|
||||||
|
ControlFlow::Wait
|
||||||
|
},
|
||||||
|
|
||||||
|
_ => {
|
||||||
|
debug!{"Retrieved unknown action selection. Processing character {}", character}
|
||||||
|
ControlFlow::Wait
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ pub fn redraw_quick(window: &Window, result: Vec<(&Entry, Vec<usize>)>, selectio
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_actions(window: &Window, actions: Vec<String>)
|
pub fn draw_actions(window: &Window, actions: Vec<String>, input: &str)
|
||||||
{
|
{
|
||||||
let context = make_context(&window);
|
let context = make_context(&window);
|
||||||
|
|
||||||
|
@ -123,6 +123,7 @@ pub fn draw_actions(window: &Window, actions: Vec<String>)
|
||||||
let painter = painter::Painter::new(&context);
|
let painter = painter::Painter::new(&context);
|
||||||
|
|
||||||
painter.background();
|
painter.background();
|
||||||
|
painter.input_box(0, 0, input);
|
||||||
painter.divider(0, 1);
|
painter.divider(0, 1);
|
||||||
|
|
||||||
actions.iter().enumerate()
|
actions.iter().enumerate()
|
||||||
|
|
Loading…
Reference in a new issue