Browse Source

Added shift keys status on the UICatalog StatusBar.

BDisp 5 years ago
parent
commit
d8e1577594
2 changed files with 35 additions and 3 deletions
  1. 1 1
      Terminal.Gui/Views/StatusBar.cs
  2. 34 2
      UICatalog/UICatalog.cs

+ 1 - 1
Terminal.Gui/Views/StatusBar.cs

@@ -47,7 +47,7 @@ namespace Terminal.Gui {
 		/// A <see cref="StatusItem.Title"/> set to `~F1~ Help` will render as *F1* using <see cref="ColorScheme.HotNormal"/> and
 		/// *Help* as <see cref="ColorScheme.HotNormal"/>.
 		/// </remarks>
-		public ustring Title { get; }
+		public ustring Title { get; set;}
 
 		/// <summary>
 		/// Gets or sets the action to be invoked when the statusbar item is triggered

+ 34 - 2
UICatalog/UICatalog.cs

@@ -50,6 +50,9 @@ namespace UICatalog {
 		private static List<Type> _scenarios;
 		private static ListView _scenarioListView;
 		private static StatusBar _statusBar;
+		private static StatusItem _capslock;
+		private static StatusItem _numlock;
+		private static StatusItem _scrolllock;
 
 		private static Scenario _runningScenario = null;
 
@@ -151,6 +154,10 @@ namespace UICatalog {
 			_categoryListView.SelectedItem = 0;
 			_categoryListView.OnSelectedChanged ();
 
+			_capslock = new StatusItem (Key.CharMask, "CapslockOff", null);
+			_numlock = new StatusItem (Key.CharMask, "NumlockOff", null);
+			_scrolllock = new StatusItem (Key.CharMask, "ScrolllockOff", null);
+
 			_statusBar = new StatusBar (new StatusItem [] {
 				//new StatusItem(Key.F1, "~F1~ Help", () => Help()),
 				new StatusItem(Key.ControlQ, "~CTRL-Q~ Quit", () => {
@@ -162,9 +169,10 @@ namespace UICatalog {
 						_runningScenario.RequestStop();
 					}
 				}),
+				_capslock,
+				_numlock,
+				_scrolllock
 			});
-
-
 		}
 
 		/// <summary>
@@ -292,6 +300,30 @@ namespace UICatalog {
 				else
 					_top.SetFocus (_leftPane);
 			}
+
+			if (a.KeyEvent.IsCapslock) {
+				_capslock.Title = "CapslockOn";
+				_statusBar.SetNeedsDisplay ();
+			} else {
+				_capslock.Title = "CapslockOff";
+				_statusBar.SetNeedsDisplay ();
+			}
+
+			if (a.KeyEvent.IsNumlock) {
+				_numlock.Title = "NumlockOn";
+				_statusBar.SetNeedsDisplay ();
+			} else {
+				_numlock.Title = "NumlockOff";
+				_statusBar.SetNeedsDisplay ();
+			}
+
+			if (a.KeyEvent.IsScrolllock) {
+				_scrolllock.Title = "ScrolllockOn";
+				_statusBar.SetNeedsDisplay ();
+			} else {
+				_scrolllock.Title = "ScrolllockOff";
+				_statusBar.SetNeedsDisplay ();
+			}
 		}
 
 		private static void CategoryListView_SelectedChanged (object sender, ListViewItemEventArgs e)