code: def insert_text(self, data, overwrite=False, move_cursor=True, fire_event=True):
          
          # Original text & cursor position.
          otext = self.text
          ocpos = self.cursor_position
  
          # In insert/text mode.
          if overwrite:
              # Don't overwrite the newline itself. Just before the line ending,
              # it should act like insert mode.
              overwritten_text = otext[ocpos:ocpos + len(data)]
              if '\n' in overwritten_text:
                  overwritten_text = overwritten_text[:overwritten_text.find('\n')]
  
              self.text = otext[:ocpos] + data + otext[ocpos + len(overwritten_text):]
          else:
              self.text = otext[:ocpos] + data + otext[ocpos:]
  
          if move_cursor:
              self.cursor_position += len(data)
  
          # Fire 'on_text_insert' event.
          if fire_event:
              self.on_text_insert.fire()
docs: Insert characters at cursor position.
  
          :param fire_event: Fire `on_text_insert` event. This is mainly used to
              trigger autocompletion while typing.