Repository: pterm/pterm (go)

Issue:
Panic at interactive_textinput_printer
Panic occurs when `pterm.DefaultInteractiveTextInput.WithDefaultValue("default").Show()` is called and a user presses `Left` or `Right` keys to change the default value in-place from a specific position. To understand what I mean, you can run test:

```go
func TestInteractiveTextInputPrinter_Editable(t *testing.T) {
	go func() {
		// change `default` to `deffaultt` by simulating cursor moves `left`, `right` and inserting
		// keys on current cursor positions.
		keyboard.SimulateKeyPress(keys.Left)
		keyboard.SimulateKeyPress(keys.Left)
		keyboard.SimulateKeyPress(keys.Left)
		keyboard.SimulateKeyPress(keys.Left)
		keyboard.SimulateKeyPress(keys.Key{Code: keys.RuneKey, Runes: []rune{'f'}})
		keyboard.SimulateKeyPress(keys.Right)
		keyboard.SimulateKeyPress(keys.Right)
		keyboard.SimulateKeyPress(keys.Right)
		keyboard.SimulateKeyPress(keys.Key{Code: keys.RuneKey, Runes: []rune{'t'}})
		keyboard.SimulateKeyPress(keys.Enter)
	}()

	result, _ := pterm.DefaultInteractiveTextInput.WithDefaultValue("default").Show()
	testza.AssertEqual(t, "deffaultt", result)
}
```

Pull request description:
fix(interactive-textinput): panic at interactive_textinput_printer & edit value in-place
<!-- Please link your PR to an exisiting issue. PRs without an issue may be closed. -->

Fixes #661 


Patch:
diff --git a/interactive_textinput_printer.go b/interactive_textinput_printer.go
index 6926a4be..f649cf8c 100644
--- a/interactive_textinput_printer.go
+++ b/interactive_textinput_printer.go
@@ -108,7 +108,7 @@ func (p InteractiveTextInputPrinter) Show(text ...string) (string, error) {
 	}
 
 	if p.DefaultValue != "" {
-		p.input = append(p.input, Gray(p.DefaultValue))
+		p.input = append(p.input, p.DefaultValue)
 		p.updateArea(&area)
 	}
 
@@ -155,19 +155,16 @@ func (p InteractiveTextInputPrinter) Show(text ...string) (string, error) {
 			}
 		case keys.RuneKey:
 			if !p.startedTyping {
-				p.input = []string{""}
 				p.startedTyping = true
 			}
 			p.input[p.cursorYPos] = string(append([]rune(p.input[p.cursorYPos])[:len([]rune(p.input[p.cursorYPos]))+p.cursorXPos], append([]rune(key.String()), []rune(p.input[p.cursorYPos])[len([]rune(p.input[p.cursorYPos]))+p.cursorXPos:]...)...))
 		case keys.Space:
 			if !p.startedTyping {
-				p.input = []string{" "}
 				p.startedTyping = true
 			}
 			p.input[p.cursorYPos] = string(append([]rune(p.input[p.cursorYPos])[:len([]rune(p.input[p.cursorYPos]))+p.cursorXPos], append([]rune(" "), []rune(p.input[p.cursorYPos])[len([]rune(p.input[p.cursorYPos]))+p.cursorXPos:]...)...))
 		case keys.Backspace:
 			if !p.startedTyping {
-				p.input = []string{""}
 				p.startedTyping = true
 			}
 			if len([]rune(p.input[p.cursorYPos]))+p.cursorXPos > 0 {
@@ -198,6 +195,9 @@ func (p InteractiveTextInputPrinter) Show(text ...string) (string, error) {
 			cancel()
 			return true, nil
 		case keys.Down:
+			if !p.MultiLine {
+				return false, nil
+			}
 			if !p.startedTyping {
 				p.input = []string{""}
 				p.startedTyping = true
@@ -210,6 +210,9 @@ func (p InteractiveTextInputPrinter) Show(text ...string) (string, error) {
 				p.cursorYPos++
 			}
 		case keys.Up:
+			if !p.MultiLine {
+				return false, nil
+			}
 			if !p.startedTyping {
 				p.input = []string{""}
 				p.startedTyping = true
@@ -290,7 +293,7 @@ func (p InteractiveTextInputPrinter) updateArea(area *cursor.Area) string {
 		p.cursorXPos = -internal.GetStringMaxWidth(p.input[p.cursorYPos])
 	}
 
-	area.Update(areaText)
+	area.Update(Gray(areaText))
 	area.Top()
 	area.Down(p.cursorYPos + 1)
 	area.StartOfLine()


Test patch:
diff --git a/interactive_textinput_printer_test.go b/interactive_textinput_printer_test.go
index 803fd72c..feae4e77 100644
--- a/interactive_textinput_printer_test.go
+++ b/interactive_textinput_printer_test.go
@@ -85,6 +85,26 @@ func TestInteractiveTextInputPrinter_OnEnter(t *testing.T) {
 	testza.AssertEqual(t, "default", result)
 }
 
+func TestInteractiveTextInputPrinter_Editable(t *testing.T) {
+	go func() {
+		// change `default` to `deffaultt` by simulating cursor moves `left`, `right` and inserting
+		// keys on current cursor positions.
+		keyboard.SimulateKeyPress(keys.Left)
+		keyboard.SimulateKeyPress(keys.Left)
+		keyboard.SimulateKeyPress(keys.Left)
+		keyboard.SimulateKeyPress(keys.Left)
+		keyboard.SimulateKeyPress(keys.Key{Code: keys.RuneKey, Runes: []rune{'f'}})
+		keyboard.SimulateKeyPress(keys.Right)
+		keyboard.SimulateKeyPress(keys.Right)
+		keyboard.SimulateKeyPress(keys.Right)
+		keyboard.SimulateKeyPress(keys.Key{Code: keys.RuneKey, Runes: []rune{'t'}})
+		keyboard.SimulateKeyPress(keys.Enter)
+	}()
+
+	result, _ := pterm.DefaultInteractiveTextInput.WithDefaultValue("default").Show()
+	testza.AssertEqual(t, "deffaultt", result)
+}
+
 func TestInteractiveTextInputPrinter_WithMultiLineOnTab(t *testing.T) {
 	go func() {
 		keyboard.SimulateKeyPress(keys.Tab)