■ ■ ■ ■ ■ ■
alacritty/src/renderer/rects.rs
| skipped 7 lines |
8 | 8 | | use alacritty_terminal::term::cell::Flags; |
9 | 9 | | use alacritty_terminal::term::color::Rgb; |
10 | 10 | | |
| 11 | + | use crate::config::ui_config::Delta; |
11 | 12 | | use crate::display::content::RenderableCell; |
12 | 13 | | use crate::display::SizeInfo; |
13 | 14 | | use crate::gl; |
| skipped 37 lines |
51 | 52 | | } |
52 | 53 | | |
53 | 54 | | impl RenderLine { |
54 | | - | pub fn rects(&self, flag: Flags, metrics: &Metrics, size: &SizeInfo) -> Vec<RenderRect> { |
| 55 | + | pub fn rects( |
| 56 | + | &self, |
| 57 | + | flag: Flags, |
| 58 | + | metrics: &Metrics, |
| 59 | + | size: &SizeInfo, |
| 60 | + | offset: Delta<i8>, |
| 61 | + | ) -> Vec<RenderRect> { |
55 | 62 | | let mut rects = Vec::new(); |
56 | 63 | | |
57 | 64 | | let mut start = self.start; |
58 | 65 | | while start.line < self.end.line { |
59 | 66 | | let end = Point::new(start.line, size.last_column()); |
60 | | - | Self::push_rects(&mut rects, metrics, size, flag, start, end, self.color); |
| 67 | + | Self::push_rects(&mut rects, metrics, size, offset, flag, start, end, self.color); |
61 | 68 | | start = Point::new(start.line + 1, Column(0)); |
62 | 69 | | } |
63 | | - | Self::push_rects(&mut rects, metrics, size, flag, start, self.end, self.color); |
| 70 | + | Self::push_rects(&mut rects, metrics, size, offset, flag, start, self.end, self.color); |
64 | 71 | | |
65 | 72 | | rects |
66 | 73 | | } |
67 | 74 | | |
68 | 75 | | /// Push all rects required to draw the cell's line. |
| 76 | + | #[allow(clippy::too_many_arguments)] |
69 | 77 | | fn push_rects( |
70 | 78 | | rects: &mut Vec<RenderRect>, |
71 | 79 | | metrics: &Metrics, |
72 | 80 | | size: &SizeInfo, |
| 81 | + | offset: Delta<i8>, |
73 | 82 | | flag: Flags, |
74 | 83 | | start: Point<usize>, |
75 | 84 | | end: Point<usize>, |
| skipped 7 lines |
83 | 92 | | |
84 | 93 | | rects.push(Self::create_rect( |
85 | 94 | | size, |
| 95 | + | offset, |
86 | 96 | | metrics.descent, |
87 | 97 | | start, |
88 | 98 | | end, |
| skipped 22 lines |
111 | 121 | | _ => unimplemented!("Invalid flag for cell line drawing specified"), |
112 | 122 | | }; |
113 | 123 | | |
114 | | - | let mut rect = |
115 | | - | Self::create_rect(size, metrics.descent, start, end, position, thickness, color); |
| 124 | + | let mut rect = Self::create_rect( |
| 125 | + | size, |
| 126 | + | offset, |
| 127 | + | metrics.descent, |
| 128 | + | start, |
| 129 | + | end, |
| 130 | + | position, |
| 131 | + | thickness, |
| 132 | + | color, |
| 133 | + | ); |
116 | 134 | | rect.kind = ty; |
117 | 135 | | rects.push(rect); |
118 | 136 | | } |
119 | 137 | | |
120 | 138 | | /// Create a line's rect at a position relative to the baseline. |
| 139 | + | #[allow(clippy::too_many_arguments)] |
121 | 140 | | fn create_rect( |
122 | 141 | | size: &SizeInfo, |
| 142 | + | offset: Delta<i8>, |
123 | 143 | | descent: f32, |
124 | 144 | | start: Point<usize>, |
125 | 145 | | end: Point<usize>, |
| skipped 11 lines |
137 | 157 | | let line_bottom = (start.line as f32 + 1.) * size.cell_height(); |
138 | 158 | | let baseline = line_bottom + descent; |
139 | 159 | | |
140 | | - | let mut y = (baseline - position - thickness / 2.).round(); |
| 160 | + | let mut y = (baseline - position - offset.y as f32 - thickness / 2.).round(); |
141 | 161 | | let max_y = line_bottom - thickness; |
142 | 162 | | if y > max_y { |
143 | 163 | | y = max_y; |
| skipped 23 lines |
167 | 187 | | } |
168 | 188 | | |
169 | 189 | | #[inline] |
170 | | - | pub fn rects(&self, metrics: &Metrics, size: &SizeInfo) -> Vec<RenderRect> { |
| 190 | + | pub fn rects(&self, metrics: &Metrics, size: &SizeInfo, offset: Delta<i8>) -> Vec<RenderRect> { |
171 | 191 | | self.inner |
172 | 192 | | .iter() |
173 | 193 | | .flat_map(|(flag, lines)| { |
174 | | - | lines.iter().flat_map(move |line| line.rects(*flag, metrics, size)) |
| 194 | + | lines.iter().flat_map(move |line| line.rects(*flag, metrics, size, offset)) |
175 | 195 | | }) |
176 | 196 | | .collect() |
177 | 197 | | } |
| skipped 310 lines |