using ANSI_Fahrplan.Screens; using ANSI_Fahrplan.UiElements; using Mindmagma.Curses; namespace ANSI_Fahrplan; class Program { private static void Main (string [] args) { //Playground.Run (args); /** * General procedure: * - Draw welcome screen * - User picks the view they want to see * - Data is being pulled from server * - Data is being read, processed and displayed in the selected view * - User can scroll up and down with Up and Down the view if it is longer than one page * - User can change date, room, speaker etc. by pressing left and right * - User can change the list type with function keys **/ var screen = NCurses.InitScreen (); NCurses.SetCursor (0); NCurses.NoEcho (); var hasColors = NCurses.HasColors (); if (hasColors) { NCurses.StartColor (); ColorSchemes.InitAll (); } // -- Screen-wide input handler -- // var screenInputHandler = new InputHandler (screen); screenInputHandler.StartListening (); // -- Create menu bar -- // var topMenu = new TopMenu (screen, CreateMenuItems (screen, screenInputHandler)); // -- Show introduction screen -- // NCurses.GetMaxYX (screen, out int height, out int width); var innerWindow = NCurses.NewWindow (height - 2, width - 4, 1, 2); NCurses.Box (innerWindow, (char) 0, (char) 0); //var introScreen = new IntroScreen (innerWindow); //introScreen.Show (); // Wait until the input handler routine stops while (true) Thread.Sleep (500); NCurses.EndWin (); Console.WriteLine ("Oh wow, the input handler crashed, that's not supposed to happen. Sorry!"); Environment.Exit (1); } private static List CreateMenuItems (nint screen, InputHandler inputHandler) { var helpItem = new MenuItem ("Help", "F1", inputHandler); var upcomingItem = new MenuItem ("Upcoming", "F2", inputHandler); var byDayItem = new MenuItem ("By Day", "F3", inputHandler); var byRoomItem = new MenuItem ("By Room", "F4", inputHandler); var bySpeakerItem = new MenuItem ("By Speaker", "F5", inputHandler); var quitItem = new MenuItem ("Quit", "q", inputHandler); quitItem.OnItemActivated += (object? sender, EventArgs e) => { NCurses.EndWin (); Console.WriteLine ("Bye-bye!"); Environment.Exit (0); }; helpItem.OnItemActivated += (object? sender, EventArgs e) => { InputBox.InputCompleted callback = (string ee) => { NCurses.MoveAddString (3, 3, $"<{ee}>"); }; new InputBox().RequestInput (screen, inputHandler, callback, "Please enter some text now:"); }; return new List { helpItem, upcomingItem, byDayItem, byRoomItem, bySpeakerItem, quitItem }; } }