diff options
author | Jesse Luehrs <doy@tozt.net> | 2011-04-14 01:44:41 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2011-04-14 01:44:41 -0500 |
commit | 0ebbb2e8eebdf4af59a34e8bc1d128b0213ccb14 (patch) | |
tree | 55622fdffdc5884309ec6888fdb1cab33261d81e | |
parent | 3737f9223a7ef620ae95e614e35cb4b50c094125 (diff) | |
download | app-termcast-0ebbb2e8eebdf4af59a34e8bc1d128b0213ccb14.tar.gz app-termcast-0ebbb2e8eebdf4af59a34e8bc1d128b0213ccb14.zip |
wait to write the updates until we know it's safe
-rw-r--r-- | lib/App/Termcast.pm | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/App/Termcast.pm b/lib/App/Termcast.pm index ed7d561..c4d0293 100644 --- a/lib/App/Termcast.pm +++ b/lib/App/Termcast.pm @@ -243,6 +243,13 @@ has _raw_mode => ( }, ); +has _needs_termsize_update => ( + traits => ['NoGetopt'], + is => 'rw', + isa => 'Bool', + default => 0, +); + sub _build_select_args { my $self = shift; my @for = @_ ? @_ : (qw(socket pty input)); @@ -302,6 +309,12 @@ sub write_to_termcast { $self->clear_socket; return $self->write_to_termcast(@_); } + + if ($self->_needs_termsize_update) { + $buf = $self->termsize_message . $buf; + $self->_needs_termsize_update(0); + } + $self->socket->syswrite($buf); } @@ -333,12 +346,7 @@ sub run { syswrite STDOUT, "\e[H\e[2J"; # for the sake of sending a # clear to the client anyway - my ($cols, $lines) = GetTerminalSize(); - my $resize_string = $self->_form_metadata_string( - geometry => [$cols, $lines], - ); - - syswrite $self->socket, $resize_string; + $self->_needs_termsize_update(1); }; while (1) { |