diff --git a/StandaloneExample/Program.cs b/StandaloneExample/Program.cs
index bd50c02cd5..2cf758b6a8 100644
--- a/StandaloneExample/Program.cs
+++ b/StandaloneExample/Program.cs
@@ -165,6 +165,14 @@ static void Close ()
MessageBox.ErrorQuery (50, 5, "Error", "There is nothing to close", "Ok");
}
+ static void Help() {
+ MessageBox.Query(50, 7, "Help", "This is a small help\nBe kind.", "Ok");
+ }
+
+ static void ExitProgram() {
+ if (Quit ()) Application.Top.Running = false;
+ }
+
public static Label ml;
static void Main ()
{
@@ -185,7 +193,7 @@ static void Main ()
new MenuItem ("_New", "Creates new file", NewFile),
new MenuItem ("_Open", "", null),
new MenuItem ("_Close", "", () => Close ()),
- new MenuItem ("_Quit", "", () => { if (Quit ()) top.Running = false; })
+ new MenuItem ("_Quit", "^X", () => ExitProgram())
}),
new MenuBarItem ("_Edit", new MenuItem [] {
new MenuItem ("_Copy", "", null),
@@ -194,6 +202,14 @@ static void Main ()
})
});
+ var statusBar = new StatusBar(new StatusItem[] {
+ new StatusItem(Key.F1, "~F1~ Help", () => Help()),
+ new StatusItem(Key.F2, "~F2~ Load", null),
+ new StatusItem(Key.F3, "~F3~ Save", null),
+ new StatusItem(Key.ControlX, "~^X~ Quit", () => ExitProgram()),
+ });
+
+
ShowEntries (win);
int count = 0;
ml = new Label (new Rect (3, 17, 47, 1), "Mouse: ");
@@ -203,8 +219,8 @@ static void Main ()
win.Add (ml);
- top.Add (win, menu);
- top.Add (menu);
+ top.Add (win, menu, statusBar);
+
Application.Run ();
}
}
\ No newline at end of file
diff --git a/StandaloneExample/StandaloneExample.csproj b/StandaloneExample/StandaloneExample.csproj
index dded31d0f8..4092f6dec2 100644
--- a/StandaloneExample/StandaloneExample.csproj
+++ b/StandaloneExample/StandaloneExample.csproj
@@ -7,6 +7,7 @@
-
+
+
diff --git a/Terminal.Gui/Views/Menu.cs b/Terminal.Gui/Views/Menu.cs
index e7c9e686c6..e789f841fd 100644
--- a/Terminal.Gui/Views/Menu.cs
+++ b/Terminal.Gui/Views/Menu.cs
@@ -131,13 +131,13 @@ static Rect MakeFrame (int x, int y, MenuItem [] items)
maxW = Math.Max (l, maxW);
}
- current = -1;
+ /* current = -1;
for (int i = 0; i < items.Length; i++) {
if (items [i] != null) {
current = i;
break;
}
- }
+ } */
return new Rect (x, y, maxW + 2, items.Length + 2);
}
@@ -205,7 +205,7 @@ public override bool ProcessKey (KeyEvent kb)
current--;
if (current < 0)
current = barItems.Children.Length - 1;
- } while (barItems.Children [current] == null)
+ } while (barItems.Children [current] == null);
SetNeedsDisplay ();
break;
case Key.CursorDown:
@@ -213,7 +213,7 @@ public override bool ProcessKey (KeyEvent kb)
current++;
if (current == barItems.Children.Length)
current = 0;
- } while (barItems.Children [current] == null)
+ } while (barItems.Children [current] == null);
SetNeedsDisplay ();
break;
case Key.CursorLeft:
@@ -424,22 +424,22 @@ internal void NextMenu ()
internal bool FindAndOpenMenuByHotkey(KeyEvent kb)
{
int pos = 0;
- var c = ((uint)kb.Key & (uint)Key.CharMask);
+ var c = ((uint)kb.Key & (uint)Key.CharMask);
for (int i = 0; i < Menus.Length; i++)
{
// TODO: this code is duplicated, hotkey should be part of the MenuBarItem
var mi = Menus[i];
int p = mi.Title.IndexOf('_');
if (p != -1 && p + 1 < mi.Title.Length) {
- if (mi.Title[p + 1] == c) {
- OpenMenu(i);
+ if (mi.Title[p + 1] == c) {
+ OpenMenu(i);
return true;
}
}
- }
+ }
return false;
- }
-
+ }
+
public override bool ProcessHotKey (KeyEvent kb)
{
if (kb.Key == Key.F9) {
diff --git a/Terminal.Gui/Views/StatusBar.cs b/Terminal.Gui/Views/StatusBar.cs
new file mode 100644
index 0000000000..8fdde36e27
--- /dev/null
+++ b/Terminal.Gui/Views/StatusBar.cs
@@ -0,0 +1,88 @@
+using System;
+using NStack;
+
+namespace Terminal.Gui
+{
+ public class StatusItem
+ {
+ public StatusItem(Key shortCut, ustring title, Action action)
+ {
+ Title = title ?? "";
+ ShortCut = shortCut;
+ Action = action;
+
+ }
+
+ ///
+ /// This is the global setting that can be used as a global shortcut to invoke the action on the menu.
+ ///
+ public Key ShortCut;
+
+ ///
+ /// Gets or sets the title.
+ ///
+ /// The title.
+ public ustring Title { get; set; }
+
+ ///
+ /// Gets or sets the action to be invoked when the menu is triggered
+ ///
+ /// Method to invoke.
+ public Action Action { get; set; }
+ };
+
+ public class StatusBar : View
+ {
+ public StatusItem [] Items { get; set; }
+
+ public StatusBar(StatusItem [] items) : base()
+ {
+ X = 0;
+ Y = Application.Driver.Rows-1; // TODO: using internals of Application
+ Width = Dim.Fill ();
+ Height = 1;
+ Items = items;
+ CanFocus = false;
+ ColorScheme = Colors.Menu;
+ }
+
+ Attribute ToggleScheme(Attribute scheme) {
+ var result = scheme==ColorScheme.Normal ? ColorScheme.HotNormal : ColorScheme.Normal;
+ Driver.SetAttribute(result);
+ return result;
+ }
+
+ public override void Redraw(Rect region) {
+ Move (0, 0);
+ Driver.SetAttribute (ColorScheme.Normal);
+ for (int i = 0; i < Frame.Width; i++)
+ Driver.AddRune (' ');
+
+ Move (1, 0);
+ var scheme = ColorScheme.Normal;
+ Driver.SetAttribute(scheme);
+ for(int i=0; i