'Toggle blanks visibility'

def set_blanks_enabled(self, state):

    self.blanks_enabled = state
    option = self.document().defaultTextOption()
    option.setFlags((option.flags() | QTextOption.AddSpaceForLineAndParagraphSeparators))
    if self.blanks_enabled:
        option.setFlags((option.flags() | QTextOption.ShowTabsAndSpaces))
    else:
        option.setFlags((option.flags() & (~ QTextOption.ShowTabsAndSpaces)))
    self.document().setDefaultTextOption(option)
    self.rehighlight()
