fckstckvrflw fckstckvrflw - 6 months ago 63
Pascal Question

Colors in windows console

I want to display colors in "simple program" turbo pascal application. I do not want to import anything, please do not put answers like "you must use this library or that library etc..". I know that when you print

to windows console, everything which comes after it will be yellow. For example, in node.js
will display yellow text in the console no matter what console default font setting was.

Pascal is using windows console for stdio, so it should be possible to achieve the same result printing the magic code. I wrote a function to do that:

function _(a: integer): boolean;
write(chr(27), '[', a, 'm');
_ := true;

and I call it like this:

write('wth this doesnt work')

Unfortunatelly, it prints this. Why? How to do it properly?


node.js is providing you with behavior that windows console does not. It's interpreting the \xb1[33m as being a color change command. Pascal does not do this.