class_docstr: Container widget that exposes a larger virtual screen to its content and
  displays it in a vertical scrollbale region.
  
  Typically this is wrapped in a large `HSplit` container. Make sure in that
  case to not specify a `height` dimension of the `HSplit`, so that it will
  scale according to the content.
  
  .. note::
  
      If you want to display a completion menu for widgets in this
      `ScrollablePane`, then it's still a good practice to use a
      `FloatContainer` with a `CompletionsMenu` in a `Float` at the top-level
      of the layout hierarchy, rather then nesting a `FloatContainer` in this
      `ScrollablePane`. (Otherwise, it's possible that the completion menu
      is clipped.)
  
  :param content: The content container.
  :param scrolloffset: Try to keep the cursor within this distance from the
      top/bottom (left/right offset is not used).
  :param keep_cursor_visible: When `True`, automatically scroll the pane so
      that the cursor (of the focused window) is always visible.
  :param keep_focused_window_visible: When `True`, automatically scroll the
      pane so that the focused window is visible, or as much visible as
      possible if it doesn't completely fit the screen.
  :param max_available_height: Always constraint the height to this amount
      for performance reasons.
  :param width: When given, use this width instead of looking at the children.
  :param height: When given, use this height instead of looking at the children.
  :param show_scrollbar: When `True` display a scrollbar on the right.
class_docstr_tok: ["Container","widget","that","exposes","a","larger","virtual","screen","to","its","content","and","displays","it","in","a","vertical","scrollbale","region",".","Typically","this","is","wrapped","in","a","large","`","HSplit","`","container",".","Make","sure","in","that","case","to","not","specify","a","`","height","`","dimension","of","the","`","HSplit","`",",","so","that","it","will","scale","according","to","the","content",".","..","note",":",":","If","you","want","to","display","a","completion","menu","for","widgets","in","this","`","ScrollablePane","`",",","then","it","'s","still","a","good","practice","to","use","a","`","FloatContainer","`","with","a","`","CompletionsMenu","`","in","a","`","Float","`","at","the","top-level","of","the","layout","hierarchy",",","rather","then","nesting","a","`","FloatContainer","`","in","this","`","ScrollablePane","`",".","(","Otherwise",",","it","'s","possible","that","the","completion","menu","is","clipped",".",")",":","param","content",":","The","content","container",".",":","param","scrolloffset",":","Try","to","keep","the","cursor","within","this","distance","from","the","top\/bottom","(","left\/right","offset","is","not","used",")",".",":","param","keep_cursor_visible",":","When","`","True","`",",","automatically","scroll","the","pane","so","that","the","cursor","(","of","the","focused","window",")","is","always","visible",".",":","param","keep_focused_window_visible",":","When","`","True","`",",","automatically","scroll","the","pane","so","that","the","focused","window","is","visible",",","or","as","much","visible","as","possible","if","it","does","n't","completely","fit","the","screen",".",":","param","max_available_height",":","Always","constraint","the","height","to","this","amount","for","performance","reasons",".",":","param","width",":","When","given",",","use","this","width","instead","of","looking","at","the","children",".",":","param","height",":","When","given",",","use","this","height","instead","of","looking","at","the","children",".",":","param","show_scrollbar",":","When","`","True","`","display","a","scrollbar","on","the","right","."]
docstr: Render scrollable pane content.
  
  This works by rendering on an off-screen canvas, and copying over the
  visible region.
docstr_tok: ["Render","scrollable","pane","content",".","This","works","by","rendering","on","an","off-screen","canvas",",","and","copying","over","the","visible","region","."]
code: def write_to_screen(
      self,
      screen: Screen,
      mouse_handlers: MouseHandlers,
      write_position: WritePosition,
      parent_style: str,
      erase_bg: bool,
      z_index: int | None,
  ) -> 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_screen.show_cursor = screen.show_cursor
      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,
          )
  
imports: from __future__ import annotations
  from prompt_toolkit.data_structures import Point
  from prompt_toolkit.filters import FilterOrBool, to_filter
  from prompt_toolkit.key_binding import KeyBindingsBase
  from prompt_toolkit.mouse_events import MouseEvent
  from .containers import Container, ScrollOffsets
  from .dimension import AnyDimension, Dimension, sum_layout_dimensions, to_dimension
  from .mouse_handlers import MouseHandler, MouseHandlers
  from .screen import Char, Screen, WritePosition
label_desc: Use image node_id 6 for calling the ScrollablePane obj's underlying member method code with example usage: obj.write_to_screen(screen, mouse_handlers, write_position, parent_style, erase_bg, z_index) without return types