1

So I have this minimal program in NIM which just enters alternate screen mode, prints a few numbers and exits the alternate screen mode.

import os

echo "\e[?1049h"
echo "\nAlternate screen works but scrolling up is allowed, no keys sent."
for i in 0..4:
    echo $i
    sleep(1000)

echo "\e[?1049l"

My problem is that scrolling in alternate screen mode is still enabled, unlike with vim for example. I have checked my settings and tried unchecking to see that it then correctly behaves with vim as it does with my program and it does: send arrow keys instead of scrolling while in alternate screen mode So it seems as though vim is sending some ansi escape sequences that my program does not, i.e. is there something I need to send to tell the terminal I want it to send arrow keys instead of scrolling the screen? Since the escape sequences I sent should (according to other stackoverflow answers) put me into alternate screen mode (and it does basically) the option in Mac OS Terminal as seen in the picture should take effect but for some reason it doesn't while it works with vim, which leaves me quite clueless as to what kind of black magic is going on here.

Any help is greatly appreciated :)

For reference:

> echo $TERM
xterm-256color
whiterock
  • 190
  • 2
  • 11

0 Answers0