diff --git a/src/app/widgets/cell.rs b/src/app/widgets/cell.rs index c8ac0ad..b24a37f 100644 --- a/src/app/widgets/cell.rs +++ b/src/app/widgets/cell.rs @@ -24,13 +24,34 @@ impl CellWidget { pub fn new(row: usize, col: usize) -> Self { Self { row, col } } + + fn col_to_letters(&self) -> String { + let mut col: usize = self.col + 1; + let mut letters: Vec = Vec::new(); + + while col > 0 { + letters.push((b'A' + ((col - 1) % 26) as u8) as char); + col = (col - 1) / 26; + } + + letters.iter().rev().collect() + } + + pub fn display_coords(&self) -> String { + format!("{}{}", self.col_to_letters(), self.row) + } } impl Widget for CellWidget { fn render(self, area: Rect, buf: &mut Buffer) { - Paragraph::new(format!("{}/{}", self.row, self.col)) + Paragraph::new("") .alignment(Alignment::Center) - .block(Block::default().borders(Borders::ALL).white()) + .block( + Block::default() + .borders(Borders::ALL) + .white() + .title(self.display_coords().green()), + ) .render(area, buf); } }