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 support for some basic attributes for the windows terminal. #62

Merged
merged 1 commit into from
Dec 30, 2018
Merged

Implement support for some basic attributes for the windows terminal. #62

merged 1 commit into from
Dec 30, 2018

Conversation

Jezza
Copy link
Contributor

@Jezza Jezza commented Dec 16, 2018

Closes #60.

@Jezza
Copy link
Contributor Author

Jezza commented Dec 16, 2018

You'll probably notice that it doesn't have the full list of values that windows supports as methods, and that's because of how crossterm constructs styles and what the other windows' values are used for.

The values I've omitted, but added explicit members in the enum for are "reset" values, and due to how the styles are constructed, it you can't really construct a line that contains multiple "on"s and "off"s.
Eg, you can't say style("Introducing ").bold().text("Me").reset().text(" and I.") which would output something like "Introducing Me and I."
The ObjectStyles in crossterm don't seem to be built that way, so it makes no sense to add explicit support for the values as methods.
The values themselves are there in the enum, so you could conceivably, chain together multiple object styles, printing them out one by one, and then in that case, the reset would come in handy, but at that point, it might be easier just to wrap that with your own thing....

@Jezza
Copy link
Contributor Author

Jezza commented Dec 17, 2018

Looking back, I think a better solution to this might be doing what Std does.
Have system specific modules, and then just export those based on the system.
That way the user can still access attributes for other systems, as it is possible that someone can use this library for sending terminal seqs over the wire.

Copy link
Member

@TimonPost TimonPost left a comment

Choose a reason for hiding this comment

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

Nice work!

You mean just allowing the user to execute their own ANSI escape codes?

@Jezza
Copy link
Contributor Author

Jezza commented Dec 30, 2018

Yeah, but do it in a controlled fashion.

format!("{}Inverted{}Normal", Attribute::Inverted, Attribute::Reset)

It doesn't stop people from being stupid, but it didn't do that before.
It just makes composing things easier.

@TimonPost
Copy link
Member

TimonPost commented Dec 30, 2018

Jup that totally true, however, for now, I am fine whit those changes. This should become another PR.

@TimonPost TimonPost merged commit 14bd60a into crossterm-rs:master Dec 30, 2018
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.

None yet

2 participants