|
|
|
|
using SCI.CursesWrapper;
|
|
|
|
|
using ANSI_Fahrplan.Screens;
|
|
|
|
|
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 = CursesWrapper.InitNCurses ();
|
|
|
|
|
|
|
|
|
|
// -- Screen-wide input handler -- //
|
|
|
|
|
var inputHandler = new InputHandler (screen);
|
|
|
|
|
inputHandler.StartListening ();
|
|
|
|
|
|
|
|
|
|
// Register quit key on main screen
|
|
|
|
|
inputHandler.OnKeyPress += (object sender, NCursesKeyPressEventArgs e) => {
|
|
|
|
|
if (e.SourceWindow is not null) return;
|
|
|
|
|
if (e.KeyCode != 'q') return;
|
|
|
|
|
|
|
|
|
|
NCurses.EndWin ();
|
|
|
|
|
Console.WriteLine ("Bye-bye!");
|
|
|
|
|
Environment.Exit (0);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// -- 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 (screen);
|
|
|
|
|
introScreen.SetBorder (true);
|
|
|
|
|
introScreen.Redraw ();
|
|
|
|
|
|
|
|
|
|
var parentWindow = new Window (3, 3, 10 * 2, 10) {
|
|
|
|
|
BackgroundColorId = ColorSchemes.TextInputField ()
|
|
|
|
|
};
|
|
|
|
|
parentWindow.SetBorder (true);
|
|
|
|
|
parentWindow.Redraw ();
|
|
|
|
|
|
|
|
|
|
var childWindow = new Window (1, 1, 3, 3, parentWindow);
|
|
|
|
|
childWindow.SetBorder (true);
|
|
|
|
|
childWindow.Redraw ();
|
|
|
|
|
|
|
|
|
|
inputHandler.OnKeyPress += (object sender, NCursesKeyPressEventArgs e) => {
|
|
|
|
|
if (e.SourceWindow is not null) {
|
|
|
|
|
NCurses.WindowAddChar (e.SourceWindow.WindowId, e.KeyCode);
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
NCurses.AddChar (e.KeyCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (e.KeyCode != 'd') return;
|
|
|
|
|
|
|
|
|
|
parentWindow.Destroy ();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
NCurses.AddString ("Done drawing");
|
|
|
|
|
NCurses.Refresh ();
|
|
|
|
|
|
|
|
|
|
// 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<MenuItem> 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<MenuItem> {
|
|
|
|
|
// helpItem,
|
|
|
|
|
// upcomingItem,
|
|
|
|
|
// byDayItem,
|
|
|
|
|
// byRoomItem,
|
|
|
|
|
// bySpeakerItem,
|
|
|
|
|
// quitItem
|
|
|
|
|
// };
|
|
|
|
|
// }
|
|
|
|
|
}
|