Just starting out

Jesse Phillips jessekphillips+d at gmail.com
Thu Oct 13 21:25:36 PDT 2011


On Thu, 13 Oct 2011 20:49:01 -0400, Nick Sabalausky wrote:

>> auto input2 = menu(promptMsg, ["coffee", "tea"]);
>>
>> auto input = require!(string, accept)(promptMsg);
>>
>> I haven't provide the option of displaying an error message, but it
>> could go in the delegate you use in require. And I suppose prompt is a
>> better name than userInput.
>>
>>
> Yea. I think mine is more customizable and generalized, but yours is
> more batteries-included and ready-to-go (which makes yours very
> enticing).

Hmm, maybe I made mine look more complicated. the two lines for input2 
and input accomplish the same thing. Both ask for and only accept input 
of coffee or tea. The only added customization I see is an error message 
which I think is hard to get right and why I built a menu and expect a 
good question.

> Maybe we could merge our designs and come up with something
> suitable for Phobos? I think this is the exactly the sort of thing
> that's a perfect fit for inclusion in a std lib: Very handy, but for
> many people not big enough to justify adding an external dependency.

Well I did bring up the idea in the Phobos group and the only comment I 
got was from Andrei saying that he doesn't think it is a good fit. But 
now with a proper review process I could see good discussion and input on 
if such should be included (that's what voting is for). 

>> On thing I've been kind of interested in is getting something set up
>> that would allow providing the needed information via a config, args,
>> or at runtime. but haven't done anything with that idea.
>>
>>
> That would be neat.
> 
> One thing I'd been thinking of adding to mine was an alternate function
> that just waited for a single keystroke (rather than a line of text +
> Enter). I think I once had it working on Tango, IIRC, but then I
> switched to D2/Phobos and couldn't figure out how to use Phobos to wait
> for a single keystroke w/o then waiting for Enter.

There isn't a C call to do something like this. In windows you can make a 
call to system("pause"), but that doesn't provide custom text, isn't 
cross platform, and apparently if you close the terminal it will start 
executing code for the time it takes to shut down (i.e. unpause).

Linux you have to pull out an curses trick to manipulate the terminal I 
believe, also not cross platform. It would be nice to get.


More information about the Digitalmars-d mailing list