public void ViGetKeyHandlers() { TestSetup(KeyMode.Vi); foreach (var handler in PSConsoleReadLine.GetKeyHandlers(includeBound: false, includeUnbound: true)) { Assert.Equal("Unbound", handler.Key); Assert.False(string.IsNullOrWhiteSpace(handler.Function)); Assert.False(string.IsNullOrWhiteSpace(handler.Description)); } foreach (var handler in PSConsoleReadLine.GetKeyHandlers(includeBound: true, includeUnbound: false)) { Assert.NotEqual("Unbound", handler.Key); Assert.False(string.IsNullOrWhiteSpace(handler.Function)); Assert.False(string.IsNullOrWhiteSpace(handler.Description)); } var handlers = PSConsoleReadLine.GetKeyHandlers(Chord: new string[] { "home" }); Assert.NotEmpty(handlers); foreach (var handler in handlers) { Assert.Contains("Home", handler.Key); } handlers = PSConsoleReadLine.GetKeyHandlers(Chord: new string[] { "d,0" }); Assert.NotEmpty(handlers); foreach (var handler in handlers) { Assert.Equal("<d,0>", handler.Key); } }
public void GetKeyHandlers() { System.Collections.Generic.IEnumerable <Microsoft.PowerShell.KeyHandler> handlers; foreach (var keymode in new[] { KeyMode.Cmd, KeyMode.Emacs }) { TestSetup(keymode); foreach (var handler in PSConsoleReadLine.GetKeyHandlers(includeBound: false, includeUnbound: true)) { Assert.Equal("Unbound", handler.Key); Assert.False(string.IsNullOrWhiteSpace(handler.Function)); Assert.False(string.IsNullOrWhiteSpace(handler.Description)); } foreach (var handler in PSConsoleReadLine.GetKeyHandlers(includeBound: true, includeUnbound: false)) { Assert.NotEqual("Unbound", handler.Key); Assert.False(string.IsNullOrWhiteSpace(handler.Function)); Assert.False(string.IsNullOrWhiteSpace(handler.Description)); } handlers = PSConsoleReadLine.GetKeyHandlers(Chord: new string[] { "home" }); Assert.NotEmpty(handlers); foreach (var handler in handlers) { Assert.Equal("Home", handler.Key); } } TestSetup(KeyMode.Emacs); handlers = PSConsoleReadLine.GetKeyHandlers(Chord: new string[] { "ctrl+x" }); Assert.NotEmpty(handlers); foreach (var handler in handlers) { Assert.Equal("Ctrl+x", handler.Key); } handlers = PSConsoleReadLine.GetKeyHandlers(Chord: new string[] { "ctrl+x,ctrl+e" }); Assert.NotEmpty(handlers); foreach (var handler in handlers) { Assert.Equal("Ctrl+x,Ctrl+e", handler.Key); } }
public void ViGetKeyHandlers() { TestSetup(KeyMode.Vi); foreach (var handler in PSConsoleReadLine.GetKeyHandlers(includeBound: false, includeUnbound: true)) { Assert.Equal("Unbound", handler.Key); Assert.False(string.IsNullOrWhiteSpace(handler.Function)); Assert.False(string.IsNullOrWhiteSpace(handler.Description)); } foreach (var handler in PSConsoleReadLine.GetKeyHandlers(includeBound: true, includeUnbound: false)) { Assert.NotEqual("Unbound", handler.Key); Assert.False(string.IsNullOrWhiteSpace(handler.Function)); Assert.False(string.IsNullOrWhiteSpace(handler.Description)); } }
public void TestGetKeyHandlers() { foreach (var keymode in new[] { KeyMode.Cmd, KeyMode.Emacs }) { TestSetup(keymode); foreach (var handler in PSConsoleReadLine.GetKeyHandlers(includeBound: false, includeUnbound: true)) { Assert.AreEqual("Unbound", handler.Key); Assert.IsFalse(string.IsNullOrWhiteSpace(handler.Function)); Assert.IsFalse(string.IsNullOrWhiteSpace(handler.Description)); } foreach (var handler in PSConsoleReadLine.GetKeyHandlers(includeBound: true, includeUnbound: false)) { Assert.AreNotEqual("Unbound", handler.Key); Assert.IsFalse(string.IsNullOrWhiteSpace(handler.Function)); Assert.IsFalse(string.IsNullOrWhiteSpace(handler.Description)); } } }
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); }