カーソルが行の先頭にある場合は、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()を使ってこれをやろうとしましたが、同じ結果が表示されます。 これを達成するための適切な方法は何ですか?使用する
FYI:getch()は「char」ではなく「int」を返します。 – TonyB