diff options
| author | Kyren223 <Kyren223@proton.me> | 2024-12-18 18:48:02 +0200 |
|---|---|---|
| committer | Kyren223 <Kyren223@proton.me> | 2024-12-18 18:48:02 +0200 |
| commit | 692e10d8251ccc0d6aa35fa24a65dc9c67d7209e (patch) | |
| tree | 8efeb9d1a97b10b52566cd1f0684aeb8f8a4287e /internal/client | |
| parent | c2ca65580d683ff983644f05681f22774263f13f (diff) | |
Fixed extra newline due to placeholder issues
Diffstat (limited to 'internal/client')
| -rw-r--r-- | internal/client/ui/core/chat/chat.go | 19 | ||||
| -rw-r--r-- | internal/client/ui/viminput/viminput.go | 12 |
2 files changed, 26 insertions, 5 deletions
diff --git a/internal/client/ui/core/chat/chat.go b/internal/client/ui/core/chat/chat.go index 463f65a..70d6654 100644 --- a/internal/client/ui/core/chat/chat.go +++ b/internal/client/ui/core/chat/chat.go @@ -8,6 +8,13 @@ import ( "github.com/kyren223/eko/internal/client/ui/viminput" ) +var ( + ViBlurredBorder = lipgloss.NewStyle(). + BorderStyle(lipgloss.RoundedBorder()).UnsetBorderBottom() + ViFocusedBorder = lipgloss.NewStyle(). + BorderStyle(lipgloss.ThickBorder()).UnsetBorderBottom() +) + type Model struct { vi viminput.Model focus bool @@ -31,7 +38,17 @@ func (m Model) Init() tea.Cmd { } func (m Model) View() string { - return m.vi.View() + input := m.vi.View() + + if m.locked { + input = ViFocusedBorder.Render(input) + } else { + input = ViBlurredBorder.Render(input) + } + + result := input + + return result } func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) { diff --git a/internal/client/ui/viminput/viminput.go b/internal/client/ui/viminput/viminput.go index d752620..db2881d 100644 --- a/internal/client/ui/viminput/viminput.go +++ b/internal/client/ui/viminput/viminput.go @@ -41,7 +41,7 @@ type Model struct { PlaceholderStyle lipgloss.Style PromptStyle lipgloss.Style - Placeholder string + Placeholder string register string lines [][]rune undoStack []State @@ -118,6 +118,7 @@ func (m Model) View() string { rest := m.PlaceholderStyle.Render(m.Placeholder[1:]) builder.WriteString(CursorStyle.Render(cursorChar)) builder.WriteString(rest) + builder.WriteByte('\n') continue } @@ -147,6 +148,7 @@ func (m Model) View() string { rest := m.PlaceholderStyle.Render(m.Placeholder[1:]) builder.WriteString(CursorStyle.Render(cursorChar)) builder.WriteString(rest) + builder.WriteByte('\n') continue } @@ -252,6 +254,7 @@ func (m Model) View() string { rest := m.PlaceholderStyle.Render(m.Placeholder[1:]) builder.WriteString(CursorStyle.Render(cursorChar)) builder.WriteString(rest) + builder.WriteByte('\n') continue } @@ -282,6 +285,7 @@ func (m Model) View() string { } result := builder.String() + result = result[:len(result)-1] // Remove last \n result = lipgloss.NewStyle().Width(m.width).Height(m.height).Render(result) return result @@ -405,7 +409,7 @@ func (m *Model) handleNormalModeKeys(key tea.KeyMsg) { motion := key.String() count := 1 - if m.count != NoCount && (motion[0] < '0' || motion[0] > '9'){ + if m.count != NoCount && (motion[0] < '0' || motion[0] > '9') { count = m.count m.count = NoCount } @@ -1618,7 +1622,7 @@ func (m *Model) handleVisualModeKeys(key tea.KeyMsg) { } count := 1 - if m.count != NoCount && (motion[0] < '0' || motion[0] > '9'){ + if m.count != NoCount && (motion[0] < '0' || motion[0] > '9') { count = m.count m.count = NoCount } @@ -1789,7 +1793,7 @@ func (m *Model) handleVisualLineModeKeys(key tea.KeyMsg) { } count := 1 - if m.count != NoCount && (motion[0] < '0' || motion[0] > '9'){ + if m.count != NoCount && (motion[0] < '0' || motion[0] > '9') { count = m.count m.count = NoCount } |
