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

highlight individual line #175

Closed
tskinn opened this issue Jun 23, 2018 · 8 comments · Fixed by #453
Closed

highlight individual line #175

tskinn opened this issue Jun 23, 2018 · 8 comments · Fixed by #453
Labels
feature-request New feature or request

Comments

@tskinn
Copy link
Contributor

tskinn commented Jun 23, 2018

Now that bat supports displaying a range of lines I would like to have bat be able to highlight one line.

My use case has to do with utilizing bat as a preview command in a fuzzy finder like fzf or skim.

Here is what we can do currently with bat: fzf
(I'm just using a copy of preview.sh I've put up here)

So how can or should this be done? Invert the colors of the line? Does syntec api have something that makes this easy? Or should we just manipulate the grid portion of the display like the line number or insert an arrow in that gutter?

Again I'd be happy to work on it but would like some input before I do.

@sharkdp
Copy link
Owner

sharkdp commented Jul 2, 2018

Sounds good!

So how can or should this be done? Invert the colors of the line?

I'd prefer using a background color, but this could be problematic when using different (dark or light) themes, I guess.

Does syntec api have something that makes this easy?

Not sure, but we translate syntect style => ANSI style ourselves, so it should be easy to modify the style in the highlighted lines.

Or should we just manipulate the grid portion of the display like the line number or insert an arrow in that gutter?

That would be problematic if no sidebar / no line-numbers are used.

@sharkdp
Copy link
Owner

sharkdp commented Aug 18, 2018

Related: trishume/syntect#198

@sharkdp
Copy link
Owner

sharkdp commented Sep 5, 2018

The next syntect release will include the mentioned helper to modify line style.

@tskinn
Copy link
Contributor Author

tskinn commented Oct 9, 2018

Looks likes syntec has a new release! https://github.com/trishume/syntect/releases
I'll have to see if upgrading breaks anything.

@sharkdp
Copy link
Owner

sharkdp commented Oct 9, 2018

Looks likes syntec has a new release! trishume/syntect/releases
I'll have to see if upgrading breaks anything.

See #345

@sharkdp
Copy link
Owner

sharkdp commented Oct 9, 2018

Actually, I just realized that we might not need that helper function after all 😄.

We never use background colors so far, so we can additional set them when we render to ANSI codes. I have implemented an initial prototype on the highlight-lines branch.

If someone wants to take this and turn it into a fully-working solution, that'd be greatly appreciated!

There are a few things to work out:

  • Two obvious TODOs in the code
  • We probably want to extend the highlighting to the full line (not just the text content). I'm not really sure what the best option would be to achieve this.

@tskinn
Copy link
Contributor Author

tskinn commented Oct 10, 2018

#346 but I forgot about the full line highlight. Yeah at the moment it just does background with content.

@sharkdp
Copy link
Owner

sharkdp commented Feb 8, 2019

Released in v0.10.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants