buffer movement is now working as I would only wish it would. Needs layers implementation, will do in the future
This commit is contained in:
@@ -49,6 +49,7 @@ pub struct UiState {
|
||||
pub show_register: bool,
|
||||
pub focus_outside_canvas: bool,
|
||||
pub buffer_history: Vec<AppView>,
|
||||
pub active_buffer_index: usize,
|
||||
pub dialog: DialogState,
|
||||
}
|
||||
|
||||
@@ -166,6 +167,7 @@ impl Default for UiState {
|
||||
show_buffer_list: false,
|
||||
focus_outside_canvas: false,
|
||||
buffer_history: vec![AppView::Intro],
|
||||
active_buffer_index: 0,
|
||||
dialog: DialogState::default(),
|
||||
}
|
||||
}
|
||||
@@ -186,10 +188,18 @@ impl Default for DialogState {
|
||||
}
|
||||
|
||||
impl UiState {
|
||||
/// Adds the given view to the history if it's different from the last one.
|
||||
/// Updates the buffer history and active index.
|
||||
pub fn update_buffer_history(&mut self, view: AppView) {
|
||||
if self.buffer_history.last() != Some(&view) {
|
||||
self.buffer_history.push(view.clone());
|
||||
let existing_pos = self.buffer_history.iter().position(|v| v == &view);
|
||||
|
||||
match existing_pos {
|
||||
Some(pos) => {
|
||||
self.active_buffer_index = pos;
|
||||
}
|
||||
None => {
|
||||
self.buffer_history.push(view.clone());
|
||||
self.active_buffer_index = self.buffer_history.len() - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user