diff options
author | Tom Feist <shabble@metavore.org> | 2010-10-06 23:20:27 +0000 |
---|---|---|
committer | Tom Feist <shabble@metavore.org> | 2010-10-06 23:20:27 +0000 |
commit | 1a4fcd79fd841430365d2e184f82f5e4ac0f736b (patch) | |
tree | 668af61f3e9c1a5083a11c4b2ba5d4b1742b45a9 /prompt_info | |
parent | added some debugging output to terminal size detection (diff) | |
download | irssi-scripts-1a4fcd79fd841430365d2e184f82f5e4ac0f736b.tar.gz irssi-scripts-1a4fcd79fd841430365d2e184f82f5e4ac0f736b.zip |
back to stty parsing, with linux and osx cases. Falls back to 80x24 if it
doesn't match either.
Diffstat (limited to 'prompt_info')
-rw-r--r-- | prompt_info/prompt_replace.pl | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/prompt_info/prompt_replace.pl b/prompt_info/prompt_replace.pl index 90bb6f6..20fb7b1 100644 --- a/prompt_info/prompt_replace.pl +++ b/prompt_info/prompt_replace.pl @@ -39,14 +39,24 @@ init(); sub update_terminal_size { - - my $rows = qx/tput lines/; - my $cols = qx/tput cols/; - chomp $rows; - chomp $cols; - - $term_w = 0+$cols; - $term_h = 0+$rows; + my @stty_data = qx/stty -a/; + my $line = $stty_data[0]; + + # linux + # speed 38400 baud; rows 36; columns 126; line = 0; + if ($line =~ m/rows (\d+); columns (\d+);/) { + $term_h = $1; + $term_w = $2; + # osx + # speed 9600 baud; 40 rows; 235 columns; + } elsif ($line =~ m/(\d+) rows; (\d+) columns;/) { + $term_h = $1; + $term_w = $2; + } else { + # guess? + $term_h = 24; + $term_w = 80; + } print "Terminal detected as $term_w cols by $term_h rows" if DEBUG; } |