// toPos returns the relative position from the beginning of the string.
977763
func (r *Render) toPos(cursor int) (x, y int) {
	col := int(r.col)
	return cursor % col, cursor / col
}
905314
func (q *Quest) ToProto() *dm.Quest {
	return &dm.Quest{
		Id:   dm.NewQuestID(q.ID),
		Data: q.DataProto(),
	}
}
1237545
func ToGeo(x, y float64, level uint32) (lng, lat float64) {
	maxtiles := float64(uint32(1 << level))

	lng = 360.0 * (x/maxtiles - 0.5)
	lat = 2.0*math.Atan(math.Exp(math.Pi-(2*math.Pi)*(y/maxtiles)))*(180.0/math.Pi) - 90.0

	return lng, lat
}
396299
func ConvertToPod(obj interface{}) interface{} {
	pod, ok := obj.(*v1.Pod)
	if !ok {
		return nil
	}
	p := &types.Pod{
		TypeMeta:        pod.TypeMeta,
		ObjectMeta:      pod.ObjectMeta,
		StatusPodIP:     pod.Status.PodIP,
		StatusHostIP:    pod.Status.HostIP,
		SpecHostNetwork: pod.Spec.HostNetwork,
	}
	*pod = v1.Pod{}
	return p
}
1349928
func string_upper(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error) {
	if err := UnpackPositionalArgs(fnname, args, kwargs, 0); err != nil {
		return nil, err
	}
	return String(strings.ToUpper(string(recv.(String)))), nil
}
523221
func (t *Terminal) moveCursorToPos(pos int) {
	if !t.echo {
		return
	}

	x := visualLength(t.prompt) + pos
	y := x / t.termWidth
	x = x % t.termWidth

	up := 0
	if y < t.cursorY {
		up = t.cursorY - y
	}

	down := 0
	if y > t.cursorY {
		down = y - t.cursorY
	}

	left := 0
	if x < t.cursorX {
		left = t.cursorX - x
	}

	right := 0
	if x > t.cursorX {
		right = x - t.cursorX
	}

	t.cursorX = x
	t.cursorY = y
	t.move(up, down, left, right)
}
777326
func (et *EnableTable) ToProto() proto.Message {
	return &pb.EnableTableRequest{
		TableName: &pb.TableName{
			// TODO: handle namespaces
			Namespace: []byte("default"),
			Qualifier: et.table,
		},
	}
}
738876
func (s *Server) Get(ctx context.Context, filePath string) ([]byte, topo.Version, error) {
	nodePath := path.Join(s.root, filePath)

	resp, err := s.cli.Get(ctx, nodePath)
	if err != nil {
		return nil, nil, convertError(err, nodePath)
	}
	if len(resp.Kvs) != 1 {
		return nil, nil, topo.NewError(topo.NoNode, nodePath)
	}

	return resp.Kvs[0].Value, EtcdVersion(resp.Kvs[0].ModRevision), nil
}
810712
func (p *PhysicalTableScan) ToPB(ctx sessionctx.Context) (*tipb.Executor, error) {
	columns := p.Columns
	tsExec := &tipb.TableScan{
		TableId: p.Table.ID,
		Columns: model.ColumnsToProto(columns, p.Table.PKIsHandle),
		Desc:    p.Desc,
	}
	err := SetPBColumnsDefaultValue(ctx, tsExec.Columns, p.Columns)
	return &tipb.Executor{Tp: tipb.ExecType_TypeTableScan, TblScan: tsExec}, err
}
186964
func (L *State) ToPointer(index int) uintptr {
	return uintptr(C.lua_topointer(L.s, C.int(index)))
}
38393
func (dt *DisableTable) ToProto() proto.Message {
	return &pb.DisableTableRequest{
		TableName: &pb.TableName{
			// TODO: handle namespaces
			Namespace: []byte("default"),
			Qualifier: dt.table,
		},
	}
}
1250739
func (s *Device) SetOs(v string) *Device {
	s.Os = &v
	return s
}
1176641
func (fms *fileMetadataStore) getOS(layer ChainID) (string, error) {
	return runtime.GOOS, nil
}
1107329
func (s *ConfigService) GetTopMenus() (*[]TopMenuEntryInfo, *Response, error) {
	u := "config/server/top-menus"

	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	v := new([]TopMenuEntryInfo)
	resp, err := s.client.Do(req, v)
	if err != nil {
		return nil, resp, err
	}

	return v, resp, err
}
1014415
func getTopic(obj interface{}) (string, bool) {
	record, ok := obj.(*goavro.Record)
	if !ok {
		return "UNKNOWN_RECORD_TYPE", false
	}
	topicObj, err := record.Get("topic")
	if err != nil {
		return "UNKNOWN_TOPIC_VAL", false
	}
	topicStr, ok := topicObj.(string)
	if !ok {
		return "UNKNOWN_TOPIC_TYPE", false
	}
	return topicStr, true
}
295487
func (s *CreateInstanceInput) SetOs(v string) *CreateInstanceInput {
	s.Os = &v
	return s
}
321042
func (node *Node) StartPos() int {
	pFirstNode, _ := strconv.Atoi(fmt.Sprintf("%d", node.head.surface))
	pCurrentNode, _ := strconv.Atoi(fmt.Sprintf("%d", node.current.surface))
	return utf8.RuneCountInString(C.GoStringN(node.head.surface, C.int(pCurrentNode-pFirstNode)))
}