def on_state_changed(self, state):
if state:<EOL><INDENT>self.editor.painted.connect(self._paint_margins)<EOL>self.editor.key_pressed.connect(self._on_key_pressed)<EOL>self.editor.repaint()<EOL><DEDENT>else:<EOL><INDENT>self.editor.painted.disconnect(self._paint_margins)<EOL>self.editor.key_pressed.disconnect(self._on_key_pressed)<EOL>self.editor.repaint()<EOL><DEDENT>
Connects/Disconnects to the painted event of the editor.

:param state: Enable state