我試圖在利用Curses庫的簡單窗口中實現刪除字符。Curses Library Backspace問題
基本上,窗口得到與邊框下面的代碼創建:
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();
}
}
}
儘管它刪除了字符,但它最終會從邊框中拉出右側的垂直條,因此會在邊框中創建一個洞。我在這裏做錯了什麼,或者是這種情況,我必須在每次刪除後手動插入空格,以便將邊框保留在其初始位置。
感謝您的任何幫助!
謝謝,我會盡力實施,從現在回來後的結果。 –