The function calls where somethimes too slow and the terminal timed out
before accepting the entire escape sequence. By constructing the whole
string before sending via printf this problem is avoided.
I originally noticed this issue when using Alacritty on WSL, where
apparently the communication via ConPTY can be a bit slow.