public static void Main(string[] args) { Console.WindowWidth = 100; Curses.InitScr(); Curses.StartColor(); Curses.InitPair(1, Colors.WHITE, Colors.BLACK); mainDisplay = new Window(Console.WindowHeight, Console.WindowWidth, 0, 0); mainDisplay.EnableScroll = true; Window commandInput = new Window(1, Console.WindowWidth, Console.WindowHeight - 1, 0); commandInput.Color = 1; mainDisplay.Color = 1; mCore.Init(EventHandler); CommandHandler.Initialize(); while (true) { commandInput.Clear(); commandInput.Add(">"); String command = commandInput.GetString(); CommandHandler.HandleCommand(command); commandInput.Refresh(); } }
private static void Main2() { Stdscr.Blocking = false; Curses.Echo = false; if (Curses.HasColors) { Curses.StartColor(); for (short i = 1; i < 8; ++i) { Curses.InitPair(i, color_table[i], Colors.BLACK); } } rng = new Random(); int flag = 0; while (Stdscr.GetChar() == -1) { int start, end, row, diff, direction; do { start = rng.Next(Curses.Cols - 3); end = rng.Next(Curses.Cols - 3); start = (start < 2) ? 2 : start; end = (end < 2) ? 2 : end; direction = (start > end) ? -1 : 1; diff = Math.Abs(start - end); } while (diff < 2 || diff >= Curses.Lines - 2); Stdscr.Attr = Attrs.NORMAL; for (row = 1; row < diff; ++row) { Stdscr.Add(Curses.Lines - row, row * direction + start, (direction < 0) ? "\\" : "/"); if (flag++ > 0) { MyRefresh(); Stdscr.Erase(); flag = 0; } } if (flag++ > 0) { MyRefresh(); flag = 0; } Explode(Curses.Lines - row, diff * direction + start); Stdscr.Erase(); MyRefresh(); } }
static void Main(string[] args) { // Init Curses Curses.InitScr(); Stdscr.Blocking = false; Curses.Echo = false; Keyboard.Init(); Stdscr.Keypad = true; if (Curses.HasColors) { Curses.StartColor(); for (short i = 1; i < 8; ++i) { Curses.InitPair(i, color_table[i], Colors.BLACK); } } // Init world. StateMachine.Switch(new IntroState()); bool running = true; Stopwatch time = new Stopwatch(); time.Start(); long spillover = 0; while (running) { if (time.ElapsedMilliseconds + spillover > 100) { Keyboard.UpdateKeys(); if (Keyboard.KeyDown(27)) { running = false; } StateMachine.Update(100); Keyboard.Reset(); // Game render StateMachine.Draw(); Stdscr.Move(Curses.Lines - 1, Curses.Cols - 1); Stdscr.Refresh(); spillover = (time.ElapsedMilliseconds + spillover) - 100; time.Restart(); } } // Game end! Curses.EndWin(); }
public ConsoleWindow(TwitterConnection twitterConnection) { Curses.InitScr(); Curses.CBreakMode = true; Curses.Echo = false; Curses.StdScr.Keypad = true; Curses.StartColor(); Curses.InitPair(1, Colors.WHITE, Colors.RED); Curses.InitPair(2, Colors.RED, Colors.WHITE); this.tweets = twitterConnection.Tweets; this.twitterConnection = twitterConnection; this.visibleTimelineBuffer = new string[Curses.Lines - STATUS_HEIGHT - 1]; this.TweetText = ""; this.topTweet = this.tweets.Count - 1; this.updateVisibleTimeline(this.topTweet); this.refreshTimeline(); this.refreshTweetWindow(); }
/// <summary> /// Creates a new Curses color to be used by Gui.cs apps /// </summary> public static uint MakeColor(short f, short b) { Curses.InitPair(++last_color_pair, f, b); return(Curses.ColorPair((uint)last_color_pair)); }
static void Main(string[] args) { Curses.Init(); if (Curses.HasColor()) { Curses.StartColor(); int bg = Colors.BLACK; if (Curses.SetDefaultColor()) { bg = -1; } Curses.InitPair(1, Colors.BLUE, bg); Curses.InitPair(2, Colors.CYAN, bg); } int maxy = Curses.Lines; Curses.Cursor = false; Curses.Blocking = false; Curses.Echo = false; Curses.Keypad = true; int start, end, row, diff, flag, direction; short i; Curses.Init(); int[] color_table = { Colors.RED, Colors.BLUE, Colors.GREEN, Colors.CYAN, Colors.RED, Colors.MAGENTA, Colors.YELLOW, Colors.WHITE }; for (i = 0; i < 8; i++) { Curses.InitPair(i + 1, color_table[i], Colors.BLACK); } flag = 0; while (Curses.GetCh().IsEof()) /* loop until a key is hit */ { do { start = rand.Next(Curses.Cols - 3); end = rand.Next(Curses.Cols - 3); start = (start < 2) ? 2 : start; end = (end < 2) ? 2 : end; direction = (start > end) ? -1 : 1; diff = Math.Abs(start - end); } while (diff < 2 || diff >= Curses.Lines - 2); for (row = 0; row < diff; row++) { Curses.Add(Curses.Lines - row, row * direction + start, (direction < 0) ? "\\" : "/"); if (flag++ > 0) { myrefresh(); Curses.Erase(); flag = 0; } } if (flag++ > 0) { myrefresh(); flag = 0; } explode(Curses.Lines - row, diff * direction + start); Curses.Erase(); myrefresh(); } Curses.Exit(); }
private static void Main2() { rng = new Random(); if (Curses.HasColors) { Curses.StartColor(); short bg = Colors.BLACK; try { Curses.UseDefaultColors(); bg = -1; } catch (CursesException) { } Curses.InitPair(1, Colors.BLUE, bg); Curses.InitPair(2, Colors.CYAN, bg); } Curses.Newlines = true; Curses.Echo = false; Curses.CursorVisibility = 0; Stdscr.ReadTimeout = 0; Stdscr.Keypad = true; int r = Curses.Lines - 4, c = Curses.Cols - 4; int[] xpos = new int[5]; int[] ypos = new int[5]; for (int j = 0; j < 5; ++j) { xpos[j] = rng.Next(c) + 2; ypos[j] = rng.Next(r) + 2; } for (int j = 0; ;) { int x = rng.Next(c) + 2; int y = rng.Next(r) + 2; Stdscr.Add(y, x, '.'); Stdscr.Add(ypos[j], xpos[j], 'o'); j = NextJ(j); Stdscr.Add(ypos[j], xpos[j], 'O'); j = NextJ(j); Stdscr.Add(ypos[j] - 1, xpos[j], '-'); Stdscr.Add(ypos[j], xpos[j] - 1, "|.|"); Stdscr.Add(ypos[j] + 1, xpos[j], '-'); j = NextJ(j); Stdscr.Add(ypos[j] - 2, xpos[j], '-'); Stdscr.Add(ypos[j] - 1, xpos[j] - 1, "/ \\"); Stdscr.Add(ypos[j], xpos[j] - 2, "| O |"); Stdscr.Add(ypos[j] + 1, xpos[j] - 1, "\\ /"); Stdscr.Add(ypos[j] + 2, xpos[j], '-'); j = NextJ(j); Stdscr.Add(ypos[j] - 2, xpos[j], ' '); Stdscr.Add(ypos[j] - 1, xpos[j] - 1, " "); Stdscr.Add(ypos[j], xpos[j] - 2, " "); Stdscr.Add(ypos[j] + 1, xpos[j] - 1, " "); Stdscr.Add(ypos[j] + 2, xpos[j], ' '); xpos[j] = x; ypos[j] = y; switch (Stdscr.GetChar()) { case 'q': case 'Q': Curses.CursorVisibility = 1; return; case 's': Stdscr.Blocking = true; break; case ' ': Stdscr.Blocking = false; break; default: break; } Curses.NapMs(50); } }