Skip to content

Commit

Permalink
Limit auto-typing to 20 lines #96
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaumgarten committed Aug 28, 2021
1 parent 8a20e19 commit 3cb1218
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions pkg/langserver/autotype_win.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,18 @@ func (ls *LangServer) getLastOpenedCode() string {
return ""
}

func min(a, b int) int {
if a < b {
return a
}
return b
}

func typeYololCode(code string) {
lines := strings.Split(code, "\n")
for _, line := range lines {
count := min(20, len(lines))
for i := 0; i < count; i++ {
line := lines[i]
win32.SendString(line)
time.Sleep(typeDelay)
win32.SendInput(win32.KeyDownInput(win32.KeycodeDown), win32.KeyUpInput(win32.KeycodeDown))
Expand All @@ -164,15 +173,19 @@ func typeYololCode(code string) {

func typeYololCodeSSC(code string) {
lines := strings.Split(code, "\n")
for _, line := range lines {
count := min(20, len(lines))
for i := 0; i < count; i++ {
line := lines[i]
win32.SendString(line)
nextLineSSC()
}
}

func overwriteYololCode(code string) {
lines := strings.Split(code, "\n")
for _, line := range lines {
count := min(20, len(lines))
for i := 0; i < count; i++ {
line := lines[i]
deleteLine()
win32.SendString(line)
time.Sleep(typeDelay)
Expand Down

0 comments on commit 3cb1218

Please sign in to comment.