- Timestamp:
- Oct 28, 2009, 10:00:15 AM (15 years ago)
- Branches:
- master, release-1.10, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 48d130b
- Parents:
- 7ca5d3e
- git-author:
- Karl Ramm <kcr@1ts.org> (10/25/09 12:11:13)
- git-committer:
- Karl Ramm <kcr@1ts.org> (10/28/09 10:00:15)
- Location:
- perl/lib/BarnOwl/Style
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
perl/lib/BarnOwl/Style/Default.pm
r0b2afba rad0dedd 24 24 } 25 25 $fmt = BarnOwl::Style::boldify($fmt) if $self->should_bold($m); 26 $fmt = $self->humanize($fmt); 26 27 return $fmt; 27 28 } … … 86 87 if ( $m->is_personal ) { 87 88 my $personal_context = $m->personal_context; 88 $personal_context = ' [' . $ personal_context. ']' if $personal_context;89 $personal_context = ' [' . $self->humanize($personal_context, 1) . ']' if $personal_context; 89 90 90 91 if ( $m->direction eq "out" ) { … … 94 95 } 95 96 } else { 96 $header = $ m->context;97 $header = $self->humanize($m->context, 1); 97 98 if(defined $m->subcontext) { 98 $header .= ' / ' . $ m->subcontext;99 $header .= ' / ' . $self->humanize($m->subcontext, 1); 99 100 } 100 101 $header .= ' / @b{' . $m->pretty_sender . '}'; … … 102 103 103 104 if($m->opcode) { 104 $header .= " [" . $ m->opcode. "]";105 $header .= " [" . $self->humanize($m->opcode, 1) . "]"; 105 106 } 106 107 $header .= " " . $self->format_time($m); … … 138 139 } 139 140 141 =head3 humanize STRING [one_line] 142 143 Method that takes a STRING with control characters and makes it human 144 readable in such a way as to not do anything funky with the terminal. 145 If one_line is true, be more conservative about what we treat as 146 control character. 147 148 =cut 149 150 sub humanize 151 { 152 my $self = shift; 153 my $s = shift; 154 my $oneline = shift; 155 sub _humanize_char 156 { 157 my $c = ord(shift); 158 159 if ($c < ord(' ')) { 160 return ('^' . chr($c + ord('@'))); 161 } elsif ($c == 255) { 162 return ('^?'); 163 } else { 164 return (sprintf('\\x{%x}', $c)); 165 } 166 } 167 my $colorize = (BarnOwl::getvar('colorztext') eq 'on') 168 ? '@color(cyan)' : ''; 169 170 my $chars = $oneline ? qr/[[:cntrl:]]/ : qr/[^[:print:]]|[\r\cK\f]/; 171 172 $s =~ s/($chars)/ 173 "\@b($colorize" . _humanize_char($1) . ')'/eg; 174 175 return $s; 176 } 177 178 =head3 humanize_short STRING 179 180 As above, but always be conservative, and replace with a '?' instead 181 of something mmore elaborate. 182 183 =cut 184 185 sub humanize_short 186 { 187 my $self = shift; 188 my $s = shift; 189 190 $s =~ s/[[:cntrl:]]/?/g; 191 192 return $s; 193 } 140 194 141 195 1; -
perl/lib/BarnOwl/Style/OneLine.pm
rfc92548d rad0dedd 80 80 $body =~ tr/\n/ /; 81 81 $line .= $body; 82 $line = $self->humanize_short($line); 82 83 return $line; 83 84 }
Note: See TracChangeset
for help on using the changeset viewer.