@@ -25,6 +25,7 @@ import { TerminalContextKeys } from 'vs/workbench/contrib/terminal/common/termin
25
25
import type { Terminal } from '@xterm/xterm' ;
26
26
import { ITerminalCommand , TerminalCapability } from 'vs/platform/terminal/common/capabilities/capabilities' ;
27
27
import { getWindow } from 'vs/base/browser/dom' ;
28
+ import { IStatusbarService , StatusbarAlignment , type IStatusbarEntry , type IStatusbarEntryAccessor } from 'vs/workbench/services/statusbar/browser/statusbar' ;
28
29
29
30
registerTerminalAction ( {
30
31
id : TerminalCommandId . ShowTextureAtlas ,
@@ -121,19 +122,36 @@ class DevModeContribution extends Disposable implements ITerminalContribution {
121
122
private readonly _activeDevModeDisposables = new MutableDisposable ( ) ;
122
123
private _currentColor = 0 ;
123
124
125
+ private _statusbarEntry : IStatusbarEntry | undefined ;
126
+ private _statusbarEntryAccessor : IStatusbarEntryAccessor | undefined ;
127
+
124
128
constructor (
125
129
private readonly _instance : ITerminalInstance ,
126
130
processManager : ITerminalProcessManager ,
127
131
widgetManager : TerminalWidgetManager ,
128
132
@IConfigurationService private readonly _configurationService : IConfigurationService ,
129
133
@ITerminalConfigurationService private readonly _terminalConfigurationService : ITerminalConfigurationService ,
134
+ @IStatusbarService private readonly _statusbarService : IStatusbarService ,
130
135
) {
131
136
super ( ) ;
132
137
this . _register ( this . _configurationService . onDidChangeConfiguration ( e => {
133
138
if ( e . affectsConfiguration ( TerminalSettingId . DevMode ) ) {
134
139
this . _updateDevMode ( ) ;
135
140
}
136
141
} ) ) ;
142
+
143
+ setTimeout ( ( ) => {
144
+ const commandDetection = this . _instance . capabilities . get ( TerminalCapability . CommandDetection )
145
+ if ( commandDetection ) {
146
+ // TODO: Listen to capability add
147
+ // TODO: Add util for when capability is available?
148
+ commandDetection . promptInputModel . onDidChangeInput ( ( ) => {
149
+ // TODO: Create a status bar item sync
150
+ // TODO: Only show focused instance status bar item
151
+ this . _updateDevMode ( ) ;
152
+ } ) ;
153
+ }
154
+ } , 2000 ) ;
137
155
}
138
156
139
157
xtermReady ( xterm : IXtermTerminal & { raw : Terminal } ) : void {
@@ -145,7 +163,26 @@ class DevModeContribution extends Disposable implements ITerminalContribution {
145
163
const devMode : boolean = this . _isEnabled ( ) ;
146
164
this . _xterm ?. raw . element ?. classList . toggle ( 'dev-mode' , devMode ) ;
147
165
148
- // Text area syncing
166
+ const promptInputModel = this . _instance . capabilities . get ( TerminalCapability . CommandDetection ) ?. promptInputModel
167
+ if ( promptInputModel ) {
168
+ // Text area syncing
169
+ const promptInput = promptInputModel . value . replaceAll ( '\n' , '\u23CE' ) ;
170
+ this . _statusbarEntry = {
171
+ name : localize ( 'terminalDevMode' , 'Terminal Dev Mode' ) ,
172
+ text : `$(terminal) ${ promptInput . substring ( 0 , promptInputModel . cursorIndex ) } |${ promptInput . substring ( promptInputModel . cursorIndex ) } ` ,
173
+ // tooltip: localize('nonResponsivePtyHost', "The connection to the terminal's pty host process is unresponsive, terminals may stop working. Click to manually restart the pty host."),
174
+ ariaLabel : localize ( 'ptyHostStatus.ariaLabel' , 'test' ) ,
175
+ // command: TerminalCommandId.RestartPtyHost,
176
+ kind : 'warning'
177
+ } ;
178
+ if ( ! this . _statusbarEntryAccessor ) {
179
+ console . log ( '1' ) ;
180
+ this . _statusbarEntryAccessor = this . _statusbarService . addEntry ( this . _statusbarEntry , 'terminal.promptInput' , StatusbarAlignment . LEFT ) ;
181
+ } else {
182
+ console . log ( '2' ) ;
183
+ this . _statusbarEntryAccessor . update ( this . _statusbarEntry ) ;
184
+ }
185
+ }
149
186
if ( this . _xterm ?. raw . textarea ) {
150
187
const font = this . _terminalConfigurationService . getFont ( getWindow ( this . _xterm . raw . textarea ) ) ;
151
188
this . _xterm . raw . textarea . style . fontFamily = font . fontFamily ;
0 commit comments