From: espie Date: Fri, 24 Jun 2016 11:42:30 +0000 (+0000) Subject: simplify the logic. no need for a separate hook when we can just specialize X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7d6f6caed0211461f6635057e57a853d1249e1ba;p=openbsd simplify the logic. no need for a separate hook when we can just specialize 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. --- diff --git a/usr.sbin/pkg_add/OpenBSD/AddCreateDelete.pm b/usr.sbin/pkg_add/OpenBSD/AddCreateDelete.pm index f6af4b538db..9105a92bfba 100644 --- a/usr.sbin/pkg_add/OpenBSD/AddCreateDelete.pm +++ b/usr.sbin/pkg_add/OpenBSD/AddCreateDelete.pm @@ -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 # @@ -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 diff --git a/usr.sbin/pkg_add/OpenBSD/ProgressMeter/Term.pm b/usr.sbin/pkg_add/OpenBSD/ProgressMeter/Term.pm index 2d32716e210..ecfed7144e9 100644 --- a/usr.sbin/pkg_add/OpenBSD/ProgressMeter/Term.pm +++ b/usr.sbin/pkg_add/OpenBSD/ProgressMeter/Term.pm @@ -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 # @@ -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; } diff --git a/usr.sbin/pkg_add/OpenBSD/State.pm b/usr.sbin/pkg_add/OpenBSD/State.pm index 56080e9a4f5..0e171b721d1 100644 --- a/usr.sbin/pkg_add/OpenBSD/State.pm +++ b/usr.sbin/pkg_add/OpenBSD/State.pm @@ -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 # @@ -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,