wip so i can work on another machine
This commit is contained in:
parent
4a3c5ac492
commit
7388eb1d28
|
@ -11,6 +11,27 @@ pub enum Component {
|
|||
Bg(Color),
|
||||
}
|
||||
|
||||
impl Component {
|
||||
fn make_for_line(
|
||||
comp: Vec<Component>,
|
||||
line: usize,
|
||||
offset: usize,
|
||||
) -> String {
|
||||
comp.into_iter()
|
||||
.map(|c| match c {
|
||||
Component::X(x) => termion::cursor::Goto(
|
||||
(x + offset) as u16,
|
||||
line as u16,
|
||||
)
|
||||
.into(),
|
||||
Component::String(s) => s,
|
||||
Component::Fg(c) => c.fg(),
|
||||
Component::Bg(c) => c.bg(),
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Component {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
match self {
|
||||
|
@ -131,11 +152,34 @@ impl PartialEq for Instruction {
|
|||
}
|
||||
|
||||
impl Instruction {
|
||||
pub fn make(
|
||||
pub fn make_lines(
|
||||
self,
|
||||
(term_width, term_height): (u16, u16),
|
||||
) -> String {
|
||||
todo!()
|
||||
line_width: usize,
|
||||
height_left: usize,
|
||||
) -> Vec<String> {
|
||||
if height_left == 0 {
|
||||
return vec![];
|
||||
}
|
||||
match self {
|
||||
Instruction::FixedHeight(next, lines, wdg) => {
|
||||
let mut offset = 0;
|
||||
let wdg = wdg.into_iter().map(|wdg| {
|
||||
let width = wdg.want_width.abs_size(line_width);
|
||||
(width, wdg)
|
||||
});
|
||||
(0..lines).zip(wdg).map(|(line_index, (width, widget))|{
|
||||
todo!();
|
||||
})
|
||||
let xxx =
|
||||
next.make_lines(line_width, height_left - lines);
|
||||
todo!()
|
||||
}
|
||||
Instruction::End => todo!(),
|
||||
}
|
||||
// let xxx = (0..term_height).map(|index| {
|
||||
// todo!();
|
||||
// });
|
||||
// todo!()
|
||||
}
|
||||
|
||||
pub fn start() -> Self {
|
||||
|
|
|
@ -76,7 +76,7 @@ impl Token {
|
|||
Self::Bg(Box::new(self), c)
|
||||
}
|
||||
|
||||
fn with_width(self, width: usize) -> Vec<Component> {
|
||||
pub fn with_width(self, width: usize) -> Vec<Component> {
|
||||
match self {
|
||||
Token::String(t, s) => vec![Component::String(s)]
|
||||
.into_iter()
|
||||
|
|
Loading…
Reference in New Issue