如果光标在按下b(删除)键时位于行首,我想将光标移到上一行。 将光标移动到ncurses中的上一行
void processKey()
{
char ch = getch();
char *check = unctrl(ch);
int safe = (check != 0 && strlen(check) == 1);
int Trow,Tcol; //Terminal's full rows and columns.
getmaxyx(stdscr,Trow,Tcol);
int row,col; //Current row and columns.
getyx(stdscr,row,col);
switch(ch)
{
case 0x11: //Ctrl + Q
closee();
break;
case 'b': //pressing "b" deletes the previous character.
if(col==0)
{
//This should move the cursor to the previous line. But that doesn't work.
move(row-1,Tcol);
addstr("\b \b");
refresh();
break;
}
else
{
addstr("\b \b");
break;
}
default:
if(safe)
{
addch(ch);
}
}
}
我想将光标移动到上一行。但是这并没有发生,光标只停留在当前位置。我试图通过使用mvcur()来做到这一点,但也显示了相同的结果。 请告诉我什么是正确的方法来完成这?
仅供参考:getch()返回一个“int”,而不是“char”。 – TonyB