[Add] basic split
This commit is contained in:
parent
a0ff6b1082
commit
3cdf7c62d5
77 changed files with 506 additions and 648 deletions
25
iota-core/src/terms/focus.rs
Normal file
25
iota-core/src/terms/focus.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Focus {
|
||||
Eula,
|
||||
Tos,
|
||||
Pp,
|
||||
Cancel,
|
||||
Continue,
|
||||
ContinueAll,
|
||||
}
|
||||
|
||||
impl Focus {
|
||||
pub fn next(&mut self, order: &[Focus]) {
|
||||
if let Some(pos) = order.iter().position(|&f| f == *self) {
|
||||
let next_pos = (pos + 1) % order.len();
|
||||
*self = order[next_pos];
|
||||
}
|
||||
}
|
||||
|
||||
pub fn prev(&mut self, order: &[Focus]) {
|
||||
if let Some(pos) = order.iter().position(|&f| f == *self) {
|
||||
let prev_pos = if pos == 0 { order.len() - 1 } else { pos - 1 };
|
||||
*self = order[prev_pos];
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue