Skip to main content
gamedev.net
🔒 Locked

Text cursor

Started by Endar Jan 11, 2005 at 12:43 AM 1 replies 350+ views
Original Post
Endar
Endar
I'm using the gamedev article on writing a quake-style console to..well, write one. I've done quite a bit, but I'm at the point where everything is displaying nicely and I'd like to add a cursor to the screen so you can move left and right to different letters and delete which ever one you are at. I know that in C, when using 'printf' there was a specifier that would allow you to highlight a specific character. Is there a way of doing this with a string object or can anyone think of another way of adding a cursor?
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
Nice Coder
Nice Coder
You simply find the spot where the curser should be, part the string there, shove a "|" in there, and join the strings on the two sides!.

You then blink it, by swapping that string, for the origional string, every so often.

From,
Nice coder
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
Erzengeldeslichtes
Erzengeldeslichtes
Quote:
Original post by Nice Coder
You simply find the spot where the curser should be, part the string there, shove a "|" in there, and join the strings on the two sides!.

You then blink it, by swapping that string, for the origional string, every so often.

From,
Nice coder


This isn't the best solution, because then you get:
Text H|ereText Here

the better solution is to simply draw a line between the two. Or you could draw the string on the left, draw the highlighted character underlined, and draw the text on the right. You might have to draw an underscore character when a space is highlighted or at the end of the text.

Also, just FYI, to get the proper blinking time, dependant upon the user's settings in Windows, use: GetCaretBlinkTime() from the Windows API. If you're using Linux or MacOS or something else, I don't know how.

[Edited by - Erzengeldeslichtes on January 11, 2005 10:32:46 PM]
----Erzengel des Lichtes光の大天使Archangel of LightEverything has a use. You must know that use, and when to properly use the effects.♀≈♂?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.