This reverts commit 3fdd4f4591
.
This commit is contained in:
parent
3fdd4f4591
commit
5f2db5b93e
2 changed files with 13 additions and 5 deletions
|
@ -112,11 +112,14 @@ pub const PREFIX_LENGTH: u16 = " > 123ms 59s ago".len() as u16;
|
|||
|
||||
impl DrawState<'_> {
|
||||
fn index(&mut self) {
|
||||
if self.y as usize + self.state.offset == self.state.selected {
|
||||
self.draw(" >> ", Style::default());
|
||||
} else {
|
||||
self.draw(" ", Style::default());
|
||||
}
|
||||
// these encode the slices of `" > "`, `" {n} "`, or `" "` in a compact form.
|
||||
// Yes, this is a hack, but it makes me feel happy
|
||||
static SLICES: &str = " > 1 2 3 4 5 6 7 8 9 ";
|
||||
|
||||
let i = self.y as usize + self.state.offset;
|
||||
let i = i.checked_sub(self.state.selected);
|
||||
let i = i.unwrap_or(10).min(10) * 2;
|
||||
self.draw(&SLICES[i..i + 3], Style::default());
|
||||
}
|
||||
|
||||
fn duration(&mut self, h: &History) {
|
||||
|
|
|
@ -95,6 +95,7 @@ impl State {
|
|||
len: usize,
|
||||
) -> Option<usize> {
|
||||
let ctrl = input.modifiers.contains(KeyModifiers::CONTROL);
|
||||
let alt = input.modifiers.contains(KeyModifiers::ALT);
|
||||
match input.code {
|
||||
KeyCode::Char('c' | 'd' | 'g') if ctrl => return Some(RETURN_ORIGINAL),
|
||||
KeyCode::Esc => {
|
||||
|
@ -106,6 +107,10 @@ impl State {
|
|||
KeyCode::Enter => {
|
||||
return Some(self.results_state.selected());
|
||||
}
|
||||
KeyCode::Char(c @ '1'..='9') if alt => {
|
||||
let c = c.to_digit(10)? as usize;
|
||||
return Some(self.results_state.selected() + c);
|
||||
}
|
||||
KeyCode::Left => {
|
||||
self.input.left();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue