ignore patch files

This commit is contained in:
Jeff Carr 2025-01-29 12:28:03 -06:00
parent 57fbbc62ed
commit 11465e4043
Notes: Jeff Carr 2025-01-29 13:11:20 -06:00
// `autogen:go.mod`

module go.wit.com/toolkits/gocui

go 1.21

toolchain go1.23.4

require (
	github.com/awesome-gocui/gocui v1.1.0
	go.wit.com/log v0.22.10
	go.wit.com/toolkits/tree v0.22.4
	go.wit.com/widget v1.1.27
	google.golang.org/protobuf v1.36.4
)

require (
	github.com/gdamore/encoding v1.0.0 // indirect
	github.com/gdamore/tcell/v2 v2.4.0 // indirect
	github.com/lucasb-eyer/go-colorful v1.0.3 // indirect
	github.com/mattn/go-runewidth v0.0.10 // indirect
	github.com/rivo/uniseg v0.1.0 // indirect
	golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 // indirect
	golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf // indirect
	golang.org/x/text v0.3.3 // indirect
)

// `autogen:go.sum`

github.com/awesome-gocui/gocui v1.1.0 h1:db2j7yFEoHZjpQFeE2xqiatS8bm1lO3THeLwE6MzOII=
github.com/awesome-gocui/gocui v1.1.0/go.mod h1:M2BXkrp7PR97CKnPRT7Rk0+rtswChPtksw/vRAESGpg=
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
github.com/gdamore/tcell/v2 v2.4.0 h1:W6dxJEmaxYvhICFoTY3WrLLEXsQ11SaFnKGVEXW57KM=
github.com/gdamore/tcell/v2 v2.4.0/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRRpdGg=
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
go.wit.com/log v0.22.10 h1:rlSgaYjvxbpcmi9UBQO3ESmbd/jiyFdRQFoGOvpCEUc=
go.wit.com/log v0.22.10/go.mod h1:4uNPFBqhsAh8zNF+zxVEmC3c/9AZ8JeTfUUvRpddvLQ=
go.wit.com/toolkits/tree v0.22.4 h1:yhefolodEfE4+Lmxxhh8fO6+UMjK9TGHuB71Lfg4rcQ=
go.wit.com/toolkits/tree v0.22.4/go.mod h1:b/GAcO13PIv7tx1aSrWv8ALK+ZEk5j78PEdEGaZ4PPA=
go.wit.com/widget v1.1.27 h1:Yd+qp6GZVwLiTTepShXSeWSDqjaCxLyfhU0ch2FrPZ8=
go.wit.com/widget v1.1.27/go.mod h1:OXIdWk7GhVJRLnHTvf45LbPNXGYG/JjbkfnmXtkoiYE=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf h1:MZ2shdL+ZM/XzY3ZGOnh4Nlpnxz5GSOhOmtHo3iPU6M=
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM=
google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=

// `autogen:view.marshal.pb.go`

// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT.
// This file was autogenerated with autogenpb v0.0.48 2025-01-28_20:32:42_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 main

import (
	"google.golang.org/protobuf/encoding/protojson"
	"google.golang.org/protobuf/encoding/prototext"
	"google.golang.org/protobuf/proto"
)

// human readable JSON
func (v *Views) FormatJSON() string {
	return protojson.Format(v)
}

// marshal json
func (v *Views) MarshalJSON() ([]byte, error) {
	return protojson.Marshal(v)
}

// unmarshal json
func (v *Views) UnmarshalJSON(data []byte) error {
	return protojson.Unmarshal(data, v)
}

// apparently this isn't stable, but it's awesomely better
// https://protobuf.dev/reference/go/faq/#unstable-text
// it's brilliant for config files!
func (v *Views) FormatTEXT() string {
	v.fixUuid()
	return prototext.Format(v)
}

// unmarshalTEXT. This reads the .text config file back in after the user edits it
func (v *Views) UnmarshalTEXT(data []byte) error {
	return prototext.Unmarshal(data, v)
}

// marshal to wire. This is called winning.
func (v *Views) Marshal() ([]byte, error) {
	v.fixUuid()
	return proto.Marshal(v)
}

// unmarshal from wire. You have won.
func (v *Views) Unmarshal(data []byte) error {
	return proto.Unmarshal(data, v)
}

// `autogen:view.pb.go`

// Code modified by go.wit.com/apps/autogenpb DO NOT EDIT.
//
// user defined Mutex locks were auto added
//
// autogenpb version & build time: v0.0.48 2025-01-28_20:32:42_UTC
// autogenpb auto generates Sort(), Unique() and Marshal() functions
//     go install go.wit.com/apps/autogenpb@latest

// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// 	protoc-gen-go v1.35.2-devel
// 	protoc        v3.21.12
// source: view.proto

package main // autogenpb changed the package name

import (
	reflect "reflect"
	sync "sync"

	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
	_ "google.golang.org/protobuf/types/known/timestamppb"
)

const (
	// Verify that this generated code is sufficiently up-to-date.
	_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
	// Verify that runtime/protoimpl is sufficiently up-to-date.
	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)

// maybe put all the gocui specific stuff here.
type GocuiState struct {
	// sync.RWMutex // skipped. protobuf file has `autogenpb:nomutex`

	state         protoimpl.MessageState
	sizeCache     protoimpl.SizeCache
	unknownFields protoimpl.UnknownFields

	Visible  bool  `protobuf:"varint,1,opt,name=visible,proto3" json:"visible,omitempty"`
	Internal bool  `protobuf:"varint,2,opt,name=internal,proto3" json:"internal,omitempty"`
	W0       int64 `protobuf:"varint,3,opt,name=w0,proto3" json:"w0,omitempty"`
	H0       int64 `protobuf:"varint,4,opt,name=h0,proto3" json:"h0,omitempty"`
	W1       int64 `protobuf:"varint,5,opt,name=w1,proto3" json:"w1,omitempty"`
	H1       int64 `protobuf:"varint,6,opt,name=h1,proto3" json:"h1,omitempty"`
}

func (x *GocuiState) Reset() {
	*x = GocuiState{}
	mi := &file_view_proto_msgTypes[0]
	ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
	ms.StoreMessageInfo(mi)
}

func (x *GocuiState) String() string {
	return protoimpl.X.MessageStringOf(x)
}

func (*GocuiState) ProtoMessage() {}

func (x *GocuiState) ProtoReflect() protoreflect.Message {
	mi := &file_view_proto_msgTypes[0]
	if x != nil {
		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
		if ms.LoadMessageInfo() == nil {
			ms.StoreMessageInfo(mi)
		}
		return ms
	}
	return mi.MessageOf(x)
}

// Deprecated: Use GocuiState.ProtoReflect.Descriptor instead.
func (*GocuiState) Descriptor() ([]byte, []int) {
	return file_view_proto_rawDescGZIP(), []int{0}
}

func (x *GocuiState) GetVisible() bool {
	if x != nil {
		return x.Visible
	}
	return false
}

func (x *GocuiState) GetInternal() bool {
	if x != nil {
		return x.Internal
	}
	return false
}

func (x *GocuiState) GetW0() int64 {
	if x != nil {
		return x.W0
	}
	return 0
}

func (x *GocuiState) GetH0() int64 {
	if x != nil {
		return x.H0
	}
	return 0
}

func (x *GocuiState) GetW1() int64 {
	if x != nil {
		return x.W1
	}
	return 0
}

func (x *GocuiState) GetH1() int64 {
	if x != nil {
		return x.H1
	}
	return 0
}

type ViewSettings struct {
	// sync.RWMutex // skipped. protobuf file has `autogenpb:nomutex`

	state         protoimpl.MessageState
	sizeCache     protoimpl.SizeCache
	unknownFields protoimpl.UnknownFields

	Pack      bool  `protobuf:"varint,1,opt,name=pack,proto3" json:"pack,omitempty"`
	Framesize int64 `protobuf:"varint,5,opt,name=framesize,proto3" json:"framesize,omitempty"`
}

func (x *ViewSettings) Reset() {
	*x = ViewSettings{}
	mi := &file_view_proto_msgTypes[1]
	ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
	ms.StoreMessageInfo(mi)
}

func (x *ViewSettings) String() string {
	return protoimpl.X.MessageStringOf(x)
}

func (*ViewSettings) ProtoMessage() {}

func (x *ViewSettings) ProtoReflect() protoreflect.Message {
	mi := &file_view_proto_msgTypes[1]
	if x != nil {
		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
		if ms.LoadMessageInfo() == nil {
			ms.StoreMessageInfo(mi)
		}
		return ms
	}
	return mi.MessageOf(x)
}

// Deprecated: Use ViewSettings.ProtoReflect.Descriptor instead.
func (*ViewSettings) Descriptor() ([]byte, []int) {
	return file_view_proto_rawDescGZIP(), []int{1}
}

func (x *ViewSettings) GetPack() bool {
	if x != nil {
		return x.Pack
	}
	return false
}

func (x *ViewSettings) GetFramesize() int64 {
	if x != nil {
		return x.Framesize
	}
	return 0
}

type Tree struct {
	sync.RWMutex // auto-added by go.wit.com/apps/autogenpb

	state         protoimpl.MessageState
	sizeCache     protoimpl.SizeCache
	unknownFields protoimpl.UnknownFields

	Parent   *View   `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"`
	Children []*View `protobuf:"bytes,2,rep,name=children,proto3" json:"children,omitempty"`
	Node     *View   `protobuf:"bytes,3,opt,name=node,proto3" json:"node,omitempty"`
}

func (x *Tree) Reset() {
	*x = Tree{}
	mi := &file_view_proto_msgTypes[2]
	ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
	ms.StoreMessageInfo(mi)
}

func (x *Tree) String() string {
	return protoimpl.X.MessageStringOf(x)
}

func (*Tree) ProtoMessage() {}

func (x *Tree) ProtoReflect() protoreflect.Message {
	mi := &file_view_proto_msgTypes[2]
	if x != nil {
		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
		if ms.LoadMessageInfo() == nil {
			ms.StoreMessageInfo(mi)
		}
		return ms
	}
	return mi.MessageOf(x)
}

// Deprecated: Use Tree.ProtoReflect.Descriptor instead.
func (*Tree) Descriptor() ([]byte, []int) {
	return file_view_proto_rawDescGZIP(), []int{2}
}

func (x *Tree) GetParent() *View {
	if x != nil {
		return x.Parent
	}
	return nil
}

func (x *Tree) GetChildren() []*View {
	if x != nil {
		return x.Children
	}
	return nil
}

func (x *Tree) GetNode() *View {
	if x != nil {
		return x.Node
	}
	return nil
}

// this is the gocui 'view' in binary tree form
type View struct {
	sync.RWMutex // auto-added by go.wit.com/apps/autogenpb

	state         protoimpl.MessageState
	sizeCache     protoimpl.SizeCache
	unknownFields protoimpl.UnknownFields

	WidgetId int64       `protobuf:"varint,3,opt,name=widgetId,proto3" json:"widgetId,omitempty"` // `autogenpb:unique` `autogenpb:sort`
	Name     string      `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"`          // `autogenpb:unique` `autogenpb:sort`
	State    *GocuiState `protobuf:"bytes,7,opt,name=state,proto3" json:"state,omitempty"`
}

func (x *View) Reset() {
	*x = View{}
	mi := &file_view_proto_msgTypes[3]
	ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
	ms.StoreMessageInfo(mi)
}

func (x *View) String() string {
	return protoimpl.X.MessageStringOf(x)
}

func (*View) ProtoMessage() {}

func (x *View) ProtoReflect() protoreflect.Message {
	mi := &file_view_proto_msgTypes[3]
	if x != nil {
		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
		if ms.LoadMessageInfo() == nil {
			ms.StoreMessageInfo(mi)
		}
		return ms
	}
	return mi.MessageOf(x)
}

// Deprecated: Use View.ProtoReflect.Descriptor instead.
func (*View) Descriptor() ([]byte, []int) {
	return file_view_proto_rawDescGZIP(), []int{3}
}

func (x *View) GetWidgetId() int64 {
	if x != nil {
		return x.WidgetId
	}
	return 0
}

func (x *View) GetName() string {
	if x != nil {
		return x.Name
	}
	return ""
}

func (x *View) GetState() *GocuiState {
	if x != nil {
		return x.State
	}
	return nil
}

type Views struct {
	sync.RWMutex // auto-added by go.wit.com/apps/autogenpb

	state         protoimpl.MessageState
	sizeCache     protoimpl.SizeCache
	unknownFields protoimpl.UnknownFields

	Uuid     string            `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"`       // `autogenpb:uuid:d19c1fbb-32c2-4957-aee6-f8128a511dca`
	Version  string            `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` // `autogenpb:version:v0.0.1`
	Views    []*View           `protobuf:"bytes,3,rep,name=Views,proto3" json:"Views,omitempty"`
	Tree     *Tree             `protobuf:"bytes,4,opt,name=tree,proto3" json:"tree,omitempty"`
	Junk     map[string]string `protobuf:"bytes,5,rep,name=junk,proto3" json:"junk,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
	Settings *ViewSettings     `protobuf:"bytes,6,opt,name=settings,proto3" json:"settings,omitempty"`
}

func (x *Views) Reset() {
	*x = Views{}
	mi := &file_view_proto_msgTypes[4]
	ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
	ms.StoreMessageInfo(mi)
}

func (x *Views) String() string {
	return protoimpl.X.MessageStringOf(x)
}

func (*Views) ProtoMessage() {}

func (x *Views) ProtoReflect() protoreflect.Message {
	mi := &file_view_proto_msgTypes[4]
	if x != nil {
		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
		if ms.LoadMessageInfo() == nil {
			ms.StoreMessageInfo(mi)
		}
		return ms
	}
	return mi.MessageOf(x)
}

// Deprecated: Use Views.ProtoReflect.Descriptor instead.
func (*Views) Descriptor() ([]byte, []int) {
	return file_view_proto_rawDescGZIP(), []int{4}
}

func (x *Views) GetUuid() string {
	if x != nil {
		return x.Uuid
	}
	return ""
}

func (x *Views) GetVersion() string {
	if x != nil {
		return x.Version
	}
	return ""
}

func (x *Views) GetViews() []*View {
	if x != nil {
		return x.Views
	}
	return nil
}

func (x *Views) GetTree() *Tree {
	if x != nil {
		return x.Tree
	}
	return nil
}

func (x *Views) GetJunk() map[string]string {
	if x != nil {
		return x.Junk
	}
	return nil
}

func (x *Views) GetSettings() *ViewSettings {
	if x != nil {
		return x.Settings
	}
	return nil
}

var File_view_proto protoreflect.FileDescriptor

var file_view_proto_rawDesc = []byte{
	0x0a, 0x0a, 0x76, 0x69, 0x65, 0x77, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x6d, 0x61,
	0x69, 0x6e, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
	0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72,
	0x6f, 0x74, 0x6f, 0x22, 0x82, 0x01, 0x0a, 0x0a, 0x47, 0x6f, 0x63, 0x75, 0x69, 0x53, 0x74, 0x61,
	0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x18, 0x01, 0x20,
	0x01, 0x28, 0x08, 0x52, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x12, 0x1a, 0x0a, 0x08,
	0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08,
	0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x77, 0x30, 0x18, 0x03,
	0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x77, 0x30, 0x12, 0x0e, 0x0a, 0x02, 0x68, 0x30, 0x18, 0x04,
	0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x68, 0x30, 0x12, 0x0e, 0x0a, 0x02, 0x77, 0x31, 0x18, 0x05,
	0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x77, 0x31, 0x12, 0x0e, 0x0a, 0x02, 0x68, 0x31, 0x18, 0x06,
	0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x68, 0x31, 0x22, 0x40, 0x0a, 0x0c, 0x56, 0x69, 0x65, 0x77,
	0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x63, 0x6b,
	0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x70, 0x61, 0x63, 0x6b, 0x12, 0x1c, 0x0a, 0x09,
	0x66, 0x72, 0x61, 0x6d, 0x65, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52,
	0x09, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x73, 0x69, 0x7a, 0x65, 0x22, 0x72, 0x0a, 0x04, 0x54, 0x72,
	0x65, 0x65, 0x12, 0x22, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01,
	0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x56, 0x69, 0x65, 0x77, 0x52, 0x06,
	0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x26, 0x0a, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72,
	0x65, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e,
	0x56, 0x69, 0x65, 0x77, 0x52, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x12, 0x1e,
	0x0a, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x6d,
	0x61, 0x69, 0x6e, 0x2e, 0x56, 0x69, 0x65, 0x77, 0x52, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x22, 0x5e,
	0x0a, 0x04, 0x56, 0x69, 0x65, 0x77, 0x12, 0x1a, 0x0a, 0x08, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74,
	0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x77, 0x69, 0x64, 0x67, 0x65, 0x74,
	0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09,
	0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18,
	0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x47, 0x6f, 0x63,
	0x75, 0x69, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x22, 0x8b,
	0x02, 0x0a, 0x05, 0x56, 0x69, 0x65, 0x77, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64,
	0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07,
	0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76,
	0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x0a, 0x05, 0x56, 0x69, 0x65, 0x77, 0x73, 0x18,
	0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x56, 0x69, 0x65,
	0x77, 0x52, 0x05, 0x56, 0x69, 0x65, 0x77, 0x73, 0x12, 0x1e, 0x0a, 0x04, 0x74, 0x72, 0x65, 0x65,
	0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x54, 0x72,
	0x65, 0x65, 0x52, 0x04, 0x74, 0x72, 0x65, 0x65, 0x12, 0x29, 0x0a, 0x04, 0x6a, 0x75, 0x6e, 0x6b,
	0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x56, 0x69,
	0x65, 0x77, 0x73, 0x2e, 0x4a, 0x75, 0x6e, 0x6b, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x6a,
	0x75, 0x6e, 0x6b, 0x12, 0x2e, 0x0a, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18,
	0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x56, 0x69, 0x65,
	0x77, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69,
	0x6e, 0x67, 0x73, 0x1a, 0x37, 0x0a, 0x09, 0x4a, 0x75, 0x6e, 0x6b, 0x45, 0x6e, 0x74, 0x72, 0x79,
	0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b,
	0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
	0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x62, 0x06, 0x70, 0x72,
	0x6f, 0x74, 0x6f, 0x33,
}

var (
	file_view_proto_rawDescOnce sync.Once
	file_view_proto_rawDescData = file_view_proto_rawDesc
)

func file_view_proto_rawDescGZIP() []byte {
	file_view_proto_rawDescOnce.Do(func() {
		file_view_proto_rawDescData = protoimpl.X.CompressGZIP(file_view_proto_rawDescData)
	})
	return file_view_proto_rawDescData
}

var file_view_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_view_proto_goTypes = []any{
	(*GocuiState)(nil),   // 0: main.GocuiState
	(*ViewSettings)(nil), // 1: main.ViewSettings
	(*Tree)(nil),         // 2: main.Tree
	(*View)(nil),         // 3: main.View
	(*Views)(nil),        // 4: main.Views
	nil,                  // 5: main.Views.JunkEntry
}
var file_view_proto_depIdxs = []int32{
	3, // 0: main.Tree.parent:type_name -> main.View
	3, // 1: main.Tree.children:type_name -> main.View
	3, // 2: main.Tree.node:type_name -> main.View
	0, // 3: main.View.state:type_name -> main.GocuiState
	3, // 4: main.Views.Views:type_name -> main.View
	2, // 5: main.Views.tree:type_name -> main.Tree
	5, // 6: main.Views.junk:type_name -> main.Views.JunkEntry
	1, // 7: main.Views.settings:type_name -> main.ViewSettings
	8, // [8:8] is the sub-list for method output_type
	8, // [8:8] is the sub-list for method input_type
	8, // [8:8] is the sub-list for extension type_name
	8, // [8:8] is the sub-list for extension extendee
	0, // [0:8] is the sub-list for field type_name
}

func init() { file_view_proto_init() }
func file_view_proto_init() {
	if File_view_proto != nil {
		return
	}
	type x struct{}
	out := protoimpl.TypeBuilder{
		File: protoimpl.DescBuilder{
			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
			RawDescriptor: file_view_proto_rawDesc,
			NumEnums:      0,
			NumMessages:   6,
			NumExtensions: 0,
			NumServices:   0,
		},
		GoTypes:           file_view_proto_goTypes,
		DependencyIndexes: file_view_proto_depIdxs,
		MessageInfos:      file_view_proto_msgTypes,
	}.Build()
	File_view_proto = out.File
	file_view_proto_rawDesc = nil
	file_view_proto_goTypes = nil
	file_view_proto_depIdxs = nil
}

// `autogen:view.sort.pb.go`

// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT.
// This file was autogenerated with autogenpb v0.0.48 2025-01-28_20:32:42_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 main

import (
	"fmt"
	"sort"
	"sync"
)

// a simple global lock
var viewMu sync.RWMutex

func (x *Views) fixUuid() {
	if x == nil {
		return
	}
	if x.Uuid == "d19c1fbb-32c2-4957-aee6-f8128a511dca" {
		return
	}
	x.Uuid = "d19c1fbb-32c2-4957-aee6-f8128a511dca"
	x.Version = "v0.0.1 go.wit.com/toolkits/gocui"
}

func NewViews() *Views {
	x := new(Views)
	x.Uuid = "d19c1fbb-32c2-4957-aee6-f8128a511dca"
	x.Version = "v0.0.1 go.wit.com/toolkits/gocui"
	return x
}

// START SORT

// DEFINE THE Views ITERATOR.
// itializes a new iterator.
func newViewsIterator(things []*Views) *ViewsIterator {
	return &ViewsIterator{things: things}
}

type ViewsIterator struct {
	sync.RWMutex // this isn't getting used properly yet?

	things []*Views
	index  int
}

func (it *ViewsIterator) Scan() bool {
	if it.index >= len(it.things) {
		return false
	}
	it.index++
	return true
}

// Next() returns the next thing in the array
func (it *ViewsIterator) Next() *Views {
	if it.things[it.index-1] == nil {
		fmt.Println("Next() error in ViewsIterator", it.index)
	}
	return it.things[it.index-1]
}

// END DEFINE THE ITERATOR

// DEFINE THE View ITERATOR.
// itializes a new iterator.
func newViewIterator(things []*View) *ViewIterator {
	return &ViewIterator{things: things}
}

type ViewIterator struct {
	sync.RWMutex // this isn't getting used properly yet?

	things []*View
	index  int
}

func (it *ViewIterator) Scan() bool {
	if it.index >= len(it.things) {
		return false
	}
	it.index++
	return true
}

// Next() returns the next thing in the array
func (it *ViewIterator) Next() *View {
	if it.things[it.index-1] == nil {
		fmt.Println("Next() error in ViewIterator", it.index)
	}
	return it.things[it.index-1]
}

// END DEFINE THE ITERATOR

// DEFINE THE GocuiState ITERATOR.
// itializes a new iterator.
func newGocuiStateIterator(things []*GocuiState) *GocuiStateIterator {
	return &GocuiStateIterator{things: things}
}

type GocuiStateIterator struct {
	sync.RWMutex // this isn't getting used properly yet?

	things []*GocuiState
	index  int
}

func (it *GocuiStateIterator) Scan() bool {
	if it.index >= len(it.things) {
		return false
	}
	it.index++
	return true
}

// Next() returns the next thing in the array
func (it *GocuiStateIterator) Next() *GocuiState {
	if it.things[it.index-1] == nil {
		fmt.Println("Next() error in GocuiStateIterator", it.index)
	}
	return it.things[it.index-1]
}

// END DEFINE THE ITERATOR

// DEFINE THE ViewSettings ITERATOR.
// itializes a new iterator.
func newViewSettingsIterator(things []*ViewSettings) *ViewSettingsIterator {
	return &ViewSettingsIterator{things: things}
}

type ViewSettingsIterator struct {
	sync.RWMutex // this isn't getting used properly yet?

	things []*ViewSettings
	index  int
}

func (it *ViewSettingsIterator) Scan() bool {
	if it.index >= len(it.things) {
		return false
	}
	it.index++
	return true
}

// Next() returns the next thing in the array
func (it *ViewSettingsIterator) Next() *ViewSettings {
	if it.things[it.index-1] == nil {
		fmt.Println("Next() error in ViewSettingsIterator", it.index)
	}
	return it.things[it.index-1]
}

// END DEFINE THE ITERATOR

// DEFINE THE Tree ITERATOR.
// itializes a new iterator.
func newTreeIterator(things []*Tree) *TreeIterator {
	return &TreeIterator{things: things}
}

type TreeIterator struct {
	sync.RWMutex // this isn't getting used properly yet?

	things []*Tree
	index  int
}

func (it *TreeIterator) Scan() bool {
	if it.index >= len(it.things) {
		return false
	}
	it.index++
	return true
}

// Next() returns the next thing in the array
func (it *TreeIterator) Next() *Tree {
	if it.things[it.index-1] == nil {
		fmt.Println("Next() error in TreeIterator", it.index)
	}
	return it.things[it.index-1]
}

// END DEFINE THE ITERATOR

// sort struct by Name
type ViewName []*View

func (a ViewName) Len() int           { return len(a) }
func (a ViewName) Less(i, j int) bool { return a[i].Name < a[j].Name }
func (a ViewName) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// safely returns a slice of pointers to the FRUIT protobufs
func (x *Views) allViews() []*View {
	x.RLock()
	defer x.RUnlock()

	// Create a new slice to hold pointers to each FRUIT
	var tmp []*View
	tmp = make([]*View, len(x.Views))
	for i, p := range x.Views {
		tmp[i] = p // Copy pointers for safe iteration
	}

	return tmp
}

// safely returns a slice of pointers to the FRUIT protobufs
func (x *Tree) allChildren() []*View {
	x.RLock()
	defer x.RUnlock()

	// Create a new slice to hold pointers to each FRUIT
	var tmp []*View
	tmp = make([]*View, len(x.Children))
	for i, p := range x.Children {
		tmp[i] = p // Copy pointers for safe iteration
	}

	return tmp
}

// safely returns a slice of pointers to the View protobufs
func (x *Views) selectAllViews() []*View {
	x.RLock()
	defer x.RUnlock()

	// Create a new slice to hold pointers to each View
	var tmp []*View
	tmp = make([]*View, len(x.Views))
	for i, p := range x.Views {
		tmp[i] = p // Copy pointers for safe iteration
	}

	return tmp
}

// safely returns a slice of pointers to the View protobufs
func (x *Tree) selectAllChildren() []*View {
	x.RLock()
	defer x.RUnlock()

	// Create a new slice to hold pointers to each View
	var tmp []*View
	tmp = make([]*View, len(x.Children))
	for i, p := range x.Children {
		tmp[i] = p // Copy pointers for safe iteration
	}

	return tmp
}
func (x *Views) SortByName() *ViewIterator {
	// copy the pointers as fast as possible.
	things := x.selectAllViews()

	// todo: try slices.SortFunc() instead to see what happens
	sort.Sort(ViewName(things))
	//    slices.SortFunc(things, func(a, b *Views) bool {
	//        return a.Name < b.Name // Sort by ??. let the compiler work it out??
	//    })
	return newViewIterator(things)
}

// END SORT

func (x *Views) Len() int {
	x.RLock()
	defer x.RUnlock()

	return len(x.Views)
}

// just a simple Append() shortcut (but still uses the mutex lock)
func (x *Views) Append(y *View) {
	x.Lock()
	defer x.Unlock()

	x.Views = append(x.Views, y)
}

func (x *Views) All() *ViewIterator {
	ViewPointers := x.selectAllViews()

	iterator := newViewIterator(ViewPointers)
	return iterator
}

func (x *Views) Delete(y *View) bool {
	x.Lock()
	defer x.Unlock()

	for i, _ := range x.Views {
		if x.Views[i] == y {
			x.Views[i] = x.Views[len(x.Views)-1]
			x.Views = x.Views[:len(x.Views)-1]
			return true
		}
	}
	return false
}

// lookup a Views by the  Name
func (x *Views) FindByName(s string) *View {
	if x == nil {
		return nil
	}

	x.RLock()
	defer x.RUnlock()

	for i, _ := range x.Views {
		if x.Views[i].Name == s {
			return x.Views[i]
		}
	}
	return nil
}

func (x *Views) DeleteByName(s string) bool {
	x.Lock()
	defer x.Unlock()

	for i, _ := range x.Views {
		if x.Views[i].Name == s {
			x.Views[i] = x.Views[len(x.Views)-1]
			x.Views = x.Views[:len(x.Views)-1]
			return true
		}
	}
	return false
}

func (x *Views) AppendByName(y *View) bool {
	x.Lock()
	defer x.Unlock()

	for _, p := range x.Views {
		if p.Name == y.Name {
			return false
		}
	}

	x.Views = append(x.Views, y)
	return true
}

// `autogen:`
2 changed files with 2 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
*.swp
*.so
*.pb.go
*.patch
go.mod
go.sum
gocui

View File

@ -20,7 +20,7 @@ custom:
clean:
rm -f gocui gocui.so
rm -f *.pb.go
rm -f *.pb.go *.patch
go-mod-clean --purge
# Test the README.md & doc.go file