equal
deleted
inserted
replaced
211 |
211 |
212 #------------------------------------------------------------------------------ |
212 #------------------------------------------------------------------------------ |
213 |
213 |
214 sub get_terminal_width |
214 sub get_terminal_width |
215 { |
215 { |
216 my $winsize; |
216 my $col = 50; |
217 die "no TIOCGWINSZ " unless defined &TIOCGWINSZ; |
217 |
218 open(TTY, "+</dev/tty") or die "No tty: $!"; |
218 if (defined &TIOCGWINSZ) { |
219 unless (ioctl(TTY, &TIOCGWINSZ, $winsize='')) { |
219 my $winsize; |
220 die sprintf "$0: ioctl TIOCGWINSZ (%08x: $!)\n", &TIOCGWINSZ; |
220 open(TTY, "+</dev/tty") or die "No tty: $!"; |
221 } |
221 unless (ioctl(TTY, &TIOCGWINSZ, $winsize='')) { |
222 (my $row, my $col, my $xpixel, my $ypixel) = unpack('S4', $winsize); |
222 die sprintf "$0: ioctl TIOCGWINSZ (%08x: $!)\n", &TIOCGWINSZ; |
|
223 } |
|
224 (my $row, $col, my $xpixel, my $ypixel) = unpack('S4', $winsize); |
|
225 } |
|
226 |
223 return $col; |
227 return $col; |
224 } |
228 } |
|
229 |
225 #------------------------------------------------------------------------------ |
230 #------------------------------------------------------------------------------ |
226 |
231 |
227 sub print_line |
232 sub print_line |
228 { |
233 { |
229 for (my $i = 0; $i < $term_width; $i++) { |
234 for (my $i = 0; $i < $term_width; $i++) { |