Ejemplo n.º 1
0
    def write(self, char_seq):
        col = 0
        index = 0
        line_feed = False

        for char in char_seq:
            if char == '\n':
                line_feed = True
            col += 1
            if col == self.cols:
                col = 0
                if line_feed:
                    line_feed = False
                    continue

            if line_feed:
                line_feed = False
                blank_index = col
                while blank_index <= self.cols:
                    self.char_buffer[blank_index - 1].char.unicode_char = ' '
                    blank_index += 1
                    index += 1
                col = 0
                continue

            self.char_buffer[index].char.unicode_char = char
            self.char_buffer[index].attributes = LIGHT_WHITE
            index += 1

        write_console_output(self.backbuffer_handle,
                             self.char_buffer,
                             self.size,
                             self.coord,
                             byref(self.rect))
Ejemplo n.º 2
0
    def write(self, char_seq):
        col = 0
        index = 0
        line_feed = False

        for char in char_seq:
            if char == '\n':
                line_feed = True
            col += 1
            if col == self.cols:
                col = 0
                if line_feed:
                    line_feed = False
                    continue

            if line_feed:
                line_feed = False
                blank_index = col
                while blank_index <= self.cols:
                    self.char_buffer[blank_index - 1].char.unicode_char = ' '
                    blank_index += 1
                    index += 1
                col = 0
                continue

            self.char_buffer[index].char.unicode_char = char
            self.char_buffer[index].attributes = LIGHT_WHITE
            index += 1

        write_console_output(self.backbuffer_handle, self.char_buffer,
                             self.size, self.coord, byref(self.rect))
Ejemplo n.º 3
0
 def cls(self):
     for y in range(self.rows):
         for x in range(self.cols):
             i = (y * self.cols) + x
             self.char_buffer[i].char.unicode_char = ' '
     write_console_output(self.backbuffer_handle, self.char_buffer,
                          self.coord, self.size, byref(self.rect))
Ejemplo n.º 4
0
 def cls(self):
     """Clears the current screen buffer.
     """
     for y in range(self._rows):
         for x in range(self._cols):
             i = (y * self._cols) + x
             self._char_buffer[i].char.unicode_char = ' '
     write_console_output(self._framebuffer, self._char_buffer, self._coord,
                          self._size, byref(self._rect))
Ejemplo n.º 5
0
 def cls(self):
     for y in range(self.rows):
         for x in range(self.cols):
             i = (y * self.cols) + x
             self.char_buffer[i].char.unicode_char = ' '
     write_console_output(self.backbuffer_handle,
                          self.char_buffer,
                          self.coord,
                          self.size,
                          byref(self.rect))
Ejemplo n.º 6
0
    def write_output(self, charseq, color=LIGHT_WHITE):
        """Writes character and color attribute data to the frame buffer.

        The data to be written is taken from a correspondingly sized rectangular
        block at a specified location in the source buffer.

        Parameters
        ----------

        charseq: str
            the sequence of characters to be written on the frame buffer

        color: int
            the terminal output color
        """
        col = 0
        x = 0
        crlf = False

        for char in charseq:
            if char == '\n':
                crlf = True
            col += 1
            # the last column has been reached.
            # If there was a carriage return
            # then stop the iteration
            if col == self._cols:
                col = 0
                if crlf:
                    crlf = False
                    continue

            if crlf:
                crlf = False
                space = col
                # keep filling the rectangle with spaces
                # until we reach the last column
                while space <= self._cols:
                    self._char_buffer[space - 1].char.unicode_char = ' '
                    space += 1
                    x += 1
                # reset the column and
                # stop the current iteration
                col = 0
                continue
            self._char_buffer[x].char.unicode_char = char
            self._char_buffer[x].attributes = color

            x += 1
        # write the character attribute data
        # to the screen buffer
        write_console_output(self._framebuffer, self._char_buffer, self._size,
                             self._coord, byref(self._rect))
Ejemplo n.º 7
0
 def cls(self):
     """Clears the current screen buffer.
     """
     for y in range(self._rows):
         for x in range(self._cols):
             i = (y * self._cols) + x
             self._char_buffer[i].char.unicode_char = ' '
     write_console_output(self._framebuffer,
                          self._char_buffer,
                          self._coord,
                          self._size,
                          byref(self._rect))
Ejemplo n.º 8
0
    def write_output(self, charseq, color=LIGHT_WHITE):
        """Writes character and color attribute data to the frame buffer.

        The data to be written is taken from a correspondingly sized rectangular
        block at a specified location in the source buffer.

        Parameters
        ----------

        charseq: str
            the sequence of characters to be written on the frame buffer

        color: int
            the terminal output color
        """

        col = 0
        x = 0
        crlf = False

        if not charseq or len(charseq) <= 0:
            return

        try:
            for char in charseq:
                if char == '\n':
                    crlf = True
                col += 1
                # the last column has been reached.
                # If there was a carriage return
                # then stop the iteration
                if col == self._cols:
                    col = 0
                    if crlf:
                        crlf = False
                        continue

                if crlf:
                    crlf = False
                    space = col
                    # keep filling the rectangle with spaces
                    # until we reach the last column
                    while space <= self._cols:
                        self._char_buffer[space - 1].char.unicode_char = ' '
                        space += 1
                        x += 1
                    # reset the column and
                    # stop the current iteration
                    col = 0
                    continue
                self._char_buffer[x].char.unicode_char = char
                self._char_buffer[x].attributes = color
                x += 1
        except IndexError:
            pass
        # write the character attribute data
        # to the screen buffer
        write_console_output(self._framebuffer,
                             self._char_buffer,
                             self._size,
                             self._coord,
                             byref(self._rect))