On macOS, add a way to query amount of tabbed windows

This should provide a way to iterate all the tabs and select the last
tab. The tab indicies are now zero based as any other sane index.

Follow-up-to: c5941d105f (add tabbing API)
This commit is contained in:
Kirill Chibisov 2023-07-14 08:01:40 +00:00 committed by GitHub
parent 06fb089633
commit 97434d8d80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 7 deletions

View file

@ -81,7 +81,14 @@ fn main() {
}
Key::Character(ch) => {
if let Ok(index) = ch.parse::<NonZeroUsize>() {
windows.get(&window_id).unwrap().select_tab_at_index(index);
let index = index.get();
// Select the last tab when pressing `9`.
let window = windows.get(&window_id).unwrap();
if index == 9 {
window.select_tab_at_index(window.num_tabs() - 1)
} else {
window.select_tab_at_index(index - 1);
}
}
}
_ => (),