on master help sign in
Fix statusline rendering, change colors on active view.
a81b8f3Blaž Hrastnik
helix-term/src/ui/editor.rs+17−5
@@ -50,7 +50,12 @@ impl EditorView {
50 // TODO: this seems to prevent setting style later
50 // TODO: this seems to prevent setting style later
51 // surface.set_style(viewport, theme.get("ui.background"));
51 // surface.set_style(viewport, theme.get("ui.background"));
52
52
53− let area = Rect::new(viewport.x, viewport.height - 2, viewport.width, 1);
53+ let area = Rect::new(
54+ viewport.x,
55+ viewport.y + viewport.height - 2,
56+ viewport.width,
57+ 1,
58+ );
54 self.render_statusline(&view.doc, area, surface, theme, is_focused);
59 self.render_statusline(&view.doc, area, surface, theme, is_focused);
55 }
60 }
56
61
@@ -241,27 +246,34 @@ impl EditorView {
241 theme: &Theme,
246 theme: &Theme,
242 is_focused: bool,
247 is_focused: bool,
243 ) {
248 ) {
244− let text_color = text_color();
245 let mode = match doc.mode() {
249 let mode = match doc.mode() {
246 Mode::Insert => "INS",
250 Mode::Insert => "INS",
247 Mode::Normal => "NOR",
251 Mode::Normal => "NOR",
248 Mode::Goto => "GOTO",
252 Mode::Goto => "GOTO",
249 };
253 };
254+ // TODO: share text_color styles inside theme
255+ let text_color = if is_focused {
256+ Style::default().fg(Color::Rgb(219, 191, 239)) // lilac
257+ } else {
258+ Style::default().fg(Color::Rgb(164, 160, 232)) // lavender
259+ };
250 // statusline
260 // statusline
251 surface.set_style(
261 surface.set_style(
252 Rect::new(viewport.x, viewport.y, viewport.width, 1),
262 Rect::new(viewport.x, viewport.y, viewport.width, 1),
253 theme.get("ui.statusline"),
263 theme.get("ui.statusline"),
254 );
264 );
265+ if is_focused {
255− surface.set_string(viewport.x + 1, viewport.y, mode, text_color);
266+ surface.set_string(viewport.x + 1, viewport.y, mode, text_color);
267+ }
256
268
257 if let Some(path) = doc.relative_path() {
269 if let Some(path) = doc.relative_path() {
258 let path = path.to_string_lossy();
270 let path = path.to_string_lossy();
259− surface.set_string(6, viewport.y, path, text_color);
271+ surface.set_string(viewport.x + 6, viewport.y, path, text_color);
260 // TODO: append [+] if modified
272 // TODO: append [+] if modified
261 }
273 }
262
274
263 surface.set_string(
275 surface.set_string(
264− viewport.width - 10,
276+ viewport.x + viewport.width - 10,
265 viewport.y,
277 viewport.y,
266 format!("{}", doc.diagnostics.len()),
278 format!("{}", doc.diagnostics.len()),
267 text_color,
279 text_color,