// Adding column colors (ANSI codes)
549637
func (t *Table) SetFooterColor(colors ...Colors) {
	if len(t.footers) != len(colors) {
		panic("Number of footer colors must be equal to number of footer.")
	}
	for i := 0; i < len(colors); i++ {
		t.footerParams = append(t.footerParams, makeSequence(colors[i]))
	}
}
538133
func (n *IntNode) flipColors() {
	// Assumes: n has two children.
	n.Color = !n.Color
	n.Left.Color = !n.Left.Color
	n.Right.Color = !n.Right.Color
}
671924
func AutoStyle(i int, fill bool) (style Style) {
	nc, nl, ns := len(StandardColors), len(StandardLineStyles), len(StandardSymbols)

	si := i % ns
	ci := i % nc
	li := i % nl

	style.Symbol = StandardSymbols[si]
	style.SymbolColor = StandardColors[ci]
	style.LineColor = StandardColors[ci]
	style.SymbolSize = 1

	if fill {
		style.LineStyle = SolidLine
		style.LineWidth = 3
		if i < nc {
			style.FillColor = lighter(style.LineColor, StandardFillFactor)
		} else if i <= 2*nc {
			style.FillColor = darker(style.LineColor, StandardFillFactor)
		} else {
			style.FillColor = style.LineColor
		}
	} else {
		style.LineStyle = StandardLineStyles[li]
		style.LineWidth = 1
	}
	return
}
853882
func colorize(s interface{}, c int, disabled bool) string {
	if disabled {
		return fmt.Sprintf("%s", s)
	}
	return fmt.Sprintf("\x1b[%dm%v\x1b[0m", c, s)
}
554828
func (me *DefaultAdapter) InsertColumnsSql(buf *SqlBuilder, cols ColumnList) error {
	buf.WriteRune(space_rune)
	buf.WriteRune(left_paren_rune)
	if err := me.Literal(buf, cols); err != nil {
		return err
	}
	buf.WriteRune(right_paren_rune)
	return nil
}
390601
func (s *Schema) ColumnsIndices(cols []*Column) (ret []int) {
	ret = make([]int, 0, len(cols))
	for _, col := range cols {
		pos := s.ColumnIndex(col)
		if pos != -1 {
			ret = append(ret, pos)
		} else {
			return nil
		}
	}
	return
}
1194519
func (inliner *Inliner) insertRawStylesheet() {
	rawCSS := inliner.computeRawCSS()
	if rawCSS != "" {
		// create <style> element
		cssNode := &html.Node{
			Type: html.TextNode,
			Data: "\n" + rawCSS,
		}

		styleNode := &html.Node{
			Type: html.ElementNode,
			Data: "style",
			Attr: []html.Attribute{{Key: "type", Val: "text/css"}},
		}

		styleNode.AppendChild(cssNode)

		// append to <head> element
		headNode := inliner.doc.Find("head")
		if headNode == nil {
			// @todo Create head node !
			panic("NOT IMPLEMENTED: create missing <head> node")
		}

		headNode.AppendNodes(styleNode)
	}
}
1034970
func (rows *OCI8Rows) Columns() []string {
	names := make([]string, len(rows.defines))
	for i, define := range rows.defines {
		names[i] = define.name
	}
	return names
}
120751
func ColorSubTable(target uint32, start int32, count int32, format uint32, xtype uint32, data unsafe.Pointer) {
	C.glowColorSubTable(gpColorSubTable, (C.GLenum)(target), (C.GLsizei)(start), (C.GLsizei)(count), (C.GLenum)(format), (C.GLenum)(xtype), data)
}
868577
func Colorizef(c Color, b BackgroundColor, format string, args ...interface{}) string {
	args = append([]interface{}{ResetColors, c, b}, args...)
	args = append(args, ResetColors)
	return fmt.Sprintf("%s%s%s"+format+"%s", args...)
}
311375
func (c *Columns) Add(names ...string) []*Column {
	var ret []*Column
	c.lock.Lock()

	tableAlias := c.TableAlias
	if tableAlias == "" {
		tableAlias = c.TableName
	}

	for _, name := range names {

		var xs []string
		var col *Column
		ss := ""
		//support for distinct xx, or distinct on (field) table.fields
		if strings.HasSuffix(name, ",r") || strings.HasSuffix(name, ",w") {
			xs = []string{name[0 : len(name)-2], name[len(name)-1:]}
		} else {
			xs = []string{name}
		}

		xs[0] = strings.TrimSpace(xs[0])
		//eg: id id2 - select id as id2
		// also distinct columnname
		// and distinct on (column1) column2
		if strings.Contains(strings.ToUpper(xs[0]), " AS ") {
			//eg: select id as id2
			i := strings.LastIndex(strings.ToUpper(xs[0]), " AS ")
			ss = xs[0]
			xs[0] = xs[0][i+4 : len(xs[0])] //get id2
		} else if strings.Contains(xs[0], " ") {
			i := strings.LastIndex(name, " ")
			ss = xs[0]
			xs[0] = xs[0][i+1 : len(xs[0])] //get id2
		}

		col = c.Cols[xs[0]]
		if col == nil {
			if ss == "" {
				ss = xs[0]
				if tableAlias != "" {
					ss = fmt.Sprintf("%s.%s", tableAlias, ss)
				}
			}

			col = &Column{
				Name:      xs[0],
				SelectSQL: ss,
				Readable:  true,
				Writeable: true,
			}

			if len(xs) > 1 {
				if xs[1] == "r" {
					col.Writeable = false
				} else if xs[1] == "w" {
					col.Readable = false
				}
			} else if col.Name == "id" {
				col.Writeable = false
			}

			c.Cols[col.Name] = col
		}
		ret = append(ret, col)
	}

	c.lock.Unlock()
	return ret
}
66795
func Colorize(x string) string {
	attr := 0
	fg := 39
	bg := 49

	for _, key := range x {
		c, ok := codeMap[int(key)]
		switch {
		case !ok:
			log.Printf("Wrong color syntax: %c", key)
		case 0 <= c && c <= 8:
			attr = c
		case 30 <= c && c <= 37:
			fg = c
		case 40 <= c && c <= 47:
			bg = c
		case c == 60:
			fg += c
		}
	}
	return fmt.Sprintf("\033[%d;%d;%dm", attr, fg, bg)
}
399139
func (c *Colorize) Color(v string) string {
	matches := parseRe.FindAllStringIndex(v, -1)
	if len(matches) == 0 {
		return v
	}

	result := new(bytes.Buffer)
	colored := false
	m := []int{0, 0}
	for _, nm := range matches {
		// Write the text in between this match and the last
		result.WriteString(v[m[1]:nm[0]])
		m = nm

		var replace string
		if code, ok := c.Colors[v[m[0]+1:m[1]-1]]; ok {
			colored = true

			if !c.Disable {
				replace = fmt.Sprintf("\033[%sm", code)
			}
		} else {
			replace = v[m[0]:m[1]]
		}

		result.WriteString(replace)
	}
	result.WriteString(v[m[1]:])

	if colored && c.Reset && !c.Disable {
		// Write the clear byte at the end
		result.WriteString("\033[0m")
	}

	return result.String()
}
995436
func (table *Table) AddMyColumn(col *Column) {
	table.myColumns = append(table.myColumns, col)
}
438961
func AddStatusCodes(codes ...int) Option {
	return func(c *options) error {
		dst := make(map[int]struct{}, len(c.statusCodes)+len(codes))
		for code := range c.statusCodes {
			dst[code] = struct{}{}
		}
		for _, code := range codes {
			c.statusCodes[code] = struct{}{}
		}
		return nil
	}
}
526670
func (fp *formatParser) setAnsiColor(name string) error {
	// If colors are not enabled then do not add strings in this function.
	if fp.color == false {
		return nil
	}
	if ansi, ok := ioOutputColorMap[name]; ok {
		fp.addStatic(ansi)
		return nil
	} else if name == "class" {
		// 10 bytes is a sane upper bound.
		fp.addFormatFunc(ioOutputFormatClassColor, 10)
		return nil
	}
	return fmt.Errorf("Unknown color name: %s", name)
}
821036
func (table *Table) AddColumn(col *Column) {
	table.columnsSeq = append(table.columnsSeq, col.Name)
	table.columns = append(table.columns, col)
	colName := strings.ToLower(col.Name)
	if c, ok := table.columnsMap[colName]; ok {
		table.columnsMap[colName] = append(c, col)
	} else {
		table.columnsMap[colName] = []*Column{col}
	}

	if col.IsPrimaryKey {
		table.PrimaryKeys = append(table.PrimaryKeys, col.Name)
	}
	if col.IsAutoIncrement {
		table.AutoIncrement = col.Name
	}
	if col.IsCreated {
		table.Created[col.Name] = true
	}
	if col.IsUpdated {
		table.Updated = col.Name
	}
	if col.IsDeleted {
		table.Deleted = col.Name
	}
	if col.IsVersion {
		table.Version = col.Name
	}
}