given the next console:
import os
import tty
import termios
from sys import stdin
class Console(object):
def __enter__(self):
self.old_settings = termios.tcgetattr(stdin)
self.buffer = []
return self
def __exit__(self, type, value, traceback):
termios.tcsetattr(stdin, termios.TCSADRAIN, self.old_settings)
...
def dimensions(self):
dim = os.popen('stty size', 'r').read().split()
return int(dim[1]), int(dim[0])
def write(self, inp):
if isinstance(inp, basestring):
inp = inp.splitlines(False)
if len(inp) == 0:
self.buffer.append("")
else:
self.buffer.extend(inp)
def printBuffer(self):
self.clear()
print "\n".join(self.buffer)
self.buffer = []
Now I have to get some letters in that buffer, but letters aren't given in the right order and some places are going to be empty. For instance: I want to have a "w" on the screen in the 12th column and the 14th row and then some other "w"'s on other places and a "b" over there etc...(the console is big enough to handle this). How could I implement this? I really don't have a clue how to solve this problem.
Another question that bothers me is how to call this exit-constructor, what kinda parameters should be given?
sincerely, a really inexperienced programmer.