Lazarus
Free Pascal => Unix => Topic started by: acerm on November 27, 2019, 01:02:06 pm
Title:
Colorizing text in the console
Post by:
acerm
on
November 27, 2019, 01:02:06 pm
Hello! Does anyone know how can I write colored text to the console?
I have a c ++ example that works, but I can't make it work on obj pascal
Code: Pascal
[Select]
[+]
[-]
#include <iostream>
int main
(
)
{
std::cout << "\033[033;31m red text" << std::endl;
return(0);
}
Output:
red text
Obj pascal:
Code: Pascal
[Select]
[+]
[-]
writeln
(
'\033[033;31m red text'
)
;
Output:
\033[033;31m red text
Thanks
Title:
Re: Colorizing text in the console
Post by:
marcov
on
November 27, 2019, 01:24:03 pm
Change the C escapes like \033 to proper Pascal writeln syntax using # ?
Title:
Re: Colorizing text in the console
Post by:
acerm
on
November 27, 2019, 02:45:47 pm
Thanks a lot marcov!
Now is working fine.
Code: Pascal
[Select]
[+]
[-]
writeln
(
#27
'[31mred text'
)
;
Title:
Re: Colorizing text in the console
Post by:
bee
on
November 28, 2019, 04:42:07 am
I've made ansiCRT unit for that purpose. You may take a look at it here (https://gist.github.com/pakLebah/c5e2bbd0b93c863b2122660111db68d1).
Hope it helps. :)
TinyPortal
© 2005-2018