detached 4005fb8

refactor(daemon): define floating geometry coordinate boundary

commit
4005fb8e3312f486d713e24fea38a91f78fec05e
author
brice · · 2026-07-11 05:12 UTC
parent
5fcde4c
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +30 -3
M internal/usecase/daemon/floating_render.go +13 -3
@@ -8,7 +8,8 @@ import (
88 )
99
1010 // floatingGeometry describes a popup's outer frame and terminal content area.
11-// Bounds and Inner are both relative to the supplied content rectangle.
11+// Committed geometry is tab-content-relative; Bounds and Inner are both relative
12+// to the supplied content rectangle.
1213 type floatingGeometry struct {
1314 Bounds domain.Rect
1415 Inner domain.Rect
@@ -18,6 +19,14 @@ func (g floatingGeometry) valid() bool {
1819 return g.Bounds.Width > 0 && g.Bounds.Height > 0 && g.Inner.Width > 0 && g.Inner.Height > 0
1920 }
2021
22+func (g floatingGeometry) translate(dx, dy int) floatingGeometry {
23+ g.Bounds.X += dx
24+ g.Bounds.Y += dy
25+ g.Inner.X += dx
26+ g.Inner.Y += dy
27+ return g
28+}
29+
2130 // committedFloatingGeometryLocked returns the geometry whose PTY resize was
2231 // last committed. Newly constructed test panes fall back to the requested
2332 // geometry until their first resize. The caller holds p.mu.
@@ -47,8 +56,9 @@ func calculateFloatingAxisGeometry(available, percent int) floatingAxisGeometry
4756 return axis
4857 }
4958
50-// calculateFloatingGeometry centers a percentage-sized popup in content.
51-// Launch sizing derives from Inner too, so rendering and PTY geometry share
59+// calculateFloatingGeometry returns coordinates in the supplied rectangle's
60+// space and centers a percentage-sized popup in content. Launch sizing derives
61+// from Inner too, so rendering and PTY geometry share
5262 // the same per-axis percentage and tiny-border rules.
5363 func calculateFloatingGeometry(content domain.Rect, cfg domain.FloatingConfig) floatingGeometry {
5464 if content.Width <= 0 || content.Height <= 0 {
@@ -8,7 +8,8 @@ import (
8 )8 )
9 9
10 // floatingGeometry describes a popup's outer frame and terminal content area.10 // floatingGeometry describes a popup's outer frame and terminal content area.
11-// Bounds and Inner are both relative to the supplied content rectangle.11+// Committed geometry is tab-content-relative; Bounds and Inner are both relative
12+// to the supplied content rectangle.
12 type floatingGeometry struct {13 type floatingGeometry struct {
13 Bounds domain.Rect14 Bounds domain.Rect
14 Inner domain.Rect15 Inner domain.Rect
@@ -18,6 +19,14 @@ func (g floatingGeometry) valid() bool {
18 return g.Bounds.Width > 0 && g.Bounds.Height > 0 && g.Inner.Width > 0 && g.Inner.Height > 019 return g.Bounds.Width > 0 && g.Bounds.Height > 0 && g.Inner.Width > 0 && g.Inner.Height > 0
19 }20 }
20 21
22+func (g floatingGeometry) translate(dx, dy int) floatingGeometry {
23+ g.Bounds.X += dx
24+ g.Bounds.Y += dy
25+ g.Inner.X += dx
26+ g.Inner.Y += dy
27+ return g
28+}
29+
21 // committedFloatingGeometryLocked returns the geometry whose PTY resize was30 // committedFloatingGeometryLocked returns the geometry whose PTY resize was
22 // last committed. Newly constructed test panes fall back to the requested31 // last committed. Newly constructed test panes fall back to the requested
23 // geometry until their first resize. The caller holds p.mu.32 // geometry until their first resize. The caller holds p.mu.
@@ -47,8 +56,9 @@ func calculateFloatingAxisGeometry(available, percent int) floatingAxisGeometry
47 return axis56 return axis
48 }57 }
49 58
50-// calculateFloatingGeometry centers a percentage-sized popup in content.59+// calculateFloatingGeometry returns coordinates in the supplied rectangle's
51-// Launch sizing derives from Inner too, so rendering and PTY geometry share60+// space and centers a percentage-sized popup in content. Launch sizing derives
61+// from Inner too, so rendering and PTY geometry share
52 // the same per-axis percentage and tiny-border rules.62 // the same per-axis percentage and tiny-border rules.
53 func calculateFloatingGeometry(content domain.Rect, cfg domain.FloatingConfig) floatingGeometry {63 func calculateFloatingGeometry(content domain.Rect, cfg domain.FloatingConfig) floatingGeometry {
54 if content.Width <= 0 || content.Height <= 0 {64 if content.Width <= 0 || content.Height <= 0 {
M internal/usecase/daemon/floating_render_test.go +17 -0
@@ -14,6 +14,23 @@ import (
1414 "github.com/bnema/vev/pkg/renderer"
1515 )
1616
17+func TestFloatingGeometryTranslate(t *testing.T) {
18+ geometry := floatingGeometry{
19+ Bounds: domain.Rect{X: 3, Y: 5, Width: 10, Height: 8},
20+ Inner: domain.Rect{X: 4, Y: 6, Width: 8, Height: 6},
21+ }
22+
23+ translated := geometry.translate(11, 13)
24+ require.Equal(t, floatingGeometry{
25+ Bounds: domain.Rect{X: 14, Y: 18, Width: 10, Height: 8},
26+ Inner: domain.Rect{X: 15, Y: 19, Width: 8, Height: 6},
27+ }, translated)
28+ require.Equal(t, floatingGeometry{
29+ Bounds: domain.Rect{X: 3, Y: 5, Width: 10, Height: 8},
30+ Inner: domain.Rect{X: 4, Y: 6, Width: 8, Height: 6},
31+ }, geometry)
32+}
33+
1734 func TestCalculateFloatingGeometry(t *testing.T) {
1835 tests := []struct {
1936 name string
@@ -14,6 +14,23 @@ import (
14 "github.com/bnema/vev/pkg/renderer"14 "github.com/bnema/vev/pkg/renderer"
15 )15 )
16 16
17+func TestFloatingGeometryTranslate(t *testing.T) {
18+ geometry := floatingGeometry{
19+ Bounds: domain.Rect{X: 3, Y: 5, Width: 10, Height: 8},
20+ Inner: domain.Rect{X: 4, Y: 6, Width: 8, Height: 6},
21+ }
22+
23+ translated := geometry.translate(11, 13)
24+ require.Equal(t, floatingGeometry{
25+ Bounds: domain.Rect{X: 14, Y: 18, Width: 10, Height: 8},
26+ Inner: domain.Rect{X: 15, Y: 19, Width: 8, Height: 6},
27+ }, translated)
28+ require.Equal(t, floatingGeometry{
29+ Bounds: domain.Rect{X: 3, Y: 5, Width: 10, Height: 8},
30+ Inner: domain.Rect{X: 4, Y: 6, Width: 8, Height: 6},
31+ }, geometry)
32+}
33+
17 func TestCalculateFloatingGeometry(t *testing.T) {34 func TestCalculateFloatingGeometry(t *testing.T) {
18 tests := []struct {35 tests := []struct {
19 name string36 name string

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 12

Tags 11

↑↓ moveenter openesc close