public override string ReadLine()
        {
            var ch = new List <char>();

            for (;;)
            {
                var i = RawUI.ReadKey(ReadKeyOptions.IncludeKeyDown);
                if (i.Character == '\r')
                {
                    break;
                }
                ch.Add(i.Character);
            }

            return(string.Join("", ch));
        }
Exemple #2
0
 public void ProcessEvents(PSHostRawUserInterface ui)
 {
     // key events first
     while (ui.KeyAvailable)
     {
         KeyInfo ki = ui.ReadKey(ReadKeyOptions.IncludeKeyDown | ReadKeyOptions.IncludeKeyUp | ReadKeyOptions.NoEcho);
         int     vk = ki.VirtualKeyCode;
         Tuple <ScriptBlock, object> sbo = null;
         if (ki.KeyDown)
         {
             if (allowAutoRepeat || !keyDownState.ContainsKey(vk))
             {
                 keyDownScripts.TryGetValue(vk, out sbo);
                 keyDownState.Add(vk, true);
             }
         }
         else
         {
             keyDownState.Remove(vk);
             keyUpScripts.TryGetValue(vk, out sbo);
         }
         // invoke the script passing this and the keyinfo in
         if (sbo != null)
         {
             sbo.A.InvokeReturnAsIs(this, ki, sbo.B);
         }
     }
     // not check if there are any timed events
     eventNum++;
     while (afterScripts.Count > 0 && eventNum >= afterScripts[0].A)
     {
         // if found, pass this and the eventnum in
         afterScripts[0].B.InvokeReturnAsIs(this, eventNum, afterScripts[0].C);
         afterScripts.RemoveAt(0);
     }
 }