Esempio n. 1
0
        private static bool InitializeNCurses(ref IntPtr screen, short[] colorMap, Byte width, Byte height)
        {
            screen = NCurses.InitScreen();

            if (NCurses.HasColors() == false)
            {
                Console.WriteLine("Your terminal doesn't support colored output.");
                NCurses.EndWin();
                return(false);
            }

            if ((NCurses.Columns < width - 1) || (NCurses.Lines < height - 1))
            {
                Console.WriteLine($"Your terminal must be {width}x{height}. You have {NCurses.Columns}x{NCurses.Lines}");
                NCurses.EndWin();
                return(false);
            }

            NCurses.NoDelay(screen, true);
            NCurses.NoEcho();
            NCurses.AttributeSet(CursesAttribute.NORMAL);
            NCurses.StartColor();
            NCurses.InitPair(colorMap[0], CursesColor.BLACK, CursesColor.BLACK);
            NCurses.InitPair(colorMap[1], CursesColor.WHITE, CursesColor.WHITE);

            return(true);
        }
Esempio n. 2
0
        private static void Fireworks()
        {
            NCurses.NoDelay(Screen, true);
            NCurses.NoEcho();

            if (NCurses.HasColors())
            {
                NCurses.StartColor();
                for (short i = 1; i < 8; i++)
                {
                    NCurses.InitPair(i, color_table[i], CursesColor.BLACK);
                }
            }

            int flag = 0;

            while (NCurses.GetChar() == -1)
            {
                int start, end, row, diff, direction;
                do
                {
                    start     = rng.Next(NCurses.Columns - 3);
                    end       = rng.Next(NCurses.Columns - 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 >= NCurses.Lines - 2);

                NCurses.AttributeSet(CursesAttribute.NORMAL);
                for (row = 1; row < diff; ++row)
                {
                    NCurses.MoveAddString(NCurses.Lines - row, row * direction + start, (direction < 0) ? "\\" : "/");
                    if (flag++ > 0)
                    {
                        MyRefresh();
                        NCurses.Erase();
                        flag = 0;
                    }
                }

                if (flag++ > 0)
                {
                    MyRefresh();
                    flag = 0;
                }

                Explode(NCurses.Lines - row, diff * direction + start);
                NCurses.Erase();
                MyRefresh();
            }
        }
Esempio n. 3
0
        private void UpdateScreenData()
        {
            int offset = 0;

            NCurses.AttributeSet(CursesAttribute.NORMAL);
            NCurses.Nap(DefaultFramerate);
            NCurses.Erase();
            for (int i = 0; i < Buffer.Height; i++)
            {
                for (int j = 0; j < Buffer.Width; j++)
                {
                    NCurses.AttributeSet(NCurses.ColorPair(_colorMap[Buffer[offset++]]));
                    NCurses.MoveAddChar(i, j, ' ');
                }
            }
            NCurses.Refresh();
        }
Esempio n. 4
0
        private static void GetColor()
        {
            uint bold = (rng.Next(2) > 0) ? CursesAttribute.BOLD : CursesAttribute.NORMAL;

            NCurses.AttributeSet(NCurses.ColorPair((short)rng.Next(8)) | bold);
        }