[497] in BarnOwl Developers

home help back first fref pref prev next nref lref last post

[D-O-H] r617 - trunk/conf.asedeno/owl/modules

daemon@ATHENA.MIT.EDU (asedeno@MIT.EDU)
Thu Oct 29 18:06:47 2009

Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
To: dirty-owl-hackers@mit.edu
From: asedeno@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Fri, 16 Feb 2007 18:49:00 -0500 (EST)

Author: asedeno
Date: 2007-02-16 18:49:00 -0500 (Fri, 16 Feb 2007)
New Revision: 617

Modified:
   trunk/conf.asedeno/owl/modules/VT-asedeno.pl
Log:
Hack to fix UTF-8 smart quotes.

Also, whitespace cleanup.



Modified: trunk/conf.asedeno/owl/modules/VT-asedeno.pl
===================================================================
--- trunk/conf.asedeno/owl/modules/VT-asedeno.pl	2007-02-16 23:35:20 UTC (rev 616)
+++ trunk/conf.asedeno/owl/modules/VT-asedeno.pl	2007-02-16 23:49:00 UTC (rev 617)
@@ -46,7 +46,7 @@
     my $m = shift;
 
     if ($m->is_zephyr)
-    {	
+    {
 	return format_VT($m);
     }
     elsif ($m->is_aim)
@@ -65,8 +65,8 @@
     {
 	return "\@bold(loopback):  ".$m->body;
     }
-    else 
-    { 
+    else
+    {
 	return $m->type.":\t".$m->body;
     }
 }
@@ -74,7 +74,7 @@
 ################################################################################
 # A place to keep my options all together, with default values.
 ################################################################################
-our %VT_Options = 
+our %VT_Options =
     ("zsigs" => 0,
      "showControl" => 0,
      "stripMitEdu" => 1,
@@ -140,7 +140,7 @@
 
     # Extract time from message
     my ($time) = $m->time =~ /(\d\d:\d\d)/;
-   
+
     # Deal with PING messages, assuming owl's rxping variable is true.
     if ($m->is_ping)
     {
@@ -160,7 +160,7 @@
 
     # Extract destination from message
     my $dest;
-    
+
     if ($m->is_personal)
     {
 	# Special casing personal zephyrs. Yes, we could use personals as a
@@ -184,14 +184,14 @@
 	# If the defaults aren't being used, show both class and instance.
 	$dest = class_display_name($m).'['.$m->instance.']';
     }
-    
+
     # Extract user/authentication information from the message.
     my $user = $m->pretty_sender;
 
-    my $auth = (($m->auth =~ /YES/) 
+    my $auth = (($m->auth =~ /YES/)
 		? '+'
 		: '-');
-    
+
     # I'm assuming I'll never see echoes of outbound non-personal zephyrs,
     # so these must be personals. For outbound personals, set username as
     # the recipient with '->' prepended, set auth to '>' to indicate
@@ -205,7 +205,7 @@
     }
 
     my ($body, $hostSep) = format_body($m);
-   
+
     my $zVT = "";
     my $cols = owl::getnumcols();
     if ($cols < $VT_Options{"narrowMode"})
@@ -233,20 +233,20 @@
 	    $hostStr =~ s/\.MIT\.EDU$// if $VT_Options{"stripMitEdu"};
 
 	    my $rest  = $cols - 50;
-	    
+
 	    my $wDest = 16 + (($rest <= 14) ? $rest : 14 );
 	    $rest -= $wDest - 16;
-	    
+
 	    my $wUser = 10 + (($rest <= 2) ? $rest : 2);
 	    $rest -= $wUser - 10;
-	    
+
 	    my $wHost = 14 + (($rest <= 10) ? $rest : 10);
 	    $rest -= $wHost - 14;
-	    
+
 	    $wDest += $rest;
-	    
+
 	    my $fmt =  "%-".$wUser.".".$wUser."s %5s $auth %-".$wDest.".".$wDest."s %".$wHost."s\n %s";
-	    
+
 	    $zVT = sprintf($fmt,
 			   $user,
 			   $time,
@@ -264,7 +264,7 @@
 		       $dest,
 		       $body);
     }
-    
+
     if (($m->is_personal || lc($m->direction) eq 'out') ||
 	ARS_Color::isBold($m))
     {
@@ -282,7 +282,7 @@
 
     # Extract time from message
     my ($time) = $m->time =~ /(\d\d:\d\d)/;
-   
+
     # Deal with login/logout messages
     if ($m->is_login())
     {
@@ -302,14 +302,14 @@
 
     # Extract destination from message
     my $dest = $m->recipient;
-    
+
     # Extract user/authentication information from the message.
     my $user = $m->sender;
 
     my $dir = (lc($m->direction) eq 'out') ? '>' : '<';
-    
+
     my ($body, $hostSep) = format_body($m);
-    
+
     # Now build the message.
     my $zVT = "";
     if (owl::getnumcols() < $VT_Options{"narrowMode"})
@@ -340,7 +340,7 @@
 
     # Extract time from message
     my ($time) = $m->time =~ /(\d\d:\d\d)/;
-   
+
     # Deal with login/logout messages
     if ($m->is_login())
     {
@@ -372,9 +372,9 @@
     $user =~ s/\@mit.edu$//;
 
     my $dir = (lc($m->direction) eq 'out') ? '>' : '<';
-    
+
     my ($body, $hostSep) = format_body($m);
-    
+
     # Now build the message.
     my $zVT = "";
     if (owl::getnumcols() < $VT_Options{"narrowMode"})
@@ -407,7 +407,7 @@
 sub format_body
 {
     my $m = shift;
-    my $cols = owl::getnumcols();          # actual number of columns 
+    my $cols = owl::getnumcols();          # actual number of columns
     my $width = $cols - 3;                 # max usable width
     my $hwidth = ($cols < $VT_Options{"narrowMode"}) ? 2 : 38;   # body header width / body indent
     my $bwidth = $width - $hwidth;         # body width
@@ -417,7 +417,7 @@
     my $strlen = 0;
     my $body = "";
     my $hostAlone = 0;
-    
+
     # Zephyrs only: This shows me if there are literal backspaces in the
     # zephyr body or zsig.
     my $hostSep = ($m->body =~ /\cH/ || $m->zsig =~ /\cH/) ? "!#" : "##";
@@ -435,6 +435,11 @@
 	$rawBody =~ s/[\cH]//g;
     }
 
+    # Deal with UTF-8 "smart quotes"
+    $rawBody =~ s/\xE2\x80(?:\x98|\x99)/'/g;
+    $rawBody =~ s/\xE2\x80(?:\x9C|\x9D)/"/g;
+
+
     # This cleans up other peoples formatting. I can see what they meant, but it
     # doesn't muck with my display. Sorry about the painful regexp.
     # Basically, double up the '@'s in these formatting messages such that they
@@ -442,8 +447,8 @@
     $rawBody =~ s/\@font\(fixed\)$//; # GAIM is broken.
     $rawBody =~ s/([^@]|^)(\@(?:b|bold|i|italic|l|left|r|right|c|center|huge|large|medium|small|beep|color)([\(\<\{\[]))/\1\@\2/gi;
 
-    
-    # This is a really dumb formatting test. If the message has any newlines 
+
+    # This is a really dumb formatting test. If the message has any newlines
     # followed by whitespace followed by non whitespace, I'll assume the sender
     # knows what they're doing and format the message as they desire.
     if ($rawBody =~ /\n[ \t]+\S.*\n/)
@@ -452,13 +457,13 @@
 	$rawBody =~ s/\n+/\n/g;
 	$rawBody =~ s/\n*$//g;
 	my @lines = split (/\n/, $rawBody);
-	
+
 	# build the body, taking into account the desired indenting.
 	my $line = shift @lines;
 	$body .= " $line";
 	$strlen = length($line);
 
-	foreach $line (@lines)    
+	foreach $line (@lines)
 	{
 	    $body .= "\n";
 	    $body .= " " x ($hwidth - 1);
@@ -471,9 +476,9 @@
     else
     {
 	# Strip leading whitespace and then get an array of 'words'
-	$rawBody =~ s/^\s*//; 
+	$rawBody =~ s/^\s*//;
 	my @words = split (/\s+/,$rawBody);
-	
+
 	# -1 to take into account the leading space. It makes the loop nicer,
 	# and is a useful space anyways.
 	$strlen = -1;
@@ -489,15 +494,15 @@
 	    {
 		$body .= " $word";
 		$strlen += 1 + length($word);
-	    }	
-	    else		
-	    {	
-		# There is a small bug here, but it doesn't bother me. If
-		# someone types in a 'word' that is larger than the 
+	    }
+	    else
+	    {
+	        # There is a small bug here, but it doesn't bother me. If
+		# someone types in a 'word' that is larger than the
 		# 'max width' it will be on a line by itself.
-		# Since owl can scroll sideways, I can look at what was said, 
+		# Since owl can scroll sideways, I can look at what was said,
 		# and it won't affect the rest of the display... I hope.
-		# I could instead break the 'word' if this becomes a problem 
+		# I could instead break the 'word' if this becomes a problem
 		# one day.
 
 		$body .= "\n";
@@ -529,21 +534,21 @@
 	    $body .= "\n";
 	    $body .= " " x $zsindent;
 	    $body .= "--";
-	    
+
 	    my $sig = $m->zsig;
-	    
+
 	    $sig =~ s/.\cH//g;
 	    # Kill leading whitespace
 	    $sig =~ s/^\s*//;
-	    
-	    # You've seen this regexp before. 
+
+	    # You've seen this regexp before.
 	    $sig =~ s/([^@]|^)(\@(?:b|bold|i|italic|l|left|r|right|c|center|huge|large|medium|small|beep|color)([\(\<\{\[]))/\1\@\2/gi;
-	    
+
 	    # Unlike zephyr bodies, I'm unwrapping zsigs no matter what.
 	    my @words = split (/\s+/, $sig);
-	    
+
 	    $strlen = 2; #takes into account the '--' we've put in.
-	    
+
 	    foreach my $word (@words)
 	    {
 		$hostSep = '!#' if ($word =~ /[[:cntrl:]]/);
@@ -577,19 +582,19 @@
 		}
 	    }
 	}
-	
+
 	# Finally append the hostname. If it will fit on the last line of the
 	# zephyr, that's great, if not it gets a line of its own. The hostname is
 	# right justified. This only happens in the large screen formatting style.
 	if ($cols >= $VT_Options{"narrowMode"})
 	{
 	    my $hostwidth = (!($VT_Options{"zsigs"} && $m->zsig ne "")
-			     ? $bwidth 
+			     ? $bwidth
 			     : $zsbwidth);
-	    
+
 	    my $hostStr = uc($m->host);
 	    $hostStr =~ s/\.MIT\.EDU$// if $VT_Options{"stripMitEdu"};
-	    
+
 	    if ($hostAlone || (($strlen + 4 + length($hostStr)) >= $hostwidth))
 	    {
 		$body .= "\n";
@@ -613,7 +618,7 @@
 
 # This takes a zephyr to be displayed and modifies it to be displayed entirely
 # in bold. Point being that owl doesn't count the bold colors as separate
-# colors, but I want them treated as such. This in conjunction with 
+# colors, but I want them treated as such. This in conjunction with
 # ARS_Color::isbold() grants me those colors in the VT style.
 sub boldify($)
 {


home help back first fref pref prev next nref lref last post