| 1 | package DBIx::dbMan::Extension::CmdSetTotalCount; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use base 'DBIx::dbMan::Extension'; | ||
| 5 | |||
| 6 | our $VERSION = '0.03'; | ||
| 7 | |||
| 8 | 1; | ||
| 9 | |||
| 10 | sub IDENTIFICATION { return "000001-000074-000003"; } | ||
| 11 | |||
| 12 | sub preference { return 1000; } | ||
| 13 | |||
| 14 | sub known_actions { return [ qw/COMMAND/ ]; } | ||
| 15 | |||
| 16 | sub menu { | ||
| 17 | my $obj = shift; | ||
| 18 | |||
| 19 | my $dir = 'on'; my $sel = ' '; | ||
| 20 | $sel = '*' if $obj->{-mempool}->get('total_count'); | ||
| 21 | $dir = 'off' if $sel eq '*'; | ||
| 22 | |||
| 23 | return ( { label => 'Settings', submenu => [ | ||
| 24 | { label => $sel.' '.'Show total count of lines and cols', | ||
| 25 | action => { action => 'COMMAND', | ||
| 26 | cmd => 'set total count '.$dir } } | ||
| 27 | ] } ); | ||
| 28 | } | ||
| 29 | |||
| 30 | sub handle_action { | ||
| 31 | my ($obj,%action) = @_; | ||
| 32 | |||
| 33 | if ($action{action} eq 'COMMAND') { | ||
| 34 | if ($action{cmd} =~ /^set\s+total\s*count\s+(on|off)$/i) { | ||
| 35 | my $want = lc $1; my $owant = $want; | ||
| 36 | $want = ($want eq 'off')?0:1; | ||
| 37 | $obj->{-mempool}->set('total_count',$want); | ||
| 38 | $action{action} = 'OUTPUT'; | ||
| 39 | $action{output} = "Total size info messages $owant.\n"; | ||
| 40 | $obj->{-interface}->rebuild_menu(); | ||
| 41 | } | ||
| 42 | } | ||
| 43 | |||
| 44 | $action{processed} = 1; | ||
| 45 | return %action; | ||
| 46 | } | ||
| 47 | |||
| 48 | sub cmdhelp { | ||
| 49 | return [ | ||
| 50 | 'SET TOTAL COUNT [ON|OFF]' => 'Set total count info messages on or off.' | ||
| 51 | ]; | ||
| 52 | } | ||
| 53 | |||
| 54 | sub cmdcomplete { | ||
| 55 | my ($obj,$text,$line,$start) = @_; | ||
| 56 | return qw/ON OFF/ if $line =~ /^\s*SET\s+TOTAL\s+COUNT\s+\S*$/i; | ||
| 57 | return qw/COUNT/ if $line =~ /^\s*SET\s+TOTAL\s+\S*$/i; | ||
| 58 | return qw/TOTAL/ if $line =~ /^\s*SET\s+\S*$/i; | ||
| 59 | return qw/SET/ if $line =~ /^\s*[A-Z]*$/i; | ||
| 60 | return (); | ||
| 61 | } |