Skip to content

Consolidate button/checkbox creation #382

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ivanovkirilg
Copy link
Contributor

@ivanovkirilg ivanovkirilg commented May 31, 2025

Before this PR, there are three possibilities for a Button's checked state:

  • Nothing, e.g. [Yes]
  • Unchecked, e.g. | About |
    This only leaves space for a checkmark.
  • Checked, e.g. |🗹 Word Wrap ...

The button only shows the provided checked state, without internal toggle logic.

Separately, there is a checkbox() function that partly overlaps with the button logic:

  • Unchecked, e.g. [☐ Match Case]
    This is not available via ButtonStyle
  • Checked, e.g. [🗹 Match Case]

The checkbox automatically toggles the given bool parameter if activated.

Note that the 'unchecked' variants of the button and checkbox are different, meaning there are four total states/styles.

Change

I have consolidated (to some degree) the checkmark-drawing code.

  1. I changed the checked: Option<bool> to an enum Checkmark that now consolidates the four possible states/styles. (Absent, AlignOnly, Checked, Unchecked)
  2. The checkbox() now uses the button() + ButtonStyle, where previously most of its code was duplicated.
  3. The Word Wrap toggle is now a proper checkbox.
    Edit: I had also converted the OVR (overtype) indicator, but reverted it on request.

Various checkboxes

Sorry if this should have been multiple PRs, the chronological order of the changes was quite chaotic. If any of this is controversial, e.g. the OVR checkbox, I can revert it.

@ivanovkirilg ivanovkirilg requested a review from lhecker June 5, 2025 20:26
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