code: def highlight_block(self, text):
          
          text = to_text_string(text)
          inside_comment = tbh.get_state(self.currentBlock().previous()) == self.INSIDE_COMMENT
          self.setFormat(0, len(text),
                         self.formats["comment" if inside_comment else "normal"])
          
          match = self.PROG.search(text)
          index = 0
          while match:
              for key, value in list(match.groupdict().items()):
                  if value:
                      start, end = match.span(key)
                      index += end-start
                      if key == "comment_start":
                          inside_comment = True
                          self.setFormat(start, len(text)-start,
                                         self.formats["comment"])
                      elif key == "comment_end":
                          inside_comment = False
                          self.setFormat(start, end-start,
                                         self.formats["comment"])
                      elif inside_comment:
                          self.setFormat(start, end-start,
                                         self.formats["comment"])
                      elif key == "define":
                          self.setFormat(start, end-start,
                                         self.formats["number"])
                      else:
                          self.setFormat(start, end-start, self.formats[key])
                      
              match = self.PROG.search(text, match.end())
          
          self.highlight_spaces(text)
          
          last_state = self.INSIDE_COMMENT if inside_comment else self.NORMAL
          tbh.set_state(self.currentBlock(), last_state)
docs: Implement highlight specific for C/C++.