-
Notifications
You must be signed in to change notification settings - Fork 285
Console colors #3015
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
Merged
Merged
Console colors #3015
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f06b563
ui_message_handlert retains console_message_handlert object
kroening 33569fa
added a message color API
kroening f133a25
use colors in BMC status reporting
kroening b27c1e8
use colors in gcc personality
kroening d999a3e
use formatting in goto-analyzer
kroening File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,20 +36,25 @@ class console_message_handlert : public message_handlert | |
|
|
||
| virtual void flush(unsigned level) override; | ||
|
|
||
| console_message_handlert() : always_flush(false) | ||
| console_message_handlert() : console_message_handlert(false) | ||
| { | ||
| } | ||
|
|
||
| explicit console_message_handlert(bool always_flush) | ||
| : always_flush(always_flush) | ||
| { | ||
| } | ||
| explicit console_message_handlert(bool always_flush); | ||
|
|
||
| std::string command(unsigned c) const override; | ||
|
|
||
| protected: | ||
| const bool always_flush; | ||
|
|
||
| /// true if we are outputting to a proper console | ||
| bool is_a_tty; | ||
|
|
||
| /// true if we use ECMA-48 SGR to render colors | ||
| bool use_SGR; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ? |
||
| }; | ||
|
|
||
| class gcc_message_handlert : public message_handlert | ||
| class gcc_message_handlert : public console_message_handlert | ||
| { | ||
| public: | ||
| // aims to imitate the messages gcc prints | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,6 +65,13 @@ class message_handlert | |
| return message_count[level]; | ||
| } | ||
|
|
||
| /// \brief Create an ECMA-48 SGR (Select Graphic Rendition) command. | ||
| /// The default behavior is no action. | ||
| virtual std::string command(unsigned) const | ||
| { | ||
| return std::string(); | ||
| } | ||
|
|
||
| protected: | ||
| unsigned verbosity; | ||
| std::vector<std::size_t> message_count; | ||
|
|
@@ -275,6 +282,52 @@ class messaget | |
| return m; | ||
| } | ||
|
|
||
| /// \brief Create an ECMA-48 SGR (Select Graphic Rendition) command. | ||
| std::string command(unsigned c) const | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Docs. |
||
| { | ||
| if(message_handler) | ||
| return message_handler->command(c); | ||
| else | ||
| return std::string(); | ||
| } | ||
|
|
||
| /// return to default formatting, | ||
| /// as defined by the terminal | ||
| std::string reset() const | ||
| { | ||
| return command(0); | ||
| } | ||
|
|
||
| /// render text with red foreground color | ||
| std::string red() const | ||
| { | ||
| return command(31); | ||
| } | ||
|
|
||
| /// render text with green foreground color | ||
| std::string green() const | ||
| { | ||
| return command(32); | ||
| } | ||
|
|
||
| /// render text with yellow foreground color | ||
| std::string yellow() const | ||
| { | ||
| return command(33); | ||
| } | ||
|
|
||
| /// render text with blue foreground color | ||
| std::string blue() const | ||
| { | ||
| return command(34); | ||
| } | ||
|
|
||
| /// render text with bold font | ||
| std::string bold() const | ||
| { | ||
| return command(1); | ||
| } | ||
|
|
||
| mstreamt &get_mstream(unsigned message_level) const | ||
| { | ||
| mstream.message_level=message_level; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing documentation. The name does not in an obvious way relate to it's functionality, and what values
cshould take is a mystery.