@@ -79,7 +79,7 @@ boxTitle boxStyle title child = do
79
79
sides =
80
80
[ withinImage (Region (left + 1 ) top (width - 2 ) 1 ) $
81
81
V. text' attr $
82
- hPadText title' (_boxStyle_n style) (width - 2 )
82
+ centerText title' (_boxStyle_n style) (width - 2 )
83
83
, withinImage (Region right (top + 1 ) 1 (height - 2 )) $
84
84
V. charFill attr (_boxStyle_e style) 1 (height - 2 )
85
85
, withinImage (Region (left + 1 ) bottom (width - 2 ) 1 ) $
@@ -98,16 +98,23 @@ boxTitle boxStyle title child = do
98
98
V. char attr (_boxStyle_sw style)
99
99
]
100
100
in sides ++ if width > 1 && height > 1 then corners else []
101
- hPadText :: T. Text -> Char -> Int -> T. Text
102
- hPadText t c l = if lt >= l
103
- then t
104
- else left <> t <> right
105
- where
106
- lt = T. length t
107
- delta = l - lt
108
- mkHalf n = T. replicate (n `div` 2 ) (T. singleton c)
109
- left = mkHalf $ delta + 1
110
- right = mkHalf delta
101
+
102
+ -- | Pad text on the left and right with the given character so that it is
103
+ -- centered
104
+ centerText
105
+ :: T. Text -- ^ Text to center
106
+ -> Char -- ^ Padding character
107
+ -> Int -- ^ Width
108
+ -> T. Text -- ^ Padded text
109
+ centerText t c l = if lt >= l
110
+ then t
111
+ else left <> t <> right
112
+ where
113
+ lt = T. length t
114
+ delta = l - lt
115
+ mkHalf n = T. replicate (n `div` 2 ) (T. singleton c)
116
+ left = mkHalf $ delta + 1
117
+ right = mkHalf delta
111
118
112
119
-- | A box without a title
113
120
box :: (MonadFix m , MonadHold t m , HasDisplayRegion t m , HasImageWriter t m , HasInput t m , HasFocusReader t m , HasTheme t m )
0 commit comments