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

--center option doesn't play well with --size #140

Closed
jaminthorns opened this issue Apr 28, 2023 · 3 comments
Closed

--center option doesn't play well with --size #140

jaminthorns opened this issue Apr 28, 2023 · 3 comments
Labels
feature New feature or request
Milestone

Comments

@jaminthorns
Copy link

I use Chafa for rendering previews of files within other programs, which makes the --size option super useful. Since I'm rendering to a statically-sized preview area, it would be nice to have these previews centered. I thought the --center option would solve this, but it doesn't seem to take the --size option into account.

Instead, it's adding a left offset based on the detected width of the terminal, not the width given through --size. In lf, where the preview takes 1/2 the screen width, this results in a preview that's cut off:

Screenshot 2023-04-28 at 4 37 00 PM

Additionally, it would be nice if there was a vertical offset when --size and --center are both provided so that the image would be vertically centered as well.

@hpjansson
Copy link
Owner

Hi, thanks for reporting this. You're correct, --center centers with respect to the terminal size. What I think we need is to be able to specify --frame-size to override the terminal size detection. Then we'll have:

stateDiagram-v2
  state frame-size {
    size
}
Loading

If --frame-size is unspecified, it will be read from the terminal. If --size is not specified, it will be chosen to be <= frame-size. When --center is specified, the inner area will be centered on the outer.

Additionally, we could add an --align <x,y> option, e.g. --align top,center or --align center,center. I think the current --center option should keep its semantics: only align horizontally. It's useful for scrolling terminals where you don't expect extra space before the next prompt.

See also #115 (comment) and #84 (comment) for related comments/discussions.

Sound good?

@hpjansson hpjansson added this to the 1.14 milestone May 1, 2023
@jaminthorns
Copy link
Author

Keeping the semantics of --center makes perfect sense, maybe adding to the description of the flag (in --help and man page) that it only centers horizontally. The --align flag sounds perfect and would allow for even more use cases. That all sounds great, thank you!

@hpjansson
Copy link
Owner

You should be able to get what you want with the new --view-size and --align options when combined with --size (the inner maximum size). You may need to add --relative on for relative positioning.

Please let me know if you find any issues!

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

No branches or pull requests

2 participants