internal static SecureString PromptForSecureString(PSHostUserInterface hostUI, string prompt) { hostUI.Write(prompt); SecureString secureString = hostUI.ReadLineAsSecureString(); hostUI.WriteLine(""); return secureString; }
private static void WriteBanner(PSHostUserInterface ui) { ui.WriteLine(ConsoleColor.White, ConsoleColor.Black, BannerText); ui.WriteLine(); }
internal PromptResponse PromptUser(PSHostUserInterface console) { char ch = char.MinValue; for (int i = 0; i < this.actualPrompt.Count; i++) { if (i < (this.actualPrompt.Count - 1)) { console.WriteLine(this.actualPrompt[i]); } else { console.Write(this.actualPrompt[i]); } } do { this.callingCmdlet.CheckStopProcessing(); switch (console.RawUI.ReadKey(ReadKeyOptions.IncludeKeyUp | ReadKeyOptions.NoEcho).Character) { case 'q': case 'Q': console.WriteLine(); return PromptResponse.Quit; case ' ': console.WriteLine(); return PromptResponse.NextPage; } } while (ch != '\r'); console.WriteLine(); return PromptResponse.NextLine; }
/// <summary> /// do the actual prompting /// </summary> /// <param name="console">PSHostUserInterface instance to prompt to</param> internal PromptResponse PromptUser(PSHostUserInterface console) { // NOTE: assume the values passed to ComputePromptLines are still valid // write out the prompt line(s). The last one will not have a new line // at the end because we leave the prompt at the end of the line for (int k = 0; k < _actualPrompt.Count; k++) { if (k < (_actualPrompt.Count - 1)) console.WriteLine(_actualPrompt[k]); // intermediate line(s) else console.Write(_actualPrompt[k]); // last line } while (true) { _callingCmdlet.CheckStopProcessing(); KeyInfo ki = console.RawUI.ReadKey(ReadKeyOptions.IncludeKeyUp | ReadKeyOptions.NoEcho); char key = ki.Character; if (key == 'q' || key == 'Q') { // need to move to the next line since we accepted input, add a newline console.WriteLine(); return PromptResponse.Quit; } else if (key == ' ') { // need to move to the next line since we accepted input, add a newline console.WriteLine(); return PromptResponse.NextPage; } else if (key == '\r') { // need to move to the next line since we accepted input, add a newline console.WriteLine(); return PromptResponse.NextLine; } } }