void
spaction(W_Event *data)
{
    int     v;
    register int i;
    register char *cp;

    /* unmap window on space or ESC [BDyess] */
    if(data->type == W_EV_KEY && (data->key == ' ' || data->key == 27)) {
      W_UnmapWindow(spWin);
      return;
    }

    switch (data->y) {

    case SPK_VFIELD:
	if (data->type == W_EV_BUTTON) {
	    if (recv_short)
		sendShortReq(SPK_VOFF);
	    else
		sendShortReq(SPK_VON);
	}
	break;

    case SPK_MFIELD:
	if (data->type == W_EV_BUTTON) {
	    if (recv_mesg)
		sendShortReq(SPK_MOFF);
	    else
		sendShortReq(SPK_MON);
	}
	break;

    case SPK_KFIELD:
	if (data->type == W_EV_BUTTON) {
	    if (recv_kmesg)
		sendShortReq(SPK_M_NOKILLS);
	    else
		sendShortReq(SPK_M_KILLS);
	}
	break;

    case SPK_WFIELD:
	if (data->type == W_EV_BUTTON) {
	    if (recv_warn)
		sendShortReq(SPK_M_NOWARN);
	    else
		sendShortReq(SPK_M_WARN);
	}
	break;

    case SPK_TFIELD:
	if (data->type == W_EV_KEY) {
	    switch (data->key) {
	    case '\b':
	    case '\177':
		cp = recv_threshold_s;
		i = strlen(cp);
		if (i > 0) {
		    cp += i - 1;
		    *cp = '\0';
		}
		break;
	    case '\025':
	    case '\030':
		recv_threshold_s[0] = '\0';
		break;

	    default:
		if (data->key >= '0' && data->key <= '9') {
		    cp = recv_threshold_s;
		    i = strlen(cp);
		    if (i < 4) {
			cp += i;
			cp[1] = '\0';
			cp[0] = data->key;
		    }
		}
		break;
	    }
	    sprefresh(SPK_TFIELD);
	}
	break;

    case SPK_WHYFIELD:
	if (F_feature_packets && data->type == W_EV_BUTTON) {
	    if (why_dead)
		sendFeature("WHY_DEAD", 'S', 0, 0, 0);
	    else
		sendFeature("WHY_DEAD", 'S', 1, 0, 0);
	}
	break;
    case SPK_DONE:

	if (data->type == W_EV_BUTTON) {
	    if (sscanf(recv_threshold_s, "%d", &v) != 1)
		strcpy(recv_threshold_s, "0");
	    else if (recv_threshold != v) {
		recv_threshold = v;
		sendThreshold(recv_threshold);
	    }
	    spdone();
	}
	break;

    }
}
Esempio n. 2
0
void    spaction(W_Event * data)
/*
 * Handle a button press.
 */
{
  int     v;
  register int i;
  register char *cp;

  switch (data->y)
    {

    case SPK_VFIELD:
      if (data->type == W_EV_BUTTON)
  {
    if (recv_short)
      sendShortReq(SPK_VOFF);
    else
      sendShortReq(SPK_VON);
  }
      break;

    case SPK_MFIELD:
      if (data->type == W_EV_BUTTON)
  {
    if (recv_mesg)
      sendShortReq(SPK_MOFF);
    else
      sendShortReq(SPK_MON);
  }
      break;

    case SPK_KFIELD:
      if (data->type == W_EV_BUTTON)
  {
    if (recv_kmesg)
      sendShortReq(SPK_M_NOKILLS);
    else
      sendShortReq(SPK_M_KILLS);
  }
      break;

    case SPK_WFIELD:
      if (data->type == W_EV_BUTTON)
  {
    if (recv_warn)
      sendShortReq(SPK_M_NOWARN);
    else
      sendShortReq(SPK_M_WARN);
  }
      break;

    case SPK_TFIELD:
      if (data->type == W_EV_KEY)
  {
    switch (data->key)
      {
      case '\b':
      case '\177':
        cp = recv_threshold_s;
        i = strlen(cp);
        if (i > 0)
    {
      cp += i - 1;
      *cp = '\0';
    }
        break;
      case '\025':
      case '\030':
        recv_threshold_s[0] = '\0';
        break;

      default:
        if (data->key >= '0' && data->key <= '9')
    {
      cp = recv_threshold_s;
      i = strlen(cp);
      if (i < 4)
        {
          cp += i;
          cp[1] = '\0';
          cp[0] = data->key;
        }
    }
        break;
      }
    sprefresh(SPK_TFIELD);
  }
      break;

    case SPK_DONE:

      if (data->type == W_EV_BUTTON)
  {
    if (sscanf(recv_threshold_s, "%d", &v) != 1)
      strcpy(recv_threshold_s, "0");
    else if (recv_threshold != v)
      {
        recv_threshold = v;
        sendThreshold(recv_threshold);
      }

    spdone();
  }
      break;

    }
}