Skip to content

Commit

Permalink
Fix chzyer#5, Changed behaviour of delete key
Browse files Browse the repository at this point in the history
* Changed current delete to CharEOT, added new CharDelete key

wader notes:
Don't expect more char after ex esc rune
Kick reader even if no char is deleted
  • Loading branch information
stdiopt authored and wader committed Mar 19, 2023
1 parent 4fc6bef commit b506c9d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,13 @@ func (o *Operation) ioloop() {
o.t.Bell()
}
case CharDelete:
o.t.KickRead()
if o.buf.Len() > 0 || !o.IsNormalMode() {
if !o.buf.Delete() {
o.t.Bell()
}
}
case CharEOT:
if o.buf.Len() > 0 || !o.IsNormalMode() {
o.t.KickRead()
if !o.buf.Delete() {
Expand Down
2 changes: 1 addition & 1 deletion terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (t *Terminal) ioloop() {
break
}
isEscape = true
case CharInterrupt, CharEnter, CharCtrlJ, CharDelete:
case CharInterrupt, CharEnter, CharCtrlJ, CharDelete, CharEOT:
expectNextChar = false
fallthrough
default:
Expand Down
4 changes: 3 additions & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (
CharLineStart = 1
CharBackward = 2
CharInterrupt = 3
CharDelete = 4
CharEOT = 4
CharLineEnd = 5
CharForward = 6
CharBell = 7
Expand All @@ -49,12 +49,14 @@ const (
CharBackspace = 127
)

// Extra virtual keys
const (
MetaBackward rune = -iota - 1
MetaForward
MetaDelete
MetaBackspace
MetaTranspose
CharDelete
)

// WaitForResume need to call before current process got suspend.
Expand Down

0 comments on commit b506c9d

Please sign in to comment.