diff options
| author | Kyren223 <Kyren223@proton.me> | 2024-12-04 18:35:11 +0200 |
|---|---|---|
| committer | Kyren223 <Kyren223@proton.me> | 2024-12-04 18:35:11 +0200 |
| commit | 37cd043920aa92189d9ae19e7631968290e4d352 (patch) | |
| tree | 62282034ca56a52bbe36634d77932beaefa5d0ef /internal/client/ui/core | |
| parent | 567d569dd649cc0b82d6f8890e2bd77b052ebed6 (diff) | |
Started work on basic vim input box
Diffstat (limited to 'internal/client/ui/core')
| -rw-r--r-- | internal/client/ui/core/chat/chat.go | 48 | ||||
| -rw-r--r-- | internal/client/ui/core/core.go | 20 | ||||
| -rw-r--r-- | internal/client/ui/core/network/network.go | 12 |
3 files changed, 69 insertions, 11 deletions
diff --git a/internal/client/ui/core/chat/chat.go b/internal/client/ui/core/chat/chat.go new file mode 100644 index 0000000..b3597a8 --- /dev/null +++ b/internal/client/ui/core/chat/chat.go @@ -0,0 +1,48 @@ +package chat + +import ( + "log" + + "github.com/charmbracelet/bubbles/textarea" + tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/lipgloss" + + "github.com/kyren223/eko/internal/client/ui/colors" + "github.com/kyren223/eko/internal/client/ui/viminput" +) + +type Model struct { + vi viminput.Model +} + +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.ShowLineNumbers = false + + // vi.CharLimit = 280 + + // vi.Focus() + + log.Println("Placeholder:", vi.Placeholder) + + return Model{ + vi: vi, + } +} + +func (m Model) Init() tea.Cmd { + return tea.Batch(textarea.Blink, nil) +} + +func (m Model) View() string { + return m.vi.View() +} + +func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) { + return m, nil +} diff --git a/internal/client/ui/core/core.go b/internal/client/ui/core/core.go index 5031dc0..b4390e0 100644 --- a/internal/client/ui/core/core.go +++ b/internal/client/ui/core/core.go @@ -58,14 +58,18 @@ type Model struct { func New(privKey ed25519.PrivateKey, name string) Model { m := Model{ - name: name, - privKey: privKey, - networkList: networklist.New(), - loading: loadscreen.New(connectingToServer), - timer: newTimer(initialTimeout), - timeout: initialTimeout, - connected: false, - focus: FocusNetworkList, + name: name, + privKey: privKey, + id: 0, + loading: loadscreen.New(connectingToServer), + timer: newTimer(initialTimeout), + timeout: initialTimeout, + connected: false, + networkCreationPopup: nil, + frequencyCreationPopup: nil, + networkList: networklist.New(), + network: network.New(), + focus: FocusNetworkList, } m.move(0) // Update focus diff --git a/internal/client/ui/core/network/network.go b/internal/client/ui/core/network/network.go index 75ea318..3c24350 100644 --- a/internal/client/ui/core/network/network.go +++ b/internal/client/ui/core/network/network.go @@ -8,6 +8,7 @@ import ( "github.com/kyren223/eko/internal/client/gateway" "github.com/kyren223/eko/internal/client/ui" "github.com/kyren223/eko/internal/client/ui/colors" + "github.com/kyren223/eko/internal/client/ui/core/chat" "github.com/kyren223/eko/internal/client/ui/core/state" "github.com/kyren223/eko/internal/packet" ) @@ -31,12 +32,16 @@ type Model struct { networkIndex int index int focus bool + chat chat.Model } func New() Model { + chat := chat.New() + return Model{ focus: false, index: 0, + chat: chat, } } @@ -69,13 +74,14 @@ func (m Model) View() string { builder.WriteString("\n") } - result := builder.String() - + sidebar := builder.String() sep := sepStyle.Height(ui.Height) if m.focus { sep = sep.BorderForeground(colors.Focus) } - result = lipgloss.JoinHorizontal(lipgloss.Top, result, sep.String()) + sidebar = lipgloss.JoinHorizontal(lipgloss.Top, sidebar, sep.String()) + + result := lipgloss.JoinHorizontal(lipgloss.Top, sidebar, m.chat.View()) return result } |
