[erlang-questions] terminal codes

Mazen Harake mazen.harake@REDACTED
Sun May 2 15:26:04 CEST 2010


I'm not sure this is 100% relevant to the discussion but if you like you 
can take a look at cecho which is an ncurses library for Erlang. You can 
set terminal modes (like cbreak mode and noecho) etc very easily, it 
also supports colors.

Check it out here if interested: http://github.com/mazenharake/cecho

/M

On 01/05/2010 23:09, Henning Diedrich wrote:
> -noshell does the trick!
>
>        erl  -s testtest run -s init stop -noshell
>
> Kind of logical in hindsight ...
>
> Beautiful, thanks! Can I see the snake game?
>
> Henning
>
> Stefan Marr wrote:
>> Hi Henning:
>>
>> I have implemented a small snake game in Erlang using ANSI terminal 
>> control sequences, and it is started as follows:
>>
>> #!/bin/sh
>> stty -echo -echok -icanon min 1 time 0
>> erl -pa ./ -run main start -run init stop -noshell
>> stty echo echok icanon
>>
>>
>> If I remember correctly, the stty is not relevant for you, it should 
>> set the shell to send all characters to Erlang, without awaiting a 
>> new-line.
>>
>> Hope that helps.
>>
>> Best regards
>> Stefan
>>
>> On 01 May 2010, at 19:32, Henning Diedrich wrote:
>>
>>> This way of involing a program seems to prevent it as well.
>>>
>>> erl -s test run -s init stop
>>>
>>> What alternate way would allow control codes to get propagated 
>>> unchanched?
>>>
>>> Thanks!
>>> Henning
>>>
>>>
>>> 黃耀賢 (Yau-Hsien Huang) wrote:
>>>> I made a Erlang script and got output that seems correct.
>>>>
>>>> #!/usr/bin/env escript
>>>> -compile(export_all).
>>>> main([]) ->
>>>>    io:format("\e[1;36mabc\e[0;37m").
>>>>
>>>> I checked it by pasting what printed into a telnet BBS and viewing it
>>>> effect. It works.
>>>> So the problem may shift to how to make Erlang shell support 
>>>> terminal color
>>>> codes.
>>>>
>>>> On Sat, May 1, 2010 at 9:30 PM, Henning Diedrich 
>>>> <hd2010@REDACTED>wrote:
>>>>
>>>>
>>>>> Can I print terminal color codes out of Erlang?
>>>>>
>>>>> E.g. \e[30m?
>>>>>
>>>>> The io: functions seem to force control codes to be printable.
>>>>>
>>>>> Thanks!
>>>>> Henning
>>>>>
>>>>>
>>>>
>>
>>
>>
>

---------------------------------------------------

---------------------------------------------------

WE'VE CHANGED NAMES!

Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.

www.erlang-solutions.com



More information about the erlang-questions mailing list