Data::Dump::Tree::Foldable

NAME

Data::Dump::Tree::Foldable

SYNOPSIS

use Data::Dump::Tree::Foldable ;
my $f = Data::Dump::Tree::Foldable.new: $data_to_dump, :title<title> ;
	my $v = $f.get_view ; # default geometry
$v.set: :top_line<1>, :page_size<10> ; # set geometry
	#get the lines to display
	my @lines = $v.get_lines ;
# move in the data structure rendering
	$v.line_down ;
	$v.page_down ;
# select a line and fold it, or unfold it if it is already folded
	$v.set: :selected_line(7) ;
	$v.fold_flip_selected ;
#get the lines to display
	@line = $v.get_lines ;

Data::Dump::Tree::Foldable and Data::Dump::Tree::Foldable::View implement the base mechanisms needed to:

  • display a structured rendered by <Data::Dump::Tree> in a viewport

  • movement through the data structure in the viewport

  • folding the data structure.

A simple search functionality is also planned in future versions.

Data::Dump::Tree::Foldable

my $f = Data::Dump::Tree::Foldable.new: $data_to_dump, :title<title> ;

A Foldable contains a Data:Dump::Tree rendering. I takes the same arguments as Data:Dump::Tree.

method get_view

my $v = $f.get_view ;

Returns a view to the rendering. You can create multiple views from a single Foldable object. The views share the Foldable but each view has its own folds and geometry.

Data::Dump::Tree::Foldable::View

A view renderer for a Data::Dump::Tree rendering.

You can set the geometry of the view then navigate the data structure and fold it too.

method set(:$page_size, :$top_line, :$selected_line)

Set the geometry of the view where:

  • :page_size is the height of the view

  • :top_line is the line of the rendering displayed at the top of the window

  • :selected_line is a line index in the view

You can call set with a combination of named arguments, eg: you don't need to set all of them.

method line_up()

Scrolls the view up showing previous lines of the rendering

method page_up()

Scrolls the view up, the height of a view

method line_down()

Scrolls the view down showing following lines of the rendering

method page_down()

Scrolls the view down, the height of a view

method fold_flip_selected()

Folds or unfolds the data under the selected_line, see set.

method fold_all()

Folds all the data

method unfold_all()

Unfolds all the data

method get_lines()

Return all the lines visible in the view, may be less than the view height and even zero lines in case of a view size equal to 0

method search(:$regex!, :$fold_other --> SearchResults)

Searches for $regex in the data rendering and returns a SearchResults that contains all the matches, it can be used for further forward and backward searche.

The search is done in folded and unfolded lines. The first match is displayed at the top line of the view, unfolding as much as necessary of the data to make the I match> visible.

  • :$fold_other = False

The folding if the data is normally only changed to display the match but if :$fold_other is set, the data structure is folded at all levels and then unfolded to expose the match

AUTHOR

Nadim ibn hamouda el Khemir https://github.com/nkh

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl6 itself.

SEE-ALSO

Data::Dump::Tree

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.