@@ -230,7 +230,7 @@ impl<T: Item + 'static> Component for Menu<T> {
230 fn required_size(&mut self, viewport: (u16, u16)) -> Option<(u16, u16)> {
230 fn required_size(&mut self, viewport: (u16, u16)) -> Option<(u16, u16)> {
231 let width = std::cmp::min(30, viewport.0);
231 let width = std::cmp::min(30, viewport.0);
233− const MAX: usize = 5;
233+ const MAX: usize = 10;
234 let height = std::cmp::min(self.options.len(), MAX);
234 let height = std::cmp::min(self.options.len(), MAX);
235 let height = std::cmp::min(height, viewport.1 as usize);
235 let height = std::cmp::min(height, viewport.1 as usize);
@@ -242,9 +242,11 @@ impl<T: Item + 'static> Component for Menu<T> {
242 Some(self.size)
242 Some(self.size)
245+ // TODO: required size should re-trigger when we filter items so we can draw a smaller menu
245 fn render(&self, area: Rect, surface: &mut Surface, cx: &mut Context) {
247 fn render(&self, area: Rect, surface: &mut Surface, cx: &mut Context) {
246 let style = cx.editor.theme.get("ui.text");
248 let style = cx.editor.theme.get("ui.text");
247− let selected = Style::default().fg(Color::Rgb(255, 255, 255));
249+ let selected = cx.editor.theme.get("ui.menu.selected");
249 let scroll = self.scroll;
251 let scroll = self.scroll;
@@ -289,13 +291,21 @@ impl<T: Item + 'static> Component for Menu<T> {
294+ // // TODO: set bg for the whole row if selected
295+ // if line == self.cursor {
296+ // surface.set_style(
297+ // Rect::new(area.x, area.y + i as u16, area.width - 1, 1),
292 for (i, option) in (scroll..(scroll + win_height).min(len)).enumerate() {
302 for (i, option) in (scroll..(scroll + win_height).min(len)).enumerate() {
293 let is_marked = i >= scroll_line && i < scroll_line + scroll_height;
303 let is_marked = i >= scroll_line && i < scroll_line + scroll_height;
295 if is_marked {
305 if is_marked {
296 let cell = surface.get_mut(area.x + area.width - 2, area.y + i as u16);
306 let cell = surface.get_mut(area.x + area.width - 2, area.y + i as u16);
297 cell.set_symbol("▐ ");
307 cell.set_symbol("▐ ");
298− cell.set_style(selected);
308+ // cell.set_style(selected);
299 // cell.set_style(if is_marked { selected } else { style });
309 // cell.set_style(if is_marked { selected } else { style });