@@ -157,6 +157,7 @@ func NewEmulator(be Backend) Emulator {
157157 localModes : map [PrivateMode ]ModeStatus {
158158 PmAppCursor : ModeOff ,
159159 PmAutoMargin : ModeOn ,
160+ PmAutoRepeat : ModeOn ,
160161 PmVT52 : ModeOnLocked , // we never support VT52 mode (note ON means ANSI mode)
161162 PmLeftRightMargin : ModeOff ,
162163 PmShowCursor : ModeOn ,
@@ -1929,6 +1930,7 @@ func (em *emulator) softReset() {
19291930 }
19301931 // and set any that should reset on (auto-margin)
19311932 em .setPrivateMode (PmAutoMargin , ModeOn )
1933+ em .setPrivateMode (PmAutoRepeat , ModeOn )
19321934 em .setPrivateMode (PmShowCursor , ModeOn )
19331935 em .setPrivateMode (PmBlinkCursor , ModeOn )
19341936 // set default cursor - matches VT defaults
@@ -2165,10 +2167,16 @@ var legacyPadKeys = map[Key]struct {
21652167}
21662168
21672169// repeatRaw is called to provide key repeat. We limit key repeating to just 40,
2168- // and we ensure that at least one is included.
2170+ // and we ensure that at least one is included. We only repeat if key repeat is enabled.
21692171func (em * emulator ) repeatRaw (ev KeyEvent , data []byte ) {
2170- for range min (max (1 , ev .Repeat ), 40 ) {
2171- em .SendRaw (data )
2172+ if pm := em .getPrivateMode (PmAutoRepeat ); pm == ModeOn || pm == ModeOnLocked {
2173+ for range min (max (1 , ev .Repeat ), 40 ) {
2174+ em .SendRaw (data )
2175+ }
2176+ } else {
2177+ if ev .Repeat == 0 {
2178+ em .SendRaw (data )
2179+ }
21722180 }
21732181}
21742182
0 commit comments