… | |
… | |
1528 | my @history; |
1528 | my @history; |
1529 | my @future; |
1529 | my @future; |
1530 | my $curnode; |
1530 | my $curnode; |
1531 | |
1531 | |
1532 | my $load_node; $load_node = sub { |
1532 | my $load_node; $load_node = sub { |
1533 | my ($node) = @_; |
1533 | my ($node, $para) = @_; |
1534 | |
1534 | |
1535 | $buttons->clear; |
1535 | $buttons->clear; |
1536 | |
1536 | |
1537 | if (@history) { |
1537 | if (@history) { |
1538 | $buttons->add (new CFPlus::UI::Button |
1538 | $buttons->add (new CFPlus::UI::Button |
1539 | text => "⋘", |
1539 | text => "⋘", |
1540 | tooltip => "back to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $history[-1]) . "</i>", |
1540 | tooltip => "back to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $history[-1]) . "</i>", |
1541 | on_activate => sub { |
1541 | on_activate => sub { |
1542 | unshift @future, $curnode if $curnode; |
1542 | unshift @future, [$curnode, $viewer->current_paragraph] if $curnode; |
1543 | $load_node->(pop @history); |
1543 | $load_node->(@{pop @history}); |
1544 | }, |
1544 | }, |
1545 | ); |
1545 | ); |
1546 | } |
1546 | } |
1547 | |
1547 | |
1548 | if (@future) { |
1548 | if (@future) { |
1549 | $buttons->add (new CFPlus::UI::Button |
1549 | $buttons->add (new CFPlus::UI::Button |
1550 | text => "⋙", |
1550 | text => "⋙", |
1551 | tooltip => "forward to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $future[0]) . "</i>", |
1551 | tooltip => "forward to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $future[0]) . "</i>", |
1552 | on_activate => sub { |
1552 | on_activate => sub { |
1553 | push @history, $curnode; |
1553 | push @history, [$curnode, $viewer->current_paragraph]; |
1554 | $load_node->(shift @future); |
1554 | $load_node->(@{shift @future}); |
1555 | }, |
1555 | }, |
1556 | ); |
1556 | ); |
1557 | } |
1557 | } |
1558 | |
1558 | |
1559 | $buttons->add (new CFPlus::UI::Label text => " "); |
1559 | $buttons->add (new CFPlus::UI::Label text => " "); |
… | |
… | |
1564 | for my $node (@path) { |
1564 | for my $node (@path) { |
1565 | $buttons->add (new CFPlus::UI::Button |
1565 | $buttons->add (new CFPlus::UI::Button |
1566 | text => $node->{kw}[0], |
1566 | text => $node->{kw}[0], |
1567 | tooltip => "go to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $node) . "</i>", |
1567 | tooltip => "go to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $node) . "</i>", |
1568 | on_activate => sub { |
1568 | on_activate => sub { |
1569 | push @history, $curnode if $curnode; @future = (); |
1569 | push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = (); |
1570 | $load_node->($node); |
1570 | $load_node->($node); |
1571 | }, |
1571 | }, |
1572 | ); |
1572 | ); |
1573 | $buttons->add (new CFPlus::UI::Label text => "/"); |
1573 | $buttons->add (new CFPlus::UI::Label text => "/"); |
1574 | } |
1574 | } |
… | |
… | |
1577 | |
1577 | |
1578 | $curnode = $node; |
1578 | $curnode = $node; |
1579 | |
1579 | |
1580 | $viewer->clear; |
1580 | $viewer->clear; |
1581 | $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $curnode); |
1581 | $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $curnode); |
1582 | $viewer->set_offset (0); |
1582 | $viewer->scroll_to ($para); |
1583 | }; |
1583 | }; |
1584 | |
1584 | |
1585 | $load_node->(CFPlus::Pod::find pod => "mainpage"); |
1585 | $load_node->(CFPlus::Pod::find pod => "mainpage"); |
1586 | |
1586 | |
1587 | $CFPlus::Pod::goto_document = sub { |
1587 | $CFPlus::Pod::goto_document = sub { |
1588 | my (@path) = @_; |
1588 | my (@path) = @_; |
1589 | |
1589 | |
1590 | push @history, $curnode if $curnode; @future = (); |
1590 | push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = (); |
1591 | |
1591 | |
1592 | $load_node->(CFPlus::Pod::find @path); |
1592 | $load_node->(CFPlus::Pod::find @path); |
1593 | $win->show; |
1593 | $win->show; |
1594 | }; |
1594 | }; |
1595 | |
1595 | |