diff --git a/Example/demo.cs b/Example/demo.cs
index faf6759d0..ca9681517 100644
--- a/Example/demo.cs
+++ b/Example/demo.cs
@@ -649,12 +649,9 @@ static class Demo {
new StatusItem(Key.F3, "~F3~ Save", Save),
new StatusItem(Key.ControlQ, "~^Q~ Quit", () => { if (Quit ()) top.Running = false; }),
}) {
- Parent = null,
};
win.Add (drag, dragText);
-#if true
- // FIXED: This currently causes a stack overflow, because it is referencing a window that has not had its size allocated yet
var bottom = new Label ("This should go on the bottom of the same top-level!");
win.Add (bottom);
@@ -667,7 +664,6 @@ static class Demo {
bottom2.X = Pos.Left (win);
bottom2.Y = Pos.Bottom (win);
};
-#endif
win.KeyPress += Win_KeyPress;
diff --git a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs
index 4c6be0307..6c482f666 100644
--- a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs
+++ b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs
@@ -420,6 +420,47 @@ namespace Terminal.Gui {
return v;
}
}
+
+#if false // See: https://github.com/migueldeicaza/gui.cs/issues/357
+ [StructLayout (LayoutKind.Sequential)]
+ public struct SMALL_RECT {
+ public short Left;
+ public short Top;
+ public short Right;
+ public short Bottom;
+
+ public SMALL_RECT (short Left, short Top, short Right, short Bottom)
+ {
+ this.Left = Left;
+ this.Top = Top;
+ this.Right = Right;
+ this.Bottom = Bottom;
+ }
+ }
+
+ [StructLayout (LayoutKind.Sequential)]
+ public struct CONSOLE_SCREEN_BUFFER_INFO {
+ public int dwSize;
+ public int dwCursorPosition;
+ public short wAttributes;
+ public SMALL_RECT srWindow;
+ public int dwMaximumWindowSize;
+ }
+
+ [DllImport ("kernel32.dll", SetLastError = true)]
+ static extern bool GetConsoleScreenBufferInfo (IntPtr hConsoleOutput, out CONSOLE_SCREEN_BUFFER_INFO ConsoleScreenBufferInfo);
+
+ // Theoretically GetConsoleScreenBuffer height should give the console Windoww size
+ // It does not work, however, and always returns the size the window was initially created at
+ internal Size GetWindowSize ()
+ {
+ var consoleScreenBufferInfo = new CONSOLE_SCREEN_BUFFER_INFO ();
+ //consoleScreenBufferInfo.dwSize = Marshal.SizeOf (typeof (CONSOLE_SCREEN_BUFFER_INFO));
+ GetConsoleScreenBufferInfo (OutputHandle, out consoleScreenBufferInfo);
+ return new Size (consoleScreenBufferInfo.srWindow.Right - consoleScreenBufferInfo.srWindow.Left,
+ consoleScreenBufferInfo.srWindow.Bottom - consoleScreenBufferInfo.srWindow.Top);
+ }
+#endif
}
internal class WindowsDriver : ConsoleDriver, IMainLoopDriver {
@@ -727,6 +768,12 @@ namespace Terminal.Gui {
UpdateOffScreen ();
TerminalResized?.Invoke ();
break;
+
+ case WindowsConsole.EventType.Focus:
+ break;
+
+ default:
+ break;
}
result = null;
}
diff --git a/Terminal.Gui/Views/StatusBar.cs b/Terminal.Gui/Views/StatusBar.cs
index c666f838b..9e5e1c3fa 100644
--- a/Terminal.Gui/Views/StatusBar.cs
+++ b/Terminal.Gui/Views/StatusBar.cs
@@ -63,41 +63,6 @@ namespace Terminal.Gui {
/// So for each context must be a new instance of a statusbar.
///
public class StatusBar : View {
- // After attempting to implement this, I noticed that there are hard dependencies
- // on StatusBar and MenuBars within core. They will need to be refactored for having the
- // StatusBar work at the top
-#if SNAP_TO_TOP
- ///
- /// The style supported by StatusBar
- ///
- public enum StatusBarStyle {
- Default = 0,
- ///
- /// The StatusBar will snap at the the bottom line of the Parent view.
- /// If the console window is made larger while the app is runing, the StatusBar
- /// will continue to snap to the bottom line of the Parent, staying visible.
- /// On consoles that support resizing of console apps (e.g. Windows Terminal and ConEmu),
- /// if the console window is subsequently made shorter, the status bar will remain visible
- /// as the Parent view resizes. If Parent is null, the StatusBar will snap to the bottom line
- /// of the console window.
- /// This is the default.
- ///
- SnapToBottom = Default,
-
- ///
- /// The StatusBar will act identically to MenuBar, snapping to the first line of the
- /// console window.
- ///
- SnapToTop = 1,
- }
-
- public StatusBarStyle Style { get; set; } = StatusBarStyle.Default;
-#endif
- ///
- /// The parent view of the .
- ///
- public View Parent { get; set; }
-
///
/// The items that compose the
///
@@ -110,7 +75,7 @@ namespace Terminal.Gui {
///
/// Initializes a new instance of the class with the specified set of s.
- /// The will be drawn on the lowest line of the terminal or (if not null).
+ /// The will be drawn on the lowest line of the terminal or (if not null).
///
/// A list of statusbar items.
public StatusBar (StatusItem [] items) : base ()
@@ -125,26 +90,14 @@ namespace Terminal.Gui {
Width = Dim.Fill ();
Height = 1;
- LayoutComplete += (e) => {
+ Application.Resized += (e) => {
X = 0;
Height = 1;
-#if SNAP_TO_TOP
- switch (Style) {
- case StatusBarStyle.SnapToTop:
- X = 0;
- Y = 0;
- break;
- case StatusBarStyle.SnapToBottom:
-#endif
- if (Parent == null) {
+ if (SuperView == null || SuperView == Application.Top) {
Y = Driver.Rows - 1;
} else {
- Y = Pos.Bottom (Parent);
+ Y = Pos.Bottom (SuperView);
}
-#if SNAP_TO_TOP
- break;
- }
-#endif
};
}