diff --git a/AsciiArt/AsciiArt.cs b/AsciiArt/AsciiArt.cs
index e65a78a..84f8315 100644
--- a/AsciiArt/AsciiArt.cs
+++ b/AsciiArt/AsciiArt.cs
@@ -56,16 +56,16 @@ public class AsciiArt {
public static string logo38c3_80x24 { get {
return
@"
-
- .;lllllllllc, .;c,:oddoc;. 'coddoc' ,clllllllll:.
- kMMMMWKOdc;'xx cWMN' 'lkXMMO .dNMM0l' kMN: :MMMMMX0xl:':K
- ,;'..':ok0kc ;NMMN' .cNKl .NXx;. NMMW. ';,...;lxOOo.
- l0NMMM0c. .:o0lldl, xMo,. dKKo ;kXWMMNd'
- 'WMMWo::oOXX0' :kO0kl;;lkK0k, OMMMMWK, 0MMMOc;lxKNKc
- .,;;clodkXMc :MKo. .l0W. cMMMW0o. ;0WN, .',;:lodxKM0
- cOkkxdollc::l: .XOddddxxxxxxkO cNMx ,0MMXo 'kOkxddolc:::l
- .lxkkkkxoc,. ':odxkkkxoc' ,lc;lxo:. :dxkkkxdl;.
-
+
+ .;lllllllllc, .;c,:oddoc;. 'coddoc' ,clllllllll:.
+ kMMMMWKOdc;'xx cWMN' 'lkXMMO .dNMM0l' kMN: :MMMMMX0xl:':K
+ ,;'..':ok0kc ;NMMN' .cNKl .NXx;. NMMW. ';,...;lxOOo.
+ l0NMMM0c. .:o0lldl, xMo,. dKKo ;kXWMMNd'
+ 'WMMWo::oOXX0' :kO0kl;;lkK0k, OMMMMWK, 0MMMOc;lxKNKc
+ .,;;clodkXMc :MKo. .l0W. cMMMW0o. ;0WN, .',;:lodxKM0
+ cOkkxdollc::l: .XOddddxxxxxxkO cNMx ,0MMXo 'kOkxddolc:::l
+ .lxkkkkxoc,. ':odxkkkxoc' ,lc;lxo:. :dxkkkxdl;.
+
";
}}
diff --git a/CursesWrapper.cs b/CursesWrapper.cs
index c74b94e..d3d8308 100755
--- a/CursesWrapper.cs
+++ b/CursesWrapper.cs
@@ -17,22 +17,22 @@ public class Helper {
/// nint - Pointer of new window
/// Throws exception if window is outside of screen bounds
public static nint CreateCenteredWindow (nint screen, int width, int height, bool borders = true) {
- NCurses.GetMaxYX (screen, out int screenHeight, out int screenWidth);
+ NCurses.GetMaxYX (screen, out int screenHeight, out int screenWidth);
- int originY = (screenHeight / 2) - (height / 2);
- int originX = (screenWidth / 2) - (width / 2);
+ int originY = (screenHeight / 2) - (height / 2);
+ int originX = (screenWidth / 2) - (width / 2);
- if (originX + width > screenWidth) throw new ArgumentOutOfRangeException ("width");
- if (originY + height > screenHeight) throw new ArgumentOutOfRangeException ("height");
+ if (originX + width > screenWidth) throw new ArgumentOutOfRangeException ("width");
+ if (originY + height > screenHeight) throw new ArgumentOutOfRangeException ("height");
- if (originX < 0) throw new ArgumentOutOfRangeException ("originX");
- if (originY < 0) throw new ArgumentOutOfRangeException ("originY");
+ if (originX < 0) throw new ArgumentOutOfRangeException ("originX");
+ if (originY < 0) throw new ArgumentOutOfRangeException ("originY");
- nint window = NCurses.NewWindow (height, width, originY, originX);
- if (borders) NCurses.Box (window, (char) 0, (char) 0);
+ nint window = NCurses.NewWindow (height, width, originY, originX);
+ if (borders) NCurses.Box (window, (char) 0, (char) 0);
- return window;
- }
+ return window;
+ }
///
/// Prints text horizontally centered to window (on a specific line);
@@ -70,13 +70,13 @@ public class MessageBox {
// then calculate the message box and inner pad origin X coords
var boxWidth = 50;
if (boxWidth + 3 >= screenWidth) boxWidth = screenWidth - 3;
- int originX = (screenWidth / 2) - (boxWidth / 2);
+ int originX = (screenWidth / 2) - (boxWidth / 2);
var padOriginX = originX + 2; // Add one for the border and for a single character padding
// Calculate sizes for the inner pad element
- var padWidth = boxWidth - 4; // Add four to the total box width due to the two character padding on both sides
+ var padWidth = boxWidth - 4; // Add four to the total box width due to the two character padding on both sides
var totalTextLines = (int) Math.Ceiling ((double) text.Length / padWidth); // Get total amount of lines required to hold all text limited by box width
- var padHeight = totalTextLines;
+ var padHeight = totalTextLines;
if (padHeight + 8 > screenHeight) { // If height required to show all text lines plus padding is larger than screen, reduce size of message box
padHeight = screenHeight - 8;
}
@@ -187,81 +187,3 @@ public class MessageBox {
return index;
}
}
-
-public class ColorPairs {
- public static int Ch_Topmenu_Label = 101;
- public static int Ch_Topmenu_Label_Active = 102;
-
- public static void InitColors () {
- NCurses.InitPair (101, CursesColor.WHITE, CursesColor.BLUE);
- NCurses.InitPair (102, CursesColor.BLACK, CursesColor.BLUE);
- }
-}
-
-public class TopMenu {
- private nint parentScreen;
- private nint childWindow;
-
- public List
private CancellationTokenSource? listeningRoutineCts;
- ///
- /// Class constructor
- /// Parent screen this InputHandler is attached to
- ///
- public InputHandler (nint screen) {
- rootScreen = screen;
- }
-
///
/// Start listening to key presses and call registered callbacks
///
@@ -96,59 +84,59 @@ public class InputHandler {
);
}
- ///
- /// Prepares the window for proper key press reading
- ///
- private void WindowSetup () {
- if (ActiveWindow is not null) {
- NCurses.Keypad (ActiveWindow.WindowId, true);
- NCurses.NoDelay (ActiveWindow.WindowId, false);
- } else {
- NCurses.Keypad (rootScreen, true);
- NCurses.NoDelay (rootScreen, false);
- }
- }
-
- ///
- /// Undoes any changes the setup routine configured for the active window
- ///
- private void WindowTeardown () {
- if (ActiveWindow is not null) {
- NCurses.Keypad (ActiveWindow.WindowId, false);
- NCurses.NoDelay (ActiveWindow.WindowId, true);
- } else {
- NCurses.Keypad (rootScreen, false);
- NCurses.NoDelay (rootScreen, true);
- }
- }
-
///
/// Actual keypress handler being called as Task by StartListening ()
///
private void _ListeningRoutine () {
if (listeningRoutineCts is null) return;
- WindowSetup ();
-
- int keyCode = -1;
-
while (!listeningRoutineCts.Token.IsCancellationRequested) {
- if (OnKeyPress is null) {
- Console.Title = "No handlers";
- } else {
- Console.Title = $"Got {OnKeyPress.GetInvocationList ().Length} handlers";
- }
-
+ int keyCode = -1;
+ int keyCode2 = -1;
+
if (ActiveWindow is not null) {
keyCode = NCurses.WindowGetChar (ActiveWindow.WindowId);
+
+ // If this block looks yanky; it is.
+ // This code checks if ESC was pressed and waits for another
+ // key press for another 10 milliseconds. This is to catch
+ // key combinations with the Alt key, as it is sent as
+ // [Alt] + []
+ if (keyCode == CursesKey.ESC) {
+ NCurses.WindowTimeOut (ActiveWindow.WindowId, 10);
+ try {
+ keyCode2 = NCurses.WindowGetChar (ActiveWindow.WindowId);
+ } catch (Exception) {
+ keyCode2 = -1;
+ }
+ NCurses.WindowTimeOut (ActiveWindow.WindowId, -1);
+ }
} else {
keyCode = NCurses.GetChar ();
+
+ // Janky solution, see above
+ if (keyCode == CursesKey.ESC) {
+ NCurses.TimeOut (10);
+ try {
+ keyCode2 = NCurses.GetChar ();
+ } catch (Exception) {
+ keyCode2 = -1;
+ }
+ NCurses.TimeOut (-1);
+ }
}
- // Do nothing until the key code is larger than -1
- if (keyCode < 0) continue;
+ // Do nothing until either key code is larger than -1
+ if (keyCode < 0 && keyCode2 < 0) continue;
+
+ // Test if [Alt]+[key] combination was pressed.
+ // This is due to [Alt]+[key] being sent as [ESC], [key]
+ bool isAltCombo = keyCode == CursesKey.ESC && keyCode2 != -1;
+ if (isAltCombo) {
+ keyCode = keyCode2;
+ }
- var eventArgs = new NCursesKeyPressEventArgs (keyCode, ActiveWindow);
+ var eventArgs = new NCursesKeyPressEventArgs (keyCode, ActiveWindow, isAltCombo);
// Handle any registered privileged key handlers
if (OnKeyPressPrivileged is not null) {
@@ -183,8 +171,12 @@ public class NCursesKeyPressEventArgs : EventArgs {
public bool CancelNextEvent { get; set; } = false;
- public NCursesKeyPressEventArgs (int keyCode, Window? sourceWindow) {
+ private bool _isAltCombination = false;
+ public bool IsAltCombination { get { return _isAltCombination; } }
+
+ public NCursesKeyPressEventArgs (int keyCode, Window? sourceWindow, bool isAltCombination) {
_keyCode = keyCode;
_sourceWindow = sourceWindow;
+ _isAltCombination = isAltCombination;
}
}
\ No newline at end of file
diff --git a/CursesWrapper/Window.cs b/CursesWrapper/Window.cs
index ecc13d4..e1699fa 100644
--- a/CursesWrapper/Window.cs
+++ b/CursesWrapper/Window.cs
@@ -5,261 +5,351 @@ using Mindmagma.Curses;
namespace SCI.CursesWrapper;
public class Window {
- ///
- /// Gets or sets the window position on the screen
- ///
- private Point _position;
- public Point Position {
- get {
- return _position;
- }
- set {
- if (ParentWindow is not null) {
- NCurses.WindowMove (
- WindowId,
- ParentWindow.Position.Y + value.Y,
- ParentWindow.Position.X + value.X
- );
- } else {
- NCurses.WindowMove (
- WindowId,
- value.Y,
- value.X
- );
- }
- _position = value;
- }
- }
-
- ///
- /// Gets or sets the width and height of the window
- ///
- private Size _windowSize;
- public Size WindowSize {
- get {
- return _windowSize;
- }
- set {
- _windowSize = value;
- }
- }
-
- ///
- /// Gets or sets the window background color pair
- ///
- private uint _backgroundColorId;
- public uint BackgroundColorId {
- get {
- return _backgroundColorId;
- }
- set {
- NCurses.WindowBackground (WindowId, value);
- Redraw ();
- _backgroundColorId = value;
- }
- }
-
- ///
- /// Sets the parent window
- ///
- private Window? _parentWindow;
- public Window? ParentWindow { get { return _parentWindow; }}
-
- ///
- /// Holds a list of children windows this window posesses
- ///
- private List _childWindows = new List ();
- public ReadOnlyCollection ChildWindows { get { return _childWindows.AsReadOnly (); }}
-
- ///
- /// Holds the pointer for this window
- ///
- private nint _windowId;
- public nint WindowId { get { return _windowId; }}
-
- ///
- /// Input handler assigned to this window
- ///
- private InputHandler? inputHandler;
-
- ///
- /// Event handler called when this window is active and a key is pressed
- ///
- public event InputHandler.KeypressEventHandler? OnKeyPress;
-
- ///
- /// Create new window by specifying X/Y and Width/Height geometry
- ///
- ///
- ///
- ///
- ///
- ///
- public Window (int x, int y, int width, int height, Window? parentWindow = null) {
- if (parentWindow is not null) {
- _windowId = NCurses.DeriveWindow (
- parentWindow.WindowId,
- height, width,
- y, x
- );
- } else {
- _windowId = NCurses.NewWindow (
- height, width,
- y, x
- );
- }
-
- Redraw ();
- }
-
- ///
- /// Create new window by specifying geometry through Point and Size objects
- ///
- ///
- ///
- ///
- public Window (Point position, Size windowSize, Window? parentWindow = null) {
- if (parentWindow is not null) {
- _windowId = NCurses.SubWindow (
- parentWindow.WindowId,
- windowSize.Height, windowSize.Width,
- position.Y, position.X
- );
- } else {
- _windowId = NCurses.NewWindow (
- windowSize.Height, windowSize.Width,
- position.Y, position.X
- );
- }
-
- Redraw ();
- }
-
- ///
- /// Adds a child window to this window
- ///
- ///
- public void AddChildWindow (Window child) {
- if (_childWindows.Contains (child)) return;
- _childWindows.Add (child);
- }
-
- ///
- /// Removes a child window from this window
- ///
- ///
- public void RemoveChildWindow (Window child) {
- if (!_childWindows.Contains (child)) return;
- _childWindows.Remove (child);
- }
-
- ///
- /// Discards all optimization options about drawn parts of this window.
- /// Call before drawing a sub window
- ///
- public void TouchWin () {
- NCurses.TouchWindow (WindowId);
- }
-
- ///
- /// Redraws this window
- ///
- public void Redraw () {
- NCurses.Refresh (); // TODO: Necessary?
-
- if (ChildWindows.Count > 0) {
- foreach (var window in ChildWindows) {
- window.Redraw ();
- }
- }
-
- if (ParentWindow is not null) ParentWindow.TouchWin ();
- NCurses.WindowRefresh (WindowId);
- }
-
- ///
- /// Destroys this window and all children windows
- ///
- public void Destroy () {
- if (ChildWindows.Count > 0) {
- foreach (var window in _childWindows) {
- window.Destroy ();
- }
- }
-
- if (inputHandler is not null) inputHandler.ActiveWindow = null;
- if (ParentWindow is not null) ParentWindow.RemoveChildWindow (this);
-
- UnregisterInputHandler ();
-
- SetBorder (false);
-
- NCurses.ClearWindow (WindowId);
- Console.Title = "About to destroy";
- NCurses.DeleteWindow (WindowId);
- Console.Title = "Destroyed";
-
- //TODO: Program hangs on DeleteWindow
- }
-
- ///
- /// Register an input handler for this window to attach to OnKeyPress events
- ///
- /// InputHandler to register
- public void RegisterInputHandler (InputHandler targetInputHandler) {
- if (inputHandler is not null) throw new Exception (
- "Another input handler is already registered"
- );
-
- inputHandler = targetInputHandler;
- inputHandler.OnKeyPress += KeyPressHandler;
- }
-
- ///
- /// Detach from all OnKeyPress events and unset input handler
- ///
- public void UnregisterInputHandler () {
- if (inputHandler is null) return;
-
- inputHandler.OnKeyPress -= KeyPressHandler;
- }
-
- ///
- /// Handle key press events from the input handler
- ///
- ///
- ///
- private void KeyPressHandler (object sender, NCursesKeyPressEventArgs e) {
- if (e.SourceWindow != this) return;
-
- if (OnKeyPress is not null) {
- OnKeyPress (sender, e);
- }
- }
-
- ///
- /// Tells the input handler this window is active
- ///
- public void SetWindowActive () {
- if (inputHandler is null) return;
-
- inputHandler.ActiveWindow = this;
- }
-
- ///
- /// Enables or disables a border around this window
- ///
- /// Sets the status of the border
- /// If specified, uses this character as the top and bottom border
- /// If specified, uses this character as the left and right border
- public void SetBorder (bool enabled, char? horizontalChar = null, char? verticalChar = null) {
- if (horizontalChar is null) horizontalChar = (char) 0;
- if (verticalChar is null) verticalChar = (char) 0;
-
- if (enabled) {
- NCurses.Box (WindowId, (char) horizontalChar, (char) verticalChar);
- } else {
- NCurses.Box (WindowId, ' ', ' ');
- }
- }
+ public const int InnerPadding = 1;
+
+ ///
+ /// Gets or sets the window position on the screen
+ ///
+ private Point _position;
+ public Point Position {
+ get {
+ return _position;
+ }
+ set {
+ if (ParentWindow is not null) {
+ int addedPadding = ParentWindow.BorderEnabled?
+ InnerPadding + 1 : 0;
+
+ NCurses.WindowMove (
+ WindowId,
+ ParentWindow.Position.Y + value.Y + addedPadding,
+ ParentWindow.Position.X + value.X + addedPadding
+ );
+ } else {
+ NCurses.WindowMove (
+ WindowId,
+ value.Y,
+ value.X
+ );
+ }
+ _position = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the width and height of the window
+ ///
+ private Size _windowSize;
+ public Size WindowSize {
+ get {
+ return _windowSize;
+ }
+ set {
+ _windowSize = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the window background color pair
+ ///
+ private uint _backgroundColorId;
+ public uint BackgroundColorId {
+ get {
+ return _backgroundColorId;
+ }
+ set {
+ NCurses.WindowBackground (WindowId, value);
+ Draw ();
+ _backgroundColorId = value;
+ }
+ }
+
+ private bool _borderEnabled;
+ public bool BorderEnabled {
+ get {
+ return _borderEnabled;
+ }
+ set {
+ SetBorder (value);
+ Draw ();
+ _borderEnabled = value;
+ }
+ }
+
+ ///
+ /// Sets the parent window
+ ///
+ private Window? _parentWindow;
+ public Window? ParentWindow { get { return _parentWindow; }}
+
+ ///
+ /// Holds a list of children windows this window posesses
+ ///
+ private List _childWindows = new List ();
+ public ReadOnlyCollection ChildWindows { get { return _childWindows.AsReadOnly (); }}
+
+ ///
+ /// Holds the pointer for this window
+ ///
+ private nint _windowId;
+ public nint WindowId { get { return _windowId; }}
+
+ ///
+ /// Input handler assigned to this window
+ ///
+ protected InputHandler? _targetInputHandler;
+ public InputHandler? TargetInputHandler { get { return _targetInputHandler; }}
+
+ ///
+ /// Event handler called when this window is active and a key is pressed
+ ///
+ public event InputHandler.KeypressEventHandler? OnKeyPress;
+
+ ///
+ /// Create new window by specifying X/Y and Width/Height geometry
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public Window (int x, int y, int width, int height, Window? parentWindow = null) {
+ _Initialize (new Point (x, y), new Size (width, height), parentWindow);
+ }
+
+ ///
+ /// Create new window by specifying geometry through Point and Size objects
+ ///
+ ///
+ ///
+ ///
+ public Window (Point position, Size windowSize, Window? parentWindow = null) {
+ _Initialize (position, windowSize, parentWindow);
+ }
+
+ ///
+ /// Create new window by specifying X/Y and Width/Height geometry
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public Window (int x, int y, int width, int height, InputHandler targetInputHandler, Window? parentWindow = null) {
+ _Initialize (new Point (x, y), new Size (width, height), parentWindow);
+ RegisterInputHandler (targetInputHandler);
+ SetWindowActive ();
+ }
+
+ ///
+ /// Create new window by specifying geometry through Point and Size objects
+ ///
+ ///
+ ///
+ ///
+ ///
+ public Window (Point position, Size windowSize, InputHandler targetInputHandler, Window? parentWindow = null) {
+ _Initialize (position, windowSize, parentWindow);
+ RegisterInputHandler (targetInputHandler);
+ SetWindowActive ();
+ }
+
+ ///
+ /// Actual initialization function for this class
+ ///
+ ///
+ ///
+ ///
+ private void _Initialize (Point position, Size windowSize, Window? parentWindow = null) {
+ if (parentWindow is not null) {
+ int addedPadding = parentWindow.BorderEnabled?
+ InnerPadding + 1 : 0;
+
+ _windowId = NCurses.DeriveWindow (
+ parentWindow.WindowId,
+ windowSize.Height, windowSize.Width,
+ position.Y + addedPadding, position.X + addedPadding
+ );
+
+ parentWindow.AddChildWindow (this);
+ } else {
+ _windowId = NCurses.NewWindow (
+ windowSize.Height, windowSize.Width,
+ position.Y, position.X
+ );
+ }
+
+ _position = position;
+ _windowSize = windowSize;
+ _parentWindow = parentWindow;
+
+ NCurses.Keypad (WindowId, true);
+
+ Draw ();
+ }
+
+ ///
+ /// Destroys the window and its sub-windows when the Window object is destroyed
+ ///
+ ~Window () {
+ Destroy ();
+ }
+
+ ///
+ /// Adds a child window to this window
+ ///
+ ///
+ public void AddChildWindow (Window child) {
+ if (_childWindows.Contains (child)) return;
+ _childWindows.Add (child);
+ }
+
+ ///
+ /// Removes a child window from this window
+ ///
+ ///
+ public void RemoveChildWindow (Window child) {
+ _childWindows.Remove (child);
+ }
+
+ ///
+ /// Discards all optimization options about drawn parts of this window.
+ /// Call before drawing a sub window
+ ///
+ public void TouchWin () {
+ NCurses.TouchWindow (WindowId);
+ }
+
+ ///
+ /// Draws this window and all sub windows
+ ///
+ public void Draw () {
+ NCurses.Refresh (); // TODO: Necessary?
+
+ foreach (var window in ChildWindows) {
+ window.Draw ();
+ }
+
+ if (ParentWindow is not null) ParentWindow.TouchWin ();
+ NCurses.WindowRefresh (WindowId);
+ }
+
+ ///
+ /// Destroys this window and all children windows
+ ///
+ public void Destroy () {
+ // Catch double destroy calls
+ if (WindowId == -1) throw new Exception ("Destroy called twice on object");
+
+ foreach (var window in _childWindows.ToList ()) {
+ window.Destroy ();
+ }
+
+ UnregisterInputHandler ();
+
+ // Prepare for screen clear
+ NCurses.WindowBackground (WindowId, NCurses.ColorPair (-1));
+ SetBorder (false);
+
+ // Clear window and redraw
+ NCurses.ClearWindow (WindowId);
+ Draw ();
+
+ NCurses.DeleteWindow (WindowId);
+ _windowId = -1;
+
+ // Ensures sure the parent is updated too
+ if (ParentWindow is not null) {
+ ParentWindow.RemoveChildWindow (this);
+ ParentWindow.Draw ();
+ }
+ }
+
+ ///
+ /// Register an input handler for this window to attach to OnKeyPress events
+ ///
+ /// InputHandler to register
+ public void RegisterInputHandler (InputHandler inputHandler) {
+ if (TargetInputHandler is not null) throw new Exception (
+ "Another input handler is already registered"
+ );
+
+ _targetInputHandler = inputHandler;
+ TargetInputHandler!.OnKeyPress += KeyPressHandler;
+ }
+
+ ///
+ /// Detach from all OnKeyPress events and unset input handler
+ ///
+ public void UnregisterInputHandler () {
+ if (TargetInputHandler is null) return;
+
+ if (TargetInputHandler.ActiveWindow == this) TargetInputHandler.ActiveWindow = null;
+ TargetInputHandler.OnKeyPress -= KeyPressHandler;
+ }
+
+ ///
+ /// Handle key press events from the input handler
+ ///
+ ///
+ ///
+ private void KeyPressHandler (object sender, NCursesKeyPressEventArgs e) {
+ if (e.SourceWindow != this) return;
+
+ if (OnKeyPress is not null) {
+ OnKeyPress (this, e);
+ }
+ }
+
+ ///
+ /// Tells the input handler this window is active
+ ///
+ public void SetWindowActive () {
+ if (TargetInputHandler is null) return;
+
+ TargetInputHandler.ActiveWindow = this;
+ Draw ();
+ }
+
+ ///
+ /// Enables or disables a border around this window
+ ///
+ /// Sets the status of the border
+ /// If specified, uses this character as the top and bottom border
+ /// If specified, uses this character as the left and right border
+ public void SetBorder (bool enabled, char? horizontalChar = null, char? verticalChar = null) {
+ if (horizontalChar is null) horizontalChar = (char) 0;
+ if (verticalChar is null) verticalChar = (char) 0;
+
+ if (enabled) {
+ NCurses.Box (WindowId, (char) horizontalChar, (char) verticalChar);
+ } else {
+ NCurses.Box (WindowId, ' ', ' ');
+ }
+ }
+
+ ///
+ /// Calcaulates the usable inner width of this window
+ ///
+ /// Usable inner width of window in columns
+ public int GetUsableWidth () {
+ if (BorderEnabled) {
+ return WindowSize.Width - 1 - InnerPadding;
+ } else {
+ return WindowSize.Width;
+ }
+ }
+
+ ///
+ /// Calcaulates the usable inner height of this window
+ ///
+ /// Usable inner height of window in rows
+ public int GetUsableHeight () {
+ if (BorderEnabled) {
+ return WindowSize.Height - 1 - InnerPadding;
+ } else {
+ return WindowSize.Height;
+ }
+ }
}
\ No newline at end of file
diff --git a/Fahrplan.cs b/Fahrplan.cs
index 384d4c1..7bcf0d1 100644
--- a/Fahrplan.cs
+++ b/Fahrplan.cs
@@ -4,94 +4,94 @@ using Newtonsoft.Json;
namespace Fahrplan;
public class Root {
- [JsonProperty("$schema")]
- public string schema { get; set; }
- public Generator generator { get; set; }
- public Schedule schedule { get; set; }
+ [JsonProperty("$schema")]
+ public string schema { get; set; }
+ public Generator generator { get; set; }
+ public Schedule schedule { get; set; }
}
public class Colors {
- public string primary { get; set; }
+ public string primary { get; set; }
}
public class Conference {
- public string acronym { get; set; }
- public string title { get; set; }
- public string start { get; set; }
- public string end { get; set; }
- public int daysCount { get; set; }
- public string timeslot_duration { get; set; }
- public string time_zone_name { get; set; }
- public Colors colors { get; set; }
- public List rooms { get; set; }
- public List