git.lucas.co / cce-data-editor
structured data editor
git clone https://git.lucas.co/cce-data-editor.git

commit10d20eb90c1efdeb565a4b0783c1335404e9ddc3
parent9c6cf712c2
authorLucas Galante <[email protected]>
date2026-06-29 14:24
Group configuration styling properties into nested nodes (Option C)

 src/main.rs | 64 +++++++++++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 47 insertions(+), 17 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index bf08aba..1673bd5 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -339,28 +339,58 @@ impl DataEditorApp {
                 out.push_str(&format!("{} {{\n", sec_name));
                 if let serde_json::Value::Object(sec_map) = sec_val {
                     for (key, k_val) in sec_map {
-                        let (val_str, val_ty) = match k_val {
-                            serde_json::Value::Bool(b) => (b.to_string(), Some("bool")),
-                            serde_json::Value::Number(num) => {
-                                if num.is_f64() {
-                                    (num.to_string(), Some("f64"))
+                        if let serde_json::Value::Object(nested_map) = k_val {
+                            let mut prop_parts = Vec::new();
+                            for (prop_name, prop_val) in nested_map {
+                                let (val_str, val_ty) = match prop_val {
+                                    serde_json::Value::Bool(b) => (b.to_string(), Some("bool")),
+                                    serde_json::Value::Number(num) => {
+                                        if num.is_f64() {
+                                            (num.to_string(), Some("f64"))
+                                        } else {
+                                            (num.to_string(), Some("i64"))
+                                        }
+                                    }
+                                    serde_json::Value::String(s) => {
+                                        if s.starts_with('#') {
+                                            (format!("\"{}\"", s), Some("color"))
+                                        } else {
+                                            (format!("\"{}\"", s), None)
+                                        }
+                                    }
+                                    _ => (prop_val.to_string(), None),
+                                };
+                                if let Some(ty) = val_ty {
+                                    prop_parts.push(format!("{}=({}){}", prop_name, ty, val_str));
                                 } else {
-                                    (num.to_string(), Some("i64"))
+                                    prop_parts.push(format!("{}={}", prop_name, val_str));
                                 }
                             }
-                            serde_json::Value::String(s) => {
-                                if s.starts_with('#') {
-                                    (format!("\"{}\"", s), Some("color"))
-                                } else {
-                                    (format!("\"{}\"", s), None)
+                            out.push_str(&format!("    {} {}\n", key, prop_parts.join(" ")));
+                        } else {
+                            let (val_str, val_ty) = match k_val {
+                                serde_json::Value::Bool(b) => (b.to_string(), Some("bool")),
+                                serde_json::Value::Number(num) => {
+                                    if num.is_f64() {
+                                        (num.to_string(), Some("f64"))
+                                    } else {
+                                        (num.to_string(), Some("i64"))
+                                    }
+                                }
+                                serde_json::Value::String(s) => {
+                                    if s.starts_with('#') {
+                                        (format!("\"{}\"", s), Some("color"))
+                                    } else {
+                                        (format!("\"{}\"", s), None)
+                                    }
                                 }
+                                _ => (k_val.to_string(), None),
+                            };
+                            if let Some(ty) = val_ty {
+                                out.push_str(&format!("    {} ({}){}\n", key, ty, val_str));
+                            } else {
+                                out.push_str(&format!("    {} {}\n", key, val_str));
                             }
-                            _ => (k_val.to_string(), None),
-                        };
-                        if let Some(ty) = val_ty {
-                            out.push_str(&format!("    {} ({}){}\n", key, ty, val_str));
-                        } else {
-                            out.push_str(&format!("    {} {}\n", key, val_str));
                         }
                     }
                 }