diff options
author | Petter Rodhelind <petter.rodhelind@gmail.com> | 2018-02-23 19:34:14 +0100 |
---|---|---|
committer | Petter Rodhelind <petter.rodhelind@gmail.com> | 2018-02-23 19:34:14 +0100 |
commit | 6ba65a24c45ae55e0af5ad9c0b7d65155f551211 (patch) | |
tree | 9bdba649cc269de0fd3114aa0f225ad4e575b2a6 | |
parent | ce20fc8a9d249798e9349679b37d9452ee14c3e0 (diff) | |
download | poe-6ba65a24c45ae55e0af5ad9c0b7d65155f551211.tar.gz poe-6ba65a24c45ae55e0af5ad9c0b7d65155f551211.tar.bz2 poe-6ba65a24c45ae55e0af5ad9c0b7d65155f551211.zip |
Implement ^W using PrevWord().
-rw-r--r-- | view.go | 30 |
1 files changed, 7 insertions, 23 deletions
@@ -402,30 +402,14 @@ func (v *View) HandleEvent(ev tcell.Event) { v.Delete() return case tcell.KeyCtrlW: // delete word backwards - offset := v.text.q0 - 1 - c, _ := v.text.buf.ByteAt(offset) - if unicode.IsSpace(rune(c)) { - if c == '\n' { - v.Delete() - return - } - for unicode.IsSpace(rune(c)) && c != '\n' { - v.Delete() - if v.text.q0 <= 0 { - break - } - offset-- - c, _ = v.text.buf.ByteAt(offset) - } - } - for !unicode.IsSpace(rune(c)) { - v.Delete() - if v.text.q0 <= 0 { - break - } - offset-- - c, _ = v.text.buf.ByteAt(offset) + startpos := v.Cursor() + offset := v.text.PrevWord(v.Cursor()) + if offset == 0 { + v.SetCursor(-1, io.SeekCurrent) + offset = v.text.PrevWord(v.Cursor()) } + v.text.SetDot(v.Cursor()-offset, startpos) + v.Delete() return case tcell.KeyCtrlZ: v.text.Undo() |