OS X: c++ xcode ncurses 调整终端大小
OS X: c++ xcode ncurses resize terminal
有了 ncurses.h
,我可以在 OS X 中创建一个 c++ 项目。
这里有一个例子:
int main(int argc, char *argv[])
{
// resizeterm(50, 50);
initscr();
// resizeterm(50, 50);
move(10, 10);
printw("%c", 'x');
return 0;
}
我在终端编译:
g++ -std=c++11 main.cpp -o main.o
g++ -std=c++11 -lncurses main.o
然后我得到一个可执行文件:a.out
.
现在,如果我在终端中输入 ./a.out
,终端将在位置 (10, 10) 处打印 x
。
现在我想改变终端的大小。这意味着当我 运行 ./a.out
时,我可以立即获得一个具有我设置大小的终端。 Google 给了我一个函数:resizeterm(int, int)
。但是没用。
当我打开终端时,它的大小默认为 80 * 24。
然后我执行 ./a.out
,终端的大小没有改变。总是 80 * 24.
ncurses responds to window-resizing events, i.e., SIGWINCH
. It does not resize the terminal (see manual page for resizeterm
).
xterm and some other terminal emulators respond to an escape sequence which tells it to resize. You can exercise that with the utility program resize
,例如,
resize -s 40 80
制作 40 行 80 列。在 OSX 上,Terminal.app
响应此转义序列。 iTerm 2
没有。
有了 ncurses.h
,我可以在 OS X 中创建一个 c++ 项目。
这里有一个例子:
int main(int argc, char *argv[])
{
// resizeterm(50, 50);
initscr();
// resizeterm(50, 50);
move(10, 10);
printw("%c", 'x');
return 0;
}
我在终端编译:
g++ -std=c++11 main.cpp -o main.o
g++ -std=c++11 -lncurses main.o
然后我得到一个可执行文件:a.out
.
现在,如果我在终端中输入 ./a.out
,终端将在位置 (10, 10) 处打印 x
。
现在我想改变终端的大小。这意味着当我 运行 ./a.out
时,我可以立即获得一个具有我设置大小的终端。 Google 给了我一个函数:resizeterm(int, int)
。但是没用。
当我打开终端时,它的大小默认为 80 * 24。
然后我执行 ./a.out
,终端的大小没有改变。总是 80 * 24.
ncurses responds to window-resizing events, i.e., SIGWINCH
. It does not resize the terminal (see manual page for resizeterm
).
xterm and some other terminal emulators respond to an escape sequence which tells it to resize. You can exercise that with the utility program resize
,例如,
resize -s 40 80
制作 40 行 80 列。在 OSX 上,Terminal.app
响应此转义序列。 iTerm 2
没有。