Re: enhancing prompt() functions

new topic     » goto parent     » topic index » view thread      » older message » newer message
euphoric said...

I would like to enhance the prompt_string() function to allow the user to supply a default or initial string to be used.

For example:

 
   uname = "Steve Jones" -- could be retrieved from a database, prefs file, or whatever 
   uname = prompt_string( "Enter username: ", uname ) 

Or is there another/a better way to go about this?

This approach is quite difficult, because we just use gets(0). Even if we fall back to C code, to handle fgets() we'd have to use ungetc() to push back the characters in the initial string - and ungetc() only guarantees one push back (thus one character).

So, we have to drop gets() and use wait_key() and puts() and handle the edit processing ourselves. This is a lot more complicated than the existing prompt_string() function. OTOH, ed.ex already does this.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu