jay
jay copied to clipboard
WIP: Add multiline support
This will allow you to press shift + enter by maintaining a queue of 2 keycodes from last pressed keys.
I had to use iohook
library to be able to capture JUST shift key presses. I did not take a ton of time to set it up properly, so it does not teardown listener and has a memory leak.
Also, I cant get the evaluate to work properly with multiline, but this is a good start I think.
ioHook.on('keypress', (event: IOHookEvent) => {
if (lastKeys.length < 2) lastKeys.push(event)
else {
lastKeys.pop()
lastKeys.unshift(event)
}
});
else if (name === 'return') {
const lastKey = lastKeys.concat().pop()
if (lastKey!.shiftKey) {
stdout.write('\n')
rl.write('\n')
}
Whoops, forgot to add you need to npm install iohook
@GavinRay97
Whoops, forgot to add you need to npm install iohook
Add it into dependencies in the package.json then: https://github.com/nikersify/jay/blob/master/package.json#L29 . More info https://docs.npmjs.com/files/package.json#dependencies
@GavinRay97
Whoops, forgot to add you need to npm install iohook
Add it into dependencies in the package.json then: https://github.com/nikersify/jay/blob/master/package.json#L29 . More info https://docs.npmjs.com/files/package.json#dependencies
Yeah for sure, I am super familiar with JS/TS dev I just blanked on commit the dependency. It still will not work properly due to not triggering the evaluation on enter though, so might need someone else (maybe @nikersify) to help figure out that issue.