##
## convert an hlist path
##
sub hlist_selection_to_expr {
my($entry, $hlist) = @_ ;
my($path) = $hlist->infoSelection() ;
my($array_context, $hash_context, $expr, $e) ;
my($root_expr, @elems) = split /$Devel::ptkdb::pathSep/, $path ;
return unless $root_expr ;
($array_context, $hash_context) = $root_expr =~ /^(\s*@)|^(\s*%)/ ;
$root_expr = '(' . $root_expr . ')' if( $root_expr =~ / /) ;
$expr = $root_expr ;
if( @elems && ($array_context || $hash_context) ) {
$expr =~ s/\s*[@%]/\$/ ;
if( $array_context ) {
$expr .= shift @elems ; # it will be a [idx] expr
} elsif ( $hash_context ) {
$expr .= "{\'" . shift(@elems) . "\'}" ;
}
}
for( @elems ) {
$expr .= '->' ;
if( /\[[0-9]+\]/ ) {
$expr .= $_ ;
}
else {
$expr .= "{\'" . $_ . "\'}" ;
}
}
$entry->delete(0, 'end') ;
$entry->insert(0, $expr) ;
$entry->selectionRange(0, 'end') ;
$entry->focus ;
}
sub install_hlist_selection_to_expr {
my($dbwin) = $DB::window ; # ptkdb window
my($hlist) = $dbwin->{'data_list'} ;
$Devel::ptkdb::pathSep = "\xff" ; # correction for ptkdb hlist bug in
+some versions
$hlist->configure( 'separator' => $Devel::ptkdb::pathSep) ;
$hlist->bind('<Button-1>', sub { hlist_selection_to_expr(@$dbwin{qw/en
+try data_list/}) }) ;
}
&install_hlist_selection_to_expr ;
|