// findSelection runs a wizard that lets the user select an entry
544389
func (s *Action) findSelection(ctx context.Context, c *cli.Context, choices []string, needle string, cb showFunc) error {
	sort.Strings(choices)
	act, sel := cui.GetSelection(ctx, "Found secrets - Please select an entry", "<↑/↓> to change the selection, <→> to show, <←> to copy, <s> to sync, <e> to edit, <ESC> to quit", choices)
	out.Debug(ctx, "Action: %s - Selection: %d", act, sel)
	switch act {
	case "default":
		// display or copy selected entry
		fmt.Fprintln(stdout, choices[sel])
		return cb(ctx, c, choices[sel], "", false)
	case "copy":
		// display selected entry
		fmt.Fprintln(stdout, choices[sel])
		return cb(WithClip(ctx, true), c, choices[sel], "", false)
	case "show":
		// display selected entry
		fmt.Fprintln(stdout, choices[sel])
		return cb(WithClip(ctx, false), c, choices[sel], "", false)
	case "sync":
		// run sync and re-run show/find workflow
		if err := s.Sync(ctx, c); err != nil {
			return err
		}
		return cb(ctx, c, needle, "", true)
	case "edit":
		// edit selected entry
		fmt.Fprintln(stdout, choices[sel])
		return s.edit(ctx, c, choices[sel])
	default:
		return ExitError(ctx, ExitAborted, nil, "user aborted")
	}
}
488952
func (t *Table) GetSelection() (row, column int) {
	return t.selectedRow, t.selectedColumn
}
318834
func GetSelection(ctx context.Context, prompt, usage string, choices []string) (string, int) {
	if ctxutil.IsAlwaysYes(ctx) || !ctxutil.IsInteractive(ctx) {
		return "impossible", 0
	}

	if prompt != "" {
		prompt += " "
	}

	if err := termbox.Init(); err != nil {
		panic(err)
	}
	defer termbox.Close()

	const coldef = termbox.ColorDefault
	termbox.Clear(coldef, coldef)

	cur := 0
	for {
		// check for context cancelation
		select {
		case <-ctx.Done():
			return "aborted", cur
		default:
		}
		termbox.Clear(coldef, coldef)
		tbprint(0, 0, coldef, coldef, prompt+"Please select:")
		_, h := termbox.Size()
		offset := 0
		if len(choices)+2 > h && cur > h-3 {
			offset = cur
		}
		for i := offset; i < len(choices) && i-offset < h; i++ {
			c := choices[i]
			mark := " "
			if cur == i {
				mark = ">"
			}
			tbprint(0, 1+i-offset, coldef, coldef, fmt.Sprintf("%s %s", mark, c))
		}
		tbprint(0, h-1, coldef, coldef, formatUsageLine(ctx, usage, offset, cur, choices))
		_ = termbox.Flush()
		var act string
		if act, cur = tbpoll(cur, len(choices)); act != "" {
			return act, cur
		}
	}
}
285281
func (f *Folder) FindFolder(name string) (tree.Tree, error) {
	sub := f.findFolder(strings.Split(strings.TrimSuffix(name, sep), sep))
	if sub == nil {
		return nil, errors.Errorf("Entry not found")
	}
	return sub, nil
}
774704
func ParseSelection(s *goquery.Selection) (a *Article, err error) {
	a = &Article{}

	a.Title = parseH3(s)
	a.Year = parseGreenLine(s)
	a.ClusterId, a.NumCite, a.NumVer, a.InfoId = parseBottom(s)
	a.Link = parseSideBar(s)

	if a.InfoId != "" {
		time.Sleep(1.0 * time.Second) // TODO: make 1.0 parameter
		a.BibTeX, err = getBibTeX(generateBibTeXLink(a.InfoId))
		if err != nil {
			return nil, err
		}
	}

	if a.BibTeX != "" {
		bibmap, err := gobibtex.Decode(a.BibTeX)
		if err != nil {
			return nil, err
		}

		if author, ok := bibmap["author"]; ok {
			a.Author = author.([]string)
		}
		if journal, ok := bibmap["journal"]; ok {
			a.Journal = journal.(string)
		}
		if booktitle, ok := bibmap["booktitle"]; ok {
			a.Booktitle = booktitle.(string)
		}
		if volume, ok := bibmap["volume"]; ok {
			a.Volume = volume.(string)
		}
		if number, ok := bibmap["number"]; ok {
			a.Number = number.(string)
		}
		if pages, ok := bibmap["pages"]; ok {
			a.Pages = pages.(string)
		}
		if publisher, ok := bibmap["publisher"]; ok {
			a.Publisher = publisher.(string)
		}
	}

	if !a.isValid() {
		return nil, errors.New(fmt.Sprintf("\"%v\" is not a valid article", a.Title.Name))
	}

	return a, nil
}
669608
func (g *Generator) PackageSelector(pkg interface{}) string {
	_, selector := g.Import(pkg)
	return selector
}
814406
func (extr *ContentExtractor) GetMetaContentWithSelector(document *goquery.Document, selector string) string {
	selection := document.Find(selector)
	content, _ := selection.Attr("content")
	return strings.TrimSpace(content)
}
131126
func (s *Selection) NextUntilSelection(sel *Selection) *Selection {
	if sel == nil {
		return s.NextAll()
	}
	return s.NextUntilNodes(sel.Nodes...)
}
1361431
func (s *Selection) ParentsMatcherUntilSelection(filter Matcher, sel *Selection) *Selection {
	if sel == nil {
		return s.ParentsMatcher(filter)
	}
	return s.ParentsMatcherUntilNodes(filter, sel.Nodes...)
}
1183400
func rangeSelection(str string) Selection {
	m := selRx.FindStringSubmatch(str)
	if len(m) >= 2 {
		from, _ := strconv.Atoi(m[1])
		to, _ := strconv.Atoi(m[2])
		if from < to {
			return makeSelection([][]int{{from, to}})
		}
	}
	return nil
}
51145
func IntQuickSelect(data []int, k int) error {
	return QuickSelect(IntSlice(data), k)
}
577733
func (m *MockEventInterface) GetFieldSelector(arg0, arg1, arg2, arg3 *string) fields.Selector {
	ret := m.ctrl.Call(m, "GetFieldSelector", arg0, arg1, arg2, arg3)
	ret0, _ := ret[0].(fields.Selector)
	return ret0
}
721060
func (o ListOptions) GetTotalAndSelected() (total, selected uint64) {
	return o.total, o.selected
}
1370520
func getSelectFunctors(attr *parser.Decl) ([]selectFunctor, error) {
	var functors []selectFunctor

	for i := range attr.Decl {

		if attr.Decl[i].Token == parser.FromToken {
			break
		}

		if attr.Decl[i].Token == parser.CountToken {
			f := &countSelectFunction{}
			functors = append(functors, f)
		}
	}

	if len(functors) == 0 {
		f := &defaultSelectFunction{}
		functors = append(functors, f)
	}

	return functors, nil

}
288485
func (cb *configBased) Select(aps []AvailablePlugin, id string) (AvailablePlugin, error) {
	if ap, ok := cb.plugins[id]; ok && ap != nil {
		return ap, nil
	}

	// add first one in case it's new id
	for _, ap := range aps {
		available := true
		for _, busyPlugin := range cb.plugins {
			if ap == busyPlugin {
				available = false
			}
		}
		if available {
			cb.plugins[id] = ap
			return ap, nil
		}
	}
	cb.logger.WithFields(log.Fields{
		"_block":   "findAvailablePlugin",
		"strategy": cb.String(),
		"error":    fmt.Sprintf("%v of %v plugins are available", len(aps)-len(cb.plugins), len(aps)),
	}).Error(ErrCouldNotSelect)
	return nil, ErrCouldNotSelect
}
258708
func (t *Tab) GetElementsBySelector(selector string) ([]*Element, error) {
	return t.GetDocumentElementsBySelector(t.GetTopNodeId(), selector)
}
401993
func (s *Selection) ParentsFilteredUntilSelection(filterSelector string, sel *Selection) *Selection {
	return s.ParentsMatcherUntilSelection(compileMatcher(filterSelector), sel)
}