| 1 | package DBIx::dbMan::Extension::OutputPager; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use base 'DBIx::dbMan::Extension'; | ||
| 5 | |||
| 6 | our $VERSION = '0.06'; | ||
| 7 | |||
| 8 | 1; | ||
| 9 | |||
| 10 | sub IDENTIFICATION { return "000001-000037-000006"; } | ||
| 11 | |||
| 12 | sub preference { return -50; } | ||
| 13 | |||
| 14 | sub known_actions { return [ qw/OUTPUT/ ]; } | ||
| 15 | |||
| 16 | sub handle_action { | ||
| 17 | my ($obj,%action) = @_; | ||
| 18 | |||
| 19 | if ($action{action} eq 'OUTPUT' and $action{output_pager} and $obj->{-interface}->can_pager()) { | ||
| 20 | open F,"|less -R"; | ||
| 21 | if ( $obj->{ -interface }->is_utf8 ) { | ||
| 22 | binmode F, ':utf8'; | ||
| 23 | } | ||
| 24 | print F $action{output}; | ||
| 25 | close F; | ||
| 26 | $action{action} = 'NONE'; | ||
| 27 | } | ||
| 28 | |||
| 29 | $action{processed} = 1; | ||
| 30 | return %action; | ||
| 31 | } |