Esempio n. 1
0
void
waraction(W_Event *data)
{
    int     enemymask;

    if (data->y == 4) {
	W_UnmapWindow(war);
	sendWarReq(newhostile);
	return;
    }
    if (data->y == 5) {
	W_UnmapWindow(war);
	return;
    }
    enemymask = 1 << data->y;

    if (me->p_swar & enemymask) {
	warning("You are already at war!");
	W_Beep();
    } else {
	if (idx_to_mask(me->p_teami) == enemymask) {
	    warning("It would never work ... your crew would have you in the brig in no time.");
	} else {
	    newhostile ^= enemymask;
	}
    }
    warrefresh();
}
Esempio n. 2
0
static void metadone(void)
{
  W_UnmapWindow(metaList);
  W_DropImage(logo);
  W_UnmapWindow(metaWin);
  SaveMetasCache();
  free(serverlist);
}
Esempio n. 3
0
optiondone(void)
{
  char   *str;

  /* Unmap window */
  W_UnmapWindow(optionWin);

  /* update keymap */
  for (str = newkeys; *str != '\0'; str += 2)
    {
      if ((*str >= 32 && *str < 127) || *str == 'O')
  {
    if (*(str + 1) == '\0')
      break;
    mystats->st_keymap[*str - 32] = *(str + 1);
  }
      if (*(str + 1) == '\0')
  break;
    }
  *newkeys = '\0';

  if (updatespeed != lastUpdateSpeed)
    {
      sendUpdatePacket(1000000 / updatespeed);
      lastUpdateSpeed = updatespeed;
    }

  sendOptionsPacket();         /* update server as to the *
              *
              * * client's options */
}
Esempio n. 4
0
showMacroWin(void)
{
  int     num = macrocnt + 5;

  if (!macroWin)
    {
      if (maclevel == 0)
  {
    lineno = 0;
    filldist(0);
    num = lineno + 5;
  }

      /* we'll use GWINSIDE since it is (probably) less than or equal to *
       * TWINSIDE.  The smaller the better. */
      macroWin = W_MakeTextWindow("macrow", GWINSIDE + BORDER, BORDER,
          80, num, NULL, BORDER);

      W_ResizeTextWindow(macroWin, 80, num);
      W_DefineTrekCursor(macroWin);
      W_SetWindowExposeHandler(macroWin, fillmacro);
      W_SetWindowButtonHandler(macroWin, switchmacros);
      W_MapWindow(macroWin);
    }
  else if (W_IsMapped(macroWin))
    W_UnmapWindow(macroWin);
  else
    W_MapWindow(macroWin);
}
Esempio n. 5
0
/* deal with events sent to the option window */
void    optionaction(W_Event * data)
{
  register struct option *op;
  int     i;
  register char *cp;

  if (data->y >= CurrentMenu->numopt)
    {
      W_Beep();
      return;
    }
  if (notdone == 0)
    return;

  op = &(CurrentMenu->menu[data->y]);

  /* Update string; don't claim keystrokes for non-string options */
  /* deal with options with string input first */
  if (op->op_string == 0)
    {
      if (data->type == W_EV_KEY)
  return;
    }
  else
    {
      if (data->type == W_EV_BUTTON)
  return;
      switch (data->key)
  {

  case '\b':         /* delete character */
  case '\177':
    cp = op->op_string;
    i = strlen(cp);
    if (i > 0)
      {
        cp += i - 1;
        *cp = '\0';
      }
    break;

  case '\027':         /* word erase */
    cp = op->op_string;
    i = strlen(cp);
    /* back up over blanks */
    while (--i >= 0 && isspace(cp[i]))
      ;
    i++;
    /* back up over non-blanks */
    while (--i >= 0 && !isspace(cp[i]))
      ;
    i++;
    cp[i] = '\0';
    break;

  case '\025':         /* kill line */
  case '\030':
    op->op_string[0] = '\0';
    break;

  default:         /* add character to the list
              *
              */
    if (data->key < 32 || data->key > 127)
      break;
    cp = op->op_string;
    i = strlen(cp);
    if (i < (op->op_size - 1) && !iscntrl(data->key))
      {
        cp += i;
        cp[1] = '\0';
        cp[0] = data->key;
      }
    else
      W_Beep();
    break;
  }
    }

  /* Toggle int, if it exists */
  if (op->op_array)
    {
      if (data->key == W_RBUTTON)
  {
    (*op->op_option)++;
    if (*(op->op_array)[*op->op_option] == '\0')
      {
        *op->op_option = 0;
      }
  }
      else if (data->key == W_MBUTTON)
  {
    /* set option number to zero on the middle key to ease shutoff */
    *op->op_option = 0;
  }
      else if (data->key == W_LBUTTON)
  {
    /* if left button, decrease option  */
    (*op->op_option)--;
    /* if decreased too far, set to top option */
    if (*(op->op_option) < 0)
      {
        *op->op_option = 0;
        while (*(op->op_array)[*op->op_option] != '\0')
    {
      (*op->op_option)++;
    }
        (*op->op_option)--;
      }
  }


      /* Actions to be taken when certain options are selected. (Yes, this is
       * * * a hack). */

      if (op->op_option == &plistStyle)
  {
    if (plistCustomLayout == 0 && plistStyle == 0)
      plistStyle = (data->key == W_LBUTTON) ? PLISTLASTSTYLE : 1;

    RedrawPlayerList();
  }
      else if (op->op_option == &showgalactic)
  {
    redrawall = 1;
  }

#ifdef ROTATERACE
      else if (rotate != old_rotate)
  {
    register i;
    register struct planet *l;
    register struct player *j;

    redrawall = 1;
    reinitPlanets = 1;

    for (i = 0, l = planets; i < MAXPLANETS; i++, l++)
      {
        if (rotate)
    {
      rotate_deg = -old_rotate_deg + rotate * 64;
      rotate_coord(&l->pl_x, &l->pl_y, rotate_deg, GWIDTH / 2, GWIDTH / 2);
      rotate_deg = rotate * 64;
    }
        else
    {
      rotate_deg = -old_rotate_deg;
      rotate_coord(&l->pl_x, &l->pl_y, rotate_deg, GWIDTH / 2, GWIDTH / 2);
      rotate_deg = 0;
    }
      }

    /* we could wait for the server to do this but looks better if we *
     *
     * * do it now. */
    for (i = 0, j = players; i < MAXPLAYER; i++, j++)
      {
        if (j->p_status != PALIVE)
    continue;
        if (rotate)
    {
      rotate_deg = -old_rotate_deg + rotate * 64;
      rotate_coord(&j->p_x, &j->p_y, rotate_deg,
             GWIDTH / 2, GWIDTH / 2);
      rotate_dir(&j->p_dir, rotate_deg);

      rotate_deg = rotate * 64;
    }
        else
    {
      rotate_deg = -old_rotate_deg;
      rotate_coord(&j->p_x, &j->p_y, rotate_deg,
             GWIDTH / 2, GWIDTH / 2);
      rotate_dir(&j->p_dir, rotate_deg);
      rotate_deg = 0;
    }
      }
    /* phasers/torps/etc .. wait for server */

    old_rotate = rotate;
    old_rotate_deg = rotate_deg;
  }
#endif

    }


  /* Does the button have a range of values? */

  else if (op->op_range)
    {
      if (data->key == W_RBUTTON)
  {
    (*op->op_option) += op->op_range->increment;
  }
      else if (data->key == W_MBUTTON)
  {
    (*op->op_option) = op->op_range->min_value;
  }
      else if (data->key == W_LBUTTON)
  {
    (*op->op_option) -= op->op_range->increment;
  }
      /* wrap value around within option range */
      if (*(op->op_option) > op->op_range->max_value)
  *(op->op_option) = op->op_range->min_value;
      if (*(op->op_option) < op->op_range->min_value)
  *(op->op_option) = op->op_range->max_value;
    }


  /* Is the option a toggle? */

#ifdef HAVE_XPM
  /* Bitwise Toggle  */

  else if ((op->op_option) && (op->op_size))
    {
      if (!(pixMissing & op->op_size))
  {
    *op->op_option ^= op->op_size;

    if (op->op_size & (NO_MAP_PIX | NO_BG_PIX | NO_HALOS))
      redrawall = 1;
  }
    }
#endif

  else if (op->op_option)
    {
      *op->op_option = !*op->op_option;

      /* Actions to be taken when certain options are selected. * (Yes, this
       * * is a hack). */

      if (op->op_option == &showPlanetOwner)
  redrawall = 1;
      else if (op->op_option == &partitionPlist)
  RedrawPlayerList();
      else if (op->op_option == &sortPlayers)
  RedrawPlayerList();
      else if (op->op_option == &sortMyTeamFirst)
  RedrawPlayerList();
    }

  /* Map/unmap window, if it exists */

  if (op->op_targetwin)
    {
      if (W_IsMapped(*op->op_targetwin))
  W_UnmapWindow(*op->op_targetwin);
      else
  {
    W_MapWindow(*op->op_targetwin);

    if (*op->op_targetwin == udpWin)
      udpwindow();
    if (*op->op_targetwin == pStats)
      redrawPStats();
    if (*op->op_targetwin == netstatWin)
      nswindow();
    if (*op->op_targetwin == spWin)
      spwindow();

#ifdef XTREKRC_HELP
    if (defWin && *op->op_targetwin == defWin)
      showdef();
#endif

#ifdef SOUND
    if (*op->op_targetwin == soundWin)
      soundwindow();
#endif

#ifdef DOC_WIN
    if (docwin && *op->op_targetwin == docwin)
      showdocs(0);

    if (xtrekrcwin && *op->op_targetwin == xtrekrcwin)
      showxtrekrc(0);
#endif
  }
    }

  /* deal with possible menu change */
  if (MenuPage != CurrentMenu->page_num)
    {
      SetMenuPage(MenuPage);
      RefreshOptions();
    }
  else if (notdone)
    optionrefresh(op);
  else
    {
      optionrefresh(op);
      optiondone();
    }

  return;
}
Esempio n. 6
0
static void hide_help()
{
  W_UnmapWindow(metaHelpWin);
}
Esempio n. 7
0
void sounddone(void) {

	W_UnmapWindow(soundWin);
	return;
}
void
new_entrywindow(int *team, int *s_type)
{
    int     i;
    int     lastplayercount[4];	/* number of players on each team */
    int     okayMask, lastOkayMask;	/* teams you're allowed to choose */
    char    buf[100];

    /* OUTFIT timeout stuff */
    long    startTime = -1;
    long    lasttime = -1;
    int     spareTime = 0;

    if (fastQuit) {
	*team = -1;
	return;
    }
    lastOkayMask = okayMask = tournMask;

    /* erase packet lights to make Bob happy [BDyess] */
    light_erase();

    /*
       map all team selection windows, and stripe out those that are
       unchoosable
    */
    for (i = 0; i < number_of_teams; i++) {
	W_MapWindow(teamWin[i]);
	lastplayercount[i] = -1;
    }
    W_MapWindow(qwin);

    /* no team selected yet */
    *team = -1;
    /*
       set to team index (0..n-1) to choose a team. set to n if you want to
       quit
    */

    /* I don't know why this restriction is in place - RF */
    if (me->p_whydead != KWINNER && me->p_whydead != KGENOCIDE) {
	showMotd(w);
	W_ClearWindow(mapw);
	showValues(mapw);
	redraw_death_messages();
    }
    do {

	/* set team to n if you want to quit */
	while (!W_EventsPending() && (me->p_status == POUTFIT ||
				      me->p_status == PTQUEUE)) {
	    /* no window events, just process socket stuff */
	    fd_set  mask;

	    light_erase();

	    readFromServer();

	    if (me->p_status == POUTFIT || me->p_status == PTQUEUE) {
		/* wait up to a half-second for input from the window system */
		struct timeval tv;

		tv.tv_sec = 0;
		tv.tv_usec = 500000;

		FD_ZERO(&mask);
		FD_SET(W_Socket(), &mask);
		select(W_Socket() + 1, &mask, 0, 0, &tv);
	    }

#if SHOW_MAP_AT_MOTD_DATA_ITEM_IMPLEMENTED
	    if(showMapAtMotd) {
		map();
	    }
#endif
	    redraw_death_messages();

	    if (me->p_status == PTQUEUE)
		startTime = -1;

	    if (me->p_status == POUTFIT) {
		/* time only elapses in OUTFIT mode */

		if (startTime == -1) {	/* we were on the tqueue */
		    /* I hate this [BDyess] */
		    W_Deiconify(baseWin);	/* we changed status.  alert
						   the user */
		    startTime = time(0);
		    spareTime = 480;	/* Allow them extra time, as long */
		    /* as they are active */
		}
		elapsed = time(0) - startTime;

		if (elapsed > autoQuit) {
		    printf("Auto-Quit.\n");
		    *team = number_of_teams;
		    break;
		}
	    }
	    if (lasttime != time(0)) {
		if (W_IsMapped(playerw))
		    playerlist2();

		if (newMotdStuff) {
		    showMotd(w);
			showValues(mapw);
		    redraw_death_messages();
		}
		if (me->p_status == POUTFIT) {
		    showTimeLeft(elapsed, autoQuit);
		}
		lasttime = time(0);
	    }
	    okayMask = tournMask;

	    /* redraw those windows whose choosable status has changed */
	    for (i = 0; i < number_of_teams; i++) {
		if ((okayMask ^ lastOkayMask) & (1 << i)) {
		    lastplayercount[i] = -1;	/* force update */
		}
		redrawTeam(teamWin[i], i, &lastplayercount[i]);
	    }
	    lastOkayMask = okayMask;
	}

	if (playback)  /* silly.  Shouldn't even be mapping team windows. */
	    break;
	/* they quit or ran out of time */
	if (*team == number_of_teams) {
	    me->p_status = PFREE;	/* exit outer while loop */
	    break;
	}
	/*
	   this makes them eventually run out of time no matter how awake
	   they are.  Only affects the OUTFIT screen.
	*/
	if (me->p_status == POUTFIT && startTime != -1) {
	    if (time(0) - startTime <= spareTime) {
		spareTime -= time(0) - startTime;
		startTime = time(0);
	    } else {
		startTime += spareTime;
		spareTime = 0;
	    }
	}
	if (!W_EventsPending())
	    continue;

	/* ok, there's a window event pending */

	/* thiswill set p_status to PFREE if they decide to quit */
	get_N_dispatch_outfit_event(team, s_type, lastplayercount);

    } while ((me->p_status == POUTFIT ||
	      me->p_status == PTQUEUE)
	     && (!pb_update)
	);

    if (*team >= 0) {
	strcpy(buf, "Welcome aboard ");
	if (paradise)
	    strcat(buf, ranks2[me->p_stats2.st_rank].name);
	else
	    strcat(buf, ranks[me->p_stats.st_rank].name);
	sprintf(buf, "Welcome aboard %s!", get_players_rank_name(me));
	warning(buf);
    }
    if (playback) {
	extern int lastTeamReq;
	*team = me->p_teami = lastTeamReq;
    } else
	/* if they quit or ran out of time */
    if (me->p_status == PFREE)
	*team = -1;
    else if (me->p_status == PALIVE ||
	     me->p_status == POBSERVE)
	if (*team == -1)
	    *team = me->p_teami;
	else
	    me->p_teami = *team;


    for (i = 0; i < number_of_teams; i++)
	W_UnmapWindow(teamWin[i]);
    W_UnmapWindow(qwin);
}
void
get_N_dispatch_outfit_event(int *team, int *s_type, int *lastplayercount)
{
    W_Event event;
    int     validshipletter = 0;
    static int resetting = 0;
    int     oldresetting;
    int     i;

    oldresetting = resetting;

    W_NextEvent(&event);
    switch ((int) event.type) {
    case W_EV_KEY:
	{
	    struct shiplist *shipscan;
	    validshipletter = 0;
	    shipscan = shiptypes;
	    while (shipscan) {
		if (shipscan->ship->s_letter == event.key) {
		    *s_type = shipscan->ship->s_type;
		    validshipletter = 1;
		    break;
		}
		shipscan = shipscan->next;
	    }
	}

	if (me->p_status == PTQUEUE) {
	    for (i = 0; i < WNUM; i++) {
		if (event.Window == messWin[i].window) {
		    messageWinEvent(&event);
		    break;
		}
	    }
	    if (i != WNUM)
		break;
	    if (event.Window == messagew ||
		event.Window == tstatw ||
		event.Window == warnw)
		smessage(event.key);
	}
	if (event.Window == motdWin) {
	    motdWinEvent(&event);
	    break;
	} else if (event.Window == playerw || event.Window == infow) {
	    /* allow 'i' 'I' and '^i' in playerw [BDyess] */
	    playerwEvent(&event);
	    break;
	} else if (event.Window == w || event.Window == mapw) {
	    switch (event.key) {
#ifdef Q_OUTFITTING
	    case 'q':
		*team = number_of_teams;
		me->p_status = PFREE;
		break;
#endif				/* Q_OUTFITTING */
	    case 'R':
		warning("Are you sure you want to reset your stats?");
		resetting = 1;
		break;
	    case 'y':
		if (resetting) {
		    sendResetStatsReq('Y');
		    warning("OK, your stats have been reset.");
		    resetting = 0;
		}
		break;
	    case 'n':
		if (resetting) {
		    warning("I didn't think so.");
		    resetting = 0;
		}
		break;

	    case 'f':		/* Scroll motd forward */
		if (currpage == NULL)
		    currpage = motddata;
		if (currpage == NULL || currpage->next == NULL)
		    break;
		currpage->next->prev = currpage;
		currpage = currpage->next;
		showMotd(w);
		resetting = 0;
		break;
	    case 'b':		/* Scroll motd backward */
		if (currpage == NULL || currpage->prev == NULL)
		    break;
		currpage = currpage->prev;
		showMotd(w);
		resetting = 0;
		break;
		/* ok, let's have some info windows available on the TQ */

	    default:		/* hmm, something that doesn't have to do
				   with the MOTD, maybe it's an info window
				   request */
		switch (doKeymap(&event)) {
		case 'U':	/* U = Rank list */
		    if (W_IsMapped(rankw)) {
			W_UnmapWindow(rankw);
		    } else {
			W_MapWindow(rankw);
		    }
		    break;
		case 'P':	/* P = Planet list */
		    if (W_IsMapped(planetw)) {
			W_UnmapWindow(planetw);
			W_UnmapWindow(planetw2);
		    } else {
			W_MapWindow(planetw);
			W_MapWindow(planetw2);
		    }
		    break;
		case 'h':	/* h = Map help window */
		    if (W_IsMapped(helpWin)) {
			W_UnmapWindow(helpWin);
		    } else {
			W_MapWindow(helpWin);
		    }
		    if (optionWin)
			optionredrawtarget(helpWin);
		    break;
		case 'O':	/* O = options Window */
		    if (optionWin != NULL && W_IsMapped(optionWin))
			optiondone();
		    else
			optionwindow();
		    break;
		case 'w':	/* w = map war stuff */
		    if (W_IsMapped(war))
			W_UnmapWindow(war);
		    else
			warwindow();
		    break;
		case '&':
		    if (defaultsFile) {
			char    buf[150];
			sprintf(buf, "Reading defaults from %s", defaultsFile);
			warning(buf);
			freeDefaults();
			defaultsFile = initDefaults(defaultsFile);
			resetDefaults();
		    } else {
			warning("No defaults file to read from!");
		    }
		}
		break;
	    }

	    break;		/* switch event type */
	}
	if (event.Window == qwin)
	    return;		/* normal keypresses can't make you quit */

	if (event.Window == optionWin) {
	    optionaction(&event);
	    return;
	}
	if (!validshipletter)
	    break;
	/*
	   it wasn't the main window, see if they hit the key in a team
	   window to choose their ship... falling through
	*/
    case W_EV_BUTTON:

	for (i = 0; i < number_of_teams; i++)
	    if (event.Window == teamWin[i]) {
		*team = i;
		break;
	    }
	if (event.Window == qwin) {
	    *team = number_of_teams;
	    me->p_status = PFREE;
	    break;
	}
	/* allow message scrollback [BDyess] */
	for (i = 0; i < WNUM; i++) {
	    if (event.Window == messWin[i].window) {
		messageWinEvent(&event);
		break;
	    }
	}
	/* allow bozo selection in playerw [BDyess] */
	if (event.Window == playerw) {
	    playerwEvent(&event);
	    break;
	} else if (event.Window == war)
	    waraction(&event);
	else if (event.Window == optionWin)
	    optionaction(&event);
	else if (event.Window == motdWin)
	    motdWinEvent(&event);
	else if (event.Window == w) {
	    W_Window tmp = motdWin;
	    motdWin = w;
	    motdWinEvent(&event);
	    motdWin = tmp;
	}
	if (*team != -1 && !teamRequest(*team, *s_type)) {
	    *team = -1;
	}
	break;
    case W_EV_EXPOSE:
	for (i = 0; i < number_of_teams; i++)
	    if (event.Window == teamWin[i]) {
		lastplayercount[i] = -1;	/* force update */
		redrawTeam(teamWin[i], i, &lastplayercount[i]);
		break;
	    }
	if (event.Window == qwin)
	    redrawQuit();
	else if (event.Window == w)
	    showMotd(w);
	else if (event.Window == mapw) {
		showValues(mapw);
	    redraw_death_messages();
	} else
	    /* let the normal expose handler figure out who to redraw */
	    dispatch_W_expose_event(&event);
	break;
    case W_EV_KILL_WINDOW:	/* WM_DESTROY_WINDOW support [BDyess] */
        if(event.Window == baseWin) exit(0);
	else W_UnmapWindow(event.Window);
	break;
    }

    if (oldresetting && resetting) {
	resetting = 0;
	warning("Resetting of stats cancelled");
    }
}
Esempio n. 10
0
void    nsaction(W_Event * data)
{
  char   *ns_get_nfthresh_s(void);
  int     v;
  register int i;
  register char *cp;

  switch (data->y)
    {

    case NETSTAT_SWITCH:
      if (data->type == W_EV_BUTTON)
  {
    if (netstat)
      {
        netstat = 0;
        W_UnmapWindow(lMeter);
      }
    else
      {
        netstat = 1;
        ns_init(5);
      }
  }
      nsrefresh(NETSTAT_SWITCH);
      break;

    case NETSTAT_RESET:
      if (data->type == W_EV_BUTTON)
  {
    ns_init(0);
    nsrefresh(NETSTAT_TOTAL);
    nsrefresh(NETSTAT_LOCAL);
    nsrefresh(NETSTAT_FAILURES);
  }
      break;

    case NETSTAT_NFTHRESH:
      if (data->type == W_EV_KEY)
  {
    switch (data->key)
      {
      case '\b':
      case '\177':
        cp = ns_get_nfthresh_s();
        i = strlen(cp);
        if (i > 0)
    {
      cp += i - 1;
      *cp = '\0';
    }
        break;
      case '\025':
      case '\030':
        ns_set_nfthresh_s("");
        break;

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



    case NETSTAT_DONE:
      if (data->type == W_EV_BUTTON)
  {
    if (sscanf(ns_get_nfthresh_s(), "%d", &v) != 1)
      {
        ns_set_nfthresh_s(NETSTAT_DF_NFT_S);
        ns_set_nfthresh(NETSTAT_DF_NFT);
      }
    else
      ns_set_nfthresh(v);

    nsdone();
  }
      break;
    }
}
Esempio n. 11
0
nsdone(void)
{
  /* Unmap window */
  W_UnmapWindow(netstatWin);
}
Esempio n. 12
0
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. 13
0
void
spdone(void)
{
    /* Unmap window */
    W_UnmapWindow(spWin);
}