Simple string formatting. More...
#include <stdbool.h>#include <stddef.h>
Include dependency graph for format.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Enumerations | |
| enum | FormatJustify { JUSTIFY_LEFT = -1 , JUSTIFY_CENTER = 0 , JUSTIFY_RIGHT = 1 } |
| Alignment for format_string() More... | |
Functions | |
| int | format_string (struct Buffer *buf, int min_cols, int max_cols, enum FormatJustify justify, char pad_char, const char *str, size_t n, bool arboreal) |
| Format a string, like snprintf() | |
Simple string formatting.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file format.h.
| enum FormatJustify |
Alignment for format_string()
| Enumerator | |
|---|---|
| JUSTIFY_LEFT | Left justify the text. |
| JUSTIFY_CENTER | Centre the text. |
| JUSTIFY_RIGHT | Right justify the text. |
| int format_string | ( | struct Buffer * | buf, |
| int | min_cols, | ||
| int | max_cols, | ||
| enum FormatJustify | justify, | ||
| char | pad_char, | ||
| const char * | str, | ||
| size_t | n, | ||
| bool | arboreal ) |
Format a string, like snprintf()
| [out] | buf | Buffer in which to save string |
| [in] | min_cols | Minimum number of screen columns to use |
| [in] | max_cols | Maximum number of screen columns to use |
| [in] | justify | Justification, e.g. JUSTIFY_RIGHT |
| [in] | pad_char | Padding character |
| [in] | str | String to format |
| [in] | n | Number of bytes of string to format |
| [in] | arboreal | If true, string contains graphical tree characters |
| obj | Number of bytes and screen columns used |
This formats a string, a bit like sprintf(buf, "%-*.*s", min_cols, max_cols, str), except that the max_cols refer to the number of character cells when printed.
Definition at line 108 of file format.c.
Here is the call graph for this function:
Here is the caller graph for this function: