Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Term::ANSIColor 2.0 doesn't support BRIGHT_* colors #3

Closed
cosimo opened this Issue · 3 comments

2 participants

@cosimo

Hi, just thought I'd drop a note here. Term::ANSIColor started having BRIGHT_* colors only from 3.0, so I think you could add an explicit dependency on T::A >= 3.0.

Plus, here's my (quick & dirty) workaround for my debian stable system where I'm currently running a debugging session :-)

From 0a12394a239c3922812bcb5581d8a30086ac9005 Mon Sep 17 00:00:00 2001
From: Cosimo Streppone <cosimo@opera.com>
Date: Thu, 24 May 2012 16:32:52 +0200
Subject: [PATCH] Users of Term::ANSIColor<3 can now use DB::Color too

Term::ANSIColor added support for BRIGHT_* colors only
from version 3.0. Debian stable still has perl 5.10 and
Term::ANSIColor 2.0.

I realize this isn't the best approach, but I was
in the middle of a debugging session, and I so wanted
syntax hightlighting... :-)
---
 lib/DB/Color/Highlight.pm |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/lib/DB/Color/Highlight.pm b/lib/DB/Color/Highlight.pm
index 17a42cb..4ba6a0b 100644
--- a/lib/DB/Color/Highlight.pm
+++ b/lib/DB/Color/Highlight.pm
@@ -61,6 +61,13 @@ sub _initialize {
 #      ON_BRIGHT_BLACK ON_BRIGHT_RED     ON_BRIGHT_GREEN ON_BRIGHT_YELLOW
 #      ON_BRIGHT_BLUE  ON_BRIGHT_MAGENTA ON_BRIGHT_CYAN  ON_BRIGHT_WHITE

+    my $has_bright_colors = Term::ANSIColor->VERSION() >= 3;
+    if (! $has_bright_colors) {
+        eval {
+            sub BRIGHT_BLUE () { return BLUE }
+        };
+    }
+
     my $highlighter = Syntax::Highlight::Engine::Kate::Perl->new(
         format_table => {
             'Keyword'      => [ YELLOW,      RESET ],
-- 
1.7.4.1
@cosimo

Maybe return CYAN is a better option for most terminals, instead of return BLUE...

@Ovid
Owner

Fixed, pushed, and a new version on the CPAN. I defaulted to BLUE instead of CYAN if they Term::ANSIColor < 3. I'm waiting for someone to submit a patch to make this configurable :)

@Ovid Ovid closed this
@cosimo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.