mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
big ass refactor (rip client)
This commit is contained in:
parent
94c1f83ef2
commit
8c3cf53c67
56 changed files with 2232 additions and 1891 deletions
|
|
@ -1,33 +0,0 @@
|
|||
use crate::core::*;
|
||||
|
||||
pub struct Cell<T> {
|
||||
text: String,
|
||||
style: Option<Style>,
|
||||
width: u16,
|
||||
height: u16,
|
||||
data: T
|
||||
}
|
||||
|
||||
impl<T> Cell<T> {
|
||||
pub fn new (text: &str, data: T) -> Self {
|
||||
Self { text: text.to_string(), style: None, width: text.len() as u16, height: 1, data }
|
||||
}
|
||||
pub fn draw (&self, buf: &mut Buffer, x: u16, y: u16) {
|
||||
self.text.blit(buf, x, y, self.style)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Table<T> {
|
||||
columns: Vec<Vec<Cell<T>>>,
|
||||
row: usize,
|
||||
col: usize,
|
||||
}
|
||||
|
||||
impl<T> Table<T> {
|
||||
pub fn new (columns: Vec<Vec<Cell<T>>>) -> Self {
|
||||
Self { columns, row: 0, col: 0 }
|
||||
}
|
||||
pub fn set (&mut self, col: usize, row: usize, cell: Cell<T>) {
|
||||
self.columns[col][row] = cell;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue