On Sat, 1 Dec 2012, Akshay Arora wrote:
# Oh nice, @skeezix could you post the code/the approach you took? Emulating the whole terminal sounds interesting.
# I would be very interested in looking at how you went about it.
Oh, I didn't get very far.. just starting building various options
and actually forking a shell and handling its basic stdio is only a few
lines of code.. but I didn't bother trying to do the terminal emulation;
for what I was doing, I didn't need to bother (but have done it before in
other projects.) ie: I just wanted to write keyb input out to its stdin,
and capture its stdout and display on something. I've already got an
enormous canvas 'thing' going on, so this just fed into it.
Its not practical to share due to the convoluted canvas stuff its
doing (and I'm keeping this particular project closed at least for now
I'ma fraid). (Its a game, and has a vaguely terminal like thing as just
one of the widgets on the display, but the whole display is tied
together.)
What I was doing was a cell (rectangle with texture) per character
though, to be most authentic; pretty easy to implement. You could use na
Array, but I just used a list (rows) of list (column) and had a Rectangle
for each cell in there. Add a texture for the character, and good to go.
(I pre-created the character-set to texture mapping, so as to re-use
textures as needed without recreating them for each cell.. that woudl have
been wasteful.)