This is quite a specific question, but I couldn't find a forum on ncurses so I thought I might as well ask it here.
I am writing a program using ncurses that needs a function to highlight a line of characters on the screen. I started writing this function that took the x & y coordinates of a character on the screen and the length of characters after that to highlight. Whilst doing this I noticed that if I highlighted the last character in a row (maxX-1 in my example) it highlighted that character (as expected), and if I highlighted just the character before that (maxX-2) it also works. But if I do both, it highlights the whole row/line. Also, if there are characters in those spaces other than the 'space' character it works too, but for my program I need to be able to highlight empty spaces as well.
To highlight I am using inch() to get the character and addch() to print it because I am using some alternate characters that chgat() replaces with normal characters.
If anyone has any ideas why it could be doing this, that would be a great help, since this makes no sense to me and there must be something i'm missing.
int maxX=0, maxY=0;
getmaxyx(stdscr, maxY, maxX);
init_pair(5, 15, 10);
mvaddch(5, maxX-1, inch()); //works as expected
mvaddch(6, maxX-1, inch());
mvaddch(6, maxX-2, inch()); //highlights whole line for some reason? whyyy?
mvaddch(7, maxX-1, inch());
mvaddch(7, maxX-2, 'c'); //works as expected