Skip to content

Commit

Permalink
add a second theme for easier reading in light terminals (#68)
Browse files Browse the repository at this point in the history
fixes #62
  • Loading branch information
chriswalz authored Oct 29, 2020
1 parent ca19a60 commit acfc65a
Showing 1 changed file with 42 additions and 7 deletions.
49 changes: 42 additions & 7 deletions cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,54 @@ type FileChange struct {
Status string
}

type PromptTheme struct {
PrefixTextColor prompt.Color
SelectedSuggestionBGColor prompt.Color
SuggestionBGColor prompt.Color
SuggestionTextColor prompt.Color
SelectedSuggestionTextColor prompt.Color
DescriptionBGColor prompt.Color
DescriptionTextColor prompt.Color
}

var DefaultTheme = PromptTheme{
PrefixTextColor: prompt.Yellow, // fine
SelectedSuggestionBGColor: prompt.Yellow,
SuggestionBGColor: prompt.Yellow,
SuggestionTextColor: prompt.DarkGray,
SelectedSuggestionTextColor: prompt.Blue,
DescriptionBGColor: prompt.Black,
DescriptionTextColor: prompt.White,
}

var InvertedTheme = PromptTheme{
PrefixTextColor: prompt.Blue, // fine
SelectedSuggestionBGColor: prompt.Blue,
SuggestionBGColor: prompt.Blue,
SuggestionTextColor: prompt.LightGray,
SelectedSuggestionTextColor: prompt.Yellow,
DescriptionBGColor: prompt.White,
DescriptionTextColor: prompt.Black,
}

func SuggestionPrompt(prefix string, completer func(d prompt.Document) []prompt.Suggest) string {
theme := DefaultTheme
themeName := os.Getenv("BIT_THEME")
if strings.EqualFold(themeName, "inverted") {
theme = InvertedTheme
}
result := prompt.Input(prefix, completer,
prompt.OptionTitle(""),
prompt.OptionHistory([]string{""}),
prompt.OptionPrefixTextColor(prompt.Yellow), // fine
prompt.OptionPrefixTextColor(theme.PrefixTextColor), // fine
prompt.OptionSelectedSuggestionBGColor(theme.SelectedSuggestionBGColor),
prompt.OptionSuggestionBGColor(theme.SuggestionBGColor),
prompt.OptionSuggestionTextColor(theme.SuggestionTextColor),
prompt.OptionSelectedSuggestionTextColor(theme.SelectedSuggestionTextColor),
prompt.OptionDescriptionBGColor(theme.DescriptionBGColor),
prompt.OptionDescriptionTextColor(theme.DescriptionTextColor),
//prompt.OptionPreviewSuggestionBGColor(prompt.Yellow),
//prompt.OptionPreviewSuggestionTextColor(prompt.Yellow),
prompt.OptionSelectedSuggestionBGColor(prompt.Yellow),
prompt.OptionSuggestionBGColor(prompt.Yellow),
prompt.OptionSuggestionTextColor(prompt.DarkGray),
prompt.OptionSelectedSuggestionTextColor(prompt.Blue),
prompt.OptionDescriptionBGColor(prompt.Black),
prompt.OptionDescriptionTextColor(prompt.White),
prompt.OptionShowCompletionAtStart(),
prompt.OptionCompletionOnDown(),
prompt.OptionSwitchKeyBindMode(prompt.EmacsKeyBind),
Expand Down

0 comments on commit acfc65a

Please sign in to comment.