parameters: (
          self, write_position: WritePosition, content_height: int, screen: Screen
      )
docstring: Draw the scrollbar on the screen.
  
          Note: There is some code duplication with the `ScrollbarMargin`
                implementation.
docstring_summary: Draw the scrollbar on the screen.
docstring_tokens: Draw the scrollbar on the screen .
function: def _draw_scrollbar(
          self, write_position: WritePosition, content_height: int, screen: Screen
      ) -> None:
          """
          Draw the scrollbar on the screen.
  
          Note: There is some code duplication with the `ScrollbarMargin`
                implementation.
          """
  
          window_height = write_position.height
          display_arrows = self.display_arrows()
  
          if display_arrows:
              window_height -= 2
  
          try:
              fraction_visible = write_position.height / float(content_height)
              fraction_above = self.vertical_scroll / float(content_height)
  
              scrollbar_height = int(
                  min(window_height, max(1, window_height * fraction_visible))
              )
              scrollbar_top = int(window_height * fraction_above)
          except ZeroDivisionError:
              return
          else:
  
              def is_scroll_button(row: int) -> bool:
                  "True if we should display a button on this row."
                  return scrollbar_top <= row <= scrollbar_top + scrollbar_height
  
              xpos = write_position.xpos + write_position.width - 1
              ypos = write_position.ypos
              data_buffer = screen.data_buffer
  
              # Up arrow.
              if display_arrows:
                  data_buffer[ypos][xpos] = Char(
                      self.up_arrow_symbol, "class:scrollbar.arrow"
                  )
                  ypos += 1
  
              # Scrollbar body.
              scrollbar_background = "class:scrollbar.background"
              scrollbar_background_start = "class:scrollbar.background,scrollbar.start"
              scrollbar_button = "class:scrollbar.button"
              scrollbar_button_end = "class:scrollbar.button,scrollbar.end"
  
              for i in range(window_height):
                  style = ""
                  if is_scroll_button(i):
                      if not is_scroll_button(i + 1):
                          # Give the last cell a different style, because we want
                          # to underline this.
                          style = scrollbar_button_end
                      else:
                          style = scrollbar_button
                  else:
                      if is_scroll_button(i + 1):
                          style = scrollbar_background_start
                      else:
                          style = scrollbar_background
  
                  data_buffer[ypos][xpos] = Char(" ", style)
                  ypos += 1
  
              # Down arrow
              if display_arrows:
                  data_buffer[ypos][xpos] = Char(
                      self.down_arrow_symbol, "class:scrollbar.arrow"
                  )
function_tokens: def _draw_scrollbar ( self , write_position : WritePosition , content_height : int , screen : Screen ) -> None : window_height = write_position . height display_arrows = self . display_arrows ( ) if display_arrows : window_height -= 2 try : fraction_visible = write_position . height / float ( content_height ) fraction_above = self . vertical_scroll / float ( content_height ) scrollbar_height = int ( min ( window_height , max ( 1 , window_height * fraction_visible ) ) ) scrollbar_top = int ( window_height * fraction_above ) except ZeroDivisionError : return else : def is_scroll_button ( row : int ) -> bool : "True if we should display a button on this row." return scrollbar_top <= row <= scrollbar_top + scrollbar_height xpos = write_position . xpos + write_position . width - 1 ypos = write_position . ypos data_buffer = screen . data_buffer # Up arrow. if display_arrows : data_buffer [ ypos ] [ xpos ] = Char ( self . up_arrow_symbol , "class:scrollbar.arrow" ) ypos += 1 # Scrollbar body. scrollbar_background = "class:scrollbar.background" scrollbar_background_start = "class:scrollbar.background,scrollbar.start" scrollbar_button = "class:scrollbar.button" scrollbar_button_end = "class:scrollbar.button,scrollbar.end" for i in range ( window_height ) : style = "" if is_scroll_button ( i ) : if not is_scroll_button ( i + 1 ) : # Give the last cell a different style, because we want # to underline this. style = scrollbar_button_end else : style = scrollbar_button else : if is_scroll_button ( i + 1 ) : style = scrollbar_background_start else : style = scrollbar_background data_buffer [ ypos ] [ xpos ] = Char ( " " , style ) ypos += 1 # Down arrow if display_arrows : data_buffer [ ypos ] [ xpos ] = Char ( self . down_arrow_symbol , "class:scrollbar.arrow" )