diff --git a/cmd/gofzf/main.go b/cmd/gofzf/main.go index 014bfc3..ec50a17 100644 --- a/cmd/gofzf/main.go +++ b/cmd/gofzf/main.go @@ -54,6 +54,15 @@ var ( flagInputPlaceholderUnderline bool flagInputPlaceholderFaint bool + flagInputTextFg string + flagInputTextBg string + flagInputTextBold bool + flagInputTextBlink bool + flagInputTextItalic bool + flagInputTextStrikethrough bool + flagInputTextUnderline bool + flagInputTextFaint bool + flagCursorFg string flagCursorBg string flagCursorBold bool @@ -143,6 +152,16 @@ var rootCmd = &cobra.Command{ Underline: flagInputPlaceholderUnderline, Faint: flagInputPlaceholderFaint, }), + fzf.WithStyleInputText(fzf.Style{ + ForegroundColor: flagInputTextFg, + BackgroundColor: flagInputTextBg, + Bold: flagInputTextBold, + Blink: flagInputTextBlink, + Italic: flagInputTextItalic, + Strikethrough: flagInputTextStrikethrough, + Underline: flagInputTextUnderline, + Faint: flagInputTextFaint, + }), fzf.WithStyleCursor(fzf.Style{ ForegroundColor: flagCursorFg, BackgroundColor: flagCursorBg, @@ -341,6 +360,15 @@ func init() { rootCmd.Flags().BoolVar(&flagInputPlaceholderUnderline, "input-placeholder-underline", false, "") rootCmd.Flags().BoolVar(&flagInputPlaceholderFaint, "input-placeholder-faint", true, "") + rootCmd.Flags().StringVar(&flagInputTextFg, "input-text-fg", "", "") + rootCmd.Flags().StringVar(&flagInputTextBg, "input-text-bg", "", "") + rootCmd.Flags().BoolVar(&flagInputTextBold, "input-text-bold", false, "") + rootCmd.Flags().BoolVar(&flagInputTextBlink, "input-text-blink", false, "") + rootCmd.Flags().BoolVar(&flagInputTextItalic, "input-text-italic", false, "") + rootCmd.Flags().BoolVar(&flagInputTextStrikethrough, "input-text-strike", false, "") + rootCmd.Flags().BoolVar(&flagInputTextUnderline, "input-text-underline", false, "") + rootCmd.Flags().BoolVar(&flagInputTextFaint, "input-text-faint", false, "") + rootCmd.Flags().StringVar(&flagCursorFg, "cursor-fg", mainColor, "") rootCmd.Flags().StringVar(&flagCursorBg, "cursor-bg", "", "") rootCmd.Flags().BoolVar(&flagCursorBold, "cursor-bold", false, "") diff --git a/docs/cli/README.ja.md b/docs/cli/README.ja.md index 2b9e57a..66c5967 100644 --- a/docs/cli/README.ja.md +++ b/docs/cli/README.ja.md @@ -55,6 +55,7 @@ $ go install github.com/koki-develop/go-fzf/cmd/gofzf@latest - [プロンプト](#プロンプト) - [インプットのプレースホルダ](#インプットのプレースホルダ) +- [インプットのテキスト](#インプットのテキスト) - [カーソル](#カーソル) - [カーソル行](#カーソル行) - [選択中 / 未選択アイテムの接頭辞](#選択中--未選択アイテムの接頭辞) @@ -88,6 +89,19 @@ $ go install github.com/koki-develop/go-fzf/cmd/gofzf@latest | `--input-placeholder-underline` | `false` | インプットのプレースホルダに下線を引く。 | | `--input-placeholder-faint` | `true` | インプットのプレースホルダを薄く表示する。 | +#### インプットのテキスト + +| フラグ | デフォルト | 説明 | +| ------------------------------- | ---------- | ------------------------------------------ | +| `--input-placeholder-fg` | N/A | インプットのテキストの文字色。 | +| `--input-placeholder-bg` | N/A | インプットのテキストの背景色。 | +| `--input-placeholder-bold` | `false` | インプットのテキストを太字にする。 | +| `--input-placeholder-blink` | `false` | インプットのテキストを点滅させる。 | +| `--input-placeholder-italic` | `false` | インプットのテキストをイタリック体にする。 | +| `--input-placeholder-strike` | `false` | インプットのテキストに取り消し線を引く。 | +| `--input-placeholder-underline` | `false` | インプットのテキストに下線を引く。 | +| `--input-placeholder-faint` | `false` | インプットのテキストを薄く表示する。 | + #### カーソル | フラグ | デフォルト | 説明 | diff --git a/docs/cli/README.md b/docs/cli/README.md index 50b2e9c..c5c97c7 100644 --- a/docs/cli/README.md +++ b/docs/cli/README.md @@ -55,6 +55,7 @@ The `gofzf` CLI allows for various visual customizations using flags. - [Prompt](#prompt) - [Placeholder for input](#placeholder-for-input) +- [Input text](#input-text) - [Cursor](#cursor) - [Cursor Line](#cursor-line) - [Prefix of selected/unselected items](#prefix-of-selectedunselected-items) @@ -88,6 +89,19 @@ The `gofzf` CLI allows for various visual customizations using flags. | `--input-placeholder-underline` | `false` | Underline placeholder for input. | | `--input-placeholder-faint` | `true` | Faint placeholder for input. | +#### Input text + +| Flag | Default | Description | +| ------------------------ | ------- | ------------------------------- | +| `--input-text-fg` | N/A | Foreground color of input text. | +| `--input-text-bg` | N/A | Background color of input text. | +| `--input-text-bold` | `false` | Bold input text. | +| `--input-text-blink` | `false` | Blink input text. | +| `--input-text-italic` | `false` | Italicize input text. | +| `--input-text-strike` | `false` | Strkethrough input text. | +| `--input-text-underline` | `false` | Underline input text. | +| `--input-text-faint` | `false` | Faint input text. | + #### Cursor | Flag | Default | Description | diff --git a/docs/library/README.ja.md b/docs/library/README.ja.md index 31c1ab6..d83a955 100644 --- a/docs/library/README.ja.md +++ b/docs/library/README.ja.md @@ -246,6 +246,7 @@ f, err := fzf.New( fzf.WithStyles( fzf.WithStylePrompt(fzf.Style{Faint: true}), // プロンプト fzf.WithStyleInputPlaceholder(fzf.Style{Faint: true, ForegroundColor: "#ff0000"}), // インプットのプレースホルダ + fzf.WithStyleInputText(fzf.Style{Italic: true}), // インプットのテキスト fzf.WithStyleCursor(fzf.Style{Bold: true}), // カーソル fzf.WithStyleCursorLine(fzf.Style{Bold: true}), // カーソル行 fzf.WithStyleMatches(fzf.Style{ForegroundColor: "#ff0000"}), // 一致文字 diff --git a/docs/library/README.md b/docs/library/README.md index b0956c2..1a05500 100644 --- a/docs/library/README.md +++ b/docs/library/README.md @@ -248,6 +248,7 @@ f, err := fzf.New( fzf.WithStyles( fzf.WithStylePrompt(fzf.Style{Faint: true}), // Prompt fzf.WithStyleInputPlaceholder(fzf.Style{Faint: true, ForegroundColor: "#ff0000"}), // Placeholder for input + fzf.WithStyleInputText(fzf.Style{Italic: true}), // Input text fzf.WithStyleCursor(fzf.Style{Bold: true}), // Cursor fzf.WithStyleCursorLine(fzf.Style{Bold: true}), // Cursor line fzf.WithStyleMatches(fzf.Style{ForegroundColor: "#ff0000"}), // Matched characters diff --git a/examples/styles/main.go b/examples/styles/main.go index 119da96..0998550 100644 --- a/examples/styles/main.go +++ b/examples/styles/main.go @@ -15,6 +15,7 @@ func main() { fzf.WithStyles( fzf.WithStylePrompt(fzf.Style{Faint: true}), // Prompt fzf.WithStyleInputPlaceholder(fzf.Style{Faint: true, ForegroundColor: "#ff0000"}), // Placeholder for input + fzf.WithStyleInputText(fzf.Style{Italic: true}), // Input text fzf.WithStyleCursor(fzf.Style{Bold: true}), // Cursor fzf.WithStyleCursorLine(fzf.Style{Bold: true}), // Cursor line fzf.WithStyleMatches(fzf.Style{ForegroundColor: "#ff0000"}), // Matched characters diff --git a/model.go b/model.go index 1605c7b..51e3e13 100644 --- a/model.go +++ b/model.go @@ -54,6 +54,7 @@ func newModel(opt *option) *model { input.PromptStyle = opt.styles.option.prompt input.Placeholder = opt.inputPlaceholder input.PlaceholderStyle = opt.styles.option.inputPlaceholder + input.TextStyle = opt.styles.option.inputText input.Focus() if !opt.multiple() { diff --git a/styles.go b/styles.go index 0311a8f..6d3cf01 100644 --- a/styles.go +++ b/styles.go @@ -7,6 +7,7 @@ var ( defaultStylesOption = stylesOption{ prompt: lipgloss.NewStyle(), inputPlaceholder: lipgloss.NewStyle().Faint(true), + inputText: lipgloss.NewStyle(), cursor: lipgloss.NewStyle().Foreground(lipgloss.Color(defaultColor)), cursorLine: lipgloss.NewStyle().Bold(true), matches: lipgloss.NewStyle().Foreground(lipgloss.Color(defaultColor)), @@ -69,6 +70,7 @@ type StylesOption func(o *stylesOption) type stylesOption struct { prompt lipgloss.Style inputPlaceholder lipgloss.Style + inputText lipgloss.Style cursor lipgloss.Style cursorLine lipgloss.Style selectedPrefix lipgloss.Style @@ -92,13 +94,20 @@ func WithStylePrompt(s Style) StylesOption { } } -// WithInputPlaceholder sets the placeholder for input. +// WithInputPlaceholder sets the style of placeholder for input. func WithStyleInputPlaceholder(s Style) StylesOption { return func(o *stylesOption) { o.inputPlaceholder = s.lipgloss() } } +// WithStyleInputText sets the style of input text. +func WithStyleInputText(s Style) StylesOption { + return func(o *stylesOption) { + o.inputText = s.lipgloss() + } +} + // WithStyleCursor sets the style of cursor. func WithStyleCursor(s Style) StylesOption { return func(o *stylesOption) {