simplify the logic. no need for a separate hook when we can just specialize
authorespie <espie@openbsd.org>
Fri, 24 Jun 2016 11:42:30 +0000 (11:42 +0000)
committerespie <espie@openbsd.org>
Fri, 24 Jun 2016 11:42:30 +0000 (11:42 +0000)
find_window_size.
fix a bug: integrate SIG{CONT} for re-checking window size.

the way it's currently written, first call to compute_playfield will
call itself once. But it makes for less code.

usr.sbin/pkg_add/OpenBSD/AddCreateDelete.pm
usr.sbin/pkg_add/OpenBSD/ProgressMeter/Term.pm
usr.sbin/pkg_add/OpenBSD/State.pm

index f6af4b5..9105a92 100644 (file)
@@ -1,5 +1,5 @@
 # ex:ts=8 sw=4:
-# $OpenBSD: AddCreateDelete.pm,v 1.38 2016/06/23 16:11:23 espie Exp $
+# $OpenBSD: AddCreateDelete.pm,v 1.39 2016/06/24 11:42:30 espie Exp $
 #
 # Copyright (c) 2007-2014 Marc Espie <espie@openbsd.org>
 #
@@ -99,9 +99,11 @@ sub is_interactive
        return shift->{interactive}->is_interactive;
 }
 
-sub window_size_changed
+sub find_window_size
 {
-       shift->{progressmeter}->compute_playfield;
+       my ($state, $cont) = @_;
+       $state->SUPER::find_window_size;
+       $state->{progressmeter}->compute_playfield($cont);
 }
 
 sub confirm
index 2d32716..ecfed71 100644 (file)
@@ -1,5 +1,5 @@
 # ex:ts=8 sw=4:
-# $OpenBSD: Term.pm,v 1.37 2016/06/23 16:11:23 espie Exp $
+# $OpenBSD: Term.pm,v 1.38 2016/06/24 11:42:30 espie Exp $
 #
 # Copyright (c) 2004-2007 Marc Espie <espie@openbsd.org>
 #
@@ -127,7 +127,7 @@ sub init
 
 sub compute_playfield
 {
-       my $self = shift;
+       my ($self, $cont) = @_;
        $self->{playfield} = $self->width - length($self->{header}) - 7;
        # we can print to 80 columns
        if ($self->{glitch} && $self->{state}->config->istrue("fullwidth")) {
@@ -136,6 +136,9 @@ sub compute_playfield
        if ($self->{playfield} < 5) {
                $self->{playfield} = 0;
        }
+       if ($cont) {
+               $self->{continued} = 1;
+       }
 }
 
 sub set_header
@@ -143,9 +146,6 @@ sub set_header
        my ($self, $header) = @_;
        $self->{header} = $header;
        $self->compute_playfield;
-       $SIG{'CONT'} = sub {
-               $self->{continued} = 1;
-       };
        return 1;
 }
 
index 56080e9..0e171b7 100644 (file)
@@ -1,5 +1,5 @@
 # ex:ts=8 sw=4:
-# $OpenBSD: State.pm,v 1.36 2016/06/23 16:11:23 espie Exp $
+# $OpenBSD: State.pm,v 1.37 2016/06/24 11:42:30 espie Exp $
 #
 # Copyright (c) 2007-2014 Marc Espie <espie@openbsd.org>
 #
@@ -394,13 +394,11 @@ sub find_window_size
                $self->{height} = $l[1];
                $SIG{'WINCH'} = sub {
                        $self->find_window_size;
-                       $self->window_size_changed;
                };
        }
-}
-
-sub window_size_changed
-{
+       $SIG{'CONT'} = sub {
+               $self->find_window_size(1);
+       }
 }
 
 OpenBSD::Auto::cache(signer_list,