diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2016-06-16 20:18:38 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-06-16 11:43:37 -0700 |
commit | 066790d7cb0fa22e64f1276d8a0e33d18484f62a (patch) | |
tree | 2cf6b9c792b734fa213e0299a6a7299b3fae4414 /pretty.c | |
parent | 3ad87c807c2b6cbfbdfb2c78412781ecc7db593d (diff) | |
download | git-066790d7cb0fa22e64f1276d8a0e33d18484f62a.tar.gz |
pretty.c: support <direction>|(<negative number>) formsnd/graph-width-padded
%>|(num), %><|(num) and %<|(num), where num is a positive number, sets a
fixed column from the screen's left border. There is no way for us to
specifiy a column relative to the right border, which is useful when you
want to make use of all terminal space (on big screens). Use negative
num for that. Inspired by Go's array syntax (*).
(*) I know Python has this first (or before Go, at least) but the idea
didn't occur to me until I learned Go.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pretty.c')
-rw-r--r-- | pretty.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -1022,9 +1022,15 @@ static size_t parse_padding_placeholder(struct strbuf *sb, int width; if (!end || end == start) return 0; - width = strtoul(start, &next, 10); + width = strtol(start, &next, 10); if (next == start || width == 0) return 0; + if (width < 0) { + if (to_column) + width += term_columns(); + if (width < 0) + return 0; + } c->padding = to_column ? -width : width; c->flush_type = flush_type; |