You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
3.2 KiB

using Fahrplan;
using Mindmagma.Curses;
using Newtonsoft.Json;
using SCI.CursesWrapper;
namespace ANSI_Fahrplan;
public class Playground {
public static void Run (string [] args) {
Console.WriteLine ("Program initializing Curses...");
// var jsonString = File.ReadAllText ("schedule.json");
// var schedule = JsonConvert.DeserializeObject<Fahrplan.Root> (jsonString);
// foreach (var day in schedule.schedule.conference.days) {
// Console.WriteLine ($"Day: {day.date}, {day.index}");
// foreach (var room in day.rooms) {
// Console.WriteLine ($" \\__ Room: {room.Key}");
// foreach (var ev in room.Value) {
// if (ev is null) continue;
// Console.WriteLine ($" \\__ Event: {ev.title}");
// }
// }
// }
var screen = NCurses.InitScreen ();
NCurses.NoEcho ();
NCurses.CBreak ();
NCurses.SetCursor (0);
var hasColors = NCurses.HasColors ();
if (hasColors) {
NCurses.StartColor ();
NCurses.InitPair (1, CursesColor.WHITE, CursesColor.BLUE);
//ColorPairs.InitColors ();
}
var win1 = NCurses.NewWindow (10, 20, 10, 10);
NCurses.Box (win1, (char) 0, (char) 0);
NCurses.WindowBackground (win1, ColorSchemes.Default ());
NCurses.MoveWindowAddString (win1, 1, 1, "Hello world!");
// Draw windows
NCurses.Refresh ();
NCurses.WindowRefresh (win1);
NCurses.GetChar ();
NCurses.EndWin ();
/*var window = CreateWindowCentered (screen, 40, 12);
NCurses.WindowBackground (window, NCurses.ColorPair (1));
NCurses.WindowAttributeOn (window, NCurses.ColorPair (1));*/
//NCurses.GetMaxYX (screen, out int screenHeight, out int screenWidth);
//NCurses.MoveAddString (screenHeight - 1, 0, "NCurses Example");
/*var menuItems = new List<TopMenu.MenuItem> () {
new TopMenu.MenuItem () { Label = "Test 1" },
new TopMenu.MenuItem () { Label = "Test 2" },
new TopMenu.MenuItem () { Label = "Test 3" },
};
var menu = new TopMenu (screen) { MenuItems = menuItems };
menu.Render ();*/
var msgBoxResponse = MessageBox.Show (screen, "Hello World, this is a message box text, yippee!! Let's make this text even longer, wooowiieeeee!", MessageBox.MessageBoxButtons.YesNo);
NCurses.AddString ($"Input was {msgBoxResponse}");
NCurses.Refresh ();
var inputTask = Task.Run (() => InputRoutine ());
while (inputTask.Status == TaskStatus.WaitingToRun);
while (inputTask.Status == TaskStatus.Running) {
NCurses.Refresh ();
//NCurses.WindowRefresh (window);
NCurses.Nap (1000 / 30);
}
//NCurses.AttributeOff (NCurses.ColorPair (1));
NCurses.EndWin ();
}
static void InputRoutine () {
int chr = 0;
while (chr != CursesKey.ESC) {
chr = NCurses.GetChar ();
/*if (chr == 265) {
menu.Render (0);
} else if (chr == 266) {
menu.Render (1);
} else if (chr == 267) {
menu.Render (2);
} else if (chr > 0) {
menu.Render ();
NCurses.MoveAddString (2, 10, $"You pressed the key {chr} ");
}*/
if (chr > 0) NCurses.MoveAddString (2, 10, $"You pressed the key {chr} ");
}
/*NCurses.WindowBorder (window, ' ', ' ', ' ',' ',' ',' ',' ',' ');
NCurses.WindowRefresh (window);
NCurses.DeleteWindow (window);*/
NCurses.MoveAddString (10, 10, "Input routine exited");
NCurses.Refresh ();
return;
}
}