Example #1
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();
            }
        }