PositionCursor() public method

public PositionCursor ( ) : void
return void
Ejemplo n.º 1
0
        /// <summary>
        ///   Starts running a new container or dialog box.
        /// </summary>
        /// <remarks>
        ///   Use this method if you want to start the dialog, but
        ///   you want to control the main loop execution manually
        ///   by calling the RunLoop method (for example, to start
        ///   the dialog, but continuing to process events).
        ///
        ///    Use the returned value as the argument to RunLoop
        ///    and later to the End method to remove the container
        ///    from the screen.
        /// </remarks>
        public static RunState Begin(Container container)
        {
            if (container == null)
                throw new ArgumentNullException ("container");
            var rs = new RunState (container);

            Init (false);

            Curses.timeout (-1);

            toplevels.Add (container);

            container.Prepare ();
            container.SizeChanged ();
            container.FocusFirst ();
            Redraw (container);
            container.PositionCursor ();
            Curses.refresh ();

            return rs;
        }
Ejemplo n.º 2
0
        /// <summary>
        ///   Runs the main loop on the given container.
        /// </summary>
        /// <remarks>
        ///   This method is used to start processing events
        ///   for the main application, but it is also used to
        ///   run modal dialog boxes.
        /// </remarks>
        public static void Run(Container container)
        {
            Init (false);

            Curses.timeout (-1);
            if (toplevels.Count == 0)
                InitApp ();

            toplevels.Add (container);

            container.Prepare ();
            container.SizeChanged ();
            container.FocusFirst ();
            Redraw (container);
            container.PositionCursor ();

            int ch;
            Curses.timeout (Timeout);

            for (container.Running = true; container.Running; ){
                ch = Curses.getch ();

                if (Iteration != null)
                    Iteration (null, EventArgs.Empty);

                if (ch == -1){
                    if (Curses.CheckWinChange ()){
                        EmptyContainer.Clear ();
                        foreach (Container c in toplevels)
                            c.SizeChanged ();
                        Refresh ();
                    }
                    continue;
                }

                if (ch == Curses.KeyMouse){
                    Curses.MouseEvent ev;

                    Curses.console_sharp_getmouse (out ev);
                    container.ProcessMouse (ev);
                    continue;
                }

                if (ch == 27){
                    Curses.timeout (100);
                    int k = Curses.getch ();
                    if (k != Curses.ERR && k != 27)
                        ch = Curses.KeyAlt | k;
                    Curses.timeout (Timeout);
                }

                if (container.ProcessHotKey (ch))
                    continue;

                if (container.ProcessKey (ch))
                    continue;

                if (container.ProcessColdKey (ch))
                    continue;

                // Control-c, quit the current operation.
                if (ch == 3)
                    break;

                // Control-z, suspend execution, then repaint.
                if (ch == 26){
                    Curses.console_sharp_sendsigtstp ();
                    Window.Standard.redrawwin ();
                    Curses.refresh ();
                }

                //
                // Focus handling
                //
                if (ch == 9 || ch == Curses.KeyDown || ch == Curses.KeyRight){
                    if (!container.FocusNext ())
                        container.FocusNext ();
                    continue;
                } else if (ch == Curses.KeyUp || ch == Curses.KeyLeft){
                    if (!container.FocusPrev ())
                        container.FocusPrev ();
                    continue;
                }

            }

            toplevels.Remove (container);
            if (toplevels.Count == 0)
                Shutdown ();
            else
                Refresh ();
        }