termiflow 0.1.0

Terminal-native Mermaid flowchart renderer — jq for diagrams
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
//! Border styles and character sets
//!
//! See SPEC §4 for complete character definitions

// Re-export spacing defaults so legacy call sites can keep using style:: constants.
pub use crate::display_profile::{
    display_char_width, display_width, graphemes, split_text_to_width_chunks, truncate_to_width,
    DisplayProfile, DEFAULT_DISPLAY_PROFILE,
};
pub use crate::spacing::{
    BOX_HEIGHT, BOX_MIN_WIDTH, BOX_PADDING, COL_SPACING, CYCLE_GUTTER, EDGE_DROP_HEIGHT,
    EDGE_JUNCTION_HEIGHT, MAX_CANVAS_HEIGHT, MAX_CANVAS_WIDTH, MAX_LABEL_WIDTH, ROW_SPACING,
    STEM_LENGTH_HORIZONTAL, STEM_LENGTH_VERTICAL, SUBGRAPH_GUTTER,
};

/// Border style variants
#[derive(Debug, Clone, Copy, PartialEq, Default)]
pub enum BaseStyle {
    Ascii,
    #[default]
    Unicode,
    Double,
    Rounded,
    Heavy,
    Dots,   // • for corners
    Plus,   // + for corners
    Stars,  // * for corners
    Blocks, // █ for lines
}

/// Component-specific style configuration
///
/// Each component can be styled independently using any BorderStyle:
/// - `corner` - Box corners (┌┐└┘ for unicode, ╭╮╰╯ for rounded, ╔╗╚╝ for double, • for dots, * for stars, etc.)
/// - `border` - Box borders/lines (─│ for unicode, ═║ for double, ━┃ for heavy, etc.)
/// - `arrow` - Arrow heads (▼◀▶ for unicode, v<> for ascii)
/// - `edge` - Connection lines between boxes
/// - `junction` - T-junctions where edges meet (┬┴├┤ for unicode, ╦╩╠╣ for double, etc.)
/// - `back` - Back edges for cycles (dotted/dashed lines)
/// - `subgraph` - Subgraph container borders (defaults to ascii for visual distinction)
#[derive(Debug, Clone, Default)]
pub struct CompositeStyle {
    pub corner: Option<BaseStyle>,   // Box corners
    pub border: Option<BaseStyle>,   // Box borders (h/v lines)
    pub arrow: Option<BaseStyle>,    // Arrow heads
    pub edge: Option<BaseStyle>,     // Edge/connection lines
    pub junction: Option<BaseStyle>, // Junction characters
    pub back: Option<BaseStyle>,     // Back edges for cycles
    pub subgraph: Option<BaseStyle>, // Subgraph container borders
}

/// Character set for a border style
#[derive(Debug, Clone, Copy)]
pub struct StyleChars {
    // Box corners
    pub tl: char, // top-left
    pub tr: char, // top-right
    pub bl: char, // bottom-left
    pub br: char, // bottom-right
    pub h: char,  // horizontal
    pub v: char,  // vertical

    // Arrows for all four directions
    pub arrow_down: char,
    pub arrow_up: char,
    pub arrow_left: char,
    pub arrow_right: char,

    // Edges
    pub edge_h: char,
    pub edge_v: char,
    pub corner_dr: char, // down-right
    pub corner_dl: char, // down-left
    pub corner_ur: char, // up-right
    pub corner_ul: char, // up-left
    pub cross: char,

    // Junctions (T-shapes for edge branching/merging)
    pub junction_down: char,  // ┬ - stem above, branches below
    pub junction_up: char,    // ┴ - stem below, branches above
    pub junction_right: char, // ├ - stem left, branches right
    pub junction_left: char,  // ┤ - stem right, branches left

    // Back-edges
    pub back_h: char,
    pub back_v: char,

    // Dotted/dashed edges (-.->)
    pub dotted_h: char,
    pub dotted_v: char,

    // End markers (--o / --x)
    pub circle_end: char,
    pub cross_end: char,

    // Dedicated subgraph portal crossing marker
    pub portal_pierce: char,
}

impl BaseStyle {
    pub fn chars(&self) -> &'static StyleChars {
        match self {
            BaseStyle::Ascii => &ASCII_CHARS,
            BaseStyle::Unicode => &UNICODE_CHARS,
            BaseStyle::Double => &DOUBLE_CHARS,
            BaseStyle::Rounded => &ROUNDED_CHARS,
            BaseStyle::Heavy => &HEAVY_CHARS,
            BaseStyle::Dots => &DOTS_CHARS,
            BaseStyle::Plus => &PLUS_CHARS,
            BaseStyle::Stars => &STARS_CHARS,
            BaseStyle::Blocks => &BLOCKS_CHARS,
        }
    }

    /// Parse a string into a BorderStyle (case-insensitive), returning None if invalid
    pub fn parse_name(s: &str) -> Option<Self> {
        s.parse().ok()
    }
}

impl std::str::FromStr for BaseStyle {
    type Err = ();

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s.to_lowercase().as_str() {
            "ascii" => Ok(BaseStyle::Ascii),
            "unicode" => Ok(BaseStyle::Unicode),
            "double" => Ok(BaseStyle::Double),
            "rounded" => Ok(BaseStyle::Rounded),
            "heavy" => Ok(BaseStyle::Heavy),
            "dots" | "dot" => Ok(BaseStyle::Dots),
            "plus" => Ok(BaseStyle::Plus),
            "stars" | "star" => Ok(BaseStyle::Stars),
            "blocks" | "block" => Ok(BaseStyle::Blocks),
            _ => Err(()),
        }
    }
}

impl CompositeStyle {
    /// Create a CompositeStyle with all components set to the given base style
    pub fn from_base(style: BaseStyle) -> Self {
        Self {
            corner: Some(style),
            border: Some(style),
            arrow: Some(style),
            edge: Some(style),
            junction: Some(style),
            back: Some(style),
            subgraph: Some(style),
        }
    }

    /// Parse a composite style string like "box:rounded,arrow:heavy,line:double"
    pub fn parse(s: &str) -> Self {
        let mut style = CompositeStyle::default();

        // Handle simple style (backward compatibility)
        if !s.contains(':') {
            if let Some(border_style) = BaseStyle::parse_name(s) {
                // Apply to all components for backward compatibility
                style.corner = Some(border_style);
                style.border = Some(border_style);
                style.arrow = Some(border_style);
                style.edge = Some(border_style);
                style.junction = Some(border_style);
                style.back = Some(border_style);
                style.subgraph = Some(border_style);
            } else if !s.is_empty() {
                // Invalid style name - warn and use default
                eprintln!(
                    "termiflow: warning: Unknown style '{}', using default (unicode)",
                    s
                );
            }
            return style;
        }

        // Parse component-specific styles
        for part in s.split(',') {
            let part = part.trim();
            if let Some((component, style_name)) = part.split_once(':') {
                let border_style = BaseStyle::parse_name(style_name.trim());
                match component.trim() {
                    "box" => {
                        // Legacy: "box" applies to both corners and borders
                        style.corner = border_style;
                        style.border = border_style;
                    }
                    "corner" => style.corner = border_style,
                    "border" => style.border = border_style,
                    "arrow" => style.arrow = border_style,
                    "edge" => style.edge = border_style,
                    "junction" => style.junction = border_style,
                    "back" => style.back = border_style,
                    "subgraph" => style.subgraph = border_style,
                    // Legacy aliases
                    "line" => style.edge = border_style, // "line" -> "edge"
                    "box_corner" => style.corner = border_style,
                    "box_line" | "box_border" => style.border = border_style,
                    "back_edge" => style.back = border_style,
                    unknown => {
                        eprintln!(
                            "termiflow: warning: Unknown style component '{}', ignoring",
                            unknown
                        );
                    }
                }
                // Also warn if the style name within the component is invalid
                if border_style.is_none() {
                    eprintln!(
                        "termiflow: warning: Unknown style name '{}' for component '{}', using default",
                        style_name.trim(),
                        component.trim()
                    );
                }
            }
        }

        style
    }

    /// Create a mixed StyleChars from component styles with a fallback
    pub fn to_style_chars(&self, fallback: BaseStyle) -> StyleChars {
        let corner_chars = self.corner.unwrap_or(fallback).chars();
        let border_chars = self.border.unwrap_or(fallback).chars();
        let arrow_chars = self.arrow.unwrap_or(fallback).chars();
        let edge_chars = self.edge.unwrap_or(fallback).chars();
        let junction_chars = self.junction.unwrap_or(fallback).chars();
        let back_chars = self.back.unwrap_or(fallback).chars();

        StyleChars {
            // Box corners (from corner style)
            tl: corner_chars.tl,
            tr: corner_chars.tr,
            bl: corner_chars.bl,
            br: corner_chars.br,

            // Box borders (from border style)
            h: border_chars.h,
            v: border_chars.v,

            // Arrow components
            arrow_down: arrow_chars.arrow_down,
            arrow_up: arrow_chars.arrow_up,
            arrow_left: arrow_chars.arrow_left,
            arrow_right: arrow_chars.arrow_right,

            // Edge components (connection lines)
            edge_h: edge_chars.edge_h,
            edge_v: edge_chars.edge_v,
            corner_dr: edge_chars.corner_dr,
            corner_dl: edge_chars.corner_dl,
            corner_ur: edge_chars.corner_ur,
            corner_ul: edge_chars.corner_ul,
            cross: edge_chars.cross,

            // Junction components
            junction_down: junction_chars.junction_down,
            junction_up: junction_chars.junction_up,
            junction_right: junction_chars.junction_right,
            junction_left: junction_chars.junction_left,

            // Back-edge components
            back_h: back_chars.back_h,
            back_v: back_chars.back_v,

            // Dotted-edge components (reuse back/edge style dotted chars)
            dotted_h: back_chars.dotted_h,
            dotted_v: back_chars.dotted_v,

            // End marker components (from arrow style)
            circle_end: arrow_chars.circle_end,
            cross_end: arrow_chars.cross_end,
            portal_pierce: arrow_chars.circle_end,
        }
    }

    /// Get StyleChars for subgraph borders.
    ///
    /// Subgraphs default to Heavy style for visual distinction from node boxes.
    /// This can be overridden with `--style="subgraph:ascii"` etc.
    pub fn to_subgraph_chars(&self) -> &'static StyleChars {
        // Default to Heavy for subgraphs (bold visual distinction from nodes)
        self.subgraph.unwrap_or(BaseStyle::Heavy).chars()
    }
}

pub static ASCII_CHARS: StyleChars = StyleChars {
    tl: '+',
    tr: '+',
    bl: '+',
    br: '+',
    h: '-',
    v: '|',
    arrow_down: 'v',
    arrow_up: '^',
    arrow_left: '<',
    arrow_right: '>',
    edge_h: '-',
    edge_v: '|',
    corner_dr: '+',
    corner_dl: '+',
    corner_ur: '+',
    corner_ul: '+',
    cross: '+',
    junction_down: '+',
    junction_up: '+',
    junction_right: '+',
    junction_left: '+',
    back_h: '-',
    back_v: ':',
    dotted_h: '-',
    dotted_v: ':',
    circle_end: 'o',
    cross_end: 'x',
    portal_pierce: 'o',
};

pub static UNICODE_CHARS: StyleChars = StyleChars {
    tl: '',
    tr: '',
    bl: '',
    br: '',
    h: '',
    v: '',
    arrow_down: '',
    arrow_up: '',
    arrow_left: '',
    arrow_right: '',
    edge_h: '',
    edge_v: '',
    corner_dr: '',
    corner_dl: '',
    corner_ur: '',
    corner_ul: '',
    cross: '',
    junction_down: '',
    junction_up: '',
    junction_right: '',
    junction_left: '',
    back_h: '',
    back_v: '',
    dotted_h: '',
    dotted_v: '',
    circle_end: '',
    cross_end: '',
    portal_pierce: '',
};

pub static DOUBLE_CHARS: StyleChars = StyleChars {
    tl: '',
    tr: '',
    bl: '',
    br: '',
    h: '',
    v: '',
    arrow_down: '',
    arrow_up: '',
    arrow_left: '',
    arrow_right: '',
    edge_h: '',
    edge_v: '',
    corner_dr: '',
    corner_dl: '',
    corner_ur: '',
    corner_ul: '',
    cross: '',
    junction_down: '',
    junction_up: '',
    junction_right: '',
    junction_left: '',
    back_h: '',
    back_v: '',
    dotted_h: '',
    dotted_v: '',
    circle_end: '',
    cross_end: '',
    portal_pierce: '',
};

pub static ROUNDED_CHARS: StyleChars = StyleChars {
    tl: '',
    tr: '',
    bl: '',
    br: '',
    h: '',
    v: '',
    arrow_down: '',
    arrow_up: '',
    arrow_left: '',
    arrow_right: '',
    edge_h: '',
    edge_v: '',
    corner_dr: '',
    corner_dl: '',
    corner_ur: '',
    corner_ul: '',
    cross: '',
    junction_down: '',
    junction_up: '',
    junction_right: '',
    junction_left: '',
    back_h: '',
    back_v: '',
    dotted_h: '',
    dotted_v: '',
    circle_end: '',
    cross_end: '',
    portal_pierce: '',
};

pub static HEAVY_CHARS: StyleChars = StyleChars {
    tl: '',
    tr: '',
    bl: '',
    br: '',
    h: '',
    v: '',
    arrow_down: '',
    arrow_up: '',
    arrow_left: '',
    arrow_right: '',
    edge_h: '',
    edge_v: '',
    corner_dr: '',
    corner_dl: '',
    corner_ur: '',
    corner_ul: '',
    cross: '',
    junction_down: '',
    junction_up: '',
    junction_right: '',
    junction_left: '',
    back_h: '',
    back_v: '',
    dotted_h: '',
    dotted_v: '',
    circle_end: '',
    cross_end: '',
    portal_pierce: '',
};

pub static DOTS_CHARS: StyleChars = StyleChars {
    tl: '',
    tr: '',
    bl: '',
    br: '',
    h: '',
    v: '',
    arrow_down: '',
    arrow_up: '',
    arrow_left: '',
    arrow_right: '',
    edge_h: '',
    edge_v: '',
    corner_dr: '',
    corner_dl: '',
    corner_ur: '',
    corner_ul: '',
    cross: '',
    junction_down: '',
    junction_up: '',
    junction_right: '',
    junction_left: '',
    back_h: '',
    back_v: '',
    dotted_h: '',
    dotted_v: ':',
    circle_end: '',
    cross_end: '',
    portal_pierce: '',
};

pub static PLUS_CHARS: StyleChars = StyleChars {
    tl: '+',
    tr: '+',
    bl: '+',
    br: '+',
    h: '-',
    v: '|',
    arrow_down: 'v',
    arrow_up: '^',
    arrow_left: '<',
    arrow_right: '>',
    edge_h: '-',
    edge_v: '|',
    corner_dr: '+',
    corner_dl: '+',
    corner_ur: '+',
    corner_ul: '+',
    cross: '+',
    junction_down: '+',
    junction_up: '+',
    junction_right: '+',
    junction_left: '+',
    back_h: '-',
    back_v: ':',
    dotted_h: '-',
    dotted_v: ':',
    circle_end: 'o',
    cross_end: 'x',
    portal_pierce: 'o',
};

pub static STARS_CHARS: StyleChars = StyleChars {
    tl: '*',
    tr: '*',
    bl: '*',
    br: '*',
    h: '',
    v: '',
    arrow_down: '',
    arrow_up: '',
    arrow_left: '',
    arrow_right: '',
    edge_h: '',
    edge_v: '',
    corner_dr: '',
    corner_dl: '',
    corner_ur: '',
    corner_ul: '',
    cross: '',
    junction_down: '',
    junction_up: '',
    junction_right: '',
    junction_left: '',
    back_h: '',
    back_v: '',
    dotted_h: '',
    dotted_v: '',
    circle_end: '',
    cross_end: '',
    portal_pierce: '',
};

pub static BLOCKS_CHARS: StyleChars = StyleChars {
    tl: '',
    tr: '',
    bl: '',
    br: '',
    h: '',
    v: '',
    arrow_down: '',
    arrow_up: '',
    arrow_left: '',
    arrow_right: '',
    edge_h: '',
    edge_v: '',
    corner_dr: '',
    corner_dl: '',
    corner_ur: '',
    corner_ul: '',
    cross: '',
    junction_down: '',
    junction_up: '',
    junction_right: '',
    junction_left: '',
    back_h: '',
    back_v: '',
    dotted_h: '',
    dotted_v: '',
    circle_end: '',
    cross_end: '',
    portal_pierce: '',
};

/// Truncate label to fit within max display columns
pub fn truncate_label(label: &str, max_width: usize) -> String {
    let current_width = display_width(label);
    if current_width <= max_width {
        return label.to_string();
    }

    let ellipsis = "...";
    let ellipsis_width = display_width(ellipsis);
    if max_width <= ellipsis_width {
        return truncate_to_width(ellipsis, max_width);
    }

    let prefix = truncate_to_width(label, max_width.saturating_sub(ellipsis_width));
    format!("{prefix}{ellipsis}")
}

/// Calculate box width from label
pub fn box_width(label: &str) -> usize {
    let label_width = display_width(label).min(MAX_LABEL_WIDTH);
    (label_width + BOX_PADDING * 2 + 2).max(BOX_MIN_WIDTH)
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_box_width_simple() {
        assert_eq!(box_width("A"), 7); // 1 + 4 + 2 = 7, but min is 5... actually 1+4+2=7
        assert_eq!(box_width("Gateway"), 13); // 7 + 4 + 2 = 13
    }

    #[test]
    fn test_truncate_label() {
        assert_eq!(truncate_label("Short", 10), "Short");
        // max_width=10, ellipsis=3, so 7 chars fit + "..." = "VeryLon..."
        assert_eq!(truncate_label("VeryLongLabel", 10), "VeryLon...");
    }

    #[test]
    fn truncate_to_width_preserves_grapheme_clusters() {
        let family = "👨‍👩‍👧‍👦";
        assert_eq!(
            truncate_to_width(&format!("{family}{family}"), display_width(family)),
            family
        );
    }

    #[test]
    fn split_text_to_width_chunks_preserves_grapheme_clusters() {
        let family = "👨‍👩‍👧‍👦";
        assert_eq!(
            split_text_to_width_chunks(&format!("{family}{family}"), display_width(family)),
            vec![family.to_string(), family.to_string()]
        );
    }

    #[test]
    fn truncate_label_preserves_combining_clusters() {
        let accented = "e\u{301}";
        assert_eq!(
            truncate_label(
                &format!("{accented}{accented}{accented}{accented}{accented}"),
                4
            ),
            format!("{accented}...")
        );
    }

    #[test]
    fn test_display_width() {
        assert_eq!(display_width("ABC"), 3);
        assert_eq!(display_width("日本語"), 6); // CJK = 2 width each
    }

    #[test]
    fn test_composite_style_parse_simple() {
        let style = CompositeStyle::parse("unicode");
        assert_eq!(style.corner, Some(BaseStyle::Unicode));
        assert_eq!(style.border, Some(BaseStyle::Unicode));
        assert_eq!(style.arrow, Some(BaseStyle::Unicode));
        assert_eq!(style.edge, Some(BaseStyle::Unicode));
        assert_eq!(style.junction, Some(BaseStyle::Unicode));
        assert_eq!(style.back, Some(BaseStyle::Unicode));
    }

    #[test]
    fn test_composite_style_parse_complex() {
        let style = CompositeStyle::parse("corner:rounded,border:heavy,arrow:unicode,edge:double");
        assert_eq!(style.corner, Some(BaseStyle::Rounded));
        assert_eq!(style.border, Some(BaseStyle::Heavy));
        assert_eq!(style.arrow, Some(BaseStyle::Unicode));
        assert_eq!(style.edge, Some(BaseStyle::Double));
        assert_eq!(style.junction, None);
        assert_eq!(style.back, None);
    }

    #[test]
    fn test_composite_style_parse_all_components() {
        let style = CompositeStyle::parse(
            "corner:dots,border:heavy,arrow:unicode,edge:double,junction:heavy,back:rounded",
        );
        assert_eq!(style.corner, Some(BaseStyle::Dots));
        assert_eq!(style.border, Some(BaseStyle::Heavy));
        assert_eq!(style.arrow, Some(BaseStyle::Unicode));
        assert_eq!(style.edge, Some(BaseStyle::Double));
        assert_eq!(style.junction, Some(BaseStyle::Heavy));
        assert_eq!(style.back, Some(BaseStyle::Rounded));
    }

    #[test]
    fn test_composite_style_to_style_chars() {
        let mut composite = CompositeStyle::default();
        composite.corner = Some(BaseStyle::Dots);
        composite.border = Some(BaseStyle::Heavy);
        composite.arrow = Some(BaseStyle::Heavy);

        let chars = composite.to_style_chars(BaseStyle::Unicode);

        // Box corners should be dots
        assert_eq!(chars.tl, '');
        assert_eq!(chars.tr, '');

        // Box lines should be heavy
        assert_eq!(chars.h, '');
        assert_eq!(chars.v, '');

        // Arrows should be heavy (uses heavy set → filled down arrow)
        assert_eq!(chars.arrow_down, '');

        // Lines should fall back to unicode
        assert_eq!(chars.edge_h, '');
    }

    #[test]
    fn test_new_styles() {
        // Test dots style
        assert_eq!(BaseStyle::parse_name("dots"), Some(BaseStyle::Dots));
        assert_eq!(BaseStyle::parse_name("dot"), Some(BaseStyle::Dots));

        // Test plus style
        assert_eq!(BaseStyle::parse_name("plus"), Some(BaseStyle::Plus));

        // Test stars style
        assert_eq!(BaseStyle::parse_name("stars"), Some(BaseStyle::Stars));
        assert_eq!(BaseStyle::parse_name("star"), Some(BaseStyle::Stars));

        // Test blocks style
        assert_eq!(BaseStyle::parse_name("blocks"), Some(BaseStyle::Blocks));
        assert_eq!(BaseStyle::parse_name("block"), Some(BaseStyle::Blocks));
    }

    #[test]
    fn test_legacy_compatibility() {
        // Test that legacy names still work
        let style = CompositeStyle::parse("box:rounded");
        assert_eq!(style.corner, Some(BaseStyle::Rounded));
        assert_eq!(style.border, Some(BaseStyle::Rounded));

        let style =
            CompositeStyle::parse("box_corner:dots,box_line:heavy,line:double,back_edge:ascii");
        assert_eq!(style.corner, Some(BaseStyle::Dots));
        assert_eq!(style.border, Some(BaseStyle::Heavy));
        assert_eq!(style.edge, Some(BaseStyle::Double));
        assert_eq!(style.back, Some(BaseStyle::Ascii));
    }
}