MCPcopy Create free account
hub / github.com/GCWing/BitFun / handle_question_key

Method handle_question_key

src/apps/cli/src/ui/question.rs:318–388  ·  view source on GitHub ↗

Handle keys during normal question selection

(&mut self, key: KeyEvent)

Source from the content-addressed store, hash-verified

316
317 /// Handle keys during normal question selection
318 fn handle_question_key(&mut self, key: KeyEvent) -> QuestionAction {
319 let total = self.total_options();
320
321 match (key.code, key.modifiers) {
322 // Navigate options vertically
323 (KeyCode::Up, _) | (KeyCode::Char('k'), KeyModifiers::NONE) => {
324 if total > 0 {
325 self.selected_option = (self.selected_option + total - 1) % total;
326 }
327 QuestionAction::None
328 }
329 (KeyCode::Down, _) | (KeyCode::Char('j'), KeyModifiers::NONE) => {
330 if total > 0 {
331 self.selected_option = (self.selected_option + 1) % total;
332 }
333 QuestionAction::None
334 }
335
336 // Navigate tabs (multi-question)
337 (KeyCode::Left, _) | (KeyCode::Char('h'), KeyModifiers::NONE) => {
338 if self.tab_count() > 1 {
339 let tabs = self.tab_count();
340 self.current_tab = (self.current_tab + tabs - 1) % tabs;
341 self.selected_option = 0;
342 }
343 QuestionAction::None
344 }
345 (KeyCode::Right, _) | (KeyCode::Char('l'), KeyModifiers::NONE) => {
346 if self.tab_count() > 1 {
347 let tabs = self.tab_count();
348 self.current_tab = (self.current_tab + 1) % tabs;
349 self.selected_option = 0;
350 }
351 QuestionAction::None
352 }
353 (KeyCode::Tab, KeyModifiers::NONE) => {
354 if self.tab_count() > 1 {
355 let tabs = self.tab_count();
356 self.current_tab = (self.current_tab + 1) % tabs;
357 self.selected_option = 0;
358 }
359 QuestionAction::None
360 }
361 (KeyCode::BackTab, _) => {
362 if self.tab_count() > 1 {
363 let tabs = self.tab_count();
364 self.current_tab = (self.current_tab + tabs - 1) % tabs;
365 self.selected_option = 0;
366 }
367 QuestionAction::None
368 }
369
370 // Select / toggle
371 (KeyCode::Enter, _) => self.select_current_option(),
372
373 // Number shortcuts (1-9)
374 (KeyCode::Char(c), KeyModifiers::NONE) if c.is_ascii_digit() && c != '0' => {
375 let digit = (c as u8 - b'0') as usize;

Callers 1

handle_key_eventMethod · 0.80

Calls 3

total_optionsMethod · 0.80
tab_countMethod · 0.80
select_current_optionMethod · 0.80

Tested by

no test coverage detected