in reply to Interactive post-coloring of readline input?

Use this and step through it.
#!/usr/bin/perl -d use strict; use warnings; use Term::ReadLine; use Term::ANSIColor; my $attr = "This is a test"; print "$attr", "\n", colored("$attr", "red"), "\n", colored("$attr", "blue"), "\n", colored("$attr", "green"), "\n", colored("$attr", "black"), "\n";

Replies are listed 'Best First'.
Re^2: Interactive post-coloring of readline input?
by LanX (Saint) on Feb 09, 2012 at 03:41 UTC
    Thanks, but maybe a misunderstanding.

    I'm using the debugger as a shell/REPL and want to highlight perl keywords while I'm typing them.

    DB<100> print $a;

    DB<101> prin█

    So my question is rather how to hook into Term::ReadLine::Gnu to intercept finished words and surround them with the help of Term::ANSIColor.

    I'm not sure what for you use Term::ReadLine in your example...

    Cheers Rolf

      Actually, you should spend your time reading the manuals for Readline library. For example here .

      Once you understand, which facilities the library provides for interacting with the users input, you should be able to find appropriate front-end functions in Perl. I see there functions like rl_insert_text, rl_delete_text which lead me to belief, that it is possible to do what you want. But personally I've never tried to do it.

        > Actually, you should spend your time reading the manuals for Readline library.

        Actually RTFM is how I spend most of yesterday. :(

        Readline is a fairly rich editor-like application ...

        FWIW hooking into rl_event_hook() is my best bet so far.

        Cheers Rolf