keane@ultima.cs.uts.oz.au (Chris Keane) (06/09/90)
Submitted-by: keane@ultima.cs.uts.oz.au (Chris Keane) Posting-number: Volume 7, Issue 87 Archive-name: xdm/patch1.02 Patch-To: xdm: Volume XXX, Issue XXX #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of shell archive." # Contents: ptyx.h xroutines.c # Wrapped by keane@zeus on Fri Jun 8 16:34:39 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'ptyx.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ptyx.h'\" else echo shar: Extracting \"'ptyx.h'\" \(15008 characters\) sed "s/^X//" >'ptyx.h' <<'END_OF_FILE' X/* X * $XConsortium: ptyx.h,v 1.18 88/10/07 14:12:29 swick Exp $ X */ X X#include <X11/copyright.h> X X/* X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. X * X * All Rights Reserved X * X * Permission to use, copy, modify, and distribute this software and its X * documentation for any purpose and without fee is hereby granted, X * provided that the above copyright notice appear in all copies and that X * both that copyright notice and this permission notice appear in X * supporting documentation, and that the name of Digital Equipment X * Corporation not be used in advertising or publicity pertaining to X * distribution of the software without specific, written prior permission. X * X * X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS X * SOFTWARE. X */ X X/* ptyx.h */ X/* @(#)ptyx.h X10/6.6 11/10/86 */ X X#include <X11/Xos.h> X#include <X11/Xlib.h> X#include <X11/IntrinsicP.h> X X/* Extra Xlib definitions */ X#define AllButtonsUp(detail, ignore) (\ X ((ignore) == Button1) ? \ X (((detail)&(Button2Mask|Button3Mask)) == 0) \ X : \ X (((ignore) == Button2) ? \ X (((detail)&(Button1Mask|Button3Mask)) == 0) \ X : \ X (((detail)&(Button1Mask|Button2Mask)) == 0)) \ X ) X X X#define Max(i, j) ((i) > (j) ? (i) : (j)) X#define Min(i, j) ((i) < (j) ? (i) : (j)) X X#define MAX_COLS 200 X#define MAX_ROWS 128 X X/* X** System V definitions X*/ X X#ifdef SYSV X X#ifdef JOBCONTROL X#define getpgrp getpgrp2 X#else /* !JOBCONTROL */ X#define getpgrp(x) (x) X#endif /* !JOBCONTROL */ X X#define killpg(x,sig) kill(-x,sig) X X#define dup2(fd1,fd2) ((fd1 == fd2) ? fd1 : \ X (close(fd2), fcntl(fd1, F_DUPFD, fd2))) X X#endif /* !SYSV */ X X/* X** allow for mobility of the pty master/slave directories X*/ X#ifndef PTYDEV X#ifdef hpux X#define PTYDEV "/dev/ptym/ptyxx" X#else /* !hpux */ X#define PTYDEV "/dev/ptyxx" X#endif /* !hpux */ X#endif /* !PTYDEV */ X X#ifndef TTYDEV X#ifdef hpux X#define TTYDEV "/dev/pty/ttyxx" X#else /* !hpux */ X#define TTYDEV "/dev/ttyxx" X#endif /* !hpux */ X#endif /* !TTYDEV */ X X#ifndef PTYCHAR1 X#ifdef hpux X#define PTYCHAR1 "zyxwvutsrqp" X#else /* !hpux */ X#define PTYCHAR1 "pqrstuvwxyz" X#endif /* !hpux */ X#endif /* !PTYCHAR1 */ X X#ifndef PTYCHAR2 X#ifdef hpux X#define PTYCHAR2 "fedcba9876543210" X#else /* !hpux */ X#define PTYCHAR2 "0123456789abcdef" X#endif /* !hpux */ X#endif /* !PTYCHAR2 */ X X/* Until the translation manager comes along, I have to do my own translation of X * mouse events into the proper routines. */ X Xtypedef enum {NORMAL, LEFTEXTENSION, RIGHTEXTENSION} EventMode; X X/* X * The origin of a screen is 0, 0. Therefore, the number of rows X * on a screen is screen->max_row + 1, and similarly for columns. X */ X Xtypedef char **ScrnBuf; X X/* X * ANSI emulation. X */ X#define INQ 0x05 X#define FF 0x0C /* C0, C1 control names */ X#define LS1 0x0E X#define LS0 0x0F X#define CAN 0x18 X#define SUB 0x1A X#define ESC 0x1B X#define US 0x1F X#define DEL 0x7F X#define HTS ('H'+0x40) X#define SS2 0x8E X#define SS3 0x8F X#define DCS 0x90 X#define OLDID 0x9A /* ESC Z */ X#define CSI 0x9B X#define ST 0x9C X#define OSC 0x9D X#define PM 0x9E X#define APC 0x9F X#define RDEL 0xFF X X#define NBOX 5 /* Number of Points in box */ X#define NPARAM 10 /* Max. parameters */ X X#define MINHILITE 32 X Xtypedef struct { X unsigned char a_type; X unsigned char a_pintro; X unsigned char a_final; X unsigned char a_inters; X char a_nparam; /* # of parameters */ X char a_dflt[NPARAM]; /* Default value flags */ X short a_param[NPARAM]; /* Parameters */ X char a_nastyf; /* Error flag */ X} ANSI; X Xtypedef struct { X int row; X int col; X unsigned flags; /* Vt100 saves graphics rendition. Ugh! */ X char curgl; X char curgr; X char gsets[4]; X} SavedCursor; X X#define TEKNUMFONTS 4 X/* Actually there are 5 types of lines, but four are non-solid lines */ X#define TEKNUMLINES 4 X Xtypedef struct { X int x; X int y; X int fontsize; X int linetype; X} Tmodes; X Xtypedef struct { X int Twidth; X int Theight; X} T_fontsize; X Xtypedef struct { X short *bits; X int x; X int y; X int width; X int height; X} BitmapBits; X X#define SAVELINES 64 /* default # lines to save */ X Xtypedef struct { X/* These parameters apply to both windows */ X Display *display; /* X display for screen */ X int respond; /* socket for responses X (position report, etc.) */ X long pid; /* pid of process on far side */ X int uid; /* user id of actual person */ X int gid; /* group id of actual person */ X GC normalGC; /* normal painting */ X GC reverseGC; /* reverse painting */ X GC normalboldGC; /* normal painting, bold font */ X GC reverseboldGC; /* reverse painting, bold font */ X GC cursorGC; /* normal cursor painting */ X GC reversecursorGC;/* reverse cursor painting */ X GC cursoroutlineGC;/* for painting lines around */ X Pixel foreground; /* foreground color */ X Pixel cursorcolor; /* Cursor color */ X Pixel mousecolor; /* Mouse color */ X int border; /* inner border */ X Pixmap graybordertile; /* tile pixmap for border when X window is unselected */ X Cursor arrow; /* arrow cursor */ X unsigned short send_mouse_pos; /* user wants mouse transition */ X /* and position information */ X int select; /* xterm selected */ X Boolean visualbell; /* visual bell mode */ X int logging; /* logging mode */ X int logfd; /* file descriptor of log */ X char *logfile; /* log file name */ X char *logstart; /* current start of log buffer */ X int inhibit; /* flags for inhibiting changes */ X X/* VT window parameters */ X struct { X Window window; /* X window id */ X int width; /* width of columns */ X int height; /* height of rows */ X int fullwidth; /* full width of window */ X int fullheight; /* full height of window */ X int f_width; /* width of fonts in pixels */ X int f_height; /* height of fonts in pixels */ X } fullVwin; X Cursor pointer_cursor; /* pointer cursor in window */ X X /* Terminal fonts must be of the same size and of fixed width */ X XFontStruct *fnt_norm; /* normal font of terminal */ X XFontStruct *fnt_bold; /* bold font of terminal */ X int enbolden; /* overstrike for bold font */ X XPoint *box; /* draw unselected cursor */ X X int cursor_state; /* ON or OFF */ X int cursor_set; /* requested state */ X int cursor_col; /* previous cursor column */ X int cursor_row; /* previous cursor row */ X int cur_col; /* current cursor column */ X int cur_row; /* current cursor row */ X int max_col; /* rightmost column */ X int max_row; /* bottom row */ X int top_marg; /* top line of scrolling region */ X int bot_marg; /* bottom line of " " */ X Widget scrollWidget; /* pointer to scrollbar struct */ X int scrollbar; /* if > 0, width of scrollbar, and X scrollbar is showing */ X int topline; /* line number of top, <= 0 */ X int savedlines; /* number of lines that've been saved */ X int savelines; /* number of lines off top to save */ X Boolean scrollinput; /* scroll to bottom on input */ X Boolean scrollkey; /* scroll to bottom on key */ X X ScrnBuf buf; /* screen buffer (main) */ X ScrnBuf allbuf; /* screen buffer (may include X lines scrolled off top */ X ScrnBuf altbuf; /* alternate screen buffer */ X Boolean alternate; /* true if using alternate buf */ X unsigned short do_wrap; /* true if cursor in last column X and character just output */ X int incopy; /* 0 if no RasterCopy exposure X event processed since last X RasterCopy */ X Boolean c132; /* allow change to 132 columns */ X Boolean curses; /* cludge-ups for more and vi */ X Boolean marginbell; /* true if margin bell on */ X int nmarginbell; /* columns from right margin */ X int bellarmed; /* cursor below bell margin */ X Boolean multiscroll; /* true if multi-scroll */ X int scrolls; /* outstanding scroll count */ X SavedCursor sc; /* data for restore cursor */ X int save_modes[19]; /* save dec private modes */ X X /* Improved VT100 emulation stuff. */ X char gsets[4]; /* G0 through G3. */ X char curgl; /* Current GL setting. */ X char curgr; /* Current GR setting. */ X char curss; /* Current single shift. */ X int scroll_amt; /* amount to scroll */ X int refresh_amt; /* amount to refresh */ X Boolean jumpscroll; /* whether we should jumpscroll */ X Boolean always_highlight; /* whether to highlight cursor */ X X/* Tektronix window parameters */ X GC TnormalGC; /* normal painting */ X GC TcursorGC; /* normal cursor painting */ X Pixel Tforeground; /* foreground color */ X Pixel Tbackground; /* Background color */ X Pixel Tcursorcolor; /* Cursor color */ X Pixmap Tbgndtile; /* background tile pixmap */ X int Tcolor; /* colors used */ X Boolean planeused; /* is xorplane being used */ X Boolean cellsused; /* are color cells being used */ X XColor colorcells[3]; /* color cells for Tek */ X Boolean Vshow; /* VT window showing */ X Boolean Tshow; /* Tek window showing */ X Boolean waitrefresh; /* postpone refresh */ X struct { X Window window; /* X window id */ X int width; /* width of columns */ X int height; /* height of rows */ X int fullwidth; /* full width of window */ X int fullheight; /* full height of window */ X double tekscale; /* scale factor Tek -> vs100 */ X } fullTwin; X XPoint **Tbox; /* draw unselected cursor */ X int xorplane; /* z plane for inverts */ X GC linepat[TEKNUMLINES]; /* line patterns */ X XFontStruct *Tfont[TEKNUMFONTS]; /* Tek fonts */ X int tobaseline[TEKNUMFONTS]; /* top to baseline for X each font */ X Boolean TekEmu; /* true if Tektronix emulation */ X int cur_X; /* current x */ X int cur_Y; /* current y */ X Tmodes cur; /* current tek modes */ X Tmodes page; /* starting tek modes on page */ X int margin; /* 0 -> margin 1, 1 -> margin 2 */ X int pen; /* current Tektronix pen 0=up, 1=dn */ X char *TekGIN; /* nonzero if Tektronix GIN mode*/ X int multiClickTime; /* time between multiclick selects */ X char *charClass; /* for overriding word selection */ X Boolean cutNewline; /* whether or not line cut has \n */ X Boolean cutToBeginningOfLine; /* line cuts to BOL? */ X char *selection; /* the current selection */ X int selection_size; /* size of allocated buffer */ X int selection_length; /* number of significant bytes */ X int selection_time; /* latest event timestamp */ X int startHRow, startHCol, /* highlighted text */ X endHRow, endHCol, X startHCoord, endHCoord; X Atom* selection_atoms; /* which selections we own */ X Cardinal sel_atoms_size; /* how many atoms allocated */ X Cardinal selection_count; /* how many atoms in use */ X} TScreen; X X/* meaning of bits in screen.select flag */ X#define INWINDOW 01 /* the mouse is in one of the windows */ X#define FOCUS 02 /* one of the windows is the focus window */ X X#define MULTICLICKTIME 250 /* milliseconds */ X Xtypedef struct X{ X unsigned flags; X} TKeyboard; X Xtypedef struct _Misc { X char *geo_metry; X char *T_geometry; X char *f_n; X char *f_b; X Boolean log_on; X Boolean login_shell; X Boolean re_verse; X Boolean reverseWrap; X Boolean logInhibit; X Boolean signalInhibit; X Boolean tekInhibit; X Boolean scrollbar; X Boolean titeInhibit; X} Misc; X Xtypedef struct {int foo;} XtermClassPart, TekClassPart; X Xtypedef struct _XtermClassRec { X CoreClassPart core_class; X XtermClassPart xterm_class; X} XtermClassRec; X Xtypedef struct _TekClassRec { X CoreClassPart core_class; X TekClassPart tek_class; X} TekClassRec; X X/* define masks for flags */ X#define CAPS_LOCK 0x01 X#define KYPD_APL 0x02 X#define CURSOR_APL 0x04 X X X#define N_MARGINBELL 10 X#define MAX_TABS 320 X#define TAB_ARRAY_SIZE 10 /* number of ints to provide MAX_TABS bits */ X Xtypedef unsigned Tabs [TAB_ARRAY_SIZE]; X Xtypedef struct _XtermWidgetRec { X CorePart core; X TKeyboard keyboard; /* terminal keyboard */ X TScreen screen; /* terminal screen */ X unsigned flags; /* mode flags */ X unsigned initflags; /* initial mode flags */ X Tabs tabs; /* tabstops of the terminal */ X Misc misc; /* miscelaneous parameters */ X} XtermWidgetRec, *XtermWidget; X Xtypedef struct _TekWidgetRec { X CorePart core; X} TekWidgetRec, *TekWidget; X X#define BUF_SIZE 4096 X X/* masks for terminal flags */ X X#define INVERSE 0x01 /* invert the characters to be output */ X#define UNDERLINE 0x02 /* true if underlining */ X#define BOLD 0x04 X#define WRAPAROUND 0x08 X#define REVERSE_VIDEO 0x10 /* true if screen white on black */ X#define ORIGIN 0x20 /* true if in origin mode */ X#define INSERT 0x40 /* true if in insert mode */ X#define SMOOTHSCROLL 0x80 /* true if in smooth scroll mode */ X#ifdef DO_AUTOREPEAT X#define AUTOREPEAT 0x100 /* true if in autorepeat mode */ X#endif /* DO_AUTOREPEAT */ X#define IN132COLUMNS 0x200 /* true if in 132 column mode */ X#define LINEFEED 0x400 X#define REVERSEWRAP 0x800 /* true if reverse wraparound mode */ X X#define ATTRIBUTES 0x07 /* attributes mask */ X#define CHAR 0177 X X#define VWindow(screen) (screen->fullVwin.window) X#define VShellWindow term->core.parent->core.window X#define TextWindow(screen) (screen->fullVwin.window) X#define TWindow(screen) (screen->fullTwin.window) X#define TShellWindow tekWidget->core.parent->core.window X#define Width(screen) (screen->fullVwin.width) X#define Height(screen) (screen->fullVwin.height) X#define FullWidth(screen) (screen->fullVwin.fullwidth) X#define FullHeight(screen) (screen->fullVwin.fullheight) X#define FontWidth(screen) (screen->fullVwin.f_width) X#define FontHeight(screen) (screen->fullVwin.f_height) X#define TWidth(screen) (screen->fullTwin.width) X#define THeight(screen) (screen->fullTwin.height) X#define TFullWidth(screen) (screen->fullTwin.fullwidth) X#define TFullHeight(screen) (screen->fullTwin.fullheight) X#define TekScale(screen) (screen->fullTwin.tekscale) X X#define CursorX(screen,col) ((col) * FontWidth(screen) + screen->border \ X + screen->scrollbar) X#define CursorY(screen,row) ((((row) - screen->topline) * FontHeight(screen)) \ X + screen->border) X X#define TWINDOWEVENTS (KeyPressMask | ExposureMask | ButtonPressMask |\ X ButtonReleaseMask | StructureNotifyMask |\ X EnterWindowMask | LeaveWindowMask | FocusChangeMask) X X#define WINDOWEVENTS (TWINDOWEVENTS | PointerMotionMask) X X X#define TEK_LINK_BLOCK_SIZE 1024 X Xtypedef struct Tek_Link X{ X struct Tek_Link *next; /* pointer to next TekLink in list X NULL <=> this is last TekLink */ X short count; X char *ptr; X char data [TEK_LINK_BLOCK_SIZE]; X} TekLink; X X/* flags for cursors */ X#define OFF 0 X#define ON 1 X#define CLEAR 0 X#define TOGGLE 1 X X/* flags for inhibit */ X#define I_LOG 0x01 X#define I_SIGNAL 0x02 X#define I_TEK 0x04 X Xextern Cursor make_tcross(); Xextern Cursor make_xterm(); Xextern Cursor make_wait(); Xextern Cursor make_arrow(); END_OF_FILE if test 15008 -ne `wc -c <'ptyx.h'`; then echo shar: \"'ptyx.h'\" unpacked with wrong size! fi # end of 'ptyx.h' fi if test -f 'xroutines.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xroutines.c'\" else echo shar: Extracting \"'xroutines.c'\" \(2773 characters\) sed "s/^X//" >'xroutines.c' <<'END_OF_FILE' X#include "xdmconsole.h" X XDisplay *disp; XWindow win; XGC wingc; XXFontStruct *font; XXEvent thebigevent; XXSizeHints hinthint; XCursor wincurs, opwincurs; Xint screen; Xlong foreg, backg; Xint winw, winh; X X Xint initwin(width, height, x, y, border, trans, name) Xint width, height, x, y, border, trans; Xchar *name; X{ X X if (win > 0) return(-1); X X if ((disp = XOpenDisplay("unix:0.0")) == NULL) exit(0); X screen=DefaultScreen(disp); X X if (x < 0) x = (int) ((DisplayWidth(disp, screen) - width) /2); X if (y < 0) y = (int) (DisplayHeight(disp, screen) - (height + 30)); X X backg=WhitePixel(disp, screen); X foreg=BlackPixel(disp, screen); X X win=XCreateSimpleWindow(disp, DefaultRootWindow(disp), X x, y, width, height, X border, foreg, backg); X X wingc=XCreateGC(disp, win, 0, 0); X XSetBackground(disp, wingc, backg); X XSetForeground(disp, wingc, foreg); X X XStoreName(disp, win, name); X X if (trans) XSetTransientForHint(disp, win, win); X winh=height; X winw=width; X} X Xint winfont(fontname) Xchar *fontname; X{ X int ndirs; X char **dir; X X dir = XGetFontPath(disp, &ndirs); X dir[ndirs] = (char *) malloc(sizeof("/usr/lib/X11/fonts/75dpi")+2); X strcpy(dir[ndirs++], "/usr/lib/X11/fonts/75dpi"); X XSetFontPath(disp, dir, ndirs); X font=XLoadQueryFont(disp, fontname); X XSetFont(disp, wingc, font->fid); X XFreeFontPath(dir); X} X Xint wincursor(cursor) Xchar *cursor; X{ X wincurs=XCreateFontCursor(disp, XC_gumby); X XDefineCursor(disp, win, wincurs); X} X Xint winevents(event) Xlong event; X{ X XSelectInput(disp, win, event); X} X X Xint winprint(x, y, string) Xint x, y; Xchar *string; X{ X XDrawString(disp, win, wingc, x, y, string, strlen(string)); X XFlush(disp); X} X Xint winwrapprint(x, y, string, inc) Xint x, y; Xchar *string; Xint inc; X{ X int count=0; X if (XTextWidth(font, string, strlen(string)) > winw) X { X for (count=strlen(string); XTextWidth(font, string, count) > winw; count--); X XDrawString(disp, win, wingc, x, y, string, count); X scrollup(inc); X XDrawString(disp, win, wingc, x, y, &string[count+1], strlen(&string[count+1])); X XFlush(disp); X return(1); X } X XDrawString(disp, win, wingc, x, y, string, strlen(string)); X XFlush(disp); X return(0); X} X Xint showwin() X{ X XMapRaised(disp, win); X XFlush(disp); X XNextEvent(disp, &thebigevent); X} X Xint clearwin() X{ X XClearWindow(disp, win); X} X Xint scrollup(lineheight) Xint lineheight; X{ X int x, y, height, width; X X x=0; X y=lineheight; X width=winw; X height=winh-lineheight; X XCopyArea(disp, win, win, wingc, x, y, width, height, 0, 0); X XClearArea(disp, win, 0, height, width, lineheight, False); X XFlush(disp); X} X Xint windeath() X{ X XFreeFont(disp, font); X XFreeGC(disp, wingc); X XDestroyWindow(disp, win); X win = 0; X XCloseDisplay(disp); X} END_OF_FILE if test 2773 -ne `wc -c <'xroutines.c'`; then echo shar: \"'xroutines.c'\" unpacked with wrong size! fi # end of 'xroutines.c' fi echo shar: End of shell archive. exit 0 dan ---------------------------------------------------- O'Reilly && Associates argv@sun.com / argv@ora.com Opinions expressed reflect those of the author only.