@classmethod
def addnstr(cls, s, x=None, y=None, n=None, attr=None):
    """
        write at most n characters at specified position or cursor.

        :param s: string to write
        :param x: optional x value
        :param y: optional y value
        :param n: max number of characters
        :param attr: optional attributes
        """
    x, y = cls._fix_xy(x, y)
    attr = cls._fix_attr(attr)
    n = cls.WIDTH if n is None else n
    if attr is None:
        return cls.WINDOW.addnstr(y, x, s, n)
    else:
        return cls.WINDOW.addnstr(y, x, s, n, attr)
