ratatui_toolkit/master_layout/keybindings/methods/get_tab_switch_index.rs
1//! get_tab_switch_index method for MasterLayoutKeyBindings
2
3use crate::master_layout::keybindings::MasterLayoutKeyBindings;
4use crossterm::event::KeyEvent;
5
6impl MasterLayoutKeyBindings {
7 /// Check if the given key event matches any tab switch key and return the tab index (0-based)
8 pub fn get_tab_switch_index(&self, key: &KeyEvent) -> Option<usize> {
9 for (i, (code, mods)) in self.switch_tabs.iter().enumerate() {
10 if key.code == *code && key.modifiers == *mods {
11 return Some(i);
12 }
13 }
14 None
15 }
16}