Mercurial > hg
comparison .hgsigs @ 33858:6f6c87888b22
log: add a "graphwidth" template variable
Wrapping text in templates for 'hg log --graph' can't be done very well,
because the template doesn't know how wide the graph drawing is. The edge
drawing function needs to know the number of lines in the template output, so
we need to also determine how wide that drawing would be before we call the
edgefn or evaluate the template.
This patch makes edgefn compute the graph width and pass it into the template
so that we can do something like this:
COLUMNS=10 hg log --graph --template "{fill(desc, termwidth - graphwidth)}"
@ a a a a
| a a a a
| a a a a
o a a a
|\ a a a
| | a a a
| | a a a
Using extensions to do this would be relatively complicated due to a lack of
hooks in this area of the code.
In the future it may make sense to have a more generic "textwidth" that tells
you how many columns you can expect to fill without causing the terminal to
wrap your output. I'm not sure there are other situations to motivate this yet,
or if it is entirely feasible.
Differential Revision: https://phab.mercurial-scm.org/D360
author | Danny Hooper <hooper@google.com> |
---|---|
date | Tue, 15 Aug 2017 10:15:31 -0700 |
parents | a3ce07e2dde5 |
children | fa4b3b666ca7 |
comparison
equal
deleted
inserted
replaced
33857:833f70277f0e | 33858:6f6c87888b22 |
---|