Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
style: move get_alignment_offset below layout()
Browse files Browse the repository at this point in the history
  • Loading branch information
joshka committed Apr 12, 2024
1 parent e5f288e commit d3869ec
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/big_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,6 @@ impl Widget for BigText<'_> {
}
}

fn get_alignment_offset<'a>(
area_width: u16,
letter_width: u16,
alignment: Alignment,
line: &'a Line<'a>,
) -> u16 {
let big_line_width = line.width() as u16 * letter_width;
match alignment {
Alignment::Center => (area_width / 2).saturating_sub(big_line_width / 2),
Alignment::Right => area_width.saturating_sub(big_line_width),
Alignment::Left => 0,
}
}

/// Chunk the area into as many x*y cells as possible returned as a 2D iterator of `Rect`s
/// representing the rows of cells. The size of each cell depends on given font size
fn layout<'a>(
Expand Down Expand Up @@ -137,6 +123,20 @@ fn layout<'a>(
})
}

fn get_alignment_offset<'a>(
area_width: u16,
letter_width: u16,
alignment: Alignment,
line: &'a Line<'a>,
) -> u16 {
let big_line_width = line.width() as u16 * letter_width;
match alignment {
Alignment::Center => (area_width / 2).saturating_sub(big_line_width / 2),
Alignment::Right => area_width.saturating_sub(big_line_width),
Alignment::Left => 0,
}
}

/// Render a single grapheme into a cell by looking up the corresponding 8x8 bitmap in the
/// `BITMAPS` array and setting the corresponding cells in the buffer.
fn render_symbol(grapheme: StyledGrapheme, area: Rect, buf: &mut Buffer, pixel_size: &PixelSize) {
Expand Down

0 comments on commit d3869ec

Please sign in to comment.