Skip to content

textarea, how to handle linebreaks? #800

@1F47E

Description

@1F47E

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions