@@ -44,6 +44,9 @@ import {
4444 historyBand ,
4545 HISTORY_ROWS ,
4646 inspectionWidth ,
47+ paneColumnProps ,
48+ paneContentProps ,
49+ paneProps ,
4750 NARROW ,
4851 profileFor ,
4952 refusalProps ,
@@ -70,7 +73,7 @@ import {
7073 scrolled ,
7174} from "./layout-admission.ts" ;
7275import type { ReplAdmission , ReplWindow } from "./layout-admission.ts" ;
73- import { ORDINARY , styleOf } from "./presentation-style.ts" ;
76+ import { ORDINARY , REPL_PALETTE , styleOf } from "./presentation-style.ts" ;
7477import type { ReplRowStyle } from "./presentation-style.ts" ;
7578import type { ReplTerminalSize } from "./terminal.ts" ;
7679import {
@@ -1975,12 +1978,17 @@ function fitted(width: number, parts: readonly GuidancePart[]): string {
19751978 * What never moves is the order: the state, then what focus actually does, then
19761979 * the way out, then movement.
19771980 */
1978- function guidance ( view : ReplView ) : string {
1981+ function guidance ( view : ReplView , room : number ) : string {
19791982 const focused = view . focused ;
19801983 const modal = view . selection . drawers . length > 0 ;
19811984 const editing = focused === undefined || focused === "footer:input" ;
19821985 const narrow = view . size . columns <= NARROW . columns ;
1983- const width = Math . max ( 1 , view . size . columns ) ;
1986+ // The room this row was measured to have, not the width of the terminal it is
1987+ // somewhere inside. They are the same only where one region is the whole
1988+ // screen; everywhere else this row lands in a column, and a sentence fitted to
1989+ // the terminal is a sentence that runs out of its own row — the engine clips no
1990+ // text, so what will not fit is drawn over the row underneath.
1991+ const width = Math . max ( 1 , room ) ;
19841992 const move : GuidancePart = { text : "Tab/Shift+Tab move" } ;
19851993 const readiness = readinessOf ( view ) ;
19861994 if ( modal ) {
@@ -2278,6 +2286,19 @@ function described(view: ReplView, context: ReplPresentationContext): DescribedS
22782286 }
22792287 }
22802288
2289+ // What each shared column is, said once at the top of it. A pane that named
2290+ // itself only when it held something would be a pane a reader has to recognize
2291+ // by what happens to be in it, and an empty one would read as a gap. They are
2292+ // read rather than activated: nothing here is a control, and the frame places
2293+ // them only where there is a pane to put them in.
2294+ // Not in a narrow frame: it routes one outlet and has neither column, so a
2295+ // title described there would be a mounted node with no box to draw it in.
2296+ // The two surface controls are that frame's own headings.
2297+ if ( ! narrow ) {
2298+ items . push ( line ( "transcript:heading" , "Transcript" , styleOf ( "pane-heading" ) ) ) ;
2299+ items . push ( line ( "inspection:heading" , "Bindings" , styleOf ( "pane-heading" ) ) ) ;
2300+ }
2301+
22812302 // The transcript of whatever is selected. Selecting an entry *is* selecting a
22822303 // transcript locus, so the rows are that entry's own — not every entry's
22832304 // concatenated, which would make the catalog a list of things that all show
@@ -2464,14 +2485,7 @@ function described(view: ReplView, context: ReplPresentationContext): DescribedS
24642485 // transcript column is narrower than the longest of them — a row wider than
24652486 // its column is one the column beside it loses space to.
24662487 if ( surface !== undefined ) {
2467- items . push ( line ( "guidance" , guidance ( view ) , styleOf ( "status" , { inspected } ) ) ) ;
2468- }
2469-
2470- // The canonical location: how a person comes back to exactly this view, here
2471- // or in another process. It goes above whatever surface is being shown rather
2472- // than in the footer, which is seven rows and has controls in them.
2473- for ( const [ offset , part ] of locationRows ( view . location , view . size , context . widths ) . entries ( ) ) {
2474- items . push ( line ( `location:${ offset } ` , part , styleOf ( "metadata" ) ) ) ;
2488+ items . push ( line ( "guidance" , guidance ( view , surface ) , styleOf ( "status" , { inspected } ) ) ) ;
24752489 }
24762490
24772491 // Why the last thing asked for changed nothing. Shown rather than swallowed: a
@@ -2515,7 +2529,11 @@ function described(view: ReplView, context: ReplPresentationContext): DescribedS
25152529 items . push (
25162530 field (
25172531 "footer:input" ,
2518- "> " ,
2532+ // Named, because the row below a reading has to say that it is where typing
2533+ // goes rather than one more line of that reading. The marker in front of it
2534+ // is still the focus cue `fieldText` writes, so this row reads `>> Draft: `
2535+ // while it holds focus and ` > Draft: ` while it does not.
2536+ "> Draft: " ,
25192537 state . draft ,
25202538 "draft" ,
25212539 styleOf ( "draft" ) ,
@@ -2755,60 +2773,6 @@ function sessionRows(
27552773 return items ;
27562774}
27572775
2758- /**
2759- * How many rows a narrow frame gives the canonical location.
2760- *
2761- * Three, and the region is thirteen. A narrow frame draws the location, both
2762- * surface controls, the two window controls and the routed outlet in one
2763- * region, so what the location takes is what the rest cannot have.
2764- */
2765- const NARROW_LOCATION_ROWS = 3 ;
2766-
2767- /**
2768- * The canonical location, as the rows one frame places it in.
2769- *
2770- * In full wherever there is room: it is the one thing a person copies out of
2771- * this screen, and a prefix of it takes them somewhere else. A narrow frame is
2772- * where there is not room — the location shares its region with every control
2773- * on the screen, and a draft long enough to fill that region would leave the
2774- * surface controls and the whole outlet mounted, focusable and drawn nowhere,
2775- * which is a screen with no way off it.
2776- *
2777- * So a narrow frame bounds it and says what it is not showing. A person who
2778- * cannot see the whole location can still read that fact and act on it; a
2779- * person whose controls are all off the bottom of the screen cannot do
2780- * anything at all.
2781- */
2782- function locationRows (
2783- location : string ,
2784- size : ReplTerminalSize ,
2785- widths : ReplMeasuredWidths | undefined ,
2786- ) : readonly string [ ] {
2787- if ( widths === undefined ) {
2788- // No width yet, and this is the longest unbounded thing on the screen: one
2789- // row of it would make the column it lands in as wide as the whole location.
2790- return Object . freeze ( [ ] ) ;
2791- }
2792- const rows = chunked ( location , widths . surface ) ;
2793- if ( profileFor ( size ) !== "narrow" || rows . length <= NARROW_LOCATION_ROWS ) {
2794- return rows ;
2795- }
2796- const shown = rows . slice ( 0 , NARROW_LOCATION_ROWS - 1 ) ;
2797- const hidden = location . length - shown . join ( "" ) . length ;
2798- // To the same width as the rows above it. This is the one location row whose
2799- // length changes — a count that loses a digit makes it shorter — and what
2800- // this application describes is a complete row either way: `chunked` already
2801- // pads every ordinary one, and covering what a shorter row no longer reaches
2802- // is this boundary's job rather than something to leave to whichever renderer
2803- // happens to draw it. The renderer in use fills a placed cell to its bounds,
2804- // so it repaints this cleanly whether or not the row arrives padded; that is
2805- // its behavior, and this is the contract.
2806- return Object . freeze ( [
2807- ...shown ,
2808- pad ( `… ${ hidden } more characters, in a wider window` , widths . surface ) ,
2809- ] ) ;
2810- }
2811-
28122776/**
28132777 * How many rows the Sessions reading holds, whatever the window shows.
28142778 *
@@ -3862,6 +3826,7 @@ export function drawerOffsetOf(state: ReplState, open: ReplDrawerRef | undefined
38623826type ReplSlot =
38633827 | "located"
38643828 | "navigation"
3829+ | "pane-heading"
38653830 | "sessions-fixed"
38663831 | "sessions"
38673832 | "entries-fixed"
@@ -3905,6 +3870,9 @@ function slotOf(key: string): ReplSlot | undefined {
39053870 if ( key === "sessions:heading" || key === "entries:heading" ) {
39063871 return "navigation" ;
39073872 }
3873+ if ( key === "transcript:heading" || key === "inspection:heading" ) {
3874+ return "pane-heading" ;
3875+ }
39083876 // The empty placeholder and both window controls stay put around the window
39093877 // rather than inside it, so a measured viewport is the moving part alone.
39103878 if ( key === "sessions:empty" || key === "sessions:earlier" || key === "sessions:later" ) {
@@ -3925,7 +3893,7 @@ function slotOf(key: string): ReplSlot | undefined {
39253893 if ( key . startsWith ( "binding:" ) || key . startsWith ( "elicit:" ) ) {
39263894 return "inspection" ;
39273895 }
3928- if ( key === "guidance" || key . startsWith ( "location:" ) ) {
3896+ if ( key === "guidance" ) {
39293897 return "located" ;
39303898 }
39313899 // Above the surface, where there is a row's full width for a sentence. On the
@@ -4107,6 +4075,7 @@ export function presentationFor(
41074075 viewports : Object . freeze ( [ ] ) ,
41084076 actions : undefined ,
41094077 regions : Object . freeze ( [ Object . freeze ( { region : "refusal" , id : "box:refusal" } ) ] ) ,
4078+ contents : Object . freeze ( [ ] ) ,
41104079 history : band ,
41114080 } ) ,
41124081 } ;
@@ -4115,6 +4084,8 @@ export function presentationFor(
41154084 const candidates = candidatesOf ( descriptions , styles ) ;
41164085 const viewports : ReplViewportSlot [ ] = [ ] ;
41174086 const regions : { region : ReplRegion ; id : string } [ ] = [ ] ;
4087+ /** The border-free inside of each pane that has edges. */
4088+ const contents : { region : ReplRegion ; id : string } [ ] = [ ] ;
41184089 /**
41194090 * How wide one region is, as this frame measured it.
41204091 *
@@ -4178,6 +4149,32 @@ export function presentationFor(
41784149 const found = of ( "navigation" ) . filter ( ( candidate ) => candidate . key === key ) ;
41794150 return found . map ( ( candidate ) => rowBox ( candidate , region , widthOfRegion ( region ) ) ) ;
41804151 } ;
4152+ /** One pane's own title, where there is a pane to put it in. */
4153+ const paneTitle = ( key : string , region : ReplRegion ) : readonly ReplBox [ ] => {
4154+ const found = of ( "pane-heading" ) . filter ( ( candidate ) => candidate . key === key ) ;
4155+ return found . map ( ( candidate ) => rowBox ( candidate , region , widthOfRegion ( region ) ) ) ;
4156+ } ;
4157+ /**
4158+ * One pane with edges, and the border-free box its rows are measured in.
4159+ *
4160+ * The column keeps the width the product gives it; the inside is whatever the
4161+ * engine leaves after the edges, and that inside is what `widthsOf` reads.
4162+ */
4163+ const edgedColumn = (
4164+ region : ReplRegion ,
4165+ width : number | undefined ,
4166+ surface : number ,
4167+ children : readonly ReplBox [ ] ,
4168+ ) : ReplBox => {
4169+ const id = `box:${ region } :content` ;
4170+ contents . push ( { region, id } ) ;
4171+ return box ( {
4172+ id : `box:${ region } ` ,
4173+ region,
4174+ props : paneColumnProps ( width , surface ) ,
4175+ children : [ box ( { id, region, props : paneContentProps ( ) , children } ) ] ,
4176+ } ) ;
4177+ } ;
41814178
41824179 const columns : ReplBox [ ] = [ ] ;
41834180 if ( profile === "narrow" ) {
@@ -4215,7 +4212,7 @@ export function presentationFor(
42154212 box ( {
42164213 id : "box:sidebar" ,
42174214 region : "sidebar" ,
4218- props : columnProps ( sidebarWidth ( size ) ) ,
4215+ props : paneProps ( sidebarWidth ( size ) , REPL_PALETTE . sideSurface ) ,
42194216 children : [
42204217 // Two groups, and only one of them grows: the Sessions reading takes
42214218 // whatever the column has left, and the catalog states its own height.
@@ -4254,37 +4251,29 @@ export function presentationFor(
42544251 } ) ,
42554252 ] ,
42564253 } ) ,
4257- box ( {
4258- id : "box:transcript" ,
4259- region : "transcript" ,
4260- props : columnProps ( undefined ) ,
4261- children : [
4262- ...located ,
4263- box ( {
4264- id : "box:transcript:viewport" ,
4265- region : "transcript" ,
4266- props : viewportProps ( ) ,
4267- children : of ( "transcript" ) . map ( ( candidate ) =>
4268- rowBox ( candidate , "transcript" , context . widths ?. surface ) ,
4269- ) ,
4270- } ) ,
4271- ] ,
4272- } ) ,
4273- box ( {
4274- id : "box:inspection" ,
4275- region : "inspection" ,
4276- props : columnProps ( inspectionWidth ( size ) ) ,
4277- children : [
4278- box ( {
4279- id : "box:inspection:viewport" ,
4280- region : "inspection" ,
4281- props : viewportProps ( ) ,
4282- children : of ( "inspection" ) . map ( ( candidate ) =>
4283- rowBox ( candidate , "inspection" , context . widths ?. inspection ) ,
4284- ) ,
4285- } ) ,
4286- ] ,
4287- } ) ,
4254+ edgedColumn ( "transcript" , undefined , REPL_PALETTE . centreSurface , [
4255+ ...paneTitle ( "transcript:heading" , "transcript" ) ,
4256+ ...located ,
4257+ box ( {
4258+ id : "box:transcript:viewport" ,
4259+ region : "transcript" ,
4260+ props : viewportProps ( ) ,
4261+ children : of ( "transcript" ) . map ( ( candidate ) =>
4262+ rowBox ( candidate , "transcript" , context . widths ?. surface ) ,
4263+ ) ,
4264+ } ) ,
4265+ ] ) ,
4266+ edgedColumn ( "inspection" , inspectionWidth ( size ) , REPL_PALETTE . bindingsSurface , [
4267+ ...paneTitle ( "inspection:heading" , "inspection" ) ,
4268+ box ( {
4269+ id : "box:inspection:viewport" ,
4270+ region : "inspection" ,
4271+ props : viewportProps ( ) ,
4272+ children : of ( "inspection" ) . map ( ( candidate ) =>
4273+ rowBox ( candidate , "inspection" , context . widths ?. inspection ) ,
4274+ ) ,
4275+ } ) ,
4276+ ] ) ,
42884277 ) ;
42894278 }
42904279
@@ -4338,7 +4327,11 @@ export function presentationFor(
43384327 id : "box:root" ,
43394328 props : rootProps ( size ) ,
43404329 children : [
4341- box ( { id : "box:body" , props : bodyProps ( ) , children : columns } ) ,
4330+ box ( {
4331+ id : "box:body" ,
4332+ props : bodyProps ( profile !== "narrow" ) ,
4333+ children : columns ,
4334+ } ) ,
43424335 box ( {
43434336 id : "box:footer" ,
43444337 region : "footer" ,
@@ -4395,6 +4388,7 @@ export function presentationFor(
43954388 ) ,
43964389 } ) ,
43974390 regions : Object . freeze ( regions . map ( ( region ) => Object . freeze ( region ) ) ) ,
4391+ contents : Object . freeze ( contents . map ( ( content ) => Object . freeze ( content ) ) ) ,
43984392 history : band ,
43994393 } ) ,
44004394 } ;
0 commit comments