-
-
Notifications
You must be signed in to change notification settings - Fork 147
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
feat(console): Add icon that sorting state #301
Merged
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4bc45d6
feat(subscriber): Add icon that sorting state
nrskt c29d6c9
feat(console): Support ASCII-only mode
nrskt 762cacf
Merge branch 'main' into add_icon_asc_or_desc
hawkw ee30549
feat(console): Fix TableList trait
nrskt b16c853
feat(console): Add the methods for styling
nrskt b0e971f
feat(console): Fix the style of all tables
nrskt 6bc5e6a
chore(console): Remove the unnecessary method.
nrskt 9f660ec
Merge branch 'main' into add_icon_asc_or_desc
hawkw a648f5e
Update tokio-console/src/view/styles.rs
nrskt 579c566
Merge branch 'main' into add_icon_asc_or_desc
hawkw 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 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 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 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 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 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 |
---|---|---|
|
@@ -127,6 +127,25 @@ impl Styles { | |
) | ||
} | ||
|
||
pub fn selected<'a>(&self, value: &str) -> Span<'static> { | ||
nrskt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let style = if let Some(cyan) = self.color(Color::Cyan) { | ||
Style::default().fg(cyan) | ||
} else { | ||
Style::default().remove_modifier(Modifier::REVERSED) | ||
}; | ||
Span::styled(value.to_string(), style) | ||
} | ||
|
||
pub fn ascending(&self, value: &str) -> Span<'static> { | ||
let value = format!("{}{}", value, self.if_utf8("▵", "+")); | ||
self.selected(&value) | ||
} | ||
|
||
pub fn descending(&self, value: &str) -> Span<'static> { | ||
let value = format!("{}{}", value, self.if_utf8("▿", "-")); | ||
Comment on lines
+140
to
+145
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. i think it might look a little bit nicer if we added a space after the symbol in the case where it's a plus or minus sign, but not a blocker. |
||
self.selected(&value) | ||
} | ||
|
||
pub fn color(&self, color: Color) -> Option<Color> { | ||
use Palette::*; | ||
match (self.palette, color) { | ||
|
This file contains 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 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.
The
WIDTHS
array seems fine to me, but, for what it's worth, think it would also be fine to just change this code to something likeSince the
HEADER
array is a const, and the1
is also a constant, this calculation should probably get const-folded, so I don't think there would be a performance difference between this approach and creating a separate const array. I think the code might be a bit simpler if we avoided the separate array.But, this is fine either way --- it's not a big deal.