textu...djust(n)
π textutil::adjust(n) π
okay bestie, so this is a page from the Text and string utilities, macro processing corner of the manual, and it's literally all about the textutil::adjust package. Let's get into it π«Ά
β¨ NAME β¨
textutil::adjust β procedures to adjust, indent, and undent paragraphs. yes that's the whole vibe π
πΈ SYNOPSIS πΈ
package require Tcl 8.5 9
package require textutil::adjust ?0.7.4?
::textutil::adjust::adjust string ?option value...?
::textutil::adjust::readPatterns filename
::textutil::adjust::listPredefined
::textutil::adjust::getPredefined filename
::textutil::adjust::indent string prefix ?skip?
::textutil::adjust::undent string
π¦ DESCRIPTION π¦
So the package textutil::adjust gives you commands that mess with strings and texts (aka long strings, or strings with embedded newlines, or whole paragraphs) β adjusting them, indenting them, the whole glow-up π
The full set of procedures is down below, no gatekeeping:
::textutil::adjust::adjust string ?option value...? π
Does a justification on the string according to the options. The string is taken as one big paragraph, ignoring any newlines. Then the line is formatted according to the options used, and the command returns a new string with enough lines to contain all the printable chars in the input string. A line is a set of characters between the beginning of the string and a newline, or between 2 newlines, or between a newline and the end of the string. If the input string is small enough, the returned string won't contain any newlines. no cap β¨
Together with ::textutil::adjust::indent it is possible to create properly wrapped paragraphs with arbitrary indentations. iconic combo tbh
By default, any occurrence of space or tabulation characters are replaced by a single space so that each word in a line is separated from the next one by exactly one space character, and this forms a real line. Each real line is placed in a logical line, which has exactly a given length (see the option -length below). The real line may be shorter. Again by default, trailing spaces are ignored before returning the string (see the option -full below).
The following options may be used after the string parameter, and change the way the command places a real line in a logical line. periodt π
-fullboolean β If set to false (default), trailing space characters are deleted before returning the string. If set to true, any trailing space characters are left in the string.-hyphenateboolean β If set to false (default), no hyphenation will be done. If set to true, the command will try to hyphenate the last word of a line. > Note: hyphenation patterns must be loaded prior, using the command::textutil::adjust::readPatterns. so like, do that first bestie, fr fr π-justifycenter|left|plain|rightβ Sets the justification of the returned string to eitherleft(default),center,plainorright. The justification means that any line in the returned string but the last one is build according to the value. If the justification is set toplainand the number of printable chars in the last line is less than 90% of the length of a line (see the option-length), then this line is justified with theleftvalue, avoiding the expansion of this line when it is too small. The meaning of each value is:centerβ The real line is centered in the logical line. If needed, a set of space characters are added at the beginning (half of the needed set) and at the end (half of the needed set) of the line if required (see the option-full).leftβ The real line is set on the left of the logical line. It means that there are no space chars at the beginning of this line. If required, all needed space chars are added at the end of the line (see the option-full).plainβ The real line is exactly set in the logical line. It means that there are no leading or trailing space chars. All the needed space chars are added in the real line, between 2 (or more) words.rightβ The real line is set on the right of the logical line. It means that there are no space chars at the end of this line, and there may be some space chars at the beginning, despite of the-fulloption.
-lengthinteger β Set the length of the logical line in the string to integer. integer must be a positive integer value. Defaults to72. (yes, seventy-two, the classic π)-strictlengthboolean β If set to false (default), a line can exceed the specified-lengthif a single word is longer than-length. If set to true, words that are longer than-lengthare split so that no line exceeds the specified-length. it's giving "no word left behind" π
::textutil::adjust::readPatterns filename π
Loads the internal storage for hyphenation patterns with the contents of the file filename. This has to be done prior to calling command ::textutil::adjust::adjust with -hyphenate true, or the hyphenation process will not work correctly. like, at all. do it first π¨
The package comes with a number of predefined pattern files, and the command ::textutil::adjust::listPredefined can be used to find out their names. cute of them honestly
::textutil::adjust::listPredefined π
This command returns a list containing the names of the hyphenation files coming with this package. iykyk
::textutil::adjust::getPredefined filename π
Use this command to query the package for the full path name of the hyphenation file filename coming with the package. Only the filenames found in the list returned by ::textutil::adjust::listPredefined are legal arguments for this command. so don't be out here making up names bestie π
::textutil::adjust::indent string prefix ?skip? π
Each line in the string is indented by adding the string prefix at its beginning. The modified string is returned as the result of the command. slay
If skip is specified the first skip lines are left untouched. The default for skip is 0, causing the modification of all lines. Negative values for skip are treated like 0. In other words, skip > 0 creates a hanging indentation.
Together with ::textutil::adjust::adjust it is possible to create properly wrapped paragraphs with arbitrary indentations. the duo of the century honestly π
::textutil::adjust::undent string π§
The command computes the common prefix for all lines in string consisting solely out of whitespace, removes this from each line and returns the modified string.
Lines containing only whitespace are always reduced to completely empty lines. They and empty lines are also ignored when computing the prefix to remove.
Together with ::textutil::adjust::adjust it is possible to create properly wrapped paragraphs with arbitrary indentations. (yes, third time, it's that good π)
π BUGS, IDEAS, FEEDBACK π
This document, and the package it describes, will undoubtedly contain bugs and other problems. ngl that's just how it is π Please report such in the category textutil of the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist]. Please also report any ideas for enhancements you may have for either package and/or documentation. we love feedback fr fr π
When proposing code changes, please provide unified diffs, i.e the output of diff -u.
Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. don't make them read a wall of pasted diff in the comments bestie, please π
π SEE ALSO π
regexp(n), split(n), string(n)
π KEYWORDS π
TeX, adjusting, formatting, hyphenation, indenting, justification, paragraph, string, undenting
π CATEGORY π
Text processing
and that's the whole page! brought to you by the tcllib girlies, version 0.7.4, manual page textu...djust(n) β stay adjusted, stay iconic, and go indent something pretty π
β¨π¦
π¦ where this page comes from
- fedora 43: tcllib 2.0-3.fc43 Β· TCL
- fedora 44: tcllib 2.0-4.fc44 Β· TCL
- nixos 26.05: tcllib 2.0
- nixpkgs unstable: tcllib 2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms