jay icon indicating copy to clipboard operation
jay copied to clipboard

WIP: Add multiline support

Open GavinRay97 opened this issue 5 years ago • 3 comments

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')
				} 

GavinRay97 avatar Dec 16 '19 02:12 GavinRay97

Whoops, forgot to add you need to npm install iohook

GavinRay97 avatar Dec 16 '19 02:12 GavinRay97

@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

schfkt avatar Dec 16 '19 09:12 schfkt

@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.

GavinRay97 avatar Dec 16 '19 18:12 GavinRay97