summaryrefslogtreecommitdiff
path: root/repo.test.go
blob: 5ce8476d7cd508ffce80ff3839c7056e8c310c2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT.
// This file was autogenerated with autogenpb v0.0.62 2025-03-02_09:17:00_UTC
//     go install go.wit.com/apps/autogenpb@latest
//
// define which structs (messages) you want to use in the .proto file
// Then sort.pb.go and marshal.pb.go files are autogenerated
//
// autogenpb uses it and has an example .proto file with instructions
//

package gitpb

import "go.wit.com/log"

/*
func (mt *ReposTable) Delete() {
	if mt == nil {
		log.Info("mt == nil table already deleted")
		return
	}
	log.Info("implement table Delete here")
	mt.parent.DeleteTable(mt.pb)
}
*/

func (mt *ReposTable) UpdateTable(pb *Repos) {
	// mt.parent.UpdateTable(pb)
}

func (mt *ReposTable) lookupByWidgetId(id int) *Repo {
	log.Info("no shit. got to lookupWidgdetId() id =", id, "on mt", mt.GetUuid())

	for _, r := range mt.pb.StringRows {
		for _, w := range r.Widgets {
			if int(w.Id) == id {
				log.Info("lookupByWidgetId() found id", id, w.Location)
				return mt.x.Repos[w.Location.Y - 1]
			}
		}
	}

	for _, r := range mt.pb.ButtonRows {
		for _, w := range r.Widgets {
			if int(w.Id) == id {
				log.Info("lookupByWidgetId() found id", id, w.Location)
				if w.Location == nil {
					log.Info("lookupByWidgetId() location was nil", id, w.Location)
					return nil
				}
				return mt.x.Repos[w.Location.Y - 1]
			}
		}
	}

	return nil
}

func (mt *ReposTable) reposCustom(id int) {
	repo := mt.lookupByWidgetId(id)
	mt.CustomFunc(repo)
}

func (mt *ReposTable) Custom(f func(*Repo)) {
	mt.pb.RegisterCustom(mt.reposCustom)
	mt.CustomFunc = f
}

//func (mt *ReposTable) CustomRegister(f func(int)) {
//	mt.pb.RegisterCustom(mt.reposCustom)
//}

func (mt *ReposTable) GetUuid() string {
	return mt.pb.Uuid
}

// END GUI