@@ -21,15 +21,19 @@ internal class LegacyReadLine : TerminalReadLine
21
21
22
22
private readonly Task [ ] _readKeyTasks ;
23
23
24
- private Func < bool , ConsoleKeyInfo > _readKeyFunc ;
24
+ private readonly Func < bool , ConsoleKeyInfo > _readKeyFunc ;
25
25
26
- private Action _onIdleAction ;
26
+ private readonly Action < CancellationToken > _onIdleAction ;
27
27
28
28
public LegacyReadLine (
29
- PsesInternalHost psesHost )
29
+ PsesInternalHost psesHost ,
30
+ Func < bool , ConsoleKeyInfo > readKeyFunc ,
31
+ Action < CancellationToken > onIdleAction )
30
32
{
31
33
_psesHost = psesHost ;
32
34
_readKeyTasks = new Task [ 2 ] ;
35
+ _readKeyFunc = readKeyFunc ;
36
+ _onIdleAction = onIdleAction ;
33
37
}
34
38
35
39
public override string ReadLine ( CancellationToken cancellationToken )
@@ -376,18 +380,6 @@ public override string ReadLine(CancellationToken cancellationToken)
376
380
return null ;
377
381
}
378
382
379
- public override bool TryOverrideIdleHandler ( Action < CancellationToken > idleHandler )
380
- {
381
- _onIdleAction = idleHandler ;
382
- return true ;
383
- }
384
-
385
- public override bool TryOverrideReadKey ( Func < bool , ConsoleKeyInfo > readKeyOverride )
386
- {
387
- _readKeyFunc = readKeyOverride ;
388
- return true ;
389
- }
390
-
391
383
protected override ConsoleKeyInfo ReadKey ( CancellationToken cancellationToken )
392
384
{
393
385
cancellationToken . ThrowIfCancellationRequested ( ) ;
@@ -421,7 +413,7 @@ private ConsoleKeyInfo ReadKeyWithIdleSupport(CancellationToken cancellationToke
421
413
422
414
// The idle timed out
423
415
case 1 :
424
- _onIdleAction ( ) ;
416
+ _onIdleAction ( cancellationToken ) ;
425
417
_readKeyTasks [ 1 ] = Task . Delay ( millisecondsDelay : 300 , cancellationToken ) ;
426
418
continue ;
427
419
}
0 commit comments