@@ -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
@@ -415,6 +416,23 @@ class Interface extends InterfaceConstructor {
415416 } ) ;
416417 }
417418
419+ /**
420+ * Sets the multiline prompt.
421+ * @param {string } prompt
422+ * @returns {void }
423+ */
424+ setMultilinePrompt ( prompt ) {
425+ this [ kMultilinePrompt ] . description = prompt ;
426+ }
427+
428+ /**
429+ * Returns the current multiline prompt.
430+ * @returns {string }
431+ */
432+ getMultilinePrompt ( ) {
433+ return this [ kMultilinePrompt ] . description ;
434+ }
435+
418436 [ kSetRawMode ] ( mode ) {
419437 const wasInRawMode = this . input . isRaw ;
420438
@@ -522,7 +540,7 @@ class Interface extends InterfaceConstructor {
522540
523541 // For continuation lines, add the "|" prefix
524542 for ( let i = 1 ; i < lines . length ; i ++ ) {
525- this [ kWriteToOutput ] ( `\n${ kMultilinePrompt . description } ` + lines [ i ] ) ;
543+ this [ kWriteToOutput ] ( `\n${ this [ kMultilinePrompt ] . description } ` + lines [ i ] ) ;
526544 }
527545 } else {
528546 // Write the prompt and the current buffer content.
@@ -987,7 +1005,8 @@ class Interface extends InterfaceConstructor {
9871005 const dy = splitEnd . length + 1 ;
9881006
9891007 // Calculate how many Xs we need to move on the right to get to the end of the line
990- const dxEndOfLineAbove = ( splitBeg [ splitBeg . length - 2 ] || '' ) . length + kMultilinePrompt . description . length ;
1008+ const dxEndOfLineAbove = ( splitBeg [ splitBeg . length - 2 ] || '' ) . length +
1009+ this [ kMultilinePrompt ] . description . length ;
9911010 moveCursor ( this . output , dxEndOfLineAbove , - dy ) ;
9921011
9931012 // This is the line that was split in the middle
@@ -1008,9 +1027,9 @@ class Interface extends InterfaceConstructor {
10081027 }
10091028
10101029 if ( needsRewriteFirstLine ) {
1011- this [ kWriteToOutput ] ( `${ this [ kPrompt ] } ${ beforeCursor } \n${ kMultilinePrompt . description } ` ) ;
1030+ this [ kWriteToOutput ] ( `${ this [ kPrompt ] } ${ beforeCursor } \n${ this [ kMultilinePrompt ] . description } ` ) ;
10121031 } else {
1013- this [ kWriteToOutput ] ( kMultilinePrompt . description ) ;
1032+ this [ kWriteToOutput ] ( this [ kMultilinePrompt ] . description ) ;
10141033 }
10151034
10161035 // Write the rest and restore the cursor to where the user left it
@@ -1022,7 +1041,7 @@ class Interface extends InterfaceConstructor {
10221041 const formattedEndContent = StringPrototypeReplaceAll (
10231042 afterCursor ,
10241043 '\n' ,
1025- `\n${ kMultilinePrompt . description } ` ,
1044+ `\n${ this [ kMultilinePrompt ] . description } ` ,
10261045 ) ;
10271046
10281047 this [ kWriteToOutput ] ( formattedEndContent ) ;
@@ -1083,7 +1102,7 @@ class Interface extends InterfaceConstructor {
10831102 const curr = splitLines [ rows ] ;
10841103 const down = direction === 1 ;
10851104 const adj = splitLines [ rows + direction ] ;
1086- const promptLen = kMultilinePrompt . description . length ;
1105+ const promptLen = this [ kMultilinePrompt ] . description . length ;
10871106 let amountToMove ;
10881107 // Clamp distance to end of current + prompt + next/prev line + newline
10891108 const clamp = down ?
@@ -1174,7 +1193,7 @@ class Interface extends InterfaceConstructor {
11741193 // Rows must be incremented by 1 even if offset = 0 or col = +Infinity.
11751194 rows += MathCeil ( offset / col ) || 1 ;
11761195 // Only add prefix offset for continuation lines in user input (not prompts)
1177- offset = this [ kIsMultiline ] ? kMultilinePrompt . description . length : 0 ;
1196+ offset = this [ kIsMultiline ] ? this [ kMultilinePrompt ] . description . length : 0 ;
11781197 continue ;
11791198 }
11801199 // Tabs must be aligned by an offset of the tab size.
0 commit comments