mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-25 08:47:18 +02:00
Update color parsing
This commit is contained in:
parent
d44bfa9519
commit
6e6b6857c0
2 changed files with 65 additions and 31 deletions
38
src/app.rs
38
src/app.rs
|
@ -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());
|
||||
// // }
|
||||
// // }
|
||||
}
|
||||
}
|
||||
|
|
46
src/color.rs
46
src/color.rs
|
@ -58,18 +58,29 @@ pub struct TColor {
|
|||
}
|
||||
|
||||
pub fn get_color(line: &str) -> RGB {
|
||||
if line.starts_with("color") {
|
||||
let sline = line.split(" ").collect::<Vec<&str>>();
|
||||
if sline.len() == 1 {
|
||||
return RGB {
|
||||
r : 0.0,
|
||||
g : 0.0,
|
||||
b : 0.0,
|
||||
}
|
||||
}
|
||||
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 line.starts_with("rgb") {
|
||||
let c = line.split(" ").collect::<Vec<&str>>()[1];
|
||||
} else if foreground.starts_with("rgb") {
|
||||
RGB {
|
||||
r : c.as_bytes()[3] as f32,
|
||||
g : c.as_bytes()[4] as f32,
|
||||
b : c.as_bytes()[5] as f32,
|
||||
r : foreground.as_bytes()[3] as f32,
|
||||
g : foreground.as_bytes()[4] as f32,
|
||||
b : foreground.as_bytes()[5] as f32,
|
||||
}
|
||||
} else {
|
||||
RGB {
|
||||
|
@ -78,6 +89,29 @@ pub fn get_color(line: &str) -> RGB {
|
|||
b : 0.0,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
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,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TColor {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue