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 · May be fixed by #5542
Open

FR: Add pad_center template function #5066

zx8 opened this issue Dec 10, 2024 · 2 comments · May be fixed by #5542
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
Member

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
Member

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

steadmon added a commit to steadmon/jj that referenced this issue Jan 31, 2025
Add a new pad_center function that centers content within a minimum
width. If an odd number of fill characters is required, the trailing
fill will be one character longer than the leading fill.

Fixes jj-vcs#5066.
@steadmon steadmon linked a pull request Jan 31, 2025 that will close this issue
4 tasks
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

Successfully merging a pull request may close this issue.

3 participants