Adding ability to use shift+insert to paste text into emulator.

This commit is contained in:
Rob Greene
2025-07-29 20:07:37 -05:00
committed by Iván Izaguirre
parent 99ed07552e
commit 97859d11a9
+19
View File
@@ -2,6 +2,7 @@ package main
import (
"fmt"
"time"
"github.com/ivanizag/izapple2"
"github.com/ivanizag/izapple2/screen"
@@ -136,6 +137,11 @@ func (k *sdlKeyboard) putKey(keyEvent *sdl.KeyboardEvent) {
}
case sdl.K_PAUSE:
k.a.SendCommand(izapple2.CommandPauseUnpause)
case sdl.K_INSERT:
if shift {
text, _ := sdl.GetClipboardText()
go k.performPaste(text)
}
}
// Missing values 91 to 95. Usually control for [\]^_
@@ -145,3 +151,16 @@ func (k *sdlKeyboard) putKey(keyEvent *sdl.KeyboardEvent) {
k.keyChannel.PutChar(result)
}
}
func (k *sdlKeyboard) performPaste(text string) {
// Note 1: Pasting is too fast, so we slow it down.
// Note 2: Need to translate CR/LF's
for _, ch := range text {
if ch == '\r' || ch == '\n' {
k.keyChannel.PutChar(13)
} else {
k.keyChannel.PutRune(ch)
}
time.Sleep(20 * time.Millisecond)
}
}