Skip to content

Commit 53ce402

Browse files
committed
refactor: combine Tab/Backtab with h/l
1 parent d330577 commit 53ce402

File tree

2 files changed

+3
-43
lines changed

2 files changed

+3
-43
lines changed

src/handler.rs

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ pub async fn handle_key_events(
183183
}
184184

185185
// Switch focus
186-
KeyCode::Tab => match app.focused_block {
186+
KeyCode::Tab | KeyCode::Char('l') => match app.focused_block {
187187
FocusedBlock::Adapter => {
188188
app.focused_block = FocusedBlock::PairedDevices;
189189
app.reset_devices_state();
@@ -205,7 +205,7 @@ pub async fn handle_key_events(
205205
_ => {}
206206
},
207207

208-
KeyCode::BackTab => match app.focused_block {
208+
KeyCode::BackTab | KeyCode::Char('h') => match app.focused_block {
209209
FocusedBlock::Adapter => {
210210
if let Some(selected_controller) = app.controller_state.selected() {
211211
let controller = &app.controllers[selected_controller];
@@ -228,46 +228,6 @@ pub async fn handle_key_events(
228228
_ => {}
229229
},
230230

231-
KeyCode::Char('h') => match app.focused_block {
232-
FocusedBlock::Adapter => {
233-
if let Some(selected_controller) = app.controller_state.selected() {
234-
let controller = &app.controllers[selected_controller];
235-
if controller.new_devices.is_empty() {
236-
app.focused_block = FocusedBlock::PairedDevices;
237-
} else {
238-
app.focused_block = FocusedBlock::NewDevices;
239-
}
240-
}
241-
}
242-
FocusedBlock::PairedDevices => {
243-
app.focused_block = FocusedBlock::Adapter;
244-
}
245-
FocusedBlock::NewDevices => {
246-
app.focused_block = FocusedBlock::PairedDevices;
247-
app.reset_devices_state();
248-
}
249-
_ => {}
250-
},
251-
252-
KeyCode::Char('l') => match app.focused_block {
253-
FocusedBlock::Adapter => {
254-
app.focused_block = FocusedBlock::PairedDevices;
255-
app.reset_devices_state();
256-
}
257-
FocusedBlock::PairedDevices => {
258-
if let Some(selected_controller) = app.controller_state.selected() {
259-
let controller = &app.controllers[selected_controller];
260-
if controller.new_devices.is_empty() {
261-
app.focused_block = FocusedBlock::Adapter;
262-
} else {
263-
app.focused_block = FocusedBlock::NewDevices;
264-
}
265-
}
266-
}
267-
FocusedBlock::NewDevices => app.focused_block = FocusedBlock::Adapter,
268-
_ => {}
269-
},
270-
271231
// scroll down
272232
KeyCode::Char('j') | KeyCode::Down => match app.focused_block {
273233
FocusedBlock::Adapter => {

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async fn main() -> AppResult<()> {
3232
let mut app = App::new(config.clone()).await?;
3333
let backend = CrosstermBackend::new(io::stdout());
3434
let terminal = Terminal::new(backend)?;
35-
let events = EventHandler::new(1_000);
35+
let events = EventHandler::new(2_000);
3636
let mut tui = Tui::new(terminal, events);
3737
tui.init()?;
3838

0 commit comments

Comments
 (0)