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

Set prompt color #13

Closed
wants to merge 4 commits into from
Closed

Set prompt color #13

wants to merge 4 commits into from

Conversation

akerl
Copy link

@akerl akerl commented Feb 20, 2020

This PR adds support for setting Prompt Color to a custom value. I added it because getting the “blue” color to be readable on my dark-background terminal was an exercise in futility.

Copy link
Owner

@ktr0731 ktr0731 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 for submitting a Pull Request!
I suggested some points. Could you confirm it?

And could you merge the latest changes from master? It fixes CI errors.

option.go Outdated
@@ -64,6 +70,13 @@ func WithPromptString(s string) Option {
}
}

// WithPromptString changes the prompt string. The default value is "> ".
Copy link
Owner

Choose a reason for hiding this comment

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

This comment is the same as WithPromptString.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed!

type opt struct {
mode mode
previewFunc func(i, width, height int) string
multi bool
hotReload bool
promptString string
promptColor termbox.Attribute
Copy link
Owner

Choose a reason for hiding this comment

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

I think that it is not preferred to depend on a specific library in the aspect of backward-compatibility. We cannot change termbox to another one because it breaks go-fuzzyfinder's backward-compatibility.
Could you define own Color type and each color?
For example:

type Color int32

const (
    ColorBlack Color = iota
    ColorRed
    ColorGreen
    ColorYellow
    ColorBlue
    ColorMagenta
    ColorCyan
    ColorWhite
)

Copy link
Author

Choose a reason for hiding this comment

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

I don’t think I agree. Because go-fuzzyfinder passes through the defined color code, redefining iotas like this would still involve breaking backwards-compatibility if the termbox dep was replaced later (because there’s no guarantee that the new library defines constant uint16 color codes the same way).

If the goal is to avoid locking the public go-fuzzyfinder API to a specific backing terminal library, I think the code would need to translate everywhere colors are used, so that fuzzyfinder.ColorBlack is converted to termbox.ColorBlack when used (and the same for the other colors), so that it doesn’t rely on the iota layout being permanently consistent.

Copy link
Owner

Choose a reason for hiding this comment

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

At least now the compatibility between I suggested enums and termbox's one will be kept as long as we use Go modules. And if termbox breaks Color backward-compatibility in a new version, we can remap enums we defined when updating go.mod.

However, this opinion is definitely correct. Also, we may replace termbox to tcell in the near future because nsf/go-termbox is not now maintained.
So, could you remap defined colors to termbox's one?

I think the code would need to translate everywhere colors are used, so that fuzzyfinder.ColorBlack is converted to termbox.ColorBlack when used (and the same for the other colors), so that it doesn’t rely on the iota layout being permanently consistent.

Copy link
Owner

Choose a reason for hiding this comment

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

@martinbaillie How about you?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have a strong opinion on this either way. I'm still making use of this library internally at work for some CLIs and flexible prompt colour would be nice.

@ktr0731
Copy link
Owner

ktr0731 commented Mar 4, 2020

@akerl ping

@akerl
Copy link
Author

akerl commented Mar 4, 2020

@ktr0731 I think I agree about the change described above. It’s probable I won’t have the bandwidth to revise this PR for another week or so.

@ktr0731
Copy link
Owner

ktr0731 commented Dec 25, 2020

Could you reopen the PR If it is ready?

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.

None yet

3 participants