@@ -48,6 +48,8 @@ import type { ReplPresentationRole, ReplRowStyle } from "./presentation-style.ts
4848import { tokenRuns } from "./description.ts" ;
4949import type { ReplTokenRun } from "./description.ts" ;
5050import { sourceRuns } from "./presentation-text.ts" ;
51+ import { inertCommandText } from "./command-output.ts" ;
52+ import type { ReplCommandChunk } from "./command-output.ts" ;
5153
5254/** What this terminal draws for each phase, glyph and word together. */
5355const BADGES : Readonly <
@@ -117,6 +119,7 @@ export interface ReplReadingSection {
117119/** One entry's whole reading: what it produced, then what produced it. */
118120export interface ReplReading {
119121 readonly output : ReplReadingSection ;
122+ readonly commands ?: readonly ReplReadingSection [ ] ;
120123 readonly source : ReplReadingSection ;
121124}
122125
@@ -146,6 +149,10 @@ export function readingLines(reading: ReplReading): readonly ReplReadingLine[] {
146149 return Object . freeze ( [
147150 caption ( "output" , reading . output ) ,
148151 ...reading . output . lines ,
152+ ...( reading . commands ?? [ ] ) . flatMap ( ( section , index ) => [
153+ caption ( `command:${ index } ` , section ) ,
154+ ...section . lines ,
155+ ] ) ,
149156 caption ( "source" , reading . source ) ,
150157 ...reading . source . lines ,
151158 ] ) ;
@@ -165,6 +172,7 @@ function caption(key: string, section: ReplReadingSection): ReplReadingLine {
165172
166173/** What a reading is being built for. */
167174export interface ReplReadingRequest {
175+ readonly commandOutput ?: readonly ReplCommandChunk [ ] ;
168176 readonly entry : ReplEntry ;
169177 /** This session's observations, or an empty reading for a retained prefix. */
170178 readonly lifecycle : ReplLifecycleReading ;
@@ -184,6 +192,19 @@ export interface ReplReadingRequest {
184192export function entryReading ( request : ReplReadingRequest ) : ReplReading {
185193 return Object . freeze ( {
186194 output : outputSection ( request ) ,
195+ commands : Object . freeze (
196+ ( request . commandOutput ?? [ ] ) . map ( ( chunk , index ) =>
197+ Object . freeze ( {
198+ caption : `Command ${ chunk . channel } ` ,
199+ captionStyle : styleOf ( "pane-heading" , { inspected : request . inspected } ) ,
200+ lines : plain (
201+ chunk . text ,
202+ `command:${ index } ` ,
203+ styleOf ( "output" , { inspected : request . inspected } ) ,
204+ ) ,
205+ } ) ,
206+ ) ,
207+ ) ,
187208 source : sourceSection ( request ) ,
188209 } ) ;
189210}
@@ -257,17 +278,19 @@ function outputSection(request: ReplReadingRequest): ReplReadingSection {
257278/** Text as lines nothing has been observed in. */
258279function plain ( text : string , prefix : string , style : ReplRowStyle ) : readonly ReplReadingLine [ ] {
259280 return Object . freeze (
260- text . split ( "\n" ) . map ( ( one , index ) =>
261- Object . freeze ( {
262- key : `${ prefix } :${ index } ` ,
263- text : one ,
264- runs : tokenRuns ( [ { text : one , token : style . role } ] ) ,
265- rail : "rail-pending" as const ,
266- depth : 0 ,
267- badge : undefined ,
268- style,
269- } ) ,
270- ) ,
281+ inertCommandText ( text )
282+ . split ( "\n" )
283+ . map ( ( one , index ) =>
284+ Object . freeze ( {
285+ key : `${ prefix } :${ index } ` ,
286+ text : one ,
287+ runs : tokenRuns ( [ { text : one , token : style . role } ] ) ,
288+ rail : "rail-pending" as const ,
289+ depth : 0 ,
290+ badge : undefined ,
291+ style,
292+ } ) ,
293+ ) ,
271294 ) ;
272295}
273296
0 commit comments