@@ -87,33 +87,23 @@ enum RenderStepKind {
8787
8888pub fn snapshot_all_grids (
8989 cell_metrics : & CellMetrics ,
90+ mono_metrics : & CellMetrics ,
9091 gridmap : & GridMap ,
9192 pix_gridmap : & PixGridMap ,
9293 hl : & HighlightMap ,
9394) -> Option < gsk:: RenderNode > {
9495 let mut snapshot = gtk:: Snapshot :: new ( ) ;
9596 let grids = gridmap. sorted_visible ( ) ;
96-
9797 for ( id, grid) in grids. iter ( ) {
98- if let Some ( pix_grid) = pix_gridmap. get ( * id) {
99- if pix_grid. columns != grid. model . columns {
100- snapshot_grid (
101- & mut snapshot,
102- cell_metrics,
103- & grid,
104- & PixGrid :: new ( grid, cell_metrics, 0.0 ) ,
105- hl,
106- ) ;
107- } else {
108- snapshot_grid ( & mut snapshot, cell_metrics, & grid, pix_grid, hl) ;
109- }
98+ let pix_grid = pix_gridmap. get ( * id) . unwrap ( ) ;
99+ let cm = if grid. monospace {
100+ mono_metrics
110101 } else {
111- eprintln ! ( "missing PixGrid {id}" ) ;
112- }
102+ cell_metrics
103+ } ;
104+ snapshot_grid ( & mut snapshot, cm, & grid, pix_grid, hl) ;
113105 }
114-
115106 snapshot_pmenu ( & mut snapshot, gridmap, pix_gridmap, cell_metrics, hl) ;
116-
117107 snapshot. to_node ( )
118108}
119109
@@ -252,20 +242,38 @@ fn snapshot_text(
252242 hl : & HighlightMap ,
253243) {
254244 let line_height = cell_metrics. line_height as f32 ;
255- let mut y = ( line_height * grid. start_row as f32 ) + cell_metrics. ascent as f32 ;
256- for ( row, line) in model. iter ( ) . enumerate ( ) {
257- let pix_row = & pix_grid. matrix [ row] ;
258- for ( col, cell) in line. line . iter ( ) . enumerate ( ) {
259- snapshot_cell (
260- & snapshot,
261- & line. item_line [ col] ,
262- hl,
263- cell,
264- pix_row[ col] as f32 ,
265- y,
266- ) ;
245+ let mut y = ( pix_grid. start_y + cell_metrics. ascent ) as f32 ;
246+ if !grid. monospace {
247+ for ( row, line) in model. iter ( ) . enumerate ( ) {
248+ let pix_row = & pix_grid. matrix [ row] ;
249+ for ( col, cell) in line. line . iter ( ) . enumerate ( ) {
250+ snapshot_cell (
251+ & snapshot,
252+ & line. item_line [ col] ,
253+ hl,
254+ cell,
255+ pix_row[ col] as f32 ,
256+ y,
257+ ) ;
258+ }
259+ y += line_height;
260+ }
261+ } else {
262+ let char_width = cell_metrics. char_width as f32 ;
263+ let mut y = ( pix_grid. start_y + cell_metrics. ascent ) as f32 ;
264+ for line in model {
265+ for ( col, cell) in line. line . iter ( ) . enumerate ( ) {
266+ snapshot_cell (
267+ & snapshot,
268+ & line. item_line [ col] ,
269+ hl,
270+ cell,
271+ pix_grid. start_x as f32 + ( col as f32 * char_width) ,
272+ y,
273+ ) ;
274+ }
275+ y += line_height;
267276 }
268- y += line_height;
269277 }
270278}
271279
@@ -293,7 +301,8 @@ fn snapshot_pmenu(
293301 }
294302 let model = pmenu. model . model ( ) ;
295303 let start_x = anchor_pix. matrix [ row as usize ] [ col as usize ] as f64 ;
296- let pmenu_pix_grid = PixGrid :: new ( pmenu, cell_metrics, start_x) ;
304+ let start_y = pmenu. start_y ( cell_metrics) ;
305+ let pmenu_pix_grid = PixGrid :: new ( pmenu, cell_metrics, start_x, start_y) ;
297306 grid_bg ( snapshot, & pmenu_pix_grid, hl. bg ( ) ) ;
298307 snapshot_text ( snapshot, cell_metrics, model, pmenu, & pmenu_pix_grid, hl) ;
299308 grid_border ( snapshot, pmenu, & pmenu_pix_grid, hl) ;
@@ -303,6 +312,7 @@ pub fn snapshot_cursor<T: CursorRedrawCb + 'static>(
303312 snapshot : & gtk:: Snapshot ,
304313 cursor : & Cursor < T > ,
305314 font_ctx : & Context ,
315+ mono_ctx : & Context ,
306316 grid : & Grid ,
307317 hl : & HighlightMap ,
308318 transparency : TransparencySettings ,
@@ -313,7 +323,15 @@ pub fn snapshot_cursor<T: CursorRedrawCb + 'static>(
313323
314324 let ui_model = & grid. model ;
315325
316- let cell_metrics = font_ctx. cell_metrics ( ) ;
326+ // TODO monospace: i use this A LOT. it may be a macro?
327+ let ctx = if grid. monospace {
328+ mono_ctx
329+ } else {
330+ font_ctx
331+ } ;
332+
333+ let cell_metrics = ctx. cell_metrics ( ) ;
334+
317335 let CellMetrics { ascent, .. } = * cell_metrics;
318336 let ( cursor_row, cursor_col) = ui_model. get_flushed_cursor ( ) ;
319337
@@ -325,6 +343,7 @@ pub fn snapshot_cursor<T: CursorRedrawCb + 'static>(
325343 } ;
326344
327345 let space_size: i32 = cell_metrics. char_width as i32 ;
346+
328347 let ( pixel_width, x, until_x) =
329348 cursor_x ( cursor_line, cursor_col, space_size, grid. sign_column_len ( ) ) ;
330349 let x = ( x as f64 + grid. start_x ( cell_metrics) ) as i32 ;
@@ -352,7 +371,7 @@ pub fn snapshot_cursor<T: CursorRedrawCb + 'static>(
352371
353372 cursor. snapshot (
354373 snapshot,
355- font_ctx ,
374+ ctx ,
356375 ( x, y) ,
357376 cell,
358377 hl,
0 commit comments