def apply_style(self, theme=None, colors=None): # get style if not colors: colors = design.getColors(theme) # editor bg color = colors['code']['background'] self.bg = color self.setTextEditFontSize() # syntax hightlighter self.blockSignals(True) # colors = None self.hgl = syntaxHighLighter.VEXHighlighterClass(self, colors) self.blockSignals(False) # completer if self.use_completer: self.completer.updateStyle(colors)
def updateStyle(self, colors=None): if not colors: colors = design.getColors() self.colors = { vex_parser.wordCompletion.FUNCTION: colors['completer']['methods'], vex_parser.wordCompletion.ATTRIBUTE: colors['completer']['attribute'], vex_parser.wordCompletion.TYPE: colors['completer']['type'], vex_parser.wordCompletion.DEFINITION: colors['completer']['directive'], vex_parser.wordCompletion.KEYWORD: colors['completer']['keywords'], vex_parser.wordCompletion.VARIABLE: colors['completer']['variable'], 'selected': colors['completer']['background_selected'], 'bg': colors['completer']['background'] } self.setStyleSheet('background-color: rgb(%s,%s,%s);' % (colors['completer']['background'][0], colors['completer']['background'][1], colors['completer']['background'][2] ))
def __init__(self, parent=None, theme=None): super(TemplateEditorTextClass, self).__init__(parent) self.setAcceptRichText(False) self.setWordWrapMode(QTextOption.NoWrap) self.colors = design.getColors(theme) self.s = vex_settings.EditorSettingsClass() self.fs = 16 self.setTheme(self.colors) metrics = QFontMetrics(self.document().defaultFont()) self.setTabStopWidth(4 * metrics.width(' ')) self.setFontSize() option = self.document().defaultTextOption() option.setFlags(option.flags() | QTextOption.ShowTabsAndSpaces) option.setFlags(option.flags() | QTextOption.AddSpaceForLineAndParagraphSeparators) self.document().setDefaultTextOption(option)
def updateStyle(self, colors=None): if not colors: colors = design.getColors() self.colors = { vex_parser.wordCompletion.FUNCTION: colors['completer']['methods'], vex_parser.wordCompletion.ATTRIBUTE: colors['completer']['attribute'], vex_parser.wordCompletion.TYPE: colors['completer']['type'], vex_parser.wordCompletion.DEFINITION: colors['completer']['directive'], vex_parser.wordCompletion.KEYWORD: colors['completer']['keywords'], vex_parser.wordCompletion.VARIABLE: colors['completer']['variable'], 'selected': colors['completer']['background_selected'], 'bg': colors['completer']['background'] } self.setStyleSheet('background-color: rgb(%s,%s,%s);' % (colors['completer']['background'][0], colors['completer']['background'][1], colors['completer']['background'][2]))