I'm studing now and I got this homework / tasks to do:
1) If you press the CTRL + L
key, all numeric symbols should change the color.
2) If you press the CTRL + S
key, you will get the length of the word, left from the cursor.
I found this function int bioskey(int cmd);
So now I can check if the key is pressed, but how to change the color only of numeric symbols, or read words from console to get their length ?
Some of us still remember the MS-DOS (let it rest in peace or pieces...)
if you are really in MS-DOS then you can not expect that the content of the console would be changed in colors for only specific areas. You need to do that your self. The problem is we do not know anything about your project background so we do not know what and how yours stuff is represented,rendered/outputed/inputed etc...
I assume EGA/VGA BIOS text mode is used so you can exploit direct access to the VRAM. So you need to set pointer to the address
B800:0000
and handle it as array where each character on screen has 2 BYTEs. one is color attribute and the other is ASCII code (not sure in which order anymore)...So for already rendered stuff you just:
loop through whole screen
usually
80x25x2
Bytestest each ASCII for alpha numeric value
so ASCII
code >= '0'
andcode<='9'
for numbers or add all the stuff you are considering as alphanumeric likecode>' '
andcode<='9'
.change colors for selected characters
just by changing the attribute byte.
When you put it together for numbers it will look like this:
if it does not work than try swap
scr[a+0]
andscr[a+1]
. If an exception occur then you are not in MS-DOS and you do not have access to VRAM. In that case use DOS-BOX or driver that allows access to memory like dllportio ... For more info see some more or less related QA's:If you got problem with the
CTRL+Key
detection not sure if in-build function in TC++ allowsCTRL
(was too long ago) then you can exploit BIOS or even hook up the keyboard ISR. See the second link where ISR for keyboard handler is there present... You can port it to C++ or google there must be a lot of examples out there especially TP7.0 (which is pascal but easily portable to TC++)