mirror of
https://github.com/Kyren223/eko.git
synced 2026-07-14 16:00:32 +00:00
Added capability for chat to be "locked" into viminput, which solves the
issue of H/L, they can now be typed normally, pressing "i" to go into locked mode and "q" (in normal mode) to leave it
This commit is contained in:
@@ -9,8 +9,9 @@ import (
|
||||
)
|
||||
|
||||
type Model struct {
|
||||
vi viminput.Model
|
||||
focus bool
|
||||
vi viminput.Model
|
||||
focus bool
|
||||
locked bool
|
||||
}
|
||||
|
||||
func New() Model {
|
||||
@@ -32,7 +33,9 @@ func New() Model {
|
||||
// vi.Focus()
|
||||
|
||||
return Model{
|
||||
vi: vi,
|
||||
vi: vi,
|
||||
focus: false,
|
||||
locked: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,9 +51,31 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
|
||||
if !m.focus {
|
||||
return m, nil
|
||||
}
|
||||
var cmd tea.Cmd
|
||||
m.vi, cmd = m.vi.Update(msg)
|
||||
return m, cmd
|
||||
|
||||
if m.locked {
|
||||
InNormal := m.vi.Mode() == viminput.NormalMode
|
||||
if key, ok := msg.(tea.KeyMsg); ok && InNormal {
|
||||
if key.String() == "q" {
|
||||
m.locked = false
|
||||
return m, nil
|
||||
}
|
||||
}
|
||||
|
||||
var cmd tea.Cmd
|
||||
m.vi, cmd = m.vi.Update(msg)
|
||||
return m, cmd
|
||||
}
|
||||
|
||||
switch msg := msg.(type) {
|
||||
case tea.KeyMsg:
|
||||
key := msg.String()
|
||||
switch key {
|
||||
case "i":
|
||||
m.locked = true
|
||||
}
|
||||
}
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (m *Model) Focus() {
|
||||
@@ -62,3 +87,7 @@ func (m *Model) Blur() {
|
||||
m.focus = false
|
||||
m.vi.Blur()
|
||||
}
|
||||
|
||||
func (m Model) Locked() bool {
|
||||
return m.locked
|
||||
}
|
||||
|
||||
@@ -265,15 +265,17 @@ func (m *Model) updateConnected(msg tea.Msg) tea.Cmd {
|
||||
return cmd
|
||||
}
|
||||
|
||||
left := msg.String() == "H"
|
||||
right := msg.String() == "L"
|
||||
direction := 0
|
||||
if left {
|
||||
direction = -1
|
||||
} else if right {
|
||||
direction = 1
|
||||
if m.focus != FocusChat || !m.chat.Locked() {
|
||||
left := msg.String() == "H"
|
||||
right := msg.String() == "L"
|
||||
direction := 0
|
||||
if left {
|
||||
direction = -1
|
||||
} else if right {
|
||||
direction = 1
|
||||
}
|
||||
m.move(direction)
|
||||
}
|
||||
m.move(direction)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1738,3 +1738,7 @@ func (m *Model) handleVisualLineModeKeys(key tea.KeyMsg) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (m Model) Mode() int {
|
||||
return m.mode
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user