@@ -16,10 +16,16 @@ public static class TuiHelper
1616 // Display a styled header
1717 public static void DisplayHeader ( string title )
1818 {
19- var border = new string ( '═' , Math . Min ( title . Length + 4 , 80 ) ) ;
19+ var borderLength = Math . Max ( title . Length + 4 , 30 ) ; // Ensure minimum length
20+ var border = new string ( '═' , borderLength ) ;
2021 Console . ForegroundColor = HeaderColor ;
2122 Console . WriteLine ( $ "\n ╔{ border } ╗") ;
22- Console . WriteLine ( $ "║ { title } ║") ;
23+ // Center the title within the border
24+ var padding = ( borderLength - title . Length ) / 2 ;
25+ var leftPadding = padding ;
26+ var rightPadding = borderLength - title . Length - leftPadding ;
27+ var paddedTitle = new string ( ' ' , leftPadding ) + title + new string ( ' ' , rightPadding ) ;
28+ Console . WriteLine ( $ "║{ paddedTitle } ║") ;
2329 Console . WriteLine ( $ "╚{ border } ╝") ;
2430 Console . ResetColor ( ) ;
2531 }
@@ -42,10 +48,11 @@ public static void DisplayTableHeader(string idLabel, string pathLabel, string d
4248 }
4349
4450 // Display a table separator line
45- public static void DisplayTableSeparator ( int idWidth = 10 , int pathWidth = 70 , int dateWidth = 20 )
51+ public static void DisplayTableSeparator ( int idWidth = 10 , int pathWidth = 60 , int dateWidth = 20 )
4652 {
4753 Console . ForegroundColor = BorderColor ;
48- var totalWidth = idWidth + pathWidth + dateWidth + 4 ; // +4 for the spaces and separators
54+ // Calculate total width: idWidth + " │ " + pathWidth + " │ " + dateWidth
55+ var totalWidth = idWidth + 3 + pathWidth + 3 + dateWidth ; // 3 chars for " │ " separator
4956 Console . WriteLine ( new string ( '─' , totalWidth ) ) ;
5057 Console . ResetColor ( ) ;
5158 }
@@ -103,17 +110,30 @@ public static void DisplayWarning(string message)
103110 // Display a styled summary box
104111 public static void DisplaySummary ( string title , params ( string label , string value ) [ ] items )
105112 {
113+ // Calculate the max width needed for the content
114+ int contentWidth = Math . Max ( title . Length + 2 , 28 ) ; // +2 for the ─ ─ spacing around title, minimum 30 total
115+ foreach ( var ( label , value ) in items )
116+ {
117+ int itemLength = ( label + ": " + value ) . Length ;
118+ if ( itemLength > contentWidth ) contentWidth = itemLength ;
119+ }
120+
106121 Console . ForegroundColor = HeaderColor ;
107- Console . WriteLine ( $ "\n ┌─ { title } ─{ '─' . Repeat ( Math . Max ( 0 , 50 - title . Length ) ) } ") ;
122+ var topBorder = $ "┌─ { title } ─{ '─' . Repeat ( Math . Max ( 0 , contentWidth - title . Length - 2 ) ) } ┐";
123+ Console . WriteLine ( $ "\n { topBorder } ") ;
108124 Console . ResetColor ( ) ;
109-
125+
110126 foreach ( var ( label , value ) in items )
111127 {
112- Console . WriteLine ( $ "│ { label } : { value } ") ;
128+ var content = $ "│ { label } : { value } ";
129+ var padding = contentWidth - ( label . Length + value . Length + 2 ) ; // 2 for ": "
130+ var paddedContent = content + new string ( ' ' , padding ) + "│" ;
131+ Console . WriteLine ( paddedContent ) ;
113132 }
114-
133+
115134 Console . ForegroundColor = HeaderColor ;
116- Console . WriteLine ( $ "└{ '─' . Repeat ( 50 ) } ┘") ;
135+ var bottomBorder = $ "└{ '─' . Repeat ( contentWidth + 2 ) } ┘"; // +2 for the │ │ borders
136+ Console . WriteLine ( bottomBorder ) ;
117137 Console . ResetColor ( ) ;
118138 }
119139 }
0 commit comments