As far as I know, the only way to go about it would be to create a table which keeps track of the character + foreground colour + background colour for each and every x/y offset on your screen. You dump everything you want to write into that table instead, then when your buffer has been completely "painted", iterate through the whole table and get it onto the actual screen. This is how GopherAtl's buffering system works (as used with his
Wolf3D-type engine).
However, when considering the use of a buffer, I feel the first thing you should ask yourself is whether you
need one. In most cases, you can reduce or eliminate flickering simply by not redrawing the whole screen - unless your program needs (as in,
needs) to change the majority of the display with each update (eg like the example linked above), or frequently redraw arbitrary and complex patterns on the screen (eg windows that were covered by other windows), then there's really no need to do so. For example, my
Tetris clone seldom changes large areas of the screen and so uses no buffering at all.
With all that said, if a buffer
is needed for whatever task you have in mind then I don't think I can find fault with GopherAtl's implementation.