octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Color terminal?


From: John W. Eaton
Subject: Color terminal?
Date: Mon, 01 Oct 2007 14:16:52 -0400

On  1-Oct-2007, Michael Goffioul wrote:

| While I'm at terminal-related stuff, I hacked octave a little bit such that
| it can make use of colored terminal. It includes:
| - additional --color argument to turn it on (turned off by default)
| - internal boolean Vterminal_color variable to hold the state
| - surround the prompt string with control chars to make it appear blue;
| the same with error strings to make it appear red (the color could be made
| configurable, if needed).
| 
| The whole stuff uses ANSI terminal color control sequence (I don't if
| there are still many terminal emulation out there that wouldn'tn support
| it). Would you like me to provide a patch?

Isn't it possible to do this with an appropriate setting of the prompt
string for readline?

I did notice a small bug in the handling of invisible prompt string
elements though and applied the following patch.  With it, you should
be able to do something like

  PS1 ('\[\e[31m\]\s:\#>\[\e[0m\] ')

to set a red prompt on a terminal that knows about ANSI escape sequences.

jwe


liboctave/ChangeLog:

2007-10-01  John W. Eaton  <address@hidden>

        * cmd-edit.cc (command_editor::do_decode_prompt_string): Don't
        insert extra '\001' when decoding \[ and \].


Index: liboctave/cmd-edit.cc
===================================================================
RCS file: /cvs/octave/liboctave/cmd-edit.cc,v
retrieving revision 1.34
diff -u -u -r1.34 cmd-edit.cc
--- liboctave/cmd-edit.cc       19 Sep 2007 20:45:13 -0000      1.34
+++ liboctave/cmd-edit.cc       1 Oct 2007 18:12:36 -0000
@@ -1128,10 +1128,9 @@
            case '[':
            case ']':
              {
-               temp.resize (2);
+               temp.resize (1);
 
-               temp[0] = '\001';
-               temp[1] = ((c == '[')
+               temp[0] = ((c == '[')
                           ? ::octave_rl_prompt_start_ignore ()
                           : ::octave_rl_prompt_end_ignore ());
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]