Simple string formatting. More...
#include "config.h"
#include <errno.h>
#include <limits.h>
#include <stdbool.h>
#include <string.h>
#include <wchar.h>
#include "mutt/lib.h"
#include "format.h"
#include "mutt_thread.h"
Go to the source code of this file.
Functions | |
void | buf_justify (struct Buffer *buf, enum FormatJustify justify, size_t max_cols, char pad_char) |
Justify a string. | |
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.c.
void buf_justify | ( | struct Buffer * | buf, |
enum FormatJustify | justify, | ||
size_t | max_cols, | ||
char | pad_char | ||
) |
Justify a string.
buf | String to justify |
justify | Justification, e.g. JUSTIFY_RIGHT |
max_cols | Number of columns to pad to |
pad_char | Character to fill with |
Definition at line 49 of file format.c.
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.