Example #1
0
        private PSConsoleReadLine()
        {
            _captureKeys = false;
            _savedKeys   = new Queue <ConsoleKeyInfo>();
            _demoStrings = new HistoryQueue <string>(100);
            _demoMode    = false;

            SetDefaultWindowsBindings();

            _buffer           = new StringBuilder(8 * 1024);
            _statusBuffer     = new StringBuilder(256);
            _savedCurrentLine = new HistoryItem();
            _queuedKeys       = new Queue <ConsoleKeyInfo>();

            _pushedEditGroupCount = new Stack <int>();

            _options = new PSConsoleReadlineOptions();

            _history = new HistoryQueue <HistoryItem>(Options.MaximumHistoryCount)
            {
                OnDequeue = HistoryOnDequeueHandler,
                OnEnqueue = HistoryOnEnqueueHandler
            };
            _currentHistoryIndex = 0;
            _hashedHistory       = new HashSet <string>();

            _killIndex = -1;    // So first add indexes 0.
            _killRing  = new List <string>(Options.MaximumKillRingCount);
        }
Example #2
0
        private PSConsoleReadLine()
        {
            _captureKeys = false;
            _savedKeys = new Queue<ConsoleKeyInfo>();
            _demoStrings = new HistoryQueue<string>(100);
            _demoMode = false;

            SetDefaultWindowsBindings();

            _buffer = new StringBuilder(8 * 1024);
            _statusBuffer = new StringBuilder(256);
            _savedCurrentLine = new HistoryItem();
            _queuedKeys = new Queue<ConsoleKeyInfo>();

            _pushedEditGroupCount = new Stack<int>();

            _options = new PSConsoleReadlineOptions();

            _history = new HistoryQueue<HistoryItem>(Options.MaximumHistoryCount)
            {
                OnDequeue = HistoryOnDequeueHandler,
                OnEnqueue = HistoryOnEnqueueHandler
            };
            _currentHistoryIndex = 0;
            _hashedHistory = new HashSet<string>();

            _killIndex = -1;    // So first add indexes 0.
            _killRing = new List<string>(Options.MaximumKillRingCount);
        }
Example #3
0
        private PSConsoleReadLine()
        {
            _mockableMethods = this;

            _captureKeys = false;
            _savedKeys   = new Queue <ConsoleKeyInfo>();
            _demoStrings = new HistoryQueue <string>(100);
            _demoMode    = false;

            SetDefaultWindowsBindings();

            _buffer           = new StringBuilder(8 * 1024);
            _statusBuffer     = new StringBuilder(256);
            _savedCurrentLine = new HistoryItem();
            _queuedKeys       = new Queue <ConsoleKeyInfo>();

            string hostName = null;

            try
            {
                var ps = PowerShell.Create(RunspaceMode.CurrentRunspace)
                         .AddCommand("Get-Variable").AddParameter("Name", "host").AddParameter("ValueOnly");
                var     results = ps.Invoke();
                dynamic host    = results.Count == 1 ? results[0] : null;
                if (host != null)
                {
                    hostName = host.Name as string;
                }
            }
            catch
            {
            }
            if (hostName == null)
            {
                hostName = "PSReadline";
            }
            _options = new PSConsoleReadlineOptions(hostName);
        }
Example #4
0
        private PSConsoleReadLine()
        {
            _mockableMethods = this;

            _captureKeys = false;
            _savedKeys = new Queue<ConsoleKeyInfo>();
            _demoStrings = new HistoryQueue<string>(100);
            _demoMode = false;

            SetDefaultWindowsBindings();

            _buffer = new StringBuilder(8 * 1024);
            _statusBuffer = new StringBuilder(256);
            _savedCurrentLine = new HistoryItem();
            _queuedKeys = new Queue<ConsoleKeyInfo>();

            string hostName = null;
            try
            {
                var ps = PowerShell.Create(RunspaceMode.CurrentRunspace)
                    .AddCommand("Get-Variable").AddParameter("Name", "host").AddParameter("ValueOnly");
                var results = ps.Invoke();
                dynamic host = results.Count == 1 ? results[0] : null;
                if (host != null)
                {
                    hostName = host.Name as string;
                }
            }
            catch
            {
            }
            if (hostName == null)
            {
                hostName = "PSReadline";
            }
            _options = new PSConsoleReadlineOptions(hostName);
        }