【发布时间】:2020-07-22 03:36:36
【问题描述】:
我有一个简单的程序,它有一个主窗口和一个底部的小窗口(没有线条,这只是为了让您可以看到两个窗口:
+------------------+
| |
| |
| |
+------------------+
| |
+------------------+
我希望底部区域是你可以输入的地方,这是我的源代码:
#include <termios.h>
#include <bits/stdc++.h>
#include <ncurses.h>
int main()
{
int scrx;
int scry;
initscr();
cbreak();
noecho();
clear();
raw();
getmaxyx(stdscr, scrx, scry);
WINDOW* input = newwin(1, scrx, scry, 0);
std::string cmdbuf;
while(true)
{
int newx;
int newy;
getmaxyx(stdscr, newx, newy);
if(newx != scrx || newy != scry)
{
// do stuff;
}
char c = wgetch(input);
cmdbuf.push_back(c);
werase(input);
mvwprintw(input, 0, 0, cmdbuf.c_str());
refresh();
wrefresh(input);
}
}
但是,它似乎没有打印任何内容,只需移动我的光标(它会在屏幕中途被吸走)。如何才能使文本真正被打印并且我的光标实际上在全屏上移动?
【问题讨论】:
-
你是在 while 循环中擦除而不是在它之前。你实际上并没有使用 newx & newy。看看以下内容:www6.uniovi.es/cscene/CS3/CS3-08.html
-
@Geoff 我已经尝试评论 werase 行,它似乎没有帮助
-
并且没有使用newx & newy...
-
@Geoff 是的,它们没有被使用,但这仅适用于调整窗口大小时(在我的测试中从未发生过)