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

Support replacing angle brackets in SelectView popup button #794

Merged
merged 2 commits into from
Jun 18, 2024

Conversation

bgilbert
Copy link
Contributor

@bgilbert bgilbert commented Jun 12, 2024

Allow a SelectView to be configured with custom decorators instead of the angle brackets around the current item label.

@gyscos
Copy link
Owner

gyscos commented Jun 17, 2024

Hi, and thanks for the work!

For buttons, the user can entirely replicate the brackets from the new_raw function, by including the desired replacement (for example if they want square brackets, nothing at all, or even putting back the original brackets themselves!) in the given string.

Here though, what ends up being displayed is a combination of the selected entry (which can change, and should not include brackets directly) and the "decorators" (currently hard-coded to be angled brackets).

I would be fine adding an option to replace the angled brackets with user-defined decorators (potentially an empty string). I guess it would take store a String for each side.

Fixes: c173bbf ("Support autojump in popup SelectView (#793)")
@bgilbert bgilbert changed the title Support disabling angle brackets in SelectView popup button Support replacing angle brackets in SelectView popup button Jun 18, 2024
@bgilbert
Copy link
Contributor Author

Good point, updated!

Copy link
Owner

@gyscos gyscos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

Just a few comments (mostly len vs width). Also since you get the sum of the decorators width, it may make sense to have a method to get it easily.

cursive-core/src/views/select_view.rs Outdated Show resolved Hide resolved
cursive-core/src/views/select_view.rs Outdated Show resolved Hide resolved
cursive-core/src/views/select_view.rs Outdated Show resolved Hide resolved
@bgilbert
Copy link
Contributor Author

Updated, added a helper method to compute the total decorator width, and fixed coordinate calculation for the popup.

cursive-core/src/views/select_view.rs Outdated Show resolved Hide resolved
cursive-core/src/views/select_view.rs Outdated Show resolved Hide resolved
Allow a SelectView to be configured with custom decorators instead of the
angle brackets around the current item label.

Fix up calculation of the available width for the item label.
@bgilbert
Copy link
Contributor Author

Done!

Copy link
Owner

@gyscos gyscos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for bearing with me!

@gyscos gyscos merged commit 8918201 into gyscos:main Jun 18, 2024
1 check passed
@bgilbert
Copy link
Contributor Author

No problem, thanks for the reviews!

@bgilbert bgilbert deleted the select-popup-raw branch June 18, 2024 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants