… | |
… | |
1507 | $vbox->add (my $viewer = new CFPlus::UI::TextScroller |
1507 | $vbox->add (my $viewer = new CFPlus::UI::TextScroller |
1508 | expand => 1, fontsize => 0.8, padding_x => 4); |
1508 | expand => 1, fontsize => 0.8, padding_x => 4); |
1509 | |
1509 | |
1510 | my @history; |
1510 | my @history; |
1511 | my @future; |
1511 | my @future; |
1512 | my $node; |
1512 | my $curnode; |
1513 | |
1513 | |
1514 | my $load_node; $load_node = sub { |
1514 | my $load_node; $load_node = sub { |
1515 | my ($node) = @_; |
1515 | my ($node) = @_; |
1516 | |
1516 | |
1517 | $buttons->clear; |
1517 | $buttons->clear; |
1518 | |
1518 | |
1519 | if (@history) { |
1519 | if (@history) { |
1520 | $buttons->add (new CFPlus::UI::Button label => "<", on_activate => sub { |
1520 | $buttons->add (new CFPlus::UI::Button |
|
|
1521 | text => "<", |
|
|
1522 | tooltip => "back to " . CFPlus::Pod::full_path_of $history[-1], |
|
|
1523 | on_activate => sub { |
1521 | unshift @future, $node if $node; |
1524 | unshift @future, $curnode if $curnode; |
1522 | $node = pop @history; |
1525 | $load_node->(pop @history); |
1523 | |
|
|
1524 | }); |
1526 | }); |
1525 | } |
1527 | } |
|
|
1528 | |
|
|
1529 | if (@future) { |
|
|
1530 | $buttons->add (new CFPlus::UI::Button |
|
|
1531 | text => ">", |
|
|
1532 | tooltip => "forward to " . CFPlus::Pod::full_path_of $future[0], |
|
|
1533 | on_activate => sub { |
|
|
1534 | push @history, $curnode; |
|
|
1535 | $load_node->(shift @future); |
|
|
1536 | }); |
|
|
1537 | } |
|
|
1538 | |
|
|
1539 | $curnode = $node; |
|
|
1540 | |
1526 | $viewer->clear; |
1541 | $viewer->clear; |
1527 | $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $node); |
1542 | $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $curnode); |
1528 | $viewer->set_offset (0); |
1543 | $viewer->set_offset (0); |
1529 | }; |
1544 | }; |
1530 | |
1545 | |
1531 | $load_node->(CFPlus::Pod::find pod => "mainpage"); |
1546 | $load_node->(CFPlus::Pod::find pod => "mainpage"); |
1532 | |
1547 | |
1533 | $CFPlus::Pod::on_link = sub { |
1548 | $CFPlus::Pod::on_link = sub { |
1534 | my (@path) = @_; |
1549 | my (@path) = @_; |
1535 | |
1550 | |
1536 | push @history, $node if $node; |
1551 | push @history, $curnode if $curnode; |
1537 | @future = (); |
1552 | @future = (); |
1538 | |
1553 | |
1539 | $load_node->(CFPlus::Pod::find @path); |
1554 | $load_node->(CFPlus::Pod::find @path); |
1540 | $win->show; |
1555 | $win->show; |
1541 | }; |
1556 | }; |