Ejemplo n.º 1
0
void HotkeyDialog::accept()
{
	if (!sequenceWidget()->valid())
		return;

	hotkey().setKeySequence(sequenceWidget()->keySequence());
	QDialog::accept();
}
Ejemplo n.º 2
0
void MyPanel::Input(
    emInputEvent & event, const emInputState & state, double mx, double my
)
{
    if (event.IsKey(EM_KEY_E) && state.IsNoMod()) {
        emLog("The E key was pressed without any modifier keys.");
        event.Eat();
    }

    if (event.IsKey(EM_KEY_G) && state.IsShiftAltMod()) {
        emLog("The Shift+Alt+G key combination was pressed.");
        event.Eat();
    }

    emInputHotkey hotkey(EM_KEY_CTRL, EM_KEY_V);
    if (hotkey.Match(event,state)) {
        emLog("The %s key combination was pressed.", hotkey.GetString().Get());
        event.Eat();
    }

    if (event.GetChars()=="$") {
        emLog("A key combination that prints the dollar sign was pressed.");
        event.Eat();
    }

    if (event.IsKey(EM_KEY_X)) {
        emLog("The X key was pressed.");
        XKeyDown=true;
        event.Eat();
    }
    if (XKeyDown && !state.Get(EM_KEY_X)) {
        emLog("The X key was released.");
        XKeyDown=false;
    }

    if (event.IsKey(EM_KEY_LEFT_BUTTON)) {
        emLog("The left mouse button was pressed at (%g, %g).", mx, my);
        ButtonDown=true;
        LastMX=mx;
        LastMY=my;
        // We do not eat the event here so that emPanel::Input still
        // sets the focus on this panel by the button event. Otherwise
        // we should call Focus().
    }
    if (ButtonDown && (LastMX!=mx || LastMY!=mx)) {
        emLog("The mouse was dragged to (%g, %g).", mx, my);
        LastMX=mx;
        LastMY=my;
    }
    if (ButtonDown && !state.Get(EM_KEY_LEFT_BUTTON)) {
        emLog("The left mouse button was released.");
        ButtonDown=false;
    }

    // Call the base class. It changes the focus by certain input events.
    emPanel::Input(event,state,mx,my);
}
Ejemplo n.º 3
0
/*
 * This function is called by the assembly STUB function
 */
void uart_i_process()
{
    int i;
    BYTE temp;
    temp = SERIAL1_UCSR;    // Ack the interrupt
    volatile BYTE CharIn = ' ';
        
    // There is data to be read
    if( temp & 1 )
    {
        CharIn = SERIAL1_RD;
        if (pong_mode)
        {
            MsgEnv* message = k_request_msg_env();
            message->msg_type = CONSOLE_INPUT;
            message->msg[0] = CharIn;
            k_send_message(PONG_PID, message);
            return;
        }
        if (CharIn == KB_LINE_END)
        {
            SERIAL1_IMR = 3;
            SERIAL1_WD = '\n';
            SERIAL1_IMR = 2;
#ifdef _CFSERVER_
            inputIndex--;
#endif
            InBuffer[inputIndex] = '\0';
            inputIndex++;
            MsgEnv* message = k_request_msg_env();
            if (message != NULL)
            {
                for (i = 0; i < inputIndex; i++)
                {
                    message->msg[i] = InBuffer[i];
                }
                message->msg_type = CONSOLE_INPUT;
                k_send_message(CCI_PID, message);
            }
            inputIndex = 0;
        }
        else if (inputIndex < INPUT_BUFFER_SIZE - 2) // enter in a character
        {
            if (!hotkey(CharIn))
            {
                InBuffer[inputIndex] = CharIn;
                inputIndex++;
                SERIAL1_IMR = 3;
                SERIAL1_WD = CharIn;
                SERIAL1_IMR = 2;
            }
        }
    }
    // Check to see if data can be written out
    else if ( temp & 4 )
    {
        if (outputIndex == 0 && output_print_char == FALSE)
        {
            MsgEnv* message = k_receive_message();
            if (message != NULL)
            {
                i = 0;
                while (message->msg[i] != '\0')
                {
                    OutBuffer[i] = message->msg[i];
                    i++;
                }
                OutBuffer[i] = '\0';
                output_print_char = TRUE;
                if (message->msg_type == CONSOLE_OUTPUT)
                {
                    k_release_msg_env(message);
                }
                else
                {
                    message->msg_type = DISPLAY_ACK;
                    k_send_message(message->send_pid, message);
                }
            }
            else
            {
                trace(ERROR, "Uart i process expected an env but received NULL");
            }
        }
        if (output_print_char)
        {
            if (OutBuffer[outputIndex] == '\0')
            {
                outputIndex = 0;
                output_print_char = FALSE;
                MsgEnv* message = k_receive_message();
                if (message != NULL)
                {
                    i = 0;
                    while (message->msg[i] != '\0')
                    {
                        OutBuffer[i] = message->msg[i];
                        i++;
                    }
                    OutBuffer[i] = '\0';
                    output_print_char = TRUE;
                    if (message->msg_type == CONSOLE_OUTPUT)
                    {
                        k_release_msg_env(message);
                    }
                    else
                    {
                        message->msg_type = DISPLAY_ACK;
                        k_send_message(message->send_pid, message);
                    }
                }
                else
                {
                    SERIAL1_IMR = 2; // Disable tx interrupt
                }
            }
            else
            {
                SERIAL1_WD = OutBuffer[outputIndex]; // Write data
                outputIndex++;
            }
        }
    }
    return;
}
Ejemplo n.º 4
0
Archivo: menu.c Proyecto: ralienpp/deco
int getmenu ()
{
    if (! menu[0].len)
        initmenu ();

    getboxes ();
    VMPutString (LINES-1, 0, "\0011\16      \17 2\16      \17 3\16      \17 4\16      \17 5\16      \17 6\16      \17 7\16      \17 8\16      \17 9\16      \01710\16Quit \17\2");
    for (;;) {
        drawhead (nmenu);
        for (;;) {
            int c, k;

            drawmenu (&menu[nmenu]);
            hidecursor ();
            VSync ();
            c = KeyGet ();
            switch (c) {
            default:
                k = hotkey (c, &menu[nmenu]);
                if (k) {
                    clrmenu (&menu[nmenu]);
                    return (k);
                }
                VBeep ();
                continue;
            case cntrl (']'):          /* redraw screen */
                VRedraw ();
                continue;
            case cntrl ('M'):
                clrmenu (&menu[nmenu]);
                return (1);
            case cntrl ('J'):
                clrmenu (&menu[nmenu]);
                return (2);
            case cntrl ('C'):
            case cntrl ('['):
            case meta ('J'):        /* f0 */
                clrmenu (&menu[nmenu]);
                return (0);
            case meta ('r'):        /* right */
                clrmenu (&menu[nmenu]);
                if (! menu[++nmenu].name)
                    nmenu = 0;
                break;
            case meta ('l'):        /* left */
                clrmenu (&menu[nmenu]);
                if (--nmenu < 0) {
                    for (nmenu=0; menu[nmenu].name; ++nmenu);
                    --nmenu;
                }
                break;
            case meta ('u'):        /* up */
                upmenu (&menu[nmenu]);
                continue;
            case meta ('d'):        /* down */
                downmenu (&menu[nmenu]);
                continue;
            }
            break;
        }
    }
}
Ejemplo n.º 5
0
void domenu(menu *mp)
{
    int y, x, nitems, barlen, mheight, mw, old = -1, cur = 0, cur0;
    bool stop = FALSE;
    WINDOW *wmenu;

    curs_set(0);
    getmenupos(&y, &x);
    menudim(mp, &nitems, &barlen);
    mheight = nitems + 2;
    mw = barlen + 2;
    wmenu = newwin(mheight, mw, y, x);
    colorbox(wmenu, SUBMENUCOLOR, 1);
    repaintmenu(wmenu, mp);

    key = ERR;

    while (!stop && !quit)
    {
        if (cur != old)
        {
            if (old != -1)
                mvwaddstr(wmenu, old + 1, 1,
                          prepad(padstr(mp[old].name, barlen - 1), 1));

            setcolor(wmenu, SUBMENUREVCOLOR);
            mvwaddstr(wmenu, cur + 1, 1,
                      prepad(padstr(mp[cur].name, barlen - 1), 1));

            setcolor(wmenu, SUBMENUCOLOR);
            statusmsg(mp[cur].desc);

            old = cur;
            wrefresh(wmenu);
        }

        switch (key = ((key != ERR) ? key : waitforkey()))
        {
        case '\n':          /* menu item selected */
            touchwin(wbody);
            wrefresh(wbody);
            setmenupos(y + 1, x + 1);
            rmerror();

            key = ERR;
            curs_set(1);
            (mp[cur].func)();   /* perform function */
            curs_set(0);

            repaintmenu(wmenu, mp);

            old = -1;
            break;

        case KEY_UP:
            cur = (cur + nitems - 1) % nitems;
            key = ERR;
            break;

        case KEY_DOWN:
            cur = (cur + 1) % nitems;
            key = ERR;
            break;

        case KEY_ESC:
        case KEY_LEFT:
        case KEY_RIGHT:
            if (key == KEY_ESC)
                key = ERR;  /* return to prev submenu */

            stop = TRUE;
            break;

        default:
            cur0 = cur;

            do
            {
                cur = (cur + 1) % nitems;

            } while ((cur != cur0) &&
                     (hotkey(mp[cur].name) != toupper((int)key)));

            key = (hotkey(mp[cur].name) == toupper((int)key)) ? '\n' : ERR;
        }

    }

    rmerror();
    delwin(wmenu);
    touchwin(wbody);
    wrefresh(wbody);
}
Ejemplo n.º 6
0
static void mainmenu(menu *mp)
{
    int nitems, barlen, old = -1, cur = 0, c, cur0;

    menudim(mp, &nitems, &barlen);
    repaintmainmenu(barlen, mp);

    while (!quit)
    {
        if (cur != old)
        {
            if (old != -1)
            {
                mvwaddstr(wmain, 0, old * barlen,
                          prepad(padstr(mp[old].name, barlen - 1), 1));

                statusmsg(mp[cur].desc);
            }
            else
                mainhelp();

            setcolor(wmain, MAINMENUREVCOLOR);

            mvwaddstr(wmain, 0, cur * barlen,
                      prepad(padstr(mp[cur].name, barlen - 1), 1));

            setcolor(wmain, MAINMENUCOLOR);
            old = cur;
            wrefresh(wmain);
        }

        switch (c = (key != ERR ? key : waitforkey()))
        {
        case KEY_DOWN:
        case '\n':              /* menu item selected */
            touchwin(wbody);
            wrefresh(wbody);
            rmerror();
            setmenupos(th + mh, cur * barlen);
            curs_set(1);
            (mp[cur].func)();   /* perform function */
            curs_set(0);

            switch (key)
            {
            case KEY_LEFT:
                cur = (cur + nitems - 1) % nitems;
                key = '\n';
                break;

            case KEY_RIGHT:
                cur = (cur + 1) % nitems;
                key = '\n';
                break;

            default:
                key = ERR;
            }

            repaintmainmenu(barlen, mp);
            old = -1;
            break;

        case KEY_LEFT:
            cur = (cur + nitems - 1) % nitems;
            break;

        case KEY_RIGHT:
            cur = (cur + 1) % nitems;
            break;

        case KEY_ESC:
            mainhelp();
            break;

        default:
            cur0 = cur;

            do
            {
                cur = (cur + 1) % nitems;

            } while ((cur != cur0) && (hotkey(mp[cur].name) != toupper(c)));

            if (hotkey(mp[cur].name) == toupper(c))
                key = '\n';
        }

    }

    rmerror();
    touchwin(wbody);
    wrefresh(wbody);
}