Skip to content

Commit 63066f5

Browse files
committed
check for hex in valid values from Configuration.tex
1 parent 50be8a1 commit 63066f5

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

octool

0 Bytes
Binary file not shown.

src/edit.rs

+18-16
Original file line numberDiff line numberDiff line change
@@ -578,22 +578,24 @@ fn edit_int(val: &mut Integer, valid_values: &Vec<String>, stdout: &mut RawTermi
578578
if hex_val.contains(' ') {
579579
hex_val = hex_val.split(" ").next().unwrap().trim().to_owned();
580580
}
581-
let dec_val = i64::from_str_radix(&hex_val[2..], 16).unwrap();
582-
if dec_val & new_int == dec_val {
583-
write!(stdout, "\x1b[32m").unwrap();
584-
if hit_space && i == selected {
585-
new_int -= dec_val;
586-
new = new_int.to_string();
587-
hit_space = false;
588-
write!(stdout, "\x1b[31m").unwrap();
589-
}
590-
} else {
591-
write!(stdout, "\x1b[31m").unwrap();
592-
if hit_space && i == selected {
593-
new_int += dec_val;
594-
new = new_int.to_string();
595-
hit_space = false;
581+
if hex_val.len() > 2 && &hex_val[..2] == "0x" {
582+
let dec_val = i64::from_str_radix(&hex_val[2..], 16).unwrap();
583+
if dec_val & new_int == dec_val {
596584
write!(stdout, "\x1b[32m").unwrap();
585+
if hit_space && i == selected {
586+
new_int -= dec_val;
587+
new = new_int.to_string();
588+
hit_space = false;
589+
write!(stdout, "\x1b[31m").unwrap();
590+
}
591+
} else {
592+
write!(stdout, "\x1b[31m").unwrap();
593+
if hit_space && i == selected {
594+
new_int += dec_val;
595+
new = new_int.to_string();
596+
hit_space = false;
597+
write!(stdout, "\x1b[32m").unwrap();
598+
}
597599
}
598600
}
599601
write!(stdout, "{}\x1b[0m\x1B[0K\r\n", vals).unwrap();
@@ -661,7 +663,7 @@ fn edit_string(
661663
let mut selected = valid_values.len();
662664
if valid_values.len() > 0 {
663665
for (i, vals) in valid_values.iter().enumerate() {
664-
if vals.contains(&new) {
666+
if vals.split("---").next().unwrap().trim() == &new {
665667
selected = i;
666668
}
667669
}

src/res.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ pub fn show_res_path(resources: &Resources, settings: &Settings, stdout: &mut Ra
301301
.unwrap();
302302
}
303303
}
304-
_ => write!(stdout, "{}false\x1B[0m\x1b0K\r\n", color::Fg(color::Red)).unwrap(),
304+
_ => write!(stdout, "{}false\x1B[0m\x1b[0K\r\n", color::Fg(color::Red)).unwrap(),
305305
}
306306

307307
/* write!(

0 commit comments

Comments
 (0)