Reading (and ignoring) escape-sequences

Mazen Harake mazen.harake@REDACTED
Mon Mar 22 13:53:54 CET 2010


Hi list,

Lets say I read 1 char at a time:

l() ->
     Chr = io:get_chars('',1),
     ...
     l().

and the person giving me input press ^[[A (UpArrow). This will yield 
three loops in my program, one for each of these characters. Well that 
is not a problem I can flag for collecting an escape-sequence but there 
is another problem.

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?

/Mazen
---------------------------------------------------

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

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