-
Notifications
You must be signed in to change notification settings - Fork 128
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
Feature/improve colour contrast #43
Feature/improve colour contrast #43
Conversation
Highlight program name in code examples
Also if this is accepted we should update the README example picture. |
Hi. Thanks for your pull request!
That was actually not intentional, I never noticed 🙂 Regarding the proposed change, first of all, do you use some customizations regarding your terminal colors? In a regular dark-background xterm session, the output looks like this: Quite high-contrast to me, I'm not sure why it looks so uniform on your terminal. In contrast, your version looks like this: To me that's less easy to parse (except that highlighting the program name is a great idea). |
@dbrgn this has been without activity for 2 weeks now. How should we proceed? |
@Voultapher sorry, I already typed a reply but never sent it off. I'm a bit tight on free time at the moment. I think the best solution in this case would be theme support (in the sense of a config file where you can specify colors from an ANSI color palette), so that people with non-standard terminal colors can customize the output themselves. However, it should not impact performance in case the defaults are used. Right now we don't have any configfile support. Maybe checking for a configfile (using dirs or directories) when starting up would be an option. If no config file exists, just carry on. If a config file exists, parse it (I think I'd prefer toml format that's being parsed into structs) and apply a theme if it exists. |
Ok, will look into it. |
@Voultapher hehe, actually last week I switched to alacritty by default (instead of uxterm) which uses a slightly different theme with less contrast between green and yellow, for example, so I'm more sympathetic to your feature request now 😄 |
Ok, syntax config support and tests for it are done, concerning performance implication of this feature:
time in seconds
0.010360291 0.012931068 0.011129954 0.009349510 0.009982335
0.011297944 0.011954686 0.011131505 0.010944560 0.010744000
0.010893010 0.009908770 0.010217479 0.010714000 0.011990885 This should not be a noticeable slowdown, no matter if a syntax config is used or not. Btw, serde is dope! Imo error categories, propagation and handling are not perfect, still I'm happy with the current state. Take a look and tell me if there is something to improve. |
Very nice to see these performance numbers 👍 Serde is blazing fast. I'll try to have a look next week if possible, I'll keep this tab open. If I forget for some reason, feel free to remind me in the last week of August, when I have a few free days 🙂 |
Fixes more than one command name per variable highlighting bug Should be easier to read and understand Fix example_variable_style typo
Friendly ping. |
Thanks! Yes, it's still on my todo list for this week 🙂 The weather early this week was great, so I spent it paragliding instead of sitting in front of my computer 😉 |
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.
Hi. Thanks for your contribution, nice PR! I did a first review pass, sorry for the many comments.
Unfortunately the output seems a bit broken:
The first words of the description text is highlighted too. Furthermore, the commands are duplicated tartar
instead of tar
. I do like tartar, but this should be fixed 😛 (Btw, you also copied that error into the test expectations.)
Wow, no idea how I missed that 😛 |
Remove config option short versions Indent README code examples over using code blocks Rename colour to color to stay consitent with rust Remove Ord derives raw_style.into() over Style::from(raw_style) Remove impl From<IoError> from TealdeerError Add debug print to command name lookup Write errors to stderr whenever exiting with non zero return code Rename Config::new() to Config::load()
Add example to inkscape input with multiple command occurrence
From my point of view there are only 2 outstanding items, multipurpose config files and |
src/config.rs
Outdated
} | ||
} | ||
} | ||
|
||
fn map_io_err_to_config_err(e: IoError) -> TealdeerError { | ||
ConfigError(format!("Io Error: {}", e)) | ||
} |
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.
Good approach, with the helper function! 👍
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.
Thanks @Voultapher for the changes after my last review!
I left some further comments. I think after those are handled, it should be ready to merge.
Once it's in the code, we can start thinking whether we want to optimize the default style, and how to share configs for different "themes".
Else indentation Serde rename Generalize config, rename and make style member
@dbrgn only the description highlighting left unresolved. Everything else looks good.Also should we warn the user if |
Thanks for the adjustments!
That's a good idea. I think even showing an error message à la "A configuration file already exists at , no action was taken" with a non-0 exit code would be fine.
What do you think about the YAML proposal above? Shouldn't be too hard to try thanks to libraries like serde-yaml, and I think it would improve readability. (I'd be fine wtih TOML too though.) |
I'll repost what I wrote earlier about toml vs serde, it seems you didn't see it: Personally prefer toml over yaml for confgs like this, also if we make the style config a member of the config object, there is no need to introduce a block. Looks like this: [style.highlight]
foreground = "blue"
underline = false
bold = true
[style.description]
underline = false
bold = false
[style.example_text]
underline = false
bold = false
[style.example_code]
underline = false
bold = false
[style.example_variable]
underline = true
bold = false To add to it. The yaml version would look something like this: style:
highlight:
foreground: blue
underline: false
bold: true
description:
underline: false
bold: false
example_text:
underline: false
bold: false
example_code:
underline: false
bold: false
example_variable:
underline: true
bold: false Not sure that is better. |
This feature was deemed potentially too confusing
dispay-config might be misleading, as this option does not display the config content
@dbrgn from my side everything is resolved. |
Friendly ping. |
OK let's keep TOML for now :) I'll do some more adjustments (like making the default style like the previous default) and will then merge the branch! Thanks a lot @Voultapher for your patience :) |
Make it a bit more colorful, like the previous style
This allows the user to omit the fields when creating a config file.
1de174b
to
6651f7f
Compare
Merged in 278a2bb! |
@Voultapher Ok, all open pull requests have been merged. I'll leave for 2 weeks of vacation tomorrow, some testing would be welcome during that time. If everything works, I plan to make the next release early October. |
What
Before:
After:
Why
Right now the only reason I use a painfully slow python version of tldr is because its colour scheme makes quickly glancing at a tldr and seeing what I'm looking for much easier than when looking at the monotone low contrast produced by the current version of tealdeer.
The current contrast of most likely dark background to teal is challenging for certain people with colour blindness. I understand that the project is called tealdear and removing the teal colour might make the pun obsolete.
If you prefer the old colour scheme, I suggest making it an option. People that want another scheme could do
alias tldr=tldr --color=teal
.Implementation Notes
I chose to go with string indexing over
split
andflat_map
as I wanted to avoid a performance regression. In a micro benchmark,format_code
is faster and more consistent thanformat_braces
whilst doing more work. Yet it is seems to be only a small fraction of the overall time, which means I wouldn't be opposed to rewriting it in a more readable fashion.Pulling the command from the title isn't pretty, the command name is present when called regularly, however when using the option
--render
we would have to either introduce a new parameter to specify the command, which would increase usage burden and could introduce user errors, or accept different behavior for regular use vs--render
which I find particular bad. This solution doesn't change the current interface and behaves the same way in regular use and--render
. However I have not tested if all tldr files correctly specify the program title in their title.