From 49fbf8df53195d521cf03d03e288c583bcba4c7c Mon Sep 17 00:00:00 2001 From: Gokul Soumya Date: Sun, 18 Jun 2023 12:10:00 -0500 Subject: [PATCH] Move Component methods except render() to FilePicker --- helix-term/src/ui/picker.rs | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index 0f334548b..627f94724 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -684,17 +684,19 @@ impl FilePicker { EventResult::Consumed(None) } - fn cursor(&self, area: Rect, ctx: &Editor) -> (Option, CursorKind) { - self.picker.cursor(area, ctx) + fn cursor(&self, area: Rect, editor: &Editor) -> (Option, CursorKind) { + let block = Block::default().borders(Borders::ALL); + // calculate the inner area inside the box + let inner = block.inner(area); + + // prompt area + let area = inner.clip_left(1).with_height(1); + + self.prompt.cursor(area, editor) } fn required_size(&mut self, (width, height): (u16, u16)) -> Option<(u16, u16)> { - let picker_width = if width > MIN_AREA_WIDTH_FOR_PREVIEW { - width / 2 - } else { - width - }; - self.picker.required_size((picker_width, height))?; + self.completion_height = height.saturating_sub(4); Some((width, height)) } @@ -826,8 +828,7 @@ impl Picker { impl Component for Picker { fn required_size(&mut self, viewport: (u16, u16)) -> Option<(u16, u16)> { - self.completion_height = viewport.1.saturating_sub(4); - Some(viewport) + unimplemented!() } fn handle_event(&mut self, event: &Event, cx: &mut Context) -> EventResult { @@ -1001,14 +1002,7 @@ impl Component for Picker { } fn cursor(&self, area: Rect, editor: &Editor) -> (Option, CursorKind) { - let block = Block::default().borders(Borders::ALL); - // calculate the inner area inside the box - let inner = block.inner(area); - - // prompt area - let area = inner.clip_left(1).with_height(1); - - self.prompt.cursor(area, editor) + unimplemented!() } }