Ignore:
Timestamp:
Dec 24, 2009, 6:18:51 PM (14 years ago)
Author:
Alex Dehnert <adehnert@mit.edu>
Branches:
master, release-1.10, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
980fa31
Parents:
c471e85
git-author:
Alex Dehnert <adehnert@mit.edu> (12/20/09 01:50:12)
git-committer:
Alex Dehnert <adehnert@mit.edu> (12/24/09 18:18:51)
Message:
Allow left/right scrolling by arbitrary amount

Move recv:{left,right}shift to Perl and make
them optionally accept a number of columns to
scroll by (default: 10).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perl/lib/BarnOwl.pm

    r1b9a163 r6700c605  
    3838use BarnOwl::Completion;
    3939
     40use List::Util qw(max);
     41
    4042=head1 NAME
    4143
     
    421423                       });
    422424
     425    # Receive window scrolling
     426    BarnOwl::new_command("recv:shiftleft",
     427                        \&BarnOwl::recv_shift_left,
     428                        {
     429                            summary => "scrolls receive window to the left",
     430                            usage => "recv:shiftleft [<amount>]",
     431                            description => <<END_DESCR
     432By default, scroll left by 10 columns. Passing no arguments or 0 activates this default behavior.
     433Otherwise, scroll by the number of columns specified as the argument.
     434END_DESCR
     435                        });
     436
     437    BarnOwl::new_command("recv:shiftright",
     438                        \&BarnOwl::recv_shift_right,
     439                        {
     440                            summary => "scrolls receive window to the right",
     441                            usage => "recv:shiftright [<amount>]",
     442                            description => <<END_DESCR
     443By default, scroll right by 10 columns. Passing no arguments or 0 activates this default behavior.
     444Otherwise, scroll by the number of columns specified as the argument.
     445END_DESCR
     446                        });
     447
    423448}
    424449
     
    485510}
    486511
     512=head3 Receive window scrolling
     513
     514Permit scrolling the receive window left or right by arbitrary
     515amounts (with a default of 10 characters).
     516
     517=cut
     518
     519sub recv_shift_left
     520{
     521    my $func = shift;
     522    my $delta = shift;
     523    $delta = 10 unless int($delta) > 0;
     524    my $shift = BarnOwl::recv_getshift();
     525    if($shift > 0) {
     526        BarnOwl::recv_setshift(max(0, $shift-$delta));
     527    } else {
     528        return "Already full left";
     529    }
     530}
     531
     532sub recv_shift_right
     533{
     534    my $func = shift;
     535    my $delta = shift;
     536    $delta = 10 unless int($delta) > 0;
     537    my $shift = BarnOwl::recv_getshift();
     538    BarnOwl::recv_setshift($shift+$delta);
     539}
     540
    487541=head3 default_zephyr_signature
    488542
Note: See TracChangeset for help on using the changeset viewer.