1 /* Align/Truncate a string in a given screen width
2 Copyright (C) 2009-2017 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19 typedef enum { MBS_ALIGN_LEFT
, MBS_ALIGN_RIGHT
, MBS_ALIGN_CENTER
} mbs_align_t
;
22 /* Use unibyte mode for invalid multibyte strings
23 or when heap memory is exhausted. */
24 MBA_UNIBYTE_FALLBACK
= 0x0001,
26 /* As an optimization, don't do multibyte processing
27 when we know no multibyte characters are present. */
28 MBA_UNIBYTE_ONLY
= 0x0002,
30 /* Don't add leading padding. */
31 MBA_NO_LEFT_PAD
= 0x0004,
33 /* Don't add trailing padding. */
34 MBA_NO_RIGHT_PAD
= 0x0008
36 #if 0 /* Other possible options. */
37 /* Skip invalid multibyte chars rather than failing. */
40 /* Align multibyte strings using "figure space" (\u2007). */
46 /* Ensure no leading whitespace. */
49 /* Ensure no trailing whitespace. */
55 mbsalign (const char *src
, char *dest
, size_t dest_size
,
56 size_t *width
, mbs_align_t align
, int flags
);
59 ambsalign (const char *src
, size_t *width
, mbs_align_t align
, int flags
);