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

[WIP] add line highlight #346

Closed
wants to merge 3 commits into from
Closed

[WIP] add line highlight #346

wants to merge 3 commits into from

Conversation

tskinn
Copy link
Contributor

@tskinn tskinn commented Oct 10, 2018

There might be a better place to get the background highlight color. Not sure.

@tskinn tskinn mentioned this pull request Oct 10, 2018
Copy link
Owner

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

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

Thank you very much!

The code looks good. I think we should somehow extend the highlighting a little bit, though. Currently, empty lines can not be highlighted at all, for example. We should think about either extending the highlighting-range to the right side of the screen or by extending it into the side panel on the left(?). What do you think?

src/printer.rs Outdated
@@ -296,6 +301,18 @@ impl<'a> Printer for InteractivePrinter<'a> {
}
}

// Line highlighting
let background = match self.config.highlight_line {
Copy link
Owner

Choose a reason for hiding this comment

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

This whole block could be something like:

let background = self.config.highlight_line
    .filter(|line| line == line_number)
    .map(|_| self.background_highlight);

Granted, I'm not sure if that is easier to read. Soon, there will be Option::replace which could be used instead of .map(|_| ..).

src/clap_app.rs Outdated
.long("highlight-line")
.overrides_with("highlight-line")
.takes_value(true)
.value_name("n")
Copy link
Owner

Choose a reason for hiding this comment

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

Can we use a captital N here to be consistent with the --line-range option?

src/clap_app.rs Outdated
.value_name("n")
.help("Highlight a line.")
.long_help(
"Highlight the nth line. The background color is changed to create contrast.",
Copy link
Owner

Choose a reason for hiding this comment

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

this would be "the N-th line" then.

@tskinn
Copy link
Contributor Author

tskinn commented Oct 11, 2018

I agree! Right when I started testing the changes I thought this kind of sucks if it doesn't change more that just the background of the text.

let background = self.config.highlight_line
.filter(|line| *line == line_number)
.map(|_| self.background_highlight)
.unwrap();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is undesirable right? I was getting and Option<Option> situation.

Copy link
Owner

@sharkdp sharkdp Oct 11, 2018

Choose a reason for hiding this comment

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

Yes. We want to avoid unwrap. In this case, it should be and_then instead of map.

@sharkdp
Copy link
Owner

sharkdp commented Oct 11, 2018

I agree! Right when I started testing the changes I thought this kind of sucks if it doesn't change more that just the background of the text.

If you have any ideas, feel free to experiment here.

@sharkdp
Copy link
Owner

sharkdp commented Oct 23, 2018

@tskinn Any updates on this? How do you think we should proceed here?

@tskinn
Copy link
Contributor Author

tskinn commented Oct 23, 2018

Sorry, no updates! I haven't looked very deeply into it yet. I've bin a little strapped for time lately but I will try to find some time this week.

@sharkdp sharkdp mentioned this pull request Dec 16, 2018
@sharkdp
Copy link
Owner

sharkdp commented Dec 16, 2018

closing this in favor of #453

@sharkdp sharkdp closed this Dec 16, 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.

2 participants