|
172 | 172 | {:keys [font width pad] :as span-decl} (extract-span-decl first-element)]
|
173 | 173 | (if width
|
174 | 174 | (let [;; Transform this span and everything below it into easily managed span vectors, starting
|
175 |
| - ;; with a reduced version of the span decl. |
| 175 | + ;; with a version of this span decl. |
176 | 176 | span-decl' (dissoc span-decl :width :pad)
|
177 | 177 | *length (volatile! 0)
|
178 | 178 | inputs' (into [span-decl'] (normalize-markup inputs *length))
|
179 | 179 | spaces (padding (- width @*length))
|
180 |
| - ;; Added the padding in the desired position; this ensures that the logic that generates |
| 180 | + ;; Add the padding in the desired position; this ensures that the logic that generates |
181 | 181 | ;; ANSI escape codes occurs correctly, with the added spaces getting the font for this span.
|
182 | 182 | padded (if (= :right pad)
|
183 | 183 | (conj inputs' spaces)
|
184 | 184 | ;; An "insert-at" for vectors would be nice
|
185 | 185 | (into [(first inputs') spaces] (next inputs')))]
|
186 | 186 | (recur state padded))
|
187 | 187 | ;; Normal (no width tracking)
|
188 |
| - (let [{:keys [current]} state |
189 |
| - state' (reduce collect-markup |
190 |
| - (-> state |
191 |
| - (update :current update-font-data-from-font-def font) |
192 |
| - (update :stack conj current)) |
193 |
| - inputs)] |
194 |
| - (-> state' |
| 188 | + (let [{:keys [current]} state] |
| 189 | + (-> (reduce collect-markup |
| 190 | + (-> state |
| 191 | + (update :current update-font-data-from-font-def font) |
| 192 | + (update :stack conj current)) |
| 193 | + inputs) |
195 | 194 | (assoc :current current
|
196 | 195 | :tracking-width? false)
|
197 | 196 | (update :stack pop)))))
|
|
226 | 225 | Nested vectors represent _spans_, a sequence of values with a specific visual representation.
|
227 | 226 | The first element in a span vector declares the visual properties of the span: the color (including
|
228 | 227 | other characteristics such as bold or underline), and the width and padding (described later).
|
| 228 | + Spans may be nested. |
229 | 229 |
|
230 | 230 | The declaration is usually a keyword, to define just the font.
|
231 | 231 | The font def contains one or more terms, separated by periods.
|
|
248 | 248 | => ...
|
249 | 249 | ```
|
250 | 250 |
|
251 |
| - The order of the terms does not matter. Behavior for conflicting terms (`:blue.green.black`) |
| 251 | + The order of the terms does not matter. Behavior for conflicting terms (e.g., `:blue.green.black`) |
252 | 252 | is not defined.
|
253 | 253 |
|
254 | 254 |
|
|
263 | 263 |
|
264 | 264 | The core colors are `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, and `white`.
|
265 | 265 |
|
266 |
| - When [[*color-enabled*]] is false, then any font defs are validated, then ignored (no ANSI codes |
267 |
| - will be included). |
| 266 | + When [[*color-enabled*]] is false, then any font defs are validated, but otherwise ignored (no ANSI codes |
| 267 | + will be included in the composed string). |
268 | 268 |
|
269 | 269 | The span's font declaration may also be a map with the following keys:
|
270 | 270 |
|
|
292 | 292 | [{:font :red
|
293 | 293 | :width 20} message]
|
294 | 294 |
|
295 |
| - This will output the value of `message` in red text, padded with spaces on the left to be 20 characters." |
| 295 | + This will output the value of `message` in red text, padded with spaces on the left to be 20 characters. |
| 296 | +
|
| 297 | + compose does not truncate a span to a width, it only pads if the span in too short." |
296 | 298 | {:added "1.4.0"}
|
297 | 299 | [& inputs]
|
298 | 300 | (let [initial-font {:foreground "39"
|
|
0 commit comments