[ale] php-cli text input

Wolf Halton wolf.halton at gmail.com
Sat Nov 26 11:49:25 EST 2011


Thanks David

On Fri, Nov 25, 2011 at 9:50 AM, David Hamm <ale at spinnerdog.com> wrote:

> Oh, good point..   Sorry about that.
>
>  I found this, on the php docs site in a user comment, after posting here.
> ::shrug,
>
> <?php
>  function readline_callback($ret)
>  {
>    global $prompt_answer, $prompt_finished;
>    $prompt_answer = $ret;
>    $prompt_finished = TRUE;
>    readline_callback_handler_remove();
>  }
>
>  readline_callback_handler_install('Enter some text> ',
>                                    'readline_callback');
>
>  $prefill = 'foobar';
>  for ($i = 0; $i < strlen($prefill); $i++)
>  {
>    readline_info('pending_input', substr($prefill, $i, 1));
>    readline_callback_read_char();
>  }
>
>  $prompt_finished = FALSE;
>  $prompt_answer = FALSE;
>  while (!$prompt_finished)
>    readline_callback_read_char();
>  echo 'You wrote: ' . $prompt_answer . "\n";
> ?>
>
> On Thursday, November 17, 2011 08:42:04 pm Richard Bronosky wrote:
> > It's customary to share the solution so that you are a contributor to the
> > community, not just a consumer. Imagine how frustrating it will be when
> our
> > mailman archive turns up as a Google search result for some other person
> > having the same problem, and instead of finding the answer they just get
> > teased with the fact that you found it and didn't share.
> >
> > On Nov 17, 2011 8:07 PM, "David Hamm" <ale at spinnerdog.com> wrote:
> > > Never mind.  I found what I needed.
> > >
> > > thanks
> > >
> > > On Thursday, November 17, 2011 04:07:41 pm David Hamm wrote:
> > > > Hi,
> > > >
> > > > In php-cli, I'm looking for a way to allow a terminal user to edit a
> > > > file name before saving it.  The program should prompt the user like
> > > > this.
> > > >
> > > > Save file as:  yourfile.txt
> > > >
> > > > And the user should be able to edit the name of the file.
> > > >
> > > > I've looked at readline() but readline doesn't let you set an
> > > > initial/default value.  I've also tried to find a way to push the
> > > > default value into the keyboard buffer but no luck.
> > > >
> > > > Does anyone have any ideas?
> > > > _______________________________________________
> > > > Ale mailing list
> > > > Ale at ale.org
> > > > http://mail.ale.org/mailman/listinfo/ale
> > > > See JOBS, ANNOUNCE and SCHOOLS lists at
> > > > http://mail.ale.org/mailman/listinfo
> > >
> > > _______________________________________________
> > > Ale mailing list
> > > Ale at ale.org
> > > http://mail.ale.org/mailman/listinfo/ale
> > > See JOBS, ANNOUNCE and SCHOOLS lists at
> > > http://mail.ale.org/mailman/listinfo
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>



-- 
This Apt Has Super Cow Powers - http://sourcefreedom.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.ale.org/pipermail/ale/attachments/20111126/b0963f27/attachment.html 


More information about the Ale mailing list