diff options
| author | Kyren223 <Kyren223@proton.me> | 2025-01-19 18:07:25 +0200 |
|---|---|---|
| committer | Kyren223 <Kyren223@proton.me> | 2025-01-19 18:07:25 +0200 |
| commit | 7c4a45f41316886a99d8a9ae1d4d2b88e4f0455e (patch) | |
| tree | 8a754347d8cdc577751ddb1913f723d4c51a4f45 /internal/client/ui/core/chat | |
| parent | 1b3b74464b373b412d256d58f5c511c64278a425 (diff) | |
Made UI more responsive
Diffstat (limited to 'internal/client/ui/core/chat')
| -rw-r--r-- | internal/client/ui/core/chat/chat.go | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/internal/client/ui/core/chat/chat.go b/internal/client/ui/core/chat/chat.go index 7c3bec0..1895c0d 100644 --- a/internal/client/ui/core/chat/chat.go +++ b/internal/client/ui/core/chat/chat.go @@ -69,6 +69,8 @@ var ( SelectedEditedIndicatorNL = lipgloss.NewStyle(). Foreground(colors.LightGray).Background(colors.BackgroundDim). SetString("\n(edited)").String() + + WidthWithoutVi = PaddingCount*2 + lipgloss.Width(LeftCorner) + lipgloss.Width(RightCorner) ) const ( @@ -108,10 +110,8 @@ type Model struct { borderStyle lipgloss.Style } -func New(width int) Model { - viWidth := width - PaddingCount*2 - lipgloss.Width(LeftCorner) - lipgloss.Width(RightCorner) - vi := viminput.New(viWidth, ui.Height/2) - vi.Placeholder = SendMessagePlaceholder +func New() Model { + vi := viminput.New() vi.PlaceholderStyle = lipgloss.NewStyle().Foreground(colors.Gray) return Model{ @@ -131,7 +131,7 @@ func New(width int) Model { maxMessagesHeight: -1, messagesCache: nil, prerender: "", - width: width, + width: -1, style: blurStyle, borderStyle: ViBlurredBorder, } @@ -165,6 +165,10 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) { // TODO: properly invalidate cache m.messagesCache = nil + viWidth := m.width - WidthWithoutVi + m.vi.SetWidth(viWidth) + m.vi.SetMaxHeight(ui.Height / 2) + networkId := state.NetworkId(m.networkIndex) if m.frequencyIndex != -1 && networkId != nil { frequencies := state.State.Frequencies[*networkId] @@ -862,3 +866,7 @@ func (m *Model) editMessage() tea.Cmd { Content: message, }) } + +func (m *Model) SetWidth(width int) { + m.width = width +} |
