Annotation of 43BSDReno/games/chess/Xchess/message.c, revision 1.1.1.1

1.1       root        1: 
                      2: /* This file contains code for X-CHESS.
                      3:    Copyright (C) 1986 Free Software Foundation, Inc.
                      4: 
                      5: This file is part of X-CHESS.
                      6: 
                      7: X-CHESS is distributed in the hope that it will be useful,
                      8: but WITHOUT ANY WARRANTY.  No author or distributor
                      9: accepts responsibility to anyone for the consequences of using it
                     10: or for whether it serves any particular purpose or works at all,
                     11: unless he says so in writing.  Refer to the X-CHESS General Public
                     12: License for full details.
                     13: 
                     14: Everyone is granted permission to copy, modify and redistribute
                     15: X-CHESS, but only under the conditions described in the
                     16: X-CHESS General Public License.   A copy of this license is
                     17: supposed to have been given to you along with X-CHESS so you
                     18: can know your rights and responsibilities.  It should be in a
                     19: file named COPYING.  Among other things, the copyright notice
                     20: and this notice must be preserved on all copies.  */
                     21: 
                     22: 
                     23: /* RCS Info: $Revision: 1.4 $ on $Date: 86/11/26 12:10:22 $
                     24:  *           $Source: /users/faustus/xchess/RCS/message.c,v $
                     25:  * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
                     26:  *     Permission is granted to do anything with this code except sell it
                     27:  *     or remove this message.
                     28:  *
                     29:  * Do stuff with the message window.  Font 0 is the normal font, font 1
                     30:  * is large, and font 2 is normal red.
                     31:  */
                     32: 
                     33: #include "xchess.h"
                     34: 
                     35: #define MESSAGE_HEADER "\n1  XChess Messages0\n"
                     36: 
                     37: void
                     38: message_init(win)
                     39:        windata *win;
                     40: {
                     41:        TxtGrab(win->display, win->messagewin, "xchess", win->medium, 
                     42:                        win->textback.pixel, win->textcolor.pixel,
                     43:                                win->cursorcolor.pixel);
                     44:        TxtAddFont(win->display, win->messagewin, 1, win->large, win->textcolor.pixel);
                     45:        TxtAddFont(win->display, win->messagewin, 2, win->medium, win->errortext.pixel);
                     46:        TxtAddFont(win->display, win->messagewin, 3, win->medium, win->playertext.pixel);
                     47: 
                     48:        TxtWriteStr(win->display, win->messagewin, MESSAGE_HEADER);
                     49:        return;
                     50: }
                     51: 
                     52: void
                     53: message_add(win, string, err)
                     54:        windata *win;
                     55:        char *string;
                     56:        bool err;
                     57: {
                     58:        if (err) {
                     59:                TxtWriteStr(win->display, win->messagewin, "2");
                     60:                TxtWriteStr(win->display, win->messagewin, string);
                     61:                TxtWriteStr(win->display, win->messagewin, "0");
                     62:                XBell(win->display, 50);
                     63:        } else
                     64:                TxtWriteStr(win->display, win->messagewin, string);
                     65: 
                     66:        XSync(win->display, 0);
                     67:        return;
                     68: }
                     69: 
                     70: void
                     71: message_send(win, event)
                     72:        windata *win;
                     73:        XEvent *event;
                     74: {
                     75:        XKeyEvent *ev = &event->xkey;
                     76:        KeySym keysym;
                     77:        windata *ow = (win == win1) ? win2 : win1;
                     78:        char buf[BSIZE], *s;
                     79:        int i;
                     80: 
                     81:        i = XLookupString(ev, buf, sizeof(buf) - 1, &keysym, &s);
                     82:        buf[i] = '\0';
                     83:        for (s = buf; *s; s++)
                     84:                if (*s == '\r')
                     85:                        *s = '\n';
                     86:                else if (*s == '\177')
                     87:                        *s = '';
                     88: 
                     89:        TxtWriteStr(win->display, win->messagewin, "3");
                     90:        TxtWriteStr(win->display, win->messagewin, buf);
                     91:        TxtWriteStr(win->display, win->messagewin, "0");
                     92:        XSync(win->display, 0);
                     93:        if (ow) {
                     94:                TxtWriteStr(ow->display, ow->messagewin, "3");
                     95:                TxtWriteStr(ow->display, ow->messagewin, buf);
                     96:                TxtWriteStr(ow->display, ow->messagewin, "0");
                     97:                XSync(ow->display, 0);
                     98:        }
                     99:        return;
                    100: }
                    101: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.