def set_window_text(self, new_text: str, *, line_range: Optional[Tuple[int, int]] = None) -> None:
        """Replace the text in the current display window with a new string."""
        text = self.text.split("\n")
        if line_range is not None:
            start, stop = line_range
        else:
            start, stop = self.line_range

        # Handle empty replacement text (deletion case)
        new_lines = new_text.split("\n") if new_text else []
        text[start : stop + 1] = new_lines
        self.text = "\n".join(text)
Replace the text in the current display window with a new string.
tools/windowed/lib/windowed_file.py