From 97277323609c3bf4e66b25da314396ff449758df Mon Sep 17 00:00:00 2001 From: Jonathan Bernard Date: Sat, 6 Nov 2010 23:51:44 -0500 Subject: [PATCH] Fixed issue #1 by modifying TwitterCLI.color() Added optional third parameter representing the color to set instead of adding a reset. If null or not given, a reset is used (current behavior). --- src/com/jdbernard/twitter/TwitterCLI.groovy | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/com/jdbernard/twitter/TwitterCLI.groovy b/src/com/jdbernard/twitter/TwitterCLI.groovy index 0c1b43a..b476dcb 100644 --- a/src/com/jdbernard/twitter/TwitterCLI.groovy +++ b/src/com/jdbernard/twitter/TwitterCLI.groovy @@ -205,6 +205,7 @@ public class TwitterCLI { int authorLen = 0, textLen String statusIndent + def textColor = colors.even timeline.each { status -> if (status.user.screenName.length() > authorLen) @@ -223,8 +224,9 @@ public class TwitterCLI { substring(statusIndent.length()) } - text = text.replaceAll(/(@\w+)/, color("\$1", colors.mentioned)) - println color(text, (rowNum % 2 == 0 ? colors.even : colors.odd)) + textColor = (rowNum % 2 == 0 ? colors.even : colors.odd) + text = text.replaceAll(/(@\w+)/, color("\$1", colors.mentioned, textColor)) + println color(text, textColor) } } @@ -234,9 +236,10 @@ public class TwitterCLI { public String resetColor() { colored ? "\u001b[m" : "" } - public String color(def message, ConsoleColor color) { + public String color(def message, ConsoleColor color, + ConsoleColor existing = null) { if (!colored) return message - return color.toString() + message + resetColor() + return color.toString() + message + (existing ?: resetColor()) } }