gyscos / cursive

A Text User Interface library for the Rust programming language
MIT License
4.26k stars 243 forks source link

Support replacing angle brackets in `SelectView` popup button #794

Closed bgilbert closed 3 months ago

bgilbert commented 3 months ago

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

gyscos commented 3 months ago

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.

bgilbert commented 3 months ago

Good point, updated!

bgilbert commented 3 months ago

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

bgilbert commented 3 months ago

Done!

bgilbert commented 3 months ago

No problem, thanks for the reviews!