【发布时间】:2010-12-21 04:22:58
【问题描述】:
如何找到 ncurses 应用程序的终端宽度和高度?
【问题讨论】:
-
@DylanJ,无需将答案放在问题中,尤其是在您接受答案后。
如何找到 ncurses 应用程序的终端宽度和高度?
【问题讨论】:
【讨论】:
【讨论】:
initscr() 将清除屏幕。有什么办法可以获取终端大小而不清屏?
y & x 不是指针,因此该函数不会向它们复制任何内容。来自mkssoftware.com:“getbegyx() and getmaxyx() macros store the current beginning coordinates and size of the specified window.”
y 和 x 不需要是指针。宏直接作用于给定的变量,不需要复制赋值或指针。
我正在使用此代码:
struct winsize size;
if (ioctl(0, TIOCGWINSZ, (char *) &size) < 0)
printf("TIOCGWINSZ error");
printf("%d rows, %d columns\n", size.ws_row, size.ws_col);
【讨论】:
使用SCR_H 和SCR_W 怎么样?
【讨论】: