DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T m

⟦316c02e0a⟧ TextFile

    Length: 1861 (0x745)
    Types: TextFile
    Names: »mesg.c«

Derivation

└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
    └─⟦this⟧ »EUUGD18/X/Xgo/mesg.c« 

TextFile

/*
 * $Header: mesg.c,v 1.2 88/02/13 12:50:27 hale Exp $
 */

/*

        Copyright 1987      Greg Hale

Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting
documentation.  No representations are made about the
suitability of this software for any purpose.  It is
provided "as is" without express or implied warranty.

*/


#include "go.h"

extern char *opponent;

int mesgx=42;
int mesgy=7;
int mesgx2=79;
int mesgy2=14;


int talkx=42;
int talky=16;
int talkx2=79;
int talky2=23;

static char mesgbuf[1000];
int cur;
int curx;
int cury;
int mesflg;

#define FD_INPUT 0

int tcury;

initmesg()
{
	mesflg=0;
	cur= -1;
	curx=mesgx;
	cury=mesgy;

	tcury=talky;


	mvprintw(0,mesgx,"   -- GO --");
	mvprintw(mesgy-1,mesgx,"   -- your messages --");
	mvprintw(talky-1,talkx,"   -- opponent --");
}

addtalk(s)
char *s;
{
	mvaddstr(tcury,talkx,s);
	if(tcury++ == talky2) tcury=talky;
	move(tcury,talkx);
	clrtoeol();
}

domesg(c)
char c;
{
	if (c=='\b' || c=='\177') {
		delchar();
	} else if (c=='\n') {
		if(cur>=0) {
			sendbuf();
			curx=mesgx;
			if (cury++ == mesgy2) cury=mesgy;
		} else {
			mesflg = 0;
			return(0);
		}
		move (cury,curx);
		clrtoeol();
	} else {
		addchar(c);
	}
	move (cury,curx);
}

addchar(c)
char c;
{
	mesgbuf[++cur] = c;
	mvaddch(cury,curx,c);
	if (curx++ == mesgx2) {
		curx=mesgx;
		if (cury++ == mesgy2) cury=mesgy;
		sendbuf();
	}
}

delchar()
{
	if (cur>=0 && curx>mesgx) {
		curx--;
		cur--;
		mvaddch(cury,curx,' ');
	}
}

sendbuf()
{
	mesgbuf[++cur] = '\0';
	SEND(MMESSAGE);
	SEND(mesgbuf);
	cur= -1;
}
/*
 * $Log:	mesg.c,v $
 * Revision 1.2  88/02/13  12:50:27  hale
 * added logging.
 * 
 */