def erase_in_line(self, mode=0):
        """
        Erase a line with different mode. Note the newline character is NOT deleted.
        :param mode:
        :return:
        """
        # Calculate the range for erase
        if mode == 0:  # erase from cursor to end of line, including cursor
            rng = [self.cursor_xs, self._find_nth_nl(default=self.text_length)]
            try:  # do not include the newline character
                if self._buffer[rng[0]] == '\n':
                    rng[0] += 1
            except IndexError:
                pass

        elif mode == 1:  # erase form beginning of line to cursor, including cursor
            rng = [self._rfind_nth_nl(default=-1) + 1, min(self.cursor_xs + 1, self.text_length)]
            try:
                if self._buffer[rng[1] - 1] == '\n':
                    rng[1] -= 1
            except IndexError:
                pass

        else:  # mode == 2:  # erase the complete line
            rng = [self._rfind_nth_nl(default=-1) + 1, self._find_nth_nl(default=self.text_length)]

        # fast fail when there is nothing to erase
        if rng[0] >= rng[1]:
            return

        # Erase characters in the range
        with self.buffer_rotate(self.text_length - rng[1]):
            for _ in xrange(*rng):
                self._buffer.pop()
            self._buffer.extend(take(rng[1] - rng[0], DEFAULT_LINE))
            self.x_drawend = rng[0]
            # update the intact right bound
            if self.x_drawend < self.intact_right_bound:
                self.intact_right_bound = self.x_drawend

        Erase a line with different mode. Note the newline character is NOT deleted.
        :param mode:
        :return:
        
system/shscreens.py