Get the latest tech news
How terminal works. Part 1: Xterm, user input (2021)
Hi there. I am going to post here thing about my work or my technical hobbies. This means c++, java, haskell, python, linux etc.
In your daily life, if you’ll get stuck with misbehaving command-line tools, you can attach to a running process and observe what your terminal is writing into filehandles and what your shell reads. We will discuss ANSI escape sequences and ASCII control characters soon, for now, we can confirm that using strace helps to observe what xterm is actually doing: it sends qwe\ESC[D\ESC[C and receives qwe\b\ESC[C. The big limitation of such an approach is that reading sequences like\33[D\33[C\n require a certain patience and might be quite hard if applications output a lot of data ¯_(ツ)_/¯.
Or read this on Hacker News