code: def write_to_screen(self, cli, screen, mouse_handlers, write_position):
          
          if not self.children:
              return
  
          sizes = self._divide_widths(cli, write_position.width)
  
          if self.report_dimensions_callback:
              self.report_dimensions_callback(cli, sizes)
  
          # If there is not enough space.
          if sizes is None:
              self.window_too_small.write_to_screen(
                  cli, screen, mouse_handlers, write_position)
              return
  
          # Calculate heights, take the largest possible, but not larger than write_position.extended_height.
          heights = [child.preferred_height(cli, width, write_position.extended_height).preferred
                     for width, child in zip(sizes, self.children)]
          height = max(write_position.height, min(write_position.extended_height, max(heights)))
  
          # Draw child panes.
          ypos = write_position.ypos
          xpos = write_position.xpos
  
          for s, c in zip(sizes, self.children):
              c.write_to_screen(cli, screen, mouse_handlers, WritePosition(xpos, ypos, s, height))
              xpos += s
docs: Render the prompt to a `Screen` instance.
  
          :param screen: The :class:`~prompt_toolkit.layout.screen.Screen` class
              to which the output has to be written.