我正在尝试在一个使用 Curses 库的简单窗口中实现删除字符。
基本上,窗口是使用以下边框代码创建的:
box(local_win, 0 , 0); // Set the border of the window to the default border style.
稍后当我继续处理退格时,我使用以下代码来完成:
initscr();
cbreak();
keypad(window, TRUE);
int ch; // The character pressed by the user.
while((ch = wgetch(window)) != EOF)
{
switch(ch)
{
case KEY_BACKSPACE: // Handle the backspace.
{
wdelch(window); // Delete the character at the position in the window.
wrefresh(window);
refresh();
}
}
}
虽然它确实删除了字符,但它最终将右侧的垂直条从边框中拉出来,因此在边框中创建了一个洞。我在这里做错了什么,还是在这种情况下,我必须在每次删除后手动插入一个空格,以将边框保持在其初始位置。
感谢您对此的任何帮助!
最佳答案
是的,您需要在竖线之前重新插入一个空格,或者(我不确定这是否可能)设置一个小于终端全宽的滚动区域。
关于Curses 库退格问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13617967/