// DisplayOK outputs a bold green translated "OK" to UI.Out.
546119
func (ui *UI) DisplayOK() {
	ui.terminalLock.Lock()
	defer ui.terminalLock.Unlock()

	fmt.Fprintf(ui.Out, "%s\n\n", ui.modifyColor(ui.TranslateText("OK"), color.New(color.FgGreen, color.Bold)))
}
12253
func (a *AIP1640Driver) Display() {
	for i := 0; i < 8; i++ {
		a.sendData(byte(i), a.buffer[i])

		a.pinData.Off()
		a.pinClock.Off()
		time.Sleep(1 * time.Millisecond)
		a.pinClock.On()
		a.pinData.On()
	}

	a.sendCommand(AIP1640DispCtrl | a.intensity)
}
833423
func (ctx *Context) OkHTML(str string) error {
	return ctx.HTML(http.StatusOK, str)
}
972027
func (p *LogFormatterParams) StatusCodeColor() string {
	code := p.StatusCode

	switch {
	case code >= http.StatusOK && code < http.StatusMultipleChoices:
		return green
	case code >= http.StatusMultipleChoices && code < http.StatusBadRequest:
		return white
	case code >= http.StatusBadRequest && code < http.StatusInternalServerError:
		return yellow
	default:
		return red
	}
}
1337433
func ConfigureOutputFormat(c *cli.Context) error {
	outFmt := c.String(FormatKey)
	switch outFmt {
	case FormatRaw, FormatJSON, FormatYML:
		// valid
		Format = outFmt
	case "":
		// default
		Format = FormatRaw
	default:
		// invalid
		return fmt.Errorf("Invalid Output Format: %s", outFmt)
	}
	return nil
}
1140415
func (ui *UI) DisplayBoolPrompt(defaultResponse bool, template string, templateValues ...map[string]interface{}) (bool, error) {
	ui.terminalLock.Lock()
	defer ui.terminalLock.Unlock()

	response := defaultResponse
	interactivePrompt := ui.Interactor.NewInteraction(ui.TranslateText(template, templateValues...))
	interactivePrompt.SetIn(ui.In)
	interactivePrompt.SetOut(ui.OutForInteration)
	err := interactivePrompt.Resolve(&response)
	if isInterrupt(err) {
		ui.Exiter.Exit(sigIntExitCode)
	}
	return response, err
}
584653
func (s *InstanceHealthSummary) SetOk(v int64) *InstanceHealthSummary {
	s.Ok = &v
	return s
}
80498
func (ctx *Context) OkJSON(val interface{}) error {
	return ctx.JSON(http.StatusOK, val)
}
1026171
func (ui *UI) DisplayTextMenu(choices []string, promptTemplate string, templateValues ...map[string]interface{}) (string, error) {
	for i, c := range choices {
		t := fmt.Sprintf("%d. %s", i+1, c)
		ui.DisplayText(t)
	}

	translatedPrompt := ui.TranslateText(promptTemplate, templateValues...)

	interactivePrompt := ui.Interactor.NewInteraction(translatedPrompt)

	interactivePrompt.SetIn(ui.In)
	interactivePrompt.SetOut(ui.OutForInteration)

	var value string = "enter to skip"
	err := interactivePrompt.Resolve(&value)

	if isInterrupt(err) {
		ui.Exiter.Exit(sigIntExitCode)
	}

	if err != nil {
		return "", err
	}

	if value == "enter to skip" {
		return "", nil
	}

	i, err := strconv.Atoi(value)
	if err != nil {
		if contains(choices, value) {
			return value, nil
		}
		return "", InvalidChoiceError{Choice: value}
	}

	if i > len(choices) || i <= 0 {
		return "", ErrInvalidIndex
	}
	return choices[i-1], nil
}
1261173
func (menu *Menu) setDisplayed(displayed bool) {
	menu.Displayed = displayed

	for _, child := range menu.Items {
		if child.IsSubMenu() {
			child.SubMenu.setDisplayed(displayed)
		}
	}
}
650090
func (t *Table) DisplayTable(rows [][]string) error {
	numRows := len(rows)
	numCols := len(rows[0])
	if numRows != len(t.RowColors) {
		return fmt.Errorf("row count and row-colors mismatch")
	}

	// Compute max. column widths
	maxColWidths := make([]int, numCols)
	for _, row := range rows {
		if len(row) != len(t.AlignRight) {
			return fmt.Errorf("col count and align-right mismatch")
		}
		for i, v := range row {
			if len([]rune(v)) > maxColWidths[i] {
				maxColWidths[i] = len([]rune(v))
			}
		}
	}

	// Compute per-cell text with padding and alignment applied.
	paddedText := make([][]string, numRows)
	for r, row := range rows {
		paddedText[r] = make([]string, numCols)
		for c, cell := range row {
			if t.AlignRight[c] {
				fmtStr := fmt.Sprintf("%%%ds", maxColWidths[c])
				paddedText[r][c] = fmt.Sprintf(fmtStr, cell)
			} else {
				extraWidth := maxColWidths[c] - len([]rune(cell))
				fmtStr := fmt.Sprintf("%%s%%%ds", extraWidth)
				paddedText[r][c] = fmt.Sprintf(fmtStr, cell, "")
			}
		}
	}

	// Draw table top border
	segments := make([]string, numCols)
	for i, c := range maxColWidths {
		segments[i] = strings.Repeat("─", c+2)
	}
	indentText := strings.Repeat(" ", t.TableIndentWidth)
	border := fmt.Sprintf("%s┌%s┐", indentText, strings.Join(segments, "┬"))
	fmt.Println(border)

	// Print the table with colors
	for r, row := range paddedText {
		fmt.Print(indentText + "│ ")
		for c, text := range row {
			t.RowColors[r].Print(text)
			if c != numCols-1 {
				fmt.Print(" │ ")
			}
		}
		fmt.Println(" │")
	}

	// Draw table bottom border
	border = fmt.Sprintf("%s└%s┘", indentText, strings.Join(segments, "┴"))
	fmt.Println(border)

	return nil
}
308284
func (self htmlIdImpl) DisplayAttribute() DomAttribute {
	return self.getOrCreateAttribute("display", func() DomAttribute {
		return NewDisplayAttr(self.t)
	})
}
450890
func (client *Client) ExecuteHook(ctx context.Context, tablet *topodatapb.Tablet, hk *hook.Hook) (*hook.HookResult, error) {
	cc, c, err := client.dial(tablet)
	if err != nil {
		return nil, err
	}
	defer cc.Close()
	hr, err := c.ExecuteHook(ctx, &tabletmanagerdatapb.ExecuteHookRequest{
		Name:       hk.Name,
		Parameters: hk.Parameters,
		ExtraEnv:   hk.ExtraEnv,
	})
	if err != nil {
		return nil, err
	}
	return &hook.HookResult{
		ExitStatus: int(hr.ExitStatus),
		Stdout:     hr.Stdout,
		Stderr:     hr.Stderr,
	}, nil
}
249855
func (v *OrderedValues) GetOk(key []byte) ([]byte, bool) {
	for _, j := range *v {
		if len(j) > 0 && bytes.Equal(j[0], key) {
			if len(j) > 1 {
				return j[1], true
			}
			return nil, true
		}
	}
	return nil, false
}
589051
func (ui *UI) DisplayTextWithFlavor(template string, templateValues ...map[string]interface{}) {
	ui.terminalLock.Lock()
	defer ui.terminalLock.Unlock()

	firstTemplateValues := getFirstSet(templateValues)
	for key, value := range firstTemplateValues {
		firstTemplateValues[key] = ui.modifyColor(fmt.Sprint(value), color.New(color.FgCyan, color.Bold))
	}
	fmt.Fprintf(ui.Out, "%s\n", ui.TranslateText(template, firstTemplateValues))
}
28568
func (logger *Logger) AddHook(hook lg.Hook) {
	mux := &sync.Mutex{}

	unsafeStd := (*unsafe.Pointer)(unsafe.Pointer(&logger.std))
	stdVal := (*lg.Logger)(atomic.LoadPointer(unsafeStd))
	old := logger.std
	mux.Lock()
	stdVal.Hooks.Add(hook)
	mux.Unlock()
	atomic.CompareAndSwapPointer(unsafeStd, unsafe.Pointer(old), unsafe.Pointer(logger.std))
}
952135
func (c *CMap) GetOk(key interface{}) (val interface{}, ok bool) {
	c.mutex.RLock()
	val, ok = c.items[key]
	c.mutex.RUnlock()
	return
}