view motdwin.c @ 3:5a977ccbc7a9 default tip

Empty changelog
author darius
date Sat, 06 Dec 1997 05:41:29 +0000
parents
children
line wrap: on
line source

/* $Id: motdwin.c,v 1.1.1.1 1997/12/06 05:41:29 darius Exp $ */

/***  Pop-up motd window code.  [BDyess] 11/21/93  ***/

#include <stdio.h>
#include <math.h>
#include <signal.h>
#include <sys/types.h>
#ifdef hpux
#include <time.h>
#else				/* hpux */
#include <sys/time.h>
#endif				/* hpux */
#include "Wlib.h"
#include "defs.h"
#include "struct.h"
#include "data.h"
#include "proto.h"
#ifdef SVR4
#include <string.h>
#else
#include <strings.h>
#endif

void
motdWinEvent(key)
    int     key;
/* handles keystrokes in the motd window */
{
    static  valuesOn = 0;

    switch (key) {
    case 'f':			/* scroll forward */
	if (currpage == NULL) {
	    currpage = motddata;
	    if (currpage == NULL)
		break;
	}
	if (currpage->next == NULL)
	    break;
	if (currpage->next)
	    currpage->next->prev = currpage;
	currpage = currpage->next;
	showMotd(motdWin);
	break;
    case 'b':			/* Scroll motd backward */
	if (currpage == NULL || currpage->prev == NULL)
	    break;
	currpage = currpage->prev;
	showMotd(motdWin);
	break;
    case ' ':			/* unmap window */
	showMotdWin();
	break;
    case '\t':			/* tab: swap between sysdef and motd */
	W_ClearWindow(motdWin);
	if (!valuesOn) {
	    showValues(motdWin);
	    valuesOn = 1;
	} else {
	    showMotd(motdWin);
	    valuesOn = 0;
	}
	break;
    case 'r':			/* refresh */
	if (valuesOn)
	    showValues(motdWin);
	else
	    showMotd(motdWin);
	break;
    }
}

void
showMotdWin()
/* handles map/unmap requests */
{
    if (!motdWin) {
	motdWin = W_MakeWindow(
			       "Motd"
			       ,-BORDER, -BORDER, WINSIDE, WINSIDE, NULL,
			       (char *) 0, BORDER, foreColor);
	W_MapWindow(motdWin);
	currpage = motddata;
	showMotd(motdWin);
    } else if (W_IsMapped(motdWin)) {
	W_UnmapWindow(motdWin);
    } else {
	W_MapWindow(motdWin);
	currpage = motddata;
	showMotd(motdWin);
    }
}