コード例 #1
0
ファイル: ReadLine.cs プロジェクト: twsouthwick/PSReadLine
        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();
        }
コード例 #2
0
ファイル: ReadLine.cs プロジェクト: pankajbharti/PSReadLine
        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 };
        }
コード例 #3
0
ファイル: ReadLine.cs プロジェクト: powercode/PSReadLine
        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);
        }
コード例 #4
0
ファイル: Cmdlets.cs プロジェクト: emandres/PSReadLine
 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);
     }
 }
コード例 #5
0
ファイル: ReadLine.cs プロジェクト: Prophasi/PSReadLine
        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);
        }
コード例 #6
0
ファイル: Cmdlets.cs プロジェクト: emandres/PSReadLine
        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);
        }
コード例 #7
0
 protected override void EndProcessing()
 {
     WriteObject(PSConsoleReadLine.GetKeyHandlers(), true);
 }
コード例 #8
0
ファイル: Cmdlets.cs プロジェクト: emandres/PSReadLine
 protected override void EndProcessing()
 {
     WriteObject(PSConsoleReadLine.GetOptions());
 }
コード例 #9
0
 public abstract void Redo(PSConsoleReadLine singleton);
コード例 #10
0
 public override void Undo(PSConsoleReadLine singleton)
 {
     _singleton._buffer.Insert(_deleteStartPosition, _deletedString);
     _singleton._current = _deleteStartPosition + _deletedString.Length;
 }
コード例 #11
0
ファイル: UndoRedo.cs プロジェクト: pankajbharti/PSReadLine
 public override void Redo(PSConsoleReadLine singleton)
 {
     _singleton._buffer.Insert(_insertStartPosition, _insertedString);
     _singleton._current += _insertedString.Length;
 }
コード例 #12
0
ファイル: UndoRedo.cs プロジェクト: pankajbharti/PSReadLine
 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;
 }
コード例 #13
0
ファイル: UndoRedo.cs プロジェクト: pankajbharti/PSReadLine
 public override void Redo(PSConsoleReadLine singleton)
 {
     _singleton._buffer.Insert(_insertStartPosition, _insertedCharacter);
     _singleton._current++;
 }
コード例 #14
0
ファイル: UndoRedo.cs プロジェクト: pankajbharti/PSReadLine
 public override void Undo(PSConsoleReadLine singleton)
 {
     _singleton._buffer.Insert(_deleteStartPosition, _deletedString);
     _singleton._current = _deleteStartPosition + _deletedString.Length;
 }
コード例 #15
0
ファイル: UndoRedo.cs プロジェクト: pankajbharti/PSReadLine
 public override void Redo(PSConsoleReadLine singleton)
 {
     _singleton._buffer.Remove(_deleteStartPosition, _deletedString.Length);
     _singleton._current = _deleteStartPosition;
 }
コード例 #16
0
 public override void Redo(PSConsoleReadLine singleton)
 {
     _singleton._buffer.Insert(_insertStartPosition, _insertedCharacter);
     _singleton._current++;
 }
コード例 #17
0
 public override void Redo(PSConsoleReadLine singleton)
 {
     _singleton._buffer.Insert(_insertStartPosition, _insertedString);
     _singleton._current += _insertedString.Length;
 }
コード例 #18
0
ファイル: UndoRedo.cs プロジェクト: pankajbharti/PSReadLine
 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;
 }
コード例 #19
0
 public override void Redo(PSConsoleReadLine singleton)
 {
     _singleton._buffer.Remove(_deleteStartPosition, _deletedString.Length);
     _singleton._current = _deleteStartPosition;
 }
コード例 #20
0
ファイル: UndoRedo.cs プロジェクト: pankajbharti/PSReadLine
 public override void Redo(PSConsoleReadLine singleton)
 {
     foreach (var editItem in _groupedEditItems)
     {
         editItem.Redo(singleton);
     }
 }
コード例 #21
0
 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;
 }
コード例 #22
0
ファイル: UndoRedo.cs プロジェクト: pankajbharti/PSReadLine
 public override void Undo(PSConsoleReadLine singleton)
 {
     for (int i = _groupedEditItems.Count - 1; i >= 0; i--)
     {
         _groupedEditItems[i].Undo(singleton);
     }
 }
コード例 #23
0
ファイル: Cmdlets.cs プロジェクト: emandres/PSReadLine
 protected override void EndProcessing()
 {
     PSConsoleReadLine.SetOptions(this);
 }
コード例 #24
0
ファイル: UndoRedo.cs プロジェクト: pankajbharti/PSReadLine
 public abstract void Undo(PSConsoleReadLine singleton);
コード例 #25
0
 protected override void EndProcessing()
 {
     PSConsoleReadLine.RemoveKeyHandler(Chord);
 }
コード例 #26
0
 protected override void EndProcessing()
 {
     PSConsoleReadLine.SetKeyHandler(Key, CtrlXPrefix.IsPresent, Handler, BriefDescription, LongDescription);
 }