surshar / claude-code
Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.
Built by Anthropic · github.com/anthropics
| 1 | import type PaneState from '../../../pane-state' |
| 2 | import type { BodyLayout, DockPlan } from '../types' |
| 3 | import Segments from './segments' |
| 4 | |
| 5 | /** |
| 6 | * The docked pane's scrolling body laid out under its pinned rows: the |
| 7 | * segments and their rows, the window's rows, the files' and list's rows. |
| 8 | * |
| 9 | * The pinned rows are counted as sidebarPane draws them (header, base or |
| 10 | * turn line, todo bar, list block); read from the box last drawn (`place`), |
| 11 | * so before any draw the window shows nothing and the top stays 0. |
| 12 | * |
| 13 | * @param model the pane's state |
| 14 | * @param plan the docked pane's decisions over that state |
| 15 | * @returns the layout |
| 16 | */ |
| 17 | export function bodyLayoutOf( |
| 18 | model: PaneState.PaneModel, |
| 19 | plan: DockPlan, |
| 20 | ): BodyLayout { |
| 21 | const segments = Segments.segmentsOf(model, plan) |
| 22 | const window = Segments.listWindowOf(model, plan) |
| 23 | const hasNoise = !plan.turn && plan.partition.noiseCount > 0 |
| 24 | const isListed = plan.message.length === 0 |
| 25 | const hasList = isListed && (plan.rows.length > 0 || hasNoise) |
| 26 | |
| 27 | const listRows = hasList |
| 28 | ? window.shown.length + |
| 29 | Number(window.above > 0) + |
| 30 | Number(window.below > 0 || plan.totals.notShown > 0) + |
| 31 | Number(plan.isUntrackedNoted) + |
| 32 | Number(hasNoise) + |
| 33 | 2 |
| 34 | : Number(isListed) |
| 35 | |
| 36 | const headRows = |
| 37 | 1 + Number(plan.line !== null) + (model.todos.total > 0 ? 2 : 0) |
| 38 | |
| 39 | const tops = new Map<string, number>() |
| 40 | |
| 41 | const visibleRows = Math.max(0, model.place.rows - headRows - listRows) |
| 42 | |
| 43 | let extent = 0 |
| 44 | |
| 45 | for (const segment of segments) { |
| 46 | if (segment.kind === 'rule' && segment.path !== null) { |
| 47 | tops.set(segment.path, extent) |
| 48 | } |
| 49 | |
| 50 | extent += Segments.segmentRowsOf(segment) |
| 51 | } |
| 52 | |
| 53 | const listTop = headRows + 1 |
| 54 | |
| 55 | return { |
| 56 | segments, |
| 57 | extent, |
| 58 | visibleRows, |
| 59 | maxTop: Math.max(0, extent - visibleRows), |
| 60 | tops, |
| 61 | listTop, |
| 62 | listEnd: hasList ? listTop + listRows - 2 : listTop, |
| 63 | } |
| 64 | } |