def print_at()

in ebcli/bundled/asciimatics/screen.py [0:0]


    def print_at(self, text, x, y, colour=7, attr=0, bg=0, transparent=False):
        """
        Print the text at the specified location using the specified colour and attributes.

        :param text: The (single line) text to be printed.
        :param x: The column (x coord) for the start of the text.
        :param y: The line (y coord) for the start of the text.
        :param colour: The colour of the text to be displayed.
        :param attr: The cell attribute of the text to be displayed.
        :param bg: The background colour of the text to be displayed.
        :param transparent: Whether to print spaces or not, thus giving a
            transparent effect.

        The colours and attributes are the COLOUR_xxx and A_yyy constants
        defined in the Screen class.
        """
        # Trim text to the buffer vertically.  Don't trim horizontally as we don't know whether any
        # of these characters are dual-width yet.  Handle it on the fly below...
        if y < 0 or y >= self._buffer_height or x > self.width:
            return

        if len(text) > 0:
            j = 0
            for i, c in enumerate(text):
                # Handle under-run and overrun of double-width glyphs now.
                #
                # Note that wcwidth uses significant resources, so only call when we have a
                # unicode aware application.  The rest of the time assume ASCII.
                width = wcwidth(c) if self._unicode_aware else 1
                if x + i + j < 0:
                    x += (width - 1)
                    continue
                if x + i + j + width > self.width:
                    return

                # Now handle the update.
                if c != " " or not transparent:
                    # Fix up orphaned double-width glyphs that we've just bisected.
                    if x + i + j - 1 >= 0 and self._buffer.get(x + i + j - 1, y)[4] == 2:
                        self._buffer.set(x + i + j - 1, y, (ord("x"), 0, 0, 0, 1))

                    self._buffer.set(x + i + j, y, (ord(c), colour, attr, bg, width))
                    if width == 2:
                        j += 1
                        if x + i + j < self.width:
                            self._buffer.set(x + i + j, y, (ord(c), colour, attr, bg, 0))

                    # Now fix up any glyphs we may have bisected the other way.
                    if x + i + j + 1 < self.width and self._buffer.get(x + i + j + 1, y)[4] == 0:
                        self._buffer.set(x + i + j + 1, y, (ord("x"), 0, 0, 0, 1))