Autocomplete for allow_select_scan option
509219
def complete_opt_allow_select_scan(self, text, *_):
        
        return [t for t in ("true", "false", "yes", "no") if t.startswith(text.lower())]
885297
public function autocomplete()
    {
        $this->loadComponent('RequestHandler');
        $this->viewClass = 'Json';
        $data = [];
        $paramName = $this->request->query('parameter');
        $query = $this->request->query('query');
        $parameter = $this->Filter->parameters()->get($paramName);
        if (!empty($parameter)) {
            $method = $parameter->config('autocompleteAction');
            $data = $method($query);
            $this->set('status', 'success');
        } else {
            $this->set('status', 'error');
            $this->set('message', __('Field not found'));
        }
        $this->set('data', $data);
        $this->set('_serialize', ['data', 'status', 'message']);
    }
407916
private function __autocomplete($config = array())
    {
        $config = new ObjectConfigJson($config);
        $config->append(array(
            'name'     => '',
            'attribs'  => array(
                'id' => 'select2-element-'.mt_rand(1000, 100000)
            ),
            'validate' => true,
            'prompt'   => '- '.$this->getObject('translator')->translate('Select').' -',
            'deselect' => true,
        ))->append(array(
            'element'    => '#'.$config->attribs->id,
            'options'    => array('multiple' => (bool) $config->attribs->multiple),
            'value'      => $config->name,
            'selected'   => $config->{$config->name},
        ))->append(array(
            'label'      => $config->value,
        ))->append(array(
            'text'       => $config->label,
            'filter'     => array('sort' => $config->label),
        ));

        if (!$config->ajax_url)
        {
            $identifier = $config->model->getIdentifier();
            $parts      = array(
                'component' => $identifier->package,
                'view'      => $identifier->name,
                'format'    => 'json'
            );

            if ($config->filter) {
                $parts = array_merge($parts, ObjectConfig::unbox($config->filter));
            }

            $config->ajax_url = $this->getObject('lib:dispatcher.router.route')->setQuery($parts);
        }

        $html = '';
        $html .= $this->createHelper('behavior')->autocomplete($config);

        $config->attribs->name = $config->name;

        $options = array();

        if ((is_scalar($config->selected) && $config->selected) || count($config->selected))
        {
            $selected = $config->selected;

            if(!$selected instanceof ModelEntityInterface)
            {
                $selected = $config->model
                    ->setState(ObjectConfig::unbox($config->filter))
                    ->setState(array($config->value => ObjectConfig::unbox($selected)))
                    ->fetch();
            }

            foreach($selected as $entity)
            {
                $options[]  = $this->option(array(
                    'value' => $entity->{$config->value},
                    'label' => $entity->{$config->label},
                    'attribs' => array('selected' => true)
                ));
            }
        }

         $html .= $this->optionlist(array(
            'name'     => $config->name,
            'id'       => $config->id,
            'options' => $options,
            'deselect' => false,
            'select2'  => false,
            'attribs'  => $config->attribs
        ));

        return $html;
    }
902702
protected function autocompletefield() {
		if ( ! $this->autocompleted) {
			$fieldname = $this->get('name', null);
			if ($fieldname !== null && ($autovalue = $this->form->autovalue($fieldname)) !== null) {
				if ($this->get('value', false) == $autovalue) {
					$this->checked();
				}
			}
			$this->autocompleted = true;
		}
	}
1245645
public function autocomplete($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'element'  => null,
            'options_callback' => null, // wraps the call to select2 options in JavaScript, can be used to add JS code
            'options'  => array(
                'minimumInputLength' => 2,
                'validate'      => false, //Toggle if the forms validation helper is loaded
                'queryVarName'  => 'search',
                'width'         => 'resolve',
                'model'		    => $config->model,
                'placeholder'   => $config->prompt,
                'allowClear'    => $config->deselect,
                'value'         => $config->value,
                'text'          => $config->text,
                'selected'      => $config->selected,
                'url'           => $config->url,
                'multiple'      => false
            )
        ))->append(array(
            'options' => array(
                'label' => $config->text
            )
        ));

        $html ='';

        if (!$config->options->url instanceof KHttpUrl) {
            $config->options->url = $this->getObject('lib:http.url', array('url' => $config->options->url));
        }

        $config->options->url->setQuery(array('fields' => $config->value.','.$config->text), true);

        $config->options->url = (string)$config->options->url;

        $options   = $config->options;
        $signature = md5('autocomplete-'.$config->element.$config->options_callback.$options);

        if($config->element && !static::isLoaded($signature))
        {
            $options = (string) $options;

            if ($config->options_callback) {
                $options = $config->options_callback.'('.$options.')';
            }

            $html .= $this->select2(array('element' => false));

            if (!static::isLoaded('koowa-select2-autocomplete')) {
                $html .= '<script>
                if(!Koowa) {
                    var Koowa = {};
                }
                
                Koowa.getSelect2Options = function(options) {
                    var defaults = {
                        width: "resolve",
                        minimumInputLength: 2,
                        theme: "bootstrap",
                        ajax: {
                            url: options.url,
                            delay: 100,
                            data: function (params) {
                                var page  = params.page || 1,  // page is the one-based page number tracked by Select2
                                    query = {
                                        limit: 10, // page size
                                        offset: (page-1)*10
                                    };
                                query[options.queryVarName] = params.term;
            
                                return query;
                            },
                            processResults: function (data, page) {
                                var results = [],
                                    more = (page * 10) < data.meta.total; // whether or not there are more results available
            
                                kQuery.each(data.entities, function(i, item) {
                                    // Change format to what select2 expects
                                    item.id   = item[options.value];
                                    item.text = item[options.text];
            
                                    results.push(item);
                                });
            
                                // notice we return the value of more so Select2 knows if more results can be loaded
                                return {results: results, more: more};
                            }
                        }
                    };
                    
                    var settings = kQuery.extend( {}, defaults, options);
                    
                    return settings;
                };
                </script>';

                static::setLoaded('koowa-select2-autocomplete');
            }

            $html .= '<script>
            kQuery(function($){
                $("'.$config->element.'").select2(Koowa.getSelect2Options('.$options.'));
            });</script>';

            static::setLoaded($signature);
        }

        return $html;
    }
726201
function searchFormSubmitted(e){
    e = e || window.event;
    e.preventDefault();

    // If there's no selected item, do nothing
    if(!selectedItem) return false;

    // Otherwise, jump to the page
    window.location.href = relativeDir + selectedItem.getAttribute('data-value');

    return false;
  }
194119
function Autocomplete(el, options) {
      _classCallCheck(this, Autocomplete);

      var _this37 = _possibleConstructorReturn(this, (Autocomplete.__proto__ || Object.getPrototypeOf(Autocomplete)).call(this, Autocomplete, el, options));

      _this37.el.M_Autocomplete = _this37;

      /**
       * Options for the autocomplete
       * @member Autocomplete#options
       * @prop {Number} duration
       * @prop {Number} dist
       * @prop {number} shift
       * @prop {number} padding
       * @prop {Boolean} fullWidth
       * @prop {Boolean} indicators
       * @prop {Boolean} noWrap
       * @prop {Function} onCycleTo
       */
      _this37.options = $.extend({}, Autocomplete.defaults, options);

      // Setup
      _this37.isOpen = false;
      _this37.count = 0;
      _this37.activeIndex = -1;
      _this37.oldVal;
      _this37.$inputField = _this37.$el.closest('.input-field');
      _this37.$active = $();
      _this37._mousedown = false;
      _this37._setupDropdown();

      _this37._setupEventHandlers();
      return _this37;
    }
1105548
def autocomplete_query(self, **kwargs):
        
        if not kwargs.get('text'):
            raise ValueError('Valid text (parameter "text") must be provided.')

        return self._query(AUTOCOMPLETE_API_URL, **kwargs)
579506
def _select_input(self):
        """"""
        line, index = self.get_position('eof')
        if self.current_prompt_pos is None:
            pline, pindex = line, index
        else:
            pline, pindex = self.current_prompt_pos
        self.setSelection(pline, pindex, line, index)
215992
function getMatchData(input, cb) {
  var string = input.context;
  var cmd = input.match;
  var midOption = String(string).trim().slice(0, 1) === '-';
  var afterOption = input.option !== undefined;
  if (midOption === true && !cmd._allowUnknownOptions) {
    var results = [];
    for (var i = 0; i < cmd.options.length; ++i) {
      var long = cmd.options[i].long;
      var short = cmd.options[i].short;
      if (!long && short) {
        results.push(short);
      } else if (long) {
        results.push(long);
      }
    }
    cb(results);
    return;
  }

  function handleDataFormat(str, config, callback) {
    var data = [];
    if (_.isArray(config)) {
      data = config;
    } else if (_.isFunction(config)) {
      var cbk = config.length < 2 ? function () {} : function (res) {
        callback(res || []);
      };
      var res = config(str, cbk);
      if (res && _.isFunction(res.then)) {
        res.then(function (resp) {
          callback(resp);
        }).catch(function (err) {
          callback(err);
        });
      } else if (config.length < 2) {
        callback(res);
      }
      return;
    }
    callback(data);
    return;
  }

  if (afterOption === true) {
    var opt = strip(input.option).trim();
    var shortMatch = _.find(cmd.options, { short: opt });
    var longMatch = _.find(cmd.options, { long: opt });
    var match = longMatch || shortMatch;
    if (match) {
      var config = match.autocomplete;
      handleDataFormat(string, config, cb);
      return;
    }
  }

  var conf = cmd._autocomplete;
  conf = conf && conf.data ? conf.data : conf;
  handleDataFormat(string, conf, cb);
  return;
}
136083
public function scanOnly($c = true, &$list = array(), $exclude_extension = array(), $exclude_file = array(), $exclude_dir = array(), $dir = "")
    {
        $aFiles = $this->scan($c, $list, $exclude_extension, $exclude_file, $exclude_dir, $dir);

        $list = array();

        foreach ($aFiles as $key => $v) {

            if (isset($c['extension']) && preg_match('/' . $c['extension'] . '/i', $v['extension'])) {
                $list[$key] = $v;
            }

            if (isset($c['type']) && preg_match('/' . $c['type'] . '/i', $v['type'])) {
                $list[$key] = $v;
            }

        }

        return $list;

    }
333330
function _keyUp() {
            var filteredChoices;

            if (lxSelect.choicesViewMode === 'panes') {
                filteredChoices = Object.keys(lxSelect.panes[(lxSelect.panes.length - 1)]);
            } else {
                filteredChoices = $filter('filterChoices')(lxSelect.choices, lxSelect.filter, lxSelect.filterModel);
            }

            if (filteredChoices.length) {
                lxSelect.activeChoiceIndex -= 1;

                if (lxSelect.activeChoiceIndex < 0) {
                    lxSelect.activeChoiceIndex = filteredChoices.length - 1;
                }
            }

            if (lxSelect.autocomplete) {
                LxDropdownService.open('dropdown-' + lxSelect.uuid, '#lx-select-selected-wrapper-' + lxSelect.uuid);
            }
        }
612443
def allow(self):
        """"""
        with self.selenium.context(self.selenium.CONTEXT_CHROME):
            self.find_primary_button().click()
555193
def prompt_autocomplete(prompt, complete, default=None, contains_spaces=True, 
                        show_default=True, prompt_suffix=': ', color=None):
    

    def real_completer(text, state):
        possibilities = complete(text) + [None]

        if possibilities:
            return possibilities[state]
        return None

    readline.set_completer_delims('\t\n' + ' ' * (not contains_spaces))
    readline.parse_and_bind("tab: complete")
    readline.set_completer(real_completer)
    
    if default is not None and show_default:
        prompt += ' [%s]' % default

    prompt += prompt_suffix

    colors = {
        'red': Fore.RED,
        'blue': Fore.BLUE,
        'green': Fore.GREEN,
        'cyan': Fore.CYAN,
        'magenta': Fore.MAGENTA,
        'yellow': Fore.YELLOW,
        'white': Fore.WHITE,
        'black': Fore.LIGHTBLACK_EX
    }

    if color:
        prompt = colors[color.lower()] + prompt + Fore.RESET

    if default is not None:
        r = input(prompt)
    else:
        while True:
            r = input(prompt)
            if r:
                break

    r = r or default

    # remove the autocompletion before quitting for future input()
    readline.parse_and_bind('tab: self-insert')
    readline.set_completer(None)

    return r
470563
def _autocomplete(ctx, shell):
    """"""
    if not shell:
        shell = os.environ.get("SHELL", "")
        shell = os.path.basename(shell).lower()
    if not shell:
        click.secho(
            "Your shell could not be detected, please pass its name "
            "as the argument.",
            fg="red",
        )
        ctx.exit(-1)

    base = os.path.abspath(os.path.dirname(__file__))
    autocomplete = os.path.join(base, "autocomplete", "{}.sh".format(shell))

    if not os.path.exists(autocomplete):
        click.secho(
            "Autocompletion for your shell ({}) is currently not "
            "supported.",
            fg="red",
        )
        ctx.exit(-1)

    with open(autocomplete) as fh:
        click.echo(fh.read())
1311957
def get_selections(fetchempty=True):
    '''
    
    '''
    selections = {}
    cmd = 'debconf-get-selections'

    out = __salt__['cmd.run_stdout'](cmd)

    lines = _unpack_lines(out)

    for line in lines:
        package, question, type_, value = line
        if fetchempty or value:
            (selections
                .setdefault(package, [])
                .append([question, type_, value]))

    return selections
663870
def autocomplete(self):
        
        if self.completion_env_var_name not in os.environ:
            return
        cwords = os.environ['COMP_WORDS'].split()[1:]
        cword = int(os.environ['COMP_CWORD'])
        try:
            current = cwords[cword-1]
        except IndexError:
            current = ''
        cmd_names = self.get_commands().keys()

        if current:
            self.stdout.write(unicode(' '.join(
                [name for name in cmd_names if name.startswith(current)])))

        sys.exit(1)