

def reformat_text(self):
    text = self.toPlainText()
    if (not (':' in text)):
        return
    pattern = '[^\\s]*:[^\\s]*'

    def format_components(m):
        component = m.group(0)
        if (component in self.word_list):
            return (("<font color='#0072B2'><b>" + component) + '</b></font> ')
        else:
            return (("<font color='#D55E00'><b>" + component) + '</b></font> ')
    html = re.sub(pattern, format_components, text)
    tc = self.textCursor()
    pos = tc.position()
    self.setHtml(html)
    text = self.toPlainText()
    pos = min(pos, len(self))
    tc.setPosition(pos)
    self.setTextCursor(tc)
    self.setAlignment(Qt.AlignCenter)

dataset/ETHPy150Open glue-viz/glue/glue/dialogs/custom_component/qt/widget.py ColorizedCompletionTextEdit.reformat_text/VarMisuse@147/209 `text`->`self`