summaryrefslogtreecommitdiff
path: root/ref-filter.h
diff options
context:
space:
mode:
authorKarthik Nayak <karthik.188@gmail.com>2015-09-11 15:03:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-09-17 17:02:48 (GMT)
commitce59208293f793ae822b5bfdf4040739f1c3ccb7 (patch)
tree4c18936f55da42abc06224340fb0435cacf5e700 /ref-filter.h
parent40a7551d25efac7979ee1a675c05e67313205444 (diff)
downloadgit-ce59208293f793ae822b5bfdf4040739f1c3ccb7.zip
git-ce59208293f793ae822b5bfdf4040739f1c3ccb7.tar.gz
git-ce59208293f793ae822b5bfdf4040739f1c3ccb7.tar.bz2
ref-filter: implement an `align` atom
Implement an `align` atom which left-, middle-, or right-aligns the content between %(align:...) and %(end). The "align:" is followed by `<width>` and `<position>` in any order separated by a comma, where the `<position>` is either left, right or middle, default being left and `<width>` is the total length of the content with alignment. If the contents length is more than the width then no alignment is performed. e.g. to align a refname atom to the middle with a total width of 40 we can do: --format="%(align:middle,40)%(refname)%(end)". We introduce an `at_end` function for each element of the stack which is to be called when the `end` atom is encountered. Using this we implement end_align_handler() for the `align` atom, this aligns the final strbuf by calling `strbuf_utf8_align()` from utf8.c. Ensure that quote formatting is performed on the whole of %(align:...)...%(end) rather than individual atoms inside. We skip quote formatting for individual atoms when the current stack element is handling an %(align:...) atom and perform quote formatting at the end when we encounter the %(end) atom of the second element of then stack. Add documentation and tests for the same. Mentored-by: Christian Couder <christian.couder@gmail.com> Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr> Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'ref-filter.h')
0 files changed, 0 insertions, 0 deletions