public static void UpdateKeys()
        {
            int c = Stdscr.GetChar();

            while (c != -1)
            {
                //Console.WriteLine( "Key " + c + " pressed!" );
                if (c == Keys.MOUSE && mouse)
                {
                    try {
                        MouseEvent e = Curses.GetMouse();
                        // We want to toggle the mouse so...
                        if (e.State == MouseState.BUTTON1_CLICKED)
                        {
                            mousedown = !mousedown;
                        }
                        mousepos = new Vector2(e.X, e.Y);
                    } catch { }
                }
                keys.Add(c);
                c = Stdscr.GetChar();
            }
        }
Exemple #2
0
        static void ProcessChar(Container container)
        {
            int ch = Stdscr.GetChar();

            if ((ch == -1) || (ch == Keys.RESET))
            {
                // TODO: Fixme
                //				if (Curses.CheckWinChange ()){
                //					EmptyContainer.Clear ();
                //					foreach (Container c in toplevels)
                //						c.SizeChanged ();
                //					Refresh ();
                //				}
                return;
            }

            // Control-c, quit the current operation.
            if (ch == Keys.CTRLC || ch == Keys.ESC)
            {
                container.Running = false;
                return;
            }

            if (ch == Keys.MOUSE)
            {
                MouseEvent ev = Curses.GetMouse();
                container.ProcessMouse(ev);
                return;
            }

            if (ch == Keys.ESC)
            {
                Stdscr.ReadTimeout = 100;
                int k = Stdscr.GetChar();
                if (k != Curses.ERR && k != Keys.ESC)
                {
                    ch = Curses.KeyAlt | k;
                }
                Stdscr.ReadTimeout = -1;
            }

            if (container.ProcessHotKey(ch))
            {
                return;
            }

            if (container.ProcessKey(ch))
            {
                return;
            }

            if (container.ProcessColdKey(ch))
            {
                return;
            }

            // Control-z, suspend execution, then repaint.
            if (ch == Keys.CTRLZ)
            {
                Curses.SendSignalToStop();
                // TODO: Fixme ;-) This is broken on return
                container.Redraw();
                Stdscr.Refresh();
                return;
            }

            //
            // Focus handling
            //
            if (ch == 9 || ch == Keys.DOWN || ch == Keys.RIGHT)
            {
                if (!container.FocusNext())
                {
                    container.FocusNext();
                }
                Stdscr.Refresh();
            }
            else if (ch == Keys.UP || ch == Keys.LEFT)
            {
                if (!container.FocusPrev())
                {
                    container.FocusPrev();
                }
                Stdscr.Refresh();
            }
        }