textarea, how to handle linebreaks?
Hi there! I'm building chat TUI app where I have textarea as text input.
I'm stuck with 2 issues right now:
-
I can't distinguish line breaks in the message from tea.KeyEnter. For example when multiline text is pasted from clipboard to textarea. Is it possible somehow pre process text form textarea to remove line breaks so that tea.KeyEnter will be not triggered in Update?
-
I cant find key combination of shift + enter for the line break while entering text inside textarea. I'm using tab right now for that. Using keypress as string "shift+enter" doesn't work.
switch keypress := msg.String(); keypress {
case "ctrl+enter":
m.textarea.SetValue(m.textarea.Value() + "\n")
}
I can go with multiline route
ta.KeyMap.InsertNewline.SetEnabled(true)
But then still need a key to send a message like shift+enter or ctrl+enter
Please point me in the right direction if there is any. Thanks!
This should be fixed once this PR is merged: https://github.com/charmbracelet/bubbletea/pull/397
Please merge this!
Hi! #397 is in the process of being merged, however we don't have an ETA yet. A proper bracketed paste solution is nuanced and will require additional work beyond the PR.
Hi! Bubble Tea supports bracketed paste as of v0.26.0. If you’re still having trouble here please reopen the issue. Thanks!