def replace_in_range(self, rng, s, relative_to_x_modifiable=False, set_drawend=False):
        """
        Replace the buffer content in the given range. This method should
        ONLY be called from the UI delegation side, i.e. NOT running
        scripts.
        :param (int, int) rng: Range of buffer to be replaced
        :param str s: String to be inserted (to be converted to Char with default properties).
        :param bool relative_to_x_modifiable: If True, the range is relative to the x_modifiable
        :param bool set_drawend: If True, the x_drawend will be set to the end of this replacement.
        :return:
        """
        if rng is None:
            rng = (len(self._buffer), len(self._buffer))

        elif relative_to_x_modifiable:  # Convert to absolute location if necessary
            rng = rng[0] + self.x_modifiable, rng[1] + self.x_modifiable

        # Update the right bound if necessary
        if rng[0] < self.intact_right_bound:
            self.intact_right_bound = rng[0]

        rotate_n = max(len(self._buffer) - rng[1], 0)
        self._buffer.rotate(rotate_n)  # rotate buffer first so deletion is possible
        try:
            if rng[0] != rng[1]:  # delete chars if necessary
                self._pop_chars(rng[1] - rng[0])
            # The newly inserted chars are always of default properties
            self._buffer.extend(DEFAULT_CHAR._replace(data=c) for c in s)

        finally:
            self._buffer.rotate(-rotate_n)

        # Update cursor to the end of this replacement
        self.cursor_x = rng[0] + len(s)

        # Normally the draw end is not set
        if set_drawend:
            self.x_drawend = self.cursor_xs

        nlf = s.count('\n')
        if nlf > 0:  # ensure max number of lines is kept
            self.nlines += nlf
            self._ensure_nlines_max()

        Replace the buffer content in the given range. This method should
        ONLY be called from the UI delegation side, i.e. NOT running
        scripts.
        :param (int, int) rng: Range of buffer to be replaced
        :param str s: String to be inserted (to be converted to Char with default properties).
        :param bool relative_to_x_modifiable: If True, the range is relative to the x_modifiable
        :param bool set_drawend: If True, the x_drawend will be set to the end of this replacement.
        :return:
        
system/shscreens.py