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 x

⟦2a6df7738⟧ TextFile

    Length: 2371 (0x943)
    Types: TextFile
    Names: »xmesg.c«

Derivation

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

TextFile

/*
 * $Header: xmesg.c,v 1.2 88/02/13 12:54:58 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 "xgo.h"

#define FontWidth 8
#define FD_INPUT 0

#define B(w,txt,v) XText(w, 5,(v) * fi->height,txt,strlen(txt),fi->id,WhitePixel,BlackPixel)
#define B1(w,txt,v,h) XText(w, 5 + h*FontWidth, (v) * fi->height,txt,strlen(txt),fi->id,WhitePixel,BlackPixel)

extern char *opponent;

int mesgx=0;
int mesgy=1;


int talkx=0;
int talky=1;

WindowInfo talkinfo,talk1info;

static char mesgbuf[1000];
char schar[2]=" ";
int cur= -1;
int curx=0;
int cury=1;
int mesflg;


int tcury;

initmesg()
{
	char t[100];
	sprintf(t,"-- Your messages (%s) --     ", (player ? "BLACK":"WHITE"));
	B(Wtalk,t,0);
	sprintf(t,"-- Opponent's messages (%s) --     ", (!player ? "BLACK":"WHITE"));
	B(Wtalk1,t,0);
	B(Wmesg,"-- Messages --     ",0);
}




addtalk(s)
char *s;
{
	WindowInfo wi;
	XQueryWindow(Wtalk1,&wi);
	B(Wtalk1,s,tcury+1);
	if(tcury++ == wi.height / fi->height -1) tcury=0;
	B(Wtalk1,blanks,tcury+1);
}

domesg(c)
char c;
{
	XQueryWindow(Wtalk,&talkinfo);
	XQueryWindow(Wtalk1,&talk1info);
	schar[0]=' ';
	B1(Wtalk,schar,cury,curx);
	if (c=='\b' || c=='\177') {
		delchar();
	} else if (c=='\n' || c=='\r') {
		if(cur>=0) {
			sendbuf();
			curx=0;
			if (cury++ == talkinfo.height / fi->height-1) cury=1;
			B1(Wtalk,blanks,cury,curx);
		}
	} else {
		addchar(c);
	}
	schar[0]='_';
	B1(Wtalk,schar,cury,curx);
}

addchar(c)
char c;
{
	schar[0]=c;
	mesgbuf[++cur] = c;
	B1(Wtalk,schar,cury,curx);
	if (curx++ == talkinfo.width / FontWidth) {
		curx=0;
		if (cury++ == talkinfo.height/fi->height-1) cury=1;
		B1(Wtalk,blanks,cury,curx);
		sendbuf();
	}
}

delchar()
{
	if (cur>=0 && curx>0) {
		curx--;
		cur--;
		B1(Wtalk," ",cury,curx);
	}
}

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