Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ func simpleEditor(v *View, key Key, ch rune, mod Modifier) {
v.EditDelete(true)
case key == KeyDelete:
v.EditDelete(false)
case key == KeyCtrlY:
v.EditDeleteLine()
case key == KeyInsert:
v.Overwrite = !v.Overwrite
case key == KeyEnter:
Expand All @@ -58,6 +60,20 @@ func (v *View) EditWrite(ch rune) {
v.MoveCursor(1, 0, true)
}

// EditDelete deletes a line at the cursor position.
func (v *View) EditDeleteLine() error {
v.tainted = true
_, y, err := v.realPosition(0, v.oy+v.cy)
if err != nil {
return err
}
if y < 0 || y >= len(v.lines) {
return errors.New("invalid point")
}
v.lines = append(v.lines[:y], v.lines[y+1:]...)
return nil
}

// EditDelete deletes a rune at the cursor position. back determines the
// direction.
func (v *View) EditDelete(back bool) {
Expand Down