Commit b610d1cb03
Verified · cmc
Layout: unified · split
content/blog/2026-08-20-nfogen.org +10 −10
| @@ -270,9 +270,10 @@ rows and columns. | ||
| 270 | 270 | ** Width |
| 271 | 271 | |
| 272 | 272 | The first issue I ran into was determining the width to use. I settled on 79 |
| 273 | characters, with border characters at both ends, because X. This means that my | |
| 274 | script needs to perform some math to calculate wrapping, padding, and centering | |
| 275 | of text throughout. | |
| 273 | characters, with border characters at both ends, because 80-column terminals, | |
| 274 | minus one so the line doesn't wrap when a terminal auto-wraps at exactly 80. | |
| 275 | This means that my script needs to perform some math to calculate wrapping, | |
| 276 | padding, and centering of text throughout. | |
| 276 | 277 | |
| 277 | 278 | The math is relatively simple because CP437 is single-byte and single-width, |
| 278 | 279 | which means I can write functions that depend on that one-to-one correlation |
| @@ -328,7 +329,7 @@ If an explicity art file is defined, this generator does not run. | ||
| 328 | 329 | |
| 329 | 330 | #+begin_src python |
| 330 | 331 | # A compact 5-row block font for the banner generator. Each glyph is five |
| 331 | # rows joined by "/". Uppercase letters, digits, space, and [<35;44;2Ma few symbols. | |
| 332 | # rows joined by "/". Uppercase letters, digits, space, and a few symbols. | |
| 332 | 333 | _FONT = { |
| 333 | 334 | "A": " ### /# #/#####/# #/# #", "B": "#### /# #/#### /# #/#### ", |
| 334 | 335 | "C": " ####/# /# /# / ####", "D": "#### /# #/# #/# #/#### ", |
| @@ -351,12 +352,11 @@ def banner(text: str) -> str: | ||
| 351 | 352 | Finally, I defined a specific order to the inputs. As stated in the README, the |
| 352 | 353 | order of importance is: =template < profile < config file < CLI flags < prompts=. |
| 353 | 354 | |
| 354 | This was an opinionated design choice, as I felt that if you were to create a | |
| 355 | template, that should take precedence above all. Then, profiles and | |
| 356 | configurations are additional preconfigured files that require effort to create | |
| 357 | and maintain, which earns them the next spots. Finally, the script falls back to | |
| 358 | CLI arguments, if supplied, and then interactive prompt mode if nothing else | |
| 359 | exists. | |
| 355 | This was an opinionated design choice, as I felt that if you were to run the | |
| 356 | script in interactive mode, that meant you wanted those to take precedence over | |
| 357 | all. Then again, specifying CLI flags directly when running the script should do | |
| 358 | the same. Finally, specifying configuration files, profiles, and templates will | |
| 359 | take precedence in descending order. | |
| 360 | 360 | |
| 361 | 361 | * The Future |
| 362 | 362 | |