def _build_calltip_data(self, textiter: Gtk.TextIter,
                         buffer: GtkSource.Buffer):
     cursor = textiter.copy()
     count_commas = 0
     count_commas_since_last_lang_string_begin_mark = 0
     while cursor.backward_char():
         if cursor.get_char() == ')':
             # We are not in a function, for sure!
             return None
         if cursor.get_char() == '{' or cursor.get_char() == '<':
             # Handle middle of language string or a pos marker
             count_commas -= count_commas_since_last_lang_string_begin_mark
             count_commas_since_last_lang_string_begin_mark = 0
         if cursor.get_char() == '}' or cursor.get_char() == '>':
             # Handle end of language string or a pos marker
             count_commas_since_last_lang_string_begin_mark = 0
         if cursor.get_char() == '(':
             # Handle the opcode/function name
             start_of_word = cursor.copy()
             backward_until_space(start_of_word)
             opcode_name = buffer.get_text(start_of_word, cursor, False)
             for op in self.opcodes:
                 if op.name == opcode_name:
                     return op, count_commas
             return None
         if cursor.get_char() == ',':
             # Collect commas for the arg index
             count_commas += 1
             count_commas_since_last_lang_string_begin_mark += 1
     return None
 def on_buffer_notify_cursor_position(self, buffer: GtkSource.Buffer,
                                      *args):
     textiter = buffer.get_iter_at_offset(buffer.props.cursor_position)
     if 'string' in buffer.get_context_classes_at_iter(textiter):
         # iter_backward_to_context_class_toggle and iter_forward_to_context_class_toggle
         # seem to be broken (because of course they are), so we do it manually.
         start = self._get_string_start(textiter)
         end = self._get_string_end(textiter)
         if start is None or end is None:
             return True
         string = buffer.get_text(start, end, False)
         self.context.on_selected_string_changed(string)
     return True