Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: Add pad_center template function #5066

Open
zx8 opened this issue Dec 10, 2024 · 2 comments
Open

FR: Add pad_center template function #5066

zx8 opened this issue Dec 10, 2024 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@zx8
Copy link

zx8 commented Dec 10, 2024

Is your feature request related to a problem? Please describe.

Similar to the other issue I recently raised, I'm currently working through the surface-level features of jj to see if I can bring things in line with my git setup.

It does not seem possible to align text to the center of a column in the log output at the moment. Git has support for this via:

%><( <N> ), %><|( <M> )
similar to %<( <N> ), %<|( <M> ) respectively, but padding both sides (i.e. the text is centered)

ref: https://git-scm.com/docs/pretty-formats

Describe the solution you'd like

It would be nice to have a pad_center function, similar to pad_start and pad_end that middle-aligned text.

Describe alternatives you've considered

I'm not sure if there are any alternatives.

@yuja yuja added enhancement New feature or request good first issue Good for newcomers labels Dec 10, 2024
@martinvonz
Copy link
Owner

martinvonz commented Dec 11, 2024

Or perhaps allow multiple templates and pad between them? pad_between(10, "-", "a", "b", "c") => a----b---c (or maybe a---b----c).

@martinvonz
Copy link
Owner

Then we would have:
pad_left(width, template, fill) = pad_between(width, fill, "", template)
pad_right(width, template, fill) = pad_between(width, fill, template, "")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants