summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/client/ui/core/chat/chat.go9
-rw-r--r--internal/client/ui/viminput/viminput.go33
2 files changed, 38 insertions, 4 deletions
diff --git a/internal/client/ui/core/chat/chat.go b/internal/client/ui/core/chat/chat.go
index a93272f..e143eb0 100644
--- a/internal/client/ui/core/chat/chat.go
+++ b/internal/client/ui/core/chat/chat.go
@@ -14,13 +14,14 @@ type Model struct {
}
func New() Model {
- vi := viminput.New(30, 3)
+ vi := viminput.New(90, 3)
vi.Placeholder = "Send a message..."
vi.PlaceholderStyle = lipgloss.NewStyle().Foreground(colors.Gray)
vi.LineDecoration = func(lnum int, m viminput.Model) string {
- lineNumberDecor := viminput.LineNumberDecoration(lipgloss.NewStyle())
- lineNumber := lineNumberDecor(lnum, m)
- return lineNumber + " ┃ "
+ // lineNumberDecor := viminput.LineNumberDecoration(lipgloss.NewStyle())
+ // lineNumber := lineNumberDecor(lnum, m)
+ // return lineNumber + " ┃ "
+ return "┃ "
}
vi.SetLines([]rune("test"), []rune("best"))
diff --git a/internal/client/ui/viminput/viminput.go b/internal/client/ui/viminput/viminput.go
index e3ebd0c..f45c472 100644
--- a/internal/client/ui/viminput/viminput.go
+++ b/internal/client/ui/viminput/viminput.go
@@ -254,6 +254,39 @@ func (m *Model) handleInsertModeKeys(key tea.KeyMsg) tea.Cmd {
return nil
}
+ if key.Type == tea.KeyBackspace {
+ line := m.lines[m.cursorLine]
+ if m.cursorColumn == 0 && m.cursorLine != 0 {
+ lineBefore := m.lines[m.cursorLine-1]
+ cursorColumn := len(lineBefore)
+
+ m.lines = slices.Delete(m.lines, m.cursorLine, m.cursorLine+1)
+ m.lines[m.cursorLine-1] = append(lineBefore, line...)
+
+ m.SetCursorLine(m.cursorLine - 1)
+ m.SetCursorColumn(cursorColumn)
+ } else if len(line) != 0 {
+ m.lines[m.cursorLine] = slices.Delete(line, m.cursorColumn-1, m.cursorColumn)
+ m.SetCursorColumn(m.cursorColumn - 1)
+ }
+ return nil
+ }
+
+ if key.Type == tea.KeyEnter {
+ line := m.lines[m.cursorLine]
+ after := line[m.cursorColumn:]
+ m.lines[m.cursorLine] = line[:m.cursorColumn]
+
+ var newline []rune
+ newline = append(newline, after...)
+ m.lines = slices.Insert(m.lines, m.cursorLine+1, newline)
+
+ m.SetCursorLine(m.cursorLine + 1)
+ m.SetCursorColumn(0)
+
+ return nil
+ }
+
keyStr := key.String()
length := len(keyStr)
if length == 1 && 32 <= keyStr[0] && keyStr[0] <= 126 {