From 980ae61d2a6067ae753ec7b11ccec5fc6eca3e89 Mon Sep 17 00:00:00 2001 From: Oliver <480930+rivo@users.noreply.github.com> Date: Sat, 13 Aug 2022 17:03:57 +0200 Subject: [PATCH] Added tabs. Also added TextArea to main documentation. --- textarea.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/textarea.go b/textarea.go index 479db49..c52ede7 100644 --- a/textarea.go +++ b/textarea.go @@ -1420,6 +1420,14 @@ func (t *TextArea) InputHandler() func(event *tcell.EventKey, setFocus func(p Pr t.cursor.row = -1 t.truncateLines(row - 1) t.clampToCursor(row) + t.selectionStart = t.cursor + case tcell.KeyTab: // Insert TabSize spaces. + from, to, row := t.getSelection() + t.cursor.pos = t.replace(from, to, strings.Repeat(" ", TabSize)) + t.cursor.row = -1 + t.truncateLines(row - 1) + t.clampToCursor(row) + t.selectionStart = t.cursor case tcell.KeyRune: if event.Modifiers()&tcell.ModAlt > 0 { // We accept some Alt- key combinations.