using Mindmagma.Curses; namespace SCI.CursesWrapper.UiElements; public class FooterWindow : Window { /// /// Class constructor /// /// Root NCurses screen ID /// Initial title to show public FooterWindow (nint screen, string defaultTitle = "") : base (0, CursesWrapper.GetHeight (screen) - 1, CursesWrapper.GetWidth (screen), 1) { var colorSchemeNormal = ColorSchemes.TopMenuNormal (); BackgroundColorId = colorSchemeNormal; NCurses.WindowAttributeOn (WindowId, colorSchemeNormal); DrawFooter (defaultTitle); } /// /// Draw the footer window and insert the specified text /// /// /// /// public void DrawFooter (string title, string left = "", string right = "") { Clear (); // TODO: Describe the last-character-in-window bug(fix) here var pad = (WindowSize.Width / 2) - (title.Length / 2) - 1; var finalString = " " + left.PadRight (pad) + title + (string.IsNullOrEmpty (right)? "" : right.PadLeft (pad) ); // String too long, leave out left and right text if (finalString.Length > WindowSize.Width - 1) { finalString = " ".PadLeft (pad) + title; } // String still too long, leave out the padding and left align title if (finalString.Length > WindowSize.Width - 1) { finalString = " " + title; } // String still too long, cut to size if (finalString.Length > WindowSize.Width - 1) { finalString = title.Substring (0, WindowSize.Width - 1); } try { NCurses.MoveWindowAddString (this, 0, 0, finalString); Draw (); } catch (Exception) {}; } }