Undescribed Horrific Abuse, One Victim & Survivor of Many gmkarl at gmail.com
Sun Nov 20 11:19:38 PST 2022

Focusing on a dot can seem non-simple when you are computer code.

I made this static `term` class, with methods `clear`, `write_at`,
`where`, and `size`:

class term:
    import curses
    import sys, tty, termios
    _cup = curses.tigetstr('cup')
    _clear = curses.tigetstr('clear').decode()
    _csi = '\x1b['
    _dsr_cpr = _csi + '6n'
    def clear(cls):
        x, y = cls.where()
        print(cls._clear, end='', flush=True)
        cls.write_at(x, y)
    def write_at(cls, x, y, *text):
        print(cls.curses.tparm(cls._cup, y, x).decode(), end='')
        print(*text, end='', flush=True)
    def size(cls):
        return cls.curses.tigetnum('cols'), cls.curses.tigetnum('rows')
    def where(cls):
        print(cls._dsr_cpr, end='', flush=True)
        _, row, col = cls._read_through(cls.sys.stdin, cls._csi, ';', 'R')
        return int(col) - 1, int(row) - 1

    def _read_through(cls, file, *delimiters, include=False):
        fileno = file.fileno()
        tattr = cls.termios.tcgetattr(fileno)
        cls.tty.setcbreak(fileno, cls.termios.TCSANOW)
            datas = []
            for delimiter in delimiters:
                data = type(delimiter)()
                while not data.endswith(delimiter):
                    data += file.read(1)
                if not include:
                    data = data[:-len(delimiter)]
            if len(datas) == 1:
                return datas[0]
                return datas
            cls.termios.tcsetattr(fileno, cls.termios.TCSANOW, tattr)

Then I can make this small environment class, and have it label a
period as I imagined:
import time
class environment:
    def make_period_at(self, x, y):
        term.write_at(x, y, '.')
    def label_as_period(self, x, y):
        term.write_at(x + 2, y, '<- this is a period')
    def wait(self, seconds):

environment = environment()
x, y = term.where()
environment.make_period_at(x, y)

environment.label_as_period(x, y)

More information about the cypherpunks mailing list