Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Fix menu option navigation issue #279

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::io::{self, Write};
use clap::{Parser, Subcommand};
use color_eyre::eyre::{Context, Report};
use color_eyre::Help;
use crossterm::event::{Event, KeyCode};
use crossterm::event::{Event, KeyCode, KeyEventKind};
use crossterm::terminal::{disable_raw_mode, enable_raw_mode};
use crossterm::{cursor, execute};
use owo_colors::OwoColorize;
Expand Down Expand Up @@ -124,25 +124,25 @@ async fn arrow_key_mode() -> Result<(), Report> {
// Process input events
loop {
if let Event::Key(event) = crossterm::event::read()? {
match event.code {
KeyCode::Up | KeyCode::Char('k') => {
match (event.kind, event.code) {
(KeyEventKind::Press, KeyCode::Up | KeyCode::Char('k')) => {
// Move selection up
if selected > 0 {
selected -= 1;
print_options(&mut stdout, &options, selected, position)?;
}
}
KeyCode::Down | KeyCode::Char('j') => {
(KeyEventKind::Press, KeyCode::Down | KeyCode::Char('j')) => {
// Move selection down
if selected < options.len() - 1 {
selected += 1;
print_options(&mut stdout, &options, selected, position)?;
}
}
KeyCode::Enter => {
(KeyEventKind::Press, KeyCode::Enter) => {
break;
}
KeyCode::Char('c')
(KeyEventKind::Press, KeyCode::Char('c'))
if event.modifiers.contains(crossterm::event::KeyModifiers::CONTROL) =>
{
return Ok(());
Expand Down
Loading