diff options
| author | Daniel Friesel <derf@finalrewind.org> | 2010-12-12 09:50:13 +0100 | 
|---|---|---|
| committer | Daniel Friesel <derf@finalrewind.org> | 2010-12-12 09:50:13 +0100 | 
| commit | 0d2164fb4033f1db0a0cac3abbc09ac83629d9d2 (patch) | |
| tree | 389dce6b31b8ecbd287bc5fcbb8a9990b074bdbc | |
| parent | 14a3c31190e310f46a3028d1b3b0c078fcad4011 (diff) | |
Don't try to cut off stuff when there's no terminal width available
| -rwxr-xr-x | bin/icli | 13 | 
1 files changed, 10 insertions, 3 deletions
| @@ -143,14 +143,21 @@ sub break_str {  	my ($text, $waste) = @_;  	my $cut = $term_width - $waste; +	if ( +			(not defined $term_width) or  +			($term_width == 0) or +			($cut < 12)) { +		return $text; +	} +  	if ($cut_mode eq 'c') { -		return(substr($text, 0, $cut)); +		return substr($text, 0, $cut);  	}  	elsif ($cut_mode eq 'b') { -		return(join("\n", split_by_words($text, $waste, $cut))); +		return join("\n", split_by_words($text, $waste, $cut));  	}  	else { -		return($text); +		return $text;  	}  } | 
