@@ -97,7 +97,7 @@ const ESCAPE_CODE_TIMEOUT = 500;
9797// Max length of the kill ring
9898const kMaxLengthOfKillRing = 32 ;
9999
100- const kMultilinePrompt = Symbol ( '| ' ) ;
100+ const kMultilinePrompt = Symbol ( 'multilinePrompt ' ) ;
101101
102102const kAddHistory = Symbol ( '_addHistory' ) ;
103103const kBeforeEdit = Symbol ( '_beforeEdit' ) ;
@@ -237,6 +237,7 @@ function InterfaceConstructor(input, output, completer, terminal) {
237237 this [ kUndoStack ] = [ ] ;
238238 this [ kRedoStack ] = [ ] ;
239239 this [ kPreviousCursorCols ] = - 1 ;
240+ this [ kMultilinePrompt ] ||= { description : '| ' } ;
240241
241242 // The kill ring is a global list of blocks of text that were previously
242243 // killed (deleted). If its size exceeds kMaxLengthOfKillRing, the oldest
@@ -411,6 +412,23 @@ class Interface extends InterfaceConstructor {
411412 } ) ;
412413 }
413414
415+ /**
416+ * Sets the multiline prompt.
417+ * @param {string } prompt
418+ * @returns {void }
419+ */
420+ setMultilinePrompt ( prompt ) {
421+ this [ kMultilinePrompt ] . description = prompt ;
422+ }
423+
424+ /**
425+ * Returns the current multiline prompt.
426+ * @returns {string }
427+ */
428+ getMultilinePrompt ( ) {
429+ return this [ kMultilinePrompt ] . description ;
430+ }
431+
414432 [ kSetRawMode ] ( mode ) {
415433 const wasInRawMode = this . input . isRaw ;
416434
@@ -518,7 +536,7 @@ class Interface extends InterfaceConstructor {
518536
519537 // For continuation lines, add the "|" prefix
520538 for ( let i = 1 ; i < lines . length ; i ++ ) {
521- this [ kWriteToOutput ] ( `\n${ kMultilinePrompt . description } ` + lines [ i ] ) ;
539+ this [ kWriteToOutput ] ( `\n${ this [ kMultilinePrompt ] . description } ` + lines [ i ] ) ;
522540 }
523541 } else {
524542 // Write the prompt and the current buffer content.
@@ -989,7 +1007,8 @@ class Interface extends InterfaceConstructor {
9891007 const dy = splitEnd . length + 1 ;
9901008
9911009 // Calculate how many Xs we need to move on the right to get to the end of the line
992- const dxEndOfLineAbove = ( splitBeg [ splitBeg . length - 2 ] || '' ) . length + kMultilinePrompt . description . length ;
1010+ const dxEndOfLineAbove = ( splitBeg [ splitBeg . length - 2 ] || '' ) . length +
1011+ this [ kMultilinePrompt ] . description . length ;
9931012 moveCursor ( this . output , dxEndOfLineAbove , - dy ) ;
9941013
9951014 // This is the line that was split in the middle
@@ -1010,9 +1029,9 @@ class Interface extends InterfaceConstructor {
10101029 }
10111030
10121031 if ( needsRewriteFirstLine ) {
1013- this [ kWriteToOutput ] ( `${ this [ kPrompt ] } ${ beforeCursor } \n${ kMultilinePrompt . description } ` ) ;
1032+ this [ kWriteToOutput ] ( `${ this [ kPrompt ] } ${ beforeCursor } \n${ this [ kMultilinePrompt ] . description } ` ) ;
10141033 } else {
1015- this [ kWriteToOutput ] ( kMultilinePrompt . description ) ;
1034+ this [ kWriteToOutput ] ( this [ kMultilinePrompt ] . description ) ;
10161035 }
10171036
10181037 // Write the rest and restore the cursor to where the user left it
@@ -1024,7 +1043,7 @@ class Interface extends InterfaceConstructor {
10241043 const formattedEndContent = StringPrototypeReplaceAll (
10251044 afterCursor ,
10261045 '\n' ,
1027- `\n${ kMultilinePrompt . description } ` ,
1046+ `\n${ this [ kMultilinePrompt ] . description } ` ,
10281047 ) ;
10291048
10301049 this [ kWriteToOutput ] ( formattedEndContent ) ;
@@ -1085,7 +1104,7 @@ class Interface extends InterfaceConstructor {
10851104 const curr = splitLines [ rows ] ;
10861105 const down = direction === 1 ;
10871106 const adj = splitLines [ rows + direction ] ;
1088- const promptLen = kMultilinePrompt . description . length ;
1107+ const promptLen = this [ kMultilinePrompt ] . description . length ;
10891108 let amountToMove ;
10901109 // Clamp distance to end of current + prompt + next/prev line + newline
10911110 const clamp = down ?
@@ -1176,7 +1195,7 @@ class Interface extends InterfaceConstructor {
11761195 // Rows must be incremented by 1 even if offset = 0 or col = +Infinity.
11771196 rows += MathCeil ( offset / col ) || 1 ;
11781197 // Only add prefix offset for continuation lines in user input (not prompts)
1179- offset = this [ kIsMultiline ] ? kMultilinePrompt . description . length : 0 ;
1198+ offset = this [ kIsMultiline ] ? this [ kMultilinePrompt ] . description . length : 0 ;
11801199 continue ;
11811200 }
11821201 // Tabs must be aligned by an offset of the tab size.
0 commit comments