commit 10d45d6cc3b15fa2b8baed526efea281033b2f8c parent 1d6da3ba0d4ed7e6cf6eb5de532037640fded745 Author: kernelkind <kernelkind@gmail.com> Date: Thu, 9 Jan 2025 12:50:52 -0500 move column Signed-off-by: kernelkind <kernelkind@gmail.com> Diffstat:
M | crates/notedeck_columns/src/column.rs | | | 19 | +++++++++++++++++++ |
1 file changed, 19 insertions(+), 0 deletions(-)
diff --git a/crates/notedeck_columns/src/column.rs b/crates/notedeck_columns/src/column.rs @@ -211,6 +211,25 @@ impl Columns { self.new_column_picker(); } } + + pub fn move_col(&mut self, from_index: usize, to_index: usize) { + if from_index == to_index + || from_index >= self.columns.len() + || to_index >= self.columns.len() + { + return; + } + + if from_index < to_index { + for i in from_index..to_index { + self.columns.swap_indices(i, i + 1); + } + } else { + for i in (to_index..from_index).rev() { + self.columns.swap_indices(i, i + 1); + } + } + } } pub enum IntermediaryRoute {