if s == ':q':
    break
if len(lines) > max_lines:
    lines = lines[1:]
stdscr.clear()
for i, line in enumerate(lines):
    stdscr.addstr(i, 0, line)
stdscr.addstr(len(lines), 0, s)
lines.append(s)
stdscr.refresh()
wrapper(main)
Keep stdin line at top or bottom of terminal screen