Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
koki-develop committed Apr 2, 2023
1 parent 7ecd3b6 commit 4ba1017
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 1 deletion.
7 changes: 7 additions & 0 deletions docs/cli/README.ja.md
Expand Up @@ -54,6 +54,7 @@ $ go install github.com/koki-develop/go-fzf/cmd/gofzf@latest
`gofzf` CLI はフラグを使用して様々な見た目のカスタマイズができます。

- [プロンプト](#プロンプト)
- [インプットの位置](#インプットの位置)
- [インプットのプレースホルダ](#インプットのプレースホルダ)
- [インプットのテキスト](#インプットのテキスト)
- [カーソル](#カーソル)
Expand All @@ -75,6 +76,12 @@ $ go install github.com/koki-develop/go-fzf/cmd/gofzf@latest
| `--prompt-underline` | `false` | プロンプトに下線を引く。 |
| `--prompt-faint` | `false` | プロンプトを薄く表示する。 |

#### インプットの位置

| フラグ | デフォルト | 説明 |
| ------------------ | ---------- | ------------------------------------------------------- |
| `--input-position` | `"top"` | インプットの位置。 `top` もしくは `bottom` が有効です。 |

#### インプットのプレースホルダ

| フラグ | デフォルト | 説明 |
Expand Down
7 changes: 7 additions & 0 deletions docs/cli/README.md
Expand Up @@ -54,6 +54,7 @@ Setting the `--no-limit` flag allows unlimited item selection.
The `gofzf` CLI allows for various visual customizations using flags.

- [Prompt](#prompt)
- [Position of input](#position-of-input)
- [Placeholder for input](#placeholder-for-input)
- [Input text](#input-text)
- [Cursor](#cursor)
Expand All @@ -75,6 +76,12 @@ The `gofzf` CLI allows for various visual customizations using flags.
| `--prompt-underline` | `false` | Underline prompt. |
| `--prompt-faint` | `false` | Faint prompt. |

#### Position of input

| Flag | Default | Description |
| ------------------ | ------- | ----------------------------------------------------- |
| `--input-position` | `"top"` | Position of input. Either `top` or `bottom` is valid. |

#### Placeholder for input

| Flag | Default | Description |
Expand Down
16 changes: 16 additions & 0 deletions docs/library/README.ja.md
Expand Up @@ -154,6 +154,7 @@ if err != nil {
- [プロンプト](#プロンプト)
- [カーソル](#カーソル)
- [選択中 / 未選択アイテムの接頭辞](#選択中--未選択アイテムの接頭辞)
- [インプットの位置](#インプットの位置)
- [インプットのプレースホルダ](#インプットのプレースホルダ)
- [カウントビュー](#カウントビュー)
- [スタイル](#スタイル)
Expand Down Expand Up @@ -201,6 +202,21 @@ if err != nil {

[Example](/examples/prefix/)

#### インプットの位置

`fzf.WithInputPosition()` を使用するとインプットの位置を設定できます。

```go
f, err := fzf.New(
fzf.WithInputPosition(fzf.InputPositionBottom),
)
if err != nil {
// ...
}
```

[Example](/examples/input-position/)

#### インプットのプレースホルダ

`fzf.WithInputPlaceholder()` を使用するとインプットのプレースホルダを設定できます。
Expand Down
16 changes: 16 additions & 0 deletions docs/library/README.md
Expand Up @@ -155,6 +155,7 @@ if err != nil {
- [Prompt](#prompt)
- [Cursor](#cursor)
- [Prefix of selected/unselected items](#prefix-of-selectedunselected-items)
- [Position of input](#position-of-input)
- [Placeholder for input](#placeholder-for-input)
- [Count View](#count-view)
- [Styles](#styles)
Expand Down Expand Up @@ -203,6 +204,21 @@ if err != nil {

[Example](/examples/prefix/)

#### Position of input

`fzf.WithInputPosition()` can be used to set the position of input.

```go
f, err := fzf.New(
fzf.WithInputPosition(fzf.InputPositionBottom),
)
if err != nil {
// ...
}
```

[Example](/examples/input-position/)

#### Placeholder for input

`fzf.WithCursor()` can be used to set the placeholder for input.
Expand Down
1 change: 1 addition & 0 deletions examples/input-position/README.md
@@ -0,0 +1 @@
![](./demo.gif)
Binary file added examples/input-position/demo.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions examples/input-position/main.go
@@ -0,0 +1,28 @@
package main

import (
"fmt"
"log"

"github.com/koki-develop/go-fzf"
)

func main() {
items := []string{"hello", "world", "foo", "bar"}

f, err := fzf.New(
fzf.WithInputPosition(fzf.InputPositionBottom),
)
if err != nil {
log.Fatal(err)
}

idxs, err := f.Find(items, func(i int) string { return items[i] })
if err != nil {
log.Fatal(err)
}

for _, i := range idxs {
fmt.Println(items[i])
}
}
2 changes: 1 addition & 1 deletion option.go
Expand Up @@ -221,7 +221,7 @@ func WithCaseSensitive(s bool) Option {
}
}

// WithInputPosition sets the position of the input.
// WithInputPosition sets the position of input.
func WithInputPosition(p InputPosition) Option {
return func(o *option) {
o.inputPosition = p
Expand Down
39 changes: 39 additions & 0 deletions tapes/library/input-position.tape
@@ -0,0 +1,39 @@
# configuration
Output ./examples/input-position/demo.gif
Set Shell "bash"
Set FontSize 32
Set Width 1200
Set Height 600

# setup
Hide
Type "mkdir ./tmp" Enter
Type "cp ./examples/input-position/main.go ./tmp/main.go" Enter
Type "cd ./tmp" Enter
Ctrl+l
Show

# ---

Type "go run ./main.go" Sleep 750ms Enter
Sleep 2s

Up 2
Sleep 1s

Down 2
Sleep 1s

Type "world"
Sleep 750ms

Enter

Sleep 3s

# ---

# cleanup
Hide
Type "cd ../" Enter
Type "\rm -rf ./tmp" Enter

0 comments on commit 4ba1017

Please sign in to comment.