I am trying print the character ch at the cursor position in a 1x6 window. I want the cursor to move to the right if I input 's'/'k' and to the left if I input 'a'/'j'(and wrap around to the beginning/end of the window if the cursor is on the beginning/end position). However, waddch does not print ch at the cursor position. I tried using mvwaddch and change ch from type char to type chtype, and ch still is not shown at the cursor position. What am I missing so that ch is not printed?
chtype ch = 'X';
char ich;
int cols = 6;
int rows = 1;
WINDOW* win = newwin(rows, cols, 1, 1);
int delwin(WINDOW *win);
raw();
int currPos = 0;
initscr();
noecho();
for(int i = 0; i< 6; i++){
ich = getch();
if(ich == 'a' || ich == 'j'){
//printf("\nsddss\n");
//mvwaddch(win, 0,currPos - 1,ch);
wmove(win, rows, currPos - 1);
waddch(win, ch);
currPos--;
}else
if(ich == 's' || ich == 'k'){
//printf("sddss3333\n");
//mvwaddch(win ,0,currPos + 1,ch);
wmove(win, rows, currPos + 1);
waddch(win, ch);
currPos++;
}
wrefresh(win);
}
delwin(win);
endwin();