Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
maaslalani committed Jun 5, 2024
2 parents bbaef64 + 4cb2312 commit c58c7ea
Show file tree
Hide file tree
Showing 26 changed files with 200 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint-soft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v5
uses: golangci/golangci-lint-action@v6
with:
# Optional: golangci-lint command line arguments.
args: --config .golangci-soft.yml --issues-exit-code=0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v5
uses: golangci/golangci-lint-action@v6
with:
# Optional: golangci-lint command line arguments.
#args:
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ fmt.Println("Order up!")
</table>

For more on Spinners see the [spinner examples](./spinner/examples) and
[the spinner docs](https://pkg.go.dev/github.com/charmbracelet/huh@main/spinner).
[the spinner docs](https://pkg.go.dev/github.com/charmbracelet/huh/spinner).

## What about Bubble Tea?

Expand Down Expand Up @@ -401,6 +401,8 @@ For some `Huh?` programs in production, see:
* [meteor](https://github.com/stefanlogue/meteor): a highly customisable conventional commit message tool
* [freeze](https://github.com/charmbracelet/freeze): a tool for generating images of code and terminal output
* [gum](https://github.com/charmbracelet/gum): a tool for glamorous shell scripts
* [savvy](https://github.com/getsavvyinc/savvy-cli): the easiest way to create, share, and run runbooks in the terminal


## Feedback

Expand Down
5 changes: 4 additions & 1 deletion examples/burger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ func main() {
form := huh.NewForm(
huh.NewGroup(huh.NewNote().
Title("Charmburger").
Description("Welcome to _Charmburger™_.\n\nHow may we take your order?")),
Description("Welcome to _Charmburger™_.\n\nHow may we take your order?\n\n").
Next(true).
NextLabel("Let's go!"),
),

// Choose a burger.
// We'll need to know what topping to add too.
Expand Down
Empty file.
32 changes: 32 additions & 0 deletions examples/filepicker/demo.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Set Shell bash

Set Width 800
Set Height 725

Hide
Type "clear && go build -o file"
Enter
Show

Sleep .5s
Type "./file" Sleep .5s
Enter

Sleep 1s
Type "Frank" Sleep 500ms
Enter

Sleep 1s
Type "_frank" Sleep 500ms
Enter

Sleep 1s
Enter
Sleep 1s
Type@200ms "jjjj"
Sleep 1s
Enter

Sleep 1.5s
Type "hunter2"
Sleep 4s
20 changes: 13 additions & 7 deletions examples/filepicker/main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package main

import (
"fmt"

"github.com/charmbracelet/huh"
)

Expand All @@ -11,16 +9,24 @@ func main() {

huh.NewForm(
huh.NewGroup(
huh.NewInput().Title("Name").Description("What's your name?"),
huh.NewInput().
Title("Name").
Description("What's your name?"),

huh.NewInput().
Title("Username").
Description("Select your username."),

huh.NewFilePicker().
Title("Select a file:").
Description("This will be your profile image.").
Title("Profile").
Description("Select your profile picture.").
AllowedTypes([]string{".png", ".jpeg", ".webp", ".gif"}).
Value(&file),

huh.NewInput().Title("Name").Description("What's your name?"),
huh.NewInput().
Title("Password").
EchoMode(huh.EchoModePassword).
Description("Set your Password."),
),
).WithShowHelp(true).Run()
fmt.Println(file)
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added examples/filepicker/profile.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 12 additions & 8 deletions examples/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ go 1.19

require (
github.com/charmbracelet/bubbles v0.18.0
github.com/charmbracelet/bubbletea v0.26.1
github.com/charmbracelet/bubbletea v0.26.3
github.com/charmbracelet/huh v0.0.0-00010101000000-000000000000
github.com/charmbracelet/huh/spinner v0.0.0-00010101000000-000000000000
github.com/charmbracelet/lipgloss v0.10.1-0.20240506202754-3ee5dcab73cb
github.com/charmbracelet/lipgloss v0.11.0
github.com/charmbracelet/log v0.4.0
github.com/charmbracelet/ssh v0.0.0-20240401141849-854cddfa2917
github.com/charmbracelet/ssh v0.0.0-20240515141028-546b2ee33a4d
github.com/charmbracelet/wish v1.4.0
github.com/charmbracelet/x/exp/strings v0.0.0-20240506152644-8135bef4e495
github.com/charmbracelet/x/exp/strings v0.0.0-20240524151031-ff83003bf67a
)

require (
Expand All @@ -21,8 +21,12 @@ require (
github.com/catppuccin/go v0.2.0 // indirect
github.com/charmbracelet/harmonica v0.2.0 // indirect
github.com/charmbracelet/keygen v0.5.0 // indirect
github.com/charmbracelet/x/errors v0.0.0-20240117030013-d31dba354651 // indirect
github.com/charmbracelet/x/exp/term v0.0.0-20240506152644-8135bef4e495 // indirect
github.com/charmbracelet/x/ansi v0.1.1 // indirect
github.com/charmbracelet/x/errors v0.0.0-20240524151031-ff83003bf67a // indirect
github.com/charmbracelet/x/exp/term v0.0.0-20240524151031-ff83003bf67a // indirect
github.com/charmbracelet/x/input v0.1.1 // indirect
github.com/charmbracelet/x/term v0.1.1 // indirect
github.com/charmbracelet/x/windows v0.1.2 // indirect
github.com/creack/pty v1.1.21 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
Expand All @@ -36,11 +40,11 @@ require (
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
golang.org/x/crypto v0.21.0 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/term v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
)

Expand Down
39 changes: 24 additions & 15 deletions examples/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,34 @@ github.com/catppuccin/go v0.2.0 h1:ktBeIrIP42b/8FGiScP9sgrWOss3lw0Z5SktRoithGA=
github.com/catppuccin/go v0.2.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc=
github.com/charmbracelet/bubbles v0.18.0 h1:PYv1A036luoBGroX6VWjQIE9Syf2Wby2oOl/39KLfy0=
github.com/charmbracelet/bubbles v0.18.0/go.mod h1:08qhZhtIwzgrtBjAcJnij1t1H0ZRjwHyGsy6AL11PSw=
github.com/charmbracelet/bubbletea v0.26.1 h1:xujcQeF73rh4jwu3+zhfQsvV18x+7zIjlw7/CYbzGJ0=
github.com/charmbracelet/bubbletea v0.26.1/go.mod h1:FzKr7sKoO8iFVcdIBM9J0sJOcQv5nDQaYwsee3kpbgo=
github.com/charmbracelet/bubbletea v0.26.3 h1:iXyGvI+FfOWqkB2V07m1DF3xxQijxjY2j8PqiXYqasg=
github.com/charmbracelet/bubbletea v0.26.3/go.mod h1:bpZHfDHTYJC5g+FBK+ptJRCQotRC+Dhh3AoMxa/2+3Q=
github.com/charmbracelet/harmonica v0.2.0 h1:8NxJWRWg/bzKqqEaaeFNipOu77YR5t8aSwG4pgaUBiQ=
github.com/charmbracelet/harmonica v0.2.0/go.mod h1:KSri/1RMQOZLbw7AHqgcBycp8pgJnQMYYT8QZRqZ1Ao=
github.com/charmbracelet/keygen v0.5.0 h1:XY0fsoYiCSM9axkrU+2ziE6u6YjJulo/b9Dghnw6MZc=
github.com/charmbracelet/keygen v0.5.0/go.mod h1:DfvCgLHxZ9rJxdK0DGw3C/LkV4SgdGbnliHcObV3L+8=
github.com/charmbracelet/lipgloss v0.10.1-0.20240506202754-3ee5dcab73cb h1:Hs3xzxHuruNT2Iuo87iS40c0PhLqpnUKBI6Xw6Ad3wQ=
github.com/charmbracelet/lipgloss v0.10.1-0.20240506202754-3ee5dcab73cb/go.mod h1:EPP2QJ0ectp3zo6gx9f8oJGq8keirqPJ3XpYEI8wrrs=
github.com/charmbracelet/lipgloss v0.11.0 h1:UoAcbQ6Qml8hDwSWs0Y1cB5TEQuZkDPH/ZqwWWYTG4g=
github.com/charmbracelet/lipgloss v0.11.0/go.mod h1:1UdRTH9gYgpcdNN5oBtjbu/IzNKtzVtb7sqN1t9LNn8=
github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM=
github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM=
github.com/charmbracelet/ssh v0.0.0-20240401141849-854cddfa2917 h1:NZKjJ7d/pzk/AfcJYEzmF8M48JlIrrY00RR5JdDc3io=
github.com/charmbracelet/ssh v0.0.0-20240401141849-854cddfa2917/go.mod h1:8/Ve8iGRRIGFM1kepYfRF2pEOF5Y3TEZYoJaA54228U=
github.com/charmbracelet/ssh v0.0.0-20240515141028-546b2ee33a4d h1:u9HPsRc4wlU2mGLEX180ZeP4UIutqT2nQ7LVVgejP2E=
github.com/charmbracelet/ssh v0.0.0-20240515141028-546b2ee33a4d/go.mod h1:8/Ve8iGRRIGFM1kepYfRF2pEOF5Y3TEZYoJaA54228U=
github.com/charmbracelet/wish v1.4.0 h1:pL1uVP/YuYgJheHEj98teZ/n6pMYnmlZq/fcHvomrfc=
github.com/charmbracelet/wish v1.4.0/go.mod h1:ew4/MjJVfW/akEO9KmrQHQv1F7bQRGscRMrA+KtovTk=
github.com/charmbracelet/x/errors v0.0.0-20240117030013-d31dba354651 h1:3RXpZWGWTOeVXCTv0Dnzxdv/MhNUkBfEcbaTY0zrTQI=
github.com/charmbracelet/x/errors v0.0.0-20240117030013-d31dba354651/go.mod h1:2P0UgXMEa6TsToMSuFqKFQR+fZTO9CNGUNokkPatT/0=
github.com/charmbracelet/x/exp/strings v0.0.0-20240506152644-8135bef4e495 h1:/aQyDLa4ptexEC+jETEzgXNfMZety/g+niLB4eYsKhM=
github.com/charmbracelet/x/exp/strings v0.0.0-20240506152644-8135bef4e495/go.mod h1:pBhA0ybfXv6hDjQUZ7hk1lVxBiUbupdw5R31yPUViVQ=
github.com/charmbracelet/x/exp/term v0.0.0-20240506152644-8135bef4e495 h1:+0U9qX8Pv8KiYgRxfBvORRjgBzLgHMjtElP4O0PyKYA=
github.com/charmbracelet/x/exp/term v0.0.0-20240506152644-8135bef4e495/go.mod h1:qeR6w1zITbkF7vEhcx0CqX5GfnIiQloJWQghN6HfP+c=
github.com/charmbracelet/x/ansi v0.1.1 h1:CGAduulr6egay/YVbGc8Hsu8deMg1xZ/bkaXTPi1JDk=
github.com/charmbracelet/x/ansi v0.1.1/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw=
github.com/charmbracelet/x/errors v0.0.0-20240524151031-ff83003bf67a h1:0lYEktGULal6+O5l2gmEf6ZIEujR9OQqHF4K6V+rGYE=
github.com/charmbracelet/x/errors v0.0.0-20240524151031-ff83003bf67a/go.mod h1:2P0UgXMEa6TsToMSuFqKFQR+fZTO9CNGUNokkPatT/0=
github.com/charmbracelet/x/exp/strings v0.0.0-20240524151031-ff83003bf67a h1:lOpqe2UvPmlln41DGoii7wlSZ/q8qGIon5JJ8Biu46I=
github.com/charmbracelet/x/exp/strings v0.0.0-20240524151031-ff83003bf67a/go.mod h1:pBhA0ybfXv6hDjQUZ7hk1lVxBiUbupdw5R31yPUViVQ=
github.com/charmbracelet/x/exp/term v0.0.0-20240524151031-ff83003bf67a h1:k/s6UoOSVynWiw7PlclyGO2VdVs5ZLbMIHiGp4shFZE=
github.com/charmbracelet/x/exp/term v0.0.0-20240524151031-ff83003bf67a/go.mod h1:YBotIGhfoWhHDlnUpJMkjebGV2pdGRCn1Y4/Nk/vVcU=
github.com/charmbracelet/x/input v0.1.1 h1:YDOJaTUKCqtGnq9PHzx3pkkl4pXDOANUHmhH3DqMtM4=
github.com/charmbracelet/x/input v0.1.1/go.mod h1:jvdTVUnNWj/RD6hjC4FsoB0SeZCJ2ZBkiuFP9zXvZI0=
github.com/charmbracelet/x/term v0.1.1 h1:3cosVAiPOig+EV4X9U+3LDgtwwAoEzJjNdwbXDjF6yI=
github.com/charmbracelet/x/term v0.1.1/go.mod h1:wB1fHt5ECsu3mXYusyzcngVWWlu1KKUmmLhfgr/Flxw=
github.com/charmbracelet/x/windows v0.1.2 h1:Iumiwq2G+BRmgoayww/qfcvof7W/3uLoelhxojXlRWg=
github.com/charmbracelet/x/windows v0.1.2/go.mod h1:GLEO/l+lizvFDBPLIOk+49gdX49L9YWMB5t+DZd0jkQ=
github.com/creack/pty v1.1.21 h1:1/QdRyBaHHJP61QkWMXlOIBfsgdDeeKfK8SYVUWJKf0=
github.com/creack/pty v1.1.21/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down Expand Up @@ -60,8 +68,10 @@ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
Expand All @@ -71,7 +81,6 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw=
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
2 changes: 2 additions & 0 deletions examples/ssh-form/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build none

package main

import (
Expand Down
3 changes: 3 additions & 0 deletions field_filepicker.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ func NewFilePicker() *FilePicker {
// CurrentDirectory sets the directory of the file field.
func (f *FilePicker) CurrentDirectory(directory string) *FilePicker {
f.picker.CurrentDirectory = directory
if cmd := f.picker.Init(); cmd != nil {
f.picker, _ = f.picker.Update(cmd())
}
return f
}

Expand Down
6 changes: 6 additions & 0 deletions field_input.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,14 @@ func (i *Input) View() string {
i.textinput.PlaceholderStyle = styles.TextInput.Placeholder
i.textinput.PromptStyle = styles.TextInput.Prompt
i.textinput.Cursor.Style = styles.TextInput.Cursor
i.textinput.Cursor.TextStyle = styles.TextInput.CursorText
i.textinput.TextStyle = styles.TextInput.Text

// Adjust text input size to its char limit if it fit in its width
if i.textinput.CharLimit > 0 {
i.textinput.Width = min(i.textinput.CharLimit, i.textinput.Width)
}

var sb strings.Builder
if i.title != "" {
sb.WriteString(styles.Title.Render(i.title))
Expand Down
3 changes: 2 additions & 1 deletion field_multiselect.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func (m *MultiSelect[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case key.Matches(msg, m.keymap.HalfPageDown):
m.cursor = min(m.cursor+m.viewport.Height/2, len(m.filteredOptions)-1)
m.viewport.HalfViewDown()
case key.Matches(msg, m.keymap.Toggle):
case key.Matches(msg, m.keymap.Toggle) && !m.filtering:
for i, option := range m.options {
if option.Key == m.filteredOptions[m.cursor].Key {
if !m.options[m.cursor].selected && m.limit > 0 && m.numSelected() >= m.limit {
Expand Down Expand Up @@ -514,6 +514,7 @@ func (m *MultiSelect[T]) WithTheme(theme *Theme) Field {
}
m.theme = theme
m.filter.Cursor.Style = m.theme.Focused.TextInput.Cursor
m.filter.Cursor.TextStyle = m.theme.Focused.TextInput.CursorText
m.filter.PromptStyle = m.theme.Focused.TextInput.Prompt
m.updateViewportHeight()
return m
Expand Down
18 changes: 17 additions & 1 deletion field_note.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type Note struct {
// customization
title string
description string
nextLabel string

// state
showNextButton bool
Expand All @@ -32,6 +33,7 @@ func NewNote() *Note {
return &Note{
showNextButton: false,
skip: true,
nextLabel: "Next",
}
}

Expand All @@ -53,6 +55,12 @@ func (n *Note) Next(show bool) *Note {
return n
}

// NextLabel sets the next button label.
func (n *Note) NextLabel(label string) *Note {
n.nextLabel = label
return n
}

// Focus focuses the note field.
func (n *Note) Focus() tea.Cmd {
n.focused = true
Expand Down Expand Up @@ -131,7 +139,7 @@ func (n *Note) View() string {
sb.WriteString(render(n.description))
}
if n.showNextButton {
sb.WriteString(styles.Next.Render("Next"))
sb.WriteString(styles.Next.Render(n.nextLabel))
}
return styles.Card.Render(sb.String())
}
Expand Down Expand Up @@ -218,9 +226,17 @@ func (n *Note) GetKey() string {
func render(input string) string {
var result strings.Builder
var italic, bold, codeblock bool
var escape bool

for _, char := range input {
if escape {
result.WriteRune(char)
escape = false
continue
}
switch char {
case '\\':
escape = true
case '_':
if !italic {
result.WriteString("\033[3m")
Expand Down
1 change: 1 addition & 0 deletions field_select.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ func (s *Select[T]) WithTheme(theme *Theme) Field {
}
s.theme = theme
s.filter.Cursor.Style = s.theme.Focused.TextInput.Cursor
s.filter.Cursor.TextStyle = s.theme.Focused.TextInput.CursorText
s.filter.PromptStyle = s.theme.Focused.TextInput.Prompt
s.updateViewportHeight()
return s
Expand Down
5 changes: 3 additions & 2 deletions field_text.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ func (t *Text) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case key.Matches(msg, t.keymap.Editor):
ext := strings.TrimPrefix(t.editorExtension, ".")
tmpFile, _ := os.CreateTemp(os.TempDir(), "*."+ext)
cmd := exec.Command(t.editorCmd, append(t.editorArgs, tmpFile.Name())...) //nolint:gosec
_ = os.WriteFile(tmpFile.Name(), []byte(t.textarea.Value()), os.ModePerm)
cmd := exec.Command(t.editorCmd, append(t.editorArgs, tmpFile.Name())...)
_ = os.WriteFile(tmpFile.Name(), []byte(t.textarea.Value()), 0600)
cmds = append(cmds, tea.ExecProcess(cmd, func(error) tea.Msg {
content, _ := os.ReadFile(tmpFile.Name())
_ = os.Remove(tmpFile.Name())
Expand Down Expand Up @@ -276,6 +276,7 @@ func (t *Text) View() string {
textareaStyles.Prompt = styles.TextInput.Prompt
textareaStyles.CursorLine = styles.TextInput.Text
t.textarea.Cursor.Style = styles.TextInput.Cursor
t.textarea.Cursor.TextStyle = styles.TextInput.CursorText

var sb strings.Builder
if t.title != "" {
Expand Down

0 comments on commit c58c7ea

Please sign in to comment.