[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
John W. Eaton
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.
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 \].
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 @@
- temp.resize (2);
+ temp.resize (1);
- temp = '\001';
- temp = ((c == '[')
+ temp = ((c == '[')
? ::octave_rl_prompt_start_ignore ()
: ::octave_rl_prompt_end_ignore ());
- Color terminal?, Michael Goffioul, 2007/10/01
- Color terminal?,
John W. Eaton <=