parameters: (
          self,
          screen: Screen,
          mouse_handlers: MouseHandlers,
          write_position: WritePosition,
          parent_style: str,
          erase_bg: bool,
          z_index: Optional[int],
      )
docstring: Render scrollable pane content.
  
          This works by rendering on an off-screen canvas, and copying over the
          visible region.
docstring_summary: Render scrollable pane content.
docstring_tokens: Render scrollable pane content .
function: def write_to_screen(
          self,
          screen: Screen,
          mouse_handlers: MouseHandlers,
          write_position: WritePosition,
          parent_style: str,
          erase_bg: bool,
          z_index: Optional[int],
      ) -> None:
          """
          Render scrollable pane content.
  
          This works by rendering on an off-screen canvas, and copying over the
          visible region.
          """
          show_scrollbar = self.show_scrollbar()
  
          if show_scrollbar:
              virtual_width = write_position.width - 1
          else:
              virtual_width = write_position.width
  
          # Compute preferred height again.
          virtual_height = self.content.preferred_height(
              virtual_width, self.max_available_height
          ).preferred
  
          # Ensure virtual height is at least the available height.
          virtual_height = max(virtual_height, write_position.height)
          virtual_height = min(virtual_height, self.max_available_height)
  
          # First, write the content to a virtual screen, then copy over the
          # visible part to the real screen.
          temp_screen = Screen(default_char=Char(char=" ", style=parent_style))
          temp_write_position = WritePosition(
              xpos=0, ypos=0, width=virtual_width, height=virtual_height
          )
  
          temp_mouse_handlers = MouseHandlers()
  
          self.content.write_to_screen(
              temp_screen,
              temp_mouse_handlers,
              temp_write_position,
              parent_style,
              erase_bg,
              z_index,
          )
          temp_screen.draw_all_floats()
  
          # If anything in the virtual screen is focused, move vertical scroll to
          from prompt_toolkit.application import get_app
  
          focused_window = get_app().layout.current_window
  
          try:
              visible_win_write_pos = temp_screen.visible_windows_to_write_positions[
                  focused_window
              ]
          except KeyError:
              pass  # No window focused here. Don't scroll.
          else:
              # Make sure this window is visible.
              self._make_window_visible(
                  write_position.height,
                  virtual_height,
                  visible_win_write_pos,
                  temp_screen.cursor_positions.get(focused_window),
              )
  
          # Copy over virtual screen and zero width escapes to real screen.
          self._copy_over_screen(screen, temp_screen, write_position, virtual_width)
  
          # Copy over mouse handlers.
          self._copy_over_mouse_handlers(
              mouse_handlers, temp_mouse_handlers, write_position, virtual_width
          )
  
          # Set screen.width/height.
          ypos = write_position.ypos
          xpos = write_position.xpos
  
          screen.width = max(screen.width, xpos + virtual_width)
          screen.height = max(screen.height, ypos + write_position.height)
  
          # Copy over window write positions.
          self._copy_over_write_positions(screen, temp_screen, write_position)
  
          if temp_screen.show_cursor:
              screen.show_cursor = True
  
          # Copy over cursor positions, if they are visible.
          for window, point in temp_screen.cursor_positions.items():
              if (
                  0 <= point.x < write_position.width
                  and self.vertical_scroll
                  <= point.y
                  < write_position.height + self.vertical_scroll
              ):
                  screen.cursor_positions[window] = Point(
                      x=point.x + xpos, y=point.y + ypos - self.vertical_scroll
                  )
  
          # Copy over menu positions, but clip them to the visible area.
          for window, point in temp_screen.menu_positions.items():
              screen.menu_positions[window] = self._clip_point_to_visible_area(
                  Point(x=point.x + xpos, y=point.y + ypos - self.vertical_scroll),
                  write_position,
              )
  
          # Draw scrollbar.
          if show_scrollbar:
              self._draw_scrollbar(
                  write_position,
                  virtual_height,
                  screen,
              )
function_tokens: def write_to_screen ( self , screen : Screen , mouse_handlers : MouseHandlers , write_position : WritePosition , parent_style : str , erase_bg : bool , z_index : Optional [ int ] , ) -> None : show_scrollbar = self . show_scrollbar ( ) if show_scrollbar : virtual_width = write_position . width - 1 else : virtual_width = write_position . width # Compute preferred height again. virtual_height = self . content . preferred_height ( virtual_width , self . max_available_height ) . preferred # Ensure virtual height is at least the available height. virtual_height = max ( virtual_height , write_position . height ) virtual_height = min ( virtual_height , self . max_available_height ) # First, write the content to a virtual screen, then copy over the # visible part to the real screen. temp_screen = Screen ( default_char = Char ( char = " " , style = parent_style ) ) temp_write_position = WritePosition ( xpos = 0 , ypos = 0 , width = virtual_width , height = virtual_height ) temp_mouse_handlers = MouseHandlers ( ) self . content . write_to_screen ( temp_screen , temp_mouse_handlers , temp_write_position , parent_style , erase_bg , z_index , ) temp_screen . draw_all_floats ( ) # If anything in the virtual screen is focused, move vertical scroll to from prompt_toolkit . application import get_app focused_window = get_app ( ) . layout . current_window try : visible_win_write_pos = temp_screen . visible_windows_to_write_positions [ focused_window ] except KeyError : pass # No window focused here. Don't scroll. else : # Make sure this window is visible. self . _make_window_visible ( write_position . height , virtual_height , visible_win_write_pos , temp_screen . cursor_positions . get ( focused_window ) , ) # Copy over virtual screen and zero width escapes to real screen. self . _copy_over_screen ( screen , temp_screen , write_position , virtual_width ) # Copy over mouse handlers. self . _copy_over_mouse_handlers ( mouse_handlers , temp_mouse_handlers , write_position , virtual_width ) # Set screen.width/height. ypos = write_position . ypos xpos = write_position . xpos screen . width = max ( screen . width , xpos + virtual_width ) screen . height = max ( screen . height , ypos + write_position . height ) # Copy over window write positions. self . _copy_over_write_positions ( screen , temp_screen , write_position ) if temp_screen . show_cursor : screen . show_cursor = True # Copy over cursor positions, if they are visible. for window , point in temp_screen . cursor_positions . items ( ) : if ( 0 <= point . x < write_position . width and self . vertical_scroll <= point . y < write_position . height + self . vertical_scroll ) : screen . cursor_positions [ window ] = Point ( x = point . x + xpos , y = point . y + ypos - self . vertical_scroll ) # Copy over menu positions, but clip them to the visible area. for window , point in temp_screen . menu_positions . items ( ) : screen . menu_positions [ window ] = self . _clip_point_to_visible_area ( Point ( x = point . x + xpos , y = point . y + ypos - self . vertical_scroll ) , write_position , ) # Draw scrollbar. if show_scrollbar : self . _draw_scrollbar ( write_position , virtual_height , screen , )