This module collects a few very simple and very specialized helper predicates
dealing with strings in the context of dict prettyprinting, which just add noise
to the main module. So they are here, in a separate module.
The homepage for this module is at
https://github.com/dtonhofer/prolog_code/blob/main/unpacked/onepointfour_basics/README_dict_pp.md
- max_line_width(+Lines, -MaxLineWidth)
- Find "maximum line width" over all lines (this means find "max string length" as the lines are strings)
- make_tag_line(+Tag, +MaxLineWidth, +PadLeft, +PadRight, +SettingsDict, -Result)
- Create the TagLineOut (a string) with the dict's tag Tag by justifying the tag
inside that line according to the values passed. In principle, the length
of string Tag =< MaxLineWidth. At call time, Tag should be an atom or an
integer, but we cannot be sure, so we pump it through format/3 once. Note that
is likely that both PadLeft and PadRight are 0.
Explainer for the various values:
|<-----PadLeft--->|<---- MaxLineWidth ---->|<----PadRight----------->|
| |left_justified_tag | |
| | right_justified_tag| |
| | center_justified_tag | |
|full_left_justified_tag | |
| | | full_right_justified_tag|
| | full_center_justified_tag |
SettingsDict may carry:
justify_tag : left,right,center , default: center
justify_tag_full : true, false , default: true
- To be done
- - justify_how/4 could be extended to not perform assertion checks internally. Maybe.
- - justify_how/4 generates trailing spaces in "Result", which might be unwanted.
- make_bordery_lines(+MaxLineWidth, +PadLeft, +PadRight, -HorizontalBorderResult, -BackgroundResult)
- A packaged call to perform make_horizontal_border_line/2 and make_background_line_with_border/2.
- make_background_line_for_padding(+MaxLineWidth, +PadLeft, +PadRight, -Result)
- Create a "background line" for padding only: it's just whitespace.