feat(layout): implement right-growth 2xK grid layout engine in lib_py.layout and refactor lib.sh (B-20)

This commit is contained in:
2026-08-23 19:54:03 +09:00
parent 82eecfda24
commit 6e2e9b1161
5 changed files with 644 additions and 33 deletions
+4 -30
View File
@@ -428,36 +428,10 @@ except Exception:
split_dir=""
if [ -n "$sample_pane" ]; then
split_dir=$(_real_herdr pane layout --pane "$sample_pane" 2>/dev/null | MAM_MIN_COLS="${MAM_MIN_PANE_COLS:-60}" MAM_MIN_ROWS="${MAM_MIN_PANE_ROWS:-20}" python3 -c "
import sys, json, os
min_cols = int(os.environ.get('MAM_MIN_COLS', 60))
min_rows = int(os.environ.get('MAM_MIN_ROWS', 20))
try:
d = json.loads(sys.stdin.read()).get('result', {})
focused_id = d.get('focused_pane_id', '')
panes = d.get('panes', [])
anchor = None
for p in panes:
if p.get('pane_id') == focused_id:
anchor = p.get('rect', {})
break
if not anchor and panes:
anchor = panes[0].get('rect', {})
if anchor:
w = anchor.get('width', 0)
h = anchor.get('height', 0)
if w <= 0 or h <= 0:
# Headless or detached session with unmeasured/zero dimensions
print('right')
elif w // 2 >= min_cols:
print('right')
elif h // 2 >= min_rows:
print('down')
else:
print('overflow')
except Exception:
pass
" 2>/dev/null || echo "")
layout_raw=$(_real_herdr pane layout --pane "$sample_pane" 2>/dev/null || echo "")
read -r split_dir split_target < <(printf '%s' "$layout_raw" | python3 -m lib_py.layout --min-cols "${MAM_MIN_PANE_COLS:-60}" --min-rows "${MAM_MIN_PANE_ROWS:-20}" --sample-pane "$sample_pane" 2>/dev/null || echo "right $sample_pane")
split_dir="${split_dir:-right}"
sample_pane="${split_target:-$sample_pane}"
fi
if [ "$split_dir" = "right" ] || [ "$split_dir" = "down" ]; then