MCPcopy Create free account
hub / github.com/GCWing/BitFun / item_index_at

Method item_index_at

src/apps/cli/src/ui/command_menu.rs:246–272  ·  view source on GitHub ↗
(&self, column: u16, row: u16, area: Rect)

Source from the content-addressed store, hash-verified

244 }
245
246 fn item_index_at(&self, column: u16, row: u16, area: Rect) -> Option<usize> {
247 if area.width < 3 || area.height < 3 {
248 return None;
249 }
250
251 let inner = Rect {
252 x: area.x.saturating_add(1),
253 y: area.y.saturating_add(1),
254 width: area.width.saturating_sub(2),
255 height: area.height.saturating_sub(2),
256 };
257
258 if column < inner.x
259 || column >= inner.x.saturating_add(inner.width)
260 || row < inner.y
261 || row >= inner.y.saturating_add(inner.height)
262 {
263 return None;
264 }
265
266 let index = row.saturating_sub(inner.y) as usize;
267 if index >= self.items.len() {
268 return None;
269 }
270
271 Some(index)
272 }
273
274 fn cursor_in_command(&self, input: &str, cursor: usize) -> bool {
275 match input.chars().position(|c| c.is_whitespace()) {

Callers 1

handle_mouse_eventMethod · 0.45

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected