-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Expose readline.Interface "line", "cursor", "getCursorPos" #30347
Comments
I can't speak for other collaborators but I'm okay with promoting The I suggest opening a pull request and see how it's received. |
I'd be OK with that suggestion as well ^ |
The current "line" and "cursor" states are often necessary when developing applications that use readline for prompts. See nodejs/node#30347
Opened a PR for |
We should document them in this repo as well. Care to open a documentation PR?
I'd recommend stripping the underscore, but also creating an alias ( |
If it's all the same to you, I think I'd rather just make an alias the other way around: To me that makes more sense (even though they both effectively do the same thing); instead of changing every instance where I will make both of these PRs when I have a few more minutes to spare. |
Documents the existence and purpose of the `line` and `cursor` properties. `line` can be used for reading the current input value during runtime, if reading from a TTY stream. Both properties are necessary when developing a custom CLI input process using `readline` as a backend. Refs: nodejs#30347 Refs: DefinitelyTyped/DefinitelyTyped#40513
The current "line" and "cursor" states are often necessary when developing applications that use readline for prompts. See nodejs/node#30347
+1 to move |
Documents the existence and purpose of the `line` and `cursor` properties. `line` can be used for reading the current input value during runtime, if reading from a TTY stream. Both properties are necessary when developing a custom CLI input process using `readline` as a backend. Refs: nodejs#30347 Refs: DefinitelyTyped/DefinitelyTyped#40513
Documents the existence and purpose of the `line` and `cursor` properties. `line` can be used for reading the current input value during runtime, if reading from a TTY stream. Both properties are necessary when developing a custom CLI input process using `readline` as a backend. Refs: #30347 Refs: DefinitelyTyped/DefinitelyTyped#40513 PR-URL: #30667 Reviewed-By: Anna Henningsen <[email protected]>
Documents the existence and purpose of the `line` and `cursor` properties. `line` can be used for reading the current input value during runtime, if reading from a TTY stream. Both properties are necessary when developing a custom CLI input process using `readline` as a backend. Refs: #30347 Refs: DefinitelyTyped/DefinitelyTyped#40513 PR-URL: #30667 Reviewed-By: Anna Henningsen <[email protected]>
Aliases Interface._getCursorPos to Interface.getCursorPos, for consumption as a public API. refs: nodejs#30347
The current "line" and "cursor" states are often necessary when developing applications that use readline for prompts. See nodejs/node#30347
Alias _getCursorPos() = getCursorPos() for backwards compatibility. Refs: #30347 PR-URL: #30687 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Alias _getCursorPos() = getCursorPos() for backwards compatibility. Refs: #30347 PR-URL: #30687 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Thanks @Js-Brecht , this is taken care in: #30667, #30687 |
Documents the existence and purpose of the `line` and `cursor` properties. `line` can be used for reading the current input value during runtime, if reading from a TTY stream. Both properties are necessary when developing a custom CLI input process using `readline` as a backend. Refs: #30347 Refs: DefinitelyTyped/DefinitelyTyped#40513 PR-URL: #30667 Reviewed-By: Anna Henningsen <[email protected]>
Alias _getCursorPos() = getCursorPos() for backwards compatibility. Refs: #30347 PR-URL: #30687 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Documents the existence and purpose of the `line` and `cursor` properties. `line` can be used for reading the current input value during runtime, if reading from a TTY stream. Both properties are necessary when developing a custom CLI input process using `readline` as a backend. Refs: #30347 Refs: DefinitelyTyped/DefinitelyTyped#40513 PR-URL: #30667 Reviewed-By: Anna Henningsen <[email protected]>
Alias _getCursorPos() = getCursorPos() for backwards compatibility. Refs: #30347 PR-URL: #30687 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Describe the solution you'd like
I think it would be very useful to be able to access
readline.Interface
's currentline
andcursor
values, as well as access the_getCursorPos()
member function.It's frequently desirable to draw something outside of the current prompt during input. I am endlessly recreating actions that
readline
does already; specifically, tracking the cursor position (so listening for left, right, home, end, delete, backspace, ctrl+, etc, etc, ad nauseam), as well as listening to stdin for data, so that I can keep track of what the input looks like. This way, if I want to draw something outside of the prompt, I know where to return the cursor to.I also see that
readline
usesInterface._getCursorPos()
internally; also very useful, and pretty much what I'm recreating withInterface.line
&Interface.cursor
calculations.Being able to read
Interface.line
at any given time can be important, if you need to use that value somewhere else, but you aren't done with the prompt yet (for example, drawing an autocomplete list)But it seems awfully redundant to have to do all of this, when
readline
already does it quite well. Honestly, by the time I'm done, I've basically created my ownreadline
interface. Seems like a waste.I can read
Interface.line
,Interface.cursor
, etc... but they aren't exposed in@types/node
, so it makes me feel like they are omitted for a reason.Describe alternatives you've considered
There's a couple of alternatives. One, I guess, is to just use the
Interface
members, and hope they don't ever change. The other is essentially creating my own custom readline interface, which really is just reinventing the wheel.Perhaps somebody could share the philosophy behind the current design? On the other hand, if they can be safely exposed in the types, I'd be happy to make a PR.
The text was updated successfully, but these errors were encountered: