Curses 库退格问题

标签 c curses

我正在尝试在一个使用 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/

相关文章:

python - python 诅咒中的进度条

c++ - 我的代码有什么问题? (pdcurses/getmaxyx)

c++ - 如何使用 Ncurses 打印 (☞゚ヮ゚)☞?

c - 我可以将哪些端口用于通讯应用程序

c - Obj-C 中的异常处理

编译器 gcc :error; no such file or directory

c指针段错误

Python Curses 处理窗口(终端)调整大小

c - 如何在 Windows 上安装 CUnit

c - ncurses 不解释键