mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
wip: remodularize 2
This commit is contained in:
parent
3b6ff81dad
commit
d38dc14e84
27 changed files with 564 additions and 563 deletions
|
|
@ -18,6 +18,7 @@ mod tui_style; pub use self::tui_style::*;
|
|||
mod tui_theme; pub use self::tui_theme::*;
|
||||
mod tui_border; pub use self::tui_border::*;
|
||||
mod tui_field; pub use self::tui_field::*;
|
||||
mod tui_buffer; pub use self::tui_buffer::*;
|
||||
|
||||
pub(crate) use std::sync::{Arc, RwLock, atomic::{AtomicUsize, AtomicBool, Ordering::*}};
|
||||
pub(crate) use std::io::{stdout, Stdout};
|
||||
|
|
|
|||
27
tui/src/tui_buffer.rs
Normal file
27
tui/src/tui_buffer.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
use crate::*;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct BigBuffer {
|
||||
pub width: usize,
|
||||
pub height: usize,
|
||||
pub content: Vec<Cell>
|
||||
}
|
||||
|
||||
impl BigBuffer {
|
||||
pub fn new (width: usize, height: usize) -> Self {
|
||||
Self { width, height, content: vec![Cell::default(); width*height] }
|
||||
}
|
||||
pub fn get (&self, x: usize, y: usize) -> Option<&Cell> {
|
||||
let i = self.index_of(x, y);
|
||||
self.content.get(i)
|
||||
}
|
||||
pub fn get_mut (&mut self, x: usize, y: usize) -> Option<&mut Cell> {
|
||||
let i = self.index_of(x, y);
|
||||
self.content.get_mut(i)
|
||||
}
|
||||
pub fn index_of (&self, x: usize, y: usize) -> usize {
|
||||
y * self.width + x
|
||||
}
|
||||
}
|
||||
|
||||
from!(|size:(usize, usize)| BigBuffer = Self::new(size.0, size.1));
|
||||
Loading…
Add table
Add a link
Reference in a new issue