structured data editor
git clone https://git.lucas.co/cce-data-editor.git
refactor: use cce_ui::color hex parser instead of a local copy
Delegate the local hex-color parse to cce_ui::color::parse_hex_* (single source
of truth), preserving the function signature and gamma handling.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
src/main.rs | 17 +----------------
1 file changed, 1 insertion(+), 16 deletions(-)
diff --git a/src/main.rs b/src/main.rs
index 593ec17..556cde3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2031,22 +2031,7 @@ impl Application for DataEditorApp {
}
fn parse_hex_color_rgba(s: &str) -> Option<[u8; 4]> {
- let s = s.trim_matches(|c| c == '"' || c == '\'' || c == ' ');
- let s = s.trim_start_matches('#');
- if s.len() == 8 {
- let r = u8::from_str_radix(&s[0..2], 16).ok()?;
- let g = u8::from_str_radix(&s[2..4], 16).ok()?;
- let b = u8::from_str_radix(&s[4..6], 16).ok()?;
- let a = u8::from_str_radix(&s[6..8], 16).ok()?;
- Some([r, g, b, a])
- } else if s.len() == 6 {
- let r = u8::from_str_radix(&s[0..2], 16).ok()?;
- let g = u8::from_str_radix(&s[2..4], 16).ok()?;
- let b = u8::from_str_radix(&s[4..6], 16).ok()?;
- Some([r, g, b, 255])
- } else {
- None
- }
+ cce_ui::color::parse_hex_bytes(s)
}
fn parse_hex_color(s: &str) -> Option<[u8; 3]> {