The question is: how to make colors of selected-cells on a console window look like some reversed version (e.g., foreground and background switching) of the unselected colors.
This behavior is built into the console window (or more generally, a terminal). There is no escape sequence or other documented feature of console windows which can do this.
In the more general sense, this aspect is different on various terminals. xterm for example can:
- exchange foreground and background colors, or
- use specific colors for the selected text.
xterm does this by mapping between different items in its color table.
Some other terminal may implement the color change by XOR'ing the color value, mapping 0 to 255 and 255 to 0 (white/black). This is very simple to implement. However, for colors other than white and black, it produces an effect like that shown in your picture.