on master help sign in
ui: Refactor styling a bit, ensure infobox is stylable
68626b8Blaž Hrastnik
helix-term/src/ui/info.rs+7−4
@@ -6,7 +6,8 @@ use tui::widgets::{Block, Borders, Paragraph, Widget};
6
6
7impl Component for Info {
7impl Component for Info {
8 fn render(&mut self, viewport: Rect, surface: &mut Surface, cx: &mut Context) {
8 fn render(&mut self, viewport: Rect, surface: &mut Surface, cx: &mut Context) {
9− let style = cx.editor.theme.get("ui.popup");
9+ let text_style = cx.editor.theme.get("ui.text.focus");
10+ let popup_style = text_style.patch(cx.editor.theme.get("ui.popup"));
10
11
11 // Calculate the area of the terminal to modify. Because we want to
12 // Calculate the area of the terminal to modify. Because we want to
12 // render at the bottom right, we use the viewport's width and height
13 // render at the bottom right, we use the viewport's width and height
@@ -19,12 +20,12 @@ impl Component for Info {
19 width,
20 width,
20 height,
21 height,
21 ));
22 ));
22− surface.clear_with(area, style);
23+ surface.clear_with(area, popup_style);
23
24
24 let block = Block::default()
25 let block = Block::default()
25 .title(self.title.as_str())
26 .title(self.title.as_str())
26 .borders(Borders::ALL)
27 .borders(Borders::ALL)
27− .border_style(style);
28+ .border_style(popup_style);
28
29
29 let margin = Margin {
30 let margin = Margin {
30 vertical: 0,
31 vertical: 0,
@@ -33,6 +34,8 @@ impl Component for Info {
33 let inner = block.inner(area).inner(&margin);
34 let inner = block.inner(area).inner(&margin);
34 block.render(area, surface);
35 block.render(area, surface);
35
36
36− Paragraph::new(self.text.as_str()).render(inner, surface);
37+ Paragraph::new(self.text.as_str())
38+ .style(text_style)
39+ .render(inner, surface);
37 }
40 }
38}
41}
helix-term/src/ui/prompt.rs+5−6
@@ -284,7 +284,8 @@ const BASE_WIDTH: u16 = 30;
284impl Prompt {
284impl Prompt {
285 pub fn render_prompt(&self, area: Rect, surface: &mut Surface, cx: &mut Context) {
285 pub fn render_prompt(&self, area: Rect, surface: &mut Surface, cx: &mut Context) {
286 let theme = &cx.editor.theme;
286 let theme = &cx.editor.theme;
287− let text_color = theme.get("ui.text.focus");
287+ let prompt_color = theme.get("ui.text");
288+ let completion_color = theme.get("ui.statusline");
288 let selected_color = theme.get("ui.menu.selected");
289 let selected_color = theme.get("ui.menu.selected");
289 // completion
290 // completion
290
291
@@ -326,15 +327,13 @@ impl Prompt {
326 let mut row = 0;
327 let mut row = 0;
327 let mut col = 0;
328 let mut col = 0;
328
329
329− // TODO: paginate
330 for (i, (_range, completion)) in
330 for (i, (_range, completion)) in
331 self.completion.iter().enumerate().skip(offset).take(items)
331 self.completion.iter().enumerate().skip(offset).take(items)
332 {
332 {
333 let color = if Some(i) == self.selection {
333 let color = if Some(i) == self.selection {
334− // Style::default().bg(Color::Rgb(104, 60, 232))
335 selected_color // TODO: just invert bg
334 selected_color // TODO: just invert bg
336 } else {
335 } else {
337− text_color
336+ completion_color
338 };
337 };
339 surface.set_stringn(
338 surface.set_stringn(
340 area.x + col * (1 + col_width),
339 area.x + col * (1 + col_width),
@@ -377,12 +376,12 @@ impl Prompt {
377
376
378 let line = area.height - 1;
377 let line = area.height - 1;
379 // render buffer text
378 // render buffer text
380− surface.set_string(area.x, area.y + line, &self.prompt, text_color);
379+ surface.set_string(area.x, area.y + line, &self.prompt, prompt_color);
381 surface.set_string(
380 surface.set_string(
382 area.x + self.prompt.len() as u16,
381 area.x + self.prompt.len() as u16,
383 area.y + line,
382 area.y + line,
384 &self.line,
383 &self.line,
385− text_color,
384+ prompt_color,
386 );
385 );
387 }
386 }
388}
387}
theme.toml+1−1
@@ -42,7 +42,7 @@ module = "#ff0000"
42"ui.help" = { bg = "#7958DC", fg = "#171452" }
42"ui.help" = { bg = "#7958DC", fg = "#171452" }
43
43
44"ui.text" = { fg = "lavender" }
44"ui.text" = { fg = "lavender" }
45−"ui.text.focus" = { fg = "lilac" }
45+"ui.text.focus" = { fg = "white" }
46
46
47"ui.selection" = { bg = "#540099" }
47"ui.selection" = { bg = "#540099" }
48"ui.selection.primary" = { bg = "#540099" }
48"ui.selection.primary" = { bg = "#540099" }