Skip to main content
GameDev.net gamedev.net
🔒 Locked

Console Buffer

Started by Luke Philpot Jan 3, 2004 at 11:31 PM 6 replies 1.3k views
SiCrane
SiCrane
I can think of at least four things off the top of my head that you could call a console buffer: a display text buffer, a display pixel buffer, an input text buffer and a command history buffer.

So I guess my question would be, which kind of buffer are you thinking about?
SiCrane
SiCrane
No, actually that sounds like the display text buffer. For that I would use a std::deque<std::pair<int, std::string> > to store the displayed lines. The int would contain the formatting information for the line (if it was input or output from the command line, a chat message, an in game diagnotistic, etc.) and the string would contain the actual line itself. Whenever something is added to the display, it would be pushed on the back, and display would be done front to back in the deque. When the buffer gets full, it's popped from the front.

edit: !#@# smile code

[edited by - SiCrane on January 4, 2004 1:01:43 AM]
kumikana
kumikana
I basicly have a text-buffer. std::vector< std::string >
And I store hundred lines of the console in there.

That deque / pair idea was pretty neat. I might implent that, because that way you could have the styles or colors stored there too pretty easily.
jamessharpe
jamessharpe
What would be even better is to store a simple class lets call it Text. Then this class can contain your string and also the formating and your not limited in any way if you want to change your implementation at a later date.

James

Topic Locked

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

Sign in to reply to this topic.