This commit is contained in:
Cheney 2015-09-23 13:03:13 +08:00
parent 9848c61567
commit bfdaae1594
4 changed files with 9 additions and 7 deletions

View File

@ -16,7 +16,7 @@ const (
CharPrev = 16
CharBckSearch = 18
CharFwdSearch = 19
CharTransform = 20
CharTranspose = 20
CharCtrlW = 23
CharEsc = 27
CharEscapeEx = 91
@ -28,5 +28,5 @@ const (
MetaNext
MetaDelete
MetaBackspace
MetaTransform
MetaTranspose
)

View File

@ -60,8 +60,8 @@ func (l *Operation) ioloop() {
l.buf.Kill()
case MetaNext:
l.buf.MoveToNextWord()
case CharTransform:
l.buf.Transform()
case CharTranspose:
l.buf.Transpose()
case MetaPrev:
l.buf.MoveToPrevWord()
case MetaDelete:

View File

@ -123,7 +123,7 @@ func (r *RuneBuffer) Kill() {
r.Refresh()
}
func (r *RuneBuffer) Transform() {
func (r *RuneBuffer) Transpose() {
if len(r.buf) < 2 {
if len(r.buf) == 1 {
r.idx++
@ -133,6 +133,8 @@ func (r *RuneBuffer) Transform() {
}
if r.idx == 0 {
r.idx = 1
} else if r.idx >= len(r.buf) {
r.idx = len(r.buf) - 1
}
r.buf[r.idx], r.buf[r.idx-1] = r.buf[r.idx-1], r.buf[r.idx]
r.idx++

View File

@ -52,8 +52,8 @@ func escapeKey(r rune) rune {
r = MetaNext
case 'd':
r = MetaDelete
case CharTransform:
r = MetaTransform
case CharTranspose:
r = MetaTranspose
case CharBackspace:
r = MetaBackspace
case CharEsc: