[erlang-questions] Reading (and ignoring) escape-sequences

Mazen Harake mazen.harake@REDACTED
Tue Mar 23 10:13:44 CET 2010


Yeah I've already started digging into that.

The problem is more fundamental then I thought and in the end it turns 
out that all libraries (including ncurses) depend on the the fact that a 
human can not type in the escape sequence as fast as it is received by a 
computer. This makes it _extreamly_ hard (I would say impossible) to do 
this from pure Erlang; it has to be done from inside the driver. The 
core problem was in fact "If an escape character, ^[, is received how do 
you know if it is the beginning of a sequence or if someone simply 
pressed escape" and the answer seems to be "Timing.".

Not what I had hoped for because now I have to implement some asynch io 
scheme to handle it. Hopefully this is something that could be handled 
by the official driver in the future (e.g. start the driver with a flag 
or something to get mapped key-input); I tried looking at it but my 
C-fetish only reach so far *shrug*.

Anyway, Thank you for the reply, Kenji.

/Mazen


On 23/03/2010 01:40, Kenji Rikitake wrote:
> I suggest you to learn termcap/terminfo libraries on UNIX,
> and the curses library (ncurses now I guess) source code.
> You need to parse the whole sequence anyway.
> And the definition of those sequences depends on the type to
> terminals you're going to connect.
>
> Kenji Rikitake
>
> In the message<4BA76862.3050609@REDACTED>
> dated Mon, Mar 22, 2010 at 02:53:30PM +0200,
> Mazen Harake<mazen.harake@REDACTED>  writes:
>    
>> Say that I want to be able to catch UpArrow but not LeftArrow (or any
>> other escape-sequence for that matter) I can't start reading the ^[
>> character and suddenly stop when there is something I don't recognise
>> because there might be "garbage" which I have to skip (the rest of the
>> sequence)... and to skip this I have to implement the whole list of
>> escape-sequences to know how much to skip. Is there any other way to do
>> this in Erlang? I can't seem to find any facility to read or get
>> escape-sequences (like UpArrow or whatever).
>>
>> Did I overlook something or anyone have any tip on how to do this?
>>      
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>    

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

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

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