Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Prompt user to fill in a template?

I’ve never been able to find anything about this in any language, but what I want to do seems rather simple to me.

I want to prompt the user for input, but have them fill in a sort of template. Let’s use a simple DD-MM-YYYY date as an example.

[█ -  -    ]

is where the user writes.
As they write, the [ and - stay where they are, with the cursor jumping past them, and hitting enter submits.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I’m not expecting anyone to write all of this for me, but cin and cout seem to be too crude a tools to do this, and so I’m wondering where I should even start, if not there.

Is there something that already does this, or at least something that gives me more control of the cursor to allow me to write it myself?
I do not want to be drawing a full-on TUI with windows and boarders and colors, so ncurses would just get in the way. I just want a single-line text field that returns the input.

>Solution :

Generally what you want is a text-based GUI library, such as ncurses. Doing console work is platform-specific, and every system has its own console API to do this. If you want to implement this yourself, you would have to examine what options does your target operating system give you in terms of console API, and build a custom solution based on that.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading