Skip to content

Colorの変更 #41

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

Merged
merged 1 commit into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 10 additions & 17 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,14 @@ func (cm configModel) View() string {
switch cm.configKeySelected {
// 設定項目を選んでいない時
case false:
white := color.New(color.FgWhite).SprintFunc()
b.WriteString(white("設定項目を選んでください:\n"))
b.WriteString(white(" ↑↓の矢印キーで項目を移動、Enterで選択\n"))
b.WriteString(color.WhiteString("設定項目を選んでください:\n"))
b.WriteString(color.WhiteString(" ↑↓の矢印キーで項目を移動、Enterで選択\n"))

for i, choice := range configKey {
cyan := color.New(color.FgCyan).SprintFunc()
hiCyan := color.New(color.FgHiCyan).SprintFunc()
if i == cm.configKeyIndex {
b.WriteString(fmt.Sprintf(hiCyan("➡️ %s\n"), choice))
b.WriteString(fmt.Sprintf(color.HiCyanString("➡️ %s\n"), choice))
} else {
b.WriteString(fmt.Sprintf(cyan(" %s\n"), choice))
b.WriteString(fmt.Sprintf(color.CyanString(" %s\n"), choice))
}
}

Expand All @@ -139,26 +136,22 @@ func (cm configModel) View() string {
// 選択肢のない項目はテキストエリアを表示
switch len(configOption[cm.configKeyIndex]) {
case 0:
white := color.New(color.FgWhite).SprintFunc()
b.WriteString(white(fmt.Sprintf(
b.WriteString(color.WhiteString(fmt.Sprintf(
"ここに%sを入力: %s\n",
configKey[cm.configKeyIndex],
cm.textInput.View(),
)))
b.WriteString(white(" Enterキーで確定"))
b.WriteString(color.WhiteString(" Enterキーで確定"))

default:
white := color.New(color.FgWhite).SprintFunc()
b.WriteString(white("設定内容を選んでください:\n"))
b.WriteString(white(" ↑↓の矢印キーで項目を移動、Enterで選択\n"))
b.WriteString(color.WhiteString("設定内容を選んでください:\n"))
b.WriteString(color.WhiteString(" ↑↓の矢印キーで項目を移動、Enterで選択\n"))

for i, option := range configOption[cm.configKeyIndex] {
cyan := color.New(color.FgCyan).SprintFunc()
hiCyan := color.New(color.FgHiCyan).SprintFunc()
if i == cm.configOptionIndex {
b.WriteString(fmt.Sprintf(hiCyan("➡️ %s\n"), option))
b.WriteString(fmt.Sprintf(color.HiCyanString("➡️ %s\n"), option))
} else {
b.WriteString(fmt.Sprintf(cyan(" %s\n"), option))
b.WriteString(fmt.Sprintf(color.CyanString(" %s\n"), option))
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions cmd/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ Copyright © 2023 NAME HERE <EMAIL ADDRESS>
package cmd

import (
"fmt"

"github.com/cocoide/commitify/static"
"github.com/fatih/color"
"github.com/spf13/cobra"
Expand All @@ -17,9 +15,7 @@ var docsCmd = &cobra.Command{
Short: "Document of commitify",
Run: func(cmd *cobra.Command, args []string) {
b, _ := static.Logo.ReadFile("logo.txt")
cyan := color.New(color.FgCyan).SprintFunc()
logo := cyan(string(b))
fmt.Println(logo)
color.Cyan(string(b))
},
}

Expand Down
17 changes: 6 additions & 11 deletions cmd/suggest.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,28 +76,23 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {

func (m model) View() string {
if m.errorMsg != "" {
red := color.New(color.FgRed).SprintFunc()
return fmt.Sprintf(red(m.errorMsg))
return color.RedString(m.errorMsg)
}
if m.isLoading {
return "🌎 Generating commit messages ..."
}
var b strings.Builder
if m.errorMsg != "" {
red := color.New(color.FgRed).SprintFunc()
b.WriteString(red(m.errorMsg) + "\n\n")
b.WriteString(color.RedString(m.errorMsg) + "\n\n")
}
white := color.New(color.FgWhite).SprintFunc()
b.WriteString(white("🍕Please select an option:"))
b.WriteString(white("\n Use arrow ↑↓ to navigate and press Enter to select.\n\n"))
b.WriteString(color.WhiteString("🍕Please select an option:"))
b.WriteString(color.WhiteString("\n Use arrow ↑↓ to navigate and press Enter to select.\n\n"))

for i, choice := range m.choices {
cyan := color.New(color.FgCyan).SprintFunc()
hiCyan := color.New(color.FgHiCyan).SprintFunc()
if i == m.currentIdx {
b.WriteString(fmt.Sprintf(hiCyan("➡️ %s\n"), choice))
b.WriteString(fmt.Sprintf(color.HiCyanString("➡️ %s\n"), choice))
} else {
b.WriteString(fmt.Sprintf(cyan(" %s\n"), choice))
b.WriteString(fmt.Sprintf(color.CyanString(" %s\n"), choice))
}
}
return b.String()
Expand Down