@@ -16,7 +16,7 @@ namespace Microsoft.PowerShell.EditorServices.Services.PowerShell.Console
1616{
1717 using System ;
1818
19- internal class LegacyReadLine : IReadLine
19+ internal class LegacyReadLine : TerminalReadLine
2020 {
2121 private readonly PsesInternalHost _psesHost ;
2222
@@ -32,7 +32,7 @@ public LegacyReadLine(
3232 _debugContext = debugContext ;
3333 }
3434
35- public string ReadLine ( CancellationToken cancellationToken )
35+ public override string ReadLine ( CancellationToken cancellationToken )
3636 {
3737 // TODO: Is inputBeforeCompletion used?
3838 string inputBeforeCompletion = null ;
@@ -59,7 +59,7 @@ public string ReadLine(CancellationToken cancellationToken)
5959 {
6060 while ( ! cancellationToken . IsCancellationRequested )
6161 {
62- ConsoleKeyInfo keyInfo = ReadKey ( displayKeyInConsole : false , cancellationToken ) ;
62+ ConsoleKeyInfo keyInfo = ReadKey ( cancellationToken ) ;
6363
6464 // Do final position calculation after the key has been pressed
6565 // because the window could have been resized before then
@@ -383,46 +383,31 @@ public string ReadLine(CancellationToken cancellationToken)
383383 return null ;
384384 }
385385
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 )
404387 {
405388 return true ;
406389 }
407390
408- public bool TryOverrideReadKey ( Func < bool , ConsoleKeyInfo > readKeyOverride )
391+ public override bool TryOverrideReadKey ( Func < bool , ConsoleKeyInfo > readKeyOverride )
409392 {
410393 _readKeyFunc = readKeyOverride ;
411394 return true ;
412395 }
413396
414- private ConsoleKeyInfo ReadKey ( bool displayKeyInConsole , CancellationToken cancellationToken )
397+ protected override ConsoleKeyInfo ReadKey ( CancellationToken cancellationToken )
415398 {
416399 cancellationToken . ThrowIfCancellationRequested ( ) ;
417400 try
418401 {
419- return _readKeyFunc ( ! displayKeyInConsole ) ;
402+ // intercept = false means we display the key in the console
403+ return _readKeyFunc ( /* intercept */ false ) ;
420404 }
421405 finally
422406 {
423407 cancellationToken . ThrowIfCancellationRequested ( ) ;
424408 }
425409 }
410+
426411 private static int InsertInput (
427412 StringBuilder inputLine ,
428413 int promptStartCol ,
0 commit comments