Ejemplo n.º 1
0
Archivo: achown.c Proyecto: jskDr/mc
static cb_ret_t
advanced_chown_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
{
    WDialog *h = DIALOG (w);
    int i;
    int f_pos;
    unsigned long id;

    id = dlg_get_current_widget_id (h);

    for (i = 0; i < BUTTONS_PERM; i++)
        if (chown_advanced_but[i].id == id)
            break;

    f_pos = i;
    i = 0;

    switch (msg)
    {
    case MSG_DRAW:
        chown_refresh ();
        chown_info_update ();
        return MSG_HANDLED;

    case MSG_POST_KEY:
        if (f_pos < 3)
            b_setpos (f_pos);
        return MSG_HANDLED;

    case MSG_FOCUS:
        if (f_pos < 3)
        {
            if ((flag_pos / 3) != f_pos)
                flag_pos = f_pos * 3;
            b_setpos (f_pos);
        }
        else if (f_pos < BUTTONS_PERM)
            flag_pos = f_pos + 6;
        return MSG_HANDLED;

    case MSG_KEY:
        switch (parm)
        {
        case XCTRL ('b'):
        case KEY_LEFT:
            if (f_pos < BUTTONS_PERM)
                return (dec_flag_pos (f_pos));
            break;

        case XCTRL ('f'):
        case KEY_RIGHT:
            if (f_pos < BUTTONS_PERM)
                return (inc_flag_pos (f_pos));
            break;

        case ' ':
            if (f_pos < 3)
                return MSG_HANDLED;
            break;

        case '\n':
        case KEY_ENTER:
            if (f_pos <= 2 || f_pos >= BUTTONS_PERM)
                break;
            do_enter_key (h, f_pos);
            return MSG_HANDLED;

        case ALT ('x'):
            i++;

        case ALT ('w'):
            i++;

        case ALT ('r'):
            parm = i + 3;
            for (i = 0; i < 3; i++)
                ch_flags[i * 3 + parm - 3] = (x_toggle & (1 << parm)) ? '-' : '+';
            x_toggle ^= (1 << parm);
            update_mode (h);
            dlg_broadcast_msg (h, MSG_DRAW);
            send_message (h->current->data, NULL, MSG_FOCUS, 0, NULL);
            break;

        case XCTRL ('x'):
            i++;

        case XCTRL ('w'):
            i++;

        case XCTRL ('r'):
            parm = i;
            for (i = 0; i < 3; i++)
                ch_flags[i * 3 + parm] = (x_toggle & (1 << parm)) ? '-' : '+';
            x_toggle ^= (1 << parm);
            update_mode (h);
            dlg_broadcast_msg (h, MSG_DRAW);
            send_message (h->current->data, NULL, MSG_FOCUS, 0, NULL);
            break;

        case 'x':
            i++;

        case 'w':
            i++;

        case 'r':
            if (f_pos > 2)
                break;
            flag_pos = f_pos * 3 + i;   /* (strchr(ch_perm,parm)-ch_perm); */
            if (BUTTON (h->current->data)->text.start[(flag_pos % 3)] == '-')
                ch_flags[flag_pos] = '+';
            else
                ch_flags[flag_pos] = '-';
            update_mode (h);
            break;

        case '4':
            i++;

        case '2':
            i++;

        case '1':
            if (f_pos <= 2)
            {
                flag_pos = i + f_pos * 3;
                ch_flags[flag_pos] = '=';
                update_mode (h);
            }
            break;

        case '-':
            if (f_pos > 2)
                break;

        case '*':
            if (parm == '*')
                parm = '=';

        case '=':
        case '+':
            if (f_pos <= 4)
            {
                ch_flags[flag_pos] = parm;
                update_mode (h);
                send_message (h, sender, MSG_KEY, KEY_RIGHT, NULL);
                if (flag_pos > 8 || (flag_pos % 3) == 0)
                    dlg_one_down (h);
            }
            break;

        default:
            break;
        }
        return MSG_NOT_HANDLED;

    default:
        return dlg_default_callback (w, sender, msg, parm, data);
    }
}
Ejemplo n.º 2
0
static cb_ret_t
advanced_chown_callback (Dlg_head *h, dlg_msg_t msg, int parm)
{
    int i = 0, f_pos = BUTTONS - h->current->dlg_id - single_set - 1;

    switch (msg) {
    case DLG_DRAW:
	chown_refresh ();
	chown_info_update ();
	return MSG_HANDLED;

    case DLG_POST_KEY:
	if (f_pos < 3)
	    b_setpos (f_pos);
	return MSG_HANDLED;

    case DLG_FOCUS:
	if (f_pos < 3) {
	    if ((flag_pos / 3) != f_pos)
		flag_pos = f_pos * 3;
	    b_setpos (f_pos);
	} else if (f_pos < 5)
	    flag_pos = f_pos + 6;
	return MSG_HANDLED;

    case DLG_KEY:
	switch (parm) {

	case XCTRL ('b'):
	case KEY_LEFT:
	    if (f_pos < 5)
		return (dec_flag_pos (f_pos));
	    break;

	case XCTRL ('f'):
	case KEY_RIGHT:
	    if (f_pos < 5)
		return (inc_flag_pos (f_pos));
	    break;

	case ' ':
	    if (f_pos < 3)
		return MSG_HANDLED;
	    break;

	case '\n':
	case KEY_ENTER:
	    if (f_pos <= 2 || f_pos >= 5)
		break;
	    do_enter_key (h, f_pos);
	    return MSG_HANDLED;

	case ALT ('x'):
	    i++;

	case ALT ('w'):
	    i++;

	case ALT ('r'):
	    parm = i + 3;
	    for (i = 0; i < 3; i++)
		ch_flags[i * 3 + parm - 3] =
		    (x_toggle & (1 << parm)) ? '-' : '+';
	    x_toggle ^= (1 << parm);
	    update_mode (h);
	    dlg_broadcast_msg (h, WIDGET_DRAW, 0);
	    send_message (h->current, WIDGET_FOCUS, 0);
	    break;

	case XCTRL ('x'):
	    i++;

	case XCTRL ('w'):
	    i++;

	case XCTRL ('r'):
	    parm = i;
	    for (i = 0; i < 3; i++)
		ch_flags[i * 3 + parm] =
		    (x_toggle & (1 << parm)) ? '-' : '+';
	    x_toggle ^= (1 << parm);
	    update_mode (h);
	    dlg_broadcast_msg (h, WIDGET_DRAW, 0);
	    send_message (h->current, WIDGET_FOCUS, 0);
	    break;

	case 'x':
	    i++;

	case 'w':
	    i++;

	case 'r':
	    if (f_pos > 2)
		break;
	    flag_pos = f_pos * 3 + i;	/* (strchr(ch_perm,parm)-ch_perm); */
	    if (((WButton *) h->current)->text.start[(flag_pos % 3)] ==
		'-')
		ch_flags[flag_pos] = '+';
	    else
		ch_flags[flag_pos] = '-';
	    update_mode (h);
	    break;

	case '4':
	    i++;

	case '2':
	    i++;

	case '1':
	    if (f_pos > 2)
		break;
	    flag_pos = i + f_pos * 3;
	    ch_flags[flag_pos] = '=';
	    update_mode (h);
	    break;

	case '-':
	    if (f_pos > 2)
		break;

	case '*':
	    if (parm == '*')
		parm = '=';

	case '=':
	case '+':
	    if (f_pos > 4)
		break;
	    ch_flags[flag_pos] = parm;
	    update_mode (h);
	    advanced_chown_callback (h, DLG_KEY, KEY_RIGHT);
	    if (flag_pos > 8 || !(flag_pos % 3))
		dlg_one_down (h);

	    break;
	}
	return MSG_NOT_HANDLED;

    default:
	return default_dlg_callback (h, msg, parm);
    }
}