Fix tui with 1 client (#734)

* unbreak tui with 1 client

* clippy
This commit is contained in:
Nicholas Lang 2022-08-19 05:30:26 -04:00 committed by GitHub
parent 93c361bcd9
commit 7b345fbba7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,16 +64,20 @@ impl TuiUI {
pub fn on_right(&mut self) { pub fn on_right(&mut self) {
if self.clients != 0 { if self.clients != 0 {
// clients_idx never 0 // clients_idx never 0
if self.clients - 1 != 0 {
// except for when it is ;)
self.clients_idx = 1 + self.clients_idx % (self.clients - 1); self.clients_idx = 1 + self.clients_idx % (self.clients - 1);
} }
} }
}
pub fn on_left(&mut self) { pub fn on_left(&mut self) {
if self.clients != 0 { if self.clients != 0 {
// clients_idx never 0 // clients_idx never 0
if self.clients_idx == 1 { if self.clients_idx == 1 {
self.clients_idx = self.clients - 1; self.clients_idx = self.clients - 1;
} else { } else if self.clients - 1 != 0 {
// don't wanna be dividing by 0
self.clients_idx = 1 + (self.clients_idx - 2) % (self.clients - 1); self.clients_idx = 1 + (self.clients_idx - 2) % (self.clients - 1);
} }
} }