'handles what to do with a scoping gesture'

def handle_scoping_input(self, continue_flag, cmd, text):

    default_split = text.partition(SELECT_SYMBOL[u'scope'])[2].split()
    cmd = cmd.replace(SELECT_SYMBOL[u'scope'], u'')
    continue_flag = True
    if (not default_split):
        self.default_command = u''
        set_scope(u'', add=False)
        print(u'unscoping    all', file=self.output)
        return (continue_flag, cmd)
    while default_split:
        if (not text):
            value = u''
        else:
            value = default_split[0]
        if self.default_command:
            tree_val = ((self.default_command + u'    ') + value)
        else:
            tree_val = value
        if in_tree(self.completer.command_tree, tree_val.strip()):
            self.set_scope(value)
            print((u'defaulting:    ' + value), file=self.output)
            cmd = cmd.replace(SELECT_SYMBOL[u'scope'], u'')
            telemetry.track_ssg(u'scope    command', value)
        elif ((SELECT_SYMBOL[u'unscope'] == default_split[0]) and (len(self.default_command.split()) > 0)):
            value = self.default_command.split()[(-1)]
            self.default_command = (u'    ' + u'    '.join(self.default_command.split()[:(-1)]))
            if (not self.default_command.strip()):
                self.default_command = self.default_command.strip()
            set_scope(self.default_command, add=False)
            print((u'unscoping:    ' + value), file=self.output)
        elif (SELECT_SYMBOL[u'unscope'] not in text):
            print(u'Scope    must    be    a    valid    command', file=self.output)
        default_split = default_split[1:]
    return (continue_flag, cmd)
