Resize terminal and scrolling problem with ncurses

后端 未结 3 2076
[愿得一人]
[愿得一人] 2020-12-10 07:00

I\'m programming in C using ncurses libraries (it\'s the first time) and I\'ve two problems. I\'m on ubuntu with the default terminal (gnome terminal).

1) I need to

3条回答
  •  醉酒成梦
    2020-12-10 07:17

    1. You can't resize the terminal window from ncurses. The functions you mention resize the part of the terminal window that is painted on by curses. The idea is you catch the SIGWINCH signal and call resizeterm in the handler when the user resizes the window from outside the application (using the mouse, probably).

    2. This is intended behavior, though poorly documented in ncurses and in the Unix standard/POSIX. NetBSD's curses docs state it explicitly:

      If n is positive then stdscr is scrolled up. n lines are lost from the top of stdscr and n blank lines are inserted at the bottom. If n is negative then stdscr is scrolled down. n blank lines are inserted at the top of stdscr and n lines are lost from the bottom.

      So you'll have to manually save input and reprint it when scrolling.

提交回复
热议问题