Annotation of 43BSD/old/talk/init_disp.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1983 Regents of the University of California.
                      3:  * All rights reserved.  The Berkeley software License Agreement
                      4:  * specifies the terms and conditions for redistribution.
                      5:  */
                      6: 
                      7: #ifndef lint
                      8: static char sccsid[] = "@(#)init_disp.c        5.1 (Berkeley) 6/6/85";
                      9: #endif not lint
                     10: 
                     11: /*
                     12:  * Initialization code for the display package,
                     13:  * as well as the signal handling routines.
                     14:  */
                     15: 
                     16: #include "talk.h"
                     17: #include <signal.h>
                     18: 
                     19: /* 
                     20:  * Set up curses, catch the appropriate signals,
                     21:  * and build the various windows.
                     22:  */
                     23: init_display()
                     24: {
                     25:        void sig_sent();
                     26:        struct sigvec sigv;
                     27: 
                     28:        initscr();
                     29:        (void) sigvec(SIGTSTP, (struct sigvec *)0, &sigv);
                     30:        sigv.sv_mask |= sigmask(SIGALRM);
                     31:        (void) sigvec(SIGTSTP, &sigv, (struct sigvec *)0);
                     32:        curses_initialized = 1;
                     33:        clear();
                     34:        refresh();
                     35:        noecho();
                     36:        crmode();
                     37:        signal(SIGINT, sig_sent);
                     38:        signal(SIGPIPE, sig_sent);
                     39:        /* curses takes care of ^Z */
                     40:        my_win.x_nlines = LINES / 2;
                     41:        my_win.x_ncols = COLS;
                     42:        my_win.x_win = newwin(my_win.x_nlines, my_win.x_ncols, 0, 0);
                     43:        scrollok(my_win.x_win, FALSE);
                     44:        wclear(my_win.x_win);
                     45: 
                     46:        his_win.x_nlines = LINES / 2 - 1;
                     47:        his_win.x_ncols = COLS;
                     48:        his_win.x_win = newwin(his_win.x_nlines, his_win.x_ncols,
                     49:            my_win.x_nlines+1, 0);
                     50:        scrollok(his_win.x_win, FALSE);
                     51:        wclear(his_win.x_win);
                     52: 
                     53:        line_win = newwin(1, COLS, my_win.x_nlines, 0);
                     54:        box(line_win, '-', '-');
                     55:        wrefresh(line_win);
                     56:        /* let them know we are working on it */
                     57:        current_state = "No connection yet";
                     58: }
                     59: 
                     60: /*
                     61:  * Trade edit characters with the other talk. By agreement
                     62:  * the first three characters each talk transmits after
                     63:  * connection are the three edit characters.
                     64:  */
                     65: set_edit_chars()
                     66: {
                     67:        char buf[3];
                     68:        int cc;
                     69:        struct sgttyb tty;
                     70:        struct ltchars ltc;
                     71:        
                     72:        ioctl(0, TIOCGETP, &tty);
                     73:        ioctl(0, TIOCGLTC, (struct sgttyb *)&ltc);
                     74:        my_win.cerase = tty.sg_erase;
                     75:        my_win.kill = tty.sg_kill;
                     76:        if (ltc.t_werasc == (char) -1)
                     77:                my_win.werase = '\027';  /* control W */
                     78:        else
                     79:                my_win.werase = ltc.t_werasc;
                     80:        buf[0] = my_win.cerase;
                     81:        buf[1] = my_win.kill;
                     82:        buf[2] = my_win.werase;
                     83:        cc = write(sockt, buf, sizeof(buf));
                     84:        if (cc != sizeof(buf) )
                     85:                p_error("Lost the connection");
                     86:        cc = read(sockt, buf, sizeof(buf));
                     87:        if (cc != sizeof(buf) )
                     88:                p_error("Lost the connection");
                     89:        his_win.cerase = buf[0];
                     90:        his_win.kill = buf[1];
                     91:        his_win.werase = buf[2];
                     92: }
                     93: 
                     94: void
                     95: sig_sent()
                     96: {
                     97: 
                     98:        message("Connection closing. Exiting");
                     99:        quit();
                    100: }
                    101: 
                    102: /*
                    103:  * All done talking...hang up the phone and reset terminal thingy's
                    104:  */
                    105: quit()
                    106: {
                    107: 
                    108:        if (curses_initialized) {
                    109:                wmove(his_win.x_win, his_win.x_nlines-1, 0);
                    110:                wclrtoeol(his_win.x_win);
                    111:                wrefresh(his_win.x_win);
                    112:                endwin();
                    113:        }
                    114:        if (invitation_waiting)
                    115:                send_delete();
                    116:        exit(0);
                    117: }

unix.superglobalmegacorp.com

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