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

Prompt for numeric entry only #436

Closed
jamesmcm opened this issue Sep 8, 2020 · 2 comments
Closed

Prompt for numeric entry only #436

jamesmcm opened this issue Sep 8, 2020 · 2 comments

Comments

@jamesmcm
Copy link

jamesmcm commented Sep 8, 2020

Hi,

I'd like to create a prompt which only accepts numeric entries, i.e. any non-numeric character key-presses do not register (or optionally, trigger the bell).

Is there any way to specify which input characters are accepted? (one could imagine the same idea would be useful for alpha-numeric only, etc.)

@gwenn
Copy link
Collaborator

gwenn commented Sep 8, 2020

Currently, you can't easily.
You can only reject final user input with a Validator.
An ugly and partial solution would be to rebind all ascii characters (except numeric and control) to Noop (no Beep/Bell command).

@gwenn gwenn mentioned this issue Feb 21, 2021
7 tasks
@gwenn
Copy link
Collaborator

gwenn commented Mar 7, 2021

Fixed in version 8.0.0
See https://github.com/kkawakam/rustyline/blob/master/examples/numeric_input.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants