summaryrefslogtreecommitdiff
path: root/utf8.h
diff options
context:
space:
mode:
authorKarthik Nayak <karthik.188@gmail.com>2015-09-10 15:48:19 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-09-17 17:02:48 (GMT)
commit110dcda50d5ddaf3557666eea3b012a6ccc74dce (patch)
treef7691945290bc4f51be7ca7dd073fbd8ebf8535e /utf8.h
parent574e96a2418cce16934f2b6e20a0af5ff5f85c92 (diff)
downloadgit-110dcda50d5ddaf3557666eea3b012a6ccc74dce.zip
git-110dcda50d5ddaf3557666eea3b012a6ccc74dce.tar.gz
git-110dcda50d5ddaf3557666eea3b012a6ccc74dce.tar.bz2
utf8: add function to align a string into given strbuf
Add strbuf_utf8_align() which will align a given string into a strbuf as per given align_type and width. If the width is greater than the string length then no alignment is performed. Helped-by: Eric Sunshine <sunshine@sunshineco.com> Mentored-by: Christian Couder <christian.couder@gmail.com> Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr> Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'utf8.h')
-rw-r--r--utf8.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/utf8.h b/utf8.h
index 5a9e94b..7930b44 100644
--- a/utf8.h
+++ b/utf8.h
@@ -55,4 +55,19 @@ int mbs_chrlen(const char **text, size_t *remainder_p, const char *encoding);
*/
int is_hfs_dotgit(const char *path);
+typedef enum {
+ ALIGN_LEFT,
+ ALIGN_MIDDLE,
+ ALIGN_RIGHT
+} align_type;
+
+/*
+ * Align the string given and store it into a strbuf as per the
+ * 'position' and 'width'. If the given string length is larger than
+ * 'width' than then the input string is not truncated and no
+ * alignment is done.
+ */
+void strbuf_utf8_align(struct strbuf *buf, align_type position, unsigned int width,
+ const char *s);
+
#endif