コード例 #1
0
        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();
            }
        }
コード例 #2
0
 public Program()
 {
     this.rng = new Random();
     Curses.InitScr();
     this.linecount = Curses.Lines - 1;
     this.colcount  = Curses.Cols;
     this.lines     = new string[linecount];
     this.offsets   = new int[linecount];
 }
コード例 #3
0
 static void Main(string[] args)
 {
     Curses.InitScr();
     try
     {
         Main2();
     }
     finally
     {
         Curses.EndWin();
     }
 }
コード例 #4
0
        public static void Main(string[] args)
        {
            // C style from http://www.tldp.org/HOWTO/NCURSES-Programming-HOWTO/helloworld.html
//			initscr();			/* Start curses mode          */
//			printw("Hello World !!!");	/* Print Hello World		  */
//			refresh();			/* Print it on to the real screen */
//			getch();			/* Wait for user input */
//			endwin();			/* End curses mode		  */

            Curses.InitScr();
            Stdscr.Add("Hello World !!!");
            Stdscr.Refresh();
            Stdscr.GetChar();
            Curses.Beep();
            Curses.EndWin();
        }
コード例 #5
0
        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();
        }
コード例 #6
0
        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();
        }
コード例 #7
0
ファイル: Terminal.cs プロジェクト: zxfdreamfly/CursesSharp
        /// <summary>
        ///    Initializes the runtime.   The boolean flag
        ///   indicates whether we are forcing color to be off.
        /// </summary>
        public static void Init(bool disable_color = false)
        {
            if (inited)
            {
                return;
            }
            inited = true;

            empty_container = new Container(0, 0, Terminal.Cols, Terminal.Lines);

            try {
                main_window = Curses.InitScr();
            } catch (Exception e) {
                Console.WriteLine("Curses failed to initialize, the exception is: " + e);
                throw new Exception("Terminal.Init failed");
            }
            Curses.RawMode = true;
            Curses.Echo    = false;
            //Curses.nonl ();
            Stdscr.Keypad = true;
            //			MainScreen.stdscr.Keypad = true;

                        #if BREAK_UTF8_RENDERING
            Curses.Event old = 0;
            MouseEventsAvailable = Curses.console_sharp_mouse_mask(
                Curses.Event.Button1Clicked | Curses.Event.Button1DoubleClicked, out old);
                        #endif

            UsingColor = false;
            if (!disable_color)
            {
                UsingColor = Curses.HasColors;
            }

            Curses.StartColor();
            Curses.UseDefaultColors();
            if (UsingColor)
            {
                ColorNormal    = MakeColor(Colors.WHITE, Colors.BLUE);
                ColorFocus     = MakeColor(Colors.BLACK, Colors.CYAN);
                ColorHotNormal = Attrs.BOLD | MakeColor(Colors.YELLOW, Colors.BLUE);
                ColorHotFocus  = Attrs.BOLD | MakeColor(Colors.YELLOW, Colors.CYAN);

                ColorMenu            = Attrs.BOLD | MakeColor(Colors.WHITE, Colors.CYAN);
                ColorMenuHot         = Attrs.BOLD | MakeColor(Colors.YELLOW, Colors.CYAN);
                ColorMenuSelected    = Attrs.BOLD | MakeColor(Colors.WHITE, Colors.BLACK);
                ColorMenuHotSelected = Attrs.BOLD | MakeColor(Colors.YELLOW, Colors.BLACK);

                ColorMarked         = ColorHotNormal;
                ColorMarkedSelected = ColorHotFocus;

                ColorDialogNormal    = MakeColor(Colors.BLACK, Colors.WHITE);
                ColorDialogFocus     = MakeColor(Colors.BLACK, Colors.CYAN);
                ColorDialogHotNormal = MakeColor(Colors.BLUE, Colors.WHITE);
                ColorDialogHotFocus  = MakeColor(Colors.BLUE, Colors.CYAN);

                ColorError         = Attrs.BOLD | MakeColor(Colors.WHITE, Colors.RED);
                ColorErrorFocus    = MakeColor(Colors.BLACK, Colors.WHITE);
                ColorErrorHot      = Attrs.BOLD | MakeColor(Colors.YELLOW, Colors.RED);
                ColorErrorHotFocus = ColorErrorHot;
            }
            else
            {
                ColorNormal    = Attrs.NORMAL;
                ColorFocus     = Attrs.REVERSE;
                ColorHotNormal = Attrs.BOLD;
                ColorHotFocus  = Attrs.REVERSE | Attrs.BOLD;

                ColorMenu            = Attrs.REVERSE;
                ColorMenuHot         = Attrs.NORMAL;
                ColorMenuSelected    = Attrs.BOLD;
                ColorMenuHotSelected = Attrs.NORMAL;

                ColorMarked         = Attrs.BOLD;
                ColorMarkedSelected = Attrs.REVERSE | Attrs.BOLD;

                ColorDialogNormal    = Attrs.REVERSE;
                ColorDialogFocus     = Attrs.NORMAL;
                ColorDialogHotNormal = Attrs.BOLD;
                ColorDialogHotFocus  = Attrs.NORMAL;

                ColorError = Attrs.BOLD;
            }
            ColorBasic = MakeColor(-1, -1);
            mainloop   = new Looper();
            mainloop.AddWatch(0, Looper.Condition.PollIn, x => {
                Container top = toplevels.Count > 0 ? toplevels [toplevels.Count - 1] : null;
                if (top != null)
                {
                    ProcessChar(top);
                }

                return(true);
            });
        }