forked from Anri/cal8tor
support bigcell format
This commit is contained in:
parent
f62c8498ca
commit
3fe5529842
1 changed files with 30 additions and 4 deletions
34
src/utils.rs
34
src/utils.rs
|
@ -17,7 +17,13 @@ fn err_code(code: i32) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Print a line for the table
|
/// Print a line for the table
|
||||||
pub fn line_table(cell_length: usize, number_cell: usize, pos: models::Position, skip_with: std::collections::HashMap<usize, &str>) {
|
pub fn line_table(
|
||||||
|
cell_length_hours: usize,
|
||||||
|
cell_length: usize,
|
||||||
|
number_cell: usize,
|
||||||
|
pos: models::Position,
|
||||||
|
skip_with: std::collections::HashMap<usize, &str>,
|
||||||
|
) {
|
||||||
// Left side
|
// Left side
|
||||||
let ls = match pos {
|
let ls = match pos {
|
||||||
models::Position::Top => models::TabChar::Jtl.val(),
|
models::Position::Top => models::TabChar::Jtl.val(),
|
||||||
|
@ -39,14 +45,34 @@ pub fn line_table(cell_length: usize, number_cell: usize, pos: models::Position,
|
||||||
models::Position::Bottom => models::TabChar::Jbr.val(),
|
models::Position::Bottom => models::TabChar::Jbr.val(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Right side before big cell
|
||||||
|
let rs_bbc = models::TabChar::Jr.val();
|
||||||
|
// Right side big cell before big cell
|
||||||
|
let rsbc_bbc = models::TabChar::Bv.val();
|
||||||
|
// Right side big cell
|
||||||
|
let rsbc = models::TabChar::Jl.val();
|
||||||
|
|
||||||
let line = models::TabChar::Bh.val().to_string().repeat(cell_length);
|
let line = models::TabChar::Bh.val().to_string().repeat(cell_length);
|
||||||
|
let line_h = models::TabChar::Bh
|
||||||
|
.val()
|
||||||
|
.to_string()
|
||||||
|
.repeat(cell_length_hours);
|
||||||
|
|
||||||
// Print the line
|
// Print the line
|
||||||
print!("\n{}{}{}", ls, line, ms);
|
print!("\n{}{}{}", ls, line_h, ms);
|
||||||
for i in 0..number_cell - 2 {
|
for i in 0..number_cell - 2 {
|
||||||
|
// Check if it's a big cell
|
||||||
match skip_with.get(&i) {
|
match skip_with.get(&i) {
|
||||||
Some(text) => print!("{:^cell_length$}{}", text, ms),
|
Some(text) => match skip_with.get(&(i + 1)) {
|
||||||
None => print!("{}{}", line, ms),
|
// Match check if the next cell will be big
|
||||||
|
Some(_) => print!("{:^cell_length$}{}", text, rsbc_bbc),
|
||||||
|
None => print!("{:^cell_length$}{}", text, rsbc),
|
||||||
|
},
|
||||||
|
None => match skip_with.get(&(i + 1)) {
|
||||||
|
// Match check if the next cell will be big
|
||||||
|
Some(_) => print!("{}{}", line, rs_bbc),
|
||||||
|
None => print!("{}{}", line, ms),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println!("{}{}", line, rs);
|
println!("{}{}", line, rs);
|
||||||
|
|
Loading…
Reference in a new issue