I have designed my own version of cout called gcout that works like cout but in graphics mode. But I don't know the idea behind how to make a caret (or a cursor that blinks).

Does this caret thing have to do something with threading in turbo c++? If so how to achieve such a task?

I know one way, in which u can achieve this
In graphics mode:
draw a horizontal line (about 5 pixels).
This will be ur cursor.
Now to blink it,
save this image (using getimage())
then after some time ( use a counter ) , remove that image from its current position (use putimage() with XOR_PUT)
repeat this process.
U may need to adjust the counter.
then check various key hits,
if TAB is hit, take ur cursor, ahead by some pixels,
if ENTER is hit, take ur cursor to next line
etc....

Hey thanx very much for your advice. It was valuable.

What if you were to design your own version of a 2d textbox?

Your solution makes the cursor to blink; okay that part is fine. But what if you wanted the cursor to behave in an event oriented fashion:

  1. If no key is pressed the cursour should blink.
  2. Now if a keyboard character is pressed, the blinking should cease.
  3. The the keyboard character should be printed where the cursor was previously displayed, and the cursor position should be moved accordingly.
  4. Again if there is no keyboard input the caret should blink normally.

When I wondered how to achieve this, I thought that the blinking of the caret should be actually managed by a separate thread. This thread should sleep when we hit a key; the caret should not be visible meanwhile. Only after the character is printed should the cursor resume blinking...

Which was why I had asked you about threading...

While you are waiting for a key, call you cursor blink function. When a key is pressed, stop calling it. Process the key and go back to your wait loop.

While you are waiting for a key, call you cursor blink function. When a key is pressed, stop calling it. Process the key and go back to your wait loop.

its correct
I hav already developed a text editor in graphic mode

Keep blinking ur cursor...
when any key is pressed, turn OFF the cursor, then check the key
and perform the required operation.
If some character key is pressed, move some pixel ahead and keep blinking...

This article has been dead for over six months. Start a new discussion instead.