static PSConsoleReadLine() { _singleton = new PSConsoleReadLine(); _breakHandlerGcHandle = GCHandle.Alloc(new BreakHandler(_singleton.BreakHandler)); NativeMethods.SetConsoleCtrlHandler((BreakHandler)_breakHandlerGcHandle.Target, true); _singleton._readKeyWaitHandle = new AutoResetEvent(false); _singleton._keyReadWaitHandle = new AutoResetEvent(false); _singleton._closingWaitHandle = new ManualResetEvent(false); _singleton._requestKeyWaitHandles = new WaitHandle[] { _singleton._keyReadWaitHandle, _singleton._closingWaitHandle }; _singleton._threadProcWaitHandles = new WaitHandle[] { _singleton._readKeyWaitHandle, _singleton._closingWaitHandle }; // This is only used for post-mortem debugging - 200 keys should be enough to reconstruct most command lines. _lastNKeys = new HistoryQueue <ConsoleKeyInfo>(200); // This is for a "being hosted in an alternate appdomain scenario" (the // DomainUnload event is not raised for the default appdomain). It allows us // to exit cleanly when the appdomain is unloaded but the process is not going // away. if (!AppDomain.CurrentDomain.IsDefaultAppDomain()) { AppDomain.CurrentDomain.DomainUnload += (x, y) => { _singleton._closingWaitHandle.Set(); _singleton._readKeyThread.Join(); // may need to wait for history to be written }; } _singleton._readKeyThread = new Thread(_singleton.ReadKeyThreadProc) { IsBackground = true }; _singleton._readKeyThread.Start(); }
static PSConsoleReadLine() { _singleton = new PSConsoleReadLine(); _breakHandlerGcHandle = GCHandle.Alloc(new BreakHandler(_singleton.BreakHandler)); NativeMethods.SetConsoleCtrlHandler((BreakHandler) _breakHandlerGcHandle.Target, true); _singleton._readKeyThread = new Thread(_singleton.ReadKeyThreadProc); _singleton._readKeyThread.Start(); _singleton._readKeyWaitHandle = new AutoResetEvent(false); _singleton._keyReadWaitHandle = new AutoResetEvent(false); _singleton._closingWaitHandle = new AutoResetEvent(false); _singleton._waitHandles = new WaitHandle[] { _singleton._keyReadWaitHandle, _singleton._closingWaitHandle }; }
static PSConsoleReadLine() { _singleton = new PSConsoleReadLine(); _breakHandlerGcHandle = GCHandle.Alloc(new BreakHandler(_singleton.BreakHandler)); NativeMethods.SetConsoleCtrlHandler((BreakHandler) _breakHandlerGcHandle.Target, true); _singleton._readKeyThread = new Thread(_singleton.ReadKeyThreadProc) {IsBackground = true}; _singleton._readKeyThread.Start(); _singleton._readKeyWaitHandle = new AutoResetEvent(false); _singleton._keyReadWaitHandle = new AutoResetEvent(false); _singleton._closingWaitHandle = new AutoResetEvent(false); _singleton._waitHandles = new WaitHandle[] { _singleton._keyReadWaitHandle, _singleton._closingWaitHandle }; // This is only used for post-mortem debugging - 200 keys should be enough to reconstruct most command lines. _lastNKeys = new HistoryQueue<ConsoleKeyInfo>(200); }
protected override void EndProcessing() { if (ParameterSetName.Equals(FunctionParameterSet)) { var function = (string)_dynamicParameters.Value[FunctionParameter].Value; var keyHandler = (Action <ConsoleKeyInfo?, object>) Delegate.CreateDelegate(typeof(Action <ConsoleKeyInfo?, object>), typeof(PSConsoleReadLine).GetMethod(function)); BriefDescription = function; PSConsoleReadLine.SetKeyHandler(Chord, keyHandler, BriefDescription, Description); } else { PSConsoleReadLine.SetKeyHandler(Chord, ScriptBlock, BriefDescription, Description); } }
static PSConsoleReadLine() { _singleton = new PSConsoleReadLine(); _breakHandlerGcHandle = GCHandle.Alloc(new BreakHandler(_singleton.BreakHandler)); NativeMethods.SetConsoleCtrlHandler((BreakHandler)_breakHandlerGcHandle.Target, true); _singleton._readKeyThread = new Thread(_singleton.ReadKeyThreadProc); _singleton._readKeyThread.IsBackground = true; _singleton._readKeyThread.Start(); _singleton._readKeyWaitHandle = new AutoResetEvent(false); _singleton._keyReadWaitHandle = new AutoResetEvent(false); _singleton._closingWaitHandle = new AutoResetEvent(false); _singleton._waitHandles = new WaitHandle[] { _singleton._keyReadWaitHandle, _singleton._closingWaitHandle }; // This is only used for post-mortem debugging - 200 keys should be enough to reconstruct most command lines. _lastNKeys = new HistoryQueue <ConsoleKeyInfo>(200); }
protected override void EndProcessing() { bool bound = true; bool unbound = true; if (_bound.HasValue && _unbound.HasValue) { bound = _bound.Value.IsPresent; unbound = _unbound.Value.IsPresent; } else if (_bound.HasValue) { bound = _bound.Value.IsPresent; unbound = false; } else if (_unbound.HasValue) { bound = false; unbound = _unbound.Value.IsPresent; } WriteObject(PSConsoleReadLine.GetKeyHandlers(bound, unbound), true); }
protected override void EndProcessing() { WriteObject(PSConsoleReadLine.GetKeyHandlers(), true); }
protected override void EndProcessing() { WriteObject(PSConsoleReadLine.GetOptions()); }
public abstract void Redo(PSConsoleReadLine singleton);
public override void Undo(PSConsoleReadLine singleton) { _singleton._buffer.Insert(_deleteStartPosition, _deletedString); _singleton._current = _deleteStartPosition + _deletedString.Length; }
public override void Redo(PSConsoleReadLine singleton) { _singleton._buffer.Insert(_insertStartPosition, _insertedString); _singleton._current += _insertedString.Length; }
public override void Undo(PSConsoleReadLine singleton) { Debug.Assert(singleton._buffer[_insertStartPosition] == _insertedCharacter, "Character to undo is not what it should be"); _singleton._buffer.Remove(_insertStartPosition, 1); _singleton._current = _insertStartPosition; }
public override void Redo(PSConsoleReadLine singleton) { _singleton._buffer.Insert(_insertStartPosition, _insertedCharacter); _singleton._current++; }
public override void Redo(PSConsoleReadLine singleton) { _singleton._buffer.Remove(_deleteStartPosition, _deletedString.Length); _singleton._current = _deleteStartPosition; }
public override void Undo(PSConsoleReadLine singleton) { Debug.Assert(singleton._buffer.ToString(_insertStartPosition, _insertedString.Length).Equals(_insertedString), "Character to undo is not what it should be"); _singleton._buffer.Remove(_insertStartPosition, _insertedString.Length); _singleton._current = _insertStartPosition; }
public override void Redo(PSConsoleReadLine singleton) { foreach (var editItem in _groupedEditItems) { editItem.Redo(singleton); } }
public override void Undo(PSConsoleReadLine singleton) { for (int i = _groupedEditItems.Count - 1; i >= 0; i--) { _groupedEditItems[i].Undo(singleton); } }
protected override void EndProcessing() { PSConsoleReadLine.SetOptions(this); }
public abstract void Undo(PSConsoleReadLine singleton);
protected override void EndProcessing() { PSConsoleReadLine.RemoveKeyHandler(Chord); }
protected override void EndProcessing() { PSConsoleReadLine.SetKeyHandler(Key, CtrlXPrefix.IsPresent, Handler, BriefDescription, LongDescription); }