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

Implement rs.bold, rs.b and rs.dim in addition to rs.bold_dim and rs.dim_bold #42

Open
feluxe opened this issue Jan 15, 2022 · 5 comments

Comments

@feluxe
Copy link
Owner

feluxe commented Jan 15, 2022

Sty uses rs.bold_dim and rs.dim_bold over rs.bold and rs.dim for the following reason:

The ANSI "SGR (Select Graphic Rendition) parameters" which are used by terminals, do not allow resetting bold and dim separately, there is only parameter 22 which resets both bold and dim. That means we cannot implement a resetter in sty which allows a user to reset bold only or dim only. When I implemented the resetters for bold and dim I decided to make this explicit, thus we have rs.bold_dim / rs.dim_bold. I chose explicitness/correctness over beauty.

After I read #41 I decided to create this ticket and leave it open for discussion if rs.bold, rs.b and rs.dim, should be added, even with the shortcomings (described above).

I wrote down the pros/cons for both options.

A) Only offer rs.bold_dim / rs.dim_bold (as implemented right now)

  • PRO: It's explicit. It describes exactly what happens. No confusion in situations where a user wants to reset bold but not dim or vice versa.
  • CON: As #41 indicates, it may still be confusing for people, because it looks strange.
  • CON: It's really ugly and verbose.

B) Add rs.b / rs.bold / rs.dim and make it very clear in the docs, that each flag always resets both bold and dim.

  • PRO: Consistent with the rest of the interface.
  • PRO: Intuitive: open with ef.bold, close with rs.bold.
  • PRO: Beautiful and non verbose. rs.b vs rs.bold_dim.
  • CON: It can be really nasty, confusing, time consuming for a user who wants to reset bold bot not dim or vice versa.

Right now I'm thinking, maybe B) is the more pragmatic solutions because:

  • The situation in which a user wants to reset bold but not dim and vice versa, might be very rare and the pain from that may be smaller than the pain of all users who have to deal with bold_dim / dim_bold.
  • It's frontend/styling code, which is not critical, so we can go with beauty over correctness.

I'm not sure about this, since there will be pain either way ;-)

I'd love to hear your opinios! You can also use the next two comments to vote for A) or B).

@feluxe
Copy link
Owner Author

feluxe commented Jan 15, 2022

Vote for A)

Give this a thumbs up if you think sty should go with A).

@feluxe
Copy link
Owner Author

feluxe commented Jan 15, 2022

Vote for B)

Give this a thumbs up if you think sty should go with B).

@daxxycodes
Copy link

Not sure if this makes sense to do, but maybe do option (B) but make them work as intended: e.g., have rs.dim reset both bold and dim, but re-apply whatever the previous bold state was.

@feluxe
Copy link
Owner Author

feluxe commented Apr 28, 2022

@daxxycodes This would add a lot of complexity to sty and I'm sure it would hit hard on performance as well. It would also be difficult to keep sty thread safe, I guess. I don't want sty to go this route. Sty should stay lightweight and performant. The problem should be fixed on a lower level, IMHO.

@feluxe feluxe removed the help wanted Extra attention is needed label Jun 15, 2022
@spenserblack
Copy link

GitHub Discussions supports actual polls now, BTW 😉

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

No branches or pull requests

3 participants