Forgot this
This commit is contained in:
parent
e7405a8d19
commit
4003f411e0
26
model.go
26
model.go
@ -96,22 +96,22 @@ func (m *model) replayInsert() {
|
||||
func (m *model) processInsertKey(key string) {
|
||||
switch key {
|
||||
case "enter":
|
||||
y := m.cursor.y
|
||||
x := m.cursor.x
|
||||
y := m.cursor.y
|
||||
x := m.cursor.x
|
||||
|
||||
// Simple case, at end, just create a line
|
||||
if x == len(m.lines[y]) {
|
||||
m.lines = append(m.lines[:y+1], append([]string{""}, m.lines[y+1:]...)...)
|
||||
// Simple case, at end, just create a line
|
||||
if x == len(m.lines[y]) {
|
||||
m.lines = append(m.lines[:y+1], append([]string{""}, m.lines[y+1:]...)...)
|
||||
|
||||
// otherwise, splice
|
||||
} else {
|
||||
l := m.lines[y]
|
||||
m.lines[y] = l[:x]
|
||||
m.lines = append(m.lines[:y+1], append([]string{l[x:]}, m.lines[y+1:]...)...)
|
||||
}
|
||||
// otherwise, splice
|
||||
} else {
|
||||
l := m.lines[y]
|
||||
m.lines[y] = l[:x]
|
||||
m.lines = append(m.lines[:y+1], append([]string{l[x:]}, m.lines[y+1:]...)...)
|
||||
}
|
||||
|
||||
m.cursor.y++
|
||||
m.cursor.x = 0
|
||||
m.cursor.y++
|
||||
m.cursor.x = 0
|
||||
|
||||
case "backspace":
|
||||
x := m.cursor.x
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user