internal ConsoleLineOutput(PSHostUserInterface hostConsole, bool paging, bool lineWrap, TerminatingErrorContext errorContext) { if (hostConsole == null) { throw PSTraceSource.NewArgumentNullException("hostConsole"); } if (errorContext == null) { throw PSTraceSource.NewArgumentNullException("errorContext"); } this.console = hostConsole; this.errorContext = errorContext; if (paging) { tracer.WriteLine("paging is needed", new object[0]); string s = StringUtil.Format(FormatAndOut_out_xxx.ConsoleLineOutput_PagingPrompt, new object[0]); this.prompt = new PromptHandler(s, this); } PSHostRawUserInterface rawUI = this.console.RawUI; if (rawUI != null) { tracer.WriteLine("there is a valid raw interface", new object[0]); this._displayCellsPSHost = new DisplayCellsPSHost(rawUI); } WriteLineHelper.WriteCallback wlc = new WriteLineHelper.WriteCallback(this.OnWriteLine); WriteLineHelper.WriteCallback wc = new WriteLineHelper.WriteCallback(this.OnWrite); if (this.forceNewLine) { this.writeLineHelper = new WriteLineHelper(lineWrap, wlc, null, this.DisplayCells); } else { this.writeLineHelper = new WriteLineHelper(lineWrap, wlc, wc, this.DisplayCells); } }
/// <summary> /// constructor for the ConsoleLineOutput /// </summary> /// <param name="hostConsole">PSHostUserInterface to wrap</param> /// <param name="paging">true if we require prompting for page breaks</param> /// <param name="errorContext">error context to throw exceptions</param> internal ConsoleLineOutput(PSHostUserInterface hostConsole, bool paging, TerminatingErrorContext errorContext) { if (hostConsole == null) { throw PSTraceSource.NewArgumentNullException("hostConsole"); } if (errorContext == null) { throw PSTraceSource.NewArgumentNullException("errorContext"); } _console = hostConsole; _errorContext = errorContext; if (paging) { tracer.WriteLine("paging is needed"); // if we need to do paging, instantiate a prompt handler // that will take care of the screen interaction string promptString = StringUtil.Format(FormatAndOut_out_xxx.ConsoleLineOutput_PagingPrompt); _prompt = new PromptHandler(promptString, this); } PSHostRawUserInterface raw = _console.RawUI; if (raw != null) { tracer.WriteLine("there is a valid raw interface"); #if TEST_MULTICELL_ON_SINGLE_CELL_LOCALE // create a test instance with fake behavior this._displayCellsPSHost = new DisplayCellsTest(); #else // set only if we have a valid raw interface _displayCellsPSHost = new DisplayCellsPSHost(raw); #endif } // instantiate the helper to do the line processing when ILineOutput.WriteXXX() is called WriteLineHelper.WriteCallback wl = new WriteLineHelper.WriteCallback(this.OnWriteLine); WriteLineHelper.WriteCallback w = new WriteLineHelper.WriteCallback(this.OnWrite); if (_forceNewLine) { _writeLineHelper = new WriteLineHelper(/*lineWrap*/ false, wl, null, this.DisplayCells); } else { _writeLineHelper = new WriteLineHelper(/*lineWrap*/ false, wl, w, this.DisplayCells); } }
private ChoicePromptHandler CreateChoicePromptHandler() { if (this.activePromptHandler != null) { Logger.Write( LogLevel.Error, "Prompt handler requested while another prompt is already active."); } ChoicePromptHandler choicePromptHandler = this.OnCreateChoicePromptHandler(); this.activePromptHandler = choicePromptHandler; this.activePromptHandler.PromptCancelled += activePromptHandler_PromptCancelled; return choicePromptHandler; }
private void activePromptHandler_PromptCancelled(object sender, EventArgs e) { // Clean up the existing prompt this.activePromptHandler.PromptCancelled -= activePromptHandler_PromptCancelled; this.activePromptHandler = null; }
/// <summary> /// constructor for the ConsoleLineOutput /// </summary> /// <param name="hostConsole">PSHostUserInterface to wrap</param> /// <param name="paging">true if we require prompting for page breaks</param> /// <param name="errorContext">error context to throw exceptions</param> internal ConsoleLineOutput(PSHostUserInterface hostConsole, bool paging, TerminatingErrorContext errorContext) { if (hostConsole == null) throw PSTraceSource.NewArgumentNullException("hostConsole"); if (errorContext == null) throw PSTraceSource.NewArgumentNullException("errorContext"); _console = hostConsole; _errorContext = errorContext; if (paging) { tracer.WriteLine("paging is needed"); // if we need to do paging, instantiate a prompt handler // that will take care of the screen interaction string promptString = StringUtil.Format(FormatAndOut_out_xxx.ConsoleLineOutput_PagingPrompt); _prompt = new PromptHandler(promptString, this); } PSHostRawUserInterface raw = _console.RawUI; if (raw != null) { tracer.WriteLine("there is a valid raw interface"); #if TEST_MULTICELL_ON_SINGLE_CELL_LOCALE // create a test instance with fake behavior this._displayCellsPSHost = new DisplayCellsTest(); #else // set only if we have a valid raw interface _displayCellsPSHost = new DisplayCellsPSHost(raw); #endif } // instantiate the helper to do the line processing when ILineOutput.WriteXXX() is called WriteLineHelper.WriteCallback wl = new WriteLineHelper.WriteCallback(this.OnWriteLine); WriteLineHelper.WriteCallback w = new WriteLineHelper.WriteCallback(this.OnWrite); if (_forceNewLine) { _writeLineHelper = new WriteLineHelper(/*lineWrap*/false, wl, null, this.DisplayCells); } else { _writeLineHelper = new WriteLineHelper(/*lineWrap*/false, wl, w, this.DisplayCells); } }