@@ -36,6 +36,7 @@ impl EditorView {
36 viewport: Rect,
36 viewport: Rect,
37 surface: &mut Surface,
37 surface: &mut Surface,
38 theme: &Theme,
38 theme: &Theme,
40 let area = Rect::new(
41 let area = Rect::new(
41 viewport.x + OFFSET,
42 viewport.x + OFFSET,
@@ -43,14 +44,14 @@ impl EditorView {
43 viewport.width - OFFSET,
44 viewport.width - OFFSET,
44 viewport.height - 2,
45 viewport.height - 2,
45 ); // - 2 for statusline and prompt
46 ); // - 2 for statusline and prompt
46− self.render_buffer(view, area, surface, theme);
47+ self.render_buffer(view, area, surface, theme, is_focused);
48 // clear with background color
49 // clear with background color
49 // TODO: this seems to prevent setting style later
50 // TODO: this seems to prevent setting style later
50 // surface.set_style(viewport, theme.get("ui.background"));
51 // surface.set_style(viewport, theme.get("ui.background"));
52 let area = Rect::new(viewport.x, viewport.height - 2, viewport.width, 1);
53 let area = Rect::new(viewport.x, viewport.height - 2, viewport.width, 1);
53− self.render_statusline(&view.doc, area, surface, theme);
54+ self.render_statusline(&view.doc, area, surface, theme, is_focused);
56 // TODO: ideally not &mut View but highlights require it because of cursor cache
57 // TODO: ideally not &mut View but highlights require it because of cursor cache
@@ -60,6 +61,7 @@ impl EditorView {
60 viewport: Rect,
61 viewport: Rect,
61 surface: &mut Surface,
62 surface: &mut Surface,
62 theme: &Theme,
63 theme: &Theme,
64 // TODO: inefficient, should feed chunks.iter() to tree_sitter.parse_with(|offset, pos|)
66 // TODO: inefficient, should feed chunks.iter() to tree_sitter.parse_with(|offset, pos|)
65 let source_code = view.doc.text().to_string();
67 let source_code = view.doc.text().to_string();
@@ -93,16 +95,20 @@ impl EditorView {
93 let mut spans = Vec::new();
95 let mut spans = Vec::new();
94 let mut visual_x = 0;
96 let mut visual_x = 0;
95 let mut line = 0u16;
97 let mut line = 0u16;
96− let visible_selections: Vec<Range> = view
98+ let visible_selections: Vec<Range> = if is_focused {
99− .selection()
101+ .selection()
100− .ranges()
102+ .ranges()
102− // TODO: limit selection to one in viewport
104+ // TODO: limit selection to one in viewport
103− // .filter(|range| !range.is_empty()) // && range.overlaps(&Range::new(start, end + 1))
105+ // .filter(|range| !range.is_empty()) // && range.overlaps(&Range::new(start, end + 1))
104− .copied()
106+ .copied()
105− .collect();
107+ .collect()
109+ // don't render selections on unfocused windows
107 'outer: for event in highlights {
113 'outer: for event in highlights {
108 match event.unwrap() {
114 match event.unwrap() {
@@ -233,6 +239,7 @@ impl EditorView {
233 viewport: Rect,
239 viewport: Rect,
234 surface: &mut Surface,
240 surface: &mut Surface,
235 theme: &Theme,
241 theme: &Theme,
237 let text_color = text_color();
244 let text_color = text_color();
238 let mode = match doc.mode() {
245 let mode = match doc.mode() {
@@ -322,9 +329,9 @@ impl Component for EditorView {
322 // SAFETY: we cheat around the view_mut() borrow because it doesn't allow us to also borrow
329 // SAFETY: we cheat around the view_mut() borrow because it doesn't allow us to also borrow
323 // theme. Theme is immutable mutating view won't disrupt theme_ref.
330 // theme. Theme is immutable mutating view won't disrupt theme_ref.
324 let theme_ref = unsafe { &*(&cx.editor.theme as *const Theme) };
331 let theme_ref = unsafe { &*(&cx.editor.theme as *const Theme) };
325− for view in cx.editor.tree.views() {
332+ for (view, is_focused) in cx.editor.tree.views() {
326 // TODO: use parent area
333 // TODO: use parent area
327− self.render_view(view, view.area, surface, theme_ref);
334+ self.render_view(view, view.area, surface, theme_ref, is_focused);
330 // TODO: drop unwrap
337 // TODO: drop unwrap