Flashing Text in Linux Terminal

This is a discussion on Flashing Text in Linux Terminal within the Linux Programming forums, part of the Platform Specific Boards category; I know its not portable either in terms of OS or CPU speed, but I want to learn some
basic ...

Flashing Text in Linux Terminal

I know its not portable either in terms of OS or CPU speed, but I want to learn some
basic graphic functionality in Windows and Linux before moving on to consider cross
-platform API's. So I'm really just interested in how I can create flashing text in
the Linux terminal window using escape codes.

In Windows the move from static to dynamic was trivial and I ended up creating a
naff flashing "Merry Xmas" sign, which I would like to replicate in Linux.

In Windows all I really needed to do was print a bright character,pause then
print its dimmer companion,pause then keep looping.

In Linux that just doesn't work,I get weird synchronisation effects and white versions
of the characters appearing instead of the coloured ones that are supposed to etc.

The only half-clue garnered from the internet was a small sentence that said "blink"
doesn't work in a terminal emulator. Which I understand is the type of terminal I am
using in a GUI Linux like the Puppy Linux I'm using.

Well I'm not using the blink attribute but it makes me think that maybe it just can't
cope with this kind of graphic switching?

The code here just prints 2 of the characters, and because I've got a white terminal
window background I first create a black background for the minimised window.

I might have missed something but I also tried gnome and there were still
synchronisation/code problems.

Part of the reason for doing the program was to use threads in Linux so I went
ahead and created a 2nd thread in the program anyway, expecting a complete mess,
only to find all the previous problems magically disappeared!
(In rxvt and gnome.)

Its also possible to have synchronised flashing text only by creating a 2nd thread
that just prints a character the same colour as the background at screen position
(0,0) for example.

Portable doesn't mean recommended. Using a delay function such as this will result in no other process being able to use the CPU during the "sleep" period....which completely defeats the purpose of a process "sleeping".

I would recommend using the delay function provided by the platform (usleep() probably good choice in this case)

Portable doesn't mean recommended. Using a delay function such as this will result in no other process being able to use the CPU during the "sleep" period....which completely defeats the purpose of a process "sleeping".

I would recommend using the delay function provided by the platform (usleep() probably good choice in this case)

Just saw this,

I would have thought whether to use a delay or a sleep would have been a design issue not a programming issue in this instance. i.e do I want the second thread to have free reign or do I want to slow it down a bit.

I was intentionally using CPU intensive routines, which can be seen from my first post as well.