diff options
| author | Kyren223 <Kyren223@proton.me> | 2024-12-12 18:16:38 +0200 |
|---|---|---|
| committer | Kyren223 <Kyren223@proton.me> | 2024-12-12 18:16:38 +0200 |
| commit | 25844d347f1a0b2396b03f96beac9974b4e05526 (patch) | |
| tree | f7c7801aa22856325e65e2e4688f8fce9d98f792 /internal/client | |
| parent | 2183261c3f7cc506d7fcf7d32a8d11ea37cce3b9 (diff) | |
Added gg and G motions to viminput
Diffstat (limited to 'internal/client')
| -rw-r--r-- | internal/client/ui/viminput/viminput.go | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/internal/client/ui/viminput/viminput.go b/internal/client/ui/viminput/viminput.go index 229e074..7e47e7c 100644 --- a/internal/client/ui/viminput/viminput.go +++ b/internal/client/ui/viminput/viminput.go @@ -41,6 +41,7 @@ type Model struct { goalColumn int mode int pending byte + gmod bool focus bool width int @@ -59,7 +60,8 @@ func New(width, height int) Model { cursorColumn: 0, goalColumn: -1, mode: NormalMode, - pending: 0, // Invalid value (valid values are 'd', 'c', 'y') + pending: 0, + gmod: false, focus: false, width: width, height: height, @@ -386,7 +388,14 @@ func (m *Model) RuneAtCursor() rune { return m.lines[m.cursorLine][m.cursorColumn] } -func (m Model) Motion(motion string) (line, col int) { +func (m *Model) Motion(motion string) (line, col int) { + if motion == "g" && !m.gmod { + m.gmod = true + return Unchanged, Unchanged + } else { + m.gmod = false + } + switch motion { case "h": return Unchanged, m.cursorColumn - 1 @@ -430,6 +439,12 @@ func (m Model) Motion(motion string) (line, col int) { } } return m.cursorLine + 1, len(line) - 1 + + case "g": + return 0, Unchanged + case "G": + return len(m.lines) - 1, Unchanged + // case "E": // for { // line := m.lines[m.cursorLine] @@ -466,6 +481,9 @@ func (m *Model) handleOpendingModeKeys(key tea.KeyMsg) { } lnum, col := m.Motion(key.String()) + if m.gmod { + return + } if lnum != Unchanged || col != Unchanged { if lnum == Unchanged { lnum = m.cursorLine @@ -565,8 +583,6 @@ func (m *Model) handleOpendingModeKeys(key tea.KeyMsg) { } case "y": - // TODO: Needs to make sure this works fine with multiline-pasting - // MULTILINE PASTING IS NOT IMPLEMENTED YET!!!!!! m.Yank(string(m.lines[m.cursorLine]) + "\n") m.ResetOpending() |
