How to use dumb terminal Input/Output instead of Web Servers for Elixir applications?

Jere

You onto something.

I will give it a try.

Thanks kindly

Hi!

I cannot find any information on how I could implement dumb terminal infrastructure for Elixir/Erlang.

The idea is very simple. You just start a TCP server (see gen_tcp example in Erlang or Elixir), and connect to its IP:PORT from any terminal emulator. Most of them are supporting nowadays ANSI/VT100 terminal escape codes which you could send from the server side to the client side - to set a cursor position or to change text attributes on the client screen.

A shell script example (run with sh or bash)
--------------------- START -----------------------
RED=’\033[0;31m’**
GREEN=’\033[0;32m’**
BLUE=’\033[0;34m’**
BRIGHT=’\033[1m’**
BLINK=’\033[5m’**
BG_YELLOW=’\033[103m’**
NC=’\033[0m’ # No Color, no attributes**
echo β€œThis is ${RED}red${NC}. This is ${GREEN}green${NC}. This is ${BLUE}${BRIGHT}${BLINK}${BG_YELLOW}blue bright blinking on yellow${NC}.”**
--------------------- END -----------------------

Links:

  1. ANSI/VT100 Terminal escape codes: http://www.termsys.demon.co.uk/vtansi.htm
  2. Examples with ANSI/VT100 colors and other text attributes: bash:tip_colors_and_formatting - FLOZz' MISC

This is for simple UI-screens. If UI is more complex, there is also the Ncurses library that does basically the same thing but includes also some more sophisticated UI abstractions, like menus, windows, popup lists etc.

Ingars

4 Likes

Thank you Ingarr.

I have a lot of experimenting to do.

Many thanks.

1 Like