code: def mouse_handler(self, cli, mouse_event):
          
          if self._tokens:
              # Read the generator.
              tokens_for_line = list(split_lines(self._tokens))
  
              try:
                  tokens = tokens_for_line[mouse_event.position.y]
              except IndexError:
                  return NotImplemented
              else:
                  # Find position in the token list.
                  xpos = mouse_event.position.x
  
                  # Find mouse handler for this character.
                  count = 0
                  for item in tokens:
                      count += len(item[1])
                      if count >= xpos:
                          if len(item) >= 3:
                              # Handler found. Call it.
                              # (Handler can return NotImplemented, so return
                              # that result.)
                              handler = item[2]
                              return handler(cli, mouse_event)
                          else:
                              break
  
          # Otherwise, don't handle here.
          return NotImplemented
docs: Handle mouse events.
  
          (When the token list contained mouse handlers and the user clicked on
          on any of these, the matching handler is called. This handler can still
          return `NotImplemented` in case we want the `Window` to handle this
          particular event.)