def _apply(self, input_string):
        """ Apply command. """
        e = self.editor

        # Parse command.
        m = COMMAND_GRAMMAR.match(input_string)
        if m is None:
            return

        variables = m.variables()

        command = variables.get('command')
        set_option = variables.get('set_option')

        # Preview colorschemes.
        if command == 'colorscheme':
            colorscheme = variables.get('colorscheme')
            if colorscheme:
                e.use_colorscheme(colorscheme)

        # Preview some set commands.
        if command == 'set':
            if set_option in ('hlsearch', 'hls'):
                e.highlight_search = True
            elif set_option in ('nohlsearch', 'nohls'):
                e.highlight_search = False
            elif set_option in ('nu', 'number'):
                e.show_line_numbers = True
            elif set_option in ('nonu', 'nonumber'):
                e.show_line_numbers = False
            elif set_option in ('ruler', 'ru'):
                e.show_ruler = True
            elif set_option in ('noruler', 'noru'):
                e.show_ruler = False
            elif set_option in ('relativenumber', 'rnu'):
                e.relative_number = True
            elif set_option in ('norelativenumber', 'nornu'):
                e.relative_number = False
            elif set_option in ('cursorline', 'cul'):
                e.cursorline = True
            elif set_option in ('cursorcolumn', 'cuc'):
                e.cursorcolumn = True
            elif set_option in ('nocursorline', 'nocul'):
                e.cursorline = False
            elif set_option in ('nocursorcolumn', 'nocuc'):
                e.cursorcolumn = False
            elif set_option in ('colorcolumn', 'cc'):
                value = variables.get('set_value', '')
                if value:
                    e.colorcolumn = [
                        int(v) for v in value.split(',') if v.isdigit()]
def _apply ( self , input_string ) : e = self . editor m = COMMAND_GRAMMAR . match ( input_string ) if m is None : return variables = m . variables ( ) command = variables . get ( 'command' ) set_option = variables . get ( 'set_option' ) if command == 'colorscheme' : colorscheme = variables . get ( 'colorscheme' ) if colorscheme : e . use_colorscheme ( colorscheme ) if command == 'set' : if set_option in ( 'hlsearch' , 'hls' ) : e . highlight_search = True elif set_option in ( 'nohlsearch' , 'nohls' ) : e . highlight_search = False elif set_option in ( 'nu' , 'number' ) : e . show_line_numbers = True elif set_option in ( 'nonu' , 'nonumber' ) : e . show_line_numbers = False elif set_option in ( 'ruler' , 'ru' ) : e . show_ruler = True elif set_option in ( 'noruler' , 'noru' ) : e . show_ruler = False elif set_option in ( 'relativenumber' , 'rnu' ) : e . relative_number = True elif set_option in ( 'norelativenumber' , 'nornu' ) : e . relative_number = False elif set_option in ( 'cursorline' , 'cul' ) : e . cursorline = True elif set_option in ( 'cursorcolumn' , 'cuc' ) : e . cursorcolumn = True elif set_option in ( 'nocursorline' , 'nocul' ) : e . cursorline = False elif set_option in ( 'nocursorcolumn' , 'nocuc' ) : e . cursorcolumn = False elif set_option in ( 'colorcolumn' , 'cc' ) : value = variables . get ( 'set_value' , '' ) if value : e . colorcolumn = [ int ( v ) for v in value . split ( ',' ) if v . isdigit ( ) ]
Apply command.