summaryrefslogtreecommitdiff
path: root/internal/client/ui/core/chat/chat.go
diff options
context:
space:
mode:
authorKyren223 <Kyren223@proton.me>2024-12-05 14:11:28 +0200
committerKyren223 <Kyren223@proton.me>2024-12-05 14:11:28 +0200
commit8087907b4b942c7d8c9296c3fd0e1f08d5d88694 (patch)
treec0a58a78503443b11df7027b415b6406d3b8178b /internal/client/ui/core/chat/chat.go
parent37cd043920aa92189d9ae19e7631968290e4d352 (diff)
Refactored how the core UI looks
Diffstat (limited to 'internal/client/ui/core/chat/chat.go')
-rw-r--r--internal/client/ui/core/chat/chat.go37
1 files changed, 25 insertions, 12 deletions
diff --git a/internal/client/ui/core/chat/chat.go b/internal/client/ui/core/chat/chat.go
index b3597a8..04eedb7 100644
--- a/internal/client/ui/core/chat/chat.go
+++ b/internal/client/ui/core/chat/chat.go
@@ -1,9 +1,6 @@
package chat
import (
- "log"
-
- "github.com/charmbracelet/bubbles/textarea"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
@@ -12,31 +9,34 @@ import (
)
type Model struct {
- vi viminput.Model
+ vi viminput.Model
+ focus bool
}
func New() Model {
vi := viminput.New(30, 3)
vi.Placeholder = "Send a message..."
vi.PlaceholderStyle = lipgloss.NewStyle().Foreground(colors.Gray)
- vi.LineDecoration = func(lnum int, line string, cursorLnum int) string {
- return "┃ "
+ vi.LineDecoration = func(lnum int, m viminput.Model) string {
+ lineNumberDecor := viminput.LineNumberDecoration(lipgloss.NewStyle())
+ lineNumber := lineNumberDecor(lnum, m)
+ return lineNumber + " ┃ "
}
- // vi.ShowLineNumbers = false
+
+ vi.SetLines(viminput.Line("test"), viminput.Line("best"))
+ // ta.Cursor.SetChar()
// vi.CharLimit = 280
// vi.Focus()
- log.Println("Placeholder:", vi.Placeholder)
-
return Model{
- vi: vi,
+ vi: vi,
}
}
func (m Model) Init() tea.Cmd {
- return tea.Batch(textarea.Blink, nil)
+ return nil
}
func (m Model) View() string {
@@ -44,5 +44,18 @@ func (m Model) View() string {
}
func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
- return m, nil
+ if !m.focus {
+ return m, nil
+ }
+ var cmd tea.Cmd
+ m.vi, cmd = m.vi.Update(msg)
+ return m, cmd
+}
+
+func (m *Model) Focus() {
+ m.focus = true
+}
+
+func (m *Model) Blur() {
+ m.focus = false
}