Update color parsing

This commit is contained in:
Dheepak Krishnamurthy 2020-08-02 11:13:54 -06:00
parent d44bfa9519
commit 6e6b6857c0
2 changed files with 65 additions and 31 deletions

View file

@ -828,27 +828,27 @@ mod tests {
#[test]
fn test_app() {
let mut app = TTApp::new();
app.update();
// let mut app = TTApp::new();
// app.update();
//println!("{:?}", app.tasks);
// //println!("{:?}", app.tasks);
//println!("{:?}", app.task_report_columns);
//println!("{:?}", app.task_report_labels);
// //println!("{:?}", app.task_report_columns);
// //println!("{:?}", app.task_report_labels);
let (t, h, c) = app.task_report();
app.next();
app.next();
app.modify = "Cannot add this string ' because it has a single quote".to_string();
println!("{}", app.modify);
// if let Ok(tasks) = import(stdin()) {
// for task in tasks {
// println!("Task: {}, entered {:?} is {} -> {}",
// task.uuid(),
// task.entry(),
// task.status(),
// task.description());
// }
// }
// let (t, h, c) = app.task_report();
// app.next();
// app.next();
// app.modify = "Cannot add this string ' because it has a single quote".to_string();
// println!("{}", app.modify);
// // if let Ok(tasks) = import(stdin()) {
// // for task in tasks {
// // println!("Task: {}, entered {:?} is {} -> {}",
// // task.uuid(),
// // task.entry(),
// // task.status(),
// // task.description());
// // }
// // }
}
}

View file

@ -58,24 +58,58 @@ pub struct TColor {
}
pub fn get_color(line: &str) -> RGB {
if line.starts_with("color") {
RGB {
let sline = line.split(" ").collect::<Vec<&str>>();
if sline.len() == 1 {
return RGB {
r : 0.0,
g : 0.0,
b : 0.0,
}
} else if line.starts_with("rgb") {
let c = line.split(" ").collect::<Vec<&str>>()[1];
RGB {
r : c.as_bytes()[3] as f32,
g : c.as_bytes()[4] as f32,
b : c.as_bytes()[5] as f32,
}
if line.contains(" on ") {
let foreground = line.split(" ").collect::<Vec<&str>>()[1];
let background = line.split(" ").collect::<Vec<&str>>()[3];
if foreground.starts_with("color") {
// TODO: get the correct color here
RGB {
r : 0.0,
g : 0.0,
b : 0.0,
}
} else if foreground.starts_with("rgb") {
RGB {
r : foreground.as_bytes()[3] as f32,
g : foreground.as_bytes()[4] as f32,
b : foreground.as_bytes()[5] as f32,
}
} else {
RGB {
r : 0.0,
g : 0.0,
b : 0.0,
}
}
} else {
RGB {
r : 0.0,
g : 0.0,
b : 0.0,
let foreground = line.split(" ").collect::<Vec<&str>>()[1];
if foreground.starts_with("color") {
// TODO: get the correct color here
RGB {
r : 0.0,
g : 0.0,
b : 0.0,
}
} else if foreground.starts_with("rgb") {
RGB {
r : foreground.as_bytes()[3] as f32,
g : foreground.as_bytes()[4] as f32,
b : foreground.as_bytes()[5] as f32,
}
} else {
RGB {
r : 0.0,
g : 0.0,
b : 0.0,
}
}
}
}