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) {
|
func (m *model) processInsertKey(key string) {
|
||||||
switch key {
|
switch key {
|
||||||
case "enter":
|
case "enter":
|
||||||
y := m.cursor.y
|
y := m.cursor.y
|
||||||
x := m.cursor.x
|
x := m.cursor.x
|
||||||
|
|
||||||
// Simple case, at end, just create a line
|
// Simple case, at end, just create a line
|
||||||
if x == len(m.lines[y]) {
|
if x == len(m.lines[y]) {
|
||||||
m.lines = append(m.lines[:y+1], append([]string{""}, m.lines[y+1:]...)...)
|
m.lines = append(m.lines[:y+1], append([]string{""}, m.lines[y+1:]...)...)
|
||||||
|
|
||||||
// otherwise, splice
|
// otherwise, splice
|
||||||
} else {
|
} else {
|
||||||
l := m.lines[y]
|
l := m.lines[y]
|
||||||
m.lines[y] = l[:x]
|
m.lines[y] = l[:x]
|
||||||
m.lines = append(m.lines[:y+1], append([]string{l[x:]}, m.lines[y+1:]...)...)
|
m.lines = append(m.lines[:y+1], append([]string{l[x:]}, m.lines[y+1:]...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
m.cursor.y++
|
m.cursor.y++
|
||||||
m.cursor.x = 0
|
m.cursor.x = 0
|
||||||
|
|
||||||
case "backspace":
|
case "backspace":
|
||||||
x := m.cursor.x
|
x := m.cursor.x
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user