Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation request: cannot chain .inputField #245

Open
jawspeak opened this issue Apr 9, 2024 · 0 comments
Open

Documentation request: cannot chain .inputField #245

jawspeak opened this issue Apr 9, 2024 · 0 comments

Comments

@jawspeak
Copy link

jawspeak commented Apr 9, 2024

Worked around a bug which ideally can error if someone else uses it incorrectly as I did. Or at least the docs add this for inputField https://github.com/cronvel/terminal-kit/blob/master/doc/high-level.md#ref.inputField

This doesn't work

term.green.bold.inputField( //...

It fails ambiguously with

TypeError: Cannot read properties of undefined (reading 'removeListener')

stacktrace: TypeError: Cannot read properties of undefined (reading 'removeListener')
    at notChainable.grabInput (/<workdir>/node_modules/terminal-kit/lib/Terminal.js:1341:13)
    at Terminal.inputField (/<workdir>/node_modules/terminal-kit/lib/inputField.js:151:32)

But this does work:

term.inputField( //...

The source is pretty clear in Terminal.js this is not chainable, but it would be nice to enforce that with an error or at least docs.

notChainable.grabInput = function( options , safe ) {
	// RESET
	this.mouseButton( false ) ;
	this.mouseDrag( false ) ;
	this.mouseMotion( false ) ;
	//this.mouseSGR( false ) ;
	this.focusEvent( false ) ;
	console.log('TEST grabInput() this.stdin', this.stdin); // this is not defined if chained term.
	this.stdin.removeListener( 'data' , this.onStdin ) ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant