@@ -16,7 +16,7 @@ namespace Microsoft.PowerShell.EditorServices.Services.PowerShell.Console
16
16
{
17
17
using System ;
18
18
19
- internal class LegacyReadLine : IReadLine
19
+ internal class LegacyReadLine : TerminalReadLine
20
20
{
21
21
private readonly PsesInternalHost _psesHost ;
22
22
@@ -32,7 +32,7 @@ public LegacyReadLine(
32
32
_debugContext = debugContext ;
33
33
}
34
34
35
- public string ReadLine ( CancellationToken cancellationToken )
35
+ public override string ReadLine ( CancellationToken cancellationToken )
36
36
{
37
37
// TODO: Is inputBeforeCompletion used?
38
38
string inputBeforeCompletion = null ;
@@ -59,7 +59,7 @@ public string ReadLine(CancellationToken cancellationToken)
59
59
{
60
60
while ( ! cancellationToken . IsCancellationRequested )
61
61
{
62
- ConsoleKeyInfo keyInfo = ReadKey ( displayKeyInConsole : false , cancellationToken ) ;
62
+ ConsoleKeyInfo keyInfo = ReadKey ( cancellationToken ) ;
63
63
64
64
// Do final position calculation after the key has been pressed
65
65
// because the window could have been resized before then
@@ -383,46 +383,31 @@ public string ReadLine(CancellationToken cancellationToken)
383
383
return null ;
384
384
}
385
385
386
- private static bool IsCtrlC ( ConsoleKeyInfo keyInfo )
387
- {
388
- if ( ( int ) keyInfo . Key == 3 )
389
- {
390
- return true ;
391
- }
392
-
393
- return keyInfo . Key == ConsoleKey . C
394
- && ( keyInfo . Modifiers & ConsoleModifiers . Control ) != 0
395
- && ( keyInfo . Modifiers & ConsoleModifiers . Alt ) == 0 ;
396
- }
397
-
398
- public SecureString ReadSecureLine ( CancellationToken cancellationToken )
399
- {
400
- throw new NotImplementedException ( ) ;
401
- }
402
-
403
- public bool TryOverrideIdleHandler ( Action idleHandler )
386
+ public override bool TryOverrideIdleHandler ( Action < CancellationToken > idleHandler )
404
387
{
405
388
return true ;
406
389
}
407
390
408
- public bool TryOverrideReadKey ( Func < bool , ConsoleKeyInfo > readKeyOverride )
391
+ public override bool TryOverrideReadKey ( Func < bool , ConsoleKeyInfo > readKeyOverride )
409
392
{
410
393
_readKeyFunc = readKeyOverride ;
411
394
return true ;
412
395
}
413
396
414
- private ConsoleKeyInfo ReadKey ( bool displayKeyInConsole , CancellationToken cancellationToken )
397
+ protected override ConsoleKeyInfo ReadKey ( CancellationToken cancellationToken )
415
398
{
416
399
cancellationToken . ThrowIfCancellationRequested ( ) ;
417
400
try
418
401
{
419
- return _readKeyFunc ( ! displayKeyInConsole ) ;
402
+ // intercept = false means we display the key in the console
403
+ return _readKeyFunc ( /* intercept */ false ) ;
420
404
}
421
405
finally
422
406
{
423
407
cancellationToken . ThrowIfCancellationRequested ( ) ;
424
408
}
425
409
}
410
+
426
411
private static int InsertInput (
427
412
StringBuilder inputLine ,
428
413
int promptStartCol ,
0 commit comments