caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* color on linux terminal
@ 2007-01-13 20:29 Markus Weihs
  2007-01-13 20:52 ` [Caml-list] " Daniel de Rauglaudre
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Markus Weihs @ 2007-01-13 20:29 UTC (permalink / raw)
  To: caml-list

Hi,

to get coloured output on a linux terminal, you can do something like

    echo -e "\033[31m This is now red"

How can I do this with OCaml? The following doesn't work

    print_string "\033[31m blabla"


Thanks in advance,

Markus


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Caml-list] color on linux terminal
  2007-01-13 20:29 color on linux terminal Markus Weihs
@ 2007-01-13 20:52 ` Daniel de Rauglaudre
  2007-01-13 21:05   ` Markus Weihs
  2007-01-13 20:53 ` [Caml-list] " Vu Ngoc San
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Daniel de Rauglaudre @ 2007-01-13 20:52 UTC (permalink / raw)
  To: caml-list

Hi,

On Sat, Jan 13, 2007 at 08:29:16PM +0000, Markus Weihs wrote:

> How can I do this with OCaml? The following doesn't work
>     print_string "\033[31m blabla"

print_string "\027[31m blabla"

Character codes are in decimal in OCaml, not in octal.

-- 
Daniel de Rauglaudre
http://pauillac.inria.fr/~ddr/


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Caml-list] color on linux terminal
  2007-01-13 20:29 color on linux terminal Markus Weihs
  2007-01-13 20:52 ` [Caml-list] " Daniel de Rauglaudre
@ 2007-01-13 20:53 ` Vu Ngoc San
  2007-01-13 20:56 ` Eric Cooper
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Vu Ngoc San @ 2007-01-13 20:53 UTC (permalink / raw)
  Cc: caml-list

print_string "\027[31m Yes it is red";;


Markus Weihs a écrit :
> Hi,
> 
> to get coloured output on a linux terminal, you can do something like
> 
>     echo -e "\033[31m This is now red"
> 
> How can I do this with OCaml? The following doesn't work
> 
>     print_string "\033[31m blabla"
> 
> 
> Thanks in advance,
> 
> Markus
> 
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
> 


-- 
---
Vu Ngoc San			tel:04 76 63 58 53
Institut Fourier		e-mail:San.Vu-Ngoc@ujf-grenoble.fr
Universite Grenoble 1, BP 74	http://www-fourier.ujf-grenoble.fr/~svungoc
38402 Saint Martin d'Heres
France
---


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Caml-list] color on linux terminal
  2007-01-13 20:29 color on linux terminal Markus Weihs
  2007-01-13 20:52 ` [Caml-list] " Daniel de Rauglaudre
  2007-01-13 20:53 ` [Caml-list] " Vu Ngoc San
@ 2007-01-13 20:56 ` Eric Cooper
  2007-01-16 18:23   ` Florian Weimer
  2007-01-21 17:11   ` Xavier Leroy
  2007-01-13 20:56 ` Goulagman
  2007-01-13 22:45 ` Christophe TROESTLER
  4 siblings, 2 replies; 10+ messages in thread
From: Eric Cooper @ 2007-01-13 20:56 UTC (permalink / raw)
  To: caml-list, caml-list

On Sat, Jan 13, 2007 at 08:29:16PM +0000, Markus Weihs wrote:
> to get coloured output on a linux terminal, you can do something like
> 
>     echo -e "\033[31m This is now red"
> 
> How can I do this with OCaml? The following doesn't work
> 
>     print_string "\033[31m blabla"

This is my biggest "pet peeve" about OCaml.  It uses *decimal* escapes
for characters, not octal like everywhere else in the UNIX and
C-influenced universe.

So you want
     print_string "\027[31m blabla"

-- 
Eric Cooper             e c c @ c m u . e d u


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Caml-list] color on linux terminal
  2007-01-13 20:29 color on linux terminal Markus Weihs
                   ` (2 preceding siblings ...)
  2007-01-13 20:56 ` Eric Cooper
@ 2007-01-13 20:56 ` Goulagman
  2007-01-13 21:38   ` Philippe Wang
  2007-01-13 22:45 ` Christophe TROESTLER
  4 siblings, 1 reply; 10+ messages in thread
From: Goulagman @ 2007-01-13 20:56 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 463 bytes --]

On 13/01/07, Markus Weihs <mweihs@gmx.at> wrote:
>
> Hi,
>
> to get coloured output on a linux terminal, you can do something like
>
>     echo -e "\033[31m This is now red"
>
> How can I do this with OCaml? The following doesn't work
>
>     print_string "\033[31m blabla"


It's because, for Ocaml,   the escape sequence \0xx matches the ASCII
character xx in decimal, not in octal.

print_string "\027[31m blabla" works fine

Thanks in advance,
>
> Markus
>
>

[-- Attachment #2: Type: text/html, Size: 1005 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: color on linux terminal
  2007-01-13 20:52 ` [Caml-list] " Daniel de Rauglaudre
@ 2007-01-13 21:05   ` Markus Weihs
  0 siblings, 0 replies; 10+ messages in thread
From: Markus Weihs @ 2007-01-13 21:05 UTC (permalink / raw)
  To: caml-list

> print_string "\027[31m blabla"

Whoa, that was quick! Thanks for all your answers.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Caml-list] color on linux terminal
  2007-01-13 20:56 ` Goulagman
@ 2007-01-13 21:38   ` Philippe Wang
  0 siblings, 0 replies; 10+ messages in thread
From: Philippe Wang @ 2007-01-13 21:38 UTC (permalink / raw)
  To: Goulagman; +Cc: caml-list


On 13 janv. 07, at 21:56, Goulagman wrote:

> It's because, for Ocaml,   the escape sequence \0xx matches the  
> ASCII character xx in decimal, not in octal.
>
> print_string "\027[31m blabla" works fine
>

Well, what you said is true, still it's not meant to be explained  
like this ! (well I guess and hope so)

The backslash in a character or string sequence introduces a decimal  
number between 0 and 255 with *exactly* 3 digits.

You can also write special characters in hexadecimal :

"\xFF"  = "\255"

;-)


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Caml-list] color on linux terminal
  2007-01-13 20:29 color on linux terminal Markus Weihs
                   ` (3 preceding siblings ...)
  2007-01-13 20:56 ` Goulagman
@ 2007-01-13 22:45 ` Christophe TROESTLER
  4 siblings, 0 replies; 10+ messages in thread
From: Christophe TROESTLER @ 2007-01-13 22:45 UTC (permalink / raw)
  To: mweihs; +Cc: caml-list

On Sat, 13 Jan 2007, Markus Weihs <mweihs@gmx.at> wrote:
> 
> to get coloured output on a linux terminal, you can do something like
> 
>     echo -e "\033[31m This is now red"

You can also use ANSITerminal
<http://math.umh.ac.be/an/software.php#x4-90008>.

ChriS


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Caml-list] color on linux terminal
  2007-01-13 20:56 ` Eric Cooper
@ 2007-01-16 18:23   ` Florian Weimer
  2007-01-21 17:11   ` Xavier Leroy
  1 sibling, 0 replies; 10+ messages in thread
From: Florian Weimer @ 2007-01-16 18:23 UTC (permalink / raw)
  To: caml-list; +Cc: caml-list

* Eric Cooper:

> This is my biggest "pet peeve" about OCaml.  It uses *decimal* escapes
> for characters, not octal like everywhere else in the UNIX and
> C-influenced universe.

DNS and BIND use decimal escape sequences, too.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Caml-list] color on linux terminal
  2007-01-13 20:56 ` Eric Cooper
  2007-01-16 18:23   ` Florian Weimer
@ 2007-01-21 17:11   ` Xavier Leroy
  1 sibling, 0 replies; 10+ messages in thread
From: Xavier Leroy @ 2007-01-21 17:11 UTC (permalink / raw)
  To: Eric Cooper; +Cc: caml-list

> This is my biggest "pet peeve" about OCaml.  It uses *decimal* escapes
> for characters,

Hexadecimal is also supported ("\x1b[31m blabla") and highly recommended.

> not octal like everywhere else in the UNIX and C-influenced universe.

Well, how many fingers do you have? :-)  Octal is a left-over from the
PDP-11 days and should have been abandoned a long time ago.

- Xavier Leroy


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-01-21 17:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-13 20:29 color on linux terminal Markus Weihs
2007-01-13 20:52 ` [Caml-list] " Daniel de Rauglaudre
2007-01-13 21:05   ` Markus Weihs
2007-01-13 20:53 ` [Caml-list] " Vu Ngoc San
2007-01-13 20:56 ` Eric Cooper
2007-01-16 18:23   ` Florian Weimer
2007-01-21 17:11   ` Xavier Leroy
2007-01-13 20:56 ` Goulagman
2007-01-13 21:38   ` Philippe Wang
2007-01-13 22:45 ` Christophe TROESTLER

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).