Expand description
compute a new selection index for the given list len, taking into account whether we should cycle or not
Examples found in repository?
More examples
src/filesystems/filesystems_state.rs (line 130)
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
fn move_line(
&mut self,
internal_exec: &InternalExecution,
input_invocation: Option<&VerbInvocation>,
dir: i32, // -1 for up, 1 for down
cycle: bool,
) -> CmdResult {
let count = get_arg(input_invocation, internal_exec, 1);
let dir = dir * count as i32;
if let Some(f) = self.filtered.as_mut() {
f.selection_idx = move_sel(f.selection_idx, f.mounts.len(), dir, cycle);
} else {
self.selection_idx = move_sel(self.selection_idx, self.mounts.len().get(), dir, cycle);
}
if self.selection_idx < self.scroll {
self.scroll = self.selection_idx;
} else if self.selection_idx >= self.scroll + self.page_height {
self.scroll = self.selection_idx + 1 - self.page_height;
}
CmdResult::Keep
}