You should look into controlling the buffer.

but i'm not particularly sure on how to implement it. just an idea, to one of the directions you can take.