Re: POE::Wheel::ReadLine change_prompt

2007-02-18 Thread Rocco Caputo

On Feb 5, 2007, at 16:35, Paul Miller wrote:


I'm using POE::Wheel::Run successfully and there's a situation where
my prompt should change dynamically.  I couldn't find a way to do it
directly, but using the source I created this mess:

sub change_prompt {
my $heap = $_[HEAP];
my $arg0 = $_[ARG0];

EVIL_HACK: {
local $| = 1; print \r,   x (length $heap-{prompt}),
\r;

$heap-{prompt} = $arg0;
$heap-{wheel}-[ $heap-{wheel}-SELF_PROMPT ] = $arg0;
$heap-{wheel}-_repaint_input_line;
}
}


Wow, that DOES seem like an evil hack.  I think I'd use _curs_left()  
to move the cursor to the start of the line.  Also your use of $_ 
[HEAP] and $_[ARG0] makes me wonder how you're calling this.  How are  
you calling this?



First of all, is there a better, less internally hacky way to do
this?  Second, if not, given that it seems like such a natural thing
to want to do; why isn't it already in there somewhere?


Or maybe I'd use _wipe_input_line() to erase the current input and  
then _repaint_input_line() to repaint it after the prompt was changed.


Generally stuff like this isn't implemented because $you are the  
first to need it.  If you use some of the existing cursor movement or  
command line painting functions instead, and you document this, I'll  
commit it for the next release.


--
Rocco Caputo - [EMAIL PROTECTED]




Re: POE::Wheel::ReadLine change_prompt

2007-02-06 Thread David Davis

Did $heap-{wheel}-get( prompt: ); not work for you?

It's documented.

David


On 5 Feb 2007 13:35:13 -0800, Paul Miller [EMAIL PROTECTED] wrote:


I'm using POE::Wheel::Run successfully and there's a situation where
my prompt should change dynamically.  I couldn't find a way to do it
directly, but using the source I created this mess:

sub change_prompt {
my $heap = $_[HEAP];
my $arg0 = $_[ARG0];

EVIL_HACK: {
local $| = 1; print \r,   x (length $heap-{prompt}),
\r;

$heap-{prompt} = $arg0;
$heap-{wheel}-[ $heap-{wheel}-SELF_PROMPT ] = $arg0;
$heap-{wheel}-_repaint_input_line;
}
}

First of all, is there a better, less internally hacky way to do
this?  Second, if not, given that it seems like such a natural thing
to want to do; why isn't it already in there somewhere?