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

Ansi color in preview mode #29

Closed
davixcky opened this issue Oct 9, 2020 · 7 comments
Closed

Ansi color in preview mode #29

davixcky opened this issue Oct 9, 2020 · 7 comments
Labels
enhancement New feature or request

Comments

@davixcky
Copy link

davixcky commented Oct 9, 2020

Describe the bug

I want to display text with Ansi colors (provided by github.com/logrusorgru/aurora). It's not possible, or it's not make sense?

To reproduce

	projects, err := hbtn.GetProjects()
		if err != nil {
			log.Fatal(err)
		}

		idx, err := fuzzyfinder.FindMulti(
			projects,
			func(i int) string {
				return projects[i].Title
			},
			fuzzyfinder.WithPreviewWindow(func(i, w, h int) string {
				if i == -1 {
					return ""
				}

				return fmt.Sprintf("Track: %s (%s)\nAlbum: %s",
					Green(projects[i].Title),
					projects[i].Tasks,
					projects[i].ID)
			}))
		if err != nil {
			log.Fatal(err)
		}
		fmt.Printf("selected: %v\n", idx)

Expected behavior

Screenshots

image

Environment

  • OS: Arch linux
  • Terminal: Tilix
  • go-fuzzyfinder version: Latest

Additional context

@davixcky davixcky added the bug Something isn't working label Oct 9, 2020
@ktr0731 ktr0731 added enhancement New feature or request and removed bug Something isn't working labels Oct 11, 2020
@ktr0731
Copy link
Owner

ktr0731 commented Oct 11, 2020

@davixcky
I think it makes sense that providing ANSI color, and it's possible.
Actually, fzf's preview window can display ANSI color-enabled text.

@ktr0731 ktr0731 added the help wanted Extra attention is needed label Oct 11, 2020
@RyanGreenup
Copy link

This would be a nice feature, what would be needed to get this working?

@ktr0731
Copy link
Owner

ktr0731 commented Jul 31, 2021

@RyanGreenup
Hi, I'm sorry for the late reply.
Currently, go-fuzzyfinder can't interpret the ANSI escape code for the string returned from WithPreviewWindow. So, we need to implement it.

@RyanGreenup
Copy link

So, we need to implement it.

I'm not a programmer by trade but I am trying to learn Go. If I manage to get some free time I'll look at trying it, I think this would be really handy and would work really well with Glow.


@danielfoehrKn
Copy link

That would be really nice to have, both for the main search window as well for the preview window.

@ktr0731 ktr0731 closed this as completed in 3788372 Jul 3, 2022
@ktr0731
Copy link
Owner

ktr0731 commented Jul 3, 2022

This is now partially supported, but we are going to not publish a new version until the rest of the ANSI color codes will be implemented.

@ktr0731 ktr0731 reopened this Jul 3, 2022
@ktr0731 ktr0731 removed the help wanted Extra attention is needed label Oct 23, 2022
@ktr0731
Copy link
Owner

ktr0731 commented Oct 23, 2022

This is now fully supported by go-fuzzyfinder v0.7.0. Please try it out!

@ktr0731 ktr0731 closed this as completed Oct 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants