bubbletea icon indicating copy to clipboard operation
bubbletea copied to clipboard

textarea, how to handle linebreaks?

Open 1F47E opened this issue 2 years ago • 3 comments

Hi there! I'm building chat TUI app where I have textarea as text input.

I'm stuck with 2 issues right now:

  1. 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?

  2. 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!

1F47E avatar Aug 14 '23 22:08 1F47E

This should be fixed once this PR is merged: https://github.com/charmbracelet/bubbletea/pull/397

milanglacier avatar Nov 07 '23 21:11 milanglacier

Please merge this!

nadimkobeissi avatar Dec 28 '23 14:12 nadimkobeissi

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.

meowgorithm avatar Jan 10 '24 14:01 meowgorithm

Hi! Bubble Tea supports bracketed paste as of v0.26.0. If you’re still having trouble here please reopen the issue. Thanks!

meowgorithm avatar May 08 '24 20:05 meowgorithm