Skip to content

Commit

Permalink
Hopefully fixed SSC-Typing #39
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaumgarten committed Apr 16, 2021
1 parent b23eac7 commit 5d72b15
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/vscode-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ One key-problem when writing yolol-code in an external editor always was how to

If you (for whatever reason) want to disable the global hotkeys, you can do so in the vscode-settings under File->Preferences->Settings->search for 'yolol'->Hotkeys: Enable). Vscode needs to be restarted for changes to this setting to take effect.

**ATTENTION**: When editing code inside the Ship.Editor slightly different keystrokes are required to autotype code. Thats why there are separate hotkeys for inside the SSC. When inside the SSC, you will need to use ```Ctrl+ALT+<key>``` instead of ```Ctrl+<key>```!
**ATTENTION**: When editing code inside the Ship.Editor slightly different keystrokes are required to autotype code. Thats why there are separate hotkeys for inside the SSC. When inside the SSC, you will need to use ```Ctrl+ALT+<key>``` instead of ```Ctrl+<key>```! Also, the SSC-typing is pretty new and might still have bugs. If you find one, please open an issue.

## Inseting code into a chip
Open the .yolol-script you want to insert in vscode (it has to be the current active file). Go to Stabase's window and open the yolol-chip you want to fill. Unlock it, aim your cursor at it and click a line. Now press ```Ctrl+I```. Vscode will start to auto-type your code into the chip, starting at your current cursor-position.
Expand Down
19 changes: 11 additions & 8 deletions pkg/langserver/autotype_win.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ func typeYololCodeSSC(code string) {
lines := strings.Split(code, "\n")
for _, line := range lines {
win32.SendString(line)
time.Sleep(typeDelay)
win32.SendInput(win32.KeyDownInput(win32.KeycodeDown), win32.KeyUpInput(win32.KeycodeDown))
win32.SendInput(win32.KeyDownInput(win32.KeycodeDown), win32.KeyUpInput(win32.KeycodeDown))
nextLineSSC()
}
}

Expand All @@ -169,9 +167,7 @@ func overwriteYololCodeSSC(code string) {
for _, line := range lines {
deleteLine()
win32.SendString(line)
time.Sleep(typeDelay)
win32.SendInput(win32.KeyDownInput(win32.KeycodeDown), win32.KeyUpInput(win32.KeycodeDown))
win32.SendInput(win32.KeyDownInput(win32.KeycodeDown), win32.KeyUpInput(win32.KeycodeDown))
nextLineSSC()
}
}

Expand All @@ -185,11 +181,18 @@ func deleteAllLines() {
func deleteAllLinesSSC() {
for i := 0; i < 20; i++ {
deleteLine()
win32.SendInput(win32.KeyDownInput(win32.KeycodeDown), win32.KeyUpInput(win32.KeycodeDown))

nextLineSSC()
}
}

func nextLineSSC() {
time.Sleep(typeDelay)
win32.SendInput(win32.KeyDownInputArrowDownSSC(), win32.KeyUpInputArrowDownSSC())
time.Sleep(typeDelay)
win32.SendInput(win32.KeyDownInputArrowDownSSC(), win32.KeyUpInputArrowDownSSC())
time.Sleep(typeDelay)
}

func deleteLine() {
win32.SendInput(win32.KeyDownInput(win32.KeycodeCtrl), win32.KeyDownInput('A'))
time.Sleep(typeDelay)
Expand Down
20 changes: 20 additions & 0 deletions pkg/langserver/win32/keyboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,26 @@ func SendInput(inputEvents ...Input) error {
return nil
}

func KeyDownInputArrowDownSSC() Input {
return Input{
InputType: 1,
KeyboardInput: KeyboardInput{
ScanCode: 0x50,
Flags: KeyeventfScancode | KeyeventfExtendedkey,
},
}
}

func KeyUpInputArrowDownSSC() Input {
return Input{
InputType: 1,
KeyboardInput: KeyboardInput{
ScanCode: 0x50 + 128,
Flags: KeyeventfScancode | KeyeventfKeyup | KeyeventfExtendedkey,
},
}
}

// SendString sends input-events to the OS, that simulate typing the given string
func SendString(s string) {
for _, r := range s {
Expand Down
2 changes: 1 addition & 1 deletion vscode-yolol/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ If you experience any issues or would like to request a feature, please [open an
- Auto-completion
- Commands for optimizing yolol
- Interactively debug YOLOL-code in vscode
- AUto-type your code into Starbase
- Auto-type your code into Starbase (see [here](https://dbaumgarten.github.io/yodk/#/vscode-instructions?id=auto-typing-into-starbase) for the Shortcuts)
- Also supports nolol

# Instructions
Expand Down

0 comments on commit 5d72b15

Please sign in to comment.