From 4893286e2696c3eb537cd2a26dcebeb4a96a20cf Mon Sep 17 00:00:00 2001 From: Alexander Trakhimenok Date: Thu, 8 Jan 2026 10:21:33 +0000 Subject: [PATCH 1/2] feat: new BoxedPrimitive interface implemented by *Box --- box.go | 5 +++ box_test.go | 89 ++++++++++++++++++++++++++++++++++++++++++++++ boxed_primitive.go | 8 +++++ 3 files changed, 102 insertions(+) create mode 100644 box_test.go create mode 100644 boxed_primitive.go diff --git a/box.go b/box.go index 5393dace..66f874cc 100644 --- a/box.go +++ b/box.go @@ -96,6 +96,11 @@ func NewBox() *Box { return b } +// GetBox returns the box itself implementing the BoxedPrimitive interface. +func (b *Box) GetBox() *Box { + return b +} + // SetBorderPadding sets the size of the borders around the box content. func (b *Box) SetBorderPadding(top, bottom, left, right int) *Box { b.paddingTop, b.paddingBottom, b.paddingLeft, b.paddingRight = top, bottom, left, right diff --git a/box_test.go b/box_test.go new file mode 100644 index 00000000..0d974b7c --- /dev/null +++ b/box_test.go @@ -0,0 +1,89 @@ +package tview + +import ( + "testing" +) + +func Test_GetBox(t *testing.T) { + for _, tt := range []struct { + name string + getBox func() (BoxedPrimitive, *Box) + }{ + {name: "Box", getBox: func() (BoxedPrimitive, *Box) { + box := NewBox() + return box, box + }}, + {name: "Button", getBox: func() (BoxedPrimitive, *Box) { + p := NewButton("Click me") + return p, p.Box + }}, + {name: "Checkbox", getBox: func() (BoxedPrimitive, *Box) { + p := NewCheckbox() + return p, p.Box + }}, + {name: "DropDown", getBox: func() (BoxedPrimitive, *Box) { + p := NewDropDown() + return p, p.Box + }}, + {name: "Flex", getBox: func() (BoxedPrimitive, *Box) { + p := NewFlex() + return p, p.Box + }}, + {name: "Form", getBox: func() (BoxedPrimitive, *Box) { + p := NewForm() + return p, p.Box + }}, + {name: "Frame", getBox: func() (BoxedPrimitive, *Box) { + p := NewFrame(NewTextView()) + return p, p.Box + }}, + {name: "Grid", getBox: func() (BoxedPrimitive, *Box) { + p := NewGrid() + return p, p.Box + }}, + {name: "Image", getBox: func() (BoxedPrimitive, *Box) { + p := NewImage() + return p, p.Box + }}, + {name: "InputField", getBox: func() (BoxedPrimitive, *Box) { + p := NewInputField() + return p, p.Box + }}, + {name: "List", getBox: func() (BoxedPrimitive, *Box) { + p := NewList() + return p, p.Box + }}, + {name: "Modal", getBox: func() (BoxedPrimitive, *Box) { + p := NewModal() + return p, p.Box + }}, + {name: "Pages", getBox: func() (BoxedPrimitive, *Box) { + p := NewPages() + return p, p.Box + }}, + {name: "Table", getBox: func() (BoxedPrimitive, *Box) { + p := NewTable() + return p, p.Box + }}, + {name: "TextArea()", getBox: func() (BoxedPrimitive, *Box) { + p := NewTextArea() + return p, p.Box + }}, + {name: "TextView", getBox: func() (BoxedPrimitive, *Box) { + p := NewTextView() + return p, p.Box + }}, + {name: "TreeView", getBox: func() (BoxedPrimitive, *Box) { + p := NewTextView() + return p, p.Box + }}, + } { + t.Run(tt.name, func(t *testing.T) { + primitive, box := tt.getBox() + actualBox := primitive.GetBox() + if actualBox != box { + t.Errorf("GetBox() got = %+v\nwant %+v", actualBox, box) + } + }) + } +} diff --git a/boxed_primitive.go b/boxed_primitive.go new file mode 100644 index 00000000..56751825 --- /dev/null +++ b/boxed_primitive.go @@ -0,0 +1,8 @@ +package tview + +// BoxedPrimitive defines a primitive with a Box +// It's implemented by Box and any type that has *Box field +type BoxedPrimitive interface { + Primitive + GetBox() *Box +} From ce27b59749b0f28da066390a4f3c3a36b8934a8c Mon Sep 17 00:00:00 2001 From: Alexander Trakhimenok Date: Fri, 27 Mar 2026 14:56:14 +0000 Subject: [PATCH 2/2] Add Claude Code post-edit hooks for Go (gofmt + golangci-lint) Co-Authored-By: Claude Opus 4.6 --- .claude/settings.json | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .claude/settings.json diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 00000000..c743b23f --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,21 @@ +{ + "hooks": { + "PostToolUse": [ + { + "matcher": "Write|Edit", + "hooks": [ + { + "type": "command", + "command": "jq -r '.tool_input.file_path' | { read -r f; case \"$f\" in *.go) gofmt -w \"$f\";; esac; } 2>/dev/null || true", + "statusMessage": "Running gofmt..." + }, + { + "type": "command", + "command": "jq -r '.tool_input.file_path' | { read -r f; case \"$f\" in *.go) output=$(golangci-lint run \"$f\" 2>&1); rc=$?; if [ $rc -ne 0 ]; then jq -n --arg ctx \"golangci-lint found issues in $f. Fix them:\\n$output\" '{\"hookSpecificOutput\":{\"hookEventName\":\"PostToolUse\",\"additionalContext\":$ctx}}'; exit $rc; fi;; esac; }", + "statusMessage": "Running golangci-lint..." + } + ] + } + ] + } +}